sunpeak 0.14.3 → 0.15.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/README.md +34 -30
- package/bin/commands/build.mjs +2 -1
- package/bin/commands/dev.mjs +72 -2
- package/dist/chatgpt/{conversation.d.ts → chatgpt-conversation.d.ts} +1 -1
- package/dist/chatgpt/chatgpt-host.d.ts +1 -0
- package/dist/chatgpt/globals.css +618 -6156
- package/dist/chatgpt/index.cjs +11 -8
- package/dist/chatgpt/index.cjs.map +1 -1
- package/dist/chatgpt/index.d.ts +10 -32
- package/dist/chatgpt/index.js +15 -12
- package/dist/chatgpt/index.js.map +1 -1
- package/dist/claude/claude-conversation.d.ts +23 -0
- package/dist/claude/claude-host.d.ts +1 -0
- package/dist/claude/index.cjs +5 -0
- package/dist/claude/index.cjs.map +1 -0
- package/dist/claude/index.d.ts +1 -0
- package/dist/claude/index.js +5 -0
- package/dist/claude/index.js.map +1 -0
- package/dist/{discovery-COZUnY6a.js → discovery-DzV3HLXs.js} +5 -5
- package/dist/{discovery-COZUnY6a.js.map → discovery-DzV3HLXs.js.map} +1 -1
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/use-app-tools.d.ts +44 -0
- package/dist/hooks/use-update-model-context.d.ts +29 -0
- package/dist/index-B0dxRJvS.cjs +42 -0
- package/dist/index-B0dxRJvS.cjs.map +1 -0
- package/dist/index-Ce_5ZIdJ.js +512 -0
- package/dist/index-Ce_5ZIdJ.js.map +1 -0
- package/dist/index-Cngntkp2.cjs +527 -0
- package/dist/index-Cngntkp2.cjs.map +1 -0
- package/dist/index-CutQgPzR.js +43 -0
- package/dist/index-CutQgPzR.js.map +1 -0
- package/dist/index.cjs +1705 -1647
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2732 -2675
- package/dist/index.js.map +1 -1
- package/dist/lib/default-style-variables.d.ts +2 -0
- package/dist/lib/discovery-cli.js +1 -1
- package/dist/mcp/index.cjs +86 -27
- package/dist/mcp/index.cjs.map +1 -1
- package/dist/mcp/index.d.ts +3 -1
- package/dist/mcp/index.js +85 -26
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/server.d.ts +4 -3
- package/dist/mcp/types.d.ts +11 -0
- package/dist/platform/chatgpt/index.cjs +1 -1
- package/dist/platform/chatgpt/index.js +1 -1
- package/dist/platform/index.cjs +3 -0
- package/dist/platform/index.cjs.map +1 -1
- package/dist/platform/index.d.ts +3 -1
- package/dist/platform/index.js +3 -0
- package/dist/platform/index.js.map +1 -1
- package/dist/{protocol-BQCnIrc9.js → protocol-DFbsCx7E.js} +29 -29
- package/dist/{protocol-BQCnIrc9.js.map → protocol-DFbsCx7E.js.map} +1 -1
- package/dist/simulator/host-styles.d.ts +5 -0
- package/dist/simulator/hosts.d.ts +73 -0
- package/dist/{chatgpt → simulator}/iframe-resource.d.ts +27 -3
- package/dist/simulator/index.cjs +39 -0
- package/dist/simulator/index.cjs.map +1 -0
- package/dist/simulator/index.d.ts +18 -0
- package/dist/simulator/index.js +39 -0
- package/dist/simulator/index.js.map +1 -0
- package/dist/{chatgpt → simulator}/mcp-app-host.d.ts +8 -1
- package/dist/simulator/mock-openai-runtime.d.ts +20 -0
- package/dist/{chatgpt → simulator}/simulator-url.d.ts +8 -1
- package/dist/simulator/simulator.d.ts +12 -0
- package/dist/{chatgpt → simulator}/theme-provider.d.ts +3 -1
- package/dist/simulator/use-simulator-state.d.ts +91 -0
- package/dist/simulator-CxrtnguM.js +8764 -0
- package/dist/simulator-CxrtnguM.js.map +1 -0
- package/dist/simulator-DcfQBRXE.cjs +8779 -0
- package/dist/simulator-DcfQBRXE.cjs.map +1 -0
- package/dist/simulator-url-CuLqtnSS.js +48 -0
- package/dist/simulator-url-CuLqtnSS.js.map +1 -0
- package/dist/simulator-url-rgg_KYOg.cjs +47 -0
- package/dist/simulator-url-rgg_KYOg.cjs.map +1 -0
- package/dist/style.css +558 -6143
- package/dist/types/runtime.d.ts +1 -1
- package/dist/{use-app-D7kRAPSG.cjs → use-app-BnoSPiUT.cjs} +2 -1
- package/dist/{use-app-D7kRAPSG.cjs.map → use-app-BnoSPiUT.cjs.map} +1 -1
- package/dist/{use-app-Dvr4LKs2.js → use-app-D_TeaMFG.js} +4 -3
- package/dist/{use-app-Dvr4LKs2.js.map → use-app-D_TeaMFG.js.map} +1 -1
- package/package.json +18 -3
- package/template/.sunpeak/dev.tsx +4 -4
- package/template/.sunpeak/resource-loader.html +1 -1
- package/template/README.md +1 -1
- package/template/node_modules/.bin/nodemon +2 -2
- package/template/node_modules/.bin/playwright +2 -2
- package/template/node_modules/.bin/sunpeak +2 -2
- package/template/node_modules/.bin/tsc +2 -2
- package/template/node_modules/.bin/tsserver +2 -2
- package/template/node_modules/.bin/tsx +2 -2
- package/template/node_modules/.bin/vite +2 -2
- package/template/src/components/avatar.tsx +4 -1
- package/template/src/components/button.tsx +17 -20
- package/template/src/resources/albums/albums-resource.tsx +2 -3
- package/template/src/resources/albums/components/album-card.tsx +4 -2
- package/template/src/resources/albums/components/film-strip.test.tsx +2 -2
- package/template/src/resources/albums/components/film-strip.tsx +2 -2
- package/template/src/resources/albums/components/fullscreen-viewer.tsx +7 -5
- package/template/src/resources/carousel/carousel-resource.tsx +2 -3
- package/template/src/resources/carousel/components/card.test.tsx +3 -2
- package/template/src/resources/carousel/components/card.tsx +8 -4
- package/template/src/resources/map/components/map-view.tsx +1 -1
- package/template/src/resources/map/components/map.tsx +1 -1
- package/template/src/resources/map/components/place-card.tsx +8 -4
- package/template/src/resources/map/components/place-carousel.tsx +1 -1
- package/template/src/resources/map/components/place-inspector.tsx +15 -7
- package/template/src/resources/map/components/place-list.tsx +7 -4
- package/template/src/resources/map/map-resource.tsx +0 -2
- package/template/src/resources/review/review-resource.tsx +61 -27
- package/template/tests/e2e/albums.spec.ts +118 -102
- package/template/tests/e2e/carousel.spec.ts +103 -100
- package/template/tests/e2e/map.spec.ts +220 -181
- package/template/tests/e2e/review.spec.ts +224 -198
- package/dist/_commonjsHelpers-Bc2YnDe1.cjs +0 -8
- package/dist/_commonjsHelpers-Bc2YnDe1.cjs.map +0 -1
- package/dist/_commonjsHelpers-DWwsNxpa.js +0 -9
- package/dist/_commonjsHelpers-DWwsNxpa.js.map +0 -1
- package/dist/index-CJ3jfcjj.js +0 -15131
- package/dist/index-CJ3jfcjj.js.map +0 -1
- package/dist/index-Cdeg96So.cjs +0 -15147
- package/dist/index-Cdeg96So.cjs.map +0 -1
- /package/dist/{chatgpt → simulator}/simple-sidebar.d.ts +0 -0
- /package/dist/{chatgpt/chatgpt-simulator-types.d.ts → simulator/simulator-types.d.ts} +0 -0
package/dist/mcp/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
export { runMCPServer, type MCPServerConfig } from './server.js';
|
|
1
|
+
export { runMCPServer, type MCPServerConfig, type MCPServerHandle } from './server.js';
|
|
2
2
|
export type { SimulationWithDist } from './types.js';
|
|
3
3
|
export { FAVICON_BASE64, FAVICON_BUFFER } from './favicon.js';
|
|
4
|
+
export { registerAppTool, registerAppResource, getUiCapability, EXTENSION_ID, RESOURCE_URI_META_KEY, RESOURCE_MIME_TYPE, } from '@modelcontextprotocol/ext-apps/server';
|
|
5
|
+
export type { McpUiAppToolConfig, McpUiAppResourceConfig, ToolConfig, ToolCallback, ReadResourceCallback, ResourceMetadata, } from '@modelcontextprotocol/ext-apps/server';
|
package/dist/mcp/index.js
CHANGED
|
@@ -2,12 +2,14 @@ import { createServer } from "node:http";
|
|
|
2
2
|
import { URL as URL$1 } from "node:url";
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
|
-
import { P as Protocol,
|
|
6
|
-
import { g as getDefaultExportFromCjs } from "../_commonjsHelpers-DWwsNxpa.js";
|
|
5
|
+
import { P as Protocol, p as LoggingLevelSchema, q as InitializeRequestSchema, r as InitializedNotificationSchema, S as SetLevelRequestSchema, s as mergeCapabilities, t as getObjectShape, u as isZ4Schema, v as LATEST_PROTOCOL_VERSION, E as EmptyResultSchema, w as CreateMessageResultWithToolsSchema, x as CreateMessageResultSchema, y as ElicitResultSchema, M as McpError, z as ErrorCode, A as ListRootsResultSchema, B as safeParse, c as CallToolRequestSchema, D as CreateTaskResultSchema, a as CallToolResultSchema, F as SUPPORTED_PROTOCOL_VERSIONS, L as ListToolsRequestSchema, G as normalizeObjectSchema, H as toJsonSchemaCompat, K as safeParseAsync, N as getParseErrorMessage, O as CompleteRequestSchema, Q as assertCompleteRequestResourceTemplate, U as assertCompleteRequestPrompt, e as ListResourcesRequestSchema, f as ListResourceTemplatesRequestSchema, g as ReadResourceRequestSchema, h as ListPromptsRequestSchema, V as GetPromptRequestSchema, W as objectFromShape, X as getLiteralValue, Y as getSchemaDescription, Z as isSchemaOptional, C as ContentBlockSchema, T as ToolSchema, R as RequestIdSchema, I as ImplementationSchema } from "../protocol-DFbsCx7E.js";
|
|
7
6
|
import { ZodOptional } from "zod";
|
|
8
7
|
import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";
|
|
9
8
|
const FAVICON_BASE64 = "iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAiLSURBVHgB7Z1NbBNHGIZfJ4GWJIAjfhKBKDYglaolGBAqUAncqNAbTTijErhUaiVIqFROJIWeeiiEnsoFEokzGE4VVJDmAFSU4oRDW/Fji6qIIFAMJKD84X7fOg5pEnt3s/Z6x/M9MPbYXhOy37vz887sjA+W2OwDZvuBl/VAyVbgdQhIBgCfH4IHSCYoFlHKxCl1AeURoJ/eu5k0+6Yv+8cceA706H56bpSAK0U7UHoUeDsOdGYUQhYBhKuAgRbKNEFQGN+RVPptWhFkEMCHQSrmL1MmAKEYiFPVXUciiE3+YBoBSPCLlPh0IpgkAAl+kROfLIIJAghTfuA+iiz4vikZiySNv8VIHBheD0T7+EXZm/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op8Ra706SgNAtfjE87RhuPUK2yC4rAIeNvb0IqXqOX8oiEEaOxhXBgWMdZJpro8Gptj3HdvBL67UuGA/w8q8W80c2aCALgtMPsPknrR3unB1YW/cjSjBZ3eYs3jDTeH+KikL19PlZfh/0wqJbkqeH25mEWgNxz8kjou+tPvTLKC+YPkrtSBQnHBMeXYvgm+8e70B0tJUFxMvfLTZBgM4gOHqJ54zd1DGS1UF45dW6rOnxp8xkJPyegituKNWyjTOLyNYUZSilBX72imwKexEcww9RIG6imzjdJaSgF43D3UCA54nAr0KJXaXUBFJN3KN+M/cngKDJvF2pMAAAAASUVORK5CYII=";
|
|
10
9
|
const FAVICON_BUFFER = Buffer.from(FAVICON_BASE64, "base64");
|
|
10
|
+
function getDefaultExportFromCjs(x2) {
|
|
11
|
+
return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
|
|
12
|
+
}
|
|
11
13
|
var ajv = { exports: {} };
|
|
12
14
|
var core$1 = {};
|
|
13
15
|
var validate = {};
|
|
@@ -14199,6 +14201,18 @@ function hk(r, i, o, t) {
|
|
|
14199
14201
|
function ak(r, i, o, t, n) {
|
|
14200
14202
|
r.registerResource(i, o, { mimeType: EI, ...t }, n);
|
|
14201
14203
|
}
|
|
14204
|
+
var C6 = "io.modelcontextprotocol/ui";
|
|
14205
|
+
function pk(r) {
|
|
14206
|
+
if (!r) return;
|
|
14207
|
+
return r.extensions?.[C6];
|
|
14208
|
+
}
|
|
14209
|
+
const LOCAL_DEV_SERVER_URL = "http://localhost:8000";
|
|
14210
|
+
const LOCAL_HMR_WS_URL = "ws://localhost:24678";
|
|
14211
|
+
function needsProdBuild(headers) {
|
|
14212
|
+
const ua = headers["user-agent"];
|
|
14213
|
+
const userAgent = typeof ua === "string" ? ua : Array.isArray(ua) ? ua[0] : "";
|
|
14214
|
+
return /claude/i.test(userAgent ?? "");
|
|
14215
|
+
}
|
|
14202
14216
|
function readResourceHtmlProd(distPath) {
|
|
14203
14217
|
const htmlPath = path.resolve(distPath);
|
|
14204
14218
|
if (!fs.existsSync(htmlPath)) {
|
|
@@ -14211,7 +14225,7 @@ function readResourceHtmlProd(distPath) {
|
|
|
14211
14225
|
function getViteResourceHtml(srcPath) {
|
|
14212
14226
|
const fileName = srcPath.split("/").pop()?.replace(/-resource\.tsx$/, "") ?? "";
|
|
14213
14227
|
const componentName = fileName.split("-").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("") + "Resource";
|
|
14214
|
-
const devServerUrl =
|
|
14228
|
+
const devServerUrl = LOCAL_DEV_SERVER_URL;
|
|
14215
14229
|
const entryParams = new URLSearchParams({ src: srcPath, component: componentName });
|
|
14216
14230
|
const virtualModuleUrl = `${devServerUrl}/@id/virtual:sunpeak-entry?${entryParams.toString()}`;
|
|
14217
14231
|
return `<!DOCTYPE html>
|
|
@@ -14250,38 +14264,44 @@ function getViteResourceHtml(srcPath) {
|
|
|
14250
14264
|
</body>
|
|
14251
14265
|
</html>`;
|
|
14252
14266
|
}
|
|
14253
|
-
function getResourceHtml(simulation, viteMode) {
|
|
14254
|
-
if (viteMode && simulation.srcPath) {
|
|
14267
|
+
function getResourceHtml(simulation, viteMode, prodBuild) {
|
|
14268
|
+
if (viteMode && simulation.srcPath && !prodBuild) {
|
|
14255
14269
|
return getViteResourceHtml(simulation.srcPath);
|
|
14256
14270
|
}
|
|
14257
14271
|
return readResourceHtmlProd(simulation.distPath);
|
|
14258
14272
|
}
|
|
14259
|
-
const DEV_SERVER_URL = "http://localhost:8000";
|
|
14260
|
-
const HMR_WS_URL = "ws://localhost:24678";
|
|
14261
14273
|
function injectViteCSP(existingMeta) {
|
|
14262
14274
|
const meta = existingMeta ?? {};
|
|
14263
14275
|
const ui2 = meta.ui ?? {};
|
|
14264
14276
|
const csp = ui2.csp ?? {};
|
|
14265
14277
|
const existingResourceDomains = csp.resourceDomains ?? [];
|
|
14266
|
-
const resourceDomains = existingResourceDomains.includes(
|
|
14278
|
+
const resourceDomains = existingResourceDomains.includes(LOCAL_DEV_SERVER_URL) ? existingResourceDomains : [...existingResourceDomains, LOCAL_DEV_SERVER_URL];
|
|
14267
14279
|
const existingConnectDomains = csp.connectDomains ?? [];
|
|
14268
|
-
const connectDomains =
|
|
14280
|
+
const connectDomains = [...existingConnectDomains];
|
|
14281
|
+
if (!connectDomains.includes(LOCAL_DEV_SERVER_URL)) connectDomains.push(LOCAL_DEV_SERVER_URL);
|
|
14282
|
+
if (!connectDomains.includes(LOCAL_HMR_WS_URL)) connectDomains.push(LOCAL_HMR_WS_URL);
|
|
14269
14283
|
return {
|
|
14270
14284
|
...meta,
|
|
14271
14285
|
ui: {
|
|
14272
14286
|
...ui2,
|
|
14273
|
-
csp: {
|
|
14274
|
-
...csp,
|
|
14275
|
-
resourceDomains,
|
|
14276
|
-
connectDomains
|
|
14277
|
-
}
|
|
14287
|
+
csp: { ...csp, resourceDomains, connectDomains }
|
|
14278
14288
|
}
|
|
14279
14289
|
};
|
|
14280
14290
|
}
|
|
14281
14291
|
function createAppServer(config, simulations, viteMode) {
|
|
14282
14292
|
const { name = "sunpeak-app", version = "0.1.0" } = config;
|
|
14283
14293
|
const mcpServer = new McpServer(
|
|
14284
|
-
{
|
|
14294
|
+
{
|
|
14295
|
+
name,
|
|
14296
|
+
version,
|
|
14297
|
+
icons: [
|
|
14298
|
+
{
|
|
14299
|
+
src: `data:image/png;base64,${FAVICON_BASE64}`,
|
|
14300
|
+
mimeType: "image/png",
|
|
14301
|
+
sizes: ["128x128"]
|
|
14302
|
+
}
|
|
14303
|
+
]
|
|
14304
|
+
},
|
|
14285
14305
|
{ capabilities: { resources: {}, tools: {} } }
|
|
14286
14306
|
);
|
|
14287
14307
|
const registeredResources = /* @__PURE__ */ new Set();
|
|
@@ -14294,32 +14314,39 @@ function createAppServer(config, simulations, viteMode) {
|
|
|
14294
14314
|
const toolMeta = tool._meta ?? {};
|
|
14295
14315
|
if (!registeredResources.has(uri2)) {
|
|
14296
14316
|
registeredResources.add(uri2);
|
|
14317
|
+
const listMeta = viteMode ? injectViteCSP(resourceMeta) : resourceMeta;
|
|
14318
|
+
console.log(`[MCP] RegisterResource: ${uri2}`);
|
|
14297
14319
|
ak(
|
|
14298
14320
|
mcpServer,
|
|
14299
14321
|
resource.name,
|
|
14300
14322
|
uri2,
|
|
14301
14323
|
{
|
|
14302
14324
|
description: resource.description,
|
|
14303
|
-
_meta:
|
|
14325
|
+
_meta: listMeta
|
|
14304
14326
|
},
|
|
14305
|
-
async () => {
|
|
14306
|
-
|
|
14327
|
+
async (_uri, extra) => {
|
|
14328
|
+
const prodBuild = needsProdBuild(
|
|
14329
|
+
extra?.requestInfo?.headers ?? {}
|
|
14330
|
+
);
|
|
14331
|
+
const readMeta = viteMode && !prodBuild ? injectViteCSP(resourceMeta) : resourceMeta;
|
|
14307
14332
|
let content;
|
|
14308
14333
|
try {
|
|
14309
|
-
content = getResourceHtml(simulation, viteMode);
|
|
14334
|
+
content = getResourceHtml(simulation, viteMode, prodBuild);
|
|
14310
14335
|
} catch (error) {
|
|
14311
14336
|
console.error(`[MCP] ReadResource error for ${uri2}:`, error);
|
|
14312
14337
|
throw error;
|
|
14313
14338
|
}
|
|
14314
14339
|
const sizeKB = (content.length / 1024).toFixed(1);
|
|
14315
|
-
console.log(
|
|
14340
|
+
console.log(
|
|
14341
|
+
`[MCP] ReadResource: ${uri2} → ${sizeKB}KB${prodBuild ? " (prod build)" : " (vite)"}`
|
|
14342
|
+
);
|
|
14316
14343
|
return {
|
|
14317
14344
|
contents: [
|
|
14318
14345
|
{
|
|
14319
14346
|
uri: uri2,
|
|
14320
14347
|
mimeType: EI,
|
|
14321
14348
|
text: content,
|
|
14322
|
-
_meta:
|
|
14349
|
+
_meta: readMeta
|
|
14323
14350
|
}
|
|
14324
14351
|
]
|
|
14325
14352
|
};
|
|
@@ -14333,7 +14360,11 @@ function createAppServer(config, simulations, viteMode) {
|
|
|
14333
14360
|
description: tool.description,
|
|
14334
14361
|
_meta: {
|
|
14335
14362
|
...toolMeta,
|
|
14336
|
-
ui: {
|
|
14363
|
+
ui: {
|
|
14364
|
+
resourceUri: uri2,
|
|
14365
|
+
// Preserve tool visibility from simulation metadata if declared
|
|
14366
|
+
...toolMeta.ui?.visibility ? { visibility: toolMeta.ui.visibility } : {}
|
|
14367
|
+
}
|
|
14337
14368
|
}
|
|
14338
14369
|
},
|
|
14339
14370
|
async (extra) => {
|
|
@@ -14362,16 +14393,24 @@ function createAppServer(config, simulations, viteMode) {
|
|
|
14362
14393
|
);
|
|
14363
14394
|
return mcpServer;
|
|
14364
14395
|
}
|
|
14396
|
+
function isLocalConnection(req) {
|
|
14397
|
+
const addr = req.socket.remoteAddress;
|
|
14398
|
+
return addr === "127.0.0.1" || addr === "::1" || addr === "::ffff:127.0.0.1";
|
|
14399
|
+
}
|
|
14365
14400
|
const sessions = /* @__PURE__ */ new Map();
|
|
14366
14401
|
const ssePath = "/mcp";
|
|
14367
14402
|
const postPath = "/mcp/messages";
|
|
14368
|
-
async function handleSseRequest(res, config, simulations, viteMode) {
|
|
14403
|
+
async function handleSseRequest(req, res, config, simulations, viteMode) {
|
|
14369
14404
|
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
14370
14405
|
const server = createAppServer(config, simulations, viteMode);
|
|
14371
14406
|
const transport = new SSEServerTransport(postPath, res);
|
|
14372
14407
|
const sessionId = transport.sessionId;
|
|
14373
|
-
|
|
14374
|
-
|
|
14408
|
+
const isLocal = isLocalConnection(req);
|
|
14409
|
+
sessions.set(sessionId, { server, transport, isLocal });
|
|
14410
|
+
const origin = isLocal ? "local" : "tunnel";
|
|
14411
|
+
console.log(
|
|
14412
|
+
`[MCP] Session started: ${sessionId.substring(0, 8)}... (${origin}, ${sessions.size} active)`
|
|
14413
|
+
);
|
|
14375
14414
|
transport.onclose = async () => {
|
|
14376
14415
|
if (!sessions.has(sessionId)) return;
|
|
14377
14416
|
sessions.delete(sessionId);
|
|
@@ -14479,7 +14518,7 @@ function runMCPServer(config) {
|
|
|
14479
14518
|
}
|
|
14480
14519
|
if (req.method === "GET" && url.pathname === ssePath) {
|
|
14481
14520
|
console.log(`[HTTP] ${req.method} ${url.pathname}`);
|
|
14482
|
-
await handleSseRequest(res, config, simulations, viteMode);
|
|
14521
|
+
await handleSseRequest(req, res, config, simulations, viteMode);
|
|
14483
14522
|
return;
|
|
14484
14523
|
}
|
|
14485
14524
|
if (req.method === "POST" && url.pathname === postPath) {
|
|
@@ -14525,10 +14564,30 @@ function runMCPServer(config) {
|
|
|
14525
14564
|
};
|
|
14526
14565
|
process.on("SIGTERM", () => void shutdown());
|
|
14527
14566
|
process.on("SIGINT", () => void shutdown());
|
|
14567
|
+
return {
|
|
14568
|
+
invalidateResources() {
|
|
14569
|
+
let notified = 0;
|
|
14570
|
+
for (const [, session] of sessions) {
|
|
14571
|
+
if (!session.isLocal) {
|
|
14572
|
+
session.server.sendResourceListChanged();
|
|
14573
|
+
notified++;
|
|
14574
|
+
}
|
|
14575
|
+
}
|
|
14576
|
+
if (notified > 0) {
|
|
14577
|
+
console.log(`[MCP] Notified ${notified} session(s) of resource changes`);
|
|
14578
|
+
}
|
|
14579
|
+
}
|
|
14580
|
+
};
|
|
14528
14581
|
}
|
|
14529
14582
|
export {
|
|
14583
|
+
C6 as EXTENSION_ID,
|
|
14530
14584
|
FAVICON_BASE64,
|
|
14531
14585
|
FAVICON_BUFFER,
|
|
14586
|
+
EI as RESOURCE_MIME_TYPE,
|
|
14587
|
+
je as RESOURCE_URI_META_KEY,
|
|
14588
|
+
pk as getUiCapability,
|
|
14589
|
+
ak as registerAppResource,
|
|
14590
|
+
hk as registerAppTool,
|
|
14532
14591
|
runMCPServer
|
|
14533
14592
|
};
|
|
14534
14593
|
//# sourceMappingURL=index.js.map
|