sunpeak 0.19.2 → 0.19.10

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 (90) hide show
  1. package/README.md +6 -4
  2. package/bin/commands/dev.mjs +1 -1
  3. package/bin/commands/inspect.mjs +1 -1
  4. package/bin/commands/new.mjs +9 -5
  5. package/bin/commands/start.mjs +3 -1
  6. package/bin/commands/test-init.mjs +478 -76
  7. package/bin/commands/test.mjs +357 -4
  8. package/bin/lib/eval/eval-reporter.mjs +105 -0
  9. package/bin/lib/eval/eval-runner.mjs +310 -0
  10. package/bin/lib/eval/eval-types.d.mts +168 -0
  11. package/bin/lib/eval/eval-vitest-plugin.mjs +158 -0
  12. package/bin/lib/eval/model-registry.mjs +73 -0
  13. package/bin/lib/sandbox-server.mjs +5 -2
  14. package/bin/sunpeak.js +1 -0
  15. package/dist/chatgpt/index.cjs +1 -1
  16. package/dist/chatgpt/index.js +1 -1
  17. package/dist/claude/index.cjs +1 -1
  18. package/dist/claude/index.js +1 -1
  19. package/dist/host/chatgpt/index.cjs +1 -1
  20. package/dist/host/chatgpt/index.js +1 -1
  21. package/dist/index.cjs +134 -124
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.ts +3 -1
  24. package/dist/index.js +71 -62
  25. package/dist/index.js.map +1 -1
  26. package/dist/inspector/index.cjs +1 -1
  27. package/dist/inspector/index.js +1 -1
  28. package/dist/{inspector-Cdo5BK2D.js → inspector-D5DckQuU.js} +236 -98
  29. package/dist/inspector-D5DckQuU.js.map +1 -0
  30. package/dist/{inspector-8nPV2A-z.cjs → inspector-jY9O18z9.cjs} +237 -99
  31. package/dist/inspector-jY9O18z9.cjs.map +1 -0
  32. package/dist/mcp/index.cjs +237 -140
  33. package/dist/mcp/index.cjs.map +1 -1
  34. package/dist/mcp/index.d.ts +1 -1
  35. package/dist/mcp/index.js +230 -134
  36. package/dist/mcp/index.js.map +1 -1
  37. package/dist/mcp/production-server.d.ts +31 -0
  38. package/dist/{protocol-C7kTcBr_.cjs → protocol-C8pFDmcy.cjs} +8194 -8187
  39. package/dist/protocol-C8pFDmcy.cjs.map +1 -0
  40. package/dist/{protocol-BfAACnv0.js → protocol-CRqiPTLT.js} +8186 -8185
  41. package/dist/protocol-CRqiPTLT.js.map +1 -0
  42. package/dist/{use-app-CfP9VypY.js → use-app-Bfargfa3.js} +194 -94
  43. package/dist/use-app-Bfargfa3.js.map +1 -0
  44. package/dist/{use-app-CzcYw1Kz.cjs → use-app-CbsBEmwv.cjs} +254 -148
  45. package/dist/use-app-CbsBEmwv.cjs.map +1 -0
  46. package/package.json +27 -3
  47. package/template/README.md +17 -7
  48. package/template/_gitignore +2 -0
  49. package/template/dist/albums/albums.html +15 -15
  50. package/template/dist/albums/albums.json +1 -1
  51. package/template/dist/carousel/carousel.html +19 -19
  52. package/template/dist/carousel/carousel.json +1 -1
  53. package/template/dist/map/map.html +14 -14
  54. package/template/dist/map/map.json +1 -1
  55. package/template/dist/review/review.html +11 -11
  56. package/template/dist/review/review.json +1 -1
  57. package/template/node_modules/.bin/vitest +2 -2
  58. package/template/node_modules/.vite/deps/_metadata.json +3 -3
  59. package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps.js +192 -91
  60. package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps.js.map +1 -1
  61. package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps_app-bridge.js +231 -92
  62. package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps_app-bridge.js.map +1 -1
  63. package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps_react.js +208 -105
  64. package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps_react.js.map +1 -1
  65. package/template/node_modules/.vite-mcp/deps/_metadata.json +25 -25
  66. package/template/node_modules/.vite-mcp/deps/{protocol-B_qKkui_.js → protocol-BqGB4zBx.js} +45 -45
  67. package/template/node_modules/.vite-mcp/deps/protocol-BqGB4zBx.js.map +1 -0
  68. package/template/node_modules/.vite-mcp/deps/vitest.js +7 -7
  69. package/template/node_modules/.vite-mcp/deps/vitest.js.map +1 -1
  70. package/template/tests/e2e/visual.spec.ts-snapshots/albums-dark-chatgpt-darwin.png +0 -0
  71. package/template/tests/e2e/visual.spec.ts-snapshots/albums-dark-claude-darwin.png +0 -0
  72. package/template/tests/e2e/visual.spec.ts-snapshots/albums-fullscreen-chatgpt-darwin.png +0 -0
  73. package/template/tests/e2e/visual.spec.ts-snapshots/albums-fullscreen-claude-darwin.png +0 -0
  74. package/template/tests/e2e/visual.spec.ts-snapshots/albums-light-chatgpt-darwin.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-page-light-chatgpt-darwin.png +0 -0
  77. package/template/tests/e2e/visual.spec.ts-snapshots/albums-page-light-claude-darwin.png +0 -0
  78. package/template/tests/evals/.env.example +5 -0
  79. package/template/tests/evals/albums.eval.ts +28 -0
  80. package/template/tests/evals/carousel.eval.ts +26 -0
  81. package/template/tests/evals/eval.config.ts +26 -0
  82. package/template/tests/evals/map.eval.ts +23 -0
  83. package/template/tests/evals/review.eval.ts +48 -0
  84. package/dist/inspector-8nPV2A-z.cjs.map +0 -1
  85. package/dist/inspector-Cdo5BK2D.js.map +0 -1
  86. package/dist/protocol-BfAACnv0.js.map +0 -1
  87. package/dist/protocol-C7kTcBr_.cjs.map +0 -1
  88. package/dist/use-app-CfP9VypY.js.map +0 -1
  89. package/dist/use-app-CzcYw1Kz.cjs.map +0 -1
  90. package/template/node_modules/.vite-mcp/deps/protocol-B_qKkui_.js.map +0 -1
