sunpeak 0.8.6 → 0.9.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 (77) hide show
  1. package/bin/commands/build.mjs +3 -3
  2. package/bin/commands/pull.mjs +2 -2
  3. package/bin/sunpeak.js +8 -6
  4. package/dist/chatgpt/chatgpt-simulator.d.ts +1 -2
  5. package/dist/chatgpt/index.cjs +9 -0
  6. package/dist/chatgpt/index.cjs.map +1 -0
  7. package/dist/chatgpt/index.d.ts +3 -1
  8. package/dist/chatgpt/index.js +9 -0
  9. package/dist/chatgpt/index.js.map +1 -0
  10. package/dist/chatgpt/simulator-url.d.ts +127 -0
  11. package/dist/index.cjs +39 -8448
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.js +58 -8466
  14. package/dist/index.js.map +1 -1
  15. package/dist/mcp/entry.cjs +2 -1
  16. package/dist/mcp/entry.cjs.map +1 -1
  17. package/dist/mcp/entry.js +2 -1
  18. package/dist/mcp/entry.js.map +1 -1
  19. package/dist/mcp/index.cjs +1 -1
  20. package/dist/mcp/index.d.ts +1 -1
  21. package/dist/mcp/index.js +1 -1
  22. package/dist/mcp/server.d.ts +1 -1
  23. package/dist/mcp/types.d.ts +3 -9
  24. package/dist/{server-DVmTC-SF.js → server-310A1k9o.js} +2 -2
  25. package/dist/{server-DVmTC-SF.js.map → server-310A1k9o.js.map} +1 -1
  26. package/dist/{server-B9YgCQdS.cjs → server-CSybLAYo.cjs} +2 -2
  27. package/dist/{server-B9YgCQdS.cjs.map → server-CSybLAYo.cjs.map} +1 -1
  28. package/dist/simulator-url-CG8lAAC3.cjs +8545 -0
  29. package/dist/simulator-url-CG8lAAC3.cjs.map +1 -0
  30. package/dist/simulator-url-CexnaL-e.js +8529 -0
  31. package/dist/simulator-url-CexnaL-e.js.map +1 -0
  32. package/dist/style.css +5872 -5894
  33. package/dist/types/simulation.d.ts +6 -32
  34. package/package.json +7 -3
  35. package/template/.sunpeak/dev.tsx +8 -7
  36. package/template/README.md +5 -5
  37. package/template/dist/albums.js +1 -1
  38. package/template/dist/albums.json +1 -1
  39. package/template/dist/carousel.js +1 -1
  40. package/template/dist/carousel.json +1 -1
  41. package/template/dist/map.js +1 -1
  42. package/template/dist/map.json +1 -1
  43. package/template/dist/review.js +2 -2
  44. package/template/dist/review.json +1 -1
  45. package/template/node_modules/.bin/playwright +21 -0
  46. package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_components_Button.js +3 -3
  47. package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_components_SegmentedControl.js +4 -4
  48. package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_components_Select.js +20 -20
  49. package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_components_Textarea.js +3 -3
  50. package/template/node_modules/.vite/deps/_metadata.json +38 -38
  51. package/template/node_modules/.vite/deps/{chunk-SPYXUHEY.js → chunk-N6DVYEXK.js} +8 -8
  52. package/template/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -1
  53. package/template/package.json +3 -1
  54. package/template/playwright.config.ts +26 -0
  55. package/template/src/resources/index.ts +4 -4
  56. package/template/src/resources/map-resource.test.tsx +95 -0
  57. package/template/src/resources/review-resource.test.tsx +538 -0
  58. package/template/src/resources/review-resource.tsx +6 -1
  59. package/template/src/simulations/albums-show-simulation.json +1 -1
  60. package/template/src/simulations/carousel-show-simulation.json +1 -1
  61. package/template/src/simulations/map-show-simulation.json +1 -1
  62. package/template/src/simulations/review-diff-simulation.json +1 -1
  63. package/template/src/simulations/review-post-simulation.json +1 -1
  64. package/template/src/simulations/review-purchase-simulation.json +1 -1
  65. package/template/test-results/.last-run.json +4 -0
  66. package/template/tests/e2e/albums.spec.ts +120 -0
  67. package/template/tests/e2e/carousel.spec.ts +127 -0
  68. package/template/tests/e2e/map.spec.ts +188 -0
  69. package/template/tests/e2e/review.spec.ts +245 -0
  70. package/template/vitest.config.ts +1 -0
  71. package/template/dist/counter.js +0 -49
  72. package/template/dist/counter.json +0 -15
  73. package/template/src/resources/counter-resource.json +0 -12
  74. package/template/src/resources/counter-resource.test.tsx +0 -116
  75. package/template/src/resources/counter-resource.tsx +0 -101
  76. package/template/src/simulations/counter-show-simulation.json +0 -20
  77. /package/template/node_modules/.vite/deps/{chunk-SPYXUHEY.js.map → chunk-N6DVYEXK.js.map} +0 -0
