sunpeak 0.19.1 → 0.19.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.
Files changed (87) hide show
  1. package/README.md +6 -3
  2. package/bin/commands/new.mjs +3 -1
  3. package/bin/commands/test.mjs +107 -46
  4. package/bin/lib/inspect/inspect-config.d.mts +4 -0
  5. package/bin/lib/inspect/inspect-config.mjs +2 -0
  6. package/bin/lib/test/base-config.mjs +16 -1
  7. package/bin/lib/test/test-config.d.mts +22 -0
  8. package/bin/lib/test/test-config.mjs +2 -0
  9. package/bin/lib/test/test-fixtures.d.mts +34 -1
  10. package/bin/lib/test/test-fixtures.mjs +43 -0
  11. package/dist/chatgpt/index.cjs +1 -1
  12. package/dist/chatgpt/index.js +1 -1
  13. package/dist/claude/index.cjs +1 -1
  14. package/dist/claude/index.js +1 -1
  15. package/dist/host/chatgpt/index.cjs +1 -1
  16. package/dist/host/chatgpt/index.js +1 -1
  17. package/dist/index.cjs +134 -124
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.ts +3 -1
  20. package/dist/index.js +71 -62
  21. package/dist/index.js.map +1 -1
  22. package/dist/inspector/index.cjs +1 -1
  23. package/dist/inspector/index.js +1 -1
  24. package/dist/{inspector-Cdo5BK2D.js → inspector-Bp9jrHIu.js} +218 -80
  25. package/dist/inspector-Bp9jrHIu.js.map +1 -0
  26. package/dist/{inspector-8nPV2A-z.cjs → inspector-Cvq3yjNL.cjs} +219 -81
  27. package/dist/inspector-Cvq3yjNL.cjs.map +1 -0
  28. package/dist/mcp/index.cjs +235 -138
  29. package/dist/mcp/index.cjs.map +1 -1
  30. package/dist/mcp/index.d.ts +1 -1
  31. package/dist/mcp/index.js +228 -132
  32. package/dist/mcp/index.js.map +1 -1
  33. package/dist/mcp/production-server.d.ts +31 -0
  34. package/dist/{protocol-C7kTcBr_.cjs → protocol-C8pFDmcy.cjs} +8194 -8187
  35. package/dist/protocol-C8pFDmcy.cjs.map +1 -0
  36. package/dist/{protocol-BfAACnv0.js → protocol-CRqiPTLT.js} +8186 -8185
  37. package/dist/protocol-CRqiPTLT.js.map +1 -0
  38. package/dist/{use-app-CfP9VypY.js → use-app-Ck5kR1Sf.js} +193 -93
  39. package/dist/use-app-Ck5kR1Sf.js.map +1 -0
  40. package/dist/{use-app-CzcYw1Kz.cjs → use-app-DHYiev3D.cjs} +253 -147
  41. package/dist/use-app-DHYiev3D.cjs.map +1 -0
  42. package/package.json +2 -2
  43. package/template/README.md +6 -3
  44. package/template/dist/albums/albums.html +15 -15
  45. package/template/dist/albums/albums.json +1 -1
  46. package/template/dist/carousel/carousel.html +19 -19
  47. package/template/dist/carousel/carousel.json +1 -1
  48. package/template/dist/map/map.html +14 -14
  49. package/template/dist/map/map.json +1 -1
  50. package/template/dist/review/review.html +11 -11
  51. package/template/dist/review/review.json +1 -1
  52. package/template/node_modules/.vite/deps/_metadata.json +3 -3
  53. package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps.js +192 -91
  54. package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps.js.map +1 -1
  55. package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps_app-bridge.js +231 -92
  56. package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps_app-bridge.js.map +1 -1
  57. package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps_react.js +208 -105
  58. package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps_react.js.map +1 -1
  59. package/template/node_modules/.vite-mcp/deps/_metadata.json +24 -24
  60. package/template/node_modules/.vite-mcp/deps/{protocol-B_qKkui_.js → protocol-BqGB4zBx.js} +45 -45
  61. package/template/node_modules/.vite-mcp/deps/protocol-BqGB4zBx.js.map +1 -0
  62. package/template/package.json +5 -3
  63. package/template/test-results/.last-run.json +4 -0
  64. package/template/tests/e2e/visual.spec.ts +36 -0
  65. package/template/tests/e2e/visual.spec.ts-snapshots/albums-dark-chatgpt-darwin.png +0 -0
  66. package/template/tests/e2e/visual.spec.ts-snapshots/albums-dark-chatgpt-linux.png +0 -0
  67. package/template/tests/e2e/visual.spec.ts-snapshots/albums-dark-claude-darwin.png +0 -0
  68. package/template/tests/e2e/visual.spec.ts-snapshots/albums-dark-claude-linux.png +0 -0
  69. package/template/tests/e2e/visual.spec.ts-snapshots/albums-fullscreen-chatgpt-darwin.png +0 -0
  70. package/template/tests/e2e/visual.spec.ts-snapshots/albums-fullscreen-chatgpt-linux.png +0 -0
  71. package/template/tests/e2e/visual.spec.ts-snapshots/albums-fullscreen-claude-darwin.png +0 -0
  72. package/template/tests/e2e/visual.spec.ts-snapshots/albums-fullscreen-claude-linux.png +0 -0
  73. package/template/tests/e2e/visual.spec.ts-snapshots/albums-light-chatgpt-darwin.png +0 -0
  74. package/template/tests/e2e/visual.spec.ts-snapshots/albums-light-chatgpt-linux.png +0 -0
  75. package/template/tests/e2e/visual.spec.ts-snapshots/albums-light-claude-darwin.png +0 -0
  76. package/template/tests/e2e/visual.spec.ts-snapshots/albums-light-claude-linux.png +0 -0
  77. package/template/tests/e2e/visual.spec.ts-snapshots/albums-page-light-chatgpt-darwin.png +0 -0
  78. package/template/tests/e2e/visual.spec.ts-snapshots/albums-page-light-chatgpt-linux.png +0 -0
  79. package/template/tests/e2e/visual.spec.ts-snapshots/albums-page-light-claude-darwin.png +0 -0
  80. package/template/tests/e2e/visual.spec.ts-snapshots/albums-page-light-claude-linux.png +0 -0
  81. package/dist/inspector-8nPV2A-z.cjs.map +0 -1
  82. package/dist/inspector-Cdo5BK2D.js.map +0 -1
  83. package/dist/protocol-BfAACnv0.js.map +0 -1
  84. package/dist/protocol-C7kTcBr_.cjs.map +0 -1
  85. package/dist/use-app-CfP9VypY.js.map +0 -1
  86. package/dist/use-app-CzcYw1Kz.cjs.map +0 -1
  87. package/template/node_modules/.vite-mcp/deps/protocol-B_qKkui_.js.map +0 -1
