skybridge 0.0.0-dev.d8b52a9 → 0.0.0-dev.d91f2cb

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 (271) hide show
  1. package/LICENSE +21 -674
  2. package/bin/run.js +9 -0
  3. package/dist/cli/use-version.d.ts +1 -0
  4. package/dist/cli/use-version.js +33 -0
  5. package/dist/cli/use-version.js.map +1 -0
  6. package/dist/commands/dev.d.ts +7 -0
  7. package/dist/commands/dev.js +30 -0
  8. package/dist/commands/dev.js.map +1 -0
  9. package/dist/server/index.d.ts +4 -0
  10. package/dist/server/index.js.map +1 -0
  11. package/dist/server/inferUtilityTypes.d.ts +64 -0
  12. package/dist/server/inferUtilityTypes.js.map +1 -0
  13. package/dist/server/server.d.ts +101 -0
  14. package/dist/server/server.js +132 -0
  15. package/dist/server/server.js.map +1 -0
  16. package/dist/{src/server → server}/templateHelper.d.ts +3 -0
  17. package/dist/{src/server → server}/templateHelper.js +5 -4
  18. package/dist/server/templateHelper.js.map +1 -0
  19. package/dist/server/templates/development.hbs +66 -0
  20. package/dist/{src/server → server}/templates/production.hbs +1 -0
  21. package/dist/{src/server → server}/widgetsDevServer.d.ts +2 -2
  22. package/dist/{src/server → server}/widgetsDevServer.js +13 -5
  23. package/dist/server/widgetsDevServer.js.map +1 -0
  24. package/dist/test/utils.d.ts +135 -0
  25. package/dist/test/utils.js +242 -0
  26. package/dist/test/utils.js.map +1 -0
  27. package/dist/test/widget.test.js +234 -0
  28. package/dist/test/widget.test.js.map +1 -0
  29. package/dist/web/bridges/adaptors/apps-sdk-adaptor.d.ts +13 -0
  30. package/dist/web/bridges/adaptors/apps-sdk-adaptor.js +33 -0
  31. package/dist/web/bridges/adaptors/apps-sdk-adaptor.js.map +1 -0
  32. package/dist/web/bridges/adaptors/mcp-app-adaptor.d.ts +16 -0
  33. package/dist/web/bridges/adaptors/mcp-app-adaptor.js +115 -0
  34. package/dist/web/bridges/adaptors/mcp-app-adaptor.js.map +1 -0
  35. package/dist/web/bridges/apps-sdk-bridge.d.ts +10 -0
  36. package/dist/web/bridges/apps-sdk-bridge.js +46 -0
  37. package/dist/web/bridges/apps-sdk-bridge.js.map +1 -0
  38. package/dist/web/bridges/hooks/use-adaptor.d.ts +2 -0
  39. package/dist/web/bridges/hooks/use-adaptor.js +8 -0
  40. package/dist/web/bridges/hooks/use-adaptor.js.map +1 -0
  41. package/dist/web/bridges/hooks/use-apps-sdk-bridge.d.ts +2 -0
  42. package/dist/web/bridges/hooks/use-apps-sdk-bridge.js +7 -0
  43. package/dist/web/bridges/hooks/use-apps-sdk-bridge.js.map +1 -0
  44. package/dist/web/bridges/hooks/use-bridge.d.ts +2 -0
  45. package/dist/web/bridges/hooks/use-bridge.js +8 -0
  46. package/dist/web/bridges/hooks/use-bridge.js.map +1 -0
  47. package/dist/web/bridges/hooks/use-mcp-app-bridge.d.ts +5 -0
  48. package/dist/web/bridges/hooks/use-mcp-app-bridge.js +7 -0
  49. package/dist/web/bridges/hooks/use-mcp-app-bridge.js.map +1 -0
  50. package/dist/web/bridges/hooks/use-mcp-app-bridge.test.js +62 -0
  51. package/dist/web/bridges/hooks/use-mcp-app-bridge.test.js.map +1 -0
  52. package/dist/web/bridges/index.d.ts +4 -0
  53. package/dist/web/bridges/index.js +5 -0
  54. package/dist/web/bridges/index.js.map +1 -0
  55. package/dist/web/bridges/mcp-app-bridge.d.ts +46 -0
  56. package/dist/web/bridges/mcp-app-bridge.js +217 -0
  57. package/dist/web/bridges/mcp-app-bridge.js.map +1 -0
  58. package/dist/web/bridges/types.d.ts +57 -0
  59. package/dist/web/bridges/types.js +2 -0
  60. package/dist/web/bridges/types.js.map +1 -0
  61. package/dist/web/create-store.d.ts +3 -0
  62. package/dist/web/create-store.js +25 -0
  63. package/dist/web/create-store.js.map +1 -0
  64. package/dist/web/create-store.test.js +70 -0
  65. package/dist/web/create-store.test.js.map +1 -0
  66. package/dist/web/data-llm.d.ts +14 -0
  67. package/dist/web/data-llm.js +70 -0
  68. package/dist/web/data-llm.js.map +1 -0
  69. package/dist/web/data-llm.test.js +76 -0
  70. package/dist/web/data-llm.test.js.map +1 -0
  71. package/dist/{src/web/typed-hooks.d.ts → web/generate-helpers.d.ts} +26 -18
  72. package/dist/{src/web/typed-hooks.js → web/generate-helpers.js} +14 -14
  73. package/dist/web/generate-helpers.js.map +1 -0
  74. package/dist/web/generate-helpers.test-d.js +209 -0
  75. package/dist/web/generate-helpers.test-d.js.map +1 -0
  76. package/dist/web/generate-helpers.test.js +17 -0
  77. package/dist/web/generate-helpers.test.js.map +1 -0
  78. package/dist/web/helpers/state.d.ts +7 -0
  79. package/dist/web/helpers/state.js +40 -0
  80. package/dist/web/helpers/state.js.map +1 -0
  81. package/dist/web/helpers/state.test.js +53 -0
  82. package/dist/web/helpers/state.test.js.map +1 -0
  83. package/dist/{src/web → web}/hooks/index.d.ts +4 -7
  84. package/dist/{src/web → web}/hooks/index.js +4 -7
  85. package/dist/web/hooks/index.js.map +1 -0
  86. package/dist/web/hooks/test/utils.d.ts +10 -0
  87. package/dist/web/hooks/test/utils.js +40 -0
  88. package/dist/web/hooks/test/utils.js.map +1 -0
  89. package/dist/web/hooks/use-call-tool.d.ts +100 -0
  90. package/dist/{src/web → web}/hooks/use-call-tool.js +19 -19
  91. package/dist/web/hooks/use-call-tool.js.map +1 -0
  92. package/dist/web/hooks/use-call-tool.test-d.js +104 -0
  93. package/dist/web/hooks/use-call-tool.test-d.js.map +1 -0
  94. package/dist/{src/web → web}/hooks/use-call-tool.test.js +42 -15
  95. package/dist/web/hooks/use-call-tool.test.js.map +1 -0
  96. package/dist/{src/web → web}/hooks/use-display-mode.d.ts +1 -1
  97. package/dist/web/hooks/use-display-mode.js +10 -0
  98. package/dist/web/hooks/use-display-mode.js.map +1 -0
  99. package/dist/{src/web → web}/hooks/use-display-mode.test.js +3 -2
  100. package/dist/web/hooks/use-display-mode.test.js.map +1 -0
  101. package/dist/web/hooks/use-files.js.map +1 -0
  102. package/dist/{src/web → web}/hooks/use-files.test.js +1 -1
  103. package/dist/web/hooks/use-files.test.js.map +1 -0
  104. package/dist/web/hooks/use-layout.d.ts +22 -0
  105. package/dist/web/hooks/use-layout.js +23 -0
  106. package/dist/web/hooks/use-layout.js.map +1 -0
  107. package/dist/web/hooks/use-layout.test.js +95 -0
  108. package/dist/web/hooks/use-layout.test.js.map +1 -0
  109. package/dist/web/hooks/use-open-external.js +8 -0
  110. package/dist/web/hooks/use-open-external.js.map +1 -0
  111. package/dist/web/hooks/use-open-external.test.js +50 -0
  112. package/dist/web/hooks/use-open-external.test.js.map +1 -0
  113. package/dist/web/hooks/use-openai-global.d.ts +3 -0
  114. package/dist/web/hooks/use-openai-global.js +6 -0
  115. package/dist/web/hooks/use-openai-global.js.map +1 -0
  116. package/dist/web/hooks/use-request-modal.d.ts +9 -0
  117. package/dist/web/hooks/use-request-modal.js +14 -0
  118. package/dist/web/hooks/use-request-modal.js.map +1 -0
  119. package/dist/web/hooks/use-request-modal.test.js +57 -0
  120. package/dist/web/hooks/use-request-modal.test.js.map +1 -0
  121. package/dist/web/hooks/use-send-follow-up-message.js +8 -0
  122. package/dist/web/hooks/use-send-follow-up-message.js.map +1 -0
  123. package/dist/{src/web → web}/hooks/use-tool-info.d.ts +13 -2
  124. package/dist/web/hooks/use-tool-info.js +26 -0
  125. package/dist/web/hooks/use-tool-info.js.map +1 -0
  126. package/dist/web/hooks/use-tool-info.test-d.d.ts +1 -0
  127. package/dist/{src/web → web}/hooks/use-tool-info.test-d.js +40 -5
  128. package/dist/web/hooks/use-tool-info.test-d.js.map +1 -0
  129. package/dist/web/hooks/use-tool-info.test.d.ts +1 -0
  130. package/dist/web/hooks/use-tool-info.test.js +130 -0
  131. package/dist/web/hooks/use-tool-info.test.js.map +1 -0
  132. package/dist/web/hooks/use-user.d.ts +18 -0
  133. package/dist/web/hooks/use-user.js +19 -0
  134. package/dist/web/hooks/use-user.js.map +1 -0
  135. package/dist/web/hooks/use-user.test.d.ts +1 -0
  136. package/dist/web/hooks/use-user.test.js +93 -0
  137. package/dist/web/hooks/use-user.test.js.map +1 -0
  138. package/dist/{src/web → web}/hooks/use-widget-state.js +11 -9
  139. package/dist/web/hooks/use-widget-state.js.map +1 -0
  140. package/dist/web/hooks/use-widget-state.test.d.ts +1 -0
  141. package/dist/{src/web → web}/hooks/use-widget-state.test.js +3 -2
  142. package/dist/web/hooks/use-widget-state.test.js.map +1 -0
  143. package/dist/web/index.d.ts +8 -0
  144. package/dist/web/index.js +9 -0
  145. package/dist/web/index.js.map +1 -0
  146. package/dist/web/mount-widget.js.map +1 -0
  147. package/dist/web/plugin/data-llm.test.d.ts +1 -0
  148. package/dist/web/plugin/data-llm.test.js +81 -0
  149. package/dist/web/plugin/data-llm.test.js.map +1 -0
  150. package/dist/web/plugin/plugin.js +39 -0
  151. package/dist/web/plugin/plugin.js.map +1 -0
  152. package/dist/web/plugin/transform-data-llm.d.ts +12 -0
  153. package/dist/web/plugin/transform-data-llm.js +96 -0
  154. package/dist/web/plugin/transform-data-llm.js.map +1 -0
  155. package/dist/web/plugin/transform-data-llm.test.d.ts +1 -0
  156. package/dist/web/plugin/transform-data-llm.test.js +81 -0
  157. package/dist/web/plugin/transform-data-llm.test.js.map +1 -0
  158. package/dist/{src/web → web}/proxy.js +6 -1
  159. package/dist/web/proxy.js.map +1 -0
  160. package/dist/{src/web → web}/types.d.ts +43 -13
  161. package/dist/{src/web → web}/types.js +1 -0
  162. package/dist/web/types.js.map +1 -0
  163. package/package.json +54 -30
  164. package/README.md +0 -323
  165. package/dist/src/server/index.d.ts +0 -4
  166. package/dist/src/server/index.js.map +0 -1
  167. package/dist/src/server/inferUtilityTypes.d.ts +0 -44
  168. package/dist/src/server/inferUtilityTypes.js.map +0 -1
  169. package/dist/src/server/server.d.ts +0 -19
  170. package/dist/src/server/server.js +0 -58
  171. package/dist/src/server/server.js.map +0 -1
  172. package/dist/src/server/templateHelper.js.map +0 -1
  173. package/dist/src/server/templates/development.hbs +0 -12
  174. package/dist/src/server/widgetsDevServer.js.map +0 -1
  175. package/dist/src/test/utils.d.ts +0 -28
  176. package/dist/src/test/utils.js +0 -43
  177. package/dist/src/test/utils.js.map +0 -1
  178. package/dist/src/test/widget.test.js +0 -90
  179. package/dist/src/test/widget.test.js.map +0 -1
  180. package/dist/src/web/hooks/index.js.map +0 -1
  181. package/dist/src/web/hooks/use-call-tool.d.ts +0 -62
  182. package/dist/src/web/hooks/use-call-tool.js.map +0 -1
  183. package/dist/src/web/hooks/use-call-tool.test.js.map +0 -1
  184. package/dist/src/web/hooks/use-display-mode.js +0 -7
  185. package/dist/src/web/hooks/use-display-mode.js.map +0 -1
  186. package/dist/src/web/hooks/use-display-mode.test.js.map +0 -1
  187. package/dist/src/web/hooks/use-files.js.map +0 -1
  188. package/dist/src/web/hooks/use-files.test.js.map +0 -1
  189. package/dist/src/web/hooks/use-locale.d.ts +0 -1
  190. package/dist/src/web/hooks/use-locale.js +0 -5
  191. package/dist/src/web/hooks/use-locale.js.map +0 -1
  192. package/dist/src/web/hooks/use-locale.test.js +0 -21
  193. package/dist/src/web/hooks/use-locale.test.js.map +0 -1
  194. package/dist/src/web/hooks/use-open-external.js +0 -6
  195. package/dist/src/web/hooks/use-open-external.js.map +0 -1
  196. package/dist/src/web/hooks/use-open-external.test.js +0 -24
  197. package/dist/src/web/hooks/use-open-external.test.js.map +0 -1
  198. package/dist/src/web/hooks/use-openai-global.d.ts +0 -2
  199. package/dist/src/web/hooks/use-openai-global.js +0 -23
  200. package/dist/src/web/hooks/use-openai-global.js.map +0 -1
  201. package/dist/src/web/hooks/use-request-modal.d.ts +0 -6
  202. package/dist/src/web/hooks/use-request-modal.js +0 -9
  203. package/dist/src/web/hooks/use-request-modal.js.map +0 -1
  204. package/dist/src/web/hooks/use-request-modal.test.js +0 -24
  205. package/dist/src/web/hooks/use-request-modal.test.js.map +0 -1
  206. package/dist/src/web/hooks/use-send-follow-up-message.js +0 -11
  207. package/dist/src/web/hooks/use-send-follow-up-message.js.map +0 -1
  208. package/dist/src/web/hooks/use-theme.d.ts +0 -1
  209. package/dist/src/web/hooks/use-theme.js +0 -5
  210. package/dist/src/web/hooks/use-theme.js.map +0 -1
  211. package/dist/src/web/hooks/use-theme.test.js +0 -26
  212. package/dist/src/web/hooks/use-theme.test.js.map +0 -1
  213. package/dist/src/web/hooks/use-tool-info.js +0 -22
  214. package/dist/src/web/hooks/use-tool-info.js.map +0 -1
  215. package/dist/src/web/hooks/use-tool-info.test-d.js.map +0 -1
  216. package/dist/src/web/hooks/use-tool-info.test.js +0 -59
  217. package/dist/src/web/hooks/use-tool-info.test.js.map +0 -1
  218. package/dist/src/web/hooks/use-tool-output.d.ts +0 -4
  219. package/dist/src/web/hooks/use-tool-output.js +0 -9
  220. package/dist/src/web/hooks/use-tool-output.js.map +0 -1
  221. package/dist/src/web/hooks/use-tool-response-metadata.d.ts +0 -4
  222. package/dist/src/web/hooks/use-tool-response-metadata.js +0 -8
  223. package/dist/src/web/hooks/use-tool-response-metadata.js.map +0 -1
  224. package/dist/src/web/hooks/use-user-agent.d.ts +0 -1
  225. package/dist/src/web/hooks/use-user-agent.js +0 -5
  226. package/dist/src/web/hooks/use-user-agent.js.map +0 -1
  227. package/dist/src/web/hooks/use-user-agent.test.js +0 -31
  228. package/dist/src/web/hooks/use-user-agent.test.js.map +0 -1
  229. package/dist/src/web/hooks/use-widget-state.js.map +0 -1
  230. package/dist/src/web/hooks/use-widget-state.test.js.map +0 -1
  231. package/dist/src/web/index.d.ts +0 -5
  232. package/dist/src/web/index.js +0 -6
  233. package/dist/src/web/index.js.map +0 -1
  234. package/dist/src/web/mount-widget.js.map +0 -1
  235. package/dist/src/web/plugin.js +0 -28
  236. package/dist/src/web/plugin.js.map +0 -1
  237. package/dist/src/web/proxy.js.map +0 -1
  238. package/dist/src/web/typed-hooks.js.map +0 -1
  239. package/dist/src/web/typed-hooks.test-d.js +0 -72
  240. package/dist/src/web/typed-hooks.test-d.js.map +0 -1
  241. package/dist/src/web/typed-hooks.test.js +0 -10
  242. package/dist/src/web/typed-hooks.test.js.map +0 -1
  243. package/dist/src/web/types.js.map +0 -1
  244. package/dist/vitest.config.d.ts +0 -2
  245. package/dist/vitest.config.js +0 -8
  246. package/dist/vitest.config.js.map +0 -1
  247. /package/dist/{src/server → server}/index.js +0 -0
  248. /package/dist/{src/server → server}/inferUtilityTypes.js +0 -0
  249. /package/dist/{src/test → test}/widget.test.d.ts +0 -0
  250. /package/dist/{src/web/hooks/use-call-tool.test.d.ts → web/bridges/hooks/use-mcp-app-bridge.test.d.ts} +0 -0
  251. /package/dist/{src/web/hooks/use-display-mode.test.d.ts → web/create-store.test.d.ts} +0 -0
  252. /package/dist/{src/web/hooks/use-files.test.d.ts → web/data-llm.test.d.ts} +0 -0
  253. /package/dist/{src/web/hooks/use-locale.test.d.ts → web/generate-helpers.test-d.d.ts} +0 -0
  254. /package/dist/{src/web/hooks/use-open-external.test.d.ts → web/generate-helpers.test.d.ts} +0 -0
  255. /package/dist/{src/web/hooks/use-request-modal.test.d.ts → web/helpers/state.test.d.ts} +0 -0
  256. /package/dist/{src/web/hooks/use-theme.test.d.ts → web/hooks/use-call-tool.test-d.d.ts} +0 -0
  257. /package/dist/{src/web/hooks/use-tool-info.test-d.d.ts → web/hooks/use-call-tool.test.d.ts} +0 -0
  258. /package/dist/{src/web/hooks/use-tool-info.test.d.ts → web/hooks/use-display-mode.test.d.ts} +0 -0
  259. /package/dist/{src/web → web}/hooks/use-files.d.ts +0 -0
  260. /package/dist/{src/web → web}/hooks/use-files.js +0 -0
  261. /package/dist/{src/web/hooks/use-user-agent.test.d.ts → web/hooks/use-files.test.d.ts} +0 -0
  262. /package/dist/{src/web/hooks/use-widget-state.test.d.ts → web/hooks/use-layout.test.d.ts} +0 -0
  263. /package/dist/{src/web → web}/hooks/use-open-external.d.ts +0 -0
  264. /package/dist/{src/web/typed-hooks.test-d.d.ts → web/hooks/use-open-external.test.d.ts} +0 -0
  265. /package/dist/{src/web/typed-hooks.test.d.ts → web/hooks/use-request-modal.test.d.ts} +0 -0
  266. /package/dist/{src/web → web}/hooks/use-send-follow-up-message.d.ts +0 -0
  267. /package/dist/{src/web → web}/hooks/use-widget-state.d.ts +0 -0
  268. /package/dist/{src/web → web}/mount-widget.d.ts +0 -0
  269. /package/dist/{src/web → web}/mount-widget.js +0 -0
  270. /package/dist/{src/web → web/plugin}/plugin.d.ts +0 -0
  271. /package/dist/{src/web → web}/proxy.d.ts +0 -0