@@ -12,5 +12,5 @@
12
12
  }
13
13
  },
14
14
  "name": "review",
15
- "uri": "ui://review-mnnqsot1"
15
+ "uri": "ui://review-mnszmwah"
16
16
  }
@@ -10,9 +10,9 @@ case `uname` in
10
10
  esac
11
11
 
12
12
  if [ -z "$NODE_PATH" ]; then
13
- export NODE_PATH="/home/runner/work/sunpeak/sunpeak/node_modules/.pnpm/vitest@4.1.2_@types+node@25.5.2_happy-dom@18.0.1_jsdom@29.0.1_vite@8.0.3_@types+node@25_c9204fc1c7dd847b5a2240e35a324b5d/node_modules/vitest/node_modules:/home/runner/work/sunpeak/sunpeak/node_modules/.pnpm/vitest@4.1.2_@types+node@25.5.2_happy-dom@18.0.1_jsdom@29.0.1_vite@8.0.3_@types+node@25_c9204fc1c7dd847b5a2240e35a324b5d/node_modules:/home/runner/work/sunpeak/sunpeak/node_modules/.pnpm/node_modules"
13
+ export NODE_PATH="/home/runner/work/sunpeak/sunpeak/node_modules/.pnpm/vitest@4.1.2_@opentelemetry+api@1.9.0_@types+node@25.5.2_happy-dom@18.0.1_jsdom@29.0.1__cf001624456b7837f7b99c4ef7b4c061/node_modules/vitest/node_modules:/home/runner/work/sunpeak/sunpeak/node_modules/.pnpm/vitest@4.1.2_@opentelemetry+api@1.9.0_@types+node@25.5.2_happy-dom@18.0.1_jsdom@29.0.1__cf001624456b7837f7b99c4ef7b4c061/node_modules:/home/runner/work/sunpeak/sunpeak/node_modules/.pnpm/node_modules"
14
14
  else
15
- export NODE_PATH="/home/runner/work/sunpeak/sunpeak/node_modules/.pnpm/vitest@4.1.2_@types+node@25.5.2_happy-dom@18.0.1_jsdom@29.0.1_vite@8.0.3_@types+node@25_c9204fc1c7dd847b5a2240e35a324b5d/node_modules/vitest/node_modules:/home/runner/work/sunpeak/sunpeak/node_modules/.pnpm/vitest@4.1.2_@types+node@25.5.2_happy-dom@18.0.1_jsdom@29.0.1_vite@8.0.3_@types+node@25_c9204fc1c7dd847b5a2240e35a324b5d/node_modules:/home/runner/work/sunpeak/sunpeak/node_modules/.pnpm/node_modules:$NODE_PATH"
15
+ export NODE_PATH="/home/runner/work/sunpeak/sunpeak/node_modules/.pnpm/vitest@4.1.2_@opentelemetry+api@1.9.0_@types+node@25.5.2_happy-dom@18.0.1_jsdom@29.0.1__cf001624456b7837f7b99c4ef7b4c061/node_modules/vitest/node_modules:/home/runner/work/sunpeak/sunpeak/node_modules/.pnpm/vitest@4.1.2_@opentelemetry+api@1.9.0_@types+node@25.5.2_happy-dom@18.0.1_jsdom@29.0.1__cf001624456b7837f7b99c4ef7b4c061/node_modules:/home/runner/work/sunpeak/sunpeak/node_modules/.pnpm/node_modules:$NODE_PATH"
16
16
  fi
17
17
  if [ -x "$basedir/node" ]; then
18
18
  exec "$basedir/node" "$basedir/../vitest/vitest.mjs" "$@"
@@ -1,8 +1,8 @@
1
1
  {
2
- "hash": "d60fea2c",
2
+ "hash": "c19ea8a1",
3
3
  "configHash": "a598103f",
4
- "lockfileHash": "125af7d7",
5
- "browserHash": "b2bebf73",
4
+ "lockfileHash": "18567c78",
5
+ "browserHash": "34bbafa0",
6
6
  "optimized": {},
7
7
  "chunks": {}
8
8
  }
