skybridge 0.0.0-dev.ef862d8 → 0.0.0-dev.ef94389

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 (364) hide show
  1. package/README.md +149 -0
  2. package/bin/run.js +5 -0
  3. package/dist/cli/detect-port.d.ts +18 -0
  4. package/dist/cli/detect-port.js +61 -0
  5. package/dist/cli/detect-port.js.map +1 -0
  6. package/dist/cli/header.d.ts +4 -0
  7. package/dist/cli/header.js +6 -0
  8. package/dist/cli/header.js.map +1 -0
  9. package/dist/cli/run-command.d.ts +2 -0
  10. package/dist/cli/run-command.js +43 -0
  11. package/dist/cli/run-command.js.map +1 -0
  12. package/dist/cli/telemetry.d.ts +7 -0
  13. package/dist/cli/telemetry.js +123 -0
  14. package/dist/cli/telemetry.js.map +1 -0
  15. package/dist/cli/use-execute-steps.d.ts +11 -0
  16. package/dist/cli/use-execute-steps.js +36 -0
  17. package/dist/cli/use-execute-steps.js.map +1 -0
  18. package/dist/cli/use-nodemon.d.ts +7 -0
  19. package/dist/cli/use-nodemon.js +76 -0
  20. package/dist/cli/use-nodemon.js.map +1 -0
  21. package/dist/cli/use-typescript-check.d.ts +8 -0
  22. package/dist/cli/use-typescript-check.js +59 -0
  23. package/dist/cli/use-typescript-check.js.map +1 -0
  24. package/dist/commands/build.d.ts +9 -0
  25. package/dist/commands/build.js +55 -0
  26. package/dist/commands/build.js.map +1 -0
  27. package/dist/commands/dev.d.ts +10 -0
  28. package/dist/commands/dev.js +42 -0
  29. package/dist/commands/dev.js.map +1 -0
  30. package/dist/commands/start.d.ts +9 -0
  31. package/dist/commands/start.js +52 -0
  32. package/dist/commands/start.js.map +1 -0
  33. package/dist/commands/telemetry/disable.d.ts +5 -0
  34. package/dist/commands/telemetry/disable.js +14 -0
  35. package/dist/commands/telemetry/disable.js.map +1 -0
  36. package/dist/commands/telemetry/enable.d.ts +5 -0
  37. package/dist/commands/telemetry/enable.js +14 -0
  38. package/dist/commands/telemetry/enable.js.map +1 -0
  39. package/dist/commands/telemetry/status.d.ts +5 -0
  40. package/dist/commands/telemetry/status.js +14 -0
  41. package/dist/commands/telemetry/status.js.map +1 -0
  42. package/dist/server/asset-base-url-transform-plugin.d.ts +11 -0
  43. package/dist/server/asset-base-url-transform-plugin.js +34 -0
  44. package/dist/server/asset-base-url-transform-plugin.js.map +1 -0
  45. package/dist/server/asset-base-url-transform-plugin.test.js +56 -0
  46. package/dist/server/asset-base-url-transform-plugin.test.js.map +1 -0
  47. package/dist/server/const.d.ts +1 -0
  48. package/dist/server/const.js +2 -0
  49. package/dist/server/const.js.map +1 -0
  50. package/dist/server/express.d.ts +9 -0
  51. package/dist/server/express.js +74 -0
  52. package/dist/server/express.js.map +1 -0
  53. package/dist/server/express.test.js +74 -0
  54. package/dist/server/express.test.js.map +1 -0
  55. package/dist/server/index.d.ts +4 -0
  56. package/dist/server/index.js +2 -0
  57. package/dist/server/index.js.map +1 -0
  58. package/dist/server/inferUtilityTypes.js.map +1 -0
  59. package/dist/server/middleware.d.ts +124 -0
  60. package/dist/server/middleware.js +93 -0
  61. package/dist/server/middleware.js.map +1 -0
  62. package/dist/server/middleware.test-d.js +75 -0
  63. package/dist/server/middleware.test-d.js.map +1 -0
  64. package/dist/server/middleware.test.js +383 -0
  65. package/dist/server/middleware.test.js.map +1 -0
  66. package/dist/server/server.d.ts +153 -0
  67. package/dist/server/server.js +275 -0
  68. package/dist/server/server.js.map +1 -0
  69. package/dist/{src/server → server}/templateHelper.d.ts +4 -2
  70. package/dist/server/templateHelper.js +12 -0
  71. package/dist/server/templateHelper.js.map +1 -0
  72. package/dist/server/templates/development.js +27 -0
  73. package/dist/server/templates/production.js +23 -0
  74. package/dist/{src/server → server}/widgetsDevServer.d.ts +2 -2
  75. package/dist/server/widgetsDevServer.js +63 -0
  76. package/dist/server/widgetsDevServer.js.map +1 -0
  77. package/dist/{src/test → test}/utils.d.ts +11 -0
  78. package/dist/{src/test → test}/utils.js +20 -0
  79. package/dist/test/utils.js.map +1 -0
  80. package/dist/test/widget.test.js +261 -0
  81. package/dist/test/widget.test.js.map +1 -0
  82. package/dist/web/bridges/apps-sdk/adaptor.d.ts +22 -0
  83. package/dist/web/bridges/apps-sdk/adaptor.js +75 -0
  84. package/dist/web/bridges/apps-sdk/adaptor.js.map +1 -0
  85. package/dist/web/bridges/apps-sdk/bridge.d.ts +10 -0
  86. package/dist/web/bridges/apps-sdk/bridge.js +46 -0
  87. package/dist/web/bridges/apps-sdk/bridge.js.map +1 -0
  88. package/dist/web/bridges/apps-sdk/index.d.ts +5 -0
  89. package/dist/web/bridges/apps-sdk/index.js +5 -0
  90. package/dist/web/bridges/apps-sdk/index.js.map +1 -0
  91. package/dist/{src/web → web/bridges/apps-sdk}/types.d.ts +37 -49
  92. package/dist/{src/web → web/bridges/apps-sdk}/types.js +0 -1
  93. package/dist/web/bridges/apps-sdk/types.js.map +1 -0
  94. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.d.ts +2 -0
  95. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js +7 -0
  96. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js.map +1 -0
  97. package/dist/web/bridges/get-adaptor.d.ts +2 -0
  98. package/dist/web/bridges/get-adaptor.js +8 -0
  99. package/dist/web/bridges/get-adaptor.js.map +1 -0
  100. package/dist/web/bridges/index.d.ts +5 -0
  101. package/dist/web/bridges/index.js +6 -0
  102. package/dist/web/bridges/index.js.map +1 -0
  103. package/dist/web/bridges/mcp-app/adaptor.d.ts +38 -0
  104. package/dist/web/bridges/mcp-app/adaptor.js +184 -0
  105. package/dist/web/bridges/mcp-app/adaptor.js.map +1 -0
  106. package/dist/web/bridges/mcp-app/bridge.d.ts +26 -0
  107. package/dist/web/bridges/mcp-app/bridge.js +102 -0
  108. package/dist/web/bridges/mcp-app/bridge.js.map +1 -0
  109. package/dist/web/bridges/mcp-app/index.d.ts +4 -0
  110. package/dist/web/bridges/mcp-app/index.js +4 -0
  111. package/dist/web/bridges/mcp-app/index.js.map +1 -0
  112. package/dist/web/bridges/mcp-app/types.d.ts +8 -0
  113. package/dist/web/bridges/mcp-app/types.js +2 -0
  114. package/dist/web/bridges/mcp-app/types.js.map +1 -0
  115. package/dist/web/bridges/mcp-app/use-mcp-app-context.d.ts +7 -0
  116. package/dist/web/bridges/mcp-app/use-mcp-app-context.js +7 -0
  117. package/dist/web/bridges/mcp-app/use-mcp-app-context.js.map +1 -0
  118. package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js +26 -0
  119. package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js.map +1 -0
  120. package/dist/web/bridges/types.d.ts +102 -0
  121. package/dist/web/bridges/types.js +2 -0
  122. package/dist/web/bridges/types.js.map +1 -0
  123. package/dist/web/bridges/use-host-context.d.ts +2 -0
  124. package/dist/web/bridges/use-host-context.js +8 -0
  125. package/dist/web/bridges/use-host-context.js.map +1 -0
  126. package/dist/web/components/modal-provider.d.ts +4 -0
  127. package/dist/web/components/modal-provider.js +47 -0
  128. package/dist/web/components/modal-provider.js.map +1 -0
  129. package/dist/{src/web → web}/create-store.js +6 -7
  130. package/dist/web/create-store.js.map +1 -0
  131. package/dist/web/create-store.test.js +131 -0
  132. package/dist/web/create-store.test.js.map +1 -0
  133. package/dist/{src/web → web}/data-llm.js +9 -5
  134. package/dist/web/data-llm.js.map +1 -0
  135. package/dist/web/data-llm.test.js +142 -0
  136. package/dist/web/data-llm.test.js.map +1 -0
  137. package/dist/{src/web → web}/generate-helpers.d.ts +3 -2
  138. package/dist/{src/web → web}/generate-helpers.js +1 -1
  139. package/dist/web/generate-helpers.js.map +1 -0
  140. package/dist/{src/web → web}/generate-helpers.test-d.js +31 -2
  141. package/dist/web/generate-helpers.test-d.js.map +1 -0
  142. package/dist/web/generate-helpers.test.js.map +1 -0
  143. package/dist/{src/web → web}/helpers/state.js +13 -8
  144. package/dist/web/helpers/state.js.map +1 -0
  145. package/dist/web/helpers/state.test.js.map +1 -0
  146. package/dist/{src/web → web}/hooks/index.d.ts +4 -5
  147. package/dist/{src/web → web}/hooks/index.js +3 -4
  148. package/dist/web/hooks/index.js.map +1 -0
  149. package/dist/web/hooks/test/utils.d.ts +16 -0
  150. package/dist/web/hooks/test/utils.js +64 -0
  151. package/dist/web/hooks/test/utils.js.map +1 -0
  152. package/dist/{src/web → web}/hooks/use-call-tool.d.ts +2 -1
  153. package/dist/{src/web → web}/hooks/use-call-tool.js +12 -4
  154. package/dist/web/hooks/use-call-tool.js.map +1 -0
  155. package/dist/web/hooks/use-call-tool.test-d.js.map +1 -0
  156. package/dist/{src/web → web}/hooks/use-call-tool.test.js +26 -1
  157. package/dist/web/hooks/use-call-tool.test.js.map +1 -0
  158. package/dist/web/hooks/use-display-mode.d.ts +4 -0
  159. package/dist/web/hooks/use-display-mode.js +9 -0
  160. package/dist/web/hooks/use-display-mode.js.map +1 -0
  161. package/dist/web/hooks/use-display-mode.test-d.js +8 -0
  162. package/dist/web/hooks/use-display-mode.test-d.js.map +1 -0
  163. package/dist/{src/web → web}/hooks/use-display-mode.test.js +1 -0
  164. package/dist/web/hooks/use-display-mode.test.js.map +1 -0
  165. package/dist/web/hooks/use-files.d.ts +6 -0
  166. package/dist/web/hooks/use-files.js +9 -0
  167. package/dist/web/hooks/use-files.js.map +1 -0
  168. package/dist/{src/web → web}/hooks/use-files.test.js +10 -5
  169. package/dist/web/hooks/use-files.test.js.map +1 -0
  170. package/dist/web/hooks/use-layout.d.ts +22 -0
  171. package/dist/web/hooks/use-layout.js +23 -0
  172. package/dist/web/hooks/use-layout.js.map +1 -0
  173. package/dist/web/hooks/use-layout.test.js +96 -0
  174. package/dist/web/hooks/use-layout.test.js.map +1 -0
  175. package/dist/web/hooks/use-open-external.d.ts +3 -0
  176. package/dist/web/hooks/use-open-external.js +8 -0
  177. package/dist/web/hooks/use-open-external.js.map +1 -0
  178. package/dist/web/hooks/use-open-external.test.js +65 -0
  179. package/dist/web/hooks/use-open-external.test.js.map +1 -0
  180. package/dist/web/hooks/use-request-modal.d.ts +9 -0
  181. package/dist/web/hooks/use-request-modal.js +16 -0
  182. package/dist/web/hooks/use-request-modal.js.map +1 -0
  183. package/dist/web/hooks/use-request-modal.test.js +57 -0
  184. package/dist/web/hooks/use-request-modal.test.js.map +1 -0
  185. package/dist/web/hooks/use-send-follow-up-message.js +8 -0
  186. package/dist/web/hooks/use-send-follow-up-message.js.map +1 -0
  187. package/dist/web/hooks/use-set-open-in-app-url.d.ts +1 -0
  188. package/dist/web/hooks/use-set-open-in-app-url.js +8 -0
  189. package/dist/web/hooks/use-set-open-in-app-url.js.map +1 -0
  190. package/dist/web/hooks/use-set-open-in-app-url.test.js +43 -0
  191. package/dist/web/hooks/use-set-open-in-app-url.test.js.map +1 -0
  192. package/dist/{src/web → web}/hooks/use-tool-info.d.ts +12 -1
  193. package/dist/web/hooks/use-tool-info.js +26 -0
  194. package/dist/web/hooks/use-tool-info.js.map +1 -0
  195. package/dist/web/hooks/use-tool-info.test-d.d.ts +1 -0
  196. package/dist/{src/web → web}/hooks/use-tool-info.test-d.js +40 -4
  197. package/dist/web/hooks/use-tool-info.test-d.js.map +1 -0
  198. package/dist/web/hooks/use-tool-info.test.d.ts +1 -0
  199. package/dist/web/hooks/use-tool-info.test.js +130 -0
  200. package/dist/web/hooks/use-tool-info.test.js.map +1 -0
  201. package/dist/web/hooks/use-user.d.ts +18 -0
  202. package/dist/web/hooks/use-user.js +19 -0
  203. package/dist/web/hooks/use-user.js.map +1 -0
  204. package/dist/web/hooks/use-user.test.d.ts +1 -0
  205. package/dist/web/hooks/use-user.test.js +94 -0
  206. package/dist/web/hooks/use-user.test.js.map +1 -0
  207. package/dist/{src/web → web}/hooks/use-widget-state.js +10 -10
  208. package/dist/web/hooks/use-widget-state.js.map +1 -0
  209. package/dist/web/hooks/use-widget-state.test.d.ts +1 -0
  210. package/dist/{src/web → web}/hooks/use-widget-state.test.js +10 -6
  211. package/dist/web/hooks/use-widget-state.test.js.map +1 -0
  212. package/dist/{src/web → web}/index.d.ts +1 -0
  213. package/dist/{src/web → web}/index.js +1 -0
  214. package/dist/web/index.js.map +1 -0
  215. package/dist/{src/web → web}/mount-widget.js +9 -1
  216. package/dist/web/mount-widget.js.map +1 -0
  217. package/dist/web/plugin/data-llm.test.d.ts +1 -0
  218. package/dist/web/plugin/data-llm.test.js.map +1 -0
  219. package/dist/web/plugin/plugin.js +54 -0
  220. package/dist/web/plugin/plugin.js.map +1 -0
  221. package/dist/{src/web → web}/plugin/transform-data-llm.js +6 -3
  222. package/dist/web/plugin/transform-data-llm.js.map +1 -0
  223. package/dist/web/plugin/transform-data-llm.test.d.ts +1 -0
  224. package/dist/web/plugin/transform-data-llm.test.js.map +1 -0
  225. package/dist/web/plugin/validate-widget.d.ts +5 -0
  226. package/dist/web/plugin/validate-widget.js +27 -0
  227. package/dist/web/plugin/validate-widget.js.map +1 -0
  228. package/dist/web/plugin/validate-widget.test.d.ts +1 -0
  229. package/dist/web/plugin/validate-widget.test.js +42 -0
  230. package/dist/web/plugin/validate-widget.test.js.map +1 -0
  231. package/dist/{src/web → web}/proxy.js +5 -1
  232. package/dist/web/proxy.js.map +1 -0
  233. package/dist/web/types.d.ts +16 -0
  234. package/dist/web/types.js +2 -0
  235. package/dist/web/types.js.map +1 -0
  236. package/package.json +59 -28
  237. package/tsconfig.base.json +28 -0
  238. package/dist/src/server/devtoolsStaticServer.d.ts +0 -15
  239. package/dist/src/server/devtoolsStaticServer.js +0 -38
  240. package/dist/src/server/devtoolsStaticServer.js.map +0 -1
  241. package/dist/src/server/index.d.ts +0 -5
  242. package/dist/src/server/index.js +0 -4
  243. package/dist/src/server/index.js.map +0 -1
  244. package/dist/src/server/inferUtilityTypes.js.map +0 -1
  245. package/dist/src/server/server.d.ts +0 -62
  246. package/dist/src/server/server.js +0 -62
  247. package/dist/src/server/server.js.map +0 -1
  248. package/dist/src/server/templateHelper.js +0 -30
  249. package/dist/src/server/templateHelper.js.map +0 -1
  250. package/dist/src/server/templates/development.hbs +0 -12
  251. package/dist/src/server/templates/production.hbs +0 -6
  252. package/dist/src/server/widgetsDevServer.js +0 -39
  253. package/dist/src/server/widgetsDevServer.js.map +0 -1
  254. package/dist/src/test/utils.js.map +0 -1
  255. package/dist/src/test/widget.test.js +0 -95
  256. package/dist/src/test/widget.test.js.map +0 -1
  257. package/dist/src/web/create-store.js.map +0 -1
  258. package/dist/src/web/create-store.test.js +0 -70
  259. package/dist/src/web/create-store.test.js.map +0 -1
  260. package/dist/src/web/data-llm.js.map +0 -1
  261. package/dist/src/web/data-llm.test.js +0 -76
  262. package/dist/src/web/data-llm.test.js.map +0 -1
  263. package/dist/src/web/generate-helpers.js.map +0 -1
  264. package/dist/src/web/generate-helpers.test-d.js.map +0 -1
  265. package/dist/src/web/generate-helpers.test.js.map +0 -1
  266. package/dist/src/web/helpers/state.js.map +0 -1
  267. package/dist/src/web/helpers/state.test.js.map +0 -1
  268. package/dist/src/web/hooks/index.js.map +0 -1
  269. package/dist/src/web/hooks/use-call-tool.js.map +0 -1
  270. package/dist/src/web/hooks/use-call-tool.test-d.js.map +0 -1
  271. package/dist/src/web/hooks/use-call-tool.test.js.map +0 -1
  272. package/dist/src/web/hooks/use-display-mode.d.ts +0 -4
  273. package/dist/src/web/hooks/use-display-mode.js +0 -7
  274. package/dist/src/web/hooks/use-display-mode.js.map +0 -1
  275. package/dist/src/web/hooks/use-display-mode.test.js.map +0 -1
  276. package/dist/src/web/hooks/use-files.d.ts +0 -10
  277. package/dist/src/web/hooks/use-files.js +0 -7
  278. package/dist/src/web/hooks/use-files.js.map +0 -1
  279. package/dist/src/web/hooks/use-files.test.js.map +0 -1
  280. package/dist/src/web/hooks/use-locale.d.ts +0 -1
  281. package/dist/src/web/hooks/use-locale.js +0 -5
  282. package/dist/src/web/hooks/use-locale.js.map +0 -1
  283. package/dist/src/web/hooks/use-locale.test.js +0 -21
  284. package/dist/src/web/hooks/use-locale.test.js.map +0 -1
  285. package/dist/src/web/hooks/use-open-external.d.ts +0 -1
  286. package/dist/src/web/hooks/use-open-external.js +0 -6
  287. package/dist/src/web/hooks/use-open-external.js.map +0 -1
  288. package/dist/src/web/hooks/use-open-external.test.js +0 -24
  289. package/dist/src/web/hooks/use-open-external.test.js.map +0 -1
  290. package/dist/src/web/hooks/use-openai-global.d.ts +0 -2
  291. package/dist/src/web/hooks/use-openai-global.js +0 -25
  292. package/dist/src/web/hooks/use-openai-global.js.map +0 -1
  293. package/dist/src/web/hooks/use-request-modal.d.ts +0 -6
  294. package/dist/src/web/hooks/use-request-modal.js +0 -9
  295. package/dist/src/web/hooks/use-request-modal.js.map +0 -1
  296. package/dist/src/web/hooks/use-request-modal.test.js +0 -24
  297. package/dist/src/web/hooks/use-request-modal.test.js.map +0 -1
  298. package/dist/src/web/hooks/use-send-follow-up-message.js +0 -11
  299. package/dist/src/web/hooks/use-send-follow-up-message.js.map +0 -1
  300. package/dist/src/web/hooks/use-theme.d.ts +0 -1
  301. package/dist/src/web/hooks/use-theme.js +0 -5
  302. package/dist/src/web/hooks/use-theme.js.map +0 -1
  303. package/dist/src/web/hooks/use-theme.test.js +0 -26
  304. package/dist/src/web/hooks/use-theme.test.js.map +0 -1
  305. package/dist/src/web/hooks/use-tool-info.js +0 -20
  306. package/dist/src/web/hooks/use-tool-info.js.map +0 -1
  307. package/dist/src/web/hooks/use-tool-info.test-d.js.map +0 -1
  308. package/dist/src/web/hooks/use-tool-info.test.js +0 -59
  309. package/dist/src/web/hooks/use-tool-info.test.js.map +0 -1
  310. package/dist/src/web/hooks/use-user-agent.d.ts +0 -1
  311. package/dist/src/web/hooks/use-user-agent.js +0 -5
  312. package/dist/src/web/hooks/use-user-agent.js.map +0 -1
  313. package/dist/src/web/hooks/use-user-agent.test.js +0 -31
  314. package/dist/src/web/hooks/use-user-agent.test.js.map +0 -1
  315. package/dist/src/web/hooks/use-widget-state.js.map +0 -1
  316. package/dist/src/web/hooks/use-widget-state.test.js.map +0 -1
  317. package/dist/src/web/index.js.map +0 -1
  318. package/dist/src/web/mount-widget.js.map +0 -1
  319. package/dist/src/web/plugin/data-llm.test.js.map +0 -1
  320. package/dist/src/web/plugin/plugin.js +0 -33
  321. package/dist/src/web/plugin/plugin.js.map +0 -1
  322. package/dist/src/web/plugin/transform-data-llm.js.map +0 -1
  323. package/dist/src/web/plugin/transform-data-llm.test.js.map +0 -1
  324. package/dist/src/web/proxy.js.map +0 -1
  325. package/dist/src/web/types.js.map +0 -1
  326. package/dist/vitest.config.d.ts +0 -2
  327. package/dist/vitest.config.js +0 -8
  328. package/dist/vitest.config.js.map +0 -1
  329. /package/dist/{src/test/widget.test.d.ts → server/asset-base-url-transform-plugin.test.d.ts} +0 -0
  330. /package/dist/{src/web/create-store.test.d.ts → server/express.test.d.ts} +0 -0
  331. /package/dist/{src/server → server}/inferUtilityTypes.d.ts +0 -0
  332. /package/dist/{src/server → server}/inferUtilityTypes.js +0 -0
  333. /package/dist/{src/web/data-llm.test.d.ts → server/middleware.test-d.d.ts} +0 -0
  334. /package/dist/{src/web/generate-helpers.test-d.d.ts → server/middleware.test.d.ts} +0 -0
  335. /package/dist/{src/web/generate-helpers.test.d.ts → test/widget.test.d.ts} +0 -0
  336. /package/dist/{src/web/helpers/state.test.d.ts → web/bridges/mcp-app/use-mcp-app-context.test.d.ts} +0 -0
  337. /package/dist/{src/web → web}/create-store.d.ts +0 -0
  338. /package/dist/{src/web/hooks/use-call-tool.test-d.d.ts → web/create-store.test.d.ts} +0 -0
  339. /package/dist/{src/web → web}/data-llm.d.ts +0 -0
  340. /package/dist/{src/web/plugin → web}/data-llm.test.d.ts +0 -0
  341. /package/dist/{src/web/hooks/use-call-tool.test.d.ts → web/generate-helpers.test-d.d.ts} +0 -0
  342. /package/dist/{src/web/hooks/use-display-mode.test.d.ts → web/generate-helpers.test.d.ts} +0 -0
  343. /package/dist/{src/web → web}/generate-helpers.test.js +0 -0
  344. /package/dist/{src/web → web}/helpers/state.d.ts +0 -0
  345. /package/dist/{src/web/hooks/use-files.test.d.ts → web/helpers/state.test.d.ts} +0 -0
  346. /package/dist/{src/web → web}/helpers/state.test.js +0 -0
  347. /package/dist/{src/web/hooks/use-locale.test.d.ts → web/hooks/use-call-tool.test-d.d.ts} +0 -0
  348. /package/dist/{src/web → web}/hooks/use-call-tool.test-d.js +0 -0
  349. /package/dist/{src/web/hooks/use-open-external.test.d.ts → web/hooks/use-call-tool.test.d.ts} +0 -0
  350. /package/dist/{src/web/hooks/use-request-modal.test.d.ts → web/hooks/use-display-mode.test-d.d.ts} +0 -0
  351. /package/dist/{src/web/hooks/use-theme.test.d.ts → web/hooks/use-display-mode.test.d.ts} +0 -0
  352. /package/dist/{src/web/hooks/use-tool-info.test-d.d.ts → web/hooks/use-files.test.d.ts} +0 -0
  353. /package/dist/{src/web/hooks/use-tool-info.test.d.ts → web/hooks/use-layout.test.d.ts} +0 -0
  354. /package/dist/{src/web/hooks/use-user-agent.test.d.ts → web/hooks/use-open-external.test.d.ts} +0 -0
  355. /package/dist/{src/web/hooks/use-widget-state.test.d.ts → web/hooks/use-request-modal.test.d.ts} +0 -0
  356. /package/dist/{src/web → web}/hooks/use-send-follow-up-message.d.ts +0 -0
  357. /package/dist/{src/web/plugin/transform-data-llm.test.d.ts → web/hooks/use-set-open-in-app-url.test.d.ts} +0 -0
  358. /package/dist/{src/web → web}/hooks/use-widget-state.d.ts +0 -0
  359. /package/dist/{src/web → web}/mount-widget.d.ts +0 -0
  360. /package/dist/{src/web → web}/plugin/data-llm.test.js +0 -0
  361. /package/dist/{src/web → web}/plugin/plugin.d.ts +0 -0
  362. /package/dist/{src/web → web}/plugin/transform-data-llm.d.ts +0 -0
  363. /package/dist/{src/web → web}/plugin/transform-data-llm.test.js +0 -0
  364. /package/dist/{src/web → web}/proxy.d.ts +0 -0