@@ -1,4 +1,20 @@
1
+ import "react";
2
+ import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
3
+ import type { WidgetHostType } from "../server/index.js";
4
+ declare module "react" {
5
+ interface HTMLAttributes<T> {
6
+ "data-llm"?: string;
7
+ }
8
+ }
1
9
  export type UnknownObject = Record<string, unknown>;
10
+ export type Prettify<T> = {
11
+ [K in keyof T]: T[K];
12
+ } & {};
13
+ export type Objectify<T> = T & UnknownObject;
14
+ type RequiredKeys<T> = {
15
+ [K in keyof T]-?: Record<string, never> extends Pick<T, K> ? never : K;
16
+ }[keyof T];
17
+ export type HasRequiredKeys<T> = RequiredKeys<T> extends never ? false : true;
2
18
  type WidgetState = UnknownObject;
3
19
  type FileMetadata = {
4
20
  fileId: string;
@@ -14,19 +30,24 @@ export declare class ToolResponseEvent extends CustomEvent<{
14
30
  }
15
31
  declare global {
16
32
  interface Window {
17
- openai: API<WidgetState> & OpenAiGlobals;
33
+ skybridge: SkybridgeProperties;
34
+ openai: OpenAiMethods<WidgetState> & OpenAiProperties;
18
35
  }
19
36
  interface WindowEventMap {
20
37
  [SET_GLOBALS_EVENT_TYPE]: SetGlobalsEvent;
21
38
  }
22
39
  }
23
- export type OpenAiGlobals<ToolInput extends UnknownObject = {}, ToolOutput extends UnknownObject = UnknownObject, ToolResponseMetadata extends UnknownObject = UnknownObject, WidgetState extends UnknownObject = UnknownObject> = {
40
+ export type SkybridgeProperties = {
41
+ hostType: WidgetHostType;
42
+ };
43
+ export type OpenAiProperties<ToolInput extends UnknownObject = Record<never, unknown>, ToolOutput extends UnknownObject = UnknownObject, ToolResponseMetadata extends UnknownObject = UnknownObject, WidgetState extends UnknownObject = UnknownObject> = {
24
44
  theme: Theme;
25
45
  userAgent: UserAgent;
26
46
  locale: string;
27
47
  maxHeight: number;
28
48
  displayMode: DisplayMode;
29
49
  safeArea: SafeArea;
50
+ view: View;
30
51
  toolInput: ToolInput;
31
52
  toolOutput: ToolOutput | {
32
53
  text: string;
@@ -36,16 +57,23 @@ export type OpenAiGlobals<ToolInput extends UnknownObject = {}, ToolOutput exten
36
57
  };
37
58
  export type CallToolArgs = Record<string, unknown> | null;
38
59
  export type CallToolResponse = {
39
- content: {
40
- type: "text";
41
- text: string;
42
- }[];
60
+ content: CallToolResult["content"];
43
61
  structuredContent: Record<string, unknown>;
44
62
  isError: boolean;
45
63
  result: string;
46
- meta: Record<string, unknown>;
64
+ _meta?: CallToolResult["_meta"];
47
65
  };
48
- type API<WidgetState extends UnknownObject> = {
66
+ export type RequestModalOptions = {
67
+ title?: string;
68
+ params?: Record<string, unknown>;
69
+ anchor?: {
70
+ top?: number;
71
+ left?: number;
72
+ width?: number;
73
+ height?: number;
74
+ };
75
+ };
76
+ export type OpenAiMethods<WidgetState extends UnknownObject = UnknownObject> = {
49
77
  /** Calls a tool on your MCP. Returns the full response. */
50
78
  callTool: <ToolArgs extends CallToolArgs = null, ToolResponse extends CallToolResponse = CallToolResponse>(name: string, args: ToolArgs) => Promise<ToolResponse>;
51
79
  /** Triggers a followup turn in the ChatGPT conversation */
@@ -75,9 +103,7 @@ type API<WidgetState extends UnknownObject> = {
75
103
  * Opens a modal portaled outside of the widget iFrame.
76
104
  * This ensures the modal is correctly displayed and not limited to the widget's area.
77
105
  */
78
- requestModal: (args: {
79
- title: string;
80
- }) => Promise<void>;
106
+ requestModal: (args: RequestModalOptions) => Promise<void>;
81
107
  /** Uploads a new file to the host */
82
108
  uploadFile: (file: File) => Promise<FileMetadata>;
83
109
  /**
@@ -90,12 +116,16 @@ type API<WidgetState extends UnknownObject> = {
90
116
  };
91
117
  export declare const SET_GLOBALS_EVENT_TYPE = "openai:set_globals";
92
118
  export declare class SetGlobalsEvent extends CustomEvent<{
93
- globals: Partial<OpenAiGlobals>;
119
+ globals: Partial<OpenAiProperties>;
94
120
  }> {
95
121
  readonly type = "openai:set_globals";
96
122
  }
97
123
  export type CallTool = (name: string, args: Record<string, unknown>) => Promise<CallToolResponse>;
98
- export type DisplayMode = "pip" | "inline" | "fullscreen";
124
+ export type DisplayMode = "pip" | "inline" | "fullscreen" | "modal";
125
+ export type View = {
126
+ mode: DisplayMode;
127
+ params?: Record<string, unknown>;
128
+ };
99
129
  export type Theme = "light" | "dark";
100
130
  export type SafeAreaInsets = {
101
131
  top: number;
@@ -1,3 +1,4 @@
1
+ import "react";
1
2
  export const TOOL_RESPONSE_EVENT_TYPE = "openai:tool_response";
2
3
  export class ToolResponseEvent extends CustomEvent {
3
4
  type = TOOL_RESPONSE_EVENT_TYPE;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/web/types.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,CAAC;AAyBf,MAAM,CAAC,MAAM,wBAAwB,GAAG,sBAAsB,CAAC;AAC/D,MAAM,OAAO,iBAAkB,SAAQ,WAErC;IACkB,IAAI,GAAG,wBAAwB,CAAC;CACnD;AAuGD,sDAAsD;AACtD,MAAM,CAAC,MAAM,sBAAsB,GAAG,oBAAoB,CAAC;AAC3D,MAAM,OAAO,eAAgB,SAAQ,WAEnC;IACkB,IAAI,GAAG,sBAAsB,CAAC;CACjD"}
package/package.json CHANGED
@@ -1,31 +1,25 @@
1
1
  {
2
2
  "name": "skybridge",
3
- "version": "0.0.0-dev.d8b52a9",
3
+ "version": "0.0.0-dev.d91f2cb",
4
4
  "description": "Skybridge is a framework for building ChatGPT apps",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/alpic-ai/skybridge.git"
8
+ },
5
9
  "type": "module",
6
10
  "files": [
7
11
  "dist"
8
12
  ],
9
13
  "exports": {
10
14
  "./server": {
11
- "types": "./dist/src/server/index.d.ts",
12
- "default": "./dist/src/server/index.js"
15
+ "types": "./dist/server/index.d.ts",
16
+ "default": "./dist/server/index.js"
13
17
  },
14
18
  "./web": {
15
- "types": "./dist/src/web/index.d.ts",
16
- "default": "./dist/src/web/index.js"
19
+ "types": "./dist/web/index.d.ts",
20
+ "default": "./dist/web/index.js"
17
21
  }
18
22
  },
19
- "scripts": {
20
- "build": "tsc && pnpm run build:templates",
21
- "build:templates": "cp -r src/server/templates dist/src/server/",
22
- "test": "pnpm run test:unit && pnpm run test:type",
23
- "test:unit": "vitest run --silent",
24
- "test:type": "tsc --noEmit",
25
- "docs:dev": "pnpm --filter @skybridge/docs start",
26
- "docs:build": "pnpm --filter @skybridge/docs build",
27
- "docs:serve": "pnpm --filter @skybridge/docs serve"
28
- },
29
23
  "keywords": [
30
24
  "chatgpt",
31
25
  "app",
@@ -35,31 +29,61 @@
35
29
  "author": "Frédéric Barthelet",
36
30
  "license": "ISC",
37
31
  "peerDependencies": {
32
+ "@modelcontextprotocol/sdk": ">=1.0.0",
38
33
  "react": ">=18.0.0",
39
34
  "react-dom": ">=18.0.0"
40
35
  },
41
36
  "dependencies": {
42
- "@modelcontextprotocol/sdk": "^1.20.0",
37
+ "@babel/core": "^7.28.5",
38
+ "@oclif/core": "^4.8.0",
43
39
  "cors": "^2.8.5",
44
- "express": "^5.1.0",
40
+ "dequal": "^2.0.3",
41
+ "es-toolkit": "^1.43.0",
42
+ "express": "^5.2.1",
45
43
  "handlebars": "^4.7.8",
46
- "vite": "^7.1.11",
47
- "zod": "^3.25.51"
44
+ "ink": "^6.6.0",
45
+ "superjson": "^2.2.6",
46
+ "vite": "^7.3.1",
47
+ "zustand": "^5.0.9"
48
48
  },
49
49
  "devDependencies": {
50
+ "@modelcontextprotocol/ext-apps": "^0.2.2",
51
+ "@modelcontextprotocol/sdk": "^1.25.2",
50
52
  "@testing-library/dom": "^10.4.1",
51
- "@testing-library/react": "^16.3.0",
53
+ "@testing-library/react": "^16.3.1",
52
54
  "@total-typescript/tsconfig": "^1.0.4",
55
+ "@types/babel__core": "^7.20.5",
53
56
  "@types/cors": "^2.8.19",
54
- "@types/express": "^5.0.3",
55
- "@types/jsdom": "^21.1.6",
56
- "@types/node": "^22.15.30",
57
- "@types/react": "^19.2.2",
58
- "@types/react-dom": "^19.2.2",
59
- "@vitest/ui": "^2.1.8",
60
- "jsdom": "^25.0.1",
57
+ "@types/express": "^5.0.6",
58
+ "@types/jsdom": "^27.0.0",
59
+ "@types/node": "^24.10.4",
60
+ "@types/react": "^19.2.7",
61
+ "@types/react-dom": "^19.2.3",
62
+ "@vitest/ui": "^4.0.16",
63
+ "jsdom": "^27.4.0",
64
+ "shx": "^0.3.4",
65
+ "ts-node": "^10.9.2",
61
66
  "typescript": "^5.9.3",
62
- "vitest": "^2.1.8"
67
+ "vitest": "^4.0.16",
68
+ "zod": "^4.3.5"
63
69
  },
64
- "packageManager": "pnpm@10.17.1"
65
- }
70
+ "bin": {
71
+ "sb": "./bin/run.js",
72
+ "skybridge": "./bin/run.js"
73
+ },
74
+ "oclif": {
75
+ "bin": "skybridge",
76
+ "commands": "./dist/commands",
77
+ "dirname": "skybridge",
78
+ "topicSeparator": " "
79
+ },
80
+ "scripts": {
81
+ "build": "shx rm -rf dist && tsc && pnpm run build:templates",
82
+ "build:templates": "cp -r src/server/templates dist/server/",
83
+ "format": "biome check --write --error-on-warnings",
84
+ "test": "pnpm run test:unit && pnpm run test:type && pnpm run test:format",
85
+ "test:unit": "vitest run",
86
+ "test:type": "tsc --noEmit",
87
+ "test:format": "biome ci"
88
+ }
89
+ }
package/README.md DELETED
@@ -1,323 +0,0 @@
1
- <div align="center">
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)
8
-
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)
12
-
13
- </div>
14
-
15
- Skybridge comes with 2 packages:
16
-
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.
19
-
20
- ## Quick start
21
-
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.
23
-
24
- ## Installation
25
-
26
- ```bash
27
- pnpm add skybridge
28
- ```
29
-
30
- ## Concepts
31
-
32
- ### Widgets
33
-
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.
35
-
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.
37
-
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:
39
-
40
- _Project structure_
41
-
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
- ```
51
-
52
- _server/src/index.ts_
53
-
54
- ```ts
55
- import { McpServer } from "skybridge/server";
56
-
57
- const server = new McpServer();
58
-
59
- server.widget(
60
- "pokemon"
61
- // Remaining arguments...
62
- );
63
- ```
64
-
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
- };
73
-
74
- mountWidget(<Pokemon />);
75
- ```
76
-
77
- ## Packages
78
-
79
- ### skybridge/server
80
-
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.
82
-
83
- ### skybridge/web
84
-
85
- The `skybridge/web` package is a react library with hooks and components to build widgets on the underlying _OpenAI iFrame skybridge_ runtime.
86
-
87
- **Vite plugin**
88
-
89
- The `skybridge/web` package comes with a Vite plugin that allows you to build your widgets as regular Vite apps.
90
-
91
- ```ts
92
- import { defineConfig } from "vite";
93
- import { skybridge } from "skybridge/web";
94
-
95
- export default defineConfig({
96
- plugins: [skybridge()],
97
- });
98
- ```
99
-
100
- **Typed Hooks**
101
-
102
- Skybridge provides fully typed hooks that give you autocomplete for tool names and type inference for inputs/outputs - similar to tRPC. This is opt-in and requires exporting your server type.
103
-
104
- > **Tip:** For the best TypeScript experience, use typed hooks throughout your application. They provide autocomplete, type safety, and better IDE support.
105
-
106
- _Server setup (server/src/index.ts)_
107
-
108
- ```ts
109
- import { McpServer } from "skybridge/server";
110
- import { z } from "zod";
111
-
112
- const server = new McpServer({ name: "my-app", version: "1.0" }, {})
113
- .widget("search-voyage", {}, {
114
- description: "Search for trips",
115
- inputSchema: {
116
- destination: z.string(),
117
- departureDate: z.string().optional(),
118
- },
119
- outputSchema: {
120
- results: z.array(z.object({ id: z.string(), name: z.string() })),
121
- totalCount: z.number(),
122
- },
123
- }, async ({ destination }) => {
124
- // Your tool logic here...
125
- return { content: [{ type: "text", text: `Found trips to ${destination}` }] };
126
- })
127
- .widget("get-details", {}, {
128
- inputSchema: { tripId: z.string() },
129
- }, async ({ tripId }) => {
130
- return { content: [{ type: "text", text: `Details for ${tripId}` }] };
131
- });
132
-
133
- // Export the server type for the client
134
- export type AppType = typeof server;
135
- ```
136
-
137
- _One-time setup (web/src/skybridge.ts)_
138
-
139
- Create typed hooks once and export them for use across your app. This file acts as a bridge between your server types and your widgets:
140
-
141
- ```ts
142
- import type { AppType } from "../server"; // type-only import
143
- import { createTypedHooks } from "skybridge/web";
144
-
145
- export const { useCallTool, useToolInfo } = createTypedHooks<AppType>();
146
- ```
147
-
148
- _Usage in widgets (web/src/widgets/search.tsx)_
149
-
150
- ```tsx
151
- import { useCallTool, useToolInfo } from "../skybridge"; // import typed hooks
152
-
153
- export function SearchWidget() {
154
- const { callTool, data, isPending } = useCallTool("search-voyage");
155
- // ^ autocomplete for tool names
156
- const toolInfo = useToolInfo<"search-voyage">();
157
- // ^ autocomplete for widget names
158
-
159
- const handleSearch = () => {
160
- callTool({ destination: "Spain" });
161
- // ^ autocomplete for input fields
162
- };
163
-
164
- return (
165
- <div>
166
- <button onClick={handleSearch} disabled={isPending}>
167
- Search
168
- </button>
169
- {toolInfo.isSuccess && (
170
- <div>Found {toolInfo.output.totalCount} results</div>
171
- // ^ typed output
172
- )}
173
- </div>
174
- );
175
- }
176
- ```
177
-
178
- **Hooks**
179
-
180
- The `skybridge/web` package comes with a set of hooks to help you build your widgets :
181
-
182
- - `useOpenAiGlobal`: A generic hook to get any global data from the OpenAI iFrame skybridge runtime (in `window.openai`).
183
- - `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.
184
- - `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.
185
- - `useToolInfo`: A hook to get the tool input, output, and response metadata with type inference. Provides a discriminated union based on status (pending/success).
186
- - `useCallTool`: A @tanstack/react-query inspired hook to send make additional tool calls inside a widget.
187
- - `createTypedHooks`: A factory that creates typed versions of `useCallTool` and `useToolInfo` with full type inference from your server type.
188
-
189
- _useOpenAiGlobal_
190
-
191
- ```ts
192
- import { useOpenAiGlobal } from "skybridge/web";
193
-
194
- const theme = useOpenAiGlobal("theme");
195
- ```
196
-
197
- _useToolOutput_
198
-
199
- ```ts
200
- import { useToolOutput } from "skybridge/web";
201
-
202
- const toolOutput = useToolOutput();
203
- ```
204
-
205
- _useToolResponseMetadata_
206
-
207
- ```ts
208
- import { useToolResponseMetadata } from "skybridge/web";
209
-
210
- const toolResponseMetadata = useToolResponseMetadata();
211
- ```
212
-
213
- _useToolInfo_
214
-
215
- ```ts
216
- import { useToolInfo } from "skybridge/web";
217
-
218
- const toolInfo = useToolInfo<{
219
- input: { query: string };
220
- output: { results: string[] };
221
- responseMetadata: { id: number };
222
- }>();
223
-
224
- // toolInfo.input is typed based on the input type
225
- // toolInfo.output is typed based on the output type (undefined when pending)
226
- // toolInfo.status narrows correctly: "pending" | "success"
227
-
228
- if (toolInfo.isPending) {
229
- // toolInfo.output is undefined here
230
- console.log(toolInfo.input.query);
231
- }
232
-
233
- if (toolInfo.isSuccess) {
234
- // toolInfo.output is typed here
235
- console.log(toolInfo.output.results);
236
- }
237
- ```
238
-
239
- _useToolInfo_ with typed hooks (recommended)
240
-
241
- ```tsx
242
- import { useToolInfo } from "../skybridge"; // import typed hooks
243
-
244
- export function SearchWidget() {
245
- const toolInfo = useToolInfo<"search-voyage">();
246
- // ^ autocomplete for widget names
247
- // toolInfo.input is typed as { destination: string; departureDate?: string; ... }
248
- // toolInfo.output is typed as { results: Array<...>; totalCount: number; } | undefined
249
-
250
- if (toolInfo.isSuccess) {
251
- return <div>Found {toolInfo.output.totalCount} results</div>;
252
- }
253
-
254
- return <div>Searching for {toolInfo.input.destination}...</div>;
255
- }
256
- ```
257
-
258
- _useCallTool_ in synchronous mode
259
-
260
- ```ts
261
- import { useCallTool } from "skybridge/web";
262
-
263
- export const TestTool: React.FunctionComponent = () => {
264
- const { callTool, isPending } = useCallTool("myToolName");
265
-
266
- return (
267
- <div>
268
- <button
269
- disabled={isPending}
270
- onClick={() => {
271
- callTool({ input: "test input" }, {
272
- onSuccess: (data) => {
273
- alert("Tool returned: " + data);
274
- },
275
- });
276
- >
277
- Call Tool inside a widget
278
- </button>
279
- </div>
280
- );
281
- };
282
- ```
283
-
284
- _useCallTool_ in asynchronous mode
285
-
286
- ```ts
287
- import { useCallTool } from "skybridge/web";
288
-
289
- export const TestTool: React.FunctionComponent = () => {
290
- const { callToolAsync, isPending } = useCallTool("myToolName");
291
-
292
- return (
293
- <div>
294
- <button
295
- disabled={isPending}
296
- onClick={async () => {
297
- const data = await callToolAsync({ input: "test input" });
298
- alert("Tool returned: " + data);
299
- }}
300
- >
301
- Call Tool inside a widget
302
- </button>
303
- </div>
304
- );
305
- };
306
- ```
307
-
308
- ## Migrate your existing MCP server to a ChatGPT app
309
-
310
- If you're already using the `@modelcontextprotocol/sdk` to build a MCP server, you can migrate to a ChatGPT app by following these steps:
311
-
312
- 1. Replace your `McpServer` import from `@modelcontextprotocol/sdk` with the same import from `skybridge/server`
313
- 2. Create a new vite project in a folder named `web` and install the `skybridge` package
314
- 3. Replace the `vite.config.ts` file with the following:
315
-
316
- ```ts
317
- import { defineConfig } from "vite";
318
- import { skybridge } from "skybridge/web";
319
-
320
- export default defineConfig({
321
- plugins: [skybridge()],
322
- });
323
- ```
@@ -1,4 +0,0 @@
1
- export { McpServer } from "./server.js";
2
- export { widgetsDevServer } from "./widgetsDevServer.js";
3
- export type { WidgetDef } from "./server.js";
4
- export type { InferWidgets, AnyWidgetRegistry, WidgetNames, WidgetInput, WidgetOutput, } from "./inferUtilityTypes.js";
@@ -1 +0,0 @@
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,44 +0,0 @@
1
- import type { McpServer, WidgetDef } from "./server.js";
2
- /**
3
- * Any widget registry shape.
4
- * Used as a constraint for type parameters that accept widget registries.
5
- */
6
- export type AnyWidgetRegistry = Record<string, WidgetDef>;
7
- /**
8
- * Extract the widget registry type from an McpServer instance.
9
- *
10
- * @example
11
- * ```ts
12
- * type MyWidgets = InferWidgets<MyServer>;
13
- * // { "search": WidgetDef<...>, "details": WidgetDef<...> }
14
- * ```
15
- */
16
- export type InferWidgets<T> = T extends McpServer<infer W extends AnyWidgetRegistry> ? W : T extends McpServer<any> ? never : never;
17
- /**
18
- * Get a union of all widget names from an McpServer instance.
19
- *
20
- * @example
21
- * ```ts
22
- * type Names = WidgetNames<MyServer>;
23
- * // "search" | "details" | "profile"
24
- * ```
25
- */
26
- export type WidgetNames<T> = keyof InferWidgets<T> & string;
27
- /**
28
- * Get the input type for a specific widget.
29
- *
30
- * @example
31
- * ```ts
32
- * type SearchInput = WidgetInput<MyServer, "search">;
33
- * ```
34
- */
35
- export type WidgetInput<T, K extends WidgetNames<T>> = InferWidgets<T>[K]["input"];
36
- /**
37
- * Get the output type for a specific widget.
38
- *
39
- * @example
40
- * ```ts
41
- * type SearchOutput = WidgetOutput<MyServer, "search">;
42
- * ```
43
- */
44
- export type WidgetOutput<T, K extends WidgetNames<T>> = InferWidgets<T>[K]["output"];
@@ -1 +0,0 @@
1
- {"version":3,"file":"inferUtilityTypes.js","sourceRoot":"","sources":["../../../src/server/inferUtilityTypes.ts"],"names":[],"mappings":""}
@@ -1,19 +0,0 @@
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, ZodObject, infer as Infer } from "zod";
4
- export type WidgetDef<TInput = unknown, TOutput = unknown> = {
5
- input: TInput;
6
- output: TOutput;
7
- };
8
- type McpServerOriginalResourceConfig = Omit<Resource, "uri" | "name" | "mimeType">;
9
- type McpServerOriginalToolConfig = Omit<Parameters<McpServerBase["registerTool"]>[1], "inputSchema" | "outputSchema">;
10
- export declare class McpServer<TWidgets extends Record<string, WidgetDef> = {}> extends McpServerBase {
11
- widget<TName extends string, TInput extends ZodRawShape, TOutput extends ZodRawShape = {}>(name: TName, resourceConfig: McpServerOriginalResourceConfig, toolConfig: McpServerOriginalToolConfig & {
12
- inputSchema?: TInput;
13
- outputSchema?: TOutput;
14
- }, toolCallback: ToolCallback<TInput>): McpServer<TWidgets & {
15
- [K in TName]: WidgetDef<Infer<ZodObject<TInput>>, Infer<ZodObject<TOutput>>>;
16
- }>;
17
- private lookupDistFile;
18
- }
19
- export {};