sunpeak 0.15.4 → 0.16.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.
Files changed (98) hide show
  1. package/README.md +51 -48
  2. package/bin/commands/build.mjs +13 -4
  3. package/bin/commands/dev.mjs +64 -19
  4. package/bin/commands/new.mjs +13 -3
  5. package/bin/lib/extract-resource.mjs +1 -1
  6. package/bin/lib/extract-tool.mjs +78 -0
  7. package/bin/lib/patterns.mjs +2 -26
  8. package/dist/chatgpt/index.cjs +3 -6
  9. package/dist/chatgpt/index.cjs.map +1 -1
  10. package/dist/chatgpt/index.d.ts +1 -1
  11. package/dist/chatgpt/index.js +6 -9
  12. package/dist/claude/index.cjs +1 -1
  13. package/dist/claude/index.js +1 -1
  14. package/dist/discovery-CH80W5l9.js +217 -0
  15. package/dist/discovery-CH80W5l9.js.map +1 -0
  16. package/dist/discovery-DmB8_4QL.cjs +216 -0
  17. package/dist/discovery-DmB8_4QL.cjs.map +1 -0
  18. package/dist/{index-CutQgPzR.js → index-BjnAsaqp.js} +3 -6
  19. package/dist/index-BjnAsaqp.js.map +1 -0
  20. package/dist/{index-Cngntkp2.cjs → index-BvQ_ZuOO.cjs} +3 -6
  21. package/dist/{index-Cngntkp2.cjs.map → index-BvQ_ZuOO.cjs.map} +1 -1
  22. package/dist/{index-B0dxRJvS.cjs → index-C9CVbGFt.cjs} +3 -6
  23. package/dist/index-C9CVbGFt.cjs.map +1 -0
  24. package/dist/{index-Ce_5ZIdJ.js → index-CTGEqlgk.js} +3 -6
  25. package/dist/{index-Ce_5ZIdJ.js.map → index-CTGEqlgk.js.map} +1 -1
  26. package/dist/index.cjs +48 -5
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.ts +3 -0
  29. package/dist/index.js +3404 -3361
  30. package/dist/index.js.map +1 -1
  31. package/dist/lib/discovery-cli.cjs +58 -5
  32. package/dist/lib/discovery-cli.cjs.map +1 -1
  33. package/dist/lib/discovery-cli.d.ts +3 -2
  34. package/dist/lib/discovery-cli.js +61 -8
  35. package/dist/lib/discovery-cli.js.map +1 -1
  36. package/dist/lib/discovery.d.ts +42 -43
  37. package/dist/lib/extract-tool.d.ts +12 -0
  38. package/dist/mcp/favicon.d.ts +1 -1
  39. package/dist/mcp/index.cjs +3 -2
  40. package/dist/mcp/index.cjs.map +1 -1
  41. package/dist/mcp/index.d.ts +1 -1
  42. package/dist/mcp/index.js +3 -2
  43. package/dist/mcp/index.js.map +1 -1
  44. package/dist/mcp/types.d.ts +24 -1
  45. package/dist/platform/chatgpt/index.cjs +1 -1
  46. package/dist/platform/chatgpt/index.js +1 -1
  47. package/dist/simulator/index.cjs +2 -5
  48. package/dist/simulator/index.cjs.map +1 -1
  49. package/dist/simulator/index.d.ts +1 -1
  50. package/dist/simulator/index.js +5 -8
  51. package/dist/simulator/simulator-url.d.ts +9 -9
  52. package/dist/{simulator-DcfQBRXE.cjs → simulator-B56j5P8W.cjs} +8 -2
  53. package/dist/{simulator-DcfQBRXE.cjs.map → simulator-B56j5P8W.cjs.map} +1 -1
  54. package/dist/{simulator-CxrtnguM.js → simulator-C0H_k092.js} +8 -2
  55. package/dist/{simulator-CxrtnguM.js.map → simulator-C0H_k092.js.map} +1 -1
  56. package/dist/simulator-url-CuLqtnSS.js.map +1 -1
  57. package/dist/simulator-url-rgg_KYOg.cjs.map +1 -1
  58. package/dist/types/resource-config.d.ts +7 -5
  59. package/dist/{use-app-D_TeaMFG.js → use-app-BThbgFFT.js} +51 -22
  60. package/dist/{use-app-D_TeaMFG.js.map → use-app-BThbgFFT.js.map} +1 -1
  61. package/dist/{use-app-BnoSPiUT.cjs → use-app-BuufpXTQ.cjs} +49 -20
  62. package/dist/{use-app-BnoSPiUT.cjs.map → use-app-BuufpXTQ.cjs.map} +1 -1
  63. package/package.json +1 -1
  64. package/template/.sunpeak/dev.tsx +8 -4
  65. package/template/.sunpeak/resource-loader.tsx +2 -1
  66. package/template/README.md +14 -10
  67. package/template/package.json +2 -1
  68. package/template/src/resources/albums/{albums-resource.test.tsx → albums.test.tsx} +1 -1
  69. package/template/src/resources/albums/{albums-resource.tsx → albums.tsx} +0 -1
  70. package/template/src/resources/carousel/{carousel-resource.test.tsx → carousel.test.tsx} +1 -1
  71. package/template/src/resources/carousel/{carousel-resource.tsx → carousel.tsx} +0 -1
  72. package/template/src/resources/index.ts +4 -4
  73. package/template/src/resources/map/{map-resource.test.tsx → map.test.tsx} +1 -1
  74. package/template/src/resources/map/{map-resource.tsx → map.tsx} +0 -1
  75. package/template/src/resources/review/{review-resource.test.tsx → review.test.tsx} +1 -1
  76. package/template/src/resources/review/{review-resource.tsx → review.tsx} +1 -2
  77. package/template/src/server.ts +15 -0
  78. package/template/src/tools/review-diff.ts +24 -0
  79. package/template/src/tools/review-post.ts +26 -0
  80. package/template/src/tools/review-purchase.ts +31 -0
  81. package/template/src/tools/show-albums.ts +22 -0
  82. package/template/src/tools/show-carousel.ts +25 -0
  83. package/template/src/tools/show-map.ts +29 -0
  84. package/template/tests/e2e/albums.spec.ts +6 -6
  85. package/template/tests/e2e/carousel.spec.ts +6 -6
  86. package/template/tests/e2e/map.spec.ts +11 -11
  87. package/template/tests/simulations/{review/review-diff-simulation.json → review-diff.json} +1 -31
  88. package/template/tests/simulations/{review/review-post-simulation.json → review-post.json} +1 -37
  89. package/template/tests/simulations/{review/review-purchase-simulation.json → review-purchase.json} +1 -38
  90. package/template/tests/simulations/{albums/albums-show-simulation.json → show-albums.json} +1 -24
  91. package/template/tests/simulations/{carousel/carousel-show-simulation.json → show-carousel.json} +1 -24
  92. package/template/tests/simulations/{map/map-show-simulation.json → show-map.json} +1 -35
  93. package/dist/discovery-CRR3SlyI.cjs +0 -156
  94. package/dist/discovery-CRR3SlyI.cjs.map +0 -1
  95. package/dist/discovery-DzV3HLXs.js +0 -157
  96. package/dist/discovery-DzV3HLXs.js.map +0 -1
  97. package/dist/index-B0dxRJvS.cjs.map +0 -1
  98. package/dist/index-CutQgPzR.js.map +0 -1