@@ -1,12 +1,69 @@
1
1
  import { Cn as object, In as string, Jn as union, Sn as number, St as _undefined, Tt as array, Yn as unknown, jn as record, kt as boolean, ln as literal } from "./schemas-NsgmY9QV.js";
2
- import { C as ResourceListChangedNotificationSchema, S as ResourceLinkSchema, T as ToolSchema, _ as PingRequestSchema, a as EmbeddedResourceSchema, b as ReadResourceResultSchema, c as JSONRPCMessageSchema, d as ListResourceTemplatesRequestSchema, f as ListResourceTemplatesResultSchema, g as LoggingMessageNotificationSchema, i as ContentBlockSchema, l as ListPromptsRequestSchema, m as ListResourcesResultSchema, n as CallToolRequestSchema, p as ListResourcesRequestSchema, r as CallToolResultSchema, s as ImplementationSchema, t as Protocol, u as ListPromptsResultSchema, v as PromptListChangedNotificationSchema, w as ToolListChangedNotificationSchema, x as RequestIdSchema, y as ReadResourceRequestSchema } from "./protocol-B_qKkui_.js";
3
- //#region ../../../node_modules/.pnpm/@modelcontextprotocol+ext-apps@1.3.2_@modelcontextprotocol+sdk@1.29.0_zod@4.3.6__react-_38e5f6c50a4ca9cf3f1dffc73a60c951/node_modules/@modelcontextprotocol/ext-apps/dist/src/app-bridge.js
4
- var G = "2026-01-26", o = "ui/open-link", a = "ui/download-file", t = "ui/message", s = "ui/notifications/sandbox-proxy-ready", e = "ui/notifications/sandbox-resource-ready", QQ = "ui/notifications/size-changed", XQ = "ui/notifications/tool-input", _ = "ui/notifications/tool-input-partial", YQ = "ui/notifications/tool-result", ZQ = "ui/notifications/tool-cancelled", $Q = "ui/notifications/host-context-changed", JQ = "ui/notifications/request-teardown", KQ = "ui/resource-teardown", GQ = "ui/initialize", WQ = "ui/notifications/initialized", DQ = "ui/request-display-mode";
5
- var m = union([literal("light"), literal("dark")]).describe("Color theme preference for the host environment."), W = union([
2
+ import { C as ResourceLinkSchema, E as ToolSchema, S as RequestIdSchema, T as ToolListChangedNotificationSchema, _ as LoggingMessageNotificationSchema, a as EmbeddedResourceSchema, b as ReadResourceRequestSchema, c as JSONRPCMessageSchema, d as ListResourceTemplatesRequestSchema, f as ListResourceTemplatesResultSchema, g as ListToolsResultSchema, i as ContentBlockSchema, l as ListPromptsRequestSchema, m as ListResourcesResultSchema, n as CallToolRequestSchema, p as ListResourcesRequestSchema, r as CallToolResultSchema, s as ImplementationSchema, t as Protocol, u as ListPromptsResultSchema, v as PingRequestSchema, w as ResourceListChangedNotificationSchema, x as ReadResourceResultSchema, y as PromptListChangedNotificationSchema } from "./protocol-BqGB4zBx.js";
3
+ //#region ../../../node_modules/.pnpm/@modelcontextprotocol+ext-apps@1.5.0_@modelcontextprotocol+sdk@1.29.0_zod@4.3.6__react-_f4871531d9cf52c692eb6edc1ee416ef/node_modules/@modelcontextprotocol/ext-apps/dist/src/app-bridge.js
4
+ var j = class extends Protocol {
5
+ _registeredMethods = /* @__PURE__ */ new Set();
6
+ _eventSlots = /* @__PURE__ */ new Map();
7
+ onEventDispatch(X, Y) {}
8
+ _ensureEventSlot(X) {
9
+ let Y = this._eventSlots.get(X);
10
+ if (!Y) {
11
+ let Z = this.eventSchemas[X];
12
+ if (!Z) throw Error(`Unknown event: ${String(X)}`);
13
+ Y = { listeners: [] }, this._eventSlots.set(X, Y);
14
+ let $ = Z.shape.method.value;
15
+ this._registeredMethods.add($);
16
+ let J = Y;
17
+ super.setNotificationHandler(Z, (K) => {
18
+ let N = K.params;
19
+ this.onEventDispatch(X, N), J.onHandler?.(N);
20
+ for (let W of [...J.listeners]) W(N);
21
+ });
22
+ }
23
+ return Y;
24
+ }
25
+ setEventHandler(X, Y) {
26
+ let Z = this._ensureEventSlot(X);
27
+ if (Z.onHandler && Y) console.warn(`[MCP Apps] on${String(X)} handler replaced. Use addEventListener("${String(X)}", …) to add multiple listeners without replacing.`);
28
+ Z.onHandler = Y;
29
+ }
30
+ getEventHandler(X) {
31
+ return this._eventSlots.get(X)?.onHandler;
32
+ }
33
+ addEventListener(X, Y) {
34
+ this._ensureEventSlot(X).listeners.push(Y);
35
+ }
36
+ removeEventListener(X, Y) {
37
+ let Z = this._eventSlots.get(X);
38
+ if (!Z) return;
39
+ let $ = Z.listeners.indexOf(Y);
40
+ if ($ !== -1) Z.listeners.splice($, 1);
41
+ }
42
+ setRequestHandler = (X, Y) => {
43
+ this._assertMethodNotRegistered(X, "setRequestHandler"), super.setRequestHandler(X, Y);
44
+ };
45
+ setNotificationHandler = (X, Y) => {
46
+ this._assertMethodNotRegistered(X, "setNotificationHandler"), super.setNotificationHandler(X, Y);
47
+ };
48
+ warnIfRequestHandlerReplaced(X, Y, Z) {
49
+ if (Y && Z) console.warn(`[MCP Apps] ${X} handler replaced. Previous handler will no longer be called.`);
50
+ }
51
+ replaceRequestHandler = (X, Y) => {
52
+ let Z = X.shape.method.value;
53
+ this._registeredMethods.add(Z), super.setRequestHandler(X, Y);
54
+ };
55
+ _assertMethodNotRegistered(X, Y) {
56
+ let Z = X.shape.method.value;
57
+ if (this._registeredMethods.has(Z)) throw Error(`Handler for "${Z}" already registered (via ${Y}). Use addEventListener() to attach multiple listeners, or the on* setter for replace semantics.`);
58
+ this._registeredMethods.add(Z);
59
+ }
60
+ };
61
+ var G = "2026-01-26", a = "ui/open-link", e = "ui/download-file", QQ = "ui/message", XQ = "ui/notifications/sandbox-proxy-ready", YQ = "ui/notifications/sandbox-resource-ready", ZQ = "ui/notifications/size-changed", $Q = "ui/notifications/tool-input", V = "ui/notifications/tool-input-partial", JQ = "ui/notifications/tool-result", KQ = "ui/notifications/tool-cancelled", GQ = "ui/notifications/host-context-changed", DQ = "ui/notifications/request-teardown", NQ = "ui/resource-teardown", WQ = "ui/initialize", jQ = "ui/notifications/initialized", zQ = "ui/request-display-mode";
62
+ var p = union([literal("light"), literal("dark")]).describe("Color theme preference for the host environment."), D = union([
6
63
  literal("inline"),
7
64
  literal("fullscreen"),
8
65
  literal("pip")
9
- ]).describe("Display mode for UI presentation."), OQ = record(union([
66
+ ]).describe("Display mode for UI presentation."), AQ = record(union([
10
67
  literal("--color-background-primary"),
11
68
  literal("--color-background-secondary"),
12
69
  literal("--color-background-tertiary"),
@@ -101,13 +158,13 @@ Individual style keys are optional - hosts may provide any subset of these value
101
158
  Values are strings containing CSS values (colors, sizes, font stacks, etc.).
102
159
 
103
160
  Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
104
- for compatibility with Zod schema generation. Both are functionally equivalent for validation.`), V = object({
161
+ for compatibility with Zod schema generation. Both are functionally equivalent for validation.`), A = object({
105
162
  method: literal("ui/open-link"),
106
163
  params: object({ url: string().describe("URL to open in the host's browser") })
107
- }), I = object({ isError: boolean().optional().describe("True if the host failed to open the URL (e.g., due to security policy).") }).passthrough(), A = object({ isError: boolean().optional().describe("True if the download failed (e.g., user cancelled or host denied).") }).passthrough(), F = object({ isError: boolean().optional().describe("True if the host rejected or failed to deliver the message.") }).passthrough(), L = object({
164
+ }), F = object({ isError: boolean().optional().describe("True if the host failed to open the URL (e.g., due to security policy).") }).passthrough(), L = object({ isError: boolean().optional().describe("True if the download failed (e.g., user cancelled or host denied).") }).passthrough(), P = object({ isError: boolean().optional().describe("True if the host rejected or failed to deliver the message.") }).passthrough(), T = object({
108
165
  method: literal("ui/notifications/sandbox-proxy-ready"),
109
166
  params: object({})
110
- }), N = object({
167
+ }), B = object({
111
168
  connectDomains: array(string()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket).
112
169
 
113
170
  - Maps to CSP \`connect-src\` directive
@@ -115,43 +172,43 @@ for compatibility with Zod schema generation. Both are functionally equivalent f
115
172
  resourceDomains: array(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)"),
116
173
  frameDomains: array(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'`)"),
117
174
  baseUriDomains: array(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'`)")
118
- }), j = object({
175
+ }), E = object({
119
176
  camera: object({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),
120
177
  microphone: object({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),
121
178
  geolocation: object({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),
122
179
  clipboardWrite: object({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")
123
- }), P = object({
180
+ }), w = object({
124
181
  method: literal("ui/notifications/size-changed"),
125
182
  params: object({
126
183
  width: number().optional().describe("New width in pixels."),
127
184
  height: number().optional().describe("New height in pixels.")
128
185
  })
129
- }), T = object({
186
+ }), R = object({
130
187
  method: literal("ui/notifications/tool-input"),
131
188
  params: object({ arguments: record(string(), unknown().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.") })
132
- }), w = object({
189
+ }), U = object({
133
190
  method: literal("ui/notifications/tool-input-partial"),
134
191
  params: object({ arguments: record(string(), unknown().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).") })
135
- }), R = object({
192
+ }), H = object({
136
193
  method: literal("ui/notifications/tool-cancelled"),
137
194
  params: object({ reason: string().optional().describe("Optional reason for the cancellation (e.g., \"user action\", \"timeout\").") })
138
- }), p = object({ fonts: string().optional() }), c = object({
139
- variables: OQ.optional().describe("CSS variables for theming the app."),
140
- css: p.optional().describe("CSS blocks that apps can inject.")
141
- }), U = object({
195
+ }), n = object({ fonts: string().optional() }), c = object({
196
+ variables: AQ.optional().describe("CSS variables for theming the app."),
197
+ css: n.optional().describe("CSS blocks that apps can inject.")
198
+ }), M = object({
142
199
  method: literal("ui/resource-teardown"),
143
200
  params: object({})
144
- }), H = record(string(), unknown()), O = object({
201
+ }), g = record(string(), unknown()), I = object({
145
202
  text: object({}).optional().describe("Host supports text content blocks."),
146
203
  image: object({}).optional().describe("Host supports image content blocks."),
147
204
  audio: object({}).optional().describe("Host supports audio content blocks."),
148
205
  resource: object({}).optional().describe("Host supports resource content blocks."),
149
206
  resourceLink: object({}).optional().describe("Host supports resource link content blocks."),
150
207
  structuredContent: object({}).optional().describe("Host supports structured content.")
151
- }), M = object({
208
+ }), C = object({
152
209
  method: literal("ui/notifications/request-teardown"),
153
210
  params: object({}).optional()
154
- }), n = object({
211
+ }), r = object({
155
212
  experimental: object({}).optional().describe("Experimental features (structure TBD)."),
156
213
  openLinks: object({}).optional().describe("Host supports opening external URLs."),
157
214
  downloadFile: object({}).optional().describe("Host supports file downloads via ui/download-file."),
@@ -159,21 +216,21 @@ for compatibility with Zod schema generation. Both are functionally equivalent f
159
216
  serverResources: object({ listChanged: boolean().optional().describe("Host supports resources/list_changed notifications.") }).optional().describe("Host can proxy resource reads to the MCP server."),
160
217
  logging: object({}).optional().describe("Host accepts log messages."),
161
218
  sandbox: object({
162
- permissions: j.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),
163
- csp: N.optional().describe("CSP domains approved by the host.")
219
+ permissions: E.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),
220
+ csp: B.optional().describe("CSP domains approved by the host.")
164
221
  }).optional().describe("Sandbox configuration applied by the host."),
165
- updateModelContext: O.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),
166
- message: O.optional().describe("Host supports receiving content messages (ui/message) from the view.")
167
- }), i = object({
222
+ updateModelContext: I.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),
223
+ message: I.optional().describe("Host supports receiving content messages (ui/message) from the view.")
224
+ }), l = object({
168
225
  experimental: object({}).optional().describe("Experimental features (structure TBD)."),
169
226
  tools: object({ listChanged: boolean().optional().describe("App supports tools/list_changed notifications.") }).optional().describe("App exposes MCP-style tools that the host can call."),
170
- availableDisplayModes: array(W).optional().describe("Display modes the app supports.")
171
- }), v = object({
227
+ availableDisplayModes: array(D).optional().describe("Display modes the app supports.")
228
+ }), S = object({
172
229
  method: literal("ui/notifications/initialized"),
173
230
  params: object({}).optional()
174
- }), VQ = object({
175
- csp: N.optional().describe("Content Security Policy configuration for UI resources."),
176
- permissions: j.optional().describe("Sandbox permissions requested by the UI resource."),
231
+ }), FQ = object({
232
+ csp: B.optional().describe("Content Security Policy configuration for UI resources."),
233
+ permissions: E.optional().describe("Sandbox permissions requested by the UI resource."),
177
234
  domain: string().optional().describe(`Dedicated origin for view sandbox.
178
235
 
179
236
  Useful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists.
@@ -190,45 +247,45 @@ Boolean requesting whether a visible border and background is provided by the ho
190
247
  - \`true\`: request visible border + background
191
248
  - \`false\`: request no visible border + background
192
249
  - omitted: host decides border`)
193
- }), E = object({
250
+ }), _ = object({
194
251
  method: literal("ui/request-display-mode"),
195
- params: object({ mode: W.describe("The display mode being requested.") })
196
- }), g = object({ mode: W.describe("The display mode that was actually set. May differ from requested if not supported.") }).passthrough(), l = union([literal("model"), literal("app")]).describe("Tool visibility scope - who can access the tool."), IQ = object({
252
+ params: object({ mode: D.describe("The display mode being requested.") })
253
+ }), q = object({ mode: D.describe("The display mode that was actually set. May differ from requested if not supported.") }).passthrough(), o = union([literal("model"), literal("app")]).describe("Tool visibility scope - who can access the tool."), LQ = object({
197
254
  resourceUri: string().optional(),
198
- visibility: array(l).optional().describe(`Who can access this tool. Default: ["model", "app"]
255
+ visibility: array(o).optional().describe(`Who can access this tool. Default: ["model", "app"]
199
256
  - "model": Tool visible to and callable by the agent
200
257
  - "app": Tool callable by the app from this server only`)
201
258
  });
202
259
  object({ mimeTypes: array(string()).optional().describe("Array of supported MIME types for UI resources.\nMust include `\"text/html;profile=mcp-app\"` for MCP Apps support.") });
203
- var C = object({
260
+ var f = object({
204
261
  method: literal("ui/download-file"),
205
262
  params: object({ contents: array(union([EmbeddedResourceSchema, ResourceLinkSchema])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.") })
206
- }), S = object({
263
+ }), y = object({
207
264
  method: literal("ui/message"),
208
265
  params: object({
209
266
  role: literal("user").describe("Message role, currently only \"user\" is supported."),
210
267
  content: array(ContentBlockSchema).describe("Message content blocks (text, image, etc.).")
211
268
  })
212
- }), AQ = object({
269
+ }), PQ = object({
213
270
  method: literal("ui/notifications/sandbox-resource-ready"),
214
271
  params: object({
215
272
  html: string().describe("HTML content to load into the inner iframe."),
216
273
  sandbox: string().optional().describe("Optional override for the inner iframe's sandbox attribute."),
217
- csp: N.optional().describe("CSP configuration from resource metadata."),
218
- permissions: j.optional().describe("Sandbox permissions from resource metadata.")
274
+ csp: B.optional().describe("CSP configuration from resource metadata."),
275
+ permissions: E.optional().describe("Sandbox permissions from resource metadata.")
219
276
  })
220
- }), q = object({
277
+ }), v = object({
221
278
  method: literal("ui/notifications/tool-result"),
222
279
  params: CallToolResultSchema.describe("Standard MCP tool execution result.")
223
- }), y = object({
280
+ }), x = object({
224
281
  toolInfo: object({
225
282
  id: RequestIdSchema.optional().describe("JSON-RPC id of the tools/call request."),
226
283
  tool: ToolSchema.describe("Tool definition including name, inputSchema, etc.")
227
284
  }).optional().describe("Metadata of the tool call that instantiated this App."),
228
- theme: m.optional().describe("Current color theme preference."),
285
+ theme: p.optional().describe("Current color theme preference."),
229
286
  styles: c.optional().describe("Style configuration for theming the app."),
230
- displayMode: W.optional().describe("How the UI is currently displayed."),
231
- availableDisplayModes: array(W).optional().describe("Display modes the host supports."),
287
+ displayMode: D.optional().describe("How the UI is currently displayed."),
288
+ availableDisplayModes: array(D).optional().describe("Display modes the host supports."),
232
289
  containerDimensions: union([object({ height: number().describe("Fixed container height in pixels.") }), object({ maxHeight: union([number(), _undefined()]).optional().describe("Maximum container height in pixels.") })]).and(union([object({ width: number().describe("Fixed container width in pixels.") }), object({ maxWidth: union([number(), _undefined()]).optional().describe("Maximum container width in pixels.") })])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
233
290
  container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),
234
291
  locale: string().optional().describe("User's language and region preference in BCP 47 format."),
@@ -251,27 +308,27 @@ container holding the app. Specify either width or maxWidth, and either height o
251
308
  }).optional().describe("Mobile safe area boundaries in pixels.")
252
309
  }).passthrough(), k = object({
253
310
  method: literal("ui/notifications/host-context-changed"),
254
- params: y.describe("Partial context update containing only changed fields.")
255
- }), f = object({
311
+ params: x.describe("Partial context update containing only changed fields.")
312
+ }), d = object({
256
313
  method: literal("ui/update-model-context"),
257
314
  params: object({
258
315
  content: array(ContentBlockSchema).optional().describe("Context content blocks (text, image, etc.)."),
259
316
  structuredContent: record(string(), unknown().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")
260
317
  })
261
- }), d = object({
318
+ }), b = object({
262
319
  method: literal("ui/initialize"),
263
320
  params: object({
264
321
  appInfo: ImplementationSchema.describe("App identification (name and version)."),
265
- appCapabilities: i.describe("Features and capabilities this app provides."),
322
+ appCapabilities: l.describe("Features and capabilities this app provides."),
266
323
  protocolVersion: string().describe("Protocol version this app supports.")
267
324
  })
268
- }), b = object({
325
+ }), u = object({
269
326
  protocolVersion: string().describe("Negotiated protocol version string (e.g., \"2025-11-21\")."),
270
327
  hostInfo: ImplementationSchema.describe("Host application identification and version."),
271
- hostCapabilities: n.describe("Features and capabilities provided by the host."),
272
- hostContext: y.describe("Rich context about the host environment.")
328
+ hostCapabilities: r.describe("Features and capabilities provided by the host."),
329
+ hostContext: x.describe("Rich context about the host environment.")
273
330
  }).passthrough();
274
- var D = class {
331
+ var z = class {
275
332
  eventTarget;
276
333
  eventSource;
277
334
  messageListener;
@@ -305,26 +362,26 @@ var D = class {
305
362
  sessionId;
306
363
  setProtocolVersion;
307
364
  };
308
- var x = "ui/resourceUri", vQ = "text/html;profile=mcp-app";
309
- function mY(X) {
365
+ var h = "ui/resourceUri", SQ = "text/html;profile=mcp-app";
366
+ function nY(X) {
310
367
  let Z = X._meta?.ui?.resourceUri;
311
- if (Z === void 0) Z = X._meta?.[x];
368
+ if (Z === void 0) Z = X._meta?.[h];
312
369
  if (typeof Z === "string" && Z.startsWith("ui://")) return Z;
313
370
  else if (Z !== void 0) throw Error(`Invalid UI resource URI: ${JSON.stringify(Z)}`);
314
371
  }
315
- function pY(X) {
372
+ function cY(X) {
316
373
  let Z = X._meta?.ui?.visibility;
317
374
  if (!Z) return !1;
318
375
  if (Z.length === 1 && Z[0] === "model") return !0;
319
376
  return !1;
320
377
  }
321
- function cY(X) {
378
+ function rY(X) {
322
379
  let Z = X._meta?.ui?.visibility;
323
380
  if (!Z) return !1;
324
381
  if (Z.length === 1 && Z[0] === "app") return !0;
325
382
  return !1;
326
383
  }
327
- function nY(X) {
384
+ function lY(X) {
328
385
  if (!X) return "";
329
386
  let Y = [];
330
387
  if (X.camera) Y.push("camera");
@@ -334,21 +391,28 @@ function nY(X) {
334
391
  return Y.join("; ");
335
392
  }
336
393
  var lQ = [G];
337
- var rQ = class extends Protocol {
394
+ var oQ = class extends j {
338
395
  _client;
339
396
  _hostInfo;
340
397
  _capabilities;
341
398
  _appCapabilities;
342
399
  _hostContext = {};
343
400
  _appInfo;
401
+ eventSchemas = {
402
+ sizechange: w,
403
+ sandboxready: T,
404
+ initialized: S,
405
+ requestteardown: C,
406
+ loggingmessage: LoggingMessageNotificationSchema
407
+ };
344
408
  constructor(X, Y, Z, $) {
345
409
  super($);
346
410
  this._client = X;
347
411
  this._hostInfo = Y;
348
412
  this._capabilities = Z;
349
- this._hostContext = $?.hostContext || {}, this.setRequestHandler(d, (J) => this._oninitialize(J)), this.setRequestHandler(PingRequestSchema, (J, K) => {
413
+ this._hostContext = $?.hostContext || {}, this.setRequestHandler(b, (J) => this._oninitialize(J)), this.setRequestHandler(PingRequestSchema, (J, K) => {
350
414
  return this.onping?.(J.params, K), {};
351
- }), this.setRequestHandler(E, (J) => {
415
+ }), this.replaceRequestHandler(_, (J) => {
352
416
  return { mode: this._hostContext.displayMode ?? "inline" };
353
417
  });
354
418
  }
@@ -359,51 +423,94 @@ var rQ = class extends Protocol {
359
423
  return this._appInfo;
360
424
  }
361
425
  onping;
426
+ get onsizechange() {
427
+ return this.getEventHandler("sizechange");
428
+ }
362
429
  set onsizechange(X) {
363
- this.setNotificationHandler(P, (Y) => X(Y.params));
430
+ this.setEventHandler("sizechange", X);
431
+ }
432
+ get onsandboxready() {
433
+ return this.getEventHandler("sandboxready");
364
434
  }
365
435
  set onsandboxready(X) {
366
- this.setNotificationHandler(L, (Y) => X(Y.params));
436
+ this.setEventHandler("sandboxready", X);
437
+ }
438
+ get oninitialized() {
439
+ return this.getEventHandler("initialized");
367
440
  }
368
441
  set oninitialized(X) {
369
- this.setNotificationHandler(v, (Y) => X(Y.params));
442
+ this.setEventHandler("initialized", X);
443
+ }
444
+ _onmessage;
445
+ get onmessage() {
446
+ return this._onmessage;
370
447
  }
371
448
  set onmessage(X) {
372
- this.setRequestHandler(S, async (Y, Z) => {
373
- return X(Y.params, Z);
449
+ this.warnIfRequestHandlerReplaced("onmessage", this._onmessage, X), this._onmessage = X, this.replaceRequestHandler(y, async (Y, Z) => {
450
+ if (!this._onmessage) throw Error("No onmessage handler set");
451
+ return this._onmessage(Y.params, Z);
374
452
  });
375
453
  }
454
+ _onopenlink;
455
+ get onopenlink() {
456
+ return this._onopenlink;
457
+ }
376
458
  set onopenlink(X) {
377
- this.setRequestHandler(V, async (Y, Z) => {
378
- return X(Y.params, Z);
459
+ this.warnIfRequestHandlerReplaced("onopenlink", this._onopenlink, X), this._onopenlink = X, this.replaceRequestHandler(A, async (Y, Z) => {
460
+ if (!this._onopenlink) throw Error("No onopenlink handler set");
461
+ return this._onopenlink(Y.params, Z);
379
462
  });
380
463
  }
464
+ _ondownloadfile;
465
+ get ondownloadfile() {
466
+ return this._ondownloadfile;
467
+ }
381
468
  set ondownloadfile(X) {
382
- this.setRequestHandler(C, async (Y, Z) => {
383
- return X(Y.params, Z);
469
+ this.warnIfRequestHandlerReplaced("ondownloadfile", this._ondownloadfile, X), this._ondownloadfile = X, this.replaceRequestHandler(f, async (Y, Z) => {
470
+ if (!this._ondownloadfile) throw Error("No ondownloadfile handler set");
471
+ return this._ondownloadfile(Y.params, Z);
384
472
  });
385
473
  }
474
+ get onrequestteardown() {
475
+ return this.getEventHandler("requestteardown");
476
+ }
386
477
  set onrequestteardown(X) {
387
- this.setNotificationHandler(M, (Y) => X(Y.params));
478
+ this.setEventHandler("requestteardown", X);
479
+ }
480
+ _onrequestdisplaymode;
481
+ get onrequestdisplaymode() {
482
+ return this._onrequestdisplaymode;
388
483
  }
389
484
  set onrequestdisplaymode(X) {
390
- this.setRequestHandler(E, async (Y, Z) => {
391
- return X(Y.params, Z);
485
+ this.warnIfRequestHandlerReplaced("onrequestdisplaymode", this._onrequestdisplaymode, X), this._onrequestdisplaymode = X, this.replaceRequestHandler(_, async (Y, Z) => {
486
+ if (!this._onrequestdisplaymode) throw Error("No onrequestdisplaymode handler set");
487
+ return this._onrequestdisplaymode(Y.params, Z);
392
488
  });
393
489
  }
490
+ get onloggingmessage() {
491
+ return this.getEventHandler("loggingmessage");
492
+ }
394
493
  set onloggingmessage(X) {
395
- this.setNotificationHandler(LoggingMessageNotificationSchema, async (Y) => {
396
- X(Y.params);
397
- });
494
+ this.setEventHandler("loggingmessage", X);
495
+ }
496
+ _onupdatemodelcontext;
497
+ get onupdatemodelcontext() {
498
+ return this._onupdatemodelcontext;
398
499
  }
399
500
  set onupdatemodelcontext(X) {
400
- this.setRequestHandler(f, async (Y, Z) => {
401
- return X(Y.params, Z);
501
+ this.warnIfRequestHandlerReplaced("onupdatemodelcontext", this._onupdatemodelcontext, X), this._onupdatemodelcontext = X, this.replaceRequestHandler(d, async (Y, Z) => {
502
+ if (!this._onupdatemodelcontext) throw Error("No onupdatemodelcontext handler set");
503
+ return this._onupdatemodelcontext(Y.params, Z);
402
504
  });
403
505
  }
506
+ _oncalltool;
507
+ get oncalltool() {
508
+ return this._oncalltool;
509
+ }
404
510
  set oncalltool(X) {
405
- this.setRequestHandler(CallToolRequestSchema, async (Y, Z) => {
406
- return X(Y.params, Z);
511
+ this.warnIfRequestHandlerReplaced("oncalltool", this._oncalltool, X), this._oncalltool = X, this.replaceRequestHandler(CallToolRequestSchema, async (Y, Z) => {
512
+ if (!this._oncalltool) throw Error("No oncalltool handler set");
513
+ return this._oncalltool(Y.params, Z);
407
514
  });
408
515
  }
409
516
  sendToolListChanged(X = {}) {
@@ -412,19 +519,34 @@ var rQ = class extends Protocol {
412
519
  params: X
413
520
  });
414
521
  }
522
+ _onlistresources;
523
+ get onlistresources() {
524
+ return this._onlistresources;
525
+ }
415
526
  set onlistresources(X) {
416
- this.setRequestHandler(ListResourcesRequestSchema, async (Y, Z) => {
417
- return X(Y.params, Z);
527
+ this.warnIfRequestHandlerReplaced("onlistresources", this._onlistresources, X), this._onlistresources = X, this.replaceRequestHandler(ListResourcesRequestSchema, async (Y, Z) => {
528
+ if (!this._onlistresources) throw Error("No onlistresources handler set");
529
+ return this._onlistresources(Y.params, Z);
418
530
  });
419
531
  }
532
+ _onlistresourcetemplates;
533
+ get onlistresourcetemplates() {
534
+ return this._onlistresourcetemplates;
535
+ }
420
536
  set onlistresourcetemplates(X) {
421
- this.setRequestHandler(ListResourceTemplatesRequestSchema, async (Y, Z) => {
422
- return X(Y.params, Z);
537
+ this.warnIfRequestHandlerReplaced("onlistresourcetemplates", this._onlistresourcetemplates, X), this._onlistresourcetemplates = X, this.replaceRequestHandler(ListResourceTemplatesRequestSchema, async (Y, Z) => {
538
+ if (!this._onlistresourcetemplates) throw Error("No onlistresourcetemplates handler set");
539
+ return this._onlistresourcetemplates(Y.params, Z);
423
540
  });
424
541
  }
542
+ _onreadresource;
543
+ get onreadresource() {
544
+ return this._onreadresource;
545
+ }
425
546
  set onreadresource(X) {
426
- this.setRequestHandler(ReadResourceRequestSchema, async (Y, Z) => {
427
- return X(Y.params, Z);
547
+ this.warnIfRequestHandlerReplaced("onreadresource", this._onreadresource, X), this._onreadresource = X, this.replaceRequestHandler(ReadResourceRequestSchema, async (Y, Z) => {
548
+ if (!this._onreadresource) throw Error("No onreadresource handler set");
549
+ return this._onreadresource(Y.params, Z);
428
550
  });
429
551
  }
430
552
  sendResourceListChanged(X = {}) {
@@ -433,9 +555,14 @@ var rQ = class extends Protocol {
433
555
  params: X
434
556
  });
435
557
  }
558
+ _onlistprompts;
559
+ get onlistprompts() {
560
+ return this._onlistprompts;
561
+ }
436
562
  set onlistprompts(X) {
437
- this.setRequestHandler(ListPromptsRequestSchema, async (Y, Z) => {
438
- return X(Y.params, Z);
563
+ this.warnIfRequestHandlerReplaced("onlistprompts", this._onlistprompts, X), this._onlistprompts = X, this.replaceRequestHandler(ListPromptsRequestSchema, async (Y, Z) => {
564
+ if (!this._onlistprompts) throw Error("No onlistprompts handler set");
565
+ return this._onlistprompts(Y.params, Z);
439
566
  });
440
567
  }
441
568
  sendPromptListChanged(X = {}) {
@@ -469,7 +596,7 @@ var rQ = class extends Protocol {
469
596
  let Y = {}, Z = !1;
470
597
  for (let $ of Object.keys(X)) {
471
598
  let J = this._hostContext[$], K = X[$];
472
- if (oQ(J, K)) continue;
599
+ if (tQ(J, K)) continue;
473
600
  Y[$] = K, Z = !0;
474
601
  }
475
602
  if (Z) this._hostContext = X, this.sendHostContextChange(Y);
@@ -514,9 +641,21 @@ var rQ = class extends Protocol {
514
641
  return this.request({
515
642
  method: "ui/resource-teardown",
516
643
  params: X
517
- }, H, Y);
644
+ }, g, Y);
518
645
  }
519
646
  sendResourceTeardown = this.teardownResource;
647
+ callTool(X, Y) {
648
+ return this.request({
649
+ method: "tools/call",
650
+ params: X
651
+ }, CallToolResultSchema, Y);
652
+ }
653
+ listTools(X, Y) {
654
+ return this.request({
655
+ method: "tools/list",
656
+ params: X
657
+ }, ListToolsResultSchema, Y);
658
+ }
520
659
  async connect(X) {
521
660
  if (this.transport) throw Error("AppBridge is already connected. Call close() before connecting again.");
522
661
  if (this._client) {
@@ -560,10 +699,10 @@ var rQ = class extends Protocol {
560
699
  return super.connect(X);
561
700
  }
562
701
  };
563
- function oQ(X, Y) {
702
+ function tQ(X, Y) {
564
703
  return JSON.stringify(X) === JSON.stringify(Y);
565
704
  }
566
705
  //#endregion
567
- export { rQ as AppBridge, a as DOWNLOAD_FILE_METHOD, $Q as HOST_CONTEXT_CHANGED_METHOD, WQ as INITIALIZED_METHOD, GQ as INITIALIZE_METHOD, G as LATEST_PROTOCOL_VERSION, t as MESSAGE_METHOD, i as McpUiAppCapabilitiesSchema, W as McpUiDisplayModeSchema, C as McpUiDownloadFileRequestSchema, A as McpUiDownloadFileResultSchema, n as McpUiHostCapabilitiesSchema, k as McpUiHostContextChangedNotificationSchema, y as McpUiHostContextSchema, p as McpUiHostCssSchema, c as McpUiHostStylesSchema, d as McpUiInitializeRequestSchema, b as McpUiInitializeResultSchema, v as McpUiInitializedNotificationSchema, S as McpUiMessageRequestSchema, F as McpUiMessageResultSchema, V as McpUiOpenLinkRequestSchema, I as McpUiOpenLinkResultSchema, E as McpUiRequestDisplayModeRequestSchema, g as McpUiRequestDisplayModeResultSchema, M as McpUiRequestTeardownNotificationSchema, N as McpUiResourceCspSchema, VQ as McpUiResourceMetaSchema, j as McpUiResourcePermissionsSchema, U as McpUiResourceTeardownRequestSchema, H as McpUiResourceTeardownResultSchema, L as McpUiSandboxProxyReadyNotificationSchema, AQ as McpUiSandboxResourceReadyNotificationSchema, P as McpUiSizeChangedNotificationSchema, O as McpUiSupportedContentBlockModalitiesSchema, m as McpUiThemeSchema, R as McpUiToolCancelledNotificationSchema, T as McpUiToolInputNotificationSchema, w as McpUiToolInputPartialNotificationSchema, IQ as McpUiToolMetaSchema, q as McpUiToolResultNotificationSchema, l as McpUiToolVisibilitySchema, f as McpUiUpdateModelContextRequestSchema, o as OPEN_LINK_METHOD, D as PostMessageTransport, DQ as REQUEST_DISPLAY_MODE_METHOD, JQ as REQUEST_TEARDOWN_METHOD, vQ as RESOURCE_MIME_TYPE, KQ as RESOURCE_TEARDOWN_METHOD, x as RESOURCE_URI_META_KEY, s as SANDBOX_PROXY_READY_METHOD, e as SANDBOX_RESOURCE_READY_METHOD, QQ as SIZE_CHANGED_METHOD, lQ as SUPPORTED_PROTOCOL_VERSIONS, ZQ as TOOL_CANCELLED_METHOD, XQ as TOOL_INPUT_METHOD, _ as TOOL_INPUT_PARTIAL_METHOD, YQ as TOOL_RESULT_METHOD, nY as buildAllowAttribute, mY as getToolUiResourceUri, cY as isToolVisibilityAppOnly, pY as isToolVisibilityModelOnly };
706
+ export { oQ as AppBridge, e as DOWNLOAD_FILE_METHOD, GQ as HOST_CONTEXT_CHANGED_METHOD, jQ as INITIALIZED_METHOD, WQ as INITIALIZE_METHOD, G as LATEST_PROTOCOL_VERSION, QQ as MESSAGE_METHOD, l as McpUiAppCapabilitiesSchema, D as McpUiDisplayModeSchema, f as McpUiDownloadFileRequestSchema, L as McpUiDownloadFileResultSchema, r as McpUiHostCapabilitiesSchema, k as McpUiHostContextChangedNotificationSchema, x as McpUiHostContextSchema, n as McpUiHostCssSchema, c as McpUiHostStylesSchema, b as McpUiInitializeRequestSchema, u as McpUiInitializeResultSchema, S as McpUiInitializedNotificationSchema, y as McpUiMessageRequestSchema, P as McpUiMessageResultSchema, A as McpUiOpenLinkRequestSchema, F as McpUiOpenLinkResultSchema, _ as McpUiRequestDisplayModeRequestSchema, q as McpUiRequestDisplayModeResultSchema, C as McpUiRequestTeardownNotificationSchema, B as McpUiResourceCspSchema, FQ as McpUiResourceMetaSchema, E as McpUiResourcePermissionsSchema, M as McpUiResourceTeardownRequestSchema, g as McpUiResourceTeardownResultSchema, T as McpUiSandboxProxyReadyNotificationSchema, PQ as McpUiSandboxResourceReadyNotificationSchema, w as McpUiSizeChangedNotificationSchema, I as McpUiSupportedContentBlockModalitiesSchema, p as McpUiThemeSchema, H as McpUiToolCancelledNotificationSchema, R as McpUiToolInputNotificationSchema, U as McpUiToolInputPartialNotificationSchema, LQ as McpUiToolMetaSchema, v as McpUiToolResultNotificationSchema, o as McpUiToolVisibilitySchema, d as McpUiUpdateModelContextRequestSchema, a as OPEN_LINK_METHOD, z as PostMessageTransport, zQ as REQUEST_DISPLAY_MODE_METHOD, DQ as REQUEST_TEARDOWN_METHOD, SQ as RESOURCE_MIME_TYPE, NQ as RESOURCE_TEARDOWN_METHOD, h as RESOURCE_URI_META_KEY, XQ as SANDBOX_PROXY_READY_METHOD, YQ as SANDBOX_RESOURCE_READY_METHOD, ZQ as SIZE_CHANGED_METHOD, lQ as SUPPORTED_PROTOCOL_VERSIONS, KQ as TOOL_CANCELLED_METHOD, $Q as TOOL_INPUT_METHOD, V as TOOL_INPUT_PARTIAL_METHOD, JQ as TOOL_RESULT_METHOD, lY as buildAllowAttribute, nY as getToolUiResourceUri, rY as isToolVisibilityAppOnly, cY as isToolVisibilityModelOnly };
568
707
 
569
708
  //# sourceMappingURL=@modelcontextprotocol_ext-apps_app-bridge.js.map