sunpeak 0.16.27 → 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 (87) hide show
  1. package/bin/commands/build.mjs +0 -1
  2. package/dist/chatgpt/globals.css +10 -9
  3. package/dist/chatgpt/index.cjs +55 -24
  4. package/dist/chatgpt/index.cjs.map +1 -1
  5. package/dist/chatgpt/index.js +31 -25
  6. package/dist/chatgpt/index.js.map +1 -1
  7. package/dist/chunk-9hOWP6kD.cjs +64 -0
  8. package/dist/chunk-D6g4UhsZ.js +35 -0
  9. package/dist/claude/index.cjs +4 -4
  10. package/dist/claude/index.js +3 -5
  11. package/dist/discovery-BxKCIgG5.cjs +332 -0
  12. package/dist/discovery-BxKCIgG5.cjs.map +1 -0
  13. package/dist/discovery-Du4LHrih.js +261 -0
  14. package/dist/discovery-Du4LHrih.js.map +1 -0
  15. package/dist/host/chatgpt/index.cjs +171 -65
  16. package/dist/host/chatgpt/index.cjs.map +1 -1
  17. package/dist/host/chatgpt/index.js +170 -70
  18. package/dist/host/chatgpt/index.js.map +1 -1
  19. package/dist/host/index.cjs +47 -19
  20. package/dist/host/index.cjs.map +1 -1
  21. package/dist/host/index.js +47 -24
  22. package/dist/host/index.js.map +1 -1
  23. package/dist/index.cjs +3103 -3725
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.js +3026 -3746
  26. package/dist/index.js.map +1 -1
  27. package/dist/lib/discovery-cli.cjs +117 -131
  28. package/dist/lib/discovery-cli.cjs.map +1 -1
  29. package/dist/lib/discovery-cli.js +107 -111
  30. package/dist/lib/discovery-cli.js.map +1 -1
  31. package/dist/mcp/index.cjs +9818 -10283
  32. package/dist/mcp/index.cjs.map +1 -1
  33. package/dist/mcp/index.js +9799 -10282
  34. package/dist/mcp/index.js.map +1 -1
  35. package/dist/protocol-DJmRaBzO.js +11080 -0
  36. package/dist/{protocol-DkDHRwOW.cjs.map → protocol-DJmRaBzO.js.map} +1 -1
  37. package/dist/protocol-jbxhzcnS.cjs +11493 -0
  38. package/dist/protocol-jbxhzcnS.cjs.map +1 -0
  39. package/dist/simulator/index.cjs +79 -36
  40. package/dist/simulator/index.cjs.map +1 -1
  41. package/dist/simulator/index.js +43 -37
  42. package/dist/simulator/index.js.map +1 -1
  43. package/dist/simulator-BYIH-xqQ.cjs +3701 -0
  44. package/dist/{simulator-Gc6n_fT4.cjs.map → simulator-BYIH-xqQ.cjs.map} +1 -1
  45. package/dist/simulator-CmgNnWBO.js +3575 -0
  46. package/dist/simulator-CmgNnWBO.js.map +1 -0
  47. package/dist/simulator-url-BDGD4vZD.cjs +69 -0
  48. package/dist/simulator-url-BDGD4vZD.cjs.map +1 -0
  49. package/dist/simulator-url-Bkxj43yT.js +64 -0
  50. package/dist/simulator-url-Bkxj43yT.js.map +1 -0
  51. package/dist/style.css +10 -9
  52. package/dist/use-app-D2h-aiyr.cjs +940 -0
  53. package/dist/use-app-D2h-aiyr.cjs.map +1 -0
  54. package/dist/use-app-X7JbGskk.js +598 -0
  55. package/dist/use-app-X7JbGskk.js.map +1 -0
  56. package/package.json +8 -8
  57. package/template/node_modules/.bin/vite +2 -2
  58. package/template/node_modules/.bin/vitest +2 -2
  59. package/template/package.json +5 -5
  60. package/dist/claude/index.cjs.map +0 -1
  61. package/dist/claude/index.js.map +0 -1
  62. package/dist/discovery-BVqD-JsT.js +0 -224
  63. package/dist/discovery-BVqD-JsT.js.map +0 -1
  64. package/dist/discovery-D1gpaVz4.cjs +0 -223
  65. package/dist/discovery-D1gpaVz4.cjs.map +0 -1
  66. package/dist/index-BEWVLFfB.cjs +0 -28
  67. package/dist/index-BEWVLFfB.cjs.map +0 -1
  68. package/dist/index-C6XYFOmh.js +0 -29
  69. package/dist/index-C6XYFOmh.js.map +0 -1
  70. package/dist/index-D0FsXP3Y.cjs +0 -40
  71. package/dist/index-D0FsXP3Y.cjs.map +0 -1
  72. package/dist/index-Rg7SWjvl.js +0 -41
  73. package/dist/index-Rg7SWjvl.js.map +0 -1
  74. package/dist/protocol-DkDHRwOW.cjs +0 -12221
  75. package/dist/protocol-uge7qFev.js +0 -12223
  76. package/dist/protocol-uge7qFev.js.map +0 -1
  77. package/dist/simulator-B-CrMHVs.js +0 -3534
  78. package/dist/simulator-B-CrMHVs.js.map +0 -1
  79. package/dist/simulator-Gc6n_fT4.cjs +0 -3549
  80. package/dist/simulator-url-DcSYRl-P.cjs +0 -53
  81. package/dist/simulator-url-DcSYRl-P.cjs.map +0 -1
  82. package/dist/simulator-url-j_XV3EoP.js +0 -54
  83. package/dist/simulator-url-j_XV3EoP.js.map +0 -1
  84. package/dist/use-app-C9gpzIQO.js +0 -349
  85. package/dist/use-app-C9gpzIQO.js.map +0 -1
  86. package/dist/use-app-D09O2swh.cjs +0 -348
  87. package/dist/use-app-D09O2swh.cjs.map +0 -1
