sunpeak 0.18.6 → 0.18.7

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.
Files changed (49) hide show
  1. package/bin/commands/dev.mjs +6 -2
  2. package/bin/commands/inspect.mjs +13 -1
  3. package/bin/commands/new.mjs +5 -0
  4. package/bin/lib/dev-overlay.mjs +50 -0
  5. package/bin/lib/live/live-config.d.mts +3 -0
  6. package/bin/lib/live/live-config.mjs +3 -1
  7. package/dist/chatgpt/index.cjs +2 -2
  8. package/dist/chatgpt/index.js +2 -2
  9. package/dist/claude/index.cjs +1 -1
  10. package/dist/claude/index.js +1 -1
  11. package/dist/index.cjs +1 -1
  12. package/dist/index.js +1 -1
  13. package/dist/inspector/index.cjs +2 -2
  14. package/dist/inspector/index.js +2 -2
  15. package/dist/inspector/inspector-url.d.ts +13 -0
  16. package/dist/inspector/use-inspector-state.d.ts +2 -0
  17. package/dist/{inspector-DRD_Q66E.cjs → inspector-CKc58UuI.cjs} +60 -19
  18. package/dist/inspector-CKc58UuI.cjs.map +1 -0
  19. package/dist/{inspector-CjSoXm6N.js → inspector-DZrN0kej.js} +60 -19
  20. package/dist/inspector-DZrN0kej.js.map +1 -0
  21. package/dist/{inspector-url-7qhtJwY6.cjs → inspector-url-C3LTKgXt.cjs} +3 -1
  22. package/dist/inspector-url-C3LTKgXt.cjs.map +1 -0
  23. package/dist/{inspector-url-DuEFmxLP.js → inspector-url-CyQcuBI9.js} +3 -1
  24. package/dist/inspector-url-CyQcuBI9.js.map +1 -0
  25. package/dist/mcp/index.cjs +81 -7
  26. package/dist/mcp/index.cjs.map +1 -1
  27. package/dist/mcp/index.js +81 -7
  28. package/dist/mcp/index.js.map +1 -1
  29. package/dist/style.css +4 -0
  30. package/package.json +1 -1
  31. package/template/dist/albums/albums.html +1 -1
  32. package/template/dist/albums/albums.json +1 -1
  33. package/template/dist/carousel/carousel.html +1 -1
  34. package/template/dist/carousel/carousel.json +1 -1
  35. package/template/dist/map/map.html +1 -1
  36. package/template/dist/map/map.json +1 -1
  37. package/template/dist/review/review.html +1 -1
  38. package/template/dist/review/review.json +1 -1
  39. package/template/tests/e2e/albums.spec.ts +1 -1
  40. package/template/tests/e2e/carousel.spec.ts +1 -1
  41. package/template/tests/e2e/dev-overlay.spec.ts +118 -0
  42. package/template/tests/e2e/helpers.ts +13 -0
  43. package/template/tests/e2e/map.spec.ts +1 -1
  44. package/template/tests/e2e/review.spec.ts +1 -1
  45. package/template/tests/live/playwright.config.ts +1 -1
  46. package/dist/inspector-CjSoXm6N.js.map +0 -1
  47. package/dist/inspector-DRD_Q66E.cjs.map +0 -1
  48. package/dist/inspector-url-7qhtJwY6.cjs.map +0 -1
  49. 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