@@ -1,4 +1,27 @@
1
- import { Resource, Tool } from '@modelcontextprotocol/sdk/types.js';
1
+ import { Resource, Tool, ServerRequest, ServerNotification } from '@modelcontextprotocol/sdk/types.js';
2
+ import { RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';
3
+ import { ToolConfig } from '@modelcontextprotocol/ext-apps/server';
4
+ export type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
5
+ export type { AuthInfo } from '@modelcontextprotocol/sdk/server/auth/types.js';
6
+ /**
7
+ * Extra context passed to tool handlers as the second argument.
8
+ *
9
+ * This is a pre-applied alias for the MCP SDK's `RequestHandlerExtra` —
10
+ * no custom fields, just ergonomic generics so users don't need to parameterize it.
11
+ *
12
+ * Key fields: `authInfo`, `sessionId`, `signal`, `_meta`.
13
+ */
14
+ export type ToolHandlerExtra = RequestHandlerExtra<ServerRequest, ServerNotification>;
15
+ /**
16
+ * Configuration for a Sunpeak tool file's `tool` export.
17
+ *
18
+ * Extends the ext-apps `ToolConfig` with a `resource` field that links
19
+ * the tool to a resource by its unique name string.
20
+ */
21
+ export interface AppToolConfig extends ToolConfig {
22
+ /** The resource name (must match a directory in `src/resources/`, e.g. `'albums'`). */
23
+ resource: string;
24
+ }
2
25
  /**
3
26
  * Simulation configuration for MCP server.
4
27
  * Must include distPath for the built HTML file.
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const React = require("react");
4
- const useApp = require("../../use-app-BnoSPiUT.cjs");
4
+ const useApp = require("../../use-app-BuufpXTQ.cjs");
5
5
  function getOpenAIRuntime() {
6
6
  if (typeof window !== "undefined" && "openai" in window) {
7
7
  return window.openai;
@@ -1,5 +1,5 @@
1
1
  import { useCallback } from "react";
2
- import { u as useApp } from "../../use-app-D_TeaMFG.js";
2
+ import { u as useApp } from "../../use-app-BThbgFFT.js";
3
3
  function getOpenAIRuntime() {
4
4
  if (typeof window !== "undefined" && "openai" in window) {
5
5
  return window.openai;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const simulator = require("../simulator-DcfQBRXE.cjs");
3
+ const simulator = require("../simulator-B56j5P8W.cjs");
4
4
  const simulatorUrl = require("../simulator-url-rgg_KYOg.cjs");
5
- const discovery = require("../discovery-CRR3SlyI.cjs");
5
+ const discovery = require("../discovery-DmB8_4QL.cjs");
6
6
  exports.IframeResource = simulator.IframeResource;
7
7
  exports.McpAppHost = simulator.McpAppHost;
8
8
  exports.SCREEN_WIDTHS = simulator.SCREEN_WIDTHS;
@@ -29,11 +29,8 @@ exports.buildSimulations = discovery.buildSimulations;
29
29
  exports.createResourceExports = discovery.createResourceExports;
30
30
  exports.extractResourceKey = discovery.extractResourceKey;
31
31
  exports.extractSimulationKey = discovery.extractSimulationKey;
32
- exports.extractSimulationName = discovery.extractSimulationName;
33
32
  exports.findResourceDirs = discovery.findResourceDirs;
34
33
  exports.findResourceKey = discovery.findResourceKey;
35
- exports.findSimulationFiles = discovery.findSimulationFiles;
36
34
  exports.getComponentName = discovery.getComponentName;
37
- exports.isSimulationFile = discovery.isSimulationFile;
38
35
  exports.toPascalCase = discovery.toPascalCase;
39
36
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -14,5 +14,5 @@ export { SCREEN_WIDTHS } from './simulator-types';
14
14
  export { createSimulatorUrl } from './simulator-url';
15
15
  export type { SimulatorUrlParams } from './simulator-url';
16
16
  export { SimpleSidebar, SidebarControl, SidebarCollapsibleControl, SidebarSelect, SidebarInput, SidebarCheckbox, SidebarTextarea, SidebarToggle, } from './simple-sidebar';
17
- export { buildDevSimulations, buildSimulations, buildResourceMap, createResourceExports, toPascalCase, extractResourceKey, extractSimulationKey, findResourceKey, getComponentName, findResourceDirs, isSimulationFile, extractSimulationName, findSimulationFiles, } from '../lib/discovery';
17
+ export { buildDevSimulations, buildSimulations, buildResourceMap, createResourceExports, toPascalCase, extractResourceKey, extractSimulationKey, findResourceKey, getComponentName, findResourceDirs, } from '../lib/discovery';
18
18
  export type { BuildSimulationsOptions, BuildDevSimulationsOptions, ResourceMetadata, ResourceDirInfo, FsOps, } from '../lib/discovery';
@@ -1,6 +1,6 @@
1
- import { I, M, a, b, c, d, e, f, g, h, i, S, T, j, k, l, r, u, m } from "../simulator-CxrtnguM.js";
1
+ import { I, M, a, b, c, d, e, f, g, h, i, S, T, j, k, l, r, u, m } from "../simulator-C0H_k092.js";
2
2
  import { c as c2 } from "../simulator-url-CuLqtnSS.js";
3
- import { b as b2, a as a2, c as c3, d as d2, e as e2, f as f2, g as g2, h as h2, i as i2, j as j2, k as k2, l as l2, t } from "../discovery-DzV3HLXs.js";
3
+ import { b as b2, a as a2, c as c3, d as d2, e as e2, f as f2, g as g2, h as h2, i as i2, t } from "../discovery-CH80W5l9.js";
4
4
  export {
5
5
  I as IframeResource,
6
6
  M as McpAppHost,
@@ -23,14 +23,11 @@ export {
23
23
  j as extractResourceCSP,
24
24
  e2 as extractResourceKey,
25
25
  f2 as extractSimulationKey,
26
- g2 as extractSimulationName,
27
- h2 as findResourceDirs,
28
- i2 as findResourceKey,
29
- j2 as findSimulationFiles,
30
- k2 as getComponentName,
26
+ g2 as findResourceDirs,
27
+ h2 as findResourceKey,
28
+ i2 as getComponentName,
31
29
  k as getHostShell,
32
30
  l as getRegisteredHosts,
33
- l2 as isSimulationFile,
34
31
  r as registerHostShell,
35
32
  t as toPascalCase,
36
33
  u as useSimulatorState,
@@ -10,7 +10,7 @@ import { Theme, DisplayMode, DeviceType } from '../types/runtime';
10
10
  *
11
11
  * // In e2e tests:
12
12
  * await page.goto(createSimulatorUrl({
13
- * simulation: 'albums-show',
13
+ * simulation: 'show-albums',
14
14
  * theme: 'dark',
15
15
  * displayMode: 'fullscreen',
16
16
  * host: 'claude',
@@ -19,8 +19,8 @@ import { Theme, DisplayMode, DeviceType } from '../types/runtime';
19
19
  */
20
20
  export interface SimulatorUrlParams {
21
21
  /**
22
- * The simulation name to load (e.g., 'albums-show', 'review-diff').
23
- * Corresponds to the simulation JSON filename without the '-simulation.json' suffix.
22
+ * The simulation name to load (e.g., 'show-albums', 'review-diff').
23
+ * Corresponds to the simulation JSON filename without the `.json` extension.
24
24
  */
25
25
  simulation?: string;
26
26
  /**
@@ -96,8 +96,8 @@ export interface SimulatorUrlParams {
96
96
  * @example
97
97
  * ```ts
98
98
  * // Basic usage
99
- * createSimulatorUrl({ simulation: 'albums-show', theme: 'light' })
100
- * // Returns: '/?simulation=albums-show&theme=light'
99
+ * createSimulatorUrl({ simulation: 'show-albums', theme: 'light' })
100
+ * // Returns: '/?simulation=show-albums&theme=light'
101
101
  *
102
102
  * // With display mode
103
103
  * createSimulatorUrl({
@@ -109,20 +109,20 @@ export interface SimulatorUrlParams {
109
109
  *
110
110
  * // With device simulation
111
111
  * createSimulatorUrl({
112
- * simulation: 'map-show',
112
+ * simulation: 'show-map',
113
113
  * deviceType: 'mobile',
114
114
  * touch: true,
115
115
  * hover: false,
116
116
  * })
117
- * // Returns: '/?simulation=map-show&deviceType=mobile&touch=true&hover=false'
117
+ * // Returns: '/?simulation=show-map&deviceType=mobile&touch=true&hover=false'
118
118
  *
119
119
  * // With safe area insets (for notch simulation)
120
120
  * createSimulatorUrl({
121
- * simulation: 'carousel-show',
121
+ * simulation: 'show-carousel',
122
122
  * safeAreaTop: 44,
123
123
  * safeAreaBottom: 34,
124
124
  * })
125
- * // Returns: '/?simulation=carousel-show&safeAreaTop=44&safeAreaBottom=34'
125
+ * // Returns: '/?simulation=show-carousel&safeAreaTop=44&safeAreaBottom=34'
126
126
  * ```
127
127
  */
128
128
  export declare function createSimulatorUrl(params: SimulatorUrlParams, basePath?: string): string;
@@ -7771,7 +7771,13 @@ function useSimulatorState({
7771
7771
  simulations,
7772
7772
  defaultHost = "chatgpt"
7773
7773
  }) {
7774
- const simulationNames = Object.keys(simulations);
7774
+ const simulationNames = Object.keys(simulations).sort((a2, b) => {
7775
+ const simA = simulations[a2];
7776
+ const simB = simulations[b];
7777
+ const labelA = `${simA.resource.title || simA.resource.name}: ${simA.tool.title || simA.tool.name}`;
7778
+ const labelB = `${simB.resource.title || simB.resource.name}: ${simB.tool.title || simB.tool.name}`;
7779
+ return labelA.localeCompare(labelB);
7780
+ });
7775
7781
  const urlParams = React.useMemo(() => parseUrlParams(), []);
7776
7782
  const [screenWidth, setScreenWidth] = React.useState("full");
7777
7783
  const isMobileWidth = (width) => width === "mobile-s" || width === "mobile-l";
@@ -8776,4 +8782,4 @@ exports.getRegisteredHosts = getRegisteredHosts;
8776
8782
  exports.registerHostShell = registerHostShell;
8777
8783
  exports.useSimulatorState = useSimulatorState;
8778
8784
  exports.useThemeContext = useThemeContext;
8779
- //# sourceMappingURL=simulator-DcfQBRXE.cjs.map
8785
+ //# sourceMappingURL=simulator-B56j5P8W.cjs.map