@@ -1,47 +1,21 @@
1
- import { Tool, Resource } from '@modelcontextprotocol/sdk/types.js';
2
- import { Theme, DisplayMode, UserAgent, SafeArea, View } from './index';
1
+ import { Tool, Resource, CallToolRequestParams, CallToolResult } from '@modelcontextprotocol/sdk/types.js';
3
2
  /**
4
3
  * Core simulation types for development and testing.
5
4
  * These types define how simulations are configured and used in both
6
5
  * the dev simulator and MCP server contexts.
7
6
  */
8
7
  import type * as React from 'react';
9
- /**
10
- * Simulation globals that configure the simulator environment.
11
- * These values are passed to the mock runtime to set initial values for development/testing.
12
- * All fields are optional as simulations can use defaults.
13
- * Globals initialized based on tool responses are instead set in SimulationCallToolResult:
14
- * (structuredContent > toolOutput, _meta > toolResponseMetadata)
15
- */
16
- export interface SimulationGlobals {
17
- theme?: Theme;
18
- userAgent?: UserAgent;
19
- locale?: string;
20
- maxHeight?: number;
21
- displayMode?: DisplayMode;
22
- safeArea?: SafeArea;
23
- view?: View | null;
24
- toolInput?: Record<string, unknown>;
25
- widgetState?: Record<string, unknown> | null;
26
- }
27
- /**
28
- * MCP CallTool response data (subset used in simulations).
29
- * Note: toolOutput (structuredContent) and toolResponseMetadata (_meta)
30
- * are set here for use by the MCP server as well, not in SimulationGlobals.
31
- */
32
- export interface SimulationCallToolResult {
33
- structuredContent?: Record<string, unknown> | null;
34
- _meta?: Record<string, unknown>;
35
- }
36
8
  /**
37
9
  * A simulation packages a component with its example data and metadata.
38
10
  * Each simulation represents a complete tool experience in the simulator.
39
11
  */
40
12
  export interface Simulation {
13
+ name: string;
41
14
  resourceComponent: React.ComponentType;
42
15
  userMessage?: string;
43
- simulationGlobals?: SimulationGlobals;
44
16
  tool: Tool;
45
- resource?: Resource;
46
- toolCall?: SimulationCallToolResult;
17
+ resource: Resource;
18
+ callToolResult?: CallToolResult;
19
+ callToolRequestParams?: CallToolRequestParams;
20
+ widgetState?: Record<string, unknown> | null;
47
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sunpeak",
3
- "version": "0.8.6",
3
+ "version": "0.9.1",
4
4
  "description": "The ChatGPT App framework. Quickstart, build, & test your ChatGPT App locally!",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -17,6 +17,12 @@
17
17
  "default": "./dist/index.cjs"
18
18
  }
19
19
  },
20
+ "./chatgpt": {
21
+ "import": {
22
+ "types": "./dist/chatgpt/index.d.ts",
23
+ "default": "./dist/chatgpt/index.js"
24
+ }
25
+ },
20
26
  "./style.css": "./dist/style.css",
21
27
  "./chatgpt/globals.css": "./dist/chatgpt/globals.css",
22
28
  "./mcp": {
@@ -68,7 +74,6 @@
68
74
  "zod": "^3.25.76"
69
75
  },
70
76
  "devDependencies": {
71
- "@playwright/test": "^1.57.0",
72
77
  "@tailwindcss/vite": "^4.1.18",
73
78
  "@testing-library/jest-dom": "^6.9.1",
74
79
  "@testing-library/react": "^16.3.1",
@@ -110,7 +115,6 @@
110
115
  "lint": "eslint . --ext .ts,.tsx --fix",
111
116
  "typecheck": "tsc --noEmit",
112
117
  "test": "vitest run",
113
- "test:e2e": "playwright test",
114
118
  "validate": "node scripts/validate.mjs"
115
119
  }
116
120
  }