@@ -3195,6 +3203,8 @@ function Inspector({ children, simulations: initialSimulations = {}, appName = "
3195
3203
  const [oauthError, setOauthError] = React.useState();
3196
3204
  const connection = useMcpConnection(mcpServerUrl || void 0);
3197
3205
  const [prodResources, setProdResources] = React.useState(state.urlProdResources ?? defaultProdResources);
3206
+ const showSidebar = state.urlSidebar !== false;
3207
+ const showDevOverlay = state.urlDevOverlay !== false;
3198
3208
  const [isRunning, setIsRunning] = React.useState(false);
3199
3209
  const [hasRun, setHasRun] = React.useState(false);
3200
3210
  const [showCheck, setShowCheck] = React.useState(false);
@@ -3365,26 +3375,47 @@ function Inspector({ children, simulations: initialSimulations = {}, appName = "
3365
3375
  if (!caller || !sim) return;
3366
3376
  const toolName = sim.tool.name;
3367
3377
  setIsRunning(true);
3378
+ const startTime = performance.now();
3368
3379
  try {
3369
3380
  const result = await caller({
3370
3381
  name: toolName,
3371
3382
  arguments: state.toolInput
3372
3383
  });
3373
- state.setToolResult(result);
3374
- state.setToolResultJson(JSON.stringify(result, null, 2));
3384
+ const clientMs = Math.round((performance.now() - startTime) * 10) / 10;
3385
+ const resultMeta = result?._meta;
3386
+ const serverMs = (resultMeta?._sunpeak)?.requestTimeMs;
3387
+ const durationMs = typeof serverMs === "number" ? serverMs : clientMs;
3388
+ const resultWithTiming = {
3389
+ ...result,
3390
+ _meta: {
3391
+ ...resultMeta,
3392
+ _sunpeak: { requestTimeMs: durationMs }
3393
+ }
3394
+ };
3395
+ state.setToolResult(resultWithTiming);
3396
+ const displayResult = resultMeta?._sunpeak ? (() => {
3397
+ const { _sunpeak: _, ...cleanMeta } = resultMeta;
3398
+ const clean = { ...result };
3399
+ clean._meta = Object.keys(cleanMeta).length > 0 ? cleanMeta : void 0;
3400
+ if (clean._meta === void 0) delete clean._meta;
3401
+ return clean;
3402
+ })() : result;
3403
+ state.setToolResultJson(JSON.stringify(displayResult, null, 2));
3375
3404
  state.setToolResultError("");
3376
3405
  setHasRun(true);
3377
3406
  setShowCheck(true);
3378
3407
  clearTimeout(checkTimerRef.current);
3379
3408
  checkTimerRef.current = setTimeout(() => setShowCheck(false), 2e3);
3380
3409
  } catch (err) {
3410
+ const durationMs = Math.round((performance.now() - startTime) * 10) / 10;
3381
3411
  const message = err instanceof Error ? err.message : String(err);
3382
3412
  state.setToolResult({
3383
3413
  content: [{
3384
3414
  type: "text",
3385
3415
  text: `Error: ${message}`
3386
3416
  }],
3387
- isError: true
3417
+ isError: true,
3418
+ _meta: { _sunpeak: { requestTimeMs: durationMs } }
3388
3419
  });
3389
3420
  state.setToolResultJson(JSON.stringify({
3390
3421
  content: [{
@@ -3519,7 +3550,8 @@ function Inspector({ children, simulations: initialSimulations = {}, appName = "
3519
3550
  clearTimeout(timer);
3520
3551
  };
3521
3552
  }, [prodResourcesPath]);
3522
- const effectiveResourceUrl = (prodResourcesPath && prodResourcesReady ? prodResourcesPath : void 0) ?? state.resourceUrl;
3553
+ const baseResourceUrl = (prodResourcesPath && prodResourcesReady ? prodResourcesPath : void 0) ?? state.resourceUrl;
3554
+ const effectiveResourceUrl = baseResourceUrl && !showDevOverlay ? `${baseResourceUrl}${baseResourceUrl.includes("?") ? "&" : "?"}devOverlay=false` : baseResourceUrl;
3523
3555
  const prodResourcesLoading = !!prodResourcesPath && !prodResourcesReady;
3524
3556
  const hasTools = toolNames.length > 0;
3525
3557
  const showEmptyState = !(activeSimulationName !== null && currentSim?.toolResult != null) && !hasRun;
@@ -3637,6 +3669,26 @@ function Inspector({ children, simulations: initialSimulations = {}, appName = "
3637
3669
  children: /* @__PURE__ */ jsx("path", { d: "M0 0L10 6L0 12V0Z" })
3638
3670
  }), "Run"]
3639
3671
  }) : void 0;
3672
+ const conversationContent = ShellConversation ? /* @__PURE__ */ jsx(ShellConversation, {
3673
+ screenWidth: state.screenWidth,
3674
+ displayMode: state.displayMode,
3675
+ platform: state.platform,
3676
+ onRequestDisplayMode: state.handleDisplayModeChange,
3677
+ appName,
3678
+ appIcon,
3679
+ userMessage,
3680
+ onContentWidthChange: state.handleContentWidthChange,
3681
+ headerAction: runButton,
3682
+ children: content
3683
+ }) : content;
3684
+ if (!showSidebar) return /* @__PURE__ */ jsx(ThemeProvider, {
3685
+ theme: state.theme,
3686
+ applyTheme,
3687
+ children: /* @__PURE__ */ jsx("div", {
3688
+ className: "flex h-screen w-screen",
3689
+ children: conversationContent
3690
+ })
3691
+ });
3640
3692
  return /* @__PURE__ */ jsx(ThemeProvider, {
3641
3693
  theme: state.theme,
3642
3694
  applyTheme,
@@ -4169,22 +4221,11 @@ function Inspector({ children, simulations: initialSimulations = {}, appName = "
4169
4221
  })
4170
4222
  ]
4171
4223
  }),
4172
- children: ShellConversation ? /* @__PURE__ */ jsx(ShellConversation, {
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
4224
+ children: conversationContent
4184
4225
  })
4185
4226
  });
4186
4227
  }
4187
4228
  //#endregion
4188
4229
  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
4230
 
4190
- //# sourceMappingURL=inspector-CjSoXm6N.js.map
4231
+ //# sourceMappingURL=inspector-DZrN0kej.js.map