skybridge 0.0.0-dev.a8e5d27 → 0.0.0-dev.aa087ad

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 (148) hide show
  1. package/LICENSE +21 -674
  2. package/README.md +74 -147
  3. package/dist/src/server/devtoolsStaticServer.d.ts +15 -0
  4. package/dist/src/server/devtoolsStaticServer.js +38 -0
  5. package/dist/src/server/devtoolsStaticServer.js.map +1 -0
  6. package/dist/src/server/index.d.ts +3 -0
  7. package/dist/src/server/index.js +1 -0
  8. package/dist/src/server/index.js.map +1 -1
  9. package/dist/src/server/inferUtilityTypes.d.ts +64 -0
  10. package/dist/src/server/inferUtilityTypes.js +2 -0
  11. package/dist/src/server/inferUtilityTypes.js.map +1 -0
  12. package/dist/src/server/server.d.ts +70 -9
  13. package/dist/src/server/server.js +55 -30
  14. package/dist/src/server/server.js.map +1 -1
  15. package/dist/src/server/templateHelper.d.ts +3 -0
  16. package/dist/src/server/templateHelper.js +5 -4
  17. package/dist/src/server/templateHelper.js.map +1 -1
  18. package/dist/src/server/templates/development.hbs +3 -2
  19. package/dist/src/server/templates/production.hbs +1 -0
  20. package/dist/src/server/widgetsDevServer.js +3 -3
  21. package/dist/src/server/widgetsDevServer.js.map +1 -1
  22. package/dist/src/test/utils.d.ts +108 -1
  23. package/dist/src/test/utils.js +202 -3
  24. package/dist/src/test/utils.js.map +1 -1
  25. package/dist/src/test/widget.test.js +83 -27
  26. package/dist/src/test/widget.test.js.map +1 -1
  27. package/dist/src/web/bridges/constants.d.ts +2 -0
  28. package/dist/src/web/bridges/constants.js +3 -0
  29. package/dist/src/web/bridges/constants.js.map +1 -0
  30. package/dist/src/web/bridges/index.d.ts +2 -0
  31. package/dist/src/web/bridges/index.js +3 -0
  32. package/dist/src/web/bridges/index.js.map +1 -0
  33. package/dist/src/web/bridges/use-apps-sdk-bridge.d.ts +7 -0
  34. package/dist/src/web/bridges/use-apps-sdk-bridge.js +39 -0
  35. package/dist/src/web/bridges/use-apps-sdk-bridge.js.map +1 -0
  36. package/dist/src/web/bridges/use-mcp-app-bridge.d.ts +25 -0
  37. package/dist/src/web/bridges/use-mcp-app-bridge.js +128 -0
  38. package/dist/src/web/bridges/use-mcp-app-bridge.js.map +1 -0
  39. package/dist/src/web/bridges/use-mcp-app-bridge.test.d.ts +1 -0
  40. package/dist/src/web/bridges/use-mcp-app-bridge.test.js +65 -0
  41. package/dist/src/web/bridges/use-mcp-app-bridge.test.js.map +1 -0
  42. package/dist/src/web/create-store.d.ts +3 -0
  43. package/dist/src/web/create-store.js +25 -0
  44. package/dist/src/web/create-store.js.map +1 -0
  45. package/dist/src/web/create-store.test.d.ts +1 -0
  46. package/dist/src/web/create-store.test.js +70 -0
  47. package/dist/src/web/create-store.test.js.map +1 -0
  48. package/dist/src/web/data-llm.d.ts +14 -0
  49. package/dist/src/web/data-llm.js +68 -0
  50. package/dist/src/web/data-llm.js.map +1 -0
  51. package/dist/src/web/data-llm.test.d.ts +1 -0
  52. package/dist/src/web/data-llm.test.js +76 -0
  53. package/dist/src/web/data-llm.test.js.map +1 -0
  54. package/dist/src/web/generate-helpers.d.ts +115 -0
  55. package/dist/src/web/generate-helpers.js +111 -0
  56. package/dist/src/web/generate-helpers.js.map +1 -0
  57. package/dist/src/web/generate-helpers.test-d.d.ts +1 -0
  58. package/dist/src/web/generate-helpers.test-d.js +206 -0
  59. package/dist/src/web/generate-helpers.test-d.js.map +1 -0
  60. package/dist/src/web/generate-helpers.test.d.ts +1 -0
  61. package/dist/src/web/generate-helpers.test.js +17 -0
  62. package/dist/src/web/generate-helpers.test.js.map +1 -0
  63. package/dist/src/web/helpers/state.d.ts +7 -0
  64. package/dist/src/web/helpers/state.js +40 -0
  65. package/dist/src/web/helpers/state.js.map +1 -0
  66. package/dist/src/web/helpers/state.test.d.ts +1 -0
  67. package/dist/src/web/helpers/state.test.js +53 -0
  68. package/dist/src/web/helpers/state.test.js.map +1 -0
  69. package/dist/src/web/hooks/index.d.ts +2 -4
  70. package/dist/src/web/hooks/index.js +2 -4
  71. package/dist/src/web/hooks/index.js.map +1 -1
  72. package/dist/src/web/hooks/use-call-tool.d.ts +58 -20
  73. package/dist/src/web/hooks/use-call-tool.js +7 -15
  74. package/dist/src/web/hooks/use-call-tool.js.map +1 -1
  75. package/dist/src/web/hooks/use-call-tool.test-d.d.ts +1 -0
  76. package/dist/src/web/hooks/use-call-tool.test-d.js +104 -0
  77. package/dist/src/web/hooks/use-call-tool.test-d.js.map +1 -0
  78. package/dist/src/web/hooks/use-call-tool.test.js +14 -12
  79. package/dist/src/web/hooks/use-call-tool.test.js.map +1 -1
  80. package/dist/src/web/hooks/use-display-mode.d.ts +1 -1
  81. package/dist/src/web/hooks/use-display-mode.js +5 -2
  82. package/dist/src/web/hooks/use-display-mode.js.map +1 -1
  83. package/dist/src/web/hooks/use-display-mode.test.js +3 -2
  84. package/dist/src/web/hooks/use-display-mode.test.js.map +1 -1
  85. package/dist/src/web/hooks/use-files.test.js +1 -1
  86. package/dist/src/web/hooks/use-files.test.js.map +1 -1
  87. package/dist/src/web/hooks/use-locale.d.ts +1 -1
  88. package/dist/src/web/hooks/use-locale.js +7 -2
  89. package/dist/src/web/hooks/use-locale.js.map +1 -1
  90. package/dist/src/web/hooks/use-locale.test.js +3 -2
  91. package/dist/src/web/hooks/use-locale.test.js.map +1 -1
  92. package/dist/src/web/hooks/use-open-external.test.js +2 -2
  93. package/dist/src/web/hooks/use-open-external.test.js.map +1 -1
  94. package/dist/src/web/hooks/use-openai-global.d.ts +3 -2
  95. package/dist/src/web/hooks/use-openai-global.js +3 -20
  96. package/dist/src/web/hooks/use-openai-global.js.map +1 -1
  97. package/dist/src/web/hooks/use-request-modal.test.js +2 -2
  98. package/dist/src/web/hooks/use-request-modal.test.js.map +1 -1
  99. package/dist/src/web/hooks/use-theme.d.ts +1 -1
  100. package/dist/src/web/hooks/use-theme.js +7 -2
  101. package/dist/src/web/hooks/use-theme.js.map +1 -1
  102. package/dist/src/web/hooks/use-theme.test.js +3 -2
  103. package/dist/src/web/hooks/use-theme.test.js.map +1 -1
  104. package/dist/src/web/hooks/use-tool-info.d.ts +4 -4
  105. package/dist/src/web/hooks/use-tool-info.js +5 -7
  106. package/dist/src/web/hooks/use-tool-info.js.map +1 -1
  107. package/dist/src/web/hooks/use-tool-info.test-d.js +0 -1
  108. package/dist/src/web/hooks/use-tool-info.test-d.js.map +1 -1
  109. package/dist/src/web/hooks/use-tool-info.test.js +3 -2
  110. package/dist/src/web/hooks/use-tool-info.test.js.map +1 -1
  111. package/dist/src/web/hooks/use-user-agent.d.ts +1 -1
  112. package/dist/src/web/hooks/use-user-agent.js +2 -2
  113. package/dist/src/web/hooks/use-user-agent.js.map +1 -1
  114. package/dist/src/web/hooks/use-user-agent.test.js +3 -2
  115. package/dist/src/web/hooks/use-user-agent.test.js.map +1 -1
  116. package/dist/src/web/hooks/use-widget-state.js +11 -9
  117. package/dist/src/web/hooks/use-widget-state.js.map +1 -1
  118. package/dist/src/web/hooks/use-widget-state.test.js +3 -2
  119. package/dist/src/web/hooks/use-widget-state.test.js.map +1 -1
  120. package/dist/src/web/index.d.ts +7 -3
  121. package/dist/src/web/index.js +7 -3
  122. package/dist/src/web/index.js.map +1 -1
  123. package/dist/src/web/plugin/data-llm.test.d.ts +1 -0
  124. package/dist/src/web/plugin/data-llm.test.js +81 -0
  125. package/dist/src/web/plugin/data-llm.test.js.map +1 -0
  126. package/dist/src/web/plugin/plugin.js +39 -0
  127. package/dist/src/web/plugin/plugin.js.map +1 -0
  128. package/dist/src/web/plugin/transform-data-llm.d.ts +12 -0
  129. package/dist/src/web/plugin/transform-data-llm.js +93 -0
  130. package/dist/src/web/plugin/transform-data-llm.js.map +1 -0
  131. package/dist/src/web/plugin/transform-data-llm.test.d.ts +1 -0
  132. package/dist/src/web/plugin/transform-data-llm.test.js +81 -0
  133. package/dist/src/web/plugin/transform-data-llm.test.js.map +1 -0
  134. package/dist/src/web/proxy.js +6 -1
  135. package/dist/src/web/proxy.js.map +1 -1
  136. package/dist/src/web/types.d.ts +23 -4
  137. package/dist/src/web/types.js +1 -0
  138. package/dist/src/web/types.js.map +1 -1
  139. package/package.json +15 -6
  140. package/dist/src/web/hooks/use-tool-output.d.ts +0 -4
  141. package/dist/src/web/hooks/use-tool-output.js +0 -9
  142. package/dist/src/web/hooks/use-tool-output.js.map +0 -1
  143. package/dist/src/web/hooks/use-tool-response-metadata.d.ts +0 -4
  144. package/dist/src/web/hooks/use-tool-response-metadata.js +0 -8
  145. package/dist/src/web/hooks/use-tool-response-metadata.js.map +0 -1
  146. package/dist/src/web/plugin.js +0 -28
  147. package/dist/src/web/plugin.js.map +0 -1
  148. /package/dist/src/web/{plugin.d.ts → plugin/plugin.d.ts} +0 -0
