sunpeak 0.16.28 → 0.17.1
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 +169 -342
- package/bin/commands/inspect.mjs +763 -0
- package/bin/commands/new.mjs +2 -2
- package/bin/lib/inspect/inspect-config.d.mts +20 -0
- package/bin/lib/inspect/inspect-config.mjs +76 -0
- package/bin/lib/live/global-setup.mjs +6 -1
- package/bin/sunpeak.js +11 -1
- package/dist/chatgpt/globals.css +35 -18
- package/dist/chatgpt/index.cjs +3 -11
- package/dist/chatgpt/index.cjs.map +1 -1
- package/dist/chatgpt/index.d.ts +2 -2
- package/dist/chatgpt/index.js +4 -8
- package/dist/chatgpt/index.js.map +1 -1
- package/dist/claude/index.cjs +1 -1
- package/dist/claude/index.js +1 -1
- package/dist/discovery-Cgoegt62.js +114 -0
- package/dist/discovery-Cgoegt62.js.map +1 -0
- package/dist/discovery-Clu4uHp1.cjs +161 -0
- package/dist/discovery-Clu4uHp1.cjs.map +1 -0
- package/dist/index.cjs +1 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/dist/lib/discovery-cli.cjs +1 -1
- package/dist/lib/discovery-cli.js +1 -1
- package/dist/lib/discovery.d.ts +7 -67
- package/dist/lib/index.d.ts +0 -1
- package/dist/mcp/index.cjs +34 -23
- package/dist/mcp/index.cjs.map +1 -1
- package/dist/mcp/index.js +34 -23
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/types.d.ts +5 -0
- package/dist/simulator/index.cjs +5 -11
- package/dist/simulator/index.cjs.map +1 -1
- package/dist/simulator/index.d.ts +4 -2
- package/dist/simulator/index.js +5 -8
- package/dist/simulator/index.js.map +1 -1
- package/dist/simulator/simple-sidebar.d.ts +7 -4
- package/dist/simulator/simulator-url.d.ts +8 -0
- package/dist/simulator/simulator.d.ts +15 -2
- package/dist/simulator/use-mcp-connection.d.ts +19 -0
- package/dist/{simulator-BYIH-xqQ.cjs → simulator-CH9hs0N6.cjs} +159 -52
- package/dist/simulator-CH9hs0N6.cjs.map +1 -0
- package/dist/{simulator-CmgNnWBO.js → simulator-Dl8B-Ljb.js} +154 -53
- package/dist/simulator-Dl8B-Ljb.js.map +1 -0
- package/dist/{simulator-url-BDGD4vZD.cjs → simulator-url-CozKF1jf.cjs} +3 -1
- package/dist/simulator-url-CozKF1jf.cjs.map +1 -0
- package/dist/{simulator-url-Bkxj43yT.js → simulator-url-KoS_ToP6.js} +3 -1
- package/dist/simulator-url-KoS_ToP6.js.map +1 -0
- package/dist/style.css +35 -18
- package/package.json +9 -1
- package/template/dist/albums/albums.html +105 -0
- package/template/dist/albums/albums.json +16 -0
- package/template/dist/carousel/carousel.html +105 -0
- package/template/dist/carousel/carousel.json +16 -0
- package/template/dist/map/map.html +3060 -0
- package/template/dist/map/map.json +22 -0
- package/template/dist/review/review.html +105 -0
- package/template/dist/review/review.json +16 -0
- package/template/dist/server.js +15 -0
- package/template/dist/tools/review-diff.js +50 -0
- package/template/dist/tools/review-post.js +50 -0
- package/template/dist/tools/review-purchase.js +61 -0
- package/template/dist/tools/review.js +31 -0
- package/template/dist/tools/show-albums.js +56 -0
- package/template/dist/tools/show-carousel.js +41 -0
- package/template/dist/tools/show-map.js +47 -0
- package/template/node_modules/.vite/deps/_metadata.json +8 -0
- package/template/node_modules/.vite/deps/package.json +3 -0
- package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps.js +500 -0
- package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps.js.map +1 -0
- package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps_app-bridge.js +563 -0
- package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps_app-bridge.js.map +1 -0
- package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps_react.js +575 -0
- package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps_react.js.map +1 -0
- package/template/node_modules/.vite-mcp/deps/@testing-library_react.js +11363 -0
- package/template/node_modules/.vite-mcp/deps/@testing-library_react.js.map +1 -0
- package/template/node_modules/.vite-mcp/deps/_metadata.json +130 -0
- package/template/node_modules/.vite-mcp/deps/chunk-BoAXSpZd.js +33 -0
- package/template/node_modules/.vite-mcp/deps/client-CU1wWud4.js +14385 -0
- package/template/node_modules/.vite-mcp/deps/client-CU1wWud4.js.map +1 -0
- package/template/node_modules/.vite-mcp/deps/clsx.js +18 -0
- package/template/node_modules/.vite-mcp/deps/clsx.js.map +1 -0
- package/template/node_modules/.vite-mcp/deps/dist-uWX8WbjY.js +505 -0
- package/template/node_modules/.vite-mcp/deps/dist-uWX8WbjY.js.map +1 -0
- package/template/node_modules/.vite-mcp/deps/embla-carousel-react.js +1461 -0
- package/template/node_modules/.vite-mcp/deps/embla-carousel-react.js.map +1 -0
- package/template/node_modules/.vite-mcp/deps/embla-carousel-wheel-gestures.js +536 -0
- package/template/node_modules/.vite-mcp/deps/embla-carousel-wheel-gestures.js.map +1 -0
- package/template/node_modules/.vite-mcp/deps/magic-string.es-Cklsmr-5.js +1013 -0
- package/template/node_modules/.vite-mcp/deps/magic-string.es-Cklsmr-5.js.map +1 -0
- package/template/node_modules/.vite-mcp/deps/mapbox-gl.js +46311 -0
- package/template/node_modules/.vite-mcp/deps/mapbox-gl.js.map +1 -0
- package/template/node_modules/.vite-mcp/deps/package.json +3 -0
- package/template/node_modules/.vite-mcp/deps/protocol-CTflwIfG.js +2090 -0
- package/template/node_modules/.vite-mcp/deps/protocol-CTflwIfG.js.map +1 -0
- package/template/node_modules/.vite-mcp/deps/react-dom.js +186 -0
- package/template/node_modules/.vite-mcp/deps/react-dom.js.map +1 -0
- package/template/node_modules/.vite-mcp/deps/react-dom_client.js +2 -0
- package/template/node_modules/.vite-mcp/deps/react.js +769 -0
- package/template/node_modules/.vite-mcp/deps/react.js.map +1 -0
- package/template/node_modules/.vite-mcp/deps/react_jsx-dev-runtime.js +205 -0
- package/template/node_modules/.vite-mcp/deps/react_jsx-dev-runtime.js.map +1 -0
- package/template/node_modules/.vite-mcp/deps/react_jsx-runtime.js +209 -0
- package/template/node_modules/.vite-mcp/deps/react_jsx-runtime.js.map +1 -0
- package/template/node_modules/.vite-mcp/deps/schemas-NsgmY9QV.js +12157 -0
- package/template/node_modules/.vite-mcp/deps/schemas-NsgmY9QV.js.map +1 -0
- package/template/node_modules/.vite-mcp/deps/tailwind-merge.js +2025 -0
- package/template/node_modules/.vite-mcp/deps/tailwind-merge.js.map +1 -0
- package/template/node_modules/.vite-mcp/deps/vitest.js +14021 -0
- package/template/node_modules/.vite-mcp/deps/vitest.js.map +1 -0
- package/template/node_modules/.vite-mcp/deps/zod.js +624 -0
- package/template/node_modules/.vite-mcp/deps/zod.js.map +1 -0
- package/template/src/tools/review-diff.test.ts +5 -1
- package/template/src/tools/review-diff.ts +1 -1
- package/template/src/tools/review-post.test.ts +5 -1
- package/template/src/tools/review-post.ts +1 -1
- package/template/src/tools/review-purchase.test.ts +5 -1
- package/template/src/tools/review-purchase.ts +1 -1
- package/template/src/tools/review.test.ts +5 -1
- package/template/src/tools/review.ts +1 -1
- package/template/src/tools/show-albums.test.ts +5 -1
- package/template/src/tools/show-albums.ts +1 -1
- package/template/src/tools/show-carousel.test.ts +5 -1
- package/template/src/tools/show-carousel.ts +1 -1
- package/template/src/tools/show-map.test.ts +5 -1
- package/template/src/tools/show-map.ts +1 -1
- package/template/tests/e2e/map.spec.ts +4 -2
- package/dist/discovery-BxKCIgG5.cjs +0 -332
- package/dist/discovery-BxKCIgG5.cjs.map +0 -1
- package/dist/discovery-Du4LHrih.js +0 -261
- package/dist/discovery-Du4LHrih.js.map +0 -1
- package/dist/simulator-BYIH-xqQ.cjs.map +0 -1
- package/dist/simulator-CmgNnWBO.js.map +0 -1
- package/dist/simulator-url-BDGD4vZD.cjs.map +0 -1
- package/dist/simulator-url-Bkxj43yT.js.map +0 -1
- package/template/.sunpeak/dev.tsx +0 -79
- package/template/.sunpeak/resource-loader.html +0 -20
- package/template/.sunpeak/resource-loader.tsx +0 -57
- package/template/index.html +0 -14
- package/template/src/resources/index.ts +0 -17
|
@@ -173,21 +173,15 @@ function Conversation({ children, screenWidth, displayMode, platform, onRequestD
|
|
|
173
173
|
style: { maxWidth: containerWidth },
|
|
174
174
|
children: [
|
|
175
175
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
176
|
-
className: "z-
|
|
177
|
-
style: {
|
|
178
|
-
borderColor: "var(--color-border-primary)",
|
|
179
|
-
backgroundColor: "var(--sim-bg-conversation, var(--color-background-primary))"
|
|
180
|
-
},
|
|
176
|
+
className: "z-20 flex h-[3.25rem] items-center justify-between p-2 pointer-events-auto",
|
|
177
|
+
style: { backgroundColor: "var(--sim-bg-conversation, var(--color-background-primary))" },
|
|
181
178
|
children: [
|
|
182
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
type: "button",
|
|
189
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CloseIcon$1, {})
|
|
190
|
-
})
|
|
179
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
180
|
+
onClick: handleClose,
|
|
181
|
+
"aria-label": "Close",
|
|
182
|
+
className: "h-7 w-7 flex items-center justify-center rounded-lg transition-colors hover:opacity-70",
|
|
183
|
+
type: "button",
|
|
184
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CloseIcon$1, {})
|
|
191
185
|
}),
|
|
192
186
|
isDesktop && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
193
187
|
className: "flex items-center justify-center text-base",
|
|
@@ -204,8 +198,7 @@ function Conversation({ children, screenWidth, displayMode, platform, onRequestD
|
|
|
204
198
|
style: {
|
|
205
199
|
maskImage: "linear-gradient(to bottom, transparent 0%, black 50%)",
|
|
206
200
|
WebkitMaskImage: "linear-gradient(to bottom, transparent 0%, black 50%)",
|
|
207
|
-
|
|
208
|
-
WebkitBackdropFilter: "blur(16px)"
|
|
201
|
+
backgroundColor: "var(--sim-bg-conversation, var(--color-background-primary))"
|
|
209
202
|
}
|
|
210
203
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
211
204
|
className: "max-w-[40rem] min-[1440px]:max-w-[48rem] mx-auto px-4 pt-4 pb-4 pointer-events-auto",
|
|
@@ -216,11 +209,12 @@ function Conversation({ children, screenWidth, displayMode, platform, onRequestD
|
|
|
216
209
|
name: "userInput",
|
|
217
210
|
disabled: true,
|
|
218
211
|
placeholder: "Message sunpeak.ai",
|
|
219
|
-
className: "w-full rounded-
|
|
212
|
+
className: "w-full rounded-[28px] p-2.5 shadow-sm",
|
|
220
213
|
style: {
|
|
221
214
|
backgroundColor: "var(--sim-bg-reply-input, var(--color-background-secondary))",
|
|
222
215
|
color: "var(--color-text-primary)",
|
|
223
|
-
border: "
|
|
216
|
+
border: "none",
|
|
217
|
+
cornerShape: "superellipse"
|
|
224
218
|
}
|
|
225
219
|
})
|
|
226
220
|
})
|
|
@@ -261,8 +255,11 @@ function Conversation({ children, screenWidth, displayMode, platform, onRequestD
|
|
|
261
255
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
262
256
|
className: "flex w-full flex-col gap-1 empty:hidden items-end",
|
|
263
257
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
264
|
-
className: "relative rounded-[
|
|
265
|
-
style: {
|
|
258
|
+
className: "relative rounded-[22px] px-4 py-2.5 leading-6 max-w-[70%]",
|
|
259
|
+
style: {
|
|
260
|
+
backgroundColor: "var(--sim-bg-user-bubble, var(--color-background-tertiary))",
|
|
261
|
+
cornerShape: "superellipse"
|
|
262
|
+
},
|
|
266
263
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
267
264
|
className: "whitespace-pre-wrap",
|
|
268
265
|
children: userMessage
|
|
@@ -313,17 +310,17 @@ function Conversation({ children, screenWidth, displayMode, platform, onRequestD
|
|
|
313
310
|
ref: setContentRef,
|
|
314
311
|
className: isPip ? "no-scrollbar @w-xl/main:top-4 fixed start-4 end-4 top-12 z-50 mx-auto max-w-[40rem] lg:max-w-[48rem] sm:start-0 sm:end-0 sm:top-[3.25rem] sm:w-full overflow-visible" : isFullscreen ? "no-scrollbar fixed inset-x-0 top-[3.25rem] bottom-0 z-50 mx-auto" : "no-scrollbar relative mb-2 @w-sm/main:w-full mx-0 max-sm:-mx-[1rem] max-sm:w-[100cqw] max-sm:overflow-hidden overflow-visible",
|
|
315
312
|
style: {
|
|
316
|
-
...isPip ? { maxHeight: "
|
|
313
|
+
...isPip ? { maxHeight: "calc(50dvh - 38px)" } : {},
|
|
317
314
|
...isFullscreen ? { maxWidth: containerWidth } : {}
|
|
318
315
|
},
|
|
319
316
|
children: [isPip && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
320
317
|
onClick: handleClose,
|
|
321
|
-
className: "absolute -start-2 -top-1.5 z-10 rounded-full bg-[#3a3a3a] p-1.
|
|
318
|
+
className: "absolute -start-2 md:-start-6 -top-1.5 z-10 rounded-full bg-[#3a3a3a] p-1.25 text-white shadow-[0px_0px_0px_1px_var(--color-border-primary),0px_4px_12px_rgba(0,0,0,0.12)] hover:bg-[#6a6a6a]",
|
|
322
319
|
"aria-label": "Close picture-in-picture",
|
|
323
320
|
type: "button",
|
|
324
321
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CloseIcon$1, { className: "h-4 w-4" })
|
|
325
322
|
}, "pip-close"), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
326
|
-
className: isPip ? "relative overflow-hidden h-full rounded-2xl sm:rounded-3xl shadow-[
|
|
323
|
+
className: isPip ? "relative overflow-hidden h-full rounded-2xl sm:rounded-3xl shadow-[0px_0px_0px_1px_var(--color-border-primary),0px_6px_20px_rgba(0,0,0,0.1)] md:-mx-4" : "relative overflow-hidden h-full",
|
|
327
324
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
328
325
|
className: "h-full w-full max-w-full",
|
|
329
326
|
style: { ...isPip ? {
|
|
@@ -350,8 +347,7 @@ function Conversation({ children, screenWidth, displayMode, platform, onRequestD
|
|
|
350
347
|
style: {
|
|
351
348
|
maskImage: "linear-gradient(to bottom, transparent 0%, black 50%)",
|
|
352
349
|
WebkitMaskImage: "linear-gradient(to bottom, transparent 0%, black 50%)",
|
|
353
|
-
|
|
354
|
-
WebkitBackdropFilter: "blur(16px)"
|
|
350
|
+
backgroundColor: "var(--sim-bg-conversation, var(--color-background-primary))"
|
|
355
351
|
}
|
|
356
352
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
357
353
|
className: "max-w-[40rem] min-[1440px]:max-w-[48rem] mx-auto px-4 pt-4 pb-4 pointer-events-auto",
|
|
@@ -418,7 +414,7 @@ registerHostShell({
|
|
|
418
414
|
"--sim-bg-sidebar": "light-dark(#ffffff, #212121)",
|
|
419
415
|
"--sim-bg-conversation": "light-dark(#ffffff, #212121)",
|
|
420
416
|
"--sim-bg-user-bubble": "light-dark(rgba(233,233,233,0.5), rgba(50,50,50,0.85))",
|
|
421
|
-
"--sim-bg-reply-input": "light-dark(#ffffff, #
|
|
417
|
+
"--sim-bg-reply-input": "light-dark(#ffffff, #303030)"
|
|
422
418
|
}
|
|
423
419
|
});
|
|
424
420
|
//#endregion
|
|
@@ -2305,10 +2301,13 @@ function useSimulatorState({ simulations, defaultHost = "chatgpt" }) {
|
|
|
2305
2301
|
height: typeof window !== "undefined" ? window.innerHeight - 52 : 800,
|
|
2306
2302
|
width: measuredContentWidth ?? (typeof window !== "undefined" ? window.innerWidth : 1280)
|
|
2307
2303
|
};
|
|
2308
|
-
if (displayMode === "pip")
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2304
|
+
if (displayMode === "pip") {
|
|
2305
|
+
const viewportH = typeof window !== "undefined" ? window.innerHeight : 800;
|
|
2306
|
+
return {
|
|
2307
|
+
maxHeight: Math.round(viewportH * .5 - 38),
|
|
2308
|
+
...measuredContentWidth != null ? { maxWidth: measuredContentWidth } : {}
|
|
2309
|
+
};
|
|
2310
|
+
}
|
|
2312
2311
|
if (measuredContentWidth != null) return { maxWidth: measuredContentWidth };
|
|
2313
2312
|
}, [
|
|
2314
2313
|
containerHeight,
|
|
@@ -2493,6 +2492,69 @@ function useSimulatorState({ simulations, defaultHost = "chatgpt" }) {
|
|
|
2493
2492
|
};
|
|
2494
2493
|
}
|
|
2495
2494
|
//#endregion
|
|
2495
|
+
//#region src/simulator/use-mcp-connection.ts
|
|
2496
|
+
/**
|
|
2497
|
+
* Hook for managing MCP server connection status via the dev server proxy.
|
|
2498
|
+
*
|
|
2499
|
+
* On mount (when `serverUrl` is provided), verifies the connection is alive
|
|
2500
|
+
* by fetching `/__sunpeak/list-tools`. Tracks connection status for display
|
|
2501
|
+
* in the sidebar (colored dot indicator).
|
|
2502
|
+
*
|
|
2503
|
+
* Tool calling is handled separately via the `onCallTool` prop — this
|
|
2504
|
+
* hook only manages the connection lifecycle and status display.
|
|
2505
|
+
*/
|
|
2506
|
+
function useMcpConnection(serverUrl) {
|
|
2507
|
+
const [status, setStatus] = (0, react.useState)(serverUrl ? "connecting" : "disconnected");
|
|
2508
|
+
const [error, setError] = (0, react.useState)();
|
|
2509
|
+
const reconnect = (0, react.useCallback)(async (url) => {
|
|
2510
|
+
setStatus("connecting");
|
|
2511
|
+
setError(void 0);
|
|
2512
|
+
try {
|
|
2513
|
+
const res = await fetch("/__sunpeak/connect", {
|
|
2514
|
+
method: "POST",
|
|
2515
|
+
headers: { "Content-Type": "application/json" },
|
|
2516
|
+
body: JSON.stringify({ url })
|
|
2517
|
+
});
|
|
2518
|
+
if (!res.ok) {
|
|
2519
|
+
const text = await res.text();
|
|
2520
|
+
throw new Error(text || `Connection failed (${res.status})`);
|
|
2521
|
+
}
|
|
2522
|
+
setStatus("connected");
|
|
2523
|
+
} catch (err) {
|
|
2524
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
2525
|
+
setStatus("error");
|
|
2526
|
+
}
|
|
2527
|
+
}, []);
|
|
2528
|
+
(0, react.useEffect)(() => {
|
|
2529
|
+
if (!serverUrl) {
|
|
2530
|
+
setStatus("disconnected");
|
|
2531
|
+
return;
|
|
2532
|
+
}
|
|
2533
|
+
let cancelled = false;
|
|
2534
|
+
(async () => {
|
|
2535
|
+
setStatus("connecting");
|
|
2536
|
+
try {
|
|
2537
|
+
const res = await fetch("/__sunpeak/list-tools");
|
|
2538
|
+
if (cancelled) return;
|
|
2539
|
+
if (!res.ok) throw new Error(`Health check failed (${res.status})`);
|
|
2540
|
+
setStatus("connected");
|
|
2541
|
+
} catch (err) {
|
|
2542
|
+
if (cancelled) return;
|
|
2543
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
2544
|
+
setStatus("error");
|
|
2545
|
+
}
|
|
2546
|
+
})();
|
|
2547
|
+
return () => {
|
|
2548
|
+
cancelled = true;
|
|
2549
|
+
};
|
|
2550
|
+
}, [serverUrl]);
|
|
2551
|
+
return {
|
|
2552
|
+
status,
|
|
2553
|
+
error,
|
|
2554
|
+
reconnect
|
|
2555
|
+
};
|
|
2556
|
+
}
|
|
2557
|
+
//#endregion
|
|
2496
2558
|
//#region src/simulator/theme-provider.tsx
|
|
2497
2559
|
var ThemeProviderContext = react.createContext(void 0);
|
|
2498
2560
|
/** Default theme applier: sets data-theme attribute on document.documentElement */
|
|
@@ -2524,7 +2586,7 @@ var useThemeContext = () => {
|
|
|
2524
2586
|
};
|
|
2525
2587
|
//#endregion
|
|
2526
2588
|
//#region src/simulator/simple-sidebar.tsx
|
|
2527
|
-
var DEFAULT_SIDEBAR_WIDTH =
|
|
2589
|
+
var DEFAULT_SIDEBAR_WIDTH = 260;
|
|
2528
2590
|
function ChevronRightIcon() {
|
|
2529
2591
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
|
|
2530
2592
|
width: "1em",
|
|
@@ -2698,9 +2760,10 @@ function HelpIcon({ tooltip, docsPath }) {
|
|
|
2698
2760
|
})]
|
|
2699
2761
|
});
|
|
2700
2762
|
}
|
|
2701
|
-
function SidebarControl({ label, children, tooltip, docsPath }) {
|
|
2763
|
+
function SidebarControl({ label, children, tooltip, docsPath, "data-testid": testId }) {
|
|
2702
2764
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2703
2765
|
className: "space-y-1",
|
|
2766
|
+
"data-testid": testId,
|
|
2704
2767
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2705
2768
|
className: "text-[10px] font-medium leading-tight inline-flex items-center gap-1",
|
|
2706
2769
|
style: { color: "var(--color-text-secondary)" },
|
|
@@ -2711,10 +2774,11 @@ function SidebarControl({ label, children, tooltip, docsPath }) {
|
|
|
2711
2774
|
}), children]
|
|
2712
2775
|
});
|
|
2713
2776
|
}
|
|
2714
|
-
function SidebarCollapsibleControl({ label, children, defaultCollapsed = true, tooltip, docsPath }) {
|
|
2777
|
+
function SidebarCollapsibleControl({ label, children, defaultCollapsed = true, tooltip, docsPath, "data-testid": testId }) {
|
|
2715
2778
|
const [isCollapsed, setIsCollapsed] = react.useState(defaultCollapsed);
|
|
2716
2779
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2717
2780
|
className: "space-y-1",
|
|
2781
|
+
"data-testid": testId,
|
|
2718
2782
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
2719
2783
|
onClick: () => setIsCollapsed(!isCollapsed),
|
|
2720
2784
|
className: "w-full flex items-center justify-between text-[10px] font-medium leading-tight transition-colors py-1 cursor-pointer",
|
|
@@ -2817,7 +2881,7 @@ function SidebarCheckbox({ checked, onChange, label, tooltip, docsPath }) {
|
|
|
2817
2881
|
})]
|
|
2818
2882
|
});
|
|
2819
2883
|
}
|
|
2820
|
-
function SidebarTextarea({ value, onChange, onFocus, onBlur, placeholder, maxRows = 8, error }) {
|
|
2884
|
+
function SidebarTextarea({ value, onChange, onFocus, onBlur, placeholder, maxRows = 8, error, "data-testid": testId }) {
|
|
2821
2885
|
const contentRows = value?.split("\n").length ?? 1;
|
|
2822
2886
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2823
2887
|
className: "space-y-0.5",
|
|
@@ -2828,6 +2892,7 @@ function SidebarTextarea({ value, onChange, onFocus, onBlur, placeholder, maxRow
|
|
|
2828
2892
|
onBlur,
|
|
2829
2893
|
placeholder,
|
|
2830
2894
|
rows: Math.min(contentRows, maxRows),
|
|
2895
|
+
"data-testid": testId,
|
|
2831
2896
|
className: "w-full text-[10px] font-mono rounded-md px-2 py-1.5 outline-none resize-y",
|
|
2832
2897
|
style: {
|
|
2833
2898
|
...formElementStyle,
|
|
@@ -2884,20 +2949,26 @@ function resolveServerToolResult(mock, args) {
|
|
|
2884
2949
|
}
|
|
2885
2950
|
//#endregion
|
|
2886
2951
|
//#region src/simulator/simulator.tsx
|
|
2887
|
-
function Simulator({ children, simulations = {}, appName = "Sunpeak", appIcon, defaultHost = "chatgpt", onCallTool, defaultProdTools = false, defaultProdResources = false, hideSimulatorModes = false, sandboxUrl }) {
|
|
2952
|
+
function Simulator({ children, simulations = {}, appName = "Sunpeak", appIcon, defaultHost = "chatgpt", onCallTool, onCallToolDirect, defaultProdTools = false, defaultProdResources = false, hideSimulatorModes = false, sandboxUrl, mcpServerUrl }) {
|
|
2953
|
+
const isInspectMode = mcpServerUrl != null;
|
|
2888
2954
|
const state = useSimulatorState({
|
|
2889
2955
|
simulations,
|
|
2890
2956
|
defaultHost
|
|
2891
2957
|
});
|
|
2892
|
-
const
|
|
2958
|
+
const connection = useMcpConnection(mcpServerUrl);
|
|
2959
|
+
const [prodTools, setProdTools] = react.useState(isInspectMode ? true : state.urlProdTools ?? defaultProdTools);
|
|
2893
2960
|
const [prodResources, setProdResources] = react.useState(state.urlProdResources ?? defaultProdResources);
|
|
2894
2961
|
const [isRunning, setIsRunning] = react.useState(false);
|
|
2895
2962
|
const [hasRun, setHasRun] = react.useState(false);
|
|
2896
2963
|
const [showCheck, setShowCheck] = react.useState(false);
|
|
2897
2964
|
const checkTimerRef = react.useRef(void 0);
|
|
2898
2965
|
react.useEffect(() => {
|
|
2899
|
-
if (prodTools)
|
|
2900
|
-
|
|
2966
|
+
if (prodTools) {
|
|
2967
|
+
setHasRun(false);
|
|
2968
|
+
state.setToolResult(void 0);
|
|
2969
|
+
state.setToolResultJson("");
|
|
2970
|
+
state.setToolResultError("");
|
|
2971
|
+
} else {
|
|
2901
2972
|
const simResult = state.selectedSim?.toolResult ?? void 0;
|
|
2902
2973
|
state.setToolResult(simResult);
|
|
2903
2974
|
}
|
|
@@ -2920,11 +2991,12 @@ function Simulator({ children, simulations = {}, appName = "Sunpeak", appIcon, d
|
|
|
2920
2991
|
simulations
|
|
2921
2992
|
]);
|
|
2922
2993
|
const handleRun = react.useCallback(async () => {
|
|
2923
|
-
|
|
2994
|
+
const caller = onCallToolDirect ?? onCallTool;
|
|
2995
|
+
if (!caller || !state.selectedSim) return;
|
|
2924
2996
|
const toolName = state.selectedSim.tool.name;
|
|
2925
2997
|
setIsRunning(true);
|
|
2926
2998
|
try {
|
|
2927
|
-
const result = await
|
|
2999
|
+
const result = (isInspectMode ? state.selectedSim.toolResult : void 0) ?? await caller({
|
|
2928
3000
|
name: toolName,
|
|
2929
3001
|
arguments: state.toolInput
|
|
2930
3002
|
});
|
|
@@ -2954,7 +3026,12 @@ function Simulator({ children, simulations = {}, appName = "Sunpeak", appIcon, d
|
|
|
2954
3026
|
} finally {
|
|
2955
3027
|
setIsRunning(false);
|
|
2956
3028
|
}
|
|
2957
|
-
}, [
|
|
3029
|
+
}, [
|
|
3030
|
+
onCallTool,
|
|
3031
|
+
onCallToolDirect,
|
|
3032
|
+
state,
|
|
3033
|
+
isInspectMode
|
|
3034
|
+
]);
|
|
2958
3035
|
const activeShell = getHostShell(state.activeHost);
|
|
2959
3036
|
const registeredHosts = getRegisteredHosts();
|
|
2960
3037
|
const ShellConversation = activeShell?.Conversation;
|
|
@@ -2987,18 +3064,21 @@ function Simulator({ children, simulations = {}, appName = "Sunpeak", appIcon, d
|
|
|
2987
3064
|
} else prevPageStyleKeysRef.current = [];
|
|
2988
3065
|
}, [activeShell]);
|
|
2989
3066
|
const handleCallTool = react.useCallback((params) => {
|
|
2990
|
-
if (
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
3067
|
+
if (!prodTools) {
|
|
3068
|
+
const mock = state.selectedSim?.serverTools?.[params.name];
|
|
3069
|
+
if (mock) {
|
|
3070
|
+
const result = resolveServerToolResult(mock, params.arguments);
|
|
3071
|
+
if (result) return result;
|
|
3072
|
+
}
|
|
2995
3073
|
}
|
|
3074
|
+
if (onCallTool) return onCallTool(params);
|
|
2996
3075
|
return { content: [{
|
|
2997
3076
|
type: "text",
|
|
2998
3077
|
text: `[Simulator] Tool "${params.name}" called — no serverTools mock found in simulation "${state.selectedSimulationName}".`
|
|
2999
3078
|
}] };
|
|
3000
3079
|
}, [
|
|
3001
3080
|
onCallTool,
|
|
3081
|
+
prodTools,
|
|
3002
3082
|
state.selectedSim,
|
|
3003
3083
|
state.selectedSimulationName
|
|
3004
3084
|
]);
|
|
@@ -3126,14 +3206,33 @@ function Simulator({ children, simulations = {}, appName = "Sunpeak", appIcon, d
|
|
|
3126
3206
|
controls: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3127
3207
|
className: "space-y-1",
|
|
3128
3208
|
children: [
|
|
3129
|
-
|
|
3209
|
+
isInspectMode && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SidebarControl, {
|
|
3210
|
+
label: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
3211
|
+
className: "flex items-center gap-1.5",
|
|
3212
|
+
children: ["MCP Server", /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3213
|
+
className: "inline-block w-2 h-2 rounded-full",
|
|
3214
|
+
"data-testid": "inspect-connection-status",
|
|
3215
|
+
style: { backgroundColor: connection.status === "connected" ? "#22c55e" : connection.status === "connecting" ? "#eab308" : connection.status === "error" ? "#ef4444" : "#6b7280" },
|
|
3216
|
+
title: connection.error ?? connection.status
|
|
3217
|
+
})]
|
|
3218
|
+
}),
|
|
3219
|
+
tooltip: "MCP server URL (set via --server flag)",
|
|
3220
|
+
"data-testid": "inspect-server-url",
|
|
3221
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SidebarInput, {
|
|
3222
|
+
value: mcpServerUrl ?? "",
|
|
3223
|
+
onChange: () => {},
|
|
3224
|
+
disabled: true,
|
|
3225
|
+
placeholder: "http://localhost:8000/mcp"
|
|
3226
|
+
})
|
|
3227
|
+
}),
|
|
3228
|
+
!isInspectMode && !hideSimulatorModes && onCallTool && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SidebarCheckbox, {
|
|
3130
3229
|
checked: prodTools,
|
|
3131
3230
|
onChange: setProdTools,
|
|
3132
3231
|
label: "Prod Tools",
|
|
3133
3232
|
tooltip: "Use real tool handlers instead of simulations",
|
|
3134
3233
|
docsPath: "api-reference/cli/dev#prod-tools-and-prod-resources-flags"
|
|
3135
3234
|
}),
|
|
3136
|
-
!hideSimulatorModes && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SidebarCheckbox, {
|
|
3235
|
+
!isInspectMode && !hideSimulatorModes && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SidebarCheckbox, {
|
|
3137
3236
|
checked: prodResources,
|
|
3138
3237
|
onChange: setProdResources,
|
|
3139
3238
|
label: "Prod Resources",
|
|
@@ -3503,13 +3602,15 @@ function Simulator({ children, simulations = {}, appName = "Sunpeak", appIcon, d
|
|
|
3503
3602
|
maxRows: 8
|
|
3504
3603
|
})
|
|
3505
3604
|
}, `tool-input-${prodTools}`),
|
|
3506
|
-
|
|
3605
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SidebarCollapsibleControl, {
|
|
3507
3606
|
label: "Tool Result (JSON)",
|
|
3508
|
-
defaultCollapsed:
|
|
3607
|
+
defaultCollapsed: prodTools,
|
|
3509
3608
|
tooltip: "Structured content returned by the tool",
|
|
3510
3609
|
docsPath: "api-reference/hooks/use-tool-data",
|
|
3610
|
+
"data-testid": "tool-result-section",
|
|
3511
3611
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SidebarTextarea, {
|
|
3512
3612
|
value: state.toolResultJson,
|
|
3613
|
+
"data-testid": "tool-result-textarea",
|
|
3513
3614
|
onChange: (json) => state.validateJSON(json, state.setToolResultJson, state.setToolResultError),
|
|
3514
3615
|
onFocus: () => state.setEditingField("toolResult"),
|
|
3515
3616
|
onBlur: () => state.commitJSON(state.toolResultJson, state.setToolResultError, (parsed) => {
|
|
@@ -3526,7 +3627,7 @@ function Simulator({ children, simulations = {}, appName = "Sunpeak", appIcon, d
|
|
|
3526
3627
|
error: state.toolResultError,
|
|
3527
3628
|
maxRows: 8
|
|
3528
3629
|
})
|
|
3529
|
-
})
|
|
3630
|
+
}, `tool-result-${prodTools}`)
|
|
3530
3631
|
]
|
|
3531
3632
|
}),
|
|
3532
3633
|
children: ShellConversation ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ShellConversation, {
|
|
@@ -3685,6 +3786,12 @@ Object.defineProperty(exports, "resolveServerToolResult", {
|
|
|
3685
3786
|
return resolveServerToolResult;
|
|
3686
3787
|
}
|
|
3687
3788
|
});
|
|
3789
|
+
Object.defineProperty(exports, "useMcpConnection", {
|
|
3790
|
+
enumerable: true,
|
|
3791
|
+
get: function() {
|
|
3792
|
+
return useMcpConnection;
|
|
3793
|
+
}
|
|
3794
|
+
});
|
|
3688
3795
|
Object.defineProperty(exports, "useSimulatorState", {
|
|
3689
3796
|
enumerable: true,
|
|
3690
3797
|
get: function() {
|
|
@@ -3698,4 +3805,4 @@ Object.defineProperty(exports, "useThemeContext", {
|
|
|
3698
3805
|
}
|
|
3699
3806
|
});
|
|
3700
3807
|
|
|
3701
|
-
//# sourceMappingURL=simulator-
|
|
3808
|
+
//# sourceMappingURL=simulator-CH9hs0N6.cjs.map
|