@@ -0,0 +1,940 @@
1
+ require("./chunk-9hOWP6kD.cjs");
2
+ const require_protocol = require("./protocol-jbxhzcnS.cjs");
3
+ let react = require("react");
4
+ let react_jsx_runtime = require("react/jsx-runtime");
5
+ //#region ../../node_modules/.pnpm/@modelcontextprotocol+ext-apps@1.2.2_@modelcontextprotocol+sdk@1.27.1_zod@4.3.6__react-_e9bf7657371391a829fe8b4e289b253c/node_modules/@modelcontextprotocol/ext-apps/dist/src/app.js
6
+ var L = "2026-01-26", d = "ui/open-link", h = "ui/download-file", m = "ui/message", p = "ui/notifications/size-changed", r = "ui/notifications/tool-input", W = "ui/notifications/tool-input-partial", l = "ui/notifications/tool-result", n = "ui/notifications/tool-cancelled", a = "ui/notifications/host-context-changed", o = "ui/resource-teardown", s = "ui/initialize", e = "ui/notifications/initialized", t = "ui/request-display-mode";
7
+ var K = class {
8
+ eventTarget;
9
+ eventSource;
10
+ messageListener;
11
+ constructor(X = window.parent, Y) {
12
+ this.eventTarget = X;
13
+ this.eventSource = Y;
14
+ this.messageListener = (Z) => {
15
+ if (Y && Z.source !== this.eventSource) {
16
+ console.debug("Ignoring message from unknown source", Z);
17
+ return;
18
+ }
19
+ let $ = require_protocol.JSONRPCMessageSchema.safeParse(Z.data);
20
+ if ($.success) console.debug("Parsed message", $.data), this.onmessage?.($.data);
21
+ else if (Z.data?.jsonrpc !== "2.0") console.debug("Ignoring non-JSON-RPC message", $.error.message, Z);
22
+ else console.error("Failed to parse message", $.error.message, Z), this.onerror?.(Error("Invalid JSON-RPC message received: " + $.error.message));
23
+ };
24
+ }
25
+ async start() {
26
+ window.addEventListener("message", this.messageListener);
27
+ }
28
+ async send(X, Y) {
29
+ if (X.method !== "ui/notifications/tool-input-partial") console.debug("Sending message", X);
30
+ this.eventTarget.postMessage(X, "*");
31
+ }
32
+ async close() {
33
+ window.removeEventListener("message", this.messageListener), this.onclose?.();
34
+ }
35
+ onclose;
36
+ onerror;
37
+ onmessage;
38
+ sessionId;
39
+ setProtocolVersion;
40
+ }, k = require_protocol.union([require_protocol.literal("light"), require_protocol.literal("dark")]).describe("Color theme preference for the host environment."), J = require_protocol.union([
41
+ require_protocol.literal("inline"),
42
+ require_protocol.literal("fullscreen"),
43
+ require_protocol.literal("pip")
44
+ ]).describe("Display mode for UI presentation."), JQ = require_protocol.union([
45
+ require_protocol.literal("--color-background-primary"),
46
+ require_protocol.literal("--color-background-secondary"),
47
+ require_protocol.literal("--color-background-tertiary"),
48
+ require_protocol.literal("--color-background-inverse"),
49
+ require_protocol.literal("--color-background-ghost"),
50
+ require_protocol.literal("--color-background-info"),
51
+ require_protocol.literal("--color-background-danger"),
52
+ require_protocol.literal("--color-background-success"),
53
+ require_protocol.literal("--color-background-warning"),
54
+ require_protocol.literal("--color-background-disabled"),
55
+ require_protocol.literal("--color-text-primary"),
56
+ require_protocol.literal("--color-text-secondary"),
57
+ require_protocol.literal("--color-text-tertiary"),
58
+ require_protocol.literal("--color-text-inverse"),
59
+ require_protocol.literal("--color-text-ghost"),
60
+ require_protocol.literal("--color-text-info"),
61
+ require_protocol.literal("--color-text-danger"),
62
+ require_protocol.literal("--color-text-success"),
63
+ require_protocol.literal("--color-text-warning"),
64
+ require_protocol.literal("--color-text-disabled"),
65
+ require_protocol.literal("--color-border-primary"),
66
+ require_protocol.literal("--color-border-secondary"),
67
+ require_protocol.literal("--color-border-tertiary"),
68
+ require_protocol.literal("--color-border-inverse"),
69
+ require_protocol.literal("--color-border-ghost"),
70
+ require_protocol.literal("--color-border-info"),
71
+ require_protocol.literal("--color-border-danger"),
72
+ require_protocol.literal("--color-border-success"),
73
+ require_protocol.literal("--color-border-warning"),
74
+ require_protocol.literal("--color-border-disabled"),
75
+ require_protocol.literal("--color-ring-primary"),
76
+ require_protocol.literal("--color-ring-secondary"),
77
+ require_protocol.literal("--color-ring-inverse"),
78
+ require_protocol.literal("--color-ring-info"),
79
+ require_protocol.literal("--color-ring-danger"),
80
+ require_protocol.literal("--color-ring-success"),
81
+ require_protocol.literal("--color-ring-warning"),
82
+ require_protocol.literal("--font-sans"),
83
+ require_protocol.literal("--font-mono"),
84
+ require_protocol.literal("--font-weight-normal"),
85
+ require_protocol.literal("--font-weight-medium"),
86
+ require_protocol.literal("--font-weight-semibold"),
87
+ require_protocol.literal("--font-weight-bold"),
88
+ require_protocol.literal("--font-text-xs-size"),
89
+ require_protocol.literal("--font-text-sm-size"),
90
+ require_protocol.literal("--font-text-md-size"),
91
+ require_protocol.literal("--font-text-lg-size"),
92
+ require_protocol.literal("--font-heading-xs-size"),
93
+ require_protocol.literal("--font-heading-sm-size"),
94
+ require_protocol.literal("--font-heading-md-size"),
95
+ require_protocol.literal("--font-heading-lg-size"),
96
+ require_protocol.literal("--font-heading-xl-size"),
97
+ require_protocol.literal("--font-heading-2xl-size"),
98
+ require_protocol.literal("--font-heading-3xl-size"),
99
+ require_protocol.literal("--font-text-xs-line-height"),
100
+ require_protocol.literal("--font-text-sm-line-height"),
101
+ require_protocol.literal("--font-text-md-line-height"),
102
+ require_protocol.literal("--font-text-lg-line-height"),
103
+ require_protocol.literal("--font-heading-xs-line-height"),
104
+ require_protocol.literal("--font-heading-sm-line-height"),
105
+ require_protocol.literal("--font-heading-md-line-height"),
106
+ require_protocol.literal("--font-heading-lg-line-height"),
107
+ require_protocol.literal("--font-heading-xl-line-height"),
108
+ require_protocol.literal("--font-heading-2xl-line-height"),
109
+ require_protocol.literal("--font-heading-3xl-line-height"),
110
+ require_protocol.literal("--border-radius-xs"),
111
+ require_protocol.literal("--border-radius-sm"),
112
+ require_protocol.literal("--border-radius-md"),
113
+ require_protocol.literal("--border-radius-lg"),
114
+ require_protocol.literal("--border-radius-xl"),
115
+ require_protocol.literal("--border-radius-full"),
116
+ require_protocol.literal("--border-width-regular"),
117
+ require_protocol.literal("--shadow-hairline"),
118
+ require_protocol.literal("--shadow-sm"),
119
+ require_protocol.literal("--shadow-md"),
120
+ require_protocol.literal("--shadow-lg")
121
+ ]).describe("CSS variable keys available to MCP apps for theming."), KQ = require_protocol.record(JQ.describe(`Style variables for theming MCP apps.
122
+
123
+ Individual style keys are optional - hosts may provide any subset of these values.
124
+ Values are strings containing CSS values (colors, sizes, font stacks, etc.).
125
+
126
+ Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
127
+ for compatibility with Zod schema generation. Both are functionally equivalent for validation.`), require_protocol.union([require_protocol.string(), require_protocol._undefined()]).describe(`Style variables for theming MCP apps.
128
+
129
+ Individual style keys are optional - hosts may provide any subset of these values.
130
+ Values are strings containing CSS values (colors, sizes, font stacks, etc.).
131
+
132
+ Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
133
+ for compatibility with Zod schema generation. Both are functionally equivalent for validation.`)).describe(`Style variables for theming MCP apps.
134
+
135
+ Individual style keys are optional - hosts may provide any subset of these values.
136
+ Values are strings containing CSS values (colors, sizes, font stacks, etc.).
137
+
138
+ Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
139
+ for compatibility with Zod schema generation. Both are functionally equivalent for validation.`), GQ = require_protocol.object({
140
+ method: require_protocol.literal("ui/open-link"),
141
+ params: require_protocol.object({ url: require_protocol.string().describe("URL to open in the host's browser") })
142
+ }), B = require_protocol.object({ isError: require_protocol.boolean().optional().describe("True if the host failed to open the URL (e.g., due to security policy).") }).passthrough(), _ = require_protocol.object({ isError: require_protocol.boolean().optional().describe("True if the download failed (e.g., user cancelled or host denied).") }).passthrough(), O = require_protocol.object({ isError: require_protocol.boolean().optional().describe("True if the host rejected or failed to deliver the message.") }).passthrough();
143
+ require_protocol.object({
144
+ method: require_protocol.literal("ui/notifications/sandbox-proxy-ready"),
145
+ params: require_protocol.object({})
146
+ });
147
+ var G = require_protocol.object({
148
+ connectDomains: require_protocol.array(require_protocol.string()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket).
149
+
150
+ - Maps to CSP \`connect-src\` directive
151
+ - Empty or omitted → no network connections (secure default)`),
152
+ resourceDomains: require_protocol.array(require_protocol.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)"),
153
+ frameDomains: require_protocol.array(require_protocol.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'`)"),
154
+ baseUriDomains: require_protocol.array(require_protocol.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'`)")
155
+ }), V = require_protocol.object({
156
+ camera: require_protocol.object({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),
157
+ microphone: require_protocol.object({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),
158
+ geolocation: require_protocol.object({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),
159
+ clipboardWrite: require_protocol.object({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")
160
+ }), NQ = require_protocol.object({
161
+ method: require_protocol.literal("ui/notifications/size-changed"),
162
+ params: require_protocol.object({
163
+ width: require_protocol.number().optional().describe("New width in pixels."),
164
+ height: require_protocol.number().optional().describe("New height in pixels.")
165
+ })
166
+ }), I = require_protocol.object({
167
+ method: require_protocol.literal("ui/notifications/tool-input"),
168
+ params: require_protocol.object({ arguments: require_protocol.record(require_protocol.string(), require_protocol.unknown().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.") })
169
+ }), w = require_protocol.object({
170
+ method: require_protocol.literal("ui/notifications/tool-input-partial"),
171
+ params: require_protocol.object({ arguments: require_protocol.record(require_protocol.string(), require_protocol.unknown().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).") })
172
+ }), A = require_protocol.object({
173
+ method: require_protocol.literal("ui/notifications/tool-cancelled"),
174
+ params: require_protocol.object({ reason: require_protocol.string().optional().describe("Optional reason for the cancellation (e.g., \"user action\", \"timeout\").") })
175
+ }), b = require_protocol.object({ fonts: require_protocol.string().optional() }), C = require_protocol.object({
176
+ variables: KQ.optional().describe("CSS variables for theming the app."),
177
+ css: b.optional().describe("CSS blocks that apps can inject.")
178
+ }), F = require_protocol.object({
179
+ method: require_protocol.literal("ui/resource-teardown"),
180
+ params: require_protocol.object({})
181
+ }), jQ = require_protocol.record(require_protocol.string(), require_protocol.unknown()), z = require_protocol.object({
182
+ text: require_protocol.object({}).optional().describe("Host supports text content blocks."),
183
+ image: require_protocol.object({}).optional().describe("Host supports image content blocks."),
184
+ audio: require_protocol.object({}).optional().describe("Host supports audio content blocks."),
185
+ resource: require_protocol.object({}).optional().describe("Host supports resource content blocks."),
186
+ resourceLink: require_protocol.object({}).optional().describe("Host supports resource link content blocks."),
187
+ structuredContent: require_protocol.object({}).optional().describe("Host supports structured content.")
188
+ }), x = require_protocol.object({
189
+ experimental: require_protocol.object({}).optional().describe("Experimental features (structure TBD)."),
190
+ openLinks: require_protocol.object({}).optional().describe("Host supports opening external URLs."),
191
+ downloadFile: require_protocol.object({}).optional().describe("Host supports file downloads via ui/download-file."),
192
+ serverTools: require_protocol.object({ listChanged: require_protocol.boolean().optional().describe("Host supports tools/list_changed notifications.") }).optional().describe("Host can proxy tool calls to the MCP server."),
193
+ serverResources: require_protocol.object({ listChanged: require_protocol.boolean().optional().describe("Host supports resources/list_changed notifications.") }).optional().describe("Host can proxy resource reads to the MCP server."),
194
+ logging: require_protocol.object({}).optional().describe("Host accepts log messages."),
195
+ sandbox: require_protocol.object({
196
+ permissions: V.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),
197
+ csp: G.optional().describe("CSP domains approved by the host.")
198
+ }).optional().describe("Sandbox configuration applied by the host."),
199
+ updateModelContext: z.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),
200
+ message: z.optional().describe("Host supports receiving content messages (ui/message) from the view.")
201
+ }), S = require_protocol.object({
202
+ experimental: require_protocol.object({}).optional().describe("Experimental features (structure TBD)."),
203
+ tools: require_protocol.object({ listChanged: require_protocol.boolean().optional().describe("App supports tools/list_changed notifications.") }).optional().describe("App exposes MCP-style tools that the host can call."),
204
+ availableDisplayModes: require_protocol.array(J).optional().describe("Display modes the app supports.")
205
+ }), EQ = require_protocol.object({
206
+ method: require_protocol.literal("ui/notifications/initialized"),
207
+ params: require_protocol.object({}).optional()
208
+ }), LQ = require_protocol.object({
209
+ csp: G.optional().describe("Content Security Policy configuration for UI resources."),
210
+ permissions: V.optional().describe("Sandbox permissions requested by the UI resource."),
211
+ domain: require_protocol.string().optional().describe(`Dedicated origin for view sandbox.
212
+
213
+ Useful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists.
214
+
215
+ **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:
216
+ - Hash-based subdomains (e.g., \`{hash}.claudemcpcontent.com\`)
217
+ - URL-derived subdomains (e.g., \`www-example-com.oaiusercontent.com\`)
218
+
219
+ If omitted, host uses default sandbox origin (typically per-conversation).`),
220
+ prefersBorder: require_protocol.boolean().optional().describe(`Visual boundary preference - true if view prefers a visible border.
221
+
222
+ Boolean 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.
223
+
224
+ - \`true\`: request visible border + background
225
+ - \`false\`: request no visible border + background
226
+ - omitted: host decides border`)
227
+ }), WQ = require_protocol.object({
228
+ method: require_protocol.literal("ui/request-display-mode"),
229
+ params: require_protocol.object({ mode: J.describe("The display mode being requested.") })
230
+ }), P = require_protocol.object({ mode: J.describe("The display mode that was actually set. May differ from requested if not supported.") }).passthrough(), g = require_protocol.union([require_protocol.literal("model"), require_protocol.literal("app")]).describe("Tool visibility scope - who can access the tool."), zQ = require_protocol.object({
231
+ resourceUri: require_protocol.string().optional(),
232
+ visibility: require_protocol.array(g).optional().describe(`Who can access this tool. Default: ["model", "app"]
233
+ - "model": Tool visible to and callable by the agent
234
+ - "app": Tool callable by the app from this server only`)
235
+ });
236
+ require_protocol.object({ mimeTypes: require_protocol.array(require_protocol.string()).optional().describe("Array of supported MIME types for UI resources.\nMust include `\"text/html;profile=mcp-app\"` for MCP Apps support.") });
237
+ var BQ = require_protocol.object({
238
+ method: require_protocol.literal("ui/download-file"),
239
+ params: require_protocol.object({ contents: require_protocol.array(require_protocol.union([require_protocol.EmbeddedResourceSchema, require_protocol.ResourceLinkSchema])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.") })
240
+ }), _Q = require_protocol.object({
241
+ method: require_protocol.literal("ui/message"),
242
+ params: require_protocol.object({
243
+ role: require_protocol.literal("user").describe("Message role, currently only \"user\" is supported."),
244
+ content: require_protocol.array(require_protocol.ContentBlockSchema).describe("Message content blocks (text, image, etc.).")
245
+ })
246
+ });
247
+ require_protocol.object({
248
+ method: require_protocol.literal("ui/notifications/sandbox-resource-ready"),
249
+ params: require_protocol.object({
250
+ html: require_protocol.string().describe("HTML content to load into the inner iframe."),
251
+ sandbox: require_protocol.string().optional().describe("Optional override for the inner iframe's sandbox attribute."),
252
+ csp: G.optional().describe("CSP configuration from resource metadata."),
253
+ permissions: V.optional().describe("Sandbox permissions from resource metadata.")
254
+ })
255
+ });
256
+ var T = require_protocol.object({
257
+ method: require_protocol.literal("ui/notifications/tool-result"),
258
+ params: require_protocol.CallToolResultSchema.describe("Standard MCP tool execution result.")
259
+ }), q = require_protocol.object({
260
+ toolInfo: require_protocol.object({
261
+ id: require_protocol.RequestIdSchema.optional().describe("JSON-RPC id of the tools/call request."),
262
+ tool: require_protocol.ToolSchema.describe("Tool definition including name, inputSchema, etc.")
263
+ }).optional().describe("Metadata of the tool call that instantiated this App."),
264
+ theme: k.optional().describe("Current color theme preference."),
265
+ styles: C.optional().describe("Style configuration for theming the app."),
266
+ displayMode: J.optional().describe("How the UI is currently displayed."),
267
+ availableDisplayModes: require_protocol.array(J).optional().describe("Display modes the host supports."),
268
+ containerDimensions: require_protocol.union([require_protocol.object({ height: require_protocol.number().describe("Fixed container height in pixels.") }), require_protocol.object({ maxHeight: require_protocol.union([require_protocol.number(), require_protocol._undefined()]).optional().describe("Maximum container height in pixels.") })]).and(require_protocol.union([require_protocol.object({ width: require_protocol.number().describe("Fixed container width in pixels.") }), require_protocol.object({ maxWidth: require_protocol.union([require_protocol.number(), require_protocol._undefined()]).optional().describe("Maximum container width in pixels.") })])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
269
+ container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),
270
+ locale: require_protocol.string().optional().describe("User's language and region preference in BCP 47 format."),
271
+ timeZone: require_protocol.string().optional().describe("User's timezone in IANA format."),
272
+ userAgent: require_protocol.string().optional().describe("Host application identifier."),
273
+ platform: require_protocol.union([
274
+ require_protocol.literal("web"),
275
+ require_protocol.literal("desktop"),
276
+ require_protocol.literal("mobile")
277
+ ]).optional().describe("Platform type for responsive design decisions."),
278
+ deviceCapabilities: require_protocol.object({
279
+ touch: require_protocol.boolean().optional().describe("Whether the device supports touch input."),
280
+ hover: require_protocol.boolean().optional().describe("Whether the device supports hover interactions.")
281
+ }).optional().describe("Device input capabilities."),
282
+ safeAreaInsets: require_protocol.object({
283
+ top: require_protocol.number().describe("Top safe area inset in pixels."),
284
+ right: require_protocol.number().describe("Right safe area inset in pixels."),
285
+ bottom: require_protocol.number().describe("Bottom safe area inset in pixels."),
286
+ left: require_protocol.number().describe("Left safe area inset in pixels.")
287
+ }).optional().describe("Mobile safe area boundaries in pixels.")
288
+ }).passthrough(), U = require_protocol.object({
289
+ method: require_protocol.literal("ui/notifications/host-context-changed"),
290
+ params: q.describe("Partial context update containing only changed fields.")
291
+ }), IQ = require_protocol.object({
292
+ method: require_protocol.literal("ui/update-model-context"),
293
+ params: require_protocol.object({
294
+ content: require_protocol.array(require_protocol.ContentBlockSchema).optional().describe("Context content blocks (text, image, etc.)."),
295
+ structuredContent: require_protocol.record(require_protocol.string(), require_protocol.unknown().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")
296
+ })
297
+ }), wQ = require_protocol.object({
298
+ method: require_protocol.literal("ui/initialize"),
299
+ params: require_protocol.object({
300
+ appInfo: require_protocol.ImplementationSchema.describe("App identification (name and version)."),
301
+ appCapabilities: S.describe("Features and capabilities this app provides."),
302
+ protocolVersion: require_protocol.string().describe("Protocol version this app supports.")
303
+ })
304
+ }), R = require_protocol.object({
305
+ protocolVersion: require_protocol.string().describe("Negotiated protocol version string (e.g., \"2025-11-21\")."),
306
+ hostInfo: require_protocol.ImplementationSchema.describe("Host application identification and version."),
307
+ hostCapabilities: x.describe("Features and capabilities provided by the host."),
308
+ hostContext: q.describe("Rich context about the host environment.")
309
+ }).passthrough();
310
+ function AQ() {
311
+ let X = document.documentElement.getAttribute("data-theme");
312
+ if (X === "dark" || X === "light") return X;
313
+ return document.documentElement.classList.contains("dark") ? "dark" : "light";
314
+ }
315
+ function FQ(X) {
316
+ let Y = document.documentElement;
317
+ Y.setAttribute("data-theme", X), Y.style.colorScheme = X;
318
+ }
319
+ function PQ(X, Y = document.documentElement) {
320
+ for (let [Z, $] of Object.entries(X)) if ($ !== void 0) Y.style.setProperty(Z, $);
321
+ }
322
+ function TQ(X) {
323
+ if (document.getElementById("__mcp-host-fonts")) return;
324
+ let Z = document.createElement("style");
325
+ Z.id = "__mcp-host-fonts", Z.textContent = X, document.head.appendChild(Z);
326
+ }
327
+ var UX = "ui/resourceUri", RX = "text/html;profile=mcp-app";
328
+ var CQ = class extends require_protocol.Protocol {
329
+ _appInfo;
330
+ _capabilities;
331
+ options;
332
+ _hostCapabilities;
333
+ _hostInfo;
334
+ _hostContext;
335
+ constructor(X, Y = {}, Z = { autoResize: !0 }) {
336
+ super(Z);
337
+ this._appInfo = X;
338
+ this._capabilities = Y;
339
+ this.options = Z;
340
+ this.setRequestHandler(require_protocol.PingRequestSchema, ($) => {
341
+ return console.log("Received ping:", $.params), {};
342
+ }), this.onhostcontextchanged = () => {};
343
+ }
344
+ getHostCapabilities() {
345
+ return this._hostCapabilities;
346
+ }
347
+ getHostVersion() {
348
+ return this._hostInfo;
349
+ }
350
+ getHostContext() {
351
+ return this._hostContext;
352
+ }
353
+ set ontoolinput(X) {
354
+ this.setNotificationHandler(I, (Y) => X(Y.params));
355
+ }
356
+ set ontoolinputpartial(X) {
357
+ this.setNotificationHandler(w, (Y) => X(Y.params));
358
+ }
359
+ set ontoolresult(X) {
360
+ this.setNotificationHandler(T, (Y) => X(Y.params));
361
+ }
362
+ set ontoolcancelled(X) {
363
+ this.setNotificationHandler(A, (Y) => X(Y.params));
364
+ }
365
+ set onhostcontextchanged(X) {
366
+ this.setNotificationHandler(U, (Y) => {
367
+ this._hostContext = {
368
+ ...this._hostContext,
369
+ ...Y.params
370
+ }, X(Y.params);
371
+ });
372
+ }
373
+ set onteardown(X) {
374
+ this.setRequestHandler(F, (Y, Z) => X(Y.params, Z));
375
+ }
376
+ set oncalltool(X) {
377
+ this.setRequestHandler(require_protocol.CallToolRequestSchema, (Y, Z) => X(Y.params, Z));
378
+ }
379
+ set onlisttools(X) {
380
+ this.setRequestHandler(require_protocol.ListToolsRequestSchema, (Y, Z) => X(Y.params, Z));
381
+ }
382
+ assertCapabilityForMethod(X) {}
383
+ assertRequestHandlerCapability(X) {
384
+ switch (X) {
385
+ case "tools/call":
386
+ case "tools/list":
387
+ if (!this._capabilities.tools) throw Error(`Client does not support tool capability (required for ${X})`);
388
+ return;
389
+ case "ping":
390
+ case "ui/resource-teardown": return;
391
+ default: throw Error(`No handler for method ${X} registered`);
392
+ }
393
+ }
394
+ assertNotificationCapability(X) {}
395
+ assertTaskCapability(X) {
396
+ throw Error("Tasks are not supported in MCP Apps");
397
+ }
398
+ assertTaskHandlerCapability(X) {
399
+ throw Error("Task handlers are not supported in MCP Apps");
400
+ }
401
+ async callServerTool(X, Y) {
402
+ 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: { ... } })?`);
403
+ return await this.request({
404
+ method: "tools/call",
405
+ params: X
406
+ }, require_protocol.CallToolResultSchema, Y);
407
+ }
408
+ async readServerResource(X, Y) {
409
+ return await this.request({
410
+ method: "resources/read",
411
+ params: X
412
+ }, require_protocol.ReadResourceResultSchema, Y);
413
+ }
414
+ async listServerResources(X, Y) {
415
+ return await this.request({
416
+ method: "resources/list",
417
+ params: X
418
+ }, require_protocol.ListResourcesResultSchema, Y);
419
+ }
420
+ sendMessage(X, Y) {
421
+ return this.request({
422
+ method: "ui/message",
423
+ params: X
424
+ }, O, Y);
425
+ }
426
+ sendLog(X) {
427
+ return this.notification({
428
+ method: "notifications/message",
429
+ params: X
430
+ });
431
+ }
432
+ updateModelContext(X, Y) {
433
+ return this.request({
434
+ method: "ui/update-model-context",
435
+ params: X
436
+ }, require_protocol.EmptyResultSchema, Y);
437
+ }
438
+ openLink(X, Y) {
439
+ return this.request({
440
+ method: "ui/open-link",
441
+ params: X
442
+ }, B, Y);
443
+ }
444
+ sendOpenLink = this.openLink;
445
+ downloadFile(X, Y) {
446
+ return this.request({
447
+ method: "ui/download-file",
448
+ params: X
449
+ }, _, Y);
450
+ }
451
+ requestDisplayMode(X, Y) {
452
+ return this.request({
453
+ method: "ui/request-display-mode",
454
+ params: X
455
+ }, P, Y);
456
+ }
457
+ sendSizeChanged(X) {
458
+ return this.notification({
459
+ method: "ui/notifications/size-changed",
460
+ params: X
461
+ });
462
+ }
463
+ setupSizeChangedNotifications() {
464
+ let X = !1, Y = 0, Z = 0, $ = () => {
465
+ if (X) return;
466
+ X = !0, requestAnimationFrame(() => {
467
+ X = !1;
468
+ let D = document.documentElement, y = D.style.width, u = D.style.height;
469
+ D.style.width = "fit-content", D.style.height = "max-content";
470
+ let H = D.getBoundingClientRect();
471
+ D.style.width = y, D.style.height = u;
472
+ let f = window.innerWidth - D.clientWidth, j = Math.ceil(H.width + f), E = Math.ceil(H.height);
473
+ if (j !== Y || E !== Z) Y = j, Z = E, this.sendSizeChanged({
474
+ width: j,
475
+ height: E
476
+ });
477
+ });
478
+ };
479
+ $();
480
+ let N = new ResizeObserver($);
481
+ return N.observe(document.documentElement), N.observe(document.body), () => N.disconnect();
482
+ }
483
+ async connect(X = new K(window.parent, window.parent), Y) {
484
+ if (this.transport) throw Error("App is already connected. Call close() before connecting again.");
485
+ await super.connect(X);
486
+ try {
487
+ let Z = await this.request({
488
+ method: "ui/initialize",
489
+ params: {
490
+ appCapabilities: this._capabilities,
491
+ appInfo: this._appInfo,
492
+ protocolVersion: L
493
+ }
494
+ }, R, Y);
495
+ if (Z === void 0) throw Error(`Server sent invalid initialize result: ${Z}`);
496
+ 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();
497
+ } catch (Z) {
498
+ throw this.close(), Z;
499
+ }
500
+ }
501
+ };
502
+ //#endregion
503
+ //#region src/hooks/app-context.tsx
504
+ /**
505
+ * React Context for sharing the MCP App instance across the component tree.
506
+ *
507
+ * AppProvider handles connecting to the MCP Apps host and provides the App
508
+ * instance via context. All sunpeak hooks read from this context internally,
509
+ * so consumers never need to pass `app` as a parameter.
510
+ *
511
+ * The provider preserves the App instance across React Fast Refresh (HMR)
512
+ * by storing it at module scope, matching the previous useApp() behavior.
513
+ */
514
+ var defaultState = {
515
+ app: null,
516
+ isConnected: false,
517
+ error: null
518
+ };
519
+ var AppContext = (0, react.createContext)(defaultState);
520
+ var _app = null;
521
+ var _connecting = null;
522
+ function AppProvider({ appInfo, capabilities, onAppCreated, children }) {
523
+ const [state, setState] = (0, react.useState)(() => _app ? {
524
+ app: _app,
525
+ isConnected: true,
526
+ error: null
527
+ } : defaultState);
528
+ (0, react.useEffect)(() => {
529
+ let cancelled = false;
530
+ if (_app) {
531
+ setState({
532
+ app: _app,
533
+ isConnected: true,
534
+ error: null
535
+ });
536
+ return () => {
537
+ cancelled = true;
538
+ };
539
+ }
540
+ if (!_connecting) _connecting = (async () => {
541
+ const transport = new K(window.parent, window.parent);
542
+ const newApp = new CQ(appInfo, capabilities ?? {});
543
+ onAppCreated?.(newApp);
544
+ await newApp.connect(transport);
545
+ _app = newApp;
546
+ return newApp;
547
+ })();
548
+ _connecting.then((connectedApp) => {
549
+ if (!cancelled) setState({
550
+ app: connectedApp,
551
+ isConnected: true,
552
+ error: null
553
+ });
554
+ }, (err) => {
555
+ _connecting = null;
556
+ if (!cancelled) setState({
557
+ app: null,
558
+ isConnected: false,
559
+ error: err instanceof Error ? err : /* @__PURE__ */ new Error("Failed to connect")
560
+ });
561
+ });
562
+ return () => {
563
+ cancelled = true;
564
+ };
565
+ }, []);
566
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AppContext.Provider, {
567
+ value: state,
568
+ children
569
+ });
570
+ }
571
+ //#endregion
572
+ //#region src/hooks/use-app.ts
573
+ /**
574
+ * Access the MCP App instance from context.
575
+ *
576
+ * Returns the connected App instance, or `null` while the connection
577
+ * is being established. Must be used inside an `<AppProvider>`.
578
+ *
579
+ * Most hooks read from context internally, so you only need `useApp()`
580
+ * for direct SDK method calls like `app.requestDisplayMode()`.
581
+ *
582
+ * @example
583
+ * ```tsx
584
+ * import { useApp } from 'sunpeak';
585
+ *
586
+ * function MyComponent() {
587
+ * const app = useApp();
588
+ * const handleFullscreen = () => app?.requestDisplayMode({ mode: 'fullscreen' });
589
+ * return <button onClick={handleFullscreen}>Fullscreen</button>;
590
+ * }
591
+ * ```
592
+ */
593
+ function useApp() {
594
+ return (0, react.useContext)(AppContext).app;
595
+ }
596
+ //#endregion
597
+ Object.defineProperty(exports, "A", {
598
+ enumerable: true,
599
+ get: function() {
600
+ return A;
601
+ }
602
+ });
603
+ Object.defineProperty(exports, "AQ", {
604
+ enumerable: true,
605
+ get: function() {
606
+ return AQ;
607
+ }
608
+ });
609
+ Object.defineProperty(exports, "AppProvider", {
610
+ enumerable: true,
611
+ get: function() {
612
+ return AppProvider;
613
+ }
614
+ });
615
+ Object.defineProperty(exports, "B", {
616
+ enumerable: true,
617
+ get: function() {
618
+ return B;
619
+ }
620
+ });
621
+ Object.defineProperty(exports, "BQ", {
622
+ enumerable: true,
623
+ get: function() {
624
+ return BQ;
625
+ }
626
+ });
627
+ Object.defineProperty(exports, "C", {
628
+ enumerable: true,
629
+ get: function() {
630
+ return C;
631
+ }
632
+ });
633
+ Object.defineProperty(exports, "CQ", {
634
+ enumerable: true,
635
+ get: function() {
636
+ return CQ;
637
+ }
638
+ });
639
+ Object.defineProperty(exports, "EQ", {
640
+ enumerable: true,
641
+ get: function() {
642
+ return EQ;
643
+ }
644
+ });
645
+ Object.defineProperty(exports, "F", {
646
+ enumerable: true,
647
+ get: function() {
648
+ return F;
649
+ }
650
+ });
651
+ Object.defineProperty(exports, "FQ", {
652
+ enumerable: true,
653
+ get: function() {
654
+ return FQ;
655
+ }
656
+ });
657
+ Object.defineProperty(exports, "G", {
658
+ enumerable: true,
659
+ get: function() {
660
+ return G;
661
+ }
662
+ });
663
+ Object.defineProperty(exports, "GQ", {
664
+ enumerable: true,
665
+ get: function() {
666
+ return GQ;
667
+ }
668
+ });
669
+ Object.defineProperty(exports, "I", {
670
+ enumerable: true,
671
+ get: function() {
672
+ return I;
673
+ }
674
+ });
675
+ Object.defineProperty(exports, "IQ", {
676
+ enumerable: true,
677
+ get: function() {
678
+ return IQ;
679
+ }
680
+ });
681
+ Object.defineProperty(exports, "J", {
682
+ enumerable: true,
683
+ get: function() {
684
+ return J;
685
+ }
686
+ });
687
+ Object.defineProperty(exports, "K", {
688
+ enumerable: true,
689
+ get: function() {
690
+ return K;
691
+ }
692
+ });
693
+ Object.defineProperty(exports, "L", {
694
+ enumerable: true,
695
+ get: function() {
696
+ return L;
697
+ }
698
+ });
699
+ Object.defineProperty(exports, "LQ", {
700
+ enumerable: true,
701
+ get: function() {
702
+ return LQ;
703
+ }
704
+ });
705
+ Object.defineProperty(exports, "NQ", {
706
+ enumerable: true,
707
+ get: function() {
708
+ return NQ;
709
+ }
710
+ });
711
+ Object.defineProperty(exports, "O", {
712
+ enumerable: true,
713
+ get: function() {
714
+ return O;
715
+ }
716
+ });
717
+ Object.defineProperty(exports, "P", {
718
+ enumerable: true,
719
+ get: function() {
720
+ return P;
721
+ }
722
+ });
723
+ Object.defineProperty(exports, "PQ", {
724
+ enumerable: true,
725
+ get: function() {
726
+ return PQ;
727
+ }
728
+ });
729
+ Object.defineProperty(exports, "R", {
730
+ enumerable: true,
731
+ get: function() {
732
+ return R;
733
+ }
734
+ });
735
+ Object.defineProperty(exports, "RX", {
736
+ enumerable: true,
737
+ get: function() {
738
+ return RX;
739
+ }
740
+ });
741
+ Object.defineProperty(exports, "S", {
742
+ enumerable: true,
743
+ get: function() {
744
+ return S;
745
+ }
746
+ });
747
+ Object.defineProperty(exports, "T", {
748
+ enumerable: true,
749
+ get: function() {
750
+ return T;
751
+ }
752
+ });
753
+ Object.defineProperty(exports, "TQ", {
754
+ enumerable: true,
755
+ get: function() {
756
+ return TQ;
757
+ }
758
+ });
759
+ Object.defineProperty(exports, "U", {
760
+ enumerable: true,
761
+ get: function() {
762
+ return U;
763
+ }
764
+ });
765
+ Object.defineProperty(exports, "UX", {
766
+ enumerable: true,
767
+ get: function() {
768
+ return UX;
769
+ }
770
+ });
771
+ Object.defineProperty(exports, "V", {
772
+ enumerable: true,
773
+ get: function() {
774
+ return V;
775
+ }
776
+ });
777
+ Object.defineProperty(exports, "W", {
778
+ enumerable: true,
779
+ get: function() {
780
+ return W;
781
+ }
782
+ });
783
+ Object.defineProperty(exports, "WQ", {
784
+ enumerable: true,
785
+ get: function() {
786
+ return WQ;
787
+ }
788
+ });
789
+ Object.defineProperty(exports, "_", {
790
+ enumerable: true,
791
+ get: function() {
792
+ return _;
793
+ }
794
+ });
795
+ Object.defineProperty(exports, "_Q", {
796
+ enumerable: true,
797
+ get: function() {
798
+ return _Q;
799
+ }
800
+ });
801
+ Object.defineProperty(exports, "a", {
802
+ enumerable: true,
803
+ get: function() {
804
+ return a;
805
+ }
806
+ });
807
+ Object.defineProperty(exports, "b", {
808
+ enumerable: true,
809
+ get: function() {
810
+ return b;
811
+ }
812
+ });
813
+ Object.defineProperty(exports, "d", {
814
+ enumerable: true,
815
+ get: function() {
816
+ return d;
817
+ }
818
+ });
819
+ Object.defineProperty(exports, "e", {
820
+ enumerable: true,
821
+ get: function() {
822
+ return e;
823
+ }
824
+ });
825
+ Object.defineProperty(exports, "g", {
826
+ enumerable: true,
827
+ get: function() {
828
+ return g;
829
+ }
830
+ });
831
+ Object.defineProperty(exports, "h", {
832
+ enumerable: true,
833
+ get: function() {
834
+ return h;
835
+ }
836
+ });
837
+ Object.defineProperty(exports, "jQ", {
838
+ enumerable: true,
839
+ get: function() {
840
+ return jQ;
841
+ }
842
+ });
843
+ Object.defineProperty(exports, "k", {
844
+ enumerable: true,
845
+ get: function() {
846
+ return k;
847
+ }
848
+ });
849
+ Object.defineProperty(exports, "l", {
850
+ enumerable: true,
851
+ get: function() {
852
+ return l;
853
+ }
854
+ });
855
+ Object.defineProperty(exports, "m", {
856
+ enumerable: true,
857
+ get: function() {
858
+ return m;
859
+ }
860
+ });
861
+ Object.defineProperty(exports, "n", {
862
+ enumerable: true,
863
+ get: function() {
864
+ return n;
865
+ }
866
+ });
867
+ Object.defineProperty(exports, "o", {
868
+ enumerable: true,
869
+ get: function() {
870
+ return o;
871
+ }
872
+ });
873
+ Object.defineProperty(exports, "p", {
874
+ enumerable: true,
875
+ get: function() {
876
+ return p;
877
+ }
878
+ });
879
+ Object.defineProperty(exports, "q", {
880
+ enumerable: true,
881
+ get: function() {
882
+ return q;
883
+ }
884
+ });
885
+ Object.defineProperty(exports, "r", {
886
+ enumerable: true,
887
+ get: function() {
888
+ return r;
889
+ }
890
+ });
891
+ Object.defineProperty(exports, "s", {
892
+ enumerable: true,
893
+ get: function() {
894
+ return s;
895
+ }
896
+ });
897
+ Object.defineProperty(exports, "t", {
898
+ enumerable: true,
899
+ get: function() {
900
+ return t;
901
+ }
902
+ });
903
+ Object.defineProperty(exports, "useApp", {
904
+ enumerable: true,
905
+ get: function() {
906
+ return useApp;
907
+ }
908
+ });
909
+ Object.defineProperty(exports, "w", {
910
+ enumerable: true,
911
+ get: function() {
912
+ return w;
913
+ }
914
+ });
915
+ Object.defineProperty(exports, "wQ", {
916
+ enumerable: true,
917
+ get: function() {
918
+ return wQ;
919
+ }
920
+ });
921
+ Object.defineProperty(exports, "x", {
922
+ enumerable: true,
923
+ get: function() {
924
+ return x;
925
+ }
926
+ });
927
+ Object.defineProperty(exports, "z", {
928
+ enumerable: true,
929
+ get: function() {
930
+ return z;
931
+ }
932
+ });
933
+ Object.defineProperty(exports, "zQ", {
934
+ enumerable: true,
935
+ get: function() {
936
+ return zQ;
937
+ }
938
+ });
939
+
940
+ //# sourceMappingURL=use-app-D2h-aiyr.cjs.map