package/README.md CHANGED
@@ -1,198 +1,125 @@
1
1
  <div align="center">
2
2
 
3
- # Skybridge
4
-
5
- **Skybridge is the TypeScript framework for building ChatGPT apps**
6
-
7
- [![By Alpic](https://img.shields.io/badge/Made%20by%20Alpic-f6ffed?logo=alpic)](https://alpic.ai)
3
+ <img alt="Skybridge" src="docs/static/img/github-banner.png" width="100%">
8
4
 
9
- ![NPM Downloads](https://img.shields.io/npm/dm/skybridge?color=e90060)
10
- ![NPM Version](https://img.shields.io/npm/v/skybridge?color=e90060)
11
- ![GitHub License](https://img.shields.io/github/license/alpic-ai/skybridge?color=e90060)
5
+ <br />
12
6
 
13
- </div>
14
-
15
- Skybridge comes with 2 packages:
7
+ # Skybridge
16
8
 
17
- - `skybridge/server`: A drop-in replacement of the `@modelcontextprotocol/sdk` official `McpServer` class with extra features for widget development.
18
- - `skybridge/web`: A react library with hooks and components to build widgets on the underlying _OpenAI iFrame skybridge_ runtime.
9
+ **Build ChatGPT Apps. The Modern TypeScript Way.**
19
10
 
20
- ## Quick start
11
+ The fullstack TypeScript framework for ChatGPT Apps.<br />
12
+ **Type-safe. React-powered. Zero config.**
21
13
 
22
- To get started in less than a minute, you can [create a new repository](https://github.com/new?template_name=apps-sdk-template&template_owner=alpic-ai) using our [ChatGPT SDK template](https://github.com/alpic-ai/apps-sdk-template). This template includes a basic setup for both the server and the widgets.
14
+ <br />
23
15
 
24
- ## Installation
16
+ [![NPM Version](https://img.shields.io/npm/v/skybridge?color=e90060&style=for-the-badge)](https://www.npmjs.com/package/skybridge)
17
+ [![NPM Downloads](https://img.shields.io/npm/dm/skybridge?color=e90060&style=for-the-badge)](https://www.npmjs.com/package/skybridge)
18
+ [![GitHub License](https://img.shields.io/github/license/alpic-ai/skybridge?color=e90060&style=for-the-badge)](https://github.com/alpic-ai/skybridge/blob/main/LICENSE)
25
19
 
26
- ```bash
27
- pnpm add skybridge
28
- ```
20
+ <br />
29
21
 
30
- ## Concepts
22
+ [Documentation](https://skybridge.tech) · [Quick Start](https://github.com/new?template_name=apps-sdk-template&template_owner=alpic-ai) · [Examples](https://github.com/alpic-ai/apps-sdk-template)
31
23
 
32
- ### Widgets
24
+ </div>
33
25
 
34
- > A widget is a UI component that turns structured tool results into a human-friendly UI. Those are built using React components. They are rendered inside an iframe inline with the conversation on ChatGPT.
26
+ <br />
35
27
 
36
- Each widget in your app must have a unique name. The name is used to bridge the tool invocation result with the widget React component.
28
+ ## Why Skybridge?
37
29
 
38
- For example, in order to register a new widget named `pokemon` on your ChatGPT app. You should have the following file structure and file contents:
30
+ ChatGPT Apps let you embed **rich, interactive UIs** directly in conversations. But the raw SDK is low-level—no hooks, no type safety, no dev tools, and no HMR.
39
31
 
40
- _Project structure_
32
+ **Skybridge fixes that.**
41
33
 
42
- ```
43
- server/
44
- └── src/
45
- └── index.ts // Register the widget with McpServer.widget()
46
- web/
47
- └── src/
48
- └── widgets/
49
- └── pokemon.tsx // Use the same widget name as the file name
50
- ```
34
+ | | |
35
+ |:--|:--|
36
+ | 👨‍💻 **Full Dev Environment** — HMR, debug traces, and local devtools. No more refresh loops. | ✅ **End-to-End Type Safety** — tRPC-style inference from server to widget. Autocomplete everywhere. |
37
+ | 🔄 **Widget-to-Model Sync** — Keep the model aware of UI state with `data-llm`. Dual surfaces, one source of truth. | ⚒️ **React Query-style Hooks** — `isPending`, `isError`, callbacks. State management you already know. |
51
38
 
52
- _server/src/index.ts_
39
+ <br />
53
40
 
54
- ```ts
55
- import { McpServer } from "skybridge/server";
41
+ ## 🚀 Get Started
56
42
 
57
- const server = new McpServer();
43
+ **Create a new ChatGPT app:**
58
44
 
59
- server.widget(
60
- "pokemon"
61
- // Remaining arguments...
62
- );
45
+ ```bash
46
+ gh repo create my-app --template alpic-ai/apps-sdk-template --clone
47
+ cd my-app && pnpm install
63
48
  ```
64
49
 
65
- _web/src/widgets/pokemon.tsx_
66
-
67
- ```ts
68
- import { mountWidget } from "skybridge/web";
69
-
70
- const Pokemon: React.FunctionComponent = () => {
71
- // Your React component code goes here...
72
- };
50
+ **Or add to an existing project:**
73
51
 
74
- mountWidget(<Pokemon />);
52
+ ```bash
53
+ npm i skybridge
54
+ yarn add skybridge
55
+ pnpm add skybridge
56
+ bun add skybridge
57
+ deno add skybridge
75
58
  ```
76
59
 
77
- ## Packages
60
+ <div align="center">
78
61
 
79
- ### skybridge/server
62
+ **👉 [Read the Docs](https://skybridge.tech) 👈**
80
63
 
81
- The `skybridge/server` package is a drop-in replacement of the `@modelcontextprotocol/sdk` official `McpServer` class with extra features for widget development. If you're already using the `@modelcontextprotocol/sdk`, you can simply replace your `McpServer` import with `skybridge/server` and you're good to go.
64
+ </div>
82
65
 
83
- ### skybridge/web
66
+ <br />
84
67
 
85
- The `skybridge/web` package is a react library with hooks and components to build widgets on the underlying _OpenAI iFrame skybridge_ runtime.
68
+ ## 📦 The Stack
86
69
 
87
- **Vite plugin**
70
+ - **`skybridge/server`** — Drop-in MCP SDK replacement with widget registration and type inference.
71
+ - **`skybridge/web`** — React hooks and components for ChatGPT's runtime.
88
72
 
89
- The `skybridge/web` package comes with a Vite plugin that allows you to build your widgets as regular Vite apps.
73
+ ### Server
90
74
 
91
75
  ```ts
92
- import { defineConfig } from "vite";
93
- import { skybridge } from "skybridge/web";
76
+ import { McpServer } from "skybridge/server";
94
77
 
95
- export default defineConfig({
96
- plugins: [skybridge()],
78
+ server.registerWidget("flights", {}, {
79
+ inputSchema: { destination: z.string() },
80
+ }, async ({ destination }) => {
81
+ const flights = await searchFlights(destination);
82
+ return { structuredContent: { flights } };
97
83
  });
98
84
  ```
99
85
 
100
- **Hooks**
101
-
102
- The `skybridge/web` package comes with a set of hooks to help you build your widgets :
86
+ ### Widget
103
87
 
104
- - `useOpenAiGlobal`: A generic hook to get any global data from the OpenAI iFrame skybridge runtime (in `window.openai`).
105
- - `useToolOutput`: A hook to get the initial tool `structuredContent` returned when rendering the widget for the first time. The data inside this hook is not updated when the tool is called again.
106
- - `useToolResponseMetadata`: A hook to get the initial tool `meta` returned when rendering the widget for the first time. The data inside this hook is not updated when the tool is called again.
107
- - `useCallTool`: A @tanstack/react-query inspired hook to send make additional tool calls inside a widget.
88
+ ```tsx
89
+ import { useToolInfo } from "skybridge/web";
108
90
 
109
- _useOpenAiGlobal_
91
+ function FlightsWidget() {
92
+ const { output } = useToolInfo();
110
93
 
111
- ```ts
112
- import { useOpenAiGlobal } from "skybridge/web";
113
-
114
- const theme = useOpenAiGlobal("theme");
115
- ```
116
-
117
- _useToolOutput_
118
-
119
- ```ts
120
- import { useToolOutput } from "skybridge/web";
121
-
122
- const toolOutput = useToolOutput();
94
+ return output.structuredContent.flights.map(f =>
95
+ <FlightCard key={f.id} flight={f} />
96
+ );
97
+ }
123
98
  ```
124
99
 
125
- _useToolResponseMetadata_
100
+ <br />
126
101
 
127
- ```ts
128
- import { useToolResponseMetadata } from "skybridge/web";
102
+ ## 🎯 Features at a Glance
129
103
 
130
- const toolResponseMetadata = useToolResponseMetadata();
131
- ```
104
+ - **Live Reload** — Vite HMR. See changes instantly without reinstalling.
105
+ - **Typed Hooks** — Full autocomplete for tools, inputs, outputs.
106
+ - **Widget → Tool Calls** — Trigger server actions from UI.
107
+ - **Dual Surface Sync** — Keep model aware of what users see with `data-llm`.
108
+ - **React Query-style API** — `isPending`, `isError`, callbacks.
109
+ - **MCP Compatible** — Extends the official SDK. Works with any MCP client.
132
110
 
133
- _useCallTool_ in synchronous mode
111
+ <br />
134
112
 
135
- ```ts
136
- import { useCallTool } from "skybridge/web";
137
-
138
- export const TestTool: React.FunctionComponent = () => {
139
- const { callTool, isPending } = useCallTool("myToolName");
140
-
141
- return (
142
- <div>
143
- <button
144
- disabled={isPending}
145
- onClick={() => {
146
- callTool({ input: "test input" }, {
147
- onSuccess: (data) => {
148
- alert("Tool returned: " + data);
149
- },
150
- });
151
- >
152
- Call Tool inside a widget
153
- </button>
154
- </div>
155
- );
156
- };
157
- ```
158
-
159
- _useCallTool_ in asynchronous mode
160
-
161
- ```ts
162
- import { useCallTool } from "skybridge/web";
163
-
164
- export const TestTool: React.FunctionComponent = () => {
165
- const { callToolAsync, isPending } = useCallTool("myToolName");
166
-
167
- return (
168
- <div>
169
- <button
170
- disabled={isPending}
171
- onClick={async () => {
172
- const data = await callToolAsync({ input: "test input" });
173
- alert("Tool returned: " + data);
174
- }}
175
- >
176
- Call Tool inside a widget
177
- </button>
178
- </div>
179
- );
180
- };
181
- ```
113
+ <div align="center">
182
114
 
183
- ## Migrate your existing MCP server to a ChatGPT app
115
+ [![GitHub Discussions](https://img.shields.io/badge/Discussions-Ask%20Questions-blue?style=flat-square&logo=github)](https://github.com/alpic-ai/skybridge/discussions)
116
+ [![GitHub Issues](https://img.shields.io/badge/Issues-Report%20Bugs-red?style=flat-square&logo=github)](https://github.com/alpic-ai/skybridge/issues)
117
+ [![Discord](https://img.shields.io/badge/Discord-Chat-5865F2?style=flat-square&logo=discord&logoColor=white)](https://discord.com/invite/gNAazGueab)
184
118
 
185
- If you're already using the `@modelcontextprotocol/sdk` to build a MCP server, you can migrate to a ChatGPT app by following these steps:
119
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for setup instructions
186
120
 
187
- 1. Replace your `McpServer` import from `@modelcontextprotocol/sdk` with the same import from `skybridge/server`
188
- 2. Create a new vite project in a folder named `web` and install the `skybridge` package
189
- 3. Replace the `vite.config.ts` file with the following:
121
+ <br />
190
122
 
191
- ```ts
192
- import { defineConfig } from "vite";
193
- import { skybridge } from "skybridge/web";
123
+ **[MIT License](LICENSE)** · Made with ❤️ by **[Alpic](https://alpic.ai)**
194
124
 
195
- export default defineConfig({
196
- plugins: [skybridge()],
197
- });
198
- ```
125
+ </div>
@@ -0,0 +1,15 @@
1
+ import { type RequestHandler } from "express";
2
+ /**
3
+ * Serve the built devtools React app
4
+ * This router serves static files from the devtools's dist directory.
5
+ * It should be installed at the application root, like so:
6
+ *
7
+ * const app = express();
8
+ *
9
+ * if (env.NODE_ENV !== "production") {
10
+ * app.use(await devtoolsStaticServer(server));
11
+ * app.use(await widgetsDevServer());
12
+ * ^^^^^^^^ Make sure to install the devtoolsStaticServer before the widgetsDevServer
13
+ * }
14
+ */
15
+ export declare const devtoolsStaticServer: () => Promise<RequestHandler>;
@@ -0,0 +1,38 @@
1
+ import { readFileSync } from "node:fs";
2
+ import path from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import cors from "cors";
5
+ import express, {} from "express";
6
+ /**
7
+ * Serve the built devtools React app
8
+ * This router serves static files from the devtools's dist directory.
9
+ * It should be installed at the application root, like so:
10
+ *
11
+ * const app = express();
12
+ *
13
+ * if (env.NODE_ENV !== "production") {
14
+ * app.use(await devtoolsStaticServer(server));
15
+ * app.use(await widgetsDevServer());
16
+ * ^^^^^^^^ Make sure to install the devtoolsStaticServer before the widgetsDevServer
17
+ * }
18
+ */
19
+ export const devtoolsStaticServer = async () => {
20
+ const router = express.Router();
21
+ const currentDir = path.dirname(fileURLToPath(import.meta.url));
22
+ const devtoolsPath = path.join(currentDir, "..", "devtools");
23
+ router.use(cors());
24
+ router.use(express.static(devtoolsPath));
25
+ router.get("/", (_req, res, next) => {
26
+ const indexHtmlPath = path.join(devtoolsPath, "index.html");
27
+ try {
28
+ const indexHtml = readFileSync(indexHtmlPath, "utf-8");
29
+ res.setHeader("Content-Type", "text/html");
30
+ res.send(indexHtml);
31
+ }
32
+ catch (error) {
33
+ next(error);
34
+ }
35
+ });
36
+ return router;
37
+ };
38
+ //# sourceMappingURL=devtoolsStaticServer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"devtoolsStaticServer.js","sourceRoot":"","sources":["../../../src/server/devtoolsStaticServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,OAAO,EAAE,EAAuB,MAAM,SAAS,CAAC;AAEvD;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,IAA6B,EAAE;IACtE,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAChC,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAChE,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;IAE7D,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;IAEnB,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;IAEzC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QAClC,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;QAC5D,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,YAAY,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;YACvD,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;YAC3C,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACtB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,KAAK,CAAC,CAAC;QACd,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
@@ -1,2 +1,5 @@
1
+ export { devtoolsStaticServer } from "./devtoolsStaticServer.js";
2
+ export type { AnyToolRegistry, InferTools, ToolInput, ToolNames, ToolOutput, ToolResponseMetadata, } from "./inferUtilityTypes.js";
3
+ export type { McpServerTypes, ToolDef, WidgetHostType } from "./server.js";
1
4
  export { McpServer } from "./server.js";
2
5
  export { widgetsDevServer } from "./widgetsDevServer.js";
@@ -1,3 +1,4 @@
1
+ export { devtoolsStaticServer } from "./devtoolsStaticServer.js";
1
2
  export { McpServer } from "./server.js";
2
3
  export { widgetsDevServer } from "./widgetsDevServer.js";
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAUjE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,64 @@
1
+ import type { McpServerTypes, ToolDef } from "./server.js";
2
+ /**
3
+ * Any tool registry shape (includes both widgets and regular tools).
4
+ * Used as a constraint for type parameters that accept tool registries.
5
+ */
6
+ export type AnyToolRegistry = Record<string, ToolDef>;
7
+ /**
8
+ * Extract the tool registry type from an McpServer instance.
9
+ * This includes both widgets (registered via widget()) and regular tools (registered via registerTool()).
10
+ *
11
+ * Uses the `$types` property pattern for cross-package type inference.
12
+ * This works across package boundaries because TypeScript uses structural typing
13
+ * on the shape of `$types`, rather than nominal typing on the McpServer class itself.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * type MyTools = InferTools<MyServer>;
18
+ * // { "search": ToolDef<...>, "calculate": ToolDef<...> }
19
+ * ```
20
+ */
21
+ export type InferTools<ServerType> = ServerType extends {
22
+ $types: McpServerTypes<infer W>;
23
+ } ? W : never;
24
+ type ExtractTool<ServerType, K extends ToolNames<ServerType>> = InferTools<ServerType>[K];
25
+ /**
26
+ * Get a union of all tool names from an McpServer instance.
27
+ * This includes both widgets and regular tools.
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * type Names = ToolNames<MyServer>;
32
+ * // "search" | "calculate" | "details"
33
+ * ```
34
+ */
35
+ export type ToolNames<ServerType> = keyof InferTools<ServerType> & string;
36
+ /**
37
+ * Get the input type for a specific tool (widget or regular tool).
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * type SearchInput = ToolInput<MyServer, "search">;
42
+ * ```
43
+ */
44
+ export type ToolInput<ServerType, ToolName extends ToolNames<ServerType>> = ExtractTool<ServerType, ToolName>["input"];
45
+ /**
46
+ * Get the output type for a specific tool (widget or regular tool).
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * type SearchOutput = ToolOutput<MyServer, "search">;
51
+ * ```
52
+ */
53
+ export type ToolOutput<ServerType, ToolName extends ToolNames<ServerType>> = ExtractTool<ServerType, ToolName>["output"];
54
+ /**
55
+ * Get the responseMetadata type for a specific tool (widget or regular tool).
56
+ * This is inferred from the `_meta` property of the tool callback's return value.
57
+ *
58
+ * @example
59
+ * ```ts
60
+ * type SearchMeta = ToolResponseMetadata<MyServer, "search">;
61
+ * ```
62
+ */
63
+ export type ToolResponseMetadata<ServerType, ToolName extends ToolNames<ServerType>> = ExtractTool<ServerType, ToolName>["responseMetadata"];
64
+ export {};
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=inferUtilityTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inferUtilityTypes.js","sourceRoot":"","sources":["../../../src/server/inferUtilityTypes.ts"],"names":[],"mappings":""}
@@ -1,13 +1,74 @@
1
- import { McpServer as McpServerBase, type ToolCallback } from "@modelcontextprotocol/sdk/server/mcp.js";
2
- import type { Resource } from "@modelcontextprotocol/sdk/types.js";
3
- import type { ZodRawShape } from "zod";
1
+ import { McpServer as McpServerBase, type RegisteredTool } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import type { AnySchema, SchemaOutput, ZodRawShapeCompat } from "@modelcontextprotocol/sdk/server/zod-compat.js";
3
+ import type { RequestHandlerExtra } from "@modelcontextprotocol/sdk/shared/protocol.js";
4
+ import type { CallToolResult, Resource, ServerNotification, ServerRequest, ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
5
+ export type ToolDef<TInput = unknown, TOutput = unknown, TResponseMetadata = unknown> = {
6
+ input: TInput;
7
+ output: TOutput;
8
+ responseMetadata: TResponseMetadata;
9
+ };
10
+ export type WidgetHostType = "chatgpt-app" | "mcp-app";
4
11
  type McpServerOriginalResourceConfig = Omit<Resource, "uri" | "name" | "mimeType">;
5
- type McpServerOriginalToolConfig = Omit<Parameters<McpServer["registerTool"]>[1], "inputSchema" | "outputSchema">;
6
- export declare class McpServer extends McpServerBase {
7
- widget<InputArgs extends ZodRawShape, OutputArgs extends ZodRawShape>(name: string, resourceConfig: McpServerOriginalResourceConfig, toolConfig: McpServerOriginalToolConfig & {
8
- inputSchema?: InputArgs;
9
- outputSchema?: OutputArgs;
10
- }, toolCallback: ToolCallback<InputArgs>): void;
12
+ type McpServerOriginalToolConfig = Omit<Parameters<typeof McpServerBase.prototype.registerTool<ZodRawShapeCompat, ZodRawShapeCompat>>[1], "inputSchema" | "outputSchema">;
13
+ type Simplify<T> = {
14
+ [K in keyof T]: T[K];
15
+ };
16
+ type ExtractStructuredContent<T> = T extends {
17
+ structuredContent: infer SC;
18
+ } ? Simplify<SC> : never;
19
+ type ExtractMeta<T> = [Extract<T, {
20
+ _meta: unknown;
21
+ }>] extends [never] ? unknown : Extract<T, {
22
+ _meta: unknown;
23
+ }> extends {
24
+ _meta: infer M;
25
+ } ? Simplify<M> : unknown;
26
+ /**
27
+ * Type-level marker interface for cross-package type inference.
28
+ * This enables TypeScript to infer tool types across package boundaries
29
+ * using structural typing on the $types property, rather than relying on
30
+ * class generic inference which fails when McpServer comes from different
31
+ * package installations.
32
+ *
33
+ * Inspired by tRPC's _def pattern and Hono's type markers.
34
+ */
35
+ export interface McpServerTypes<TTools extends Record<string, ToolDef>> {
36
+ readonly tools: TTools;
37
+ }
38
+ type ShapeOutput<Shape extends ZodRawShapeCompat> = Simplify<{
39
+ [K in keyof Shape as undefined extends SchemaOutput<Shape[K]> ? never : K]: SchemaOutput<Shape[K]>;
40
+ } & {
41
+ [K in keyof Shape as undefined extends SchemaOutput<Shape[K]> ? K : never]?: SchemaOutput<Shape[K]>;
42
+ }>;
43
+ type AddTool<TTools, TName extends string, TInput extends ZodRawShapeCompat, TOutput, TResponseMetadata = unknown> = McpServer<TTools & {
44
+ [K in TName]: ToolDef<ShapeOutput<TInput>, TOutput, TResponseMetadata>;
45
+ }>;
46
+ type ToolConfig<TInput extends ZodRawShapeCompat | AnySchema> = {
47
+ title?: string;
48
+ description?: string;
49
+ inputSchema?: TInput;
50
+ outputSchema?: ZodRawShapeCompat | AnySchema;
51
+ annotations?: ToolAnnotations;
52
+ _meta?: Record<string, unknown>;
53
+ };
54
+ type ToolHandler<TInput extends ZodRawShapeCompat, TReturn extends {
55
+ content: CallToolResult["content"];
56
+ } = CallToolResult> = (args: ShapeOutput<TInput>, extra: RequestHandlerExtra<ServerRequest, ServerNotification>) => TReturn | Promise<TReturn>;
57
+ export declare class McpServer<TTools extends Record<string, ToolDef> = Record<never, ToolDef>> extends McpServerBase {
58
+ readonly $types: McpServerTypes<TTools>;
59
+ registerWidget<TName extends string, TInput extends ZodRawShapeCompat, TReturn extends {
60
+ content: CallToolResult["content"];
61
+ }>(name: TName, resourceConfig: McpServerOriginalResourceConfig, toolConfig: McpServerOriginalToolConfig & {
62
+ inputSchema?: TInput;
63
+ outputSchema?: ZodRawShapeCompat | AnySchema;
64
+ }, toolCallback: ToolHandler<TInput, TReturn>): AddTool<TTools, TName, TInput, ExtractStructuredContent<TReturn>, ExtractMeta<TReturn>>;
65
+ registerTool<TName extends string, InputArgs extends ZodRawShapeCompat, TReturn extends {
66
+ content: CallToolResult["content"];
67
+ }>(name: TName, config: ToolConfig<InputArgs>, cb: ToolHandler<InputArgs, TReturn>): AddTool<TTools, TName, InputArgs, ExtractStructuredContent<TReturn>, ExtractMeta<TReturn>>;
68
+ registerTool<InputArgs extends ZodRawShapeCompat>(name: string, config: ToolConfig<InputArgs>, cb: ToolHandler<InputArgs>): RegisteredTool;
69
+ private registerWidgetResource;
11
70
  private lookupDistFile;
71
+ private lookupDistFileWithIndexFallback;
72
+ private readManifest;
12
73
  }
13
74
  export {};
@@ -1,57 +1,82 @@
1
- import { McpServer as McpServerBase, } from "@modelcontextprotocol/sdk/server/mcp.js";
2
- import { templateHelper } from "./templateHelper.js";
3
1
  import { readFileSync } from "node:fs";
4
2
  import path from "node:path";
3
+ import { McpServer as McpServerBase, } from "@modelcontextprotocol/sdk/server/mcp.js";
4
+ import { templateHelper } from "./templateHelper.js";
5
5
  export class McpServer extends McpServerBase {
6
- widget(name, resourceConfig, toolConfig, toolCallback) {
7
- const uri = `ui://widgets/${name}.html`;
6
+ registerWidget(name, resourceConfig, toolConfig, toolCallback) {
8
7
  const resourceMetadata = {
9
8
  ...(resourceConfig._meta ?? {}),
10
9
  };
11
10
  if (toolConfig.description !== undefined) {
12
11
  resourceMetadata["openai/widgetDescription"] = toolConfig.description;
13
12
  }
14
- this.resource(name, uri, {
15
- ...resourceConfig,
16
- _meta: resourceMetadata,
17
- }, async (_uri, extra) => {
13
+ const appsSdkResourceConfig = {
14
+ hostType: "chatgpt-app",
15
+ uri: `ui://widgets/apps-sdk/${name}.html`,
16
+ mimeType: "text/html+skybridge",
17
+ };
18
+ const extAppsResourceConfig = {
19
+ hostType: "mcp-app",
20
+ uri: `ui://widgets/ext-apps/${name}.html`,
21
+ mimeType: "text/html;profile=mcp-app",
22
+ };
23
+ [appsSdkResourceConfig, extAppsResourceConfig].forEach(({ hostType, uri, mimeType }) => {
24
+ this.registerWidgetResource({
25
+ name,
26
+ hostType,
27
+ widgetUri: uri,
28
+ mimeType,
29
+ resourceConfig,
30
+ resourceMetadata,
31
+ });
32
+ });
33
+ const toolMeta = {
34
+ ...toolConfig._meta,
35
+ "openai/outputTemplate": appsSdkResourceConfig.uri,
36
+ // "ui/resourceUri": extAppsResourceConfig.uri,
37
+ };
38
+ this.registerTool(name, {
39
+ ...toolConfig,
40
+ _meta: toolMeta,
41
+ }, toolCallback);
42
+ return this;
43
+ }
44
+ registerTool(name, config, cb) {
45
+ super.registerTool(name, config, cb);
46
+ return this;
47
+ }
48
+ registerWidgetResource({ name, hostType, widgetUri, mimeType, resourceConfig, resourceMetadata, }) {
49
+ this.registerResource(name, widgetUri, { ...resourceConfig, _meta: resourceMetadata }, async (uri, extra) => {
18
50
  const serverUrl = process.env.NODE_ENV === "production"
19
- ? `https://${extra?.requestInfo?.headers?.["x-forwarded-host"] ??
20
- extra?.requestInfo?.headers?.host}`
51
+ ? `https://${extra?.requestInfo?.headers?.["x-forwarded-host"] ?? extra?.requestInfo?.headers?.host}`
21
52
  : `http://localhost:3000`;
22
53
  const html = process.env.NODE_ENV === "production"
23
54
  ? templateHelper.renderProduction({
55
+ hostType,
24
56
  serverUrl,
25
- widgetFile: this.lookupDistFile(`src/widgets/${name}.tsx`),
57
+ widgetFile: this.lookupDistFileWithIndexFallback(`src/widgets/${name}`),
26
58
  styleFile: this.lookupDistFile("style.css"),
27
59
  })
28
60
  : templateHelper.renderDevelopment({
61
+ hostType,
29
62
  serverUrl,
30
63
  widgetName: name,
31
64
  });
32
- return {
33
- contents: [
34
- {
35
- uri,
36
- mimeType: "text/html+skybridge",
37
- text: html,
38
- },
39
- ],
40
- };
65
+ return { contents: [{ uri: uri.href, mimeType, text: html }] };
41
66
  });
42
- const toolMeta = {
43
- ...toolConfig._meta,
44
- "openai/outputTemplate": uri,
45
- "ui/resourceUri": uri,
46
- };
47
- this.registerTool(name, {
48
- ...toolConfig,
49
- _meta: toolMeta,
50
- }, toolCallback);
51
67
  }
52
68
  lookupDistFile(key) {
53
- const manifest = JSON.parse(readFileSync(path.join(process.cwd(), "dist", "assets", ".vite", "manifest.json"), "utf-8"));
69
+ const manifest = this.readManifest();
54
70
  return manifest[key]?.file;
55
71
  }
72
+ lookupDistFileWithIndexFallback(basePath) {
73
+ const manifest = this.readManifest();
74
+ const flatFileKey = `${basePath}.tsx`;
75
+ const indexFileKey = `${basePath}/index.tsx`;
76
+ return manifest[flatFileKey]?.file ?? manifest[indexFileKey]?.file;
77
+ }
78
+ readManifest() {
79
+ return JSON.parse(readFileSync(path.join(process.cwd(), "dist", "assets", ".vite", "manifest.json"), "utf-8"));
80
+ }
56
81
  }
57
82
  //# sourceMappingURL=server.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/server/server.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,IAAI,aAAa,GAE3B,MAAM,yCAAyC,CAAC;AAGjD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AA+C7B,MAAM,OAAO,SAAU,SAAQ,aAAa;IAC1C,MAAM,CACJ,IAAY,EACZ,cAA+C,EAC/C,UAGC,EACD,YAAqC;QAErC,MAAM,GAAG,GAAG,gBAAgB,IAAI,OAAO,CAAC;QACxC,MAAM,gBAAgB,GAAiB;YACrC,GAAG,CAAC,cAAc,C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