skybridge 0.0.0-dev.d798b8b → 0.0.0-dev.d7d9ce9

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 (273) hide show
  1. package/LICENSE +21 -674
  2. package/bin/run.js +5 -0
  3. package/dist/cli/header.d.ts +4 -0
  4. package/dist/cli/header.js +6 -0
  5. package/dist/cli/header.js.map +1 -0
  6. package/dist/cli/run-command.d.ts +2 -0
  7. package/dist/cli/run-command.js +43 -0
  8. package/dist/cli/run-command.js.map +1 -0
  9. package/dist/cli/telemetry.d.ts +7 -0
  10. package/dist/cli/telemetry.js +123 -0
  11. package/dist/cli/telemetry.js.map +1 -0
  12. package/dist/cli/use-execute-steps.d.ts +10 -0
  13. package/dist/cli/use-execute-steps.js +31 -0
  14. package/dist/cli/use-execute-steps.js.map +1 -0
  15. package/dist/commands/build.d.ts +9 -0
  16. package/dist/commands/build.js +44 -0
  17. package/dist/commands/build.js.map +1 -0
  18. package/dist/commands/dev.d.ts +9 -0
  19. package/dist/commands/dev.js +32 -0
  20. package/dist/commands/dev.js.map +1 -0
  21. package/dist/commands/start.d.ts +7 -0
  22. package/dist/commands/start.js +33 -0
  23. package/dist/commands/start.js.map +1 -0
  24. package/dist/commands/telemetry/disable.d.ts +5 -0
  25. package/dist/commands/telemetry/disable.js +14 -0
  26. package/dist/commands/telemetry/disable.js.map +1 -0
  27. package/dist/commands/telemetry/enable.d.ts +5 -0
  28. package/dist/commands/telemetry/enable.js +14 -0
  29. package/dist/commands/telemetry/enable.js.map +1 -0
  30. package/dist/commands/telemetry/status.d.ts +5 -0
  31. package/dist/commands/telemetry/status.js +14 -0
  32. package/dist/commands/telemetry/status.js.map +1 -0
  33. package/dist/server/index.d.ts +4 -0
  34. package/dist/server/index.js.map +1 -0
  35. package/dist/server/inferUtilityTypes.d.ts +64 -0
  36. package/dist/server/inferUtilityTypes.js +2 -0
  37. package/dist/server/inferUtilityTypes.js.map +1 -0
  38. package/dist/server/server.d.ts +99 -0
  39. package/dist/server/server.js +139 -0
  40. package/dist/server/server.js.map +1 -0
  41. package/dist/server/templateHelper.d.ts +18 -0
  42. package/dist/{src/server → server}/templateHelper.js +5 -12
  43. package/dist/server/templateHelper.js.map +1 -0
  44. package/dist/server/templates/development.hbs +66 -0
  45. package/dist/server/templates/production.hbs +7 -0
  46. package/dist/{src/server → server}/widgetsDevServer.d.ts +2 -2
  47. package/dist/{src/server → server}/widgetsDevServer.js +13 -5
  48. package/dist/server/widgetsDevServer.js.map +1 -0
  49. package/dist/test/utils.d.ts +135 -0
  50. package/dist/test/utils.js +242 -0
  51. package/dist/test/utils.js.map +1 -0
  52. package/dist/test/widget.test.js +255 -0
  53. package/dist/test/widget.test.js.map +1 -0
  54. package/dist/web/bridges/apps-sdk/adaptor.d.ts +22 -0
  55. package/dist/web/bridges/apps-sdk/adaptor.js +64 -0
  56. package/dist/web/bridges/apps-sdk/adaptor.js.map +1 -0
  57. package/dist/web/bridges/apps-sdk/bridge.d.ts +10 -0
  58. package/dist/web/bridges/apps-sdk/bridge.js +46 -0
  59. package/dist/web/bridges/apps-sdk/bridge.js.map +1 -0
  60. package/dist/web/bridges/apps-sdk/index.d.ts +5 -0
  61. package/dist/web/bridges/apps-sdk/index.js +5 -0
  62. package/dist/web/bridges/apps-sdk/index.js.map +1 -0
  63. package/dist/{src/web → web/bridges/apps-sdk}/types.d.ts +48 -36
  64. package/dist/web/bridges/apps-sdk/types.js.map +1 -0
  65. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.d.ts +2 -0
  66. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js +7 -0
  67. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js.map +1 -0
  68. package/dist/web/bridges/get-adaptor.d.ts +2 -0
  69. package/dist/web/bridges/get-adaptor.js +8 -0
  70. package/dist/web/bridges/get-adaptor.js.map +1 -0
  71. package/dist/web/bridges/index.d.ts +5 -0
  72. package/dist/web/bridges/index.js +6 -0
  73. package/dist/web/bridges/index.js.map +1 -0
  74. package/dist/web/bridges/mcp-app/adaptor.d.ts +36 -0
  75. package/dist/web/bridges/mcp-app/adaptor.js +185 -0
  76. package/dist/web/bridges/mcp-app/adaptor.js.map +1 -0
  77. package/dist/web/bridges/mcp-app/bridge.d.ts +43 -0
  78. package/dist/web/bridges/mcp-app/bridge.js +255 -0
  79. package/dist/web/bridges/mcp-app/bridge.js.map +1 -0
  80. package/dist/web/bridges/mcp-app/index.d.ts +4 -0
  81. package/dist/web/bridges/mcp-app/index.js +4 -0
  82. package/dist/web/bridges/mcp-app/index.js.map +1 -0
  83. package/dist/web/bridges/mcp-app/types.d.ts +8 -0
  84. package/dist/web/bridges/mcp-app/types.js +2 -0
  85. package/dist/web/bridges/mcp-app/types.js.map +1 -0
  86. package/dist/web/bridges/mcp-app/use-mcp-app-context.d.ts +5 -0
  87. package/dist/web/bridges/mcp-app/use-mcp-app-context.js +7 -0
  88. package/dist/web/bridges/mcp-app/use-mcp-app-context.js.map +1 -0
  89. package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js +66 -0
  90. package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js.map +1 -0
  91. package/dist/web/bridges/types.d.ts +98 -0
  92. package/dist/web/bridges/types.js +2 -0
  93. package/dist/web/bridges/types.js.map +1 -0
  94. package/dist/web/bridges/use-host-context.d.ts +2 -0
  95. package/dist/web/bridges/use-host-context.js +8 -0
  96. package/dist/web/bridges/use-host-context.js.map +1 -0
  97. package/dist/web/components/modal-provider.d.ts +4 -0
  98. package/dist/web/components/modal-provider.js +47 -0
  99. package/dist/web/components/modal-provider.js.map +1 -0
  100. package/dist/web/create-store.d.ts +3 -0
  101. package/dist/web/create-store.js +24 -0
  102. package/dist/web/create-store.js.map +1 -0
  103. package/dist/web/create-store.test.js +126 -0
  104. package/dist/web/create-store.test.js.map +1 -0
  105. package/dist/web/data-llm.d.ts +14 -0
  106. package/dist/web/data-llm.js +72 -0
  107. package/dist/web/data-llm.js.map +1 -0
  108. package/dist/web/data-llm.test.d.ts +1 -0
  109. package/dist/web/data-llm.test.js +139 -0
  110. package/dist/web/data-llm.test.js.map +1 -0
  111. package/dist/web/generate-helpers.d.ts +116 -0
  112. package/dist/web/generate-helpers.js +111 -0
  113. package/dist/web/generate-helpers.js.map +1 -0
  114. package/dist/web/generate-helpers.test-d.d.ts +1 -0
  115. package/dist/web/generate-helpers.test-d.js +209 -0
  116. package/dist/web/generate-helpers.test-d.js.map +1 -0
  117. package/dist/web/generate-helpers.test.d.ts +1 -0
  118. package/dist/web/generate-helpers.test.js +17 -0
  119. package/dist/web/generate-helpers.test.js.map +1 -0
  120. package/dist/web/helpers/state.d.ts +7 -0
  121. package/dist/web/helpers/state.js +45 -0
  122. package/dist/web/helpers/state.js.map +1 -0
  123. package/dist/web/helpers/state.test.d.ts +1 -0
  124. package/dist/web/helpers/state.test.js +53 -0
  125. package/dist/web/helpers/state.test.js.map +1 -0
  126. package/dist/web/hooks/index.d.ts +11 -0
  127. package/dist/web/hooks/index.js +12 -0
  128. package/dist/web/hooks/index.js.map +1 -0
  129. package/dist/web/hooks/test/utils.d.ts +16 -0
  130. package/dist/web/hooks/test/utils.js +60 -0
  131. package/dist/web/hooks/test/utils.js.map +1 -0
  132. package/dist/web/hooks/use-call-tool.d.ts +101 -0
  133. package/dist/web/hooks/use-call-tool.js +68 -0
  134. package/dist/web/hooks/use-call-tool.js.map +1 -0
  135. package/dist/web/hooks/use-call-tool.test-d.d.ts +1 -0
  136. package/dist/web/hooks/use-call-tool.test-d.js +104 -0
  137. package/dist/web/hooks/use-call-tool.test-d.js.map +1 -0
  138. package/dist/web/hooks/use-call-tool.test.d.ts +1 -0
  139. package/dist/web/hooks/use-call-tool.test.js +190 -0
  140. package/dist/web/hooks/use-call-tool.test.js.map +1 -0
  141. package/dist/web/hooks/use-display-mode.d.ts +4 -0
  142. package/dist/web/hooks/use-display-mode.js +9 -0
  143. package/dist/web/hooks/use-display-mode.js.map +1 -0
  144. package/dist/web/hooks/use-display-mode.test.d.ts +1 -0
  145. package/dist/web/hooks/use-display-mode.test.js +41 -0
  146. package/dist/web/hooks/use-display-mode.test.js.map +1 -0
  147. package/dist/web/hooks/use-files.d.ts +6 -0
  148. package/dist/web/hooks/use-files.js +9 -0
  149. package/dist/web/hooks/use-files.js.map +1 -0
  150. package/dist/web/hooks/use-files.test.d.ts +1 -0
  151. package/dist/web/hooks/use-files.test.js +30 -0
  152. package/dist/web/hooks/use-files.test.js.map +1 -0
  153. package/dist/web/hooks/use-layout.d.ts +22 -0
  154. package/dist/web/hooks/use-layout.js +23 -0
  155. package/dist/web/hooks/use-layout.js.map +1 -0
  156. package/dist/web/hooks/use-layout.test.d.ts +1 -0
  157. package/dist/web/hooks/use-layout.test.js +96 -0
  158. package/dist/web/hooks/use-layout.test.js.map +1 -0
  159. package/dist/web/hooks/use-open-external.d.ts +1 -0
  160. package/dist/web/hooks/use-open-external.js +8 -0
  161. package/dist/web/hooks/use-open-external.js.map +1 -0
  162. package/dist/web/hooks/use-open-external.test.d.ts +1 -0
  163. package/dist/web/hooks/use-open-external.test.js +50 -0
  164. package/dist/web/hooks/use-open-external.test.js.map +1 -0
  165. package/dist/web/hooks/use-request-modal.d.ts +9 -0
  166. package/dist/web/hooks/use-request-modal.js +16 -0
  167. package/dist/web/hooks/use-request-modal.js.map +1 -0
  168. package/dist/web/hooks/use-request-modal.test.d.ts +1 -0
  169. package/dist/web/hooks/use-request-modal.test.js +57 -0
  170. package/dist/web/hooks/use-request-modal.test.js.map +1 -0
  171. package/dist/web/hooks/use-send-follow-up-message.d.ts +1 -0
  172. package/dist/web/hooks/use-send-follow-up-message.js +8 -0
  173. package/dist/web/hooks/use-send-follow-up-message.js.map +1 -0
  174. package/dist/web/hooks/use-set-open-in-app-url.d.ts +1 -0
  175. package/dist/web/hooks/use-set-open-in-app-url.js +8 -0
  176. package/dist/web/hooks/use-set-open-in-app-url.js.map +1 -0
  177. package/dist/web/hooks/use-set-open-in-app-url.test.d.ts +1 -0
  178. package/dist/web/hooks/use-set-open-in-app-url.test.js +49 -0
  179. package/dist/web/hooks/use-set-open-in-app-url.test.js.map +1 -0
  180. package/dist/web/hooks/use-tool-info.d.ts +36 -0
  181. package/dist/web/hooks/use-tool-info.js +26 -0
  182. package/dist/web/hooks/use-tool-info.js.map +1 -0
  183. package/dist/web/hooks/use-tool-info.test-d.d.ts +1 -0
  184. package/dist/web/hooks/use-tool-info.test-d.js +109 -0
  185. package/dist/web/hooks/use-tool-info.test-d.js.map +1 -0
  186. package/dist/web/hooks/use-tool-info.test.d.ts +1 -0
  187. package/dist/web/hooks/use-tool-info.test.js +130 -0
  188. package/dist/web/hooks/use-tool-info.test.js.map +1 -0
  189. package/dist/web/hooks/use-user.d.ts +18 -0
  190. package/dist/web/hooks/use-user.js +19 -0
  191. package/dist/web/hooks/use-user.js.map +1 -0
  192. package/dist/web/hooks/use-user.test.d.ts +1 -0
  193. package/dist/web/hooks/use-user.test.js +94 -0
  194. package/dist/web/hooks/use-user.test.js.map +1 -0
  195. package/dist/web/hooks/use-widget-state.d.ts +4 -0
  196. package/dist/web/hooks/use-widget-state.js +32 -0
  197. package/dist/web/hooks/use-widget-state.js.map +1 -0
  198. package/dist/web/hooks/use-widget-state.test.d.ts +1 -0
  199. package/dist/web/hooks/use-widget-state.test.js +61 -0
  200. package/dist/web/hooks/use-widget-state.test.js.map +1 -0
  201. package/dist/web/index.d.ts +8 -0
  202. package/dist/web/index.js +9 -0
  203. package/dist/web/index.js.map +1 -0
  204. package/dist/web/mount-widget.js +27 -0
  205. package/dist/web/mount-widget.js.map +1 -0
  206. package/dist/web/plugin/data-llm.test.d.ts +1 -0
  207. package/dist/web/plugin/data-llm.test.js +81 -0
  208. package/dist/web/plugin/data-llm.test.js.map +1 -0
  209. package/dist/web/plugin/plugin.js +39 -0
  210. package/dist/web/plugin/plugin.js.map +1 -0
  211. package/dist/web/plugin/transform-data-llm.d.ts +12 -0
  212. package/dist/web/plugin/transform-data-llm.js +96 -0
  213. package/dist/web/plugin/transform-data-llm.js.map +1 -0
  214. package/dist/web/plugin/transform-data-llm.test.d.ts +1 -0
  215. package/dist/web/plugin/transform-data-llm.test.js +81 -0
  216. package/dist/web/plugin/transform-data-llm.test.js.map +1 -0
  217. package/dist/web/proxy.d.ts +1 -0
  218. package/dist/web/proxy.js +53 -0
  219. package/dist/web/proxy.js.map +1 -0
  220. package/dist/web/types.d.ts +16 -0
  221. package/dist/web/types.js +2 -0
  222. package/dist/web/types.js.map +1 -0
  223. package/package.json +62 -27
  224. package/README.md +0 -126
  225. package/dist/src/server/index.d.ts +0 -2
  226. package/dist/src/server/index.js.map +0 -1
  227. package/dist/src/server/server.d.ts +0 -12
  228. package/dist/src/server/server.js +0 -45
  229. package/dist/src/server/server.js.map +0 -1
  230. package/dist/src/server/templateHelper.d.ts +0 -14
  231. package/dist/src/server/templateHelper.js.map +0 -1
  232. package/dist/src/server/templates/development.hbs +0 -11
  233. package/dist/src/server/templates/production.hbs +0 -5
  234. package/dist/src/server/widgetsDevServer.js.map +0 -1
  235. package/dist/src/test/setup.js +0 -9
  236. package/dist/src/test/setup.js.map +0 -1
  237. package/dist/src/test/utils.d.ts +0 -28
  238. package/dist/src/test/utils.js +0 -43
  239. package/dist/src/test/utils.js.map +0 -1
  240. package/dist/src/test/widget.test.js +0 -69
  241. package/dist/src/test/widget.test.js.map +0 -1
  242. package/dist/src/web/index.d.ts +0 -7
  243. package/dist/src/web/index.js +0 -8
  244. package/dist/src/web/index.js.map +0 -1
  245. package/dist/src/web/mount-widget.js +0 -14
  246. package/dist/src/web/mount-widget.js.map +0 -1
  247. package/dist/src/web/plugin.js +0 -30
  248. package/dist/src/web/plugin.js.map +0 -1
  249. package/dist/src/web/types.js.map +0 -1
  250. package/dist/src/web/use-call-tool.d.ts +0 -54
  251. package/dist/src/web/use-call-tool.js +0 -67
  252. package/dist/src/web/use-call-tool.js.map +0 -1
  253. package/dist/src/web/use-call-tool.test.js +0 -66
  254. package/dist/src/web/use-call-tool.test.js.map +0 -1
  255. package/dist/src/web/use-openai-global.d.ts +0 -2
  256. package/dist/src/web/use-openai-global.js +0 -21
  257. package/dist/src/web/use-openai-global.js.map +0 -1
  258. package/dist/src/web/use-tool-output.d.ts +0 -3
  259. package/dist/src/web/use-tool-output.js +0 -5
  260. package/dist/src/web/use-tool-output.js.map +0 -1
  261. package/dist/src/web/use-tool-response-metadata.d.ts +0 -3
  262. package/dist/src/web/use-tool-response-metadata.js +0 -5
  263. package/dist/src/web/use-tool-response-metadata.js.map +0 -1
  264. package/dist/vitest.config.d.ts +0 -2
  265. package/dist/vitest.config.js +0 -9
  266. package/dist/vitest.config.js.map +0 -1
  267. /package/dist/{src/server → server}/index.js +0 -0
  268. /package/dist/{src/test → test}/widget.test.d.ts +0 -0
  269. /package/dist/{src/web → web/bridges/apps-sdk}/types.js +0 -0
  270. /package/dist/{src/test/setup.d.ts → web/bridges/mcp-app/use-mcp-app-context.test.d.ts} +0 -0
  271. /package/dist/{src/web/use-call-tool.test.d.ts → web/create-store.test.d.ts} +0 -0
  272. /package/dist/{src/web → web}/mount-widget.d.ts +0 -0
  273. /package/dist/{src/web → web/plugin}/plugin.d.ts +0 -0
