sunpeak 0.19.2 → 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.
- package/dist/chatgpt/index.cjs +1 -1
- package/dist/chatgpt/index.js +1 -1
- package/dist/claude/index.cjs +1 -1
- package/dist/claude/index.js +1 -1
- package/dist/host/chatgpt/index.cjs +1 -1
- package/dist/host/chatgpt/index.js +1 -1
- package/dist/index.cjs +134 -124
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +71 -62
- package/dist/index.js.map +1 -1
- package/dist/inspector/index.cjs +1 -1
- package/dist/inspector/index.js +1 -1
- package/dist/{inspector-Cdo5BK2D.js → inspector-Bp9jrHIu.js} +218 -80
- package/dist/inspector-Bp9jrHIu.js.map +1 -0
- package/dist/{inspector-8nPV2A-z.cjs → inspector-Cvq3yjNL.cjs} +219 -81
- package/dist/inspector-Cvq3yjNL.cjs.map +1 -0
- package/dist/mcp/index.cjs +235 -138
- package/dist/mcp/index.cjs.map +1 -1
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +228 -132
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/production-server.d.ts +31 -0
- package/dist/{protocol-C7kTcBr_.cjs → protocol-C8pFDmcy.cjs} +8194 -8187
- package/dist/protocol-C8pFDmcy.cjs.map +1 -0
- package/dist/{protocol-BfAACnv0.js → protocol-CRqiPTLT.js} +8186 -8185
- package/dist/protocol-CRqiPTLT.js.map +1 -0
- package/dist/{use-app-CfP9VypY.js → use-app-Ck5kR1Sf.js} +193 -93
- package/dist/use-app-Ck5kR1Sf.js.map +1 -0
- package/dist/{use-app-CzcYw1Kz.cjs → use-app-DHYiev3D.cjs} +253 -147
- package/dist/use-app-DHYiev3D.cjs.map +1 -0
- package/package.json +2 -2
- package/template/dist/albums/albums.html +15 -15
- package/template/dist/albums/albums.json +1 -1
- package/template/dist/carousel/carousel.html +19 -19
- package/template/dist/carousel/carousel.json +1 -1
- package/template/dist/map/map.html +14 -14
- package/template/dist/map/map.json +1 -1
- package/template/dist/review/review.html +11 -11
- package/template/dist/review/review.json +1 -1
- package/template/node_modules/.vite/deps/_metadata.json +3 -3
- package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps.js +192 -91
- package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps.js.map +1 -1
- package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps_app-bridge.js +231 -92
- package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps_app-bridge.js.map +1 -1
- package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps_react.js +208 -105
- package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps_react.js.map +1 -1
- package/template/node_modules/.vite-mcp/deps/_metadata.json +24 -24
- package/template/node_modules/.vite-mcp/deps/{protocol-B_qKkui_.js → protocol-BqGB4zBx.js} +45 -45
- package/template/node_modules/.vite-mcp/deps/protocol-BqGB4zBx.js.map +1 -0
- package/template/tests/e2e/visual.spec.ts-snapshots/albums-dark-chatgpt-darwin.png +0 -0
- package/template/tests/e2e/visual.spec.ts-snapshots/albums-dark-claude-darwin.png +0 -0
- package/template/tests/e2e/visual.spec.ts-snapshots/albums-fullscreen-chatgpt-darwin.png +0 -0
- package/template/tests/e2e/visual.spec.ts-snapshots/albums-fullscreen-claude-darwin.png +0 -0
- package/template/tests/e2e/visual.spec.ts-snapshots/albums-light-chatgpt-darwin.png +0 -0
- package/template/tests/e2e/visual.spec.ts-snapshots/albums-light-claude-darwin.png +0 -0
- package/template/tests/e2e/visual.spec.ts-snapshots/albums-page-light-chatgpt-darwin.png +0 -0
- package/template/tests/e2e/visual.spec.ts-snapshots/albums-page-light-claude-darwin.png +0 -0
- package/dist/inspector-8nPV2A-z.cjs.map +0 -1
- package/dist/inspector-Cdo5BK2D.js.map +0 -1
- package/dist/protocol-BfAACnv0.js.map +0 -1
- package/dist/protocol-C7kTcBr_.cjs.map +0 -1
- package/dist/use-app-CfP9VypY.js.map +0 -1
- package/dist/use-app-CzcYw1Kz.cjs.map +0 -1
- package/template/node_modules/.vite-mcp/deps/protocol-B_qKkui_.js.map +0 -1
|
@@ -1,11 +1,68 @@
|
|
|
1
1
|
import { r as __toESM } from "./chunk-BoAXSpZd.js";
|
|
2
2
|
import { t as require_react } from "./react.js";
|
|
3
3
|
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";
|
|
4
|
-
import {
|
|
5
|
-
//#region ../../../node_modules/.pnpm/@modelcontextprotocol+ext-apps@1.
|
|
4
|
+
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";
|
|
5
|
+
//#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/react/index.js
|
|
6
6
|
var import_react = /* @__PURE__ */ __toESM(require_react(), 1);
|
|
7
|
-
var R =
|
|
8
|
-
|
|
7
|
+
var R = class extends Protocol {
|
|
8
|
+
_registeredMethods = /* @__PURE__ */ new Set();
|
|
9
|
+
_eventSlots = /* @__PURE__ */ new Map();
|
|
10
|
+
onEventDispatch(K, Q) {}
|
|
11
|
+
_ensureEventSlot(K) {
|
|
12
|
+
let Q = this._eventSlots.get(K);
|
|
13
|
+
if (!Q) {
|
|
14
|
+
let X = this.eventSchemas[K];
|
|
15
|
+
if (!X) throw Error(`Unknown event: ${String(K)}`);
|
|
16
|
+
Q = { listeners: [] }, this._eventSlots.set(K, Q);
|
|
17
|
+
let Y = X.shape.method.value;
|
|
18
|
+
this._registeredMethods.add(Y);
|
|
19
|
+
let Z = Q;
|
|
20
|
+
super.setNotificationHandler(X, ($) => {
|
|
21
|
+
let G = $.params;
|
|
22
|
+
this.onEventDispatch(K, G), Z.onHandler?.(G);
|
|
23
|
+
for (let j of [...Z.listeners]) j(G);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return Q;
|
|
27
|
+
}
|
|
28
|
+
setEventHandler(K, Q) {
|
|
29
|
+
let X = this._ensureEventSlot(K);
|
|
30
|
+
if (X.onHandler && Q) console.warn(`[MCP Apps] on${String(K)} handler replaced. Use addEventListener("${String(K)}", …) to add multiple listeners without replacing.`);
|
|
31
|
+
X.onHandler = Q;
|
|
32
|
+
}
|
|
33
|
+
getEventHandler(K) {
|
|
34
|
+
return this._eventSlots.get(K)?.onHandler;
|
|
35
|
+
}
|
|
36
|
+
addEventListener(K, Q) {
|
|
37
|
+
this._ensureEventSlot(K).listeners.push(Q);
|
|
38
|
+
}
|
|
39
|
+
removeEventListener(K, Q) {
|
|
40
|
+
let X = this._eventSlots.get(K);
|
|
41
|
+
if (!X) return;
|
|
42
|
+
let Y = X.listeners.indexOf(Q);
|
|
43
|
+
if (Y !== -1) X.listeners.splice(Y, 1);
|
|
44
|
+
}
|
|
45
|
+
setRequestHandler = (K, Q) => {
|
|
46
|
+
this._assertMethodNotRegistered(K, "setRequestHandler"), super.setRequestHandler(K, Q);
|
|
47
|
+
};
|
|
48
|
+
setNotificationHandler = (K, Q) => {
|
|
49
|
+
this._assertMethodNotRegistered(K, "setNotificationHandler"), super.setNotificationHandler(K, Q);
|
|
50
|
+
};
|
|
51
|
+
warnIfRequestHandlerReplaced(K, Q, X) {
|
|
52
|
+
if (Q && X) console.warn(`[MCP Apps] ${K} handler replaced. Previous handler will no longer be called.`);
|
|
53
|
+
}
|
|
54
|
+
replaceRequestHandler = (K, Q) => {
|
|
55
|
+
let X = K.shape.method.value;
|
|
56
|
+
this._registeredMethods.add(X), super.setRequestHandler(K, Q);
|
|
57
|
+
};
|
|
58
|
+
_assertMethodNotRegistered(K, Q) {
|
|
59
|
+
let X = K.shape.method.value;
|
|
60
|
+
if (this._registeredMethods.has(X)) throw Error(`Handler for "${X}" already registered (via ${Q}). Use addEventListener() to attach multiple listeners, or the on* setter for replace semantics.`);
|
|
61
|
+
this._registeredMethods.add(X);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
var z = "2026-01-26", s = "ui/open-link", t = "ui/download-file", e = "ui/message", JJ = "ui/notifications/sandbox-proxy-ready", KJ = "ui/notifications/sandbox-resource-ready", QJ = "ui/notifications/size-changed", XJ = "ui/notifications/tool-input", U = "ui/notifications/tool-input-partial", YJ = "ui/notifications/tool-result", ZJ = "ui/notifications/tool-cancelled", $J = "ui/notifications/host-context-changed", GJ = "ui/notifications/request-teardown", jJ = "ui/resource-teardown", WJ = "ui/initialize", LJ = "ui/notifications/initialized", NJ = "ui/request-display-mode";
|
|
65
|
+
var L = class {
|
|
9
66
|
eventTarget;
|
|
10
67
|
eventSource;
|
|
11
68
|
messageListener;
|
|
@@ -39,11 +96,11 @@ var W = class {
|
|
|
39
96
|
sessionId;
|
|
40
97
|
setProtocolVersion;
|
|
41
98
|
};
|
|
42
|
-
var
|
|
99
|
+
var m = union([literal("light"), literal("dark")]).describe("Color theme preference for the host environment."), N = union([
|
|
43
100
|
literal("inline"),
|
|
44
101
|
literal("fullscreen"),
|
|
45
102
|
literal("pip")
|
|
46
|
-
]).describe("Display mode for UI presentation."),
|
|
103
|
+
]).describe("Display mode for UI presentation."), IJ = record(union([
|
|
47
104
|
literal("--color-background-primary"),
|
|
48
105
|
literal("--color-background-secondary"),
|
|
49
106
|
literal("--color-background-tertiary"),
|
|
@@ -138,10 +195,10 @@ Individual style keys are optional - hosts may provide any subset of these value
|
|
|
138
195
|
Values are strings containing CSS values (colors, sizes, font stacks, etc.).
|
|
139
196
|
|
|
140
197
|
Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
|
|
141
|
-
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),
|
|
198
|
+
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`), FJ = object({
|
|
142
199
|
method: literal("ui/open-link"),
|
|
143
200
|
params: object({ url: string().describe("URL to open in the host's browser") })
|
|
144
|
-
}),
|
|
201
|
+
}), M = object({ isError: boolean().optional().describe("True if the host failed to open the URL (e.g., due to security policy).") }).passthrough(), T = object({ isError: boolean().optional().describe("True if the download failed (e.g., user cancelled or host denied).") }).passthrough(), H = object({ isError: boolean().optional().describe("True if the host rejected or failed to deliver the message.") }).passthrough(), EJ = object({
|
|
145
202
|
method: literal("ui/notifications/sandbox-proxy-ready"),
|
|
146
203
|
params: object({})
|
|
147
204
|
}), V = object({
|
|
@@ -152,43 +209,43 @@ for compatibility with Zod schema generation. Both are functionally equivalent f
|
|
|
152
209
|
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)"),
|
|
153
210
|
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'`)"),
|
|
154
211
|
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'`)")
|
|
155
|
-
}),
|
|
212
|
+
}), _ = object({
|
|
156
213
|
camera: object({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),
|
|
157
214
|
microphone: object({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),
|
|
158
215
|
geolocation: object({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),
|
|
159
216
|
clipboardWrite: object({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")
|
|
160
|
-
}),
|
|
217
|
+
}), RJ = object({
|
|
161
218
|
method: literal("ui/notifications/size-changed"),
|
|
162
219
|
params: object({
|
|
163
220
|
width: number().optional().describe("New width in pixels."),
|
|
164
221
|
height: number().optional().describe("New height in pixels.")
|
|
165
222
|
})
|
|
166
|
-
}),
|
|
223
|
+
}), A = object({
|
|
167
224
|
method: literal("ui/notifications/tool-input"),
|
|
168
225
|
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.") })
|
|
169
|
-
}),
|
|
226
|
+
}), k = object({
|
|
170
227
|
method: literal("ui/notifications/tool-input-partial"),
|
|
171
228
|
params: object({ arguments: record(string(), unknown().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).") })
|
|
172
|
-
}),
|
|
229
|
+
}), b = object({
|
|
173
230
|
method: literal("ui/notifications/tool-cancelled"),
|
|
174
231
|
params: object({ reason: string().optional().describe("Optional reason for the cancellation (e.g., \"user action\", \"timeout\").") })
|
|
175
|
-
}),
|
|
176
|
-
variables:
|
|
177
|
-
css:
|
|
178
|
-
}),
|
|
232
|
+
}), c = object({ fonts: string().optional() }), r = object({
|
|
233
|
+
variables: IJ.optional().describe("CSS variables for theming the app."),
|
|
234
|
+
css: c.optional().describe("CSS blocks that apps can inject.")
|
|
235
|
+
}), S = object({
|
|
179
236
|
method: literal("ui/resource-teardown"),
|
|
180
237
|
params: object({})
|
|
181
|
-
}),
|
|
238
|
+
}), zJ = record(string(), unknown()), w = object({
|
|
182
239
|
text: object({}).optional().describe("Host supports text content blocks."),
|
|
183
240
|
image: object({}).optional().describe("Host supports image content blocks."),
|
|
184
241
|
audio: object({}).optional().describe("Host supports audio content blocks."),
|
|
185
242
|
resource: object({}).optional().describe("Host supports resource content blocks."),
|
|
186
243
|
resourceLink: object({}).optional().describe("Host supports resource link content blocks."),
|
|
187
244
|
structuredContent: object({}).optional().describe("Host supports structured content.")
|
|
188
|
-
}),
|
|
245
|
+
}), UJ = object({
|
|
189
246
|
method: literal("ui/notifications/request-teardown"),
|
|
190
247
|
params: object({}).optional()
|
|
191
|
-
}),
|
|
248
|
+
}), l = object({
|
|
192
249
|
experimental: object({}).optional().describe("Experimental features (structure TBD)."),
|
|
193
250
|
openLinks: object({}).optional().describe("Host supports opening external URLs."),
|
|
194
251
|
downloadFile: object({}).optional().describe("Host supports file downloads via ui/download-file."),
|
|
@@ -196,21 +253,21 @@ for compatibility with Zod schema generation. Both are functionally equivalent f
|
|
|
196
253
|
serverResources: object({ listChanged: boolean().optional().describe("Host supports resources/list_changed notifications.") }).optional().describe("Host can proxy resource reads to the MCP server."),
|
|
197
254
|
logging: object({}).optional().describe("Host accepts log messages."),
|
|
198
255
|
sandbox: object({
|
|
199
|
-
permissions:
|
|
256
|
+
permissions: _.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),
|
|
200
257
|
csp: V.optional().describe("CSP domains approved by the host.")
|
|
201
258
|
}).optional().describe("Sandbox configuration applied by the host."),
|
|
202
|
-
updateModelContext:
|
|
203
|
-
message:
|
|
204
|
-
}),
|
|
259
|
+
updateModelContext: w.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),
|
|
260
|
+
message: w.optional().describe("Host supports receiving content messages (ui/message) from the view.")
|
|
261
|
+
}), i = object({
|
|
205
262
|
experimental: object({}).optional().describe("Experimental features (structure TBD)."),
|
|
206
263
|
tools: object({ listChanged: boolean().optional().describe("App supports tools/list_changed notifications.") }).optional().describe("App exposes MCP-style tools that the host can call."),
|
|
207
|
-
availableDisplayModes: array(
|
|
208
|
-
}),
|
|
264
|
+
availableDisplayModes: array(N).optional().describe("Display modes the app supports.")
|
|
265
|
+
}), wJ = object({
|
|
209
266
|
method: literal("ui/notifications/initialized"),
|
|
210
267
|
params: object({}).optional()
|
|
211
|
-
}),
|
|
268
|
+
}), MJ = object({
|
|
212
269
|
csp: V.optional().describe("Content Security Policy configuration for UI resources."),
|
|
213
|
-
permissions:
|
|
270
|
+
permissions: _.optional().describe("Sandbox permissions requested by the UI resource."),
|
|
214
271
|
domain: string().optional().describe(`Dedicated origin for view sandbox.
|
|
215
272
|
|
|
216
273
|
Useful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists.
|
|
@@ -227,45 +284,45 @@ Boolean requesting whether a visible border and background is provided by the ho
|
|
|
227
284
|
- \`true\`: request visible border + background
|
|
228
285
|
- \`false\`: request no visible border + background
|
|
229
286
|
- omitted: host decides border`)
|
|
230
|
-
}),
|
|
287
|
+
}), TJ = object({
|
|
231
288
|
method: literal("ui/request-display-mode"),
|
|
232
|
-
params: object({ mode:
|
|
233
|
-
}),
|
|
289
|
+
params: object({ mode: N.describe("The display mode being requested.") })
|
|
290
|
+
}), C = object({ mode: N.describe("The display mode that was actually set. May differ from requested if not supported.") }).passthrough(), p = union([literal("model"), literal("app")]).describe("Tool visibility scope - who can access the tool."), HJ = object({
|
|
234
291
|
resourceUri: string().optional(),
|
|
235
|
-
visibility: array(
|
|
292
|
+
visibility: array(p).optional().describe(`Who can access this tool. Default: ["model", "app"]
|
|
236
293
|
- "model": Tool visible to and callable by the agent
|
|
237
294
|
- "app": Tool callable by the app from this server only`)
|
|
238
295
|
});
|
|
239
296
|
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.") });
|
|
240
|
-
var
|
|
297
|
+
var AJ = object({
|
|
241
298
|
method: literal("ui/download-file"),
|
|
242
299
|
params: object({ contents: array(union([EmbeddedResourceSchema, ResourceLinkSchema])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.") })
|
|
243
|
-
}),
|
|
300
|
+
}), kJ = object({
|
|
244
301
|
method: literal("ui/message"),
|
|
245
302
|
params: object({
|
|
246
303
|
role: literal("user").describe("Message role, currently only \"user\" is supported."),
|
|
247
304
|
content: array(ContentBlockSchema).describe("Message content blocks (text, image, etc.).")
|
|
248
305
|
})
|
|
249
|
-
}),
|
|
306
|
+
}), bJ = object({
|
|
250
307
|
method: literal("ui/notifications/sandbox-resource-ready"),
|
|
251
308
|
params: object({
|
|
252
309
|
html: string().describe("HTML content to load into the inner iframe."),
|
|
253
310
|
sandbox: string().optional().describe("Optional override for the inner iframe's sandbox attribute."),
|
|
254
311
|
csp: V.optional().describe("CSP configuration from resource metadata."),
|
|
255
|
-
permissions:
|
|
312
|
+
permissions: _.optional().describe("Sandbox permissions from resource metadata.")
|
|
256
313
|
})
|
|
257
|
-
}),
|
|
314
|
+
}), g = object({
|
|
258
315
|
method: literal("ui/notifications/tool-result"),
|
|
259
316
|
params: CallToolResultSchema.describe("Standard MCP tool execution result.")
|
|
260
|
-
}),
|
|
317
|
+
}), v = object({
|
|
261
318
|
toolInfo: object({
|
|
262
319
|
id: RequestIdSchema.optional().describe("JSON-RPC id of the tools/call request."),
|
|
263
320
|
tool: ToolSchema.describe("Tool definition including name, inputSchema, etc.")
|
|
264
321
|
}).optional().describe("Metadata of the tool call that instantiated this App."),
|
|
265
|
-
theme:
|
|
266
|
-
styles:
|
|
267
|
-
displayMode:
|
|
268
|
-
availableDisplayModes: array(
|
|
322
|
+
theme: m.optional().describe("Current color theme preference."),
|
|
323
|
+
styles: r.optional().describe("Style configuration for theming the app."),
|
|
324
|
+
displayMode: N.optional().describe("How the UI is currently displayed."),
|
|
325
|
+
availableDisplayModes: array(N).optional().describe("Display modes the host supports."),
|
|
269
326
|
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
|
|
270
327
|
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),
|
|
271
328
|
locale: string().optional().describe("User's language and region preference in BCP 47 format."),
|
|
@@ -286,34 +343,34 @@ container holding the app. Specify either width or maxWidth, and either height o
|
|
|
286
343
|
bottom: number().describe("Bottom safe area inset in pixels."),
|
|
287
344
|
left: number().describe("Left safe area inset in pixels.")
|
|
288
345
|
}).optional().describe("Mobile safe area boundaries in pixels.")
|
|
289
|
-
}).passthrough(),
|
|
346
|
+
}).passthrough(), x = object({
|
|
290
347
|
method: literal("ui/notifications/host-context-changed"),
|
|
291
|
-
params:
|
|
292
|
-
}),
|
|
348
|
+
params: v.describe("Partial context update containing only changed fields.")
|
|
349
|
+
}), SJ = object({
|
|
293
350
|
method: literal("ui/update-model-context"),
|
|
294
351
|
params: object({
|
|
295
352
|
content: array(ContentBlockSchema).optional().describe("Context content blocks (text, image, etc.)."),
|
|
296
353
|
structuredContent: record(string(), unknown().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")
|
|
297
354
|
})
|
|
298
|
-
}),
|
|
355
|
+
}), CJ = object({
|
|
299
356
|
method: literal("ui/initialize"),
|
|
300
357
|
params: object({
|
|
301
358
|
appInfo: ImplementationSchema.describe("App identification (name and version)."),
|
|
302
|
-
appCapabilities:
|
|
359
|
+
appCapabilities: i.describe("Features and capabilities this app provides."),
|
|
303
360
|
protocolVersion: string().describe("Protocol version this app supports.")
|
|
304
361
|
})
|
|
305
|
-
}),
|
|
362
|
+
}), y = object({
|
|
306
363
|
protocolVersion: string().describe("Negotiated protocol version string (e.g., \"2025-11-21\")."),
|
|
307
364
|
hostInfo: ImplementationSchema.describe("Host application identification and version."),
|
|
308
|
-
hostCapabilities:
|
|
309
|
-
hostContext:
|
|
365
|
+
hostCapabilities: l.describe("Features and capabilities provided by the host."),
|
|
366
|
+
hostContext: v.describe("Rich context about the host environment.")
|
|
310
367
|
}).passthrough();
|
|
311
|
-
function
|
|
368
|
+
function O() {
|
|
312
369
|
let K = document.documentElement.getAttribute("data-theme");
|
|
313
370
|
if (K === "dark" || K === "light") return K;
|
|
314
371
|
return document.documentElement.classList.contains("dark") ? "dark" : "light";
|
|
315
372
|
}
|
|
316
|
-
function
|
|
373
|
+
function P(K) {
|
|
317
374
|
let Q = document.documentElement;
|
|
318
375
|
Q.setAttribute("data-theme", K), Q.style.colorScheme = K;
|
|
319
376
|
}
|
|
@@ -325,14 +382,27 @@ function D(K) {
|
|
|
325
382
|
let X = document.createElement("style");
|
|
326
383
|
X.id = "__mcp-host-fonts", X.textContent = K, document.head.appendChild(X);
|
|
327
384
|
}
|
|
328
|
-
var
|
|
329
|
-
var
|
|
385
|
+
var mK = "ui/resourceUri", cK = "text/html;profile=mcp-app";
|
|
386
|
+
var f = class extends R {
|
|
330
387
|
_appInfo;
|
|
331
388
|
_capabilities;
|
|
332
389
|
options;
|
|
333
390
|
_hostCapabilities;
|
|
334
391
|
_hostInfo;
|
|
335
392
|
_hostContext;
|
|
393
|
+
eventSchemas = {
|
|
394
|
+
toolinput: A,
|
|
395
|
+
toolinputpartial: k,
|
|
396
|
+
toolresult: g,
|
|
397
|
+
toolcancelled: b,
|
|
398
|
+
hostcontextchanged: x
|
|
399
|
+
};
|
|
400
|
+
onEventDispatch(K, Q) {
|
|
401
|
+
if (K === "hostcontextchanged") this._hostContext = {
|
|
402
|
+
...this._hostContext,
|
|
403
|
+
...Q
|
|
404
|
+
};
|
|
405
|
+
}
|
|
336
406
|
constructor(K, Q = {}, X = { autoResize: !0 }) {
|
|
337
407
|
super(X);
|
|
338
408
|
this._appInfo = K;
|
|
@@ -340,7 +410,7 @@ var y = class extends Protocol {
|
|
|
340
410
|
this.options = X;
|
|
341
411
|
this.setRequestHandler(PingRequestSchema, (Y) => {
|
|
342
412
|
return console.log("Received ping:", Y.params), {};
|
|
343
|
-
}), this.
|
|
413
|
+
}), this.setEventHandler("hostcontextchanged", void 0);
|
|
344
414
|
}
|
|
345
415
|
getHostCapabilities() {
|
|
346
416
|
return this._hostCapabilities;
|
|
@@ -351,34 +421,65 @@ var y = class extends Protocol {
|
|
|
351
421
|
getHostContext() {
|
|
352
422
|
return this._hostContext;
|
|
353
423
|
}
|
|
424
|
+
get ontoolinput() {
|
|
425
|
+
return this.getEventHandler("toolinput");
|
|
426
|
+
}
|
|
354
427
|
set ontoolinput(K) {
|
|
355
|
-
this.
|
|
428
|
+
this.setEventHandler("toolinput", K);
|
|
429
|
+
}
|
|
430
|
+
get ontoolinputpartial() {
|
|
431
|
+
return this.getEventHandler("toolinputpartial");
|
|
356
432
|
}
|
|
357
433
|
set ontoolinputpartial(K) {
|
|
358
|
-
this.
|
|
434
|
+
this.setEventHandler("toolinputpartial", K);
|
|
435
|
+
}
|
|
436
|
+
get ontoolresult() {
|
|
437
|
+
return this.getEventHandler("toolresult");
|
|
359
438
|
}
|
|
360
439
|
set ontoolresult(K) {
|
|
361
|
-
this.
|
|
440
|
+
this.setEventHandler("toolresult", K);
|
|
441
|
+
}
|
|
442
|
+
get ontoolcancelled() {
|
|
443
|
+
return this.getEventHandler("toolcancelled");
|
|
362
444
|
}
|
|
363
445
|
set ontoolcancelled(K) {
|
|
364
|
-
this.
|
|
446
|
+
this.setEventHandler("toolcancelled", K);
|
|
447
|
+
}
|
|
448
|
+
get onhostcontextchanged() {
|
|
449
|
+
return this.getEventHandler("hostcontextchanged");
|
|
365
450
|
}
|
|
366
451
|
set onhostcontextchanged(K) {
|
|
367
|
-
this.
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
});
|
|
452
|
+
this.setEventHandler("hostcontextchanged", K);
|
|
453
|
+
}
|
|
454
|
+
_onteardown;
|
|
455
|
+
get onteardown() {
|
|
456
|
+
return this._onteardown;
|
|
373
457
|
}
|
|
374
458
|
set onteardown(K) {
|
|
375
|
-
this.
|
|
459
|
+
this.warnIfRequestHandlerReplaced("onteardown", this._onteardown, K), this._onteardown = K, this.replaceRequestHandler(S, (Q, X) => {
|
|
460
|
+
if (!this._onteardown) throw Error("No onteardown handler set");
|
|
461
|
+
return this._onteardown(Q.params, X);
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
_oncalltool;
|
|
465
|
+
get oncalltool() {
|
|
466
|
+
return this._oncalltool;
|
|
376
467
|
}
|
|
377
468
|
set oncalltool(K) {
|
|
378
|
-
this.
|
|
469
|
+
this.warnIfRequestHandlerReplaced("oncalltool", this._oncalltool, K), this._oncalltool = K, this.replaceRequestHandler(CallToolRequestSchema, (Q, X) => {
|
|
470
|
+
if (!this._oncalltool) throw Error("No oncalltool handler set");
|
|
471
|
+
return this._oncalltool(Q.params, X);
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
_onlisttools;
|
|
475
|
+
get onlisttools() {
|
|
476
|
+
return this._onlisttools;
|
|
379
477
|
}
|
|
380
478
|
set onlisttools(K) {
|
|
381
|
-
this.
|
|
479
|
+
this.warnIfRequestHandlerReplaced("onlisttools", this._onlisttools, K), this._onlisttools = K, this.replaceRequestHandler(ListToolsRequestSchema, (Q, X) => {
|
|
480
|
+
if (!this._onlisttools) throw Error("No onlisttools handler set");
|
|
481
|
+
return this._onlisttools(Q.params, X);
|
|
482
|
+
});
|
|
382
483
|
}
|
|
383
484
|
assertCapabilityForMethod(K) {}
|
|
384
485
|
assertRequestHandlerCapability(K) {
|
|
@@ -422,7 +523,7 @@ var y = class extends Protocol {
|
|
|
422
523
|
return this.request({
|
|
423
524
|
method: "ui/message",
|
|
424
525
|
params: K
|
|
425
|
-
},
|
|
526
|
+
}, H, Q);
|
|
426
527
|
}
|
|
427
528
|
sendLog(K) {
|
|
428
529
|
return this.notification({
|
|
@@ -440,14 +541,14 @@ var y = class extends Protocol {
|
|
|
440
541
|
return this.request({
|
|
441
542
|
method: "ui/open-link",
|
|
442
543
|
params: K
|
|
443
|
-
},
|
|
544
|
+
}, M, Q);
|
|
444
545
|
}
|
|
445
546
|
sendOpenLink = this.openLink;
|
|
446
547
|
downloadFile(K, Q) {
|
|
447
548
|
return this.request({
|
|
448
549
|
method: "ui/download-file",
|
|
449
550
|
params: K
|
|
450
|
-
},
|
|
551
|
+
}, T, Q);
|
|
451
552
|
}
|
|
452
553
|
requestTeardown(K = {}) {
|
|
453
554
|
return this.notification({
|
|
@@ -459,7 +560,7 @@ var y = class extends Protocol {
|
|
|
459
560
|
return this.request({
|
|
460
561
|
method: "ui/request-display-mode",
|
|
461
562
|
params: K
|
|
462
|
-
},
|
|
563
|
+
}, C, Q);
|
|
463
564
|
}
|
|
464
565
|
sendSizeChanged(K) {
|
|
465
566
|
return this.notification({
|
|
@@ -472,14 +573,14 @@ var y = class extends Protocol {
|
|
|
472
573
|
if (K) return;
|
|
473
574
|
K = !0, requestAnimationFrame(() => {
|
|
474
575
|
K = !1;
|
|
475
|
-
let $ = document.documentElement,
|
|
576
|
+
let $ = document.documentElement, G = $.style.height;
|
|
476
577
|
$.style.height = "max-content";
|
|
477
|
-
let
|
|
478
|
-
$.style.height =
|
|
479
|
-
let
|
|
480
|
-
if (
|
|
481
|
-
width:
|
|
482
|
-
height:
|
|
578
|
+
let j = Math.ceil($.getBoundingClientRect().height);
|
|
579
|
+
$.style.height = G;
|
|
580
|
+
let W = Math.ceil(window.innerWidth);
|
|
581
|
+
if (W !== Q || j !== X) Q = W, X = j, this.sendSizeChanged({
|
|
582
|
+
width: W,
|
|
583
|
+
height: j
|
|
483
584
|
});
|
|
484
585
|
});
|
|
485
586
|
};
|
|
@@ -487,7 +588,7 @@ var y = class extends Protocol {
|
|
|
487
588
|
let Z = new ResizeObserver(Y);
|
|
488
589
|
return Z.observe(document.documentElement), Z.observe(document.body), () => Z.disconnect();
|
|
489
590
|
}
|
|
490
|
-
async connect(K = new
|
|
591
|
+
async connect(K = new L(window.parent, window.parent), Q) {
|
|
491
592
|
if (this.transport) throw Error("App is already connected. Call close() before connecting again.");
|
|
492
593
|
await super.connect(K);
|
|
493
594
|
try {
|
|
@@ -496,9 +597,9 @@ var y = class extends Protocol {
|
|
|
496
597
|
params: {
|
|
497
598
|
appCapabilities: this._capabilities,
|
|
498
599
|
appInfo: this._appInfo,
|
|
499
|
-
protocolVersion:
|
|
600
|
+
protocolVersion: z
|
|
500
601
|
}
|
|
501
|
-
},
|
|
602
|
+
}, y, Q);
|
|
502
603
|
if (X === void 0) throw Error(`Server sent invalid initialize result: ${X}`);
|
|
503
604
|
if (this._hostCapabilities = X.hostCapabilities, this._hostInfo = X.hostInfo, this._hostContext = X.hostContext, await this.notification({ method: "ui/notifications/initialized" }), this.options?.autoResize) this.setupSizeChangedNotifications();
|
|
504
605
|
} catch (X) {
|
|
@@ -506,38 +607,38 @@ var y = class extends Protocol {
|
|
|
506
607
|
}
|
|
507
608
|
}
|
|
508
609
|
};
|
|
509
|
-
function
|
|
510
|
-
let [Y, Z] = (0, import_react.useState)(null), [$,
|
|
610
|
+
function sK({ appInfo: K, capabilities: Q, onAppCreated: X }) {
|
|
611
|
+
let [Y, Z] = (0, import_react.useState)(null), [$, G] = (0, import_react.useState)(!1), [j, W] = (0, import_react.useState)(null);
|
|
511
612
|
return (0, import_react.useEffect)(() => {
|
|
512
613
|
let F = !0;
|
|
513
|
-
async function
|
|
614
|
+
async function o() {
|
|
514
615
|
try {
|
|
515
|
-
let B = new
|
|
516
|
-
if (X?.(E), await E.connect(B), F) Z(E),
|
|
616
|
+
let B = new L(window.parent, window.parent), E = new f(K, Q);
|
|
617
|
+
if (X?.(E), await E.connect(B), F) Z(E), G(!0), W(null);
|
|
517
618
|
} catch (B) {
|
|
518
|
-
if (F) Z(null),
|
|
619
|
+
if (F) Z(null), G(!1), W(B instanceof Error ? B : Error("Failed to connect"));
|
|
519
620
|
}
|
|
520
621
|
}
|
|
521
|
-
return
|
|
622
|
+
return o(), () => {
|
|
522
623
|
F = !1;
|
|
523
624
|
};
|
|
524
625
|
}, []), {
|
|
525
626
|
app: Y,
|
|
526
627
|
isConnected: $,
|
|
527
|
-
error:
|
|
628
|
+
error: j
|
|
528
629
|
};
|
|
529
630
|
}
|
|
530
|
-
function
|
|
631
|
+
function QQ(K, Q) {
|
|
531
632
|
(0, import_react.useEffect)(() => {
|
|
532
633
|
if (!K) return;
|
|
533
634
|
return K.setupSizeChangedNotifications();
|
|
534
635
|
}, [K, Q]);
|
|
535
636
|
}
|
|
536
|
-
function
|
|
537
|
-
let [K, Q] = (0, import_react.useState)(
|
|
637
|
+
function $Q() {
|
|
638
|
+
let [K, Q] = (0, import_react.useState)(O);
|
|
538
639
|
return (0, import_react.useEffect)(() => {
|
|
539
640
|
let X = new MutationObserver(() => {
|
|
540
|
-
Q(
|
|
641
|
+
Q(O());
|
|
541
642
|
});
|
|
542
643
|
return X.observe(document.documentElement, {
|
|
543
644
|
attributes: !0,
|
|
@@ -548,37 +649,39 @@ function XQ() {
|
|
|
548
649
|
}), () => X.disconnect();
|
|
549
650
|
}, []), K;
|
|
550
651
|
}
|
|
551
|
-
function
|
|
652
|
+
function lJ(K, Q) {
|
|
552
653
|
let X = (0, import_react.useRef)(!1);
|
|
553
654
|
(0, import_react.useEffect)(() => {
|
|
554
655
|
if (X.current) return;
|
|
555
|
-
if (Q?.theme)
|
|
656
|
+
if (Q?.theme) P(Q.theme);
|
|
556
657
|
if (Q?.styles?.variables) q(Q.styles.variables);
|
|
557
658
|
if (Q?.theme || Q?.styles?.variables) X.current = !0;
|
|
558
659
|
}, [Q]), (0, import_react.useEffect)(() => {
|
|
559
660
|
if (!K) return;
|
|
560
|
-
|
|
561
|
-
if (
|
|
562
|
-
if (
|
|
661
|
+
let Y = (Z) => {
|
|
662
|
+
if (Z.theme) P(Z.theme);
|
|
663
|
+
if (Z.styles?.variables) q(Z.styles.variables);
|
|
563
664
|
};
|
|
665
|
+
return K.addEventListener("hostcontextchanged", Y), () => K.removeEventListener("hostcontextchanged", Y);
|
|
564
666
|
}, [K]);
|
|
565
667
|
}
|
|
566
|
-
function
|
|
668
|
+
function iJ(K, Q) {
|
|
567
669
|
let X = (0, import_react.useRef)(!1);
|
|
568
670
|
(0, import_react.useEffect)(() => {
|
|
569
671
|
if (X.current) return;
|
|
570
672
|
if (Q?.styles?.css?.fonts) D(Q.styles.css.fonts), X.current = !0;
|
|
571
673
|
}, [Q]), (0, import_react.useEffect)(() => {
|
|
572
674
|
if (!K) return;
|
|
573
|
-
|
|
574
|
-
if (
|
|
675
|
+
let Y = (Z) => {
|
|
676
|
+
if (Z.styles?.css?.fonts) D(Z.styles.css.fonts);
|
|
575
677
|
};
|
|
678
|
+
return K.addEventListener("hostcontextchanged", Y), () => K.removeEventListener("hostcontextchanged", Y);
|
|
576
679
|
}, [K]);
|
|
577
680
|
}
|
|
578
|
-
function
|
|
579
|
-
|
|
681
|
+
function LQ(K, Q) {
|
|
682
|
+
lJ(K, Q), iJ(K, Q);
|
|
580
683
|
}
|
|
581
684
|
//#endregion
|
|
582
|
-
export {
|
|
685
|
+
export { f as App, t as DOWNLOAD_FILE_METHOD, $J as HOST_CONTEXT_CHANGED_METHOD, LJ as INITIALIZED_METHOD, WJ as INITIALIZE_METHOD, z as LATEST_PROTOCOL_VERSION, e as MESSAGE_METHOD, i as McpUiAppCapabilitiesSchema, N as McpUiDisplayModeSchema, AJ as McpUiDownloadFileRequestSchema, T as McpUiDownloadFileResultSchema, l as McpUiHostCapabilitiesSchema, x as McpUiHostContextChangedNotificationSchema, v as McpUiHostContextSchema, c as McpUiHostCssSchema, r as McpUiHostStylesSchema, CJ as McpUiInitializeRequestSchema, y as McpUiInitializeResultSchema, wJ as McpUiInitializedNotificationSchema, kJ as McpUiMessageRequestSchema, H as McpUiMessageResultSchema, FJ as McpUiOpenLinkRequestSchema, M as McpUiOpenLinkResultSchema, TJ as McpUiRequestDisplayModeRequestSchema, C as McpUiRequestDisplayModeResultSchema, UJ as McpUiRequestTeardownNotificationSchema, V as McpUiResourceCspSchema, MJ as McpUiResourceMetaSchema, _ as McpUiResourcePermissionsSchema, S as McpUiResourceTeardownRequestSchema, zJ as McpUiResourceTeardownResultSchema, EJ as McpUiSandboxProxyReadyNotificationSchema, bJ as McpUiSandboxResourceReadyNotificationSchema, RJ as McpUiSizeChangedNotificationSchema, w as McpUiSupportedContentBlockModalitiesSchema, m as McpUiThemeSchema, b as McpUiToolCancelledNotificationSchema, A as McpUiToolInputNotificationSchema, k as McpUiToolInputPartialNotificationSchema, HJ as McpUiToolMetaSchema, g as McpUiToolResultNotificationSchema, p as McpUiToolVisibilitySchema, SJ as McpUiUpdateModelContextRequestSchema, s as OPEN_LINK_METHOD, L as PostMessageTransport, R as ProtocolWithEvents, NJ as REQUEST_DISPLAY_MODE_METHOD, GJ as REQUEST_TEARDOWN_METHOD, cK as RESOURCE_MIME_TYPE, jJ as RESOURCE_TEARDOWN_METHOD, mK as RESOURCE_URI_META_KEY, JJ as SANDBOX_PROXY_READY_METHOD, KJ as SANDBOX_RESOURCE_READY_METHOD, QJ as SIZE_CHANGED_METHOD, ZJ as TOOL_CANCELLED_METHOD, XJ as TOOL_INPUT_METHOD, U as TOOL_INPUT_PARTIAL_METHOD, YJ as TOOL_RESULT_METHOD, P as applyDocumentTheme, D as applyHostFonts, q as applyHostStyleVariables, O as getDocumentTheme, sK as useApp, QQ as useAutoResize, $Q as useDocumentTheme, iJ as useHostFonts, lJ as useHostStyleVariables, LQ as useHostStyles };
|
|
583
686
|
|
|
584
687
|
//# sourceMappingURL=@modelcontextprotocol_ext-apps_react.js.map
|