@@ -1,8 +1,65 @@
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 { S as ResourceLinkSchema, T as ToolSchema, _ as PingRequestSchema, a as EmbeddedResourceSchema, b as ReadResourceResultSchema, c as JSONRPCMessageSchema, h as ListToolsRequestSchema, i as ContentBlockSchema, m as ListResourcesResultSchema, n as CallToolRequestSchema, o as EmptyResultSchema, r as CallToolResultSchema, s as ImplementationSchema, t as Protocol, x as RequestIdSchema } 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.js
4
- var E = "2026-01-26", y = "ui/open-link", u = "ui/download-file", f = "ui/message", d = "ui/notifications/sandbox-proxy-ready", h = "ui/notifications/sandbox-resource-ready", m = "ui/notifications/size-changed", i = "ui/notifications/tool-input", z = "ui/notifications/tool-input-partial", l = "ui/notifications/tool-result", r = "ui/notifications/tool-cancelled", c = "ui/notifications/host-context-changed", p = "ui/notifications/request-teardown", n = "ui/resource-teardown", a = "ui/initialize", o = "ui/notifications/initialized", s = "ui/request-display-mode";
5
- var K = class {
2
+ import { C as ResourceLinkSchema, E as ToolSchema, S as RequestIdSchema, a as EmbeddedResourceSchema, c as JSONRPCMessageSchema, h as ListToolsRequestSchema, i as ContentBlockSchema, m as ListResourcesResultSchema, n as CallToolRequestSchema, o as EmptyResultSchema, r as CallToolResultSchema, s as ImplementationSchema, t as Protocol, v as PingRequestSchema, x as ReadResourceResultSchema } 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.js
4
+ var z = 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 D = Y;
17
+ super.setNotificationHandler(Z, (J) => {
18
+ let G = J.params;
19
+ this.onEventDispatch(X, G), D.onHandler?.(G);
20
+ for (let V of [...D.listeners]) V(G);
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 B = "2026-01-26", u = "ui/open-link", d = "ui/download-file", h = "ui/message", i = "ui/notifications/sandbox-proxy-ready", m = "ui/notifications/sandbox-resource-ready", p = "ui/notifications/size-changed", r = "ui/notifications/tool-input", E = "ui/notifications/tool-input-partial", c = "ui/notifications/tool-result", l = "ui/notifications/tool-cancelled", n = "ui/notifications/host-context-changed", a = "ui/notifications/request-teardown", o = "ui/resource-teardown", s = "ui/initialize", t = "ui/notifications/initialized", e = "ui/request-display-mode";
62
+ var N = class {
6
63
  eventTarget;
7
64
  eventSource;
8
65
  messageListener;
@@ -36,11 +93,11 @@ var K = class {
36
93
  sessionId;
37
94
  setProtocolVersion;
38
95
  };
39
- var v = union([literal("light"), literal("dark")]).describe("Color theme preference for the host environment."), D = union([
96
+ var k = union([literal("light"), literal("dark")]).describe("Color theme preference for the host environment."), K = union([
40
97
  literal("inline"),
41
98
  literal("fullscreen"),
42
99
  literal("pip")
43
- ]).describe("Display mode for UI presentation."), DQ = record(union([
100
+ ]).describe("Display mode for UI presentation."), KQ = record(union([
44
101
  literal("--color-background-primary"),
45
102
  literal("--color-background-secondary"),
46
103
  literal("--color-background-tertiary"),
@@ -135,13 +192,13 @@ Individual style keys are optional - hosts may provide any subset of these value
135
192
  Values are strings containing CSS values (colors, sizes, font stacks, etc.).
136
193
 
137
194
  Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
138
- for compatibility with Zod schema generation. Both are functionally equivalent for validation.`), JQ = object({
195
+ for compatibility with Zod schema generation. Both are functionally equivalent for validation.`), GQ = object({
139
196
  method: literal("ui/open-link"),
140
197
  params: object({ url: string().describe("URL to open in the host's browser") })
141
- }), B = object({ isError: boolean().optional().describe("True if the host failed to open the URL (e.g., due to security policy).") }).passthrough(), _ = object({ isError: boolean().optional().describe("True if the download failed (e.g., user cancelled or host denied).") }).passthrough(), O = object({ isError: boolean().optional().describe("True if the host rejected or failed to deliver the message.") }).passthrough(), KQ = object({
198
+ }), O = object({ isError: boolean().optional().describe("True if the host failed to open the URL (e.g., due to security policy).") }).passthrough(), I = object({ isError: boolean().optional().describe("True if the download failed (e.g., user cancelled or host denied).") }).passthrough(), w = object({ isError: boolean().optional().describe("True if the host rejected or failed to deliver the message.") }).passthrough(), VQ = object({
142
199
  method: literal("ui/notifications/sandbox-proxy-ready"),
143
200
  params: object({})
144
- }), G = object({
201
+ }), W = object({
145
202
  connectDomains: array(string()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket).
146
203
 
147
204
  - Maps to CSP \`connect-src\` directive
@@ -149,43 +206,43 @@ for compatibility with Zod schema generation. Both are functionally equivalent f
149
206
  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)"),
150
207
  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'`)"),
151
208
  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'`)")
152
- }), V = object({
209
+ }), j = object({
153
210
  camera: object({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),
154
211
  microphone: object({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),
155
212
  geolocation: object({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),
156
213
  clipboardWrite: object({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")
157
- }), GQ = object({
214
+ }), NQ = object({
158
215
  method: literal("ui/notifications/size-changed"),
159
216
  params: object({
160
217
  width: number().optional().describe("New width in pixels."),
161
218
  height: number().optional().describe("New height in pixels.")
162
219
  })
163
- }), I = object({
220
+ }), A = object({
164
221
  method: literal("ui/notifications/tool-input"),
165
222
  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.") })
166
- }), w = object({
223
+ }), F = object({
167
224
  method: literal("ui/notifications/tool-input-partial"),
168
225
  params: object({ arguments: record(string(), unknown().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).") })
169
- }), A = object({
226
+ }), P = object({
170
227
  method: literal("ui/notifications/tool-cancelled"),
171
228
  params: object({ reason: string().optional().describe("Optional reason for the cancellation (e.g., \"user action\", \"timeout\").") })
172
- }), b = object({ fonts: string().optional() }), k = object({
173
- variables: DQ.optional().describe("CSS variables for theming the app."),
174
- css: b.optional().describe("CSS blocks that apps can inject.")
175
- }), F = object({
229
+ }), g = object({ fonts: string().optional() }), x = object({
230
+ variables: KQ.optional().describe("CSS variables for theming the app."),
231
+ css: g.optional().describe("CSS blocks that apps can inject.")
232
+ }), q = object({
176
233
  method: literal("ui/resource-teardown"),
177
234
  params: object({})
178
- }), VQ = record(string(), unknown()), L = object({
235
+ }), WQ = record(string(), unknown()), _ = object({
179
236
  text: object({}).optional().describe("Host supports text content blocks."),
180
237
  image: object({}).optional().describe("Host supports image content blocks."),
181
238
  audio: object({}).optional().describe("Host supports audio content blocks."),
182
239
  resource: object({}).optional().describe("Host supports resource content blocks."),
183
240
  resourceLink: object({}).optional().describe("Host supports resource link content blocks."),
184
241
  structuredContent: object({}).optional().describe("Host supports structured content.")
185
- }), WQ = object({
242
+ }), jQ = object({
186
243
  method: literal("ui/notifications/request-teardown"),
187
244
  params: object({}).optional()
188
- }), C = object({
245
+ }), S = object({
189
246
  experimental: object({}).optional().describe("Experimental features (structure TBD)."),
190
247
  openLinks: object({}).optional().describe("Host supports opening external URLs."),
191
248
  downloadFile: object({}).optional().describe("Host supports file downloads via ui/download-file."),
@@ -193,21 +250,21 @@ for compatibility with Zod schema generation. Both are functionally equivalent f
193
250
  serverResources: object({ listChanged: boolean().optional().describe("Host supports resources/list_changed notifications.") }).optional().describe("Host can proxy resource reads to the MCP server."),
194
251
  logging: object({}).optional().describe("Host accepts log messages."),
195
252
  sandbox: 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.")
253
+ permissions: j.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),
254
+ csp: W.optional().describe("CSP domains approved by the host.")
198
255
  }).optional().describe("Sandbox configuration applied by the host."),
199
- updateModelContext: L.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),
200
- message: L.optional().describe("Host supports receiving content messages (ui/message) from the view.")
201
- }), x = object({
256
+ updateModelContext: _.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),
257
+ message: _.optional().describe("Host supports receiving content messages (ui/message) from the view.")
258
+ }), y = object({
202
259
  experimental: object({}).optional().describe("Experimental features (structure TBD)."),
203
260
  tools: object({ listChanged: boolean().optional().describe("App supports tools/list_changed notifications.") }).optional().describe("App exposes MCP-style tools that the host can call."),
204
- availableDisplayModes: array(D).optional().describe("Display modes the app supports.")
205
- }), NQ = object({
261
+ availableDisplayModes: array(K).optional().describe("Display modes the app supports.")
262
+ }), LQ = object({
206
263
  method: literal("ui/notifications/initialized"),
207
264
  params: object({}).optional()
208
- }), jQ = 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."),
265
+ }), zQ = object({
266
+ csp: W.optional().describe("Content Security Policy configuration for UI resources."),
267
+ permissions: j.optional().describe("Sandbox permissions requested by the UI resource."),
211
268
  domain: string().optional().describe(`Dedicated origin for view sandbox.
212
269
 
213
270
  Useful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists.
@@ -224,45 +281,45 @@ Boolean requesting whether a visible border and background is provided by the ho
224
281
  - \`true\`: request visible border + background
225
282
  - \`false\`: request no visible border + background
226
283
  - omitted: host decides border`)
227
- }), EQ = object({
284
+ }), BQ = object({
228
285
  method: literal("ui/request-display-mode"),
229
- params: object({ mode: D.describe("The display mode being requested.") })
230
- }), P = object({ mode: D.describe("The display mode that was actually set. May differ from requested if not supported.") }).passthrough(), g = union([literal("model"), literal("app")]).describe("Tool visibility scope - who can access the tool."), zQ = object({
286
+ params: object({ mode: K.describe("The display mode being requested.") })
287
+ }), T = object({ mode: K.describe("The display mode that was actually set. May differ from requested if not supported.") }).passthrough(), v = union([literal("model"), literal("app")]).describe("Tool visibility scope - who can access the tool."), EQ = object({
231
288
  resourceUri: string().optional(),
232
- visibility: array(g).optional().describe(`Who can access this tool. Default: ["model", "app"]
289
+ visibility: array(v).optional().describe(`Who can access this tool. Default: ["model", "app"]
233
290
  - "model": Tool visible to and callable by the agent
234
291
  - "app": Tool callable by the app from this server only`)
235
292
  });
236
293
  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.") });
237
- var LQ = object({
294
+ var _Q = object({
238
295
  method: literal("ui/download-file"),
239
296
  params: object({ contents: array(union([EmbeddedResourceSchema, ResourceLinkSchema])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.") })
240
- }), BQ = object({
297
+ }), OQ = object({
241
298
  method: literal("ui/message"),
242
299
  params: object({
243
300
  role: literal("user").describe("Message role, currently only \"user\" is supported."),
244
301
  content: array(ContentBlockSchema).describe("Message content blocks (text, image, etc.).")
245
302
  })
246
- }), _Q = object({
303
+ }), IQ = object({
247
304
  method: literal("ui/notifications/sandbox-resource-ready"),
248
305
  params: object({
249
306
  html: string().describe("HTML content to load into the inner iframe."),
250
307
  sandbox: string().optional().describe("Optional override for the inner iframe's sandbox attribute."),
251
- csp: G.optional().describe("CSP configuration from resource metadata."),
252
- permissions: V.optional().describe("Sandbox permissions from resource metadata.")
308
+ csp: W.optional().describe("CSP configuration from resource metadata."),
309
+ permissions: j.optional().describe("Sandbox permissions from resource metadata.")
253
310
  })
254
- }), q = object({
311
+ }), R = object({
255
312
  method: literal("ui/notifications/tool-result"),
256
313
  params: CallToolResultSchema.describe("Standard MCP tool execution result.")
257
- }), T = object({
314
+ }), U = object({
258
315
  toolInfo: object({
259
316
  id: RequestIdSchema.optional().describe("JSON-RPC id of the tools/call request."),
260
317
  tool: ToolSchema.describe("Tool definition including name, inputSchema, etc.")
261
318
  }).optional().describe("Metadata of the tool call that instantiated this App."),
262
- theme: v.optional().describe("Current color theme preference."),
263
- styles: k.optional().describe("Style configuration for theming the app."),
264
- displayMode: D.optional().describe("How the UI is currently displayed."),
265
- availableDisplayModes: array(D).optional().describe("Display modes the host supports."),
319
+ theme: k.optional().describe("Current color theme preference."),
320
+ styles: x.optional().describe("Style configuration for theming the app."),
321
+ displayMode: K.optional().describe("How the UI is currently displayed."),
322
+ availableDisplayModes: array(K).optional().describe("Display modes the host supports."),
266
323
  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
267
324
  container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),
268
325
  locale: string().optional().describe("User's language and region preference in BCP 47 format."),
@@ -283,53 +340,66 @@ container holding the app. Specify either width or maxWidth, and either height o
283
340
  bottom: number().describe("Bottom safe area inset in pixels."),
284
341
  left: number().describe("Left safe area inset in pixels.")
285
342
  }).optional().describe("Mobile safe area boundaries in pixels.")
286
- }).passthrough(), R = object({
343
+ }).passthrough(), H = object({
287
344
  method: literal("ui/notifications/host-context-changed"),
288
- params: T.describe("Partial context update containing only changed fields.")
289
- }), OQ = object({
345
+ params: U.describe("Partial context update containing only changed fields.")
346
+ }), wQ = object({
290
347
  method: literal("ui/update-model-context"),
291
348
  params: object({
292
349
  content: array(ContentBlockSchema).optional().describe("Context content blocks (text, image, etc.)."),
293
350
  structuredContent: record(string(), unknown().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")
294
351
  })
295
- }), IQ = object({
352
+ }), AQ = object({
296
353
  method: literal("ui/initialize"),
297
354
  params: object({
298
355
  appInfo: ImplementationSchema.describe("App identification (name and version)."),
299
- appCapabilities: x.describe("Features and capabilities this app provides."),
356
+ appCapabilities: y.describe("Features and capabilities this app provides."),
300
357
  protocolVersion: string().describe("Protocol version this app supports.")
301
358
  })
302
- }), U = object({
359
+ }), M = object({
303
360
  protocolVersion: string().describe("Negotiated protocol version string (e.g., \"2025-11-21\")."),
304
361
  hostInfo: ImplementationSchema.describe("Host application identification and version."),
305
- hostCapabilities: C.describe("Features and capabilities provided by the host."),
306
- hostContext: T.describe("Rich context about the host environment.")
362
+ hostCapabilities: S.describe("Features and capabilities provided by the host."),
363
+ hostContext: U.describe("Rich context about the host environment.")
307
364
  }).passthrough();
308
- function wQ() {
365
+ function FQ() {
309
366
  let X = document.documentElement.getAttribute("data-theme");
310
367
  if (X === "dark" || X === "light") return X;
311
368
  return document.documentElement.classList.contains("dark") ? "dark" : "light";
312
369
  }
313
- function AQ(X) {
370
+ function PQ(X) {
314
371
  let Y = document.documentElement;
315
372
  Y.setAttribute("data-theme", X), Y.style.colorScheme = X;
316
373
  }
317
- function FQ(X, Y = document.documentElement) {
374
+ function qQ(X, Y = document.documentElement) {
318
375
  for (let [Z, $] of Object.entries(X)) if ($ !== void 0) Y.style.setProperty(Z, $);
319
376
  }
320
- function PQ(X) {
377
+ function TQ(X) {
321
378
  if (document.getElementById("__mcp-host-fonts")) return;
322
379
  let Z = document.createElement("style");
323
380
  Z.id = "__mcp-host-fonts", Z.textContent = X, document.head.appendChild(Z);
324
381
  }
325
- var RX = "ui/resourceUri", UX = "text/html;profile=mcp-app";
326
- var kQ = class extends Protocol {
382
+ var MX = "ui/resourceUri", CX = "text/html;profile=mcp-app";
383
+ var gQ = class extends z {
327
384
  _appInfo;
328
385
  _capabilities;
329
386
  options;
330
387
  _hostCapabilities;
331
388
  _hostInfo;
332
389
  _hostContext;
390
+ eventSchemas = {
391
+ toolinput: A,
392
+ toolinputpartial: F,
393
+ toolresult: R,
394
+ toolcancelled: P,
395
+ hostcontextchanged: H
396
+ };
397
+ onEventDispatch(X, Y) {
398
+ if (X === "hostcontextchanged") this._hostContext = {
399
+ ...this._hostContext,
400
+ ...Y
401
+ };
402
+ }
333
403
  constructor(X, Y = {}, Z = { autoResize: !0 }) {
334
404
  super(Z);
335
405
  this._appInfo = X;
@@ -337,7 +407,7 @@ var kQ = class extends Protocol {
337
407
  this.options = Z;
338
408
  this.setRequestHandler(PingRequestSchema, ($) => {
339
409
  return console.log("Received ping:", $.params), {};
340
- }), this.onhostcontextchanged = () => {};
410
+ }), this.setEventHandler("hostcontextchanged", void 0);
341
411
  }
342
412
  getHostCapabilities() {
343
413
  return this._hostCapabilities;
@@ -348,34 +418,65 @@ var kQ = class extends Protocol {
348
418
  getHostContext() {
349
419
  return this._hostContext;
350
420
  }
421
+ get ontoolinput() {
422
+ return this.getEventHandler("toolinput");
423
+ }
351
424
  set ontoolinput(X) {
352
- this.setNotificationHandler(I, (Y) => X(Y.params));
425
+ this.setEventHandler("toolinput", X);
426
+ }
427
+ get ontoolinputpartial() {
428
+ return this.getEventHandler("toolinputpartial");
353
429
  }
354
430
  set ontoolinputpartial(X) {
355
- this.setNotificationHandler(w, (Y) => X(Y.params));
431
+ this.setEventHandler("toolinputpartial", X);
432
+ }
433
+ get ontoolresult() {
434
+ return this.getEventHandler("toolresult");
356
435
  }
357
436
  set ontoolresult(X) {
358
- this.setNotificationHandler(q, (Y) => X(Y.params));
437
+ this.setEventHandler("toolresult", X);
438
+ }
439
+ get ontoolcancelled() {
440
+ return this.getEventHandler("toolcancelled");
359
441
  }
360
442
  set ontoolcancelled(X) {
361
- this.setNotificationHandler(A, (Y) => X(Y.params));
443
+ this.setEventHandler("toolcancelled", X);
444
+ }
445
+ get onhostcontextchanged() {
446
+ return this.getEventHandler("hostcontextchanged");
362
447
  }
363
448
  set onhostcontextchanged(X) {
364
- this.setNotificationHandler(R, (Y) => {
365
- this._hostContext = {
366
- ...this._hostContext,
367
- ...Y.params
368
- }, X(Y.params);
369
- });
449
+ this.setEventHandler("hostcontextchanged", X);
450
+ }
451
+ _onteardown;
452
+ get onteardown() {
453
+ return this._onteardown;
370
454
  }
371
455
  set onteardown(X) {
372
- this.setRequestHandler(F, (Y, Z) => X(Y.params, Z));
456
+ this.warnIfRequestHandlerReplaced("onteardown", this._onteardown, X), this._onteardown = X, this.replaceRequestHandler(q, (Y, Z) => {
457
+ if (!this._onteardown) throw Error("No onteardown handler set");
458
+ return this._onteardown(Y.params, Z);
459
+ });
460
+ }
461
+ _oncalltool;
462
+ get oncalltool() {
463
+ return this._oncalltool;
373
464
  }
374
465
  set oncalltool(X) {
375
- this.setRequestHandler(CallToolRequestSchema, (Y, Z) => X(Y.params, Z));
466
+ this.warnIfRequestHandlerReplaced("oncalltool", this._oncalltool, X), this._oncalltool = X, this.replaceRequestHandler(CallToolRequestSchema, (Y, Z) => {
467
+ if (!this._oncalltool) throw Error("No oncalltool handler set");
468
+ return this._oncalltool(Y.params, Z);
469
+ });
470
+ }
471
+ _onlisttools;
472
+ get onlisttools() {
473
+ return this._onlisttools;
376
474
  }
377
475
  set onlisttools(X) {
378
- this.setRequestHandler(ListToolsRequestSchema, (Y, Z) => X(Y.params, Z));
476
+ this.warnIfRequestHandlerReplaced("onlisttools", this._onlisttools, X), this._onlisttools = X, this.replaceRequestHandler(ListToolsRequestSchema, (Y, Z) => {
477
+ if (!this._onlisttools) throw Error("No onlisttools handler set");
478
+ return this._onlisttools(Y.params, Z);
479
+ });
379
480
  }
380
481
  assertCapabilityForMethod(X) {}
381
482
  assertRequestHandlerCapability(X) {
@@ -419,7 +520,7 @@ var kQ = class extends Protocol {
419
520
  return this.request({
420
521
  method: "ui/message",
421
522
  params: X
422
- }, O, Y);
523
+ }, w, Y);
423
524
  }
424
525
  sendLog(X) {
425
526
  return this.notification({
@@ -437,14 +538,14 @@ var kQ = class extends Protocol {
437
538
  return this.request({
438
539
  method: "ui/open-link",
439
540
  params: X
440
- }, B, Y);
541
+ }, O, Y);
441
542
  }
442
543
  sendOpenLink = this.openLink;
443
544
  downloadFile(X, Y) {
444
545
  return this.request({
445
546
  method: "ui/download-file",
446
547
  params: X
447
- }, _, Y);
548
+ }, I, Y);
448
549
  }
449
550
  requestTeardown(X = {}) {
450
551
  return this.notification({
@@ -456,7 +557,7 @@ var kQ = class extends Protocol {
456
557
  return this.request({
457
558
  method: "ui/request-display-mode",
458
559
  params: X
459
- }, P, Y);
560
+ }, T, Y);
460
561
  }
461
562
  sendSizeChanged(X) {
462
563
  return this.notification({
@@ -469,22 +570,22 @@ var kQ = class extends Protocol {
469
570
  if (X) return;
470
571
  X = !0, requestAnimationFrame(() => {
471
572
  X = !1;
472
- let J = document.documentElement, S = J.style.height;
573
+ let J = document.documentElement, G = J.style.height;
473
574
  J.style.height = "max-content";
474
- let N = Math.ceil(J.getBoundingClientRect().height);
475
- J.style.height = S;
476
- let j = Math.ceil(window.innerWidth);
477
- if (j !== Y || N !== Z) Y = j, Z = N, this.sendSizeChanged({
478
- width: j,
479
- height: N
575
+ let V = Math.ceil(J.getBoundingClientRect().height);
576
+ J.style.height = G;
577
+ let L = Math.ceil(window.innerWidth);
578
+ if (L !== Y || V !== Z) Y = L, Z = V, this.sendSizeChanged({
579
+ width: L,
580
+ height: V
480
581
  });
481
582
  });
482
583
  };
483
584
  $();
484
- let W = new ResizeObserver($);
485
- return W.observe(document.documentElement), W.observe(document.body), () => W.disconnect();
585
+ let D = new ResizeObserver($);
586
+ return D.observe(document.documentElement), D.observe(document.body), () => D.disconnect();
486
587
  }
487
- async connect(X = new K(window.parent, window.parent), Y) {
588
+ async connect(X = new N(window.parent, window.parent), Y) {
488
589
  if (this.transport) throw Error("App is already connected. Call close() before connecting again.");
489
590
  await super.connect(X);
490
591
  try {
@@ -493,9 +594,9 @@ var kQ = class extends Protocol {
493
594
  params: {
494
595
  appCapabilities: this._capabilities,
495
596
  appInfo: this._appInfo,
496
- protocolVersion: E
597
+ protocolVersion: B
497
598
  }
498
- }, U, Y);
599
+ }, M, Y);
499
600
  if (Z === void 0) throw Error(`Server sent invalid initialize result: ${Z}`);
500
601
  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();
501
602
  } catch (Z) {
@@ -504,6 +605,6 @@ var kQ = class extends Protocol {
504
605
  }
505
606
  };
506
607
  //#endregion
507
- export { kQ as App, u as DOWNLOAD_FILE_METHOD, c as HOST_CONTEXT_CHANGED_METHOD, o as INITIALIZED_METHOD, a as INITIALIZE_METHOD, E as LATEST_PROTOCOL_VERSION, f as MESSAGE_METHOD, x as McpUiAppCapabilitiesSchema, D as McpUiDisplayModeSchema, LQ as McpUiDownloadFileRequestSchema, _ as McpUiDownloadFileResultSchema, C as McpUiHostCapabilitiesSchema, R as McpUiHostContextChangedNotificationSchema, T as McpUiHostContextSchema, b as McpUiHostCssSchema, k as McpUiHostStylesSchema, IQ as McpUiInitializeRequestSchema, U as McpUiInitializeResultSchema, NQ as McpUiInitializedNotificationSchema, BQ as McpUiMessageRequestSchema, O as McpUiMessageResultSchema, JQ as McpUiOpenLinkRequestSchema, B as McpUiOpenLinkResultSchema, EQ as McpUiRequestDisplayModeRequestSchema, P as McpUiRequestDisplayModeResultSchema, WQ as McpUiRequestTeardownNotificationSchema, G as McpUiResourceCspSchema, jQ as McpUiResourceMetaSchema, V as McpUiResourcePermissionsSchema, F as McpUiResourceTeardownRequestSchema, VQ as McpUiResourceTeardownResultSchema, KQ as McpUiSandboxProxyReadyNotificationSchema, _Q as McpUiSandboxResourceReadyNotificationSchema, GQ as McpUiSizeChangedNotificationSchema, L as McpUiSupportedContentBlockModalitiesSchema, v as McpUiThemeSchema, A as McpUiToolCancelledNotificationSchema, I as McpUiToolInputNotificationSchema, w as McpUiToolInputPartialNotificationSchema, zQ as McpUiToolMetaSchema, q as McpUiToolResultNotificationSchema, g as McpUiToolVisibilitySchema, OQ as McpUiUpdateModelContextRequestSchema, y as OPEN_LINK_METHOD, K as PostMessageTransport, s as REQUEST_DISPLAY_MODE_METHOD, p as REQUEST_TEARDOWN_METHOD, UX as RESOURCE_MIME_TYPE, n as RESOURCE_TEARDOWN_METHOD, RX as RESOURCE_URI_META_KEY, d as SANDBOX_PROXY_READY_METHOD, h as SANDBOX_RESOURCE_READY_METHOD, m as SIZE_CHANGED_METHOD, r as TOOL_CANCELLED_METHOD, i as TOOL_INPUT_METHOD, z as TOOL_INPUT_PARTIAL_METHOD, l as TOOL_RESULT_METHOD, AQ as applyDocumentTheme, PQ as applyHostFonts, FQ as applyHostStyleVariables, wQ as getDocumentTheme };
608
+ export { gQ as App, d as DOWNLOAD_FILE_METHOD, n as HOST_CONTEXT_CHANGED_METHOD, t as INITIALIZED_METHOD, s as INITIALIZE_METHOD, B as LATEST_PROTOCOL_VERSION, h as MESSAGE_METHOD, y as McpUiAppCapabilitiesSchema, K as McpUiDisplayModeSchema, _Q as McpUiDownloadFileRequestSchema, I as McpUiDownloadFileResultSchema, S as McpUiHostCapabilitiesSchema, H as McpUiHostContextChangedNotificationSchema, U as McpUiHostContextSchema, g as McpUiHostCssSchema, x as McpUiHostStylesSchema, AQ as McpUiInitializeRequestSchema, M as McpUiInitializeResultSchema, LQ as McpUiInitializedNotificationSchema, OQ as McpUiMessageRequestSchema, w as McpUiMessageResultSchema, GQ as McpUiOpenLinkRequestSchema, O as McpUiOpenLinkResultSchema, BQ as McpUiRequestDisplayModeRequestSchema, T as McpUiRequestDisplayModeResultSchema, jQ as McpUiRequestTeardownNotificationSchema, W as McpUiResourceCspSchema, zQ as McpUiResourceMetaSchema, j as McpUiResourcePermissionsSchema, q as McpUiResourceTeardownRequestSchema, WQ as McpUiResourceTeardownResultSchema, VQ as McpUiSandboxProxyReadyNotificationSchema, IQ as McpUiSandboxResourceReadyNotificationSchema, NQ as McpUiSizeChangedNotificationSchema, _ as McpUiSupportedContentBlockModalitiesSchema, k as McpUiThemeSchema, P as McpUiToolCancelledNotificationSchema, A as McpUiToolInputNotificationSchema, F as McpUiToolInputPartialNotificationSchema, EQ as McpUiToolMetaSchema, R as McpUiToolResultNotificationSchema, v as McpUiToolVisibilitySchema, wQ as McpUiUpdateModelContextRequestSchema, u as OPEN_LINK_METHOD, N as PostMessageTransport, z as ProtocolWithEvents, e as REQUEST_DISPLAY_MODE_METHOD, a as REQUEST_TEARDOWN_METHOD, CX as RESOURCE_MIME_TYPE, o as RESOURCE_TEARDOWN_METHOD, MX as RESOURCE_URI_META_KEY, i as SANDBOX_PROXY_READY_METHOD, m as SANDBOX_RESOURCE_READY_METHOD, p as SIZE_CHANGED_METHOD, l as TOOL_CANCELLED_METHOD, r as TOOL_INPUT_METHOD, E as TOOL_INPUT_PARTIAL_METHOD, c as TOOL_RESULT_METHOD, PQ as applyDocumentTheme, TQ as applyHostFonts, qQ as applyHostStyleVariables, FQ as getDocumentTheme };
508
609
 
509
610
  //# sourceMappingURL=@modelcontextprotocol_ext-apps.js.map