sunpeak 0.18.6 → 0.18.9
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/bin/commands/dev.mjs +9 -5
- package/bin/commands/inspect.mjs +13 -1
- package/bin/commands/new.mjs +5 -0
- package/bin/lib/dev-overlay.mjs +50 -0
- package/bin/lib/live/live-config.d.mts +3 -0
- package/bin/lib/live/live-config.mjs +3 -1
- package/bin/lib/sandbox-server.mjs +19 -0
- package/dist/chatgpt/index.cjs +2 -3
- package/dist/chatgpt/index.js +2 -3
- package/dist/claude/index.cjs +1 -2
- package/dist/claude/index.js +1 -2
- package/dist/host/chatgpt/index.cjs +0 -1
- package/dist/host/chatgpt/index.cjs.map +1 -1
- package/dist/host/chatgpt/index.js +0 -1
- package/dist/host/chatgpt/index.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/inspector/index.cjs +2 -3
- package/dist/inspector/index.js +2 -3
- package/dist/inspector/inspector-url.d.ts +13 -0
- package/dist/inspector/use-inspector-state.d.ts +2 -0
- package/dist/{inspector-DRD_Q66E.cjs → inspector-CTMccsz9.cjs} +71 -22
- package/dist/inspector-CTMccsz9.cjs.map +1 -0
- package/dist/{inspector-CjSoXm6N.js → inspector-DkS75JCk.js} +71 -22
- package/dist/inspector-DkS75JCk.js.map +1 -0
- package/dist/{inspector-url-7qhtJwY6.cjs → inspector-url-C3LTKgXt.cjs} +3 -1
- package/dist/inspector-url-C3LTKgXt.cjs.map +1 -0
- package/dist/{inspector-url-DuEFmxLP.js → inspector-url-CyQcuBI9.js} +3 -1
- package/dist/inspector-url-CyQcuBI9.js.map +1 -0
- package/dist/mcp/index.cjs +98 -15
- package/dist/mcp/index.cjs.map +1 -1
- package/dist/mcp/index.js +98 -15
- package/dist/mcp/index.js.map +1 -1
- package/dist/style.css +4 -0
- package/package.json +5 -5
- package/template/dist/albums/albums.html +1 -1
- package/template/dist/albums/albums.json +1 -1
- package/template/dist/carousel/carousel.html +1 -1
- package/template/dist/carousel/carousel.json +1 -1
- package/template/dist/map/map.html +1 -1
- package/template/dist/map/map.json +1 -1
- package/template/dist/review/review.html +1 -1
- package/template/dist/review/review.json +1 -1
- package/template/node_modules/.bin/vite +2 -2
- package/template/node_modules/.bin/vitest +2 -2
- package/template/node_modules/.vite/deps/_metadata.json +4 -4
- package/template/node_modules/.vite-mcp/deps/@testing-library_react.js +9 -6
- package/template/node_modules/.vite-mcp/deps/@testing-library_react.js.map +1 -1
- package/template/node_modules/.vite-mcp/deps/_metadata.json +21 -21
- package/template/node_modules/.vite-mcp/deps/vitest.js +366 -128
- package/template/node_modules/.vite-mcp/deps/vitest.js.map +1 -1
- package/template/package.json +2 -2
- package/template/tests/e2e/albums.spec.ts +1 -1
- package/template/tests/e2e/carousel.spec.ts +1 -1
- package/template/tests/e2e/dev-overlay.spec.ts +118 -0
- package/template/tests/e2e/helpers.ts +13 -0
- package/template/tests/e2e/map.spec.ts +1 -1
- package/template/tests/e2e/review.spec.ts +1 -1
- package/template/tests/live/playwright.config.ts +1 -1
- package/dist/inspector-CjSoXm6N.js.map +0 -1
- package/dist/inspector-DRD_Q66E.cjs.map +0 -1
- package/dist/inspector-url-7qhtJwY6.cjs.map +0 -1
- package/dist/inspector-url-DuEFmxLP.js.map +0 -1
|
@@ -2337,6 +2337,10 @@ function parseUrlParams() {
|
|
|
2337
2337
|
const host = params.get("host") ?? void 0;
|
|
2338
2338
|
const prodResourcesParam = params.get("prodResources");
|
|
2339
2339
|
const prodResources = prodResourcesParam === "true" ? true : prodResourcesParam === "false" ? false : void 0;
|
|
2340
|
+
const sidebarParam = params.get("sidebar");
|
|
2341
|
+
const sidebar = sidebarParam === "false" ? false : sidebarParam === "true" ? true : void 0;
|
|
2342
|
+
const devOverlayParam = params.get("devOverlay");
|
|
2343
|
+
const devOverlay = devOverlayParam === "false" ? false : devOverlayParam === "true" ? true : void 0;
|
|
2340
2344
|
const deviceType = params.get("deviceType");
|
|
2341
2345
|
let platform;
|
|
2342
2346
|
if (deviceType === "mobile" || deviceType === "tablet") platform = "mobile";
|
|
@@ -2369,7 +2373,9 @@ function parseUrlParams() {
|
|
|
2369
2373
|
deviceCapabilities,
|
|
2370
2374
|
safeAreaInsets,
|
|
2371
2375
|
host: host ?? void 0,
|
|
2372
|
-
prodResources
|
|
2376
|
+
prodResources,
|
|
2377
|
+
sidebar,
|
|
2378
|
+
devOverlay
|
|
2373
2379
|
};
|
|
2374
2380
|
}
|
|
2375
2381
|
function useInspectorState({ simulations, defaultHost = "chatgpt" }) {
|
|
@@ -2620,7 +2626,9 @@ function useInspectorState({ simulations, defaultHost = "chatgpt" }) {
|
|
|
2620
2626
|
permissions: resourceMeta?.permissions,
|
|
2621
2627
|
prefersBorder: resourceMeta?.prefersBorder ?? false,
|
|
2622
2628
|
urlTool: urlParams.tool,
|
|
2623
|
-
urlProdResources: urlParams.prodResources
|
|
2629
|
+
urlProdResources: urlParams.prodResources,
|
|
2630
|
+
urlSidebar: urlParams.sidebar,
|
|
2631
|
+
urlDevOverlay: urlParams.devOverlay
|
|
2624
2632
|
};
|
|
2625
2633
|
}
|
|
2626
2634
|
//#endregion
|
|
@@ -2654,18 +2662,23 @@ function useMcpConnection(initialServerUrl) {
|
|
|
2654
2662
|
body: JSON.stringify(body)
|
|
2655
2663
|
});
|
|
2656
2664
|
if (!res.ok) {
|
|
2657
|
-
let message
|
|
2665
|
+
let message;
|
|
2658
2666
|
try {
|
|
2659
2667
|
const json = await res.json();
|
|
2660
2668
|
if (json.error) message = json.error;
|
|
2661
2669
|
} catch {}
|
|
2670
|
+
if (!message) if (res.status === 404) message = "Server not found at this URL. Check the URL and make sure the server is running.";
|
|
2671
|
+
else if (res.status >= 500) message = `Server error (${res.status}). Check the MCP server logs for details.`;
|
|
2672
|
+
else message = `Connection failed (${res.status})`;
|
|
2662
2673
|
throw new Error(message);
|
|
2663
2674
|
}
|
|
2664
2675
|
const data = await res.json();
|
|
2665
2676
|
setStatus("connected");
|
|
2666
2677
|
setSimulations(data.simulations ?? void 0);
|
|
2667
2678
|
} catch (err) {
|
|
2668
|
-
|
|
2679
|
+
let message = err instanceof Error ? err.message : String(err);
|
|
2680
|
+
if (err instanceof TypeError && message === "Failed to fetch") message = "Cannot reach MCP server. Is it running?";
|
|
2681
|
+
setError(message);
|
|
2669
2682
|
setStatus("error");
|
|
2670
2683
|
setSimulations(void 0);
|
|
2671
2684
|
}
|
|
@@ -2684,7 +2697,10 @@ function useMcpConnection(initialServerUrl) {
|
|
|
2684
2697
|
try {
|
|
2685
2698
|
const res = await fetch("/__sunpeak/list-tools");
|
|
2686
2699
|
if (cancelled) return;
|
|
2687
|
-
if (!res.ok)
|
|
2700
|
+
if (!res.ok) {
|
|
2701
|
+
const msg = res.status === 404 ? "MCP server not reachable. Is it running?" : `Health check failed (${res.status}). Check the MCP server logs.`;
|
|
2702
|
+
throw new Error(msg);
|
|
2703
|
+
}
|
|
2688
2704
|
setStatus("connected");
|
|
2689
2705
|
} catch (err) {
|
|
2690
2706
|
if (cancelled) return;
|
|
@@ -3195,6 +3211,8 @@ function Inspector({ children, simulations: initialSimulations = {}, appName = "
|
|
|
3195
3211
|
const [oauthError, setOauthError] = React.useState();
|
|
3196
3212
|
const connection = useMcpConnection(mcpServerUrl || void 0);
|
|
3197
3213
|
const [prodResources, setProdResources] = React.useState(state.urlProdResources ?? defaultProdResources);
|
|
3214
|
+
const showSidebar = state.urlSidebar !== false;
|
|
3215
|
+
const showDevOverlay = state.urlDevOverlay !== false;
|
|
3198
3216
|
const [isRunning, setIsRunning] = React.useState(false);
|
|
3199
3217
|
const [hasRun, setHasRun] = React.useState(false);
|
|
3200
3218
|
const [showCheck, setShowCheck] = React.useState(false);
|
|
@@ -3365,26 +3383,47 @@ function Inspector({ children, simulations: initialSimulations = {}, appName = "
|
|
|
3365
3383
|
if (!caller || !sim) return;
|
|
3366
3384
|
const toolName = sim.tool.name;
|
|
3367
3385
|
setIsRunning(true);
|
|
3386
|
+
const startTime = performance.now();
|
|
3368
3387
|
try {
|
|
3369
3388
|
const result = await caller({
|
|
3370
3389
|
name: toolName,
|
|
3371
3390
|
arguments: state.toolInput
|
|
3372
3391
|
});
|
|
3373
|
-
|
|
3374
|
-
|
|
3392
|
+
const clientMs = Math.round((performance.now() - startTime) * 10) / 10;
|
|
3393
|
+
const resultMeta = result?._meta;
|
|
3394
|
+
const serverMs = (resultMeta?._sunpeak)?.requestTimeMs;
|
|
3395
|
+
const durationMs = typeof serverMs === "number" ? serverMs : clientMs;
|
|
3396
|
+
const resultWithTiming = {
|
|
3397
|
+
...result,
|
|
3398
|
+
_meta: {
|
|
3399
|
+
...resultMeta,
|
|
3400
|
+
_sunpeak: { requestTimeMs: durationMs }
|
|
3401
|
+
}
|
|
3402
|
+
};
|
|
3403
|
+
state.setToolResult(resultWithTiming);
|
|
3404
|
+
const displayResult = resultMeta?._sunpeak ? (() => {
|
|
3405
|
+
const { _sunpeak: _, ...cleanMeta } = resultMeta;
|
|
3406
|
+
const clean = { ...result };
|
|
3407
|
+
clean._meta = Object.keys(cleanMeta).length > 0 ? cleanMeta : void 0;
|
|
3408
|
+
if (clean._meta === void 0) delete clean._meta;
|
|
3409
|
+
return clean;
|
|
3410
|
+
})() : result;
|
|
3411
|
+
state.setToolResultJson(JSON.stringify(displayResult, null, 2));
|
|
3375
3412
|
state.setToolResultError("");
|
|
3376
3413
|
setHasRun(true);
|
|
3377
3414
|
setShowCheck(true);
|
|
3378
3415
|
clearTimeout(checkTimerRef.current);
|
|
3379
3416
|
checkTimerRef.current = setTimeout(() => setShowCheck(false), 2e3);
|
|
3380
3417
|
} catch (err) {
|
|
3418
|
+
const durationMs = Math.round((performance.now() - startTime) * 10) / 10;
|
|
3381
3419
|
const message = err instanceof Error ? err.message : String(err);
|
|
3382
3420
|
state.setToolResult({
|
|
3383
3421
|
content: [{
|
|
3384
3422
|
type: "text",
|
|
3385
3423
|
text: `Error: ${message}`
|
|
3386
3424
|
}],
|
|
3387
|
-
isError: true
|
|
3425
|
+
isError: true,
|
|
3426
|
+
_meta: { _sunpeak: { requestTimeMs: durationMs } }
|
|
3388
3427
|
});
|
|
3389
3428
|
state.setToolResultJson(JSON.stringify({
|
|
3390
3429
|
content: [{
|
|
@@ -3519,7 +3558,8 @@ function Inspector({ children, simulations: initialSimulations = {}, appName = "
|
|
|
3519
3558
|
clearTimeout(timer);
|
|
3520
3559
|
};
|
|
3521
3560
|
}, [prodResourcesPath]);
|
|
3522
|
-
const
|
|
3561
|
+
const baseResourceUrl = (prodResourcesPath && prodResourcesReady ? prodResourcesPath : void 0) ?? state.resourceUrl;
|
|
3562
|
+
const effectiveResourceUrl = baseResourceUrl && !showDevOverlay ? `${baseResourceUrl}${baseResourceUrl.includes("?") ? "&" : "?"}devOverlay=false` : baseResourceUrl;
|
|
3523
3563
|
const prodResourcesLoading = !!prodResourcesPath && !prodResourcesReady;
|
|
3524
3564
|
const hasTools = toolNames.length > 0;
|
|
3525
3565
|
const showEmptyState = !(activeSimulationName !== null && currentSim?.toolResult != null) && !hasRun;
|
|
@@ -3637,6 +3677,26 @@ function Inspector({ children, simulations: initialSimulations = {}, appName = "
|
|
|
3637
3677
|
children: /* @__PURE__ */ jsx("path", { d: "M0 0L10 6L0 12V0Z" })
|
|
3638
3678
|
}), "Run"]
|
|
3639
3679
|
}) : void 0;
|
|
3680
|
+
const conversationContent = ShellConversation ? /* @__PURE__ */ jsx(ShellConversation, {
|
|
3681
|
+
screenWidth: state.screenWidth,
|
|
3682
|
+
displayMode: state.displayMode,
|
|
3683
|
+
platform: state.platform,
|
|
3684
|
+
onRequestDisplayMode: state.handleDisplayModeChange,
|
|
3685
|
+
appName,
|
|
3686
|
+
appIcon,
|
|
3687
|
+
userMessage,
|
|
3688
|
+
onContentWidthChange: state.handleContentWidthChange,
|
|
3689
|
+
headerAction: runButton,
|
|
3690
|
+
children: content
|
|
3691
|
+
}) : content;
|
|
3692
|
+
if (!showSidebar) return /* @__PURE__ */ jsx(ThemeProvider, {
|
|
3693
|
+
theme: state.theme,
|
|
3694
|
+
applyTheme,
|
|
3695
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
3696
|
+
className: "flex h-screen w-screen",
|
|
3697
|
+
children: conversationContent
|
|
3698
|
+
})
|
|
3699
|
+
});
|
|
3640
3700
|
return /* @__PURE__ */ jsx(ThemeProvider, {
|
|
3641
3701
|
theme: state.theme,
|
|
3642
3702
|
applyTheme,
|
|
@@ -4169,22 +4229,11 @@ function Inspector({ children, simulations: initialSimulations = {}, appName = "
|
|
|
4169
4229
|
})
|
|
4170
4230
|
]
|
|
4171
4231
|
}),
|
|
4172
|
-
children:
|
|
4173
|
-
screenWidth: state.screenWidth,
|
|
4174
|
-
displayMode: state.displayMode,
|
|
4175
|
-
platform: state.platform,
|
|
4176
|
-
onRequestDisplayMode: state.handleDisplayModeChange,
|
|
4177
|
-
appName,
|
|
4178
|
-
appIcon,
|
|
4179
|
-
userMessage,
|
|
4180
|
-
onContentWidthChange: state.handleContentWidthChange,
|
|
4181
|
-
headerAction: runButton,
|
|
4182
|
-
children: content
|
|
4183
|
-
}) : content
|
|
4232
|
+
children: conversationContent
|
|
4184
4233
|
})
|
|
4185
4234
|
});
|
|
4186
4235
|
}
|
|
4187
4236
|
//#endregion
|
|
4188
4237
|
export { DEFAULT_STYLE_VARIABLES as S, McpAppHost as _, SidebarControl as a, getRegisteredHosts as b, SidebarTextarea as c, ThemeProvider as d, useThemeContext as f, extractResourceCSP as g, IframeResource as h, SidebarCollapsibleControl as i, SidebarToggle as l, useInspectorState as m, resolveServerToolResult as n, SidebarInput as o, useMcpConnection as p, SidebarCheckbox as r, SidebarSelect as s, Inspector as t, SimpleSidebar as u, SCREEN_WIDTHS as v, registerHostShell as x, getHostShell as y };
|
|
4189
4238
|
|
|
4190
|
-
//# sourceMappingURL=inspector-
|
|
4239
|
+
//# sourceMappingURL=inspector-DkS75JCk.js.map
|