@@ -23,7 +23,7 @@ const resourceModules = import.meta.glob('../src/resources/*-resource.json', { e
23
23
  type ResourceData = { name: string; [key: string]: unknown };
24
24
  const resourcesMap = new Map<string, ResourceData>();
25
25
  for (const [path, module] of Object.entries(resourceModules)) {
26
- // Extract key from path: '../src/resources/counter-resource.json' -> 'counter'
26
+ // Extract key from path: '../src/resources/review-resource.json' -> 'review'
27
27
  const match = path.match(/\/([^/]+)-resource\.json$/);
28
28
  const key = match?.[1];
29
29
  if (key) {
@@ -52,7 +52,7 @@ function findResourceKey(simulationKey: string): string | undefined {
52
52
 
53
53
  /**
54
54
  * Convert resource name to component name
55
- * Example: 'carousel' -> 'CarouselResource', 'counter' -> 'CounterResource'
55
+ * Example: 'carousel' -> 'CarouselResource', 'review' -> 'ReviewResource'
56
56
  */
57
57
  function getResourceComponent(name: string): React.ComponentType {
58
58
  const pascalName = name.charAt(0).toUpperCase() + name.slice(1);
@@ -70,9 +70,9 @@ function getResourceComponent(name: string): React.ComponentType {
70
70
  return component;
71
71
  }
72
72
 
73
- // Build simulations array from discovered files
74
- type SimulationData = Omit<Simulation, 'resourceComponent' | 'resource'>;
75
- const simulations: Simulation[] = [];
73
+ // Build simulations object from discovered files
74
+ type SimulationData = Omit<Simulation, 'name' | 'resourceComponent' | 'resource'>;
75
+ const simulations: Record<string, Simulation> = {};
76
76
 
77
77
  for (const [path, module] of Object.entries(simulationModules)) {
78
78
  // Extract simulation key from path: '../src/simulations/albums-show-simulation.json' -> 'albums-show'
@@ -94,11 +94,12 @@ for (const [path, module] of Object.entries(simulationModules)) {
94
94
 
95
95
  const resource = resourcesMap.get(resourceKey)!;
96
96
 
97
- simulations.push({
97
+ simulations[simulationKey] = {
98
98
  ...simulation,
99
+ name: simulationKey,
99
100
  resource,
100
101
  resourceComponent: getResourceComponent(resource.name),
101
- });
102
+ };
102
103
  }
103
104
 
104
105
  // Read app config from environment or use defaults
@@ -30,8 +30,8 @@ The template includes a minimal test setup with Vitest. You can add additional t
30
30
 
31
31
  - `src/resources/` - Resource files must be here
32
32
  - `src/simulations/` - Simulation files must be here
33
- - Resource file naming: `*-resource.tsx` (e.g., `counter-resource.tsx`)
34
- - Simulation file naming: `*-simulation.tsx` (e.g., `counter-simulation.tsx`)
33
+ - Resource file naming: `*-resource.tsx` (e.g., `review-resource.tsx`)
34
+ - Simulation file naming: `*-simulation.json` (e.g., `review-purchase-simulation.json`)
35
35
  - `src/index-resource.tsx` - Build template (must have `// RESOURCE_IMPORT` and `// RESOURCE_MOUNT` comments)
36
36
 
37
37
  **You can customize:**
@@ -71,7 +71,7 @@ ngrok http 6766
71
71
 
72
72
  You can then connect to the tunnel forwarding URL at the `/mcp` path from ChatGPT **in developer mode** to see your UI in action: `User > Settings > Apps & Connectors > Create`
73
73
 
74
- Once your app is connected, send the name of the app and a tool, like `/sunpeak show counter`, to ChatGPT.
74
+ Once your app is connected, send the name of the app and a tool, like `/sunpeak show review`, to ChatGPT.
75
75
 
76
76
  When you make changes to the UI, refresh your app in ChatGPT after the MCP server has finished rebuilding your app: `User > Settings > Apps & Connectors > My App > Refresh`
77
77
 
@@ -87,8 +87,8 @@ This creates optimized builds in `dist/`:
87
87
 
88
88
  - `dist/albums.js`
89
89
  - `dist/albums.json`
90
- - `dist/counter.js`
91
- - `dist/counter.json`
90
+ - `dist/review.js`
91
+ - `dist/review.json`
92
92
  - _(One .js file per resource in src/resources/)_
93
93
  - _(One .json file per resource in src/resources/)_
94
94