@@ -0,0 +1,275 @@
1
+ import crypto from "node:crypto";
2
+ import { readFileSync } from "node:fs";
3
+ import http from "node:http";
4
+ import path from "node:path";
5
+ import { McpServer as McpServerBase, } from "@modelcontextprotocol/sdk/server/mcp.js";
6
+ import { mergeWith, union } from "es-toolkit";
7
+ import { DEFAULT_HMR_PORT } from "./const.js";
8
+ import { createServer } from "./express.js";
9
+ import { buildMiddlewareChain, getHandlerMaps } from "./middleware.js";
10
+ import { templateHelper } from "./templateHelper.js";
11
+ const mergeWithUnion = (target, source) => {
12
+ return mergeWith(target, source, (targetVal, sourceVal) => {
13
+ if (Array.isArray(targetVal) && Array.isArray(sourceVal)) {
14
+ return union(targetVal, sourceVal);
15
+ }
16
+ });
17
+ };
18
+ export class McpServer extends McpServerBase {
19
+ express;
20
+ customMiddleware = [];
21
+ mcpMiddlewareEntries = [];
22
+ mcpMiddlewareApplied = false;
23
+ viteManifest = null;
24
+ use(pathOrHandler, ...handlers) {
25
+ if (typeof pathOrHandler === "string") {
26
+ this.customMiddleware.push({
27
+ path: pathOrHandler,
28
+ handlers,
29
+ });
30
+ }
31
+ else {
32
+ this.customMiddleware.push({
33
+ handlers: [pathOrHandler, ...handlers],
34
+ });
35
+ }
36
+ return this;
37
+ }
38
+ setViteManifest(manifest) {
39
+ this.viteManifest = manifest;
40
+ return this;
41
+ }
42
+ mcpMiddleware(filterOrHandler,
43
+ // biome-ignore lint/suspicious/noExplicitAny: overloads narrow the handler type at call sites; implementation must accept all variants
44
+ maybeHandler) {
45
+ if (this.mcpMiddlewareApplied) {
46
+ throw new Error("Cannot register MCP middleware after run() or connect() has been called");
47
+ }
48
+ const handler = maybeHandler;
49
+ if (typeof filterOrHandler === "function") {
50
+ this.mcpMiddlewareEntries.push({
51
+ filter: null,
52
+ handler: filterOrHandler,
53
+ });
54
+ }
55
+ else if (handler) {
56
+ this.mcpMiddlewareEntries.push({
57
+ filter: filterOrHandler,
58
+ handler,
59
+ });
60
+ }
61
+ else {
62
+ throw new Error("mcpMiddleware requires a handler function when a filter is provided");
63
+ }
64
+ return this;
65
+ }
66
+ applyMcpMiddleware() {
67
+ if (this.mcpMiddlewareApplied) {
68
+ return;
69
+ }
70
+ this.mcpMiddlewareApplied = true;
71
+ if (this.mcpMiddlewareEntries.length === 0) {
72
+ return;
73
+ }
74
+ const { requestHandlers, notificationHandlers } = getHandlerMaps(this.server);
75
+ const entries = this.mcpMiddlewareEntries;
76
+ // Wrap existing handlers and proxy future .set() for lazy SDK registration
77
+ const instrumentMap = (map, isNotification) => {
78
+ for (const [method, handler] of map) {
79
+ map.set(method, buildMiddlewareChain(method, isNotification, handler, entries));
80
+ }
81
+ const originalSet = map.set.bind(map);
82
+ map.set = (method, handler) => originalSet(method, buildMiddlewareChain(method, isNotification, handler, entries));
83
+ };
84
+ instrumentMap(requestHandlers, false);
85
+ instrumentMap(notificationHandlers, true);
86
+ }
87
+ async connect(transport) {
88
+ this.applyMcpMiddleware();
89
+ return super.connect(transport);
90
+ }
91
+ async run() {
92
+ this.applyMcpMiddleware();
93
+ if (!this.express) {
94
+ this.express = await createServer({
95
+ server: this,
96
+ customMiddleware: this.customMiddleware,
97
+ });
98
+ }
99
+ const express = this.express;
100
+ const port = parseInt(process.env.__PORT ?? "3000", 10);
101
+ await new Promise((resolve, reject) => {
102
+ const server = http.createServer(express);
103
+ server.on("error", (error) => {
104
+ console.error("Failed to start server:", error);
105
+ reject(error);
106
+ });
107
+ server.listen(port, () => {
108
+ resolve();
109
+ });
110
+ });
111
+ try {
112
+ const cloudflareNode = "cloudflare:node";
113
+ const { httpServerHandler } = await import(cloudflareNode);
114
+ return httpServerHandler({ port });
115
+ }
116
+ catch {
117
+ return undefined;
118
+ }
119
+ }
120
+ registerWidget(name, resourceConfig, toolConfig, toolCallback) {
121
+ const userMeta = resourceConfig._meta;
122
+ const toolMeta = {
123
+ ...toolConfig._meta,
124
+ };
125
+ if (!resourceConfig.hosts || resourceConfig.hosts.includes("apps-sdk")) {
126
+ const widgetConfig = {
127
+ hostType: "apps-sdk",
128
+ uri: `ui://widgets/apps-sdk/${name}.html`,
129
+ mimeType: "text/html+skybridge",
130
+ buildContentMeta: ({ resourceDomains, connectDomains, domain }, overrides) => {
131
+ const userUi = userMeta?.ui;
132
+ const userCsp = userUi?.csp;
133
+ const defaults = {
134
+ "openai/widgetCSP": {
135
+ resource_domains: resourceDomains,
136
+ connect_domains: connectDomains,
137
+ },
138
+ "openai/widgetDomain": domain,
139
+ "openai/widgetDescription": resourceConfig.description,
140
+ };
141
+ const fromUi = {
142
+ "openai/widgetCSP": {
143
+ resource_domains: userCsp?.resourceDomains,
144
+ connect_domains: userCsp?.connectDomains,
145
+ frame_domains: userCsp?.frameDomains,
146
+ redirect_domains: userCsp?.redirectDomains,
147
+ },
148
+ "openai/widgetDomain": userUi?.domain,
149
+ "openai/widgetPrefersBorder": userUi?.prefersBorder,
150
+ };
151
+ const directOpenaiKeys = Object.fromEntries(Object.entries(userMeta ?? {}).filter(([key]) => key.startsWith("openai/")));
152
+ return mergeWithUnion(mergeWithUnion(mergeWithUnion(defaults, fromUi), directOpenaiKeys), { "openai/widgetDomain": overrides.domain });
153
+ },
154
+ };
155
+ this.registerWidgetResource({
156
+ name,
157
+ widgetConfig,
158
+ resourceConfig,
159
+ });
160
+ toolMeta["openai/outputTemplate"] = widgetConfig.uri;
161
+ }
162
+ if (!resourceConfig.hosts || resourceConfig.hosts.includes("mcp-app")) {
163
+ const widgetConfig = {
164
+ hostType: "mcp-app",
165
+ uri: `ui://widgets/ext-apps/${name}.html`,
166
+ mimeType: "text/html;profile=mcp-app",
167
+ buildContentMeta: ({ resourceDomains, connectDomains, domain }, overrides) => {
168
+ const defaults = {
169
+ ui: {
170
+ csp: {
171
+ resourceDomains,
172
+ connectDomains,
173
+ },
174
+ domain,
175
+ },
176
+ };
177
+ return mergeWithUnion(defaults, {
178
+ ui: { ...userMeta?.ui, ...overrides },
179
+ });
180
+ },
181
+ };
182
+ this.registerWidgetResource({
183
+ name,
184
+ widgetConfig,
185
+ resourceConfig,
186
+ });
187
+ // @ts-expect-error - For backwards compatibility with Claude current implementation of the specs
188
+ toolMeta["ui/resourceUri"] = widgetConfig.uri;
189
+ toolMeta.ui = { resourceUri: widgetConfig.uri };
190
+ }
191
+ this.registerTool(name, {
192
+ ...toolConfig,
193
+ _meta: toolMeta,
194
+ }, toolCallback);
195
+ return this;
196
+ }
197
+ registerTool(name, config, cb) {
198
+ super.registerTool(name, config, cb);
199
+ return this;
200
+ }
201
+ registerWidgetResource({ name, widgetConfig, resourceConfig, }) {
202
+ const { hostType, uri: widgetUri, mimeType, buildContentMeta, } = widgetConfig;
203
+ this.registerResource(name, widgetUri, { ...resourceConfig, _meta: resourceConfig._meta }, async (uri, extra) => {
204
+ const isProduction = process.env.NODE_ENV === "production";
205
+ const useForwardedHost = process.env.SKYBRIDGE_USE_FORWARDED_HOST === "true";
206
+ const isClaude = extra?.requestInfo?.headers?.["user-agent"] === "Claude-User";
207
+ const hostFromHeaders = extra?.requestInfo?.headers?.["x-forwarded-host"] ??
208
+ extra?.requestInfo?.headers?.host;
209
+ const useExternalHost = isProduction || useForwardedHost || isClaude;
210
+ const devPort = process.env.__PORT || "3000";
211
+ const serverUrl = useExternalHost
212
+ ? `https://${hostFromHeaders}`
213
+ : `http://localhost:${devPort}`;
214
+ const html = isProduction
215
+ ? templateHelper.renderProduction({
216
+ hostType,
217
+ serverUrl,
218
+ widgetFile: this.lookupDistFileWithIndexFallback(`src/widgets/${name}`),
219
+ styleFile: this.lookupDistFile("style.css"),
220
+ })
221
+ : templateHelper.renderDevelopment({
222
+ hostType,
223
+ serverUrl,
224
+ useLocalNetworkAccess: !useExternalHost,
225
+ widgetName: name,
226
+ });
227
+ const connectDomains = [serverUrl];
228
+ if (!isProduction) {
229
+ const hmrPort = process.env.__SKYBRIDGE_HMR_PORT ?? DEFAULT_HMR_PORT;
230
+ const VITE_HMR_WEBSOCKET_DEFAULT_URL = `ws://localhost:${hmrPort}`;
231
+ connectDomains.push(VITE_HMR_WEBSOCKET_DEFAULT_URL);
232
+ }
233
+ const pathname = extra?.requestInfo?.url?.pathname ?? "";
234
+ const url = `https://${hostFromHeaders}${pathname}`;
235
+ const hash = crypto
236
+ .createHash("sha256")
237
+ .update(url)
238
+ .digest("hex")
239
+ .slice(0, 32);
240
+ const contentMetaOverrides = isClaude
241
+ ? {
242
+ domain: `${hash}.claudemcpcontent.com`,
243
+ }
244
+ : {};
245
+ const contentMeta = buildContentMeta({
246
+ resourceDomains: [serverUrl],
247
+ connectDomains,
248
+ domain: serverUrl,
249
+ baseUriDomains: [serverUrl],
250
+ }, contentMetaOverrides);
251
+ return {
252
+ contents: [
253
+ { uri: uri.href, mimeType, text: html, _meta: contentMeta },
254
+ ],
255
+ };
256
+ });
257
+ }
258
+ lookupDistFile(key) {
259
+ const manifest = this.readManifest();
260
+ return manifest[key]?.file;
261
+ }
262
+ lookupDistFileWithIndexFallback(basePath) {
263
+ const manifest = this.readManifest();
264
+ const flatFileKey = `${basePath}.tsx`;
265
+ const indexFileKey = `${basePath}/index.tsx`;
266
+ return manifest[flatFileKey]?.file ?? manifest[indexFileKey]?.file;
267
+ }
268
+ readManifest() {
269
+ if (this.viteManifest) {
270
+ return this.viteManifest;
271
+ }
272
+ return JSON.parse(readFileSync(path.join(process.cwd(), "dist", "assets", ".vite", "manifest.json"), "utf-8"));
273
+ }
274
+ }
275
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/server/server.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,IAAI,MAAM,WAAW,CAAC;AAK7B,OAAO,EACL,SAAS,IAAI,aAAa,GAG3B,MAAM,yCAAyC,CAAC;AAejD,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAE9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAY5C,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAA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K,CACf,YAAY,CACV,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,eAAe,CAAC,EACpE,OAAO,CACR,CACF,CAAC;IACJ,CAAC;CACF"}
@@ -1,13 +1,15 @@
1
+ import type { WidgetHostType } from "./server.js";
1
2
  declare class TemplateHelper {
2
- private templateCache;
3
- private loadTemplate;
4
3
  renderProduction(data: {
4
+ hostType: WidgetHostType;
5
5
  serverUrl: string;
6
6
  widgetFile: string;
7
7
  styleFile: string;
8
8
  }): string;
9
9
  renderDevelopment(data: {
10
+ hostType: WidgetHostType;
10
11
  serverUrl: string;
12
+ useLocalNetworkAccess: boolean;
11
13
  widgetName: string;
12
14
  }): string;
13
15
  }
