sunpeak 0.16.21 → 0.16.27
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 +4 -3
- package/bin/commands/dev.mjs +120 -8
- package/bin/commands/new.mjs +6 -2
- package/bin/commands/start.mjs +7 -2
- package/bin/lib/get-port.mjs +60 -0
- package/bin/lib/live/browser-auth.mjs +161 -0
- package/bin/lib/live/chatgpt-config.d.mts +5 -0
- package/bin/lib/live/chatgpt-config.mjs +12 -0
- package/bin/lib/live/chatgpt-fixtures.d.mts +12 -0
- package/bin/lib/live/chatgpt-fixtures.mjs +25 -0
- package/bin/lib/live/chatgpt-page.mjs +210 -0
- package/bin/lib/live/global-setup.mjs +158 -0
- package/bin/lib/live/host-fixtures.mjs +61 -0
- package/bin/lib/live/host-page.mjs +294 -0
- package/bin/lib/live/live-config.d.mts +38 -0
- package/bin/lib/live/live-config.mjs +98 -0
- package/bin/lib/live/live-fixtures.d.mts +11 -0
- package/bin/lib/live/live-fixtures.mjs +102 -0
- package/bin/lib/live/test-config.d.mts +10 -0
- package/bin/lib/live/test-config.mjs +35 -0
- package/bin/lib/live/types.d.mts +54 -0
- package/bin/lib/live/utils.mjs +70 -0
- package/bin/lib/sandbox-server.mjs +304 -0
- package/bin/sunpeak.js +1 -1
- package/dist/chatgpt/chatgpt-conversation.d.ts +3 -7
- package/dist/chatgpt/globals.css +18 -0
- package/dist/chatgpt/index.cjs +1 -1
- package/dist/chatgpt/index.js +1 -1
- package/dist/claude/claude-conversation.d.ts +3 -2
- package/dist/claude/index.cjs +1 -1
- package/dist/claude/index.js +1 -1
- package/dist/{index-bKBBCBK6.cjs → index-BEWVLFfB.cjs} +2 -2
- package/dist/index-BEWVLFfB.cjs.map +1 -0
- package/dist/{index-CX6Z4bED.js → index-C6XYFOmh.js} +2 -2
- package/dist/index-C6XYFOmh.js.map +1 -0
- package/dist/{index-CKabCJyV.cjs → index-D0FsXP3Y.cjs} +2 -2
- package/dist/index-D0FsXP3Y.cjs.map +1 -0
- package/dist/{index-B4aC3vjH.js → index-Rg7SWjvl.js} +2 -2
- package/dist/index-Rg7SWjvl.js.map +1 -0
- package/dist/index.cjs +13 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +13 -5
- package/dist/index.js.map +1 -1
- package/dist/mcp/favicon.d.ts +3 -1
- package/dist/mcp/index.cjs +90 -49
- package/dist/mcp/index.cjs.map +1 -1
- package/dist/mcp/index.d.ts +2 -2
- package/dist/mcp/index.js +90 -49
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/production-server.d.ts +7 -1
- package/dist/mcp/types.d.ts +32 -1
- package/dist/simulator/hosts.d.ts +11 -2
- package/dist/simulator/iframe-resource.d.ts +8 -1
- package/dist/simulator/index.cjs +1 -1
- package/dist/simulator/index.js +1 -1
- package/dist/simulator/mcp-app-host.d.ts +17 -0
- package/dist/simulator/sandbox-proxy.d.ts +38 -0
- package/dist/simulator/simple-sidebar.d.ts +3 -1
- package/dist/simulator/simulator.d.ts +7 -1
- package/dist/simulator/use-simulator-state.d.ts +2 -4
- package/dist/{simulator-D8t-r7HH.js → simulator-B-CrMHVs.js} +504 -192
- package/dist/simulator-B-CrMHVs.js.map +1 -0
- package/dist/{simulator-FFNttkqL.cjs → simulator-Gc6n_fT4.cjs} +503 -191
- package/dist/simulator-Gc6n_fT4.cjs.map +1 -0
- package/dist/style.css +18 -0
- package/package.json +25 -1
- package/template/.sunpeak/dev.tsx +9 -3
- package/template/README.md +24 -2
- package/template/_gitignore +1 -0
- package/template/package.json +3 -2
- package/template/playwright.config.ts +34 -6
- package/template/src/server.ts +16 -2
- package/template/src/tools/show-albums.ts +17 -0
- package/template/tests/e2e/albums.spec.ts +37 -5
- package/template/tests/e2e/carousel.spec.ts +6 -6
- package/template/tests/e2e/global-setup.ts +6 -21
- package/template/tests/e2e/map.spec.ts +11 -11
- package/template/tests/e2e/review.spec.ts +24 -24
- package/template/tests/live/albums.spec.ts +53 -0
- package/template/tests/live/carousel.spec.ts +52 -0
- package/template/tests/live/map.spec.ts +31 -0
- package/template/tests/live/playwright.config.ts +3 -0
- package/template/tests/live/review.spec.ts +54 -0
- package/template/vitest.config.ts +1 -1
- package/dist/index-B4aC3vjH.js.map +0 -1
- package/dist/index-CKabCJyV.cjs.map +0 -1
- package/dist/index-CX6Z4bED.js.map +0 -1
- package/dist/index-bKBBCBK6.cjs.map +0 -1
- package/dist/simulator-D8t-r7HH.js.map +0 -1
- package/dist/simulator-FFNttkqL.cjs.map +0 -1
package/dist/mcp/favicon.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
export declare const FAVICON_BASE64 = "
|
|
1
|
+
export declare const FAVICON_BASE64 = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAOdEVYdFNvZnR3YXJlAEZpZ21hnrGWYwAAA6BJREFUeAHtm09ME0EUxr+lqIDVlMQEI8aAaPRUmwgmeLEcTLxR7ibASY+QqNfSqxfiDU+UhDvlZuKBcpEELpUTBwWCciDRsMGC8Q/W9y0U+29bu922dHZ/yXRndynp++btzLzZeRryCPqA5AigDQKpgBx9aGhSutiQkMoMsBLNvatln94LAX+mG99oUzalRDKF8Py71xuWjykxvgU1oKvjB3zew5Oi7zejBrBhpZGvymF7kReOPaBvRD6mUQVoaNCfxAP/HgLXDwxjea0QFCHxsVVKG96vtyHBIvXqoA0By7G0ABv8rbCJoP+bYfDIw6+mxv4vmzvnEHvnw6vYZamfhY1I3/CrW7Oz9Wl4+PG2cawG8dULmHl7CVEp9tA0TgEWpBZEBVTb8FzoFeOvrxmeUSFxCrCLo86hbHznDzH9bAOh/l3UA3pCZLazkkdDpwApWICtPRf+ICL8Rj0xvGFKvGHJmjdYEoA9eahfx2mCj4O+7yn7e5Y9QBWa4HBcAeBwHC9A0QiE47zPW99hrlI4TBajqACTT7dkPv8FjQznB0ORm6b3TR+B0H294Y0nnK8Um6KbCjD5ZAuqwDjFjIICsOUrDWNPE/QAMy8oKMCwxPGqYeYFeQJ0dfwUtfagGmZekBcL0PUpgopwuS137dENhuBwXAHgcNxgKPOkVqu69YbL62myRoHUmxU4Ae1R30n95BFQaepbikxb3U4QDscVIF0ptXSkEpm2Zg2DAy9uw2m4wRAcjisAHI4bDOVe4NugQM8BVITDX+5ukjwBaPzCyzWoSPewP+9a3iPAUDG+ehGqQbsKTfYK9gGR2StQjRmTrXUFBVDNC9jy0XIEICp5AXeRmWEqAL0gttSORoctX2wLXclYoNFXivSkp+hOdDcYgsNxBYDDcYMhWEClzdKWBDgaWjzGRqp6D5Mc4oYiNywZT+RbnWNyLDtTbO1TC+ZlgtHurV/4zInawPNbWPvcCovotqTMcE9hLb2BcQqn6pkvOa3+KxGgVzxAm4QNcHsdd5hVa5OVjYanGRUBAjJRPsO0OduyRekJY6EdDIpn2JE2x1D2KEK1zXBB2wSWu4/zBu+GZEScQxVg/8CESZY7Pd+Nc7M8IxqrJ5uRWG/ForR2fNVbzTdWo0yhzcgd7p0QVcKoEbmeUdtXc1pEWn/CqGXfYBIlRUh1QU2YST7KlNn0Ba3w3xnZpMNSArCxb6gTnLElpFHnAW9UutKsGdxfpFM6myaou6kAAAAASUVORK5CYII=";
|
|
2
|
+
/** Data URI for use in serverInfo.icons[].src (inline, no fetch needed). */
|
|
3
|
+
export declare const FAVICON_DATA_URI = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAOdEVYdFNvZnR3YXJlAEZpZ21hnrGWYwAAA6BJREFUeAHtm09ME0EUxr+lqIDVlMQEI8aAaPRUmwgmeLEcTLxR7ibASY+QqNfSqxfiDU+UhDvlZuKBcpEELpUTBwWCciDRsMGC8Q/W9y0U+29bu922dHZ/yXRndynp++btzLzZeRryCPqA5AigDQKpgBx9aGhSutiQkMoMsBLNvatln94LAX+mG99oUzalRDKF8Py71xuWjykxvgU1oKvjB3zew5Oi7zejBrBhpZGvymF7kReOPaBvRD6mUQVoaNCfxAP/HgLXDwxjea0QFCHxsVVKG96vtyHBIvXqoA0By7G0ABv8rbCJoP+bYfDIw6+mxv4vmzvnEHvnw6vYZamfhY1I3/CrW7Oz9Wl4+PG2cawG8dULmHl7CVEp9tA0TgEWpBZEBVTb8FzoFeOvrxmeUSFxCrCLo86hbHznDzH9bAOh/l3UA3pCZLazkkdDpwApWICtPRf+ICL8Rj0xvGFKvGHJmjdYEoA9eahfx2mCj4O+7yn7e5Y9QBWa4HBcAeBwHC9A0QiE47zPW99hrlI4TBajqACTT7dkPv8FjQznB0ORm6b3TR+B0H294Y0nnK8Um6KbCjD5ZAuqwDjFjIICsOUrDWNPE/QAMy8oKMCwxPGqYeYFeQJ0dfwUtfagGmZekBcL0PUpgopwuS137dENhuBwXAHgcNxgKPOkVqu69YbL62myRoHUmxU4Ae1R30n95BFQaepbikxb3U4QDscVIF0ptXSkEpm2Zg2DAy9uw2m4wRAcjisAHI4bDOVe4NugQM8BVITDX+5ukjwBaPzCyzWoSPewP+9a3iPAUDG+ehGqQbsKTfYK9gGR2StQjRmTrXUFBVDNC9jy0XIEICp5AXeRmWEqAL0gttSORoctX2wLXclYoNFXivSkp+hOdDcYgsNxBYDDcYMhWEClzdKWBDgaWjzGRqp6D5Mc4oYiNywZT+RbnWNyLDtTbO1TC+ZlgtHurV/4zInawPNbWPvcCovotqTMcE9hLb2BcQqn6pkvOa3+KxGgVzxAm4QNcHsdd5hVa5OVjYanGRUBAjJRPsO0OduyRekJY6EdDIpn2JE2x1D2KEK1zXBB2wSWu4/zBu+GZEScQxVg/8CESZY7Pd+Nc7M8IxqrJ5uRWG/ForR2fNVbzTdWo0yhzcgd7p0QVcKoEbmeUdtXc1pEWn/CqGXfYBIlRUh1QU2YST7KlNn0Ba3w3xnZpMNSArCxb6gTnLElpFHnAW9UutKsGdxfpFM6myaou6kAAAAASUVORK5CYII=";
|
|
2
4
|
export declare const FAVICON_BUFFER: Buffer<ArrayBuffer>;
|
package/dist/mcp/index.cjs
CHANGED
|
@@ -11,7 +11,8 @@ const http2 = require("http2");
|
|
|
11
11
|
const stream = require("stream");
|
|
12
12
|
const crypto$1 = require("crypto");
|
|
13
13
|
const node_crypto = require("node:crypto");
|
|
14
|
-
const FAVICON_BASE64 = "
|
|
14
|
+
const FAVICON_BASE64 = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAOdEVYdFNvZnR3YXJlAEZpZ21hnrGWYwAAA6BJREFUeAHtm09ME0EUxr+lqIDVlMQEI8aAaPRUmwgmeLEcTLxR7ibASY+QqNfSqxfiDU+UhDvlZuKBcpEELpUTBwWCciDRsMGC8Q/W9y0U+29bu922dHZ/yXRndynp++btzLzZeRryCPqA5AigDQKpgBx9aGhSutiQkMoMsBLNvatln94LAX+mG99oUzalRDKF8Py71xuWjykxvgU1oKvjB3zew5Oi7zejBrBhpZGvymF7kReOPaBvRD6mUQVoaNCfxAP/HgLXDwxjea0QFCHxsVVKG96vtyHBIvXqoA0By7G0ABv8rbCJoP+bYfDIw6+mxv4vmzvnEHvnw6vYZamfhY1I3/CrW7Oz9Wl4+PG2cawG8dULmHl7CVEp9tA0TgEWpBZEBVTb8FzoFeOvrxmeUSFxCrCLo86hbHznDzH9bAOh/l3UA3pCZLazkkdDpwApWICtPRf+ICL8Rj0xvGFKvGHJmjdYEoA9eahfx2mCj4O+7yn7e5Y9QBWa4HBcAeBwHC9A0QiE47zPW99hrlI4TBajqACTT7dkPv8FjQznB0ORm6b3TR+B0H294Y0nnK8Um6KbCjD5ZAuqwDjFjIICsOUrDWNPE/QAMy8oKMCwxPGqYeYFeQJ0dfwUtfagGmZekBcL0PUpgopwuS137dENhuBwXAHgcNxgKPOkVqu69YbL62myRoHUmxU4Ae1R30n95BFQaepbikxb3U4QDscVIF0ptXSkEpm2Zg2DAy9uw2m4wRAcjisAHI4bDOVe4NugQM8BVITDX+5ukjwBaPzCyzWoSPewP+9a3iPAUDG+ehGqQbsKTfYK9gGR2StQjRmTrXUFBVDNC9jy0XIEICp5AXeRmWEqAL0gttSORoctX2wLXclYoNFXivSkp+hOdDcYgsNxBYDDcYMhWEClzdKWBDgaWjzGRqp6D5Mc4oYiNywZT+RbnWNyLDtTbO1TC+ZlgtHurV/4zInawPNbWPvcCovotqTMcE9hLb2BcQqn6pkvOa3+KxGgVzxAm4QNcHsdd5hVa5OVjYanGRUBAjJRPsO0OduyRekJY6EdDIpn2JE2x1D2KEK1zXBB2wSWu4/zBu+GZEScQxVg/8CESZY7Pd+Nc7M8IxqrJ5uRWG/ForR2fNVbzTdWo0yhzcgd7p0QVcKoEbmeUdtXc1pEWn/CqGXfYBIlRUh1QU2YST7KlNn0Ba3w3xnZpMNSArCxb6gTnLElpFHnAW9UutKsGdxfpFM6myaou6kAAAAASUVORK5CYII=";
|
|
15
|
+
const FAVICON_DATA_URI = `data:image/png;base64,${FAVICON_BASE64}`;
|
|
15
16
|
const FAVICON_BUFFER = Buffer.from(FAVICON_BASE64, "base64");
|
|
16
17
|
function getDefaultExportFromCjs(x) {
|
|
17
18
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
@@ -9523,8 +9524,8 @@ function dZ(Z) {
|
|
|
9523
9524
|
if (!Z) return;
|
|
9524
9525
|
return Z.extensions?.[OQ];
|
|
9525
9526
|
}
|
|
9526
|
-
|
|
9527
|
-
|
|
9527
|
+
let localDevServerUrl = "http://localhost:8000";
|
|
9528
|
+
let localHmrWsUrl = "ws://localhost:24678";
|
|
9528
9529
|
function needsProdBuild(headers) {
|
|
9529
9530
|
const ua = headers["user-agent"];
|
|
9530
9531
|
const userAgent = typeof ua === "string" ? ua : Array.isArray(ua) ? ua[0] : "";
|
|
@@ -9543,7 +9544,7 @@ function getViteResourceHtml(srcPath) {
|
|
|
9543
9544
|
const rawFileName = srcPath.split("/").pop() ?? "";
|
|
9544
9545
|
const fileName = rawFileName.replace(/\.tsx$/, "");
|
|
9545
9546
|
const componentName = fileName.split("-").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("") + "Resource";
|
|
9546
|
-
const devServerUrl =
|
|
9547
|
+
const devServerUrl = localDevServerUrl;
|
|
9547
9548
|
const entryParams = new URLSearchParams({ src: srcPath, component: componentName });
|
|
9548
9549
|
const virtualModuleUrl = `${devServerUrl}/@id/virtual:sunpeak-entry?${entryParams.toString()}`;
|
|
9549
9550
|
return `<!DOCTYPE html>
|
|
@@ -9593,11 +9594,11 @@ function injectViteCSP(existingMeta) {
|
|
|
9593
9594
|
const ui = meta.ui ?? {};
|
|
9594
9595
|
const csp = ui.csp ?? {};
|
|
9595
9596
|
const existingResourceDomains = csp.resourceDomains ?? [];
|
|
9596
|
-
const resourceDomains = existingResourceDomains.includes(
|
|
9597
|
+
const resourceDomains = existingResourceDomains.includes(localDevServerUrl) ? existingResourceDomains : [...existingResourceDomains, localDevServerUrl];
|
|
9597
9598
|
const existingConnectDomains = csp.connectDomains ?? [];
|
|
9598
9599
|
const connectDomains = [...existingConnectDomains];
|
|
9599
|
-
if (!connectDomains.includes(
|
|
9600
|
-
if (!connectDomains.includes(
|
|
9600
|
+
if (!connectDomains.includes(localDevServerUrl)) connectDomains.push(localDevServerUrl);
|
|
9601
|
+
if (!connectDomains.includes(localHmrWsUrl)) connectDomains.push(localHmrWsUrl);
|
|
9601
9602
|
return {
|
|
9602
9603
|
...meta,
|
|
9603
9604
|
ui: {
|
|
@@ -9608,16 +9609,19 @@ function injectViteCSP(existingMeta) {
|
|
|
9608
9609
|
}
|
|
9609
9610
|
const startupTimestamp = Date.now().toString(36);
|
|
9610
9611
|
function createAppServer(config, simulations, viteMode) {
|
|
9611
|
-
const { name = "sunpeak-app", version = "0.1.0" } = config;
|
|
9612
|
+
const { name = "sunpeak-app", version = "0.1.0", serverInfo } = config;
|
|
9612
9613
|
const mcpServer = new McpServer(
|
|
9613
9614
|
{
|
|
9614
|
-
name,
|
|
9615
|
-
version,
|
|
9616
|
-
|
|
9615
|
+
name: serverInfo?.name ?? name,
|
|
9616
|
+
version: serverInfo?.version ?? version,
|
|
9617
|
+
...serverInfo?.title ? { title: serverInfo.title } : {},
|
|
9618
|
+
...serverInfo?.description ? { description: serverInfo.description } : {},
|
|
9619
|
+
...serverInfo?.websiteUrl ? { websiteUrl: serverInfo.websiteUrl } : {},
|
|
9620
|
+
icons: serverInfo?.icons ?? [
|
|
9617
9621
|
{
|
|
9618
|
-
src:
|
|
9622
|
+
src: FAVICON_DATA_URI,
|
|
9619
9623
|
mimeType: "image/png",
|
|
9620
|
-
sizes: ["
|
|
9624
|
+
sizes: ["64x64"]
|
|
9621
9625
|
}
|
|
9622
9626
|
]
|
|
9623
9627
|
},
|
|
@@ -9692,6 +9696,9 @@ function createAppServer(config, simulations, viteMode) {
|
|
|
9692
9696
|
tool.name,
|
|
9693
9697
|
{
|
|
9694
9698
|
description: tool.description,
|
|
9699
|
+
...simulation.outputSchema ? {
|
|
9700
|
+
outputSchema: simulation.outputSchema
|
|
9701
|
+
} : {},
|
|
9695
9702
|
_meta: fullToolMeta
|
|
9696
9703
|
},
|
|
9697
9704
|
async (extra) => {
|
|
@@ -9735,17 +9742,19 @@ function createAppServer(config, simulations, viteMode) {
|
|
|
9735
9742
|
} else if (!registeredToolNames.has(tool.name)) {
|
|
9736
9743
|
registeredToolNames.add(tool.name);
|
|
9737
9744
|
const realHandler = simulation.handler;
|
|
9745
|
+
const plainToolConfig = {
|
|
9746
|
+
description: tool.description,
|
|
9747
|
+
// Use passthrough so the SDK passes all args to the handler without stripping.
|
|
9748
|
+
// We can't use the tool's own Zod schema because it's loaded via Vite SSR
|
|
9749
|
+
// from a different Zod module instance, causing isZodSchemaInstance checks to fail.
|
|
9750
|
+
inputSchema: zod.z.object({}).passthrough(),
|
|
9751
|
+
...simulation.outputSchema ? { outputSchema: simulation.outputSchema } : {},
|
|
9752
|
+
annotations: tool.annotations,
|
|
9753
|
+
_meta: toolMeta
|
|
9754
|
+
};
|
|
9738
9755
|
mcpServer.registerTool(
|
|
9739
9756
|
tool.name,
|
|
9740
|
-
|
|
9741
|
-
description: tool.description,
|
|
9742
|
-
// Use passthrough so the SDK passes all args to the handler without stripping.
|
|
9743
|
-
// We can't use the tool's own Zod schema because it's loaded via Vite SSR
|
|
9744
|
-
// from a different Zod module instance, causing isZodSchemaInstance checks to fail.
|
|
9745
|
-
inputSchema: zod.z.object({}).passthrough(),
|
|
9746
|
-
annotations: tool.annotations,
|
|
9747
|
-
_meta: toolMeta
|
|
9748
|
-
},
|
|
9757
|
+
plainToolConfig,
|
|
9749
9758
|
async (args, extra) => {
|
|
9750
9759
|
const argKeys = Object.keys(args);
|
|
9751
9760
|
const argsStr = argKeys.length > 0 ? `{${argKeys.join(", ")}}` : "{}";
|
|
@@ -9902,6 +9911,10 @@ function runMCPServer(config) {
|
|
|
9902
9911
|
const portEnv = Number(process.env.PORT ?? 8e3);
|
|
9903
9912
|
const port = config.port ?? (Number.isFinite(portEnv) ? portEnv : 8e3);
|
|
9904
9913
|
const { simulations } = config;
|
|
9914
|
+
localDevServerUrl = `http://localhost:${port}`;
|
|
9915
|
+
if (config.hmrPort) {
|
|
9916
|
+
localHmrWsUrl = `ws://localhost:${config.hmrPort}`;
|
|
9917
|
+
}
|
|
9905
9918
|
const viteServer = config.viteServer;
|
|
9906
9919
|
const viteMode = !!viteServer;
|
|
9907
9920
|
const httpServer = node_http.createServer(async (req, res) => {
|
|
@@ -9924,21 +9937,21 @@ function runMCPServer(config) {
|
|
|
9924
9937
|
<html>
|
|
9925
9938
|
<head>
|
|
9926
9939
|
<meta charset="UTF-8" />
|
|
9927
|
-
<link rel="icon" type="image/png" href="/favicon.
|
|
9940
|
+
<link rel="icon" type="image/png" href="/favicon.png" />
|
|
9928
9941
|
<title>Sunpeak MCP Server</title>
|
|
9929
9942
|
</head>
|
|
9930
9943
|
<body><h1>Sunpeak MCP Server</h1><p>Connect via <a href="/mcp">/mcp</a></p></body>
|
|
9931
9944
|
</html>`);
|
|
9932
9945
|
return;
|
|
9933
9946
|
}
|
|
9934
|
-
if (req.method === "GET" && url.pathname === "/favicon.ico") {
|
|
9947
|
+
if ((req.method === "GET" || req.method === "HEAD") && (url.pathname === "/favicon.png" || url.pathname === "/favicon.ico")) {
|
|
9935
9948
|
res.writeHead(200, {
|
|
9936
9949
|
"Content-Type": "image/png",
|
|
9937
9950
|
"Content-Length": FAVICON_BUFFER.length,
|
|
9938
9951
|
"Cache-Control": "public, max-age=86400",
|
|
9939
9952
|
"Access-Control-Allow-Origin": "*"
|
|
9940
9953
|
});
|
|
9941
|
-
res.end(FAVICON_BUFFER);
|
|
9954
|
+
res.end(req.method === "HEAD" ? void 0 : FAVICON_BUFFER);
|
|
9942
9955
|
return;
|
|
9943
9956
|
}
|
|
9944
9957
|
if (url.pathname === MCP_PATH$1) {
|
|
@@ -9963,13 +9976,24 @@ function runMCPServer(config) {
|
|
|
9963
9976
|
console.error("HTTP client error", err);
|
|
9964
9977
|
socket.end("HTTP/1.1 400 Bad Request\r\n\r\n");
|
|
9965
9978
|
});
|
|
9966
|
-
|
|
9967
|
-
|
|
9968
|
-
|
|
9979
|
+
const onListening = () => {
|
|
9980
|
+
const actualPort = httpServer.address().port;
|
|
9981
|
+
localDevServerUrl = `http://localhost:${actualPort}`;
|
|
9982
|
+
console.log(`Sunpeak MCP server listening on http://localhost:${actualPort}`);
|
|
9983
|
+
console.log(` MCP endpoint: http://localhost:${actualPort}${MCP_PATH$1}`);
|
|
9969
9984
|
if (viteMode) {
|
|
9970
9985
|
console.log(` Vite HMR: enabled (source files served with hot reload)`);
|
|
9971
9986
|
}
|
|
9987
|
+
};
|
|
9988
|
+
httpServer.on("error", (err) => {
|
|
9989
|
+
if (err.code === "EADDRINUSE") {
|
|
9990
|
+
console.warn(`Port ${port} in use, finding an available port...`);
|
|
9991
|
+
httpServer.listen(0);
|
|
9992
|
+
} else {
|
|
9993
|
+
throw err;
|
|
9994
|
+
}
|
|
9972
9995
|
});
|
|
9996
|
+
httpServer.listen(port, onListening);
|
|
9973
9997
|
const shutdown = async () => {
|
|
9974
9998
|
console.log("\nShutting down MCP server...");
|
|
9975
9999
|
httpServer.close(() => {
|
|
@@ -10036,16 +10060,19 @@ function log(level, msg, extra) {
|
|
|
10036
10060
|
}
|
|
10037
10061
|
}
|
|
10038
10062
|
function createProductionMcpServer(config) {
|
|
10039
|
-
const { name = "sunpeak-app", version = "0.1.0", tools, resources } = config;
|
|
10063
|
+
const { name = "sunpeak-app", version = "0.1.0", serverInfo, tools, resources } = config;
|
|
10040
10064
|
const mcpServer = new McpServer(
|
|
10041
10065
|
{
|
|
10042
|
-
name,
|
|
10043
|
-
version,
|
|
10044
|
-
|
|
10066
|
+
name: serverInfo?.name ?? name,
|
|
10067
|
+
version: serverInfo?.version ?? version,
|
|
10068
|
+
...serverInfo?.title ? { title: serverInfo.title } : {},
|
|
10069
|
+
...serverInfo?.description ? { description: serverInfo.description } : {},
|
|
10070
|
+
...serverInfo?.websiteUrl ? { websiteUrl: serverInfo.websiteUrl } : {},
|
|
10071
|
+
icons: serverInfo?.icons ?? [
|
|
10045
10072
|
{
|
|
10046
|
-
src:
|
|
10073
|
+
src: FAVICON_DATA_URI,
|
|
10047
10074
|
mimeType: "image/png",
|
|
10048
|
-
sizes: ["
|
|
10075
|
+
sizes: ["64x64"]
|
|
10049
10076
|
}
|
|
10050
10077
|
]
|
|
10051
10078
|
},
|
|
@@ -10107,6 +10134,7 @@ function createProductionMcpServer(config) {
|
|
|
10107
10134
|
description: tool.tool.description,
|
|
10108
10135
|
annotations: tool.tool.annotations,
|
|
10109
10136
|
...tool.schema ? { inputSchema: tool.schema } : {},
|
|
10137
|
+
...tool.outputSchema ? { outputSchema: tool.outputSchema } : {},
|
|
10110
10138
|
_meta: {
|
|
10111
10139
|
...tool.tool._meta,
|
|
10112
10140
|
ui: {
|
|
@@ -10123,17 +10151,19 @@ function createProductionMcpServer(config) {
|
|
|
10123
10151
|
);
|
|
10124
10152
|
} else {
|
|
10125
10153
|
const cb = makeCallback();
|
|
10126
|
-
const
|
|
10127
|
-
|
|
10128
|
-
|
|
10129
|
-
|
|
10130
|
-
|
|
10154
|
+
const toolConfig = {
|
|
10155
|
+
description: tool.tool.description,
|
|
10156
|
+
annotations: tool.tool.annotations,
|
|
10157
|
+
_meta: tool.tool._meta,
|
|
10158
|
+
...tool.schema ? { inputSchema: tool.schema } : {},
|
|
10159
|
+
...tool.outputSchema ? { outputSchema: tool.outputSchema } : {}
|
|
10160
|
+
};
|
|
10161
|
+
mcpServer.registerTool(tool.name, toolConfig, async (...args) => {
|
|
10131
10162
|
if (tool.schema) {
|
|
10132
10163
|
return cb(args[0], args[1]);
|
|
10133
10164
|
}
|
|
10134
10165
|
return cb(args[0]);
|
|
10135
10166
|
});
|
|
10136
|
-
mcpServer.tool(...toolArgs);
|
|
10137
10167
|
}
|
|
10138
10168
|
toolCount++;
|
|
10139
10169
|
}
|
|
@@ -10317,8 +10347,8 @@ function createHandler(config) {
|
|
|
10317
10347
|
return addCorsHeaders(response);
|
|
10318
10348
|
}
|
|
10319
10349
|
if (req.method === "POST") {
|
|
10320
|
-
const { name, version, tools, resources } = config;
|
|
10321
|
-
const server = createProductionMcpServer({ name, version, tools, resources });
|
|
10350
|
+
const { name, version, serverInfo, tools, resources } = config;
|
|
10351
|
+
const server = createProductionMcpServer({ name, version, serverInfo, tools, resources });
|
|
10322
10352
|
const transport = new WebStandardStreamableHTTPServerTransport({
|
|
10323
10353
|
sessionIdGenerator: () => node_crypto.randomUUID(),
|
|
10324
10354
|
onsessioninitialized: (id2) => {
|
|
@@ -10401,21 +10431,21 @@ function startProductionHttpServer(config, portOrOptions) {
|
|
|
10401
10431
|
<html>
|
|
10402
10432
|
<head>
|
|
10403
10433
|
<meta charset="UTF-8" />
|
|
10404
|
-
<link rel="icon" type="image/png" href="/favicon.
|
|
10434
|
+
<link rel="icon" type="image/png" href="/favicon.png" />
|
|
10405
10435
|
<title>Sunpeak MCP Server</title>
|
|
10406
10436
|
</head>
|
|
10407
10437
|
<body><h1>Sunpeak MCP Server</h1><p>Connect via <a href="/mcp">/mcp</a></p></body>
|
|
10408
10438
|
</html>`);
|
|
10409
10439
|
return;
|
|
10410
10440
|
}
|
|
10411
|
-
if (req.method === "GET" && url.pathname === "/favicon.ico") {
|
|
10441
|
+
if ((req.method === "GET" || req.method === "HEAD") && (url.pathname === "/favicon.png" || url.pathname === "/favicon.ico")) {
|
|
10412
10442
|
res.writeHead(200, {
|
|
10413
10443
|
"Content-Type": "image/png",
|
|
10414
10444
|
"Content-Length": FAVICON_BUFFER.length,
|
|
10415
10445
|
"Cache-Control": "public, max-age=86400",
|
|
10416
10446
|
"Access-Control-Allow-Origin": "*"
|
|
10417
10447
|
});
|
|
10418
|
-
res.end(FAVICON_BUFFER);
|
|
10448
|
+
res.end(req.method === "HEAD" ? void 0 : FAVICON_BUFFER);
|
|
10419
10449
|
return;
|
|
10420
10450
|
}
|
|
10421
10451
|
await mcpHandler(req, res);
|
|
@@ -10429,11 +10459,21 @@ function startProductionHttpServer(config, portOrOptions) {
|
|
|
10429
10459
|
socket.end("HTTP/1.1 400 Bad Request\r\n\r\n");
|
|
10430
10460
|
});
|
|
10431
10461
|
const displayHost = host === "0.0.0.0" ? "localhost" : host;
|
|
10432
|
-
|
|
10433
|
-
|
|
10434
|
-
log("info", `
|
|
10435
|
-
log("info", `
|
|
10462
|
+
const onListening = () => {
|
|
10463
|
+
const addr = httpServer.address();
|
|
10464
|
+
log("info", `Server listening on http://${displayHost}:${addr.port}`);
|
|
10465
|
+
log("info", `MCP endpoint: http://${displayHost}:${addr.port}${MCP_PATH}`);
|
|
10466
|
+
log("info", `Health check: http://${displayHost}:${addr.port}/health`);
|
|
10467
|
+
};
|
|
10468
|
+
httpServer.on("error", (err) => {
|
|
10469
|
+
if (err.code === "EADDRINUSE") {
|
|
10470
|
+
log("warn", `Port ${port} in use, finding an available port...`);
|
|
10471
|
+
httpServer.listen(0, host);
|
|
10472
|
+
} else {
|
|
10473
|
+
throw err;
|
|
10474
|
+
}
|
|
10436
10475
|
});
|
|
10476
|
+
httpServer.listen(port, host, onListening);
|
|
10437
10477
|
const shutdown = async () => {
|
|
10438
10478
|
log("info", "Shutting down MCP server...");
|
|
10439
10479
|
httpServer.close(() => {
|
|
@@ -10451,6 +10491,7 @@ function startProductionHttpServer(config, portOrOptions) {
|
|
|
10451
10491
|
exports.EXTENSION_ID = OQ;
|
|
10452
10492
|
exports.FAVICON_BASE64 = FAVICON_BASE64;
|
|
10453
10493
|
exports.FAVICON_BUFFER = FAVICON_BUFFER;
|
|
10494
|
+
exports.FAVICON_DATA_URI = FAVICON_DATA_URI;
|
|
10454
10495
|
exports.RESOURCE_MIME_TYPE = d;
|
|
10455
10496
|
exports.RESOURCE_URI_META_KEY = v;
|
|
10456
10497
|
exports.createHandler = createHandler;
|