@@ -0,0 +1,53 @@
1
+ const colors = {
2
+ brand: "#6366f1",
3
+ info: "#22223b",
4
+ success: "#22c55e",
5
+ error: "#ef4444",
6
+ };
7
+ export function installOpenAILoggingProxy() {
8
+ if (typeof window === "undefined" || !window.openai) {
9
+ console.warn("[openai-proxy] window.openai not found, skipping proxy installation");
10
+ return;
11
+ }
12
+ const descriptor = Object.getOwnPropertyDescriptor(window, "openai");
13
+ if (descriptor?.configurable === false || descriptor?.writable === false) {
14
+ console.warn("[openai-proxy] window.openai is not configurable or writable, skipping proxy installation");
15
+ return;
16
+ }
17
+ const originalOpenAI = window.openai;
18
+ const handler = {
19
+ get(target, prop, receiver) {
20
+ const value = Reflect.get(target, prop, receiver);
21
+ if (typeof value !== "function") {
22
+ return value;
23
+ }
24
+ return (...args) => {
25
+ const methodName = String(prop);
26
+ console.group(`%c[openai] %cmethod %c${methodName}`, `color: ${colors.brand}; font-weight: normal`, `color: ${colors.info}; font-weight: normal`, `color: ${colors.success}`);
27
+ console.log("%c← args:", `color: ${colors.info}`, args);
28
+ const result = value.apply(target, args);
29
+ if (result && typeof result.then === "function") {
30
+ return result.then((resolved) => {
31
+ console.log("%c→ resolved:", `color: ${colors.success}`, resolved);
32
+ console.groupEnd();
33
+ return resolved;
34
+ }, (error) => {
35
+ console.error("%c→ rejected:", `color: ${colors.error}`, error);
36
+ console.groupEnd();
37
+ throw error;
38
+ });
39
+ }
40
+ console.log("%c→ returned:", `color: ${colors.success}`, result);
41
+ console.groupEnd();
42
+ return result;
43
+ };
44
+ },
45
+ set(target, prop, value, receiver) {
46
+ console.log(`%c[openai] %cupdate %c${String(prop)}`, `color: ${colors.brand}`, `color: ${colors.info}`, `color: ${colors.success}; font-weight: bold`, "←", value);
47
+ return Reflect.set(target, prop, value, receiver);
48
+ },
49
+ };
50
+ window.openai = new Proxy(originalOpenAI, handler);
51
+ console.log("%c[openai-proxy] %cInstalled logging proxy for window.openai", `color: ${colors.brand}`, `color: ${colors.info}`);
52
+ }
53
+ //# sourceMappingURL=proxy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proxy.js","sourceRoot":"","sources":["../../src/web/proxy.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG;IACb,KAAK,EAAE,SAAS;IAChB,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,SAAS;CACR,CAAC;AAEX,MAAM,UAAU,yBAAyB;IACvC,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QACpD,OAAO,CAAC,IAAI,CACV,qEAAqE,CACtE,CAAC;QACF,OAAO;IACT,CAAC;IAED,MAAM,UAAU,GAAG,MAAM,CAAC,wBAAwB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC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,KAAc,EAAE,EAAE;wBACjB,OAAO,CAAC,KAAK,CAAC,eAAe,EAAE,UAAU,MAAM,CAAC,KAAK,EAAE,EAAE,KAAK,CAAC,CAAC;wBAChE,OAAO,CAAC,QAAQ,EAAE,CAAC;wBACnB,MAAM,KAAK,CAAC;oBACd,CAAC,CACF,CAAC;gBACJ,CAAC;gBAED,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,MAAM,CAAC,OAAO,EAAE,EAAE,MAAM,CAAC,CAAC;gBACjE,OAAO,CAAC,QAAQ,EAAE,CAAC;gBAEnB,OAAO,MAAM,CAAC;YAChB,CAAC,CAAC;QACJ,CAAC;QAED,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ;YAC/B,OAAO,CAAC,GAAG,CACT,yBAAyB,MAAM,CAAC,IAAI,CAAC,EAAE,EACvC,UAAU,MAAM,CAAC,KAAK,EAAE,EACxB,UAAU,MAAM,CAAC,IAAI,EAAE,EACvB,UAAU,MAAM,CAAC,OAAO,qBAAqB,EAC7C,GAAG,EACH,KAAK,CACN,CAAC;YAEF,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;QACpD,CAAC;KACF,CAAC;IAEF,MAAM,CAAC,MAAM,GAAG,IAAI,KAAK,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAEnD,OAAO,CAAC,GAAG,CACT,8DAA8D,EAC9D,UAAU,MAAM,CAAC,KAAK,EAAE,EACxB,UAAU,MAAM,CAAC,IAAI,EAAE,CACxB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,16 @@
1
+ import "react";
2
+ declare module "react" {
3
+ interface HTMLAttributes<T> {
4
+ "data-llm"?: string;
5
+ }
6
+ }
7
+ export type UnknownObject = Record<string, unknown>;
8
+ export type Prettify<T> = {
9
+ [K in keyof T]: T[K];
10
+ } & {};
11
+ export type Objectify<T> = T & UnknownObject;
12
+ type RequiredKeys<T> = {
13
+ [K in keyof T]-?: Record<string, never> extends Pick<T, K> ? never : K;
14
+ }[keyof T];
15
+ export type HasRequiredKeys<T> = RequiredKeys<T> extends never ? false : true;
16
+ export {};
@@ -0,0 +1,2 @@
1
+ import "react";
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/web/types.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,CAAC"}
package/package.json CHANGED
@@ -1,26 +1,26 @@
1
1
  {
2
2
  "name": "skybridge",
3
- "version": "0.0.0-dev.d798b8b",
4
- "description": "Skybridge is a framework for building ChatGPT apps",
3
+ "version": "0.0.0-dev.d7d9ce9",
4
+ "description": "Skybridge is a framework for building ChatGPT and MCP Apps",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/alpic-ai/skybridge.git"
8
+ },
5
9
  "type": "module",