@@ -0,0 +1,12 @@
1
+ import developmentTemplate from "./templates/development.js";
2
+ import productionTemplate from "./templates/production.js";
3
+ class TemplateHelper {
4
+ renderProduction(data) {
5
+ return productionTemplate(data);
6
+ }
7
+ renderDevelopment(data) {
8
+ return developmentTemplate(data);
9
+ }
10
+ }
11
+ export const templateHelper = new TemplateHelper();
12
+ //# sourceMappingURL=templateHelper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templateHelper.js","sourceRoot":"","sources":["../../src/server/templateHelper.ts"],"names":[],"mappings":"AACA,OAAO,mBAAmB,MAAM,4BAA4B,CAAC;AAC7D,OAAO,kBAAkB,MAAM,2BAA2B,CAAC;AAE3D,MAAM,cAAc;IAClB,gBAAgB,CAAC,IAKhB;QACC,OAAO,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;IAED,iBAAiB,CAAC,IAKjB;QACC,OAAO,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;CACF;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC"}
@@ -0,0 +1,27 @@
1
+ import Handlebars from "handlebars/runtime.js";
2
+ export default Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
3
+ return "<script type=\"module\">\n // Checks for browser support and shows error if local network access is denied\n (async () => {\n if (!navigator.permissions?.query) {\n return;\n }\n\n // Skip for non-http(s) protocols (file://, custom protocols in Electron, etc.)\n const protocol = window.location.protocol;\n const isNonHttpProtocol = protocol !== 'http:' && protocol !== 'https:'\n if (isNonHttpProtocol) {\n return;\n }\n\n const host = window.location.hostname;\n const isLoopback = host === 'localhost'\n || /^127\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$/.test(host)\n || host === '::1';\n if (isLoopback) {\n return;\n }\n \n try {\n const status = await navigator.permissions.query({ name: \"local-network-access\" });\n if (status.state === \"denied\") {\n const errorDiv = document.createElement(\"div\");\n errorDiv.style.cssText = \"background: #fef2f2; border: 2px solid #ef4444; border-radius: 8px; padding: 16px; text-align: center; z-index: 10000; font-family: system-ui, sans-serif;\";\n\n const errorTitle = document.createElement(\"div\");\n errorTitle.style.cssText = \"color: #ef4444; font-size: 18px; font-weight: 600; margin-bottom: 8px;\";\n errorTitle.textContent = \"Error: Local network access permission is denied.\";\n\n const errorMessage = document.createElement(\"div\");\n errorMessage.style.cssText = \"color: #ef4444; font-size: 14px;\";\n errorMessage.textContent = \"Local network access is required for your widget to connect to the local dev server. Please enable it in your browser settings. \";\n\n const link = document.createElement(\"a\");\n link.href = \"https://developer.chrome.com/blog/local-network-access\";\n link.target = \"_blank\";\n link.rel = \"noopener noreferrer\";\n link.style.cssText = \"color: #ef4444; text-decoration: underline;\";\n link.textContent = \"Learn more\";\n errorMessage.appendChild(link);\n\n errorDiv.appendChild(errorTitle);\n errorDiv.appendChild(errorMessage);\n document.body.appendChild(errorDiv);\n }\n } catch (e) {\n // Permission API doesn't support local-network-access, ignore silently\n }\n })();\n</script>\n";
4
+ },"compiler":[8,">= 4.3.0"],"main":function(container,depth0,helpers,partials,data) {
5
+ var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=container.hooks.helperMissing, alias3="function", alias4=container.escapeExpression, lookupProperty = container.lookupProperty || function(parent, propertyName) {
6
+ if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
7
+ return parent[propertyName];
8
+ }
9
+ return undefined
10
+ };
11
+
12
+ return "<script type=\"module\">window.skybridge = { hostType: \""
13
+ + alias4(((helper = (helper = lookupProperty(helpers,"hostType") || (depth0 != null ? lookupProperty(depth0,"hostType") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"hostType","hash":{},"data":data,"loc":{"start":{"line":1,"column":54},"end":{"line":1,"column":66}}}) : helper)))
14
+ + "\", serverUrl: \""
15
+ + alias4(((helper = (helper = lookupProperty(helpers,"serverUrl") || (depth0 != null ? lookupProperty(depth0,"serverUrl") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"serverUrl","hash":{},"data":data,"loc":{"start":{"line":1,"column":81},"end":{"line":1,"column":94}}}) : helper)))
16
+ + "\" };</script>\n<script type=\"module\">\n import { injectIntoGlobalHook } from \""
17
+ + alias4(((helper = (helper = lookupProperty(helpers,"serverUrl") || (depth0 != null ? lookupProperty(depth0,"serverUrl") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"serverUrl","hash":{},"data":data,"loc":{"start":{"line":3,"column":40},"end":{"line":3,"column":53}}}) : helper)))
18
+ + "/assets/@react-refresh\";\n injectIntoGlobalHook(window); window.$RefreshReg$ = () => {};\n window.$RefreshSig$ = () => (type) => type;\n window.__vite_plugin_react_preamble_installed__ = true;\n</script>\n<script type=\"module\" src=\""
19
+ + alias4(((helper = (helper = lookupProperty(helpers,"serverUrl") || (depth0 != null ? lookupProperty(depth0,"serverUrl") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"serverUrl","hash":{},"data":data,"loc":{"start":{"line":8,"column":27},"end":{"line":8,"column":40}}}) : helper)))
20
+ + "/@vite/client\"></script>\n"
21
+ + ((stack1 = lookupProperty(helpers,"if").call(alias1,(depth0 != null ? lookupProperty(depth0,"useLocalNetworkAccess") : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data,"loc":{"start":{"line":9,"column":0},"end":{"line":63,"column":7}}})) != null ? stack1 : "")
22
+ + "<div id=\"root\"></div>\n<script type=\"module\" id=\"dev-widget-entry\">\n import('"
23
+ + alias4(((helper = (helper = lookupProperty(helpers,"serverUrl") || (depth0 != null ? lookupProperty(depth0,"serverUrl") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"serverUrl","hash":{},"data":data,"loc":{"start":{"line":66,"column":10},"end":{"line":66,"column":23}}}) : helper)))
24
+ + "/src/widgets/"
25
+ + alias4(((helper = (helper = lookupProperty(helpers,"widgetName") || (depth0 != null ? lookupProperty(depth0,"widgetName") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"widgetName","hash":{},"data":data,"loc":{"start":{"line":66,"column":36},"end":{"line":66,"column":50}}}) : helper)))
26
+ + "');\n</script>";
27
+ },"useData":true});
@@ -0,0 +1,23 @@
1
+ import Handlebars from "handlebars/runtime.js";
2
+ export default Handlebars.template({"compiler":[8,">= 4.3.0"],"main":function(container,depth0,helpers,partials,data) {
3
+ var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=container.hooks.helperMissing, alias3="function", alias4=container.escapeExpression, lookupProperty = container.lookupProperty || function(parent, propertyName) {
4
+ if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
5
+ return parent[propertyName];
6
+ }
7
+ return undefined
8
+ };
9
+
10
+ return "<script type=\"module\">window.skybridge = { hostType: \""
11
+ + alias4(((helper = (helper = lookupProperty(helpers,"hostType") || (depth0 != null ? lookupProperty(depth0,"hostType") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"hostType","hash":{},"data":data,"loc":{"start":{"line":1,"column":54},"end":{"line":1,"column":66}}}) : helper)))
12
+ + "\", serverUrl: \""
13
+ + alias4(((helper = (helper = lookupProperty(helpers,"serverUrl") || (depth0 != null ? lookupProperty(depth0,"serverUrl") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"serverUrl","hash":{},"data":data,"loc":{"start":{"line":1,"column":81},"end":{"line":1,"column":94}}}) : helper)))
14
+ + "\" };</script>\n<div id=\"root\"></div>\n<script type=\"module\">\n import('"
15
+ + alias4(((helper = (helper = lookupProperty(helpers,"serverUrl") || (depth0 != null ? lookupProperty(depth0,"serverUrl") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"serverUrl","hash":{},"data":data,"loc":{"start":{"line":4,"column":10},"end":{"line":4,"column":23}}}) : helper)))
16
+ + "/assets/"
17
+ + alias4(((helper = (helper = lookupProperty(helpers,"widgetFile") || (depth0 != null ? lookupProperty(depth0,"widgetFile") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"widgetFile","hash":{},"data":data,"loc":{"start":{"line":4,"column":31},"end":{"line":4,"column":45}}}) : helper)))
18
+ + "');\n</script>\n<link rel=\"stylesheet\" crossorigin href=\""
19
+ + alias4(((helper = (helper = lookupProperty(helpers,"serverUrl") || (depth0 != null ? lookupProperty(depth0,"serverUrl") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"serverUrl","hash":{},"data":data,"loc":{"start":{"line":6,"column":41},"end":{"line":6,"column":54}}}) : helper)))
20
+ + "/assets/"
21
+ + alias4(((helper = (helper = lookupProperty(helpers,"styleFile") || (depth0 != null ? lookupProperty(depth0,"styleFile") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"styleFile","hash":{},"data":data,"loc":{"start":{"line":6,"column":62},"end":{"line":6,"column":75}}}) : helper)))
22
+ + "\" />";
23
+ },"useData":true});
@@ -1,4 +1,4 @@
1
- import { type RequestHandler } from "express";
1
+ import { type Router } from "express";
2
2
  /**
3
3
  * Install Vite dev server
4
4
  * This router MUST be installed at the application root, like so:
@@ -9,4 +9,4 @@ import { type RequestHandler } from "express";
9
9
  * app.use(await widgetsRouter());
10
10
  * }
11
11
  */
12
- export declare const widgetsDevServer: () => Promise<RequestHandler>;
12
+ export declare const widgetsDevServer: () => Promise<Router>;
@@ -0,0 +1,63 @@
1
+ import { existsSync } from "node:fs";
2
+ import path from "node:path";
3
+ import cors from "cors";
4
+ import express, {} from "express";
5
+ import { detectAvailablePort } from "../cli/detect-port.js";
6
+ import { assetBaseUrlTransformPlugin } from "./asset-base-url-transform-plugin.js";
7
+ import { DEFAULT_HMR_PORT } from "./const.js";
8
+ /**
9
+ * Install Vite dev server
10
+ * This router MUST be installed at the application root, like so:
11
+ *
12
+ * const app = express();
13
+ *
14
+ * if (env.NODE_ENV !== "production") {
15
+ * app.use(await widgetsRouter());
16
+ * }
17
+ */
18
+ export const widgetsDevServer = async () => {
19
+ const router = express.Router();
20
+ const { createServer, searchForWorkspaceRoot, loadConfigFromFile } = await import("vite");
21
+ // Since 0.16.0, the template is a single package that does not rely on workspace.
22
+ // It means that, when starting the server, the working dir is the template root
23
+ // hence we don't need to walk up the tree to find the workspace, which does not exist anymore.
24
+ let webAppRoot = path.join(process.cwd(), "web");
25
+ // fallback to the old behavior for backward compatibility
26
+ const hasWebAppRoot = existsSync(webAppRoot);
27
+ if (!hasWebAppRoot) {
28
+ const workspaceRoot = searchForWorkspaceRoot(process.cwd());
29
+ webAppRoot = path.join(workspaceRoot, "web");
30
+ }
31
+ const configResult = await loadConfigFromFile({ command: "serve", mode: "development" }, path.join(webAppRoot, "vite.config.ts"), webAppRoot);
32
+ const { build, preview, plugins: userPlugins = [], ...devConfig } = configResult?.config || {};
33
+ const hmrPort = await detectAvailablePort(DEFAULT_HMR_PORT, "localhost");
34
+ process.env.__SKYBRIDGE_HMR_PORT = String(hmrPort);
35
+ const vite = await createServer({
36
+ ...devConfig,
37
+ configFile: false, // Keep this to prevent vite from trying to resolve path in the target config file
38
+ appType: "custom",
39
+ server: {
40
+ allowedHosts: true,
41
+ middlewareMode: true,
42
+ hmr: {
43
+ protocol: "ws",
44
+ host: "localhost",
45
+ port: hmrPort,
46
+ },
47
+ },
48
+ root: webAppRoot,
49
+ optimizeDeps: {
50
+ include: ["react", "react-dom/client"],
51
+ },
52
+ plugins: [
53
+ ...userPlugins,
54
+ assetBaseUrlTransformPlugin({
55
+ devServerOrigin: `http://localhost:${process.env.__PORT ?? "3000"}`,
56
+ }),
57
+ ],
58
+ });
59
+ router.use(cors());
60
+ router.use("/", vite.middlewares);
61
+ return router;
62
+ };
63
+ //# sourceMappingURL=widgetsDevServer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"widgetsDevServer.js","sourceRoot":"","sources":["../../src/server/widgetsDevServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,OAAO,EAAE,EAAe,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,IAAqB,EAAE;IAC1D,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAEhC,MAAM,EAAE,YAAY,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,GAChE,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC;IAEvB,kFAAkF;IAClF,gFAAgF;IAChF,+FAA+F;IAC/F,IAAI,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,KAAK,CAAC,CAAC;IAEjD,0DAA0D;IAC1D,MAAM,aAAa,GAAG,UAAU,CAAC,U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AC;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"}
@@ -104,6 +104,17 @@ export declare function createMinimalTestServer(): McpServer<Record<never, impor
104
104
  }[];