6
10
  "files": [
7
- "dist"
11
+ "dist",
12
+ "README.md"
8
13
  ],
9
14
  "exports": {
10
15
  "./server": {
11
- "types": "./dist/src/server/index.d.ts",
12
- "default": "./dist/src/server/index.js"
16
+ "types": "./dist/server/index.d.ts",
17
+ "default": "./dist/server/index.js"
13
18
  },
14
19
  "./web": {
15
- "types": "./dist/src/web/index.d.ts",
16
- "default": "./dist/src/web/index.js"
20
+ "types": "./dist/web/index.d.ts",
21
+ "default": "./dist/web/index.js"
17
22
  }
18
23
  },
19
- "scripts": {
20
- "build": "tsc && pnpm run build:templates",
21
- "build:templates": "cp -r src/server/templates dist/src/server/",
22
- "test": "vitest run --silent"
23
- },
24
24
  "keywords": [
25
25
  "chatgpt",
26
26
  "app",
@@ -30,31 +30,66 @@
30
30
  "author": "Frédéric Barthelet",
31
31
  "license": "ISC",
32
32
  "peerDependencies": {
33
+ "@modelcontextprotocol/sdk": ">=1.0.0",
33
34
  "react": ">=18.0.0",
34
35
  "react-dom": ">=18.0.0"
35
36
  },
36
37
  "dependencies": {
37
- "@modelcontextprotocol/sdk": "^1.20.0",
38
+ "@babel/core": "^7.28.6",
39
+ "@oclif/core": "^4.8.0",
40
+ "ci-info": "^4.3.1",
38
41
  "cors": "^2.8.5",
39
- "express": "^5.1.0",
42
+ "dequal": "^2.0.3",
43
+ "es-toolkit": "^1.43.0",
44
+ "express": "^5.2.1",
40
45
  "handlebars": "^4.7.8",
41
- "vite": "^7.1.11",
42
- "zod": "^3.25.51"
46
+ "ink": "^6.6.0",
47
+ "posthog-node": "^5.21.0",
48
+ "superjson": "^2.2.6",
49
+ "vite": "^7.3.1",
50
+ "zustand": "^5.0.10"
43
51
  },
44
52
  "devDependencies": {
53
+ "@modelcontextprotocol/ext-apps": "^0.4.0",
54
+ "@modelcontextprotocol/sdk": "^1.25.2",
45
55
  "@testing-library/dom": "^10.4.1",
46
- "@testing-library/react": "^16.3.0",
56
+ "@testing-library/react": "^16.3.1",
47
57
  "@total-typescript/tsconfig": "^1.0.4",
58
+ "@types/babel__core": "^7.20.5",
48
59
  "@types/cors": "^2.8.19",
49
- "@types/express": "^5.0.3",
50
- "@types/jsdom": "^21.1.6",
51
- "@types/node": "^22.15.30",
52
- "@types/react": "^19.2.2",
53
- "@types/react-dom": "^19.2.2",
54
- "@vitest/ui": "^2.1.8",
55
- "jsdom": "^25.0.1",
60
+ "@types/express": "^5.0.6",
61
+ "@types/jsdom": "^27.0.0",
62
+ "@types/node": "^24.10.8",
63
+ "@types/react": "^19.2.8",
64
+ "@types/react-dom": "^19.2.3",
65
+ "@vitest/ui": "^4.0.17",
66
+ "jsdom": "^27.4.0",
67
+ "shx": "^0.4.0",
68
+ "ts-node": "^10.9.2",
56
69
  "typescript": "^5.9.3",
57
- "vitest": "^2.1.8"
70
+ "vitest": "^4.0.17",
71
+ "zod": "^4.3.5"
72
+ },
73
+ "bin": {
74
+ "sb": "./bin/run.js",
75
+ "skybridge": "./bin/run.js"
58
76
  },
59
- "packageManager": "pnpm@10.17.1"
60
- }
77
+ "oclif": {
78
+ "bin": "skybridge",
79
+ "commands": "./dist/commands",
80
+ "dirname": "skybridge",
81
+ "topicSeparator": " ",
82
+ "hooks": {
83
+ "finally": "./dist/cli/telemetry"
84
+ }
85
+ },
86
+ "scripts": {
87
+ "build": "shx rm -rf dist && tsc && pnpm run build:templates",
88
+ "build:templates": "cp -r src/server/templates dist/server/",
89
+ "format": "biome check --write --error-on-warnings",
90
+ "test": "pnpm run test:unit && pnpm run test:type && pnpm run test:format",
91
+ "test:unit": "vitest run",
92
+ "test:type": "tsc --noEmit",
93
+ "test:format": "biome ci"
94
+ }
95
+ }
package/README.md DELETED
@@ -1,126 +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
- **Hooks**
101
-
102
- The `skybridge/web` package comes with a set of hooks to help you build your widgets.
103
-
104
- ```ts
105
- import { useToolOutput } from "skybridge/web";
106
-
107
- // Initial data returned by the tool invocation on structuredOutput
108
- const toolOutput = useToolOutput();
109
- ```
110
-
111
- ## Migrate your existing MCP server to a ChatGPT app
112
-
113
- If you're already using the `@modelcontextprotocol/sdk` to build a MCP server, you can migrate to a ChatGPT app by following these steps:
114
-
115
- 1. Replace your `McpServer` import from `@modelcontextprotocol/sdk` with the same import from `skybridge/server`
116
- 2. Create a new vite project in a folder named `web` and install the `skybridge` package
117
- 3. Replace the `vite.config.ts` file with the following:
118
-
119
- ```ts
120
- import { defineConfig } from "vite";
121
- import { skybridge } from "skybridge/web";
122
-
123
- export default defineConfig({
124
- plugins: [skybridge()],
125
- });
126
- ```
@@ -1,2 +0,0 @@
1
- export { McpServer } from "./server.js";
2
- export { widgetsDevServer } from "./widgetsDevServer.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,12 +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 } from "zod";
4
- 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;
11
- }
12
- export {};
@@ -1,45 +0,0 @@
1
- import { McpServer as McpServerBase, } from "@modelcontextprotocol/sdk/server/mcp.js";
2
- import { templateHelper } from "./templateHelper.js";
3
- export class McpServer extends McpServerBase {
4
- widget(name, resourceConfig, toolConfig, toolCallback) {
5
- const uri = `ui://widgets/${name}.html`;
6
- const resourceMetadata = { ...(resourceConfig._meta ?? {}) };
7
- if (toolConfig.description !== undefined) {
8
- resourceMetadata["openai/widgetDescription"] = toolConfig.description;
9
- }
10
- this.resource(name, uri, {
11
- ...resourceConfig,
12
- _meta: resourceMetadata,
13
- }, async (_uri, extra) => {
14
- const serverUrl = process.env.NODE_ENV === "production"
15
- ? `https://${extra?.requestInfo?.headers?.["x-forwarded-host"] ??
16
- extra?.requestInfo?.headers?.host}`
17
- : `http://localhost:3000`;
18
- const templateData = {
19
- serverUrl,
20
- widgetName: name,
21
- };
22
- const html = process.env.NODE_ENV === "production"
23
- ? templateHelper.renderProduction(templateData)
24
- : templateHelper.renderDevelopment(templateData);
25
- return {
26
- contents: [
27
- {
28
- uri,
29
- mimeType: "text/html+skybridge",
30
- text: html,
31
- },
32
- ],
33
- };
34
- });
35
- const toolMeta = {
36
- ...toolConfig._meta,
37
- "openai/outputTemplate": uri,
38
- };
39
- this.registerTool(name, {
40
- ...toolConfig,
41
- _meta: toolMeta,
42
- }, toolCallback);
43
- }
44
- }
45
- //# sourceMappingURL=server.js.map
@@ -1 +0,0 @@
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;AA4BrD,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,EAAE,GAAG,CAAC,cAAc,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE,CAAC;QAC3E,IAAI,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;YACzC,gBAAgB,CAAC,0BAA0B,CAAC,GAAG,UAAU,CAAC,WAAW,CAAC;QACxE,CAAC;QAED,IAAI,CAAC,QAAQ,CACX,IAAI,EACJ,GAAG,EACH;YACE,GAAG,cAAc;YACjB,KAAK,EAAE,gBAAgB;SACxB,EACD,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;YACpB,MAAM,SAAS,GACb,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;gBACnC,CAAC,CAAC,WACE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,kBAAkB,CAAC;oBACjD,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,IAC/B,EAAE;gBACJ,CAAC,CAAC,uBAAuB,CAAC;YAE9B,MAAM,YAAY,GAAG;gBACnB,SAAS;gBACT,UAAU,EAAE,IAAI;aACjB,CAAC;YAEF,MAAM,IAAI,GACR,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;gBACnC,CAAC,CAAC,cAAc,CAAC,gBAAgB,CAAC,YAAY,CAAC;gBAC/C,CAAC,CAAC,cAAc,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAC;YAErD,OAAO;gBACL,QAAQ,EAAE;oBACR;wBACE,GAAG;wBACH,QAAQ,EAAE,qBAAqB;wBAC/B,IAAI,EAAE,IAAI;qBACX;iBACF;aACF,CAAC;QACJ,CAAC,CACF,CAAC;QAEF,MAAM,QAAQ,GAAa;YACzB,GAAG,UAAU,CAAC,KAAK;YACnB,uBAAuB,EAAE,GAAG;SAC7B,CAAC;QAEF,IAAI,CAAC,YAAY,CACf,IAAI,EACJ;YACE,GAAG,UAAU;YACb,KAAK,EAAE,QAAQ;SAChB,EACD,YAAY,CACb,CAAC;IACJ,CAAC;CACF"}
@@ -1,14 +0,0 @@
1
- type TemplateData = {
2
- serverUrl: string;
3
- widgetName: string;
4
- };
5
- declare class TemplateHelper {
6
- private templateCache;
7
- private loadTemplate;
8
- renderProduction(data: TemplateData): string;
9
- renderDevelopment(data: TemplateData): string;
10
- renderViteClient(data: TemplateData): string;
11
- injectViteClient(html: string, data: TemplateData): string;
12
- }
13
- export declare const templateHelper: TemplateHelper;
14
- export {};
@@ -1 +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ClD,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;IAED,gBAAgB,CAAC,IAAkB;QACjC,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;QAClD,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;IAED,gBAAgB,CAAC,IAAY,EAAE,IAAkB;QAC/C,MAAM,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;QACrD,OAAO,gBAAgB,GAAG,IAAI,CAAC;IACjC,CAAC;CACF;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC"}
@@ -1,11 +0,0 @@
1
- <script type="module">
2
- import { injectIntoGlobalHook } from "{{serverUrl}}/@react-refresh";
3
- injectIntoGlobalHook(window); window.$RefreshReg$ = () => {};
4
- window.$RefreshSig$ = () => (type) => type;
5
- window.__vite_plugin_react_preamble_installed__ = true;
6
- </script>
7
- <script type="module" src="{{serverUrl}}/@vite/client"></script>
8
- <div id="root"></div>
9
- <script type="module">
10
- import('{{serverUrl}}/src/widgets/{{widgetName}}.tsx');
11
- </script>
@@ -1,5 +0,0 @@
1
- <div id="root"></div>
2
- <script type="module">
3
- import('{{serverUrl}}/assets/{{widgetName}}.js');
4
- </script>
5
- <link rel="stylesheet" crossorigin href="{{serverUrl}}/assets/style.css" />
@@ -1 +0,0 @@
1
- {"version":3,"file":"widgetsDevServer.js","sourceRoot":"","sources":["../../../src/server/widgetsDevServer.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EAAuB,MAAM,SAAS,CAAC;AACvD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,IAA6B,EAAE;IAClE,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAEhC,MAAM,EAAE,YAAY,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,GAChE,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC;IACvB,MAAM,aAAa,GAAG,sBAAsB,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAC5D,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;IAEnD,MAAM,YAAY,GAAG,MAAM,kBAAkB,CAC3C,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,EACzC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,gBAAgB,CAAC,EACvC,UAAU,CACX,CAAC;IAEF,+DAA+D;IAC/D,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,SAAS,EAAE,GAAG,YAAY,EAAE,MAAM,IAAI,EAAE,CAAC;IAEpE,MAAM,IAAI,GAAG,MAAM,YAAY,CAAC;QAC9B,GAAG,SAAS;QACZ,UAAU,EAAE,KAAK,EAAE,kFAAkF;QACrG,OAAO,EAAE,QAAQ;QACjB,MAAM,EAAE;YACN,YAAY,EAAE,IAAI;YAClB,cAAc,EAAE,IAAI;SACrB;QACD,IAAI,EAAE,UAAU;QAChB,YAAY,EAAE;YACZ,OAAO,EAAE,CAAC,OAAO,EAAE,kBAAkB,CAAC;SACvC;KACF,CAAC,CAAC;IAEH,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;IACnB,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAElC,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
@@ -1,9 +0,0 @@
1
- import { vi } from "vitest";
2
- // Mock console methods to avoid noise in tests
3
- global.console = {
4
- ...console,
5
- error: vi.fn(),
6
- warn: vi.fn(),
7
- log: vi.fn(),
8
- };
9
- //# sourceMappingURL=setup.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"setup.js","sourceRoot":"","sources":["../../../src/test/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE5B,+CAA+C;AAC/C,MAAM,CAAC,OAAO,GAAG;IACf,GAAG,OAAO;IACV,KAAK,EAAE,EAAE,CAAC,EAAE,EAAE;IACd,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE;IACb,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE;CACb,CAAC"}
@@ -1,28 +0,0 @@
1
- import { type MockInstance } from "vitest";
2
- import { McpServer } from "../server/server.js";
3
- /**
4
- * Creates a real McpServer instance for testing
5
- */
6
- export declare function createMockMcpServer(): {
7
- server: McpServer;
8
- mockResource: MockInstance<McpServer["resource"]>;
9
- mockRegisterTool: MockInstance<McpServer["registerTool"]>;
10
- };
11
- /**
12
- * Mock extra parameter for resource callback
13
- */
14
- export declare function createMockExtra(host: string): {
15
- requestInfo: {
16
- headers: {
17
- host: string;
18
- };
19
- };
20
- };
21
- /**
22
- * Sets up environment variables for testing
23
- */
24
- export declare function setTestEnv(env: Record<string, string>): void;
25
- /**
26
- * Resets environment variables
27
- */
28
- export declare function resetTestEnv(): void;
@@ -1,43 +0,0 @@
1
- import { vi } from "vitest";
2
- import { McpServer, McpServer as McpServerBase } from "../server/server.js";
3
- /**
4
- * Creates a real McpServer instance for testing
5
- */
6
- export function createMockMcpServer() {
7
- // Create a real McpServer instance
8
- const server = new McpServer({
9
- name: "alpic-openai-app",
10
- version: "0.0.1",
11
- }, { capabilities: {} });
12
- // Mock the underlying methods to track calls
13
- const mockResource = vi.spyOn(server, "resource");
14
- const mockRegisterTool = vi.spyOn(server, "registerTool");
15
- return {
16
- server,
17
- mockResource,
18
- mockRegisterTool,
19
- };
20
- }
21
- /**
22
- * Mock extra parameter for resource callback
23
- */
24
- export function createMockExtra(host) {
25
- return {
26
- requestInfo: {
27
- headers: { host },
28
- },
29
- };
30
- }
31
- /**
32
- * Sets up environment variables for testing
33
- */
34
- export function setTestEnv(env) {
35
- Object.assign(process.env, env);
36
- }
37
- /**
38
- * Resets environment variables
39
- */
40
- export function resetTestEnv() {
41
- delete process.env.NODE_ENV;
42
- }
43
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/test/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAqB,MAAM,QAAQ,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAE5E;;GAEG;AACH,MAAM,UAAU,mBAAmB;IAKjC,mCAAmC;IACnC,MAAM,MAAM,GAAG,IAAI,SAAS,CAC1B;QACE,IAAI,EAAE,kBAAkB;QACxB,OAAO,EAAE,OAAO;KACjB,EACD,EAAE,YAAY,EAAE,EAAE,EAAE,CACrB,CAAC;IAEF,6CAA6C;IAC7C,MAAM,YAAY,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAClD,MAAM,gBAAgB,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAE1D,OAAO;QACL,MAAM;QACN,YAAY;QACZ,gBAAgB;KACjB,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,OAAO;QACL,WAAW,EAAE;YACX,OAAO,EAAE,EAAE,IAAI,EAAE;SAClB;KACF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,GAA2B;IACpD,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAClC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY;IAC1B,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;AAC9B,CAAC"}
@@ -1,69 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach, afterEach, } from "vitest";
2
- import { McpServer } from "../server/server.js";
3
- import { createMockMcpServer, createMockExtra, setTestEnv, resetTestEnv, } from "./utils.js";
4
- describe("McpServer.widget", () => {
5
- let server;
6
- let mockResource;
7
- let mockRegisterTool;
8
- beforeEach(() => {
9
- ({ server, mockResource, mockRegisterTool } = createMockMcpServer());
10
- });
11
- afterEach(() => {
12
- vi.clearAllMocks();
13
- resetTestEnv();
14
- });
15
- it("should generate correct HTML for development mode", async () => {
16
- setTestEnv({ NODE_ENV: "development" });
17
- const mockToolCallback = vi.fn();
18
- const mockResourceConfig = { description: "Test widget" };
19
- const mockToolConfig = { description: "Test tool" };
20
- server.widget("my-widget", mockResourceConfig, mockToolConfig, mockToolCallback);
21
- // Get the resource callback function
22
- const resourceCallback = mockResource.mock.calls[0]?.[3];
23
- expect(resourceCallback).toBeDefined();
24
- const serverUrl = "http://localhost:3000";
25
- const mockExtra = createMockExtra("__not_used__");
26
- const result = await resourceCallback(new URL("ui://widgets/my-widget.html"), mockExtra);
27
- expect(result).toEqual({
28
- contents: [
29
- {
30
- uri: "ui://widgets/my-widget.html",
31
- mimeType: "text/html+skybridge",
32
- text: expect.stringContaining('<div id="root"></div>'),
33
- },
34
- ],
35
- });
36
- // Check development-specific content
37
- expect(result.contents[0]?.text).toContain(serverUrl + "/@react-refresh");
38
- expect(result.contents[0]?.text).toContain(serverUrl + "/@vite/client");
39
- expect(result.contents[0]?.text).toContain(serverUrl + "/src/widgets/my-widget.tsx");
40
- });
41
- it("should generate correct HTML for production mode", async () => {
42
- setTestEnv({ NODE_ENV: "production" });
43
- const mockToolCallback = vi.fn();
44
- const mockResourceConfig = { description: "Test widget" };
45
- const mockToolConfig = { description: "Test tool" };
46
- server.widget("my-widget", mockResourceConfig, mockToolConfig, mockToolCallback);
47
- // Get the resource callback function
48
- const resourceCallback = mockResource.mock.calls[0]?.[3];
49
- expect(resourceCallback).toBeDefined();
50
- const serverUrl = "https://myapp.com";
51
- const mockExtra = createMockExtra(serverUrl);
52
- const result = await resourceCallback(new URL("ui://widgets/my-widget.html"), mockExtra);
53
- expect(result).toEqual({
54
- contents: [
55
- {
56
- uri: "ui://widgets/my-widget.html",
57
- mimeType: "text/html+skybridge",
58
- text: expect.stringContaining('<div id="root"></div>'),
59
- },
60
- ],
61
- });
62
- // Check production-specific content
63
- expect(result.contents[0]?.text).not.toContain(serverUrl + "@react-refresh");
64
- expect(result.contents[0]?.text).not.toContain(serverUrl + "@vite/client");
65
- expect(result.contents[0]?.text).toContain(serverUrl + "/assets/my-widget.js");
66
- expect(result.contents[0]?.text).toContain(serverUrl + "/assets/style.css");
67
- });
68
- });
69
- //# sourceMappingURL=widget.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"widget.test.js","sourceRoot":"","sources":["../../../src/test/widget.test.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,EAAE,EACF,MAAM,EACN,EAAE,EACF,UAAU,EACV,SAAS,GAEV,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,UAAU,EACV,YAAY,GACb,MAAM,YAAY,CAAC;AAEpB,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,IAAI,MAAiB,CAAC;IACtB,IAAI,YAAiD,CAAC;IACtD,IAAI,gBAAyD,CAAC;IAE9D,UAAU,CAAC,GAAG,EAAE;QACd,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,gBAAgB,EAAE,GAAG,mBAAmB,EAAE,CAAC,CAAC;IACvE,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,EAAE,CAAC,aAAa,EAAE,CAAC;QACnB,YAAY,EAAE,CAAC;IACjB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mDAAmD,EAAE,KAAK,IAAI,EAAE;QACjE,UAAU,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC,CAAC;QAExC,MA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CAAC,SAAS,CAAC,SAAS,GAAG,cAAc,CAAC,CAAC;QAC3E,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,SAAS,CACxC,SAAS,GAAG,sBAAsB,CACnC,CAAC;QACF,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,SAAS,CAAC,SAAS,GAAG,mBAAmB,CAAC,CAAC;IAC9E,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,7 +0,0 @@
1
- export { useOpenAiGlobal } from "./use-openai-global.js";
2
- export { useToolOutput } from "./use-tool-output.js";
3
- export { useToolResponseMetadata } from "./use-tool-response-metadata.js";
4
- export { useCallTool } from "./use-call-tool.js";
5
- export * from "./types.js";
6
- export { mountWidget } from "./mount-widget.js";
7
- export { skybridge } from "./plugin.js";
@@ -1,8 +0,0 @@
1
- export { useOpenAiGlobal } from "./use-openai-global.js";
2
- export { useToolOutput } from "./use-tool-output.js";
3
- export { useToolResponseMetadata } from "./use-tool-response-metadata.js";
4
- export { useCallTool } from "./use-call-tool.js";
5
- export * from "./types.js";
6
- export { mountWidget } from "./mount-widget.js";
7
- export { skybridge } from "./plugin.js";
8
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/web/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}