105
105
  }, unknown>;
106
106
  }>;
107
+ export declare function createInterfaceTestServer(): McpServer<Record<never, import("../server/server.js").ToolDef<unknown, unknown, unknown>> & {
108
+ "interface-widget": import("../server/server.js").ToolDef<{
109
+ id: string;
110
+ }, {
111
+ itemName: string;
112
+ quantity: number;
113
+ }, {
114
+ processedBy: string;
115
+ version: number;
116
+ }>;
117
+ }>;
107
118
  /**
108
119
  * Mock extra parameter for resource callback
109
120
  */
@@ -197,6 +197,26 @@ export function createMinimalTestServer() {
197
197
  };
198
198
  });
199
199
  }
200
+ export function createInterfaceTestServer() {
201
+ return new McpServer({ name: "interface-test-app", version: "1.0.0" }, {}).registerWidget("interface-widget", {}, {
202
+ description: "Widget with interface-typed output",
203
+ inputSchema: {
204
+ id: z.string(),
205
+ },
206
+ }, async ({ id }) => {
207
+ return {
208
+ content: [{ type: "text", text: `Item ${id}` }],
209
+ structuredContent: {
210
+ itemName: "Test Item",
211
+ quantity: 42,
212
+ },
213
+ _meta: {
214
+ processedBy: "test",
215
+ version: 1,
216
+ },
217
+ };
218
+ });
219
+ }
200
220
  /**
201
221
  * Mock extra parameter for resource callback
202
222
  */
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/test/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD;;GAEG;AACH,MAAM,UAAU,mBAAmB;IAKjC,mCAAmC;I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