skybridge 0.0.0-dev.ddf8a13 → 0.0.0-dev.ddfb4e5

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 (453) hide show
  1. package/README.md +126 -124
  2. package/dist/cli/build-helpers.d.ts +11 -0
  3. package/dist/cli/build-helpers.js +107 -0
  4. package/dist/cli/build-helpers.js.map +1 -0
  5. package/dist/cli/build-helpers.test.js +132 -0
  6. package/dist/cli/build-helpers.test.js.map +1 -0
  7. package/dist/cli/build-steps.d.ts +2 -0
  8. package/dist/cli/build-steps.js +73 -0
  9. package/dist/cli/build-steps.js.map +1 -0
  10. package/dist/cli/build-steps.test.js +52 -0
  11. package/dist/cli/build-steps.test.js.map +1 -0
  12. package/dist/cli/detect-port.d.ts +2 -2
  13. package/dist/cli/detect-port.js +8 -20
  14. package/dist/cli/detect-port.js.map +1 -1
  15. package/dist/cli/header.d.ts +1 -1
  16. package/dist/cli/header.js.map +1 -1
  17. package/dist/cli/resolve-skybridge-config.d.ts +5 -0
  18. package/dist/cli/resolve-skybridge-config.js +18 -0
  19. package/dist/cli/resolve-skybridge-config.js.map +1 -0
  20. package/dist/cli/run-command.js.map +1 -1
  21. package/dist/cli/run-plain.d.ts +18 -0
  22. package/dist/cli/run-plain.js +89 -0
  23. package/dist/cli/run-plain.js.map +1 -0
  24. package/dist/cli/telemetry.js +2 -0
  25. package/dist/cli/telemetry.js.map +1 -1
  26. package/dist/cli/tunnel-control-server.js.map +1 -1
  27. package/dist/cli/tunnel-control-server.test.js.map +1 -1
  28. package/dist/cli/tunnel-handler.js.map +1 -1
  29. package/dist/cli/tunnel-handler.test.js.map +1 -1
  30. package/dist/cli/tunnel.js +2 -2
  31. package/dist/cli/tunnel.js.map +1 -1
  32. package/dist/cli/tunnel.test.js.map +1 -1
  33. package/dist/cli/types.js.map +1 -1
  34. package/dist/cli/use-execute-steps.d.ts +1 -1
  35. package/dist/cli/use-execute-steps.js.map +1 -1
  36. package/dist/cli/use-messages.js.map +1 -1
  37. package/dist/cli/use-nodemon.d.ts +14 -0
  38. package/dist/cli/use-nodemon.js +82 -54
  39. package/dist/cli/use-nodemon.js.map +1 -1
  40. package/dist/cli/use-open-browser.d.ts +1 -0
  41. package/dist/cli/use-open-browser.js +44 -0
  42. package/dist/cli/use-open-browser.js.map +1 -0
  43. package/dist/cli/use-tunnel.js.map +1 -1
  44. package/dist/cli/use-typescript-check.d.ts +8 -2
  45. package/dist/cli/use-typescript-check.js +71 -68
  46. package/dist/cli/use-typescript-check.js.map +1 -1
  47. package/dist/commands/build.d.ts +0 -3
  48. package/dist/commands/build.js +2 -38
  49. package/dist/commands/build.js.map +1 -1
  50. package/dist/commands/create.d.ts +9 -0
  51. package/dist/commands/create.js +30 -0
  52. package/dist/commands/create.js.map +1 -0
  53. package/dist/commands/dev.d.ts +2 -0
  54. package/dist/commands/dev.js +55 -0
  55. package/dist/commands/dev.js.map +1 -1
  56. package/dist/commands/start.js +7 -1
  57. package/dist/commands/start.js.map +1 -1
  58. package/dist/commands/telemetry/disable.js.map +1 -1
  59. package/dist/commands/telemetry/enable.js.map +1 -1
  60. package/dist/commands/telemetry/status.js.map +1 -1
  61. package/dist/context-warnings.d.ts +5 -0
  62. package/dist/context-warnings.js +31 -0
  63. package/dist/context-warnings.js.map +1 -0
  64. package/dist/context-warnings.test.js +28 -0
  65. package/dist/context-warnings.test.js.map +1 -0
  66. package/dist/server/app.d.ts +194 -0
  67. package/dist/server/app.js +266 -0
  68. package/dist/server/app.js.map +1 -0
  69. package/dist/server/app.test.js +97 -0
  70. package/dist/server/app.test.js.map +1 -0
  71. package/dist/server/asset-base-url-transform-plugin.d.ts +1 -0
  72. package/dist/server/asset-base-url-transform-plugin.js +16 -1
  73. package/dist/server/asset-base-url-transform-plugin.js.map +1 -1
  74. package/dist/server/asset-base-url-transform-plugin.test.js +51 -1
  75. package/dist/server/asset-base-url-transform-plugin.test.js.map +1 -1
  76. package/dist/server/auth/discovery.d.ts +33 -0
  77. package/dist/server/auth/discovery.js +56 -0
  78. package/dist/server/auth/discovery.js.map +1 -0
  79. package/dist/server/auth/discovery.test.d.ts +1 -0
  80. package/dist/server/auth/discovery.test.js +93 -0
  81. package/dist/server/auth/discovery.test.js.map +1 -0
  82. package/dist/server/auth/index.d.ts +48 -0
  83. package/dist/server/auth/index.js +2 -0
  84. package/dist/server/auth/index.js.map +1 -0
  85. package/dist/server/auth/providers/auth0.d.ts +40 -0
  86. package/dist/server/auth/providers/auth0.js +36 -0
  87. package/dist/server/auth/providers/auth0.js.map +1 -0
  88. package/dist/server/auth/providers/auth0.test.d.ts +1 -0
  89. package/dist/server/auth/providers/auth0.test.js +50 -0
  90. package/dist/server/auth/providers/auth0.test.js.map +1 -0
  91. package/dist/server/auth/providers/authplane.d.ts +49 -0
  92. package/dist/server/auth/providers/authplane.js +57 -0
  93. package/dist/server/auth/providers/authplane.js.map +1 -0
  94. package/dist/server/auth/providers/authplane.test.d.ts +1 -0
  95. package/dist/server/auth/providers/authplane.test.js +143 -0
  96. package/dist/server/auth/providers/authplane.test.js.map +1 -0
  97. package/dist/server/auth/providers/clerk.d.ts +51 -0
  98. package/dist/server/auth/providers/clerk.js +19 -0
  99. package/dist/server/auth/providers/clerk.js.map +1 -0
  100. package/dist/server/auth/providers/clerk.test.d.ts +1 -0
  101. package/dist/server/auth/providers/clerk.test.js +30 -0
  102. package/dist/server/auth/providers/clerk.test.js.map +1 -0
  103. package/dist/server/auth/providers/custom.d.ts +40 -0
  104. package/dist/server/auth/providers/custom.js +59 -0
  105. package/dist/server/auth/providers/custom.js.map +1 -0
  106. package/dist/server/auth/providers/custom.test.d.ts +1 -0
  107. package/dist/server/auth/providers/custom.test.js +161 -0
  108. package/dist/server/auth/providers/custom.test.js.map +1 -0
  109. package/dist/server/auth/providers/descope.d.ts +44 -0
  110. package/dist/server/auth/providers/descope.js +44 -0
  111. package/dist/server/auth/providers/descope.js.map +1 -0
  112. package/dist/server/auth/providers/descope.test.d.ts +1 -0
  113. package/dist/server/auth/providers/descope.test.js +62 -0
  114. package/dist/server/auth/providers/descope.test.js.map +1 -0
  115. package/dist/server/auth/providers/shared.d.ts +2 -0
  116. package/dist/server/auth/providers/shared.js +6 -0
  117. package/dist/server/auth/providers/shared.js.map +1 -0
  118. package/dist/server/auth/providers/shared.test.d.ts +1 -0
  119. package/dist/server/auth/providers/shared.test.js +10 -0
  120. package/dist/server/auth/providers/shared.test.js.map +1 -0
  121. package/dist/server/auth/providers/stytch.d.ts +25 -0
  122. package/dist/server/auth/providers/stytch.js +16 -0
  123. package/dist/server/auth/providers/stytch.js.map +1 -0
  124. package/dist/server/auth/providers/verify-spy.d.ts +12 -0
  125. package/dist/server/auth/providers/verify-spy.js +21 -0
  126. package/dist/server/auth/providers/verify-spy.js.map +1 -0
  127. package/dist/server/auth/providers/workos.d.ts +33 -0
  128. package/dist/server/auth/providers/workos.js +15 -0
  129. package/dist/server/auth/providers/workos.js.map +1 -0
  130. package/dist/server/auth/security-schemes.d.ts +23 -0
  131. package/dist/server/auth/security-schemes.js +64 -0
  132. package/dist/server/auth/security-schemes.js.map +1 -0
  133. package/dist/server/auth/security-schemes.test.d.ts +1 -0
  134. package/dist/server/auth/security-schemes.test.js +99 -0
  135. package/dist/server/auth/security-schemes.test.js.map +1 -0
  136. package/dist/server/auth/setup.d.ts +6 -0
  137. package/dist/server/auth/setup.js +91 -0
  138. package/dist/server/auth/setup.js.map +1 -0
  139. package/dist/server/auth/setup.test.d.ts +1 -0
  140. package/dist/server/auth/setup.test.js +514 -0
  141. package/dist/server/auth/setup.test.js.map +1 -0
  142. package/dist/server/auth/verify.d.ts +46 -0
  143. package/dist/server/auth/verify.js +62 -0
  144. package/dist/server/auth/verify.js.map +1 -0
  145. package/dist/server/auth/verify.test.d.ts +1 -0
  146. package/dist/server/auth/verify.test.js +149 -0
  147. package/dist/server/auth/verify.test.js.map +1 -0
  148. package/dist/server/auth-extra.test-d.js +130 -0
  149. package/dist/server/auth-extra.test-d.js.map +1 -0
  150. package/dist/server/auth.d.ts +57 -0
  151. package/dist/server/auth.js +27 -0
  152. package/dist/server/auth.js.map +1 -0
  153. package/dist/server/build-manifest.test.d.ts +1 -0
  154. package/dist/server/build-manifest.test.js +28 -0
  155. package/dist/server/build-manifest.test.js.map +1 -0
  156. package/dist/server/content-helpers.d.ts +41 -1
  157. package/dist/server/content-helpers.js +33 -0
  158. package/dist/server/content-helpers.js.map +1 -1
  159. package/dist/server/content-helpers.test.js.map +1 -1
  160. package/dist/server/express.d.ts +23 -7
  161. package/dist/server/express.js +42 -30
  162. package/dist/server/express.js.map +1 -1
  163. package/dist/server/express.test.js +345 -85
  164. package/dist/server/express.test.js.map +1 -1
  165. package/dist/server/file-ref.d.ts +28 -0
  166. package/dist/server/file-ref.js +27 -0
  167. package/dist/server/file-ref.js.map +1 -0
  168. package/dist/server/host.d.ts +2 -0
  169. package/dist/server/host.js +11 -0
  170. package/dist/server/host.js.map +1 -0
  171. package/dist/server/host.test.d.ts +1 -0
  172. package/dist/server/host.test.js +13 -0
  173. package/dist/server/host.test.js.map +1 -0
  174. package/dist/server/index.d.ts +18 -2
  175. package/dist/server/index.js +15 -1
  176. package/dist/server/index.js.map +1 -1
  177. package/dist/server/inferUtilityTypes.js.map +1 -1
  178. package/dist/server/mcp-errors.test.d.ts +1 -0
  179. package/dist/server/mcp-errors.test.js +41 -0
  180. package/dist/server/mcp-errors.test.js.map +1 -0
  181. package/dist/server/metric.js.map +1 -1
  182. package/dist/server/middleware.d.ts +51 -13
  183. package/dist/server/middleware.js +33 -0
  184. package/dist/server/middleware.js.map +1 -1
  185. package/dist/server/middleware.test-d.js +1 -1
  186. package/dist/server/middleware.test-d.js.map +1 -1
  187. package/dist/server/middleware.test.js +242 -134
  188. package/dist/server/middleware.test.js.map +1 -1
  189. package/dist/server/register-tool.test.d.ts +1 -0
  190. package/dist/server/register-tool.test.js +27 -0
  191. package/dist/server/register-tool.test.js.map +1 -0
  192. package/dist/server/requestOrigin.d.ts +7 -0
  193. package/dist/server/requestOrigin.js +25 -0
  194. package/dist/server/requestOrigin.js.map +1 -0
  195. package/dist/server/server.d.ts +300 -53
  196. package/dist/server/server.js +407 -297
  197. package/dist/server/server.js.map +1 -1
  198. package/dist/server/skills-integration.test.d.ts +1 -0
  199. package/dist/server/skills-integration.test.js +86 -0
  200. package/dist/server/skills-integration.test.js.map +1 -0
  201. package/dist/server/skills.d.ts +27 -0
  202. package/dist/server/skills.js +188 -0
  203. package/dist/server/skills.js.map +1 -0
  204. package/dist/server/skills.test.d.ts +1 -0
  205. package/dist/server/skills.test.js +243 -0
  206. package/dist/server/skills.test.js.map +1 -0
  207. package/dist/server/templateHelper.d.ts +0 -5
  208. package/dist/server/templateHelper.js +3 -22
  209. package/dist/server/templateHelper.js.map +1 -1
  210. package/dist/server/templates.generated.d.ts +4 -0
  211. package/dist/server/templates.generated.js +43 -0
  212. package/dist/server/templates.generated.js.map +1 -0
  213. package/dist/server/tool-extra.test.d.ts +1 -0
  214. package/dist/server/tool-extra.test.js +88 -0
  215. package/dist/server/tool-extra.test.js.map +1 -0
  216. package/dist/server/tunnel-proxy-router.js.map +1 -1
  217. package/dist/server/tunnel-proxy-router.test.js.map +1 -1
  218. package/dist/server/view-name.test-d.d.ts +1 -0
  219. package/dist/server/view-name.test-d.js +8 -0
  220. package/dist/server/view-name.test-d.js.map +1 -0
  221. package/dist/server/view-resource-resolution.test.d.ts +6 -0
  222. package/dist/server/view-resource-resolution.test.js +176 -0
  223. package/dist/server/view-resource-resolution.test.js.map +1 -0
  224. package/dist/server/viewsDevServer.js +4 -1
  225. package/dist/server/viewsDevServer.js.map +1 -1
  226. package/dist/test/utils.d.ts +9 -11
  227. package/dist/test/utils.js +220 -201
  228. package/dist/test/utils.js.map +1 -1
  229. package/dist/test/view.test.js +123 -106
  230. package/dist/test/view.test.js.map +1 -1
  231. package/dist/version.js +1 -3
  232. package/dist/version.js.map +1 -1
  233. package/dist/views/index.d.ts +10 -0
  234. package/dist/views/index.js +3 -0
  235. package/dist/views/index.js.map +1 -0
  236. package/dist/{web/plugin → views}/scan-views.js +1 -1
  237. package/dist/views/scan-views.js.map +1 -0
  238. package/dist/views/scan-views.test.d.ts +1 -0
  239. package/dist/views/scan-views.test.js.map +1 -0
  240. package/dist/views/validate-view.d.ts +1 -0
  241. package/dist/{web/plugin → views}/validate-view.js +2 -2
  242. package/dist/views/validate-view.js.map +1 -0
  243. package/dist/views/validate-view.test.d.ts +1 -0
  244. package/dist/views/validate-view.test.js.map +1 -0
  245. package/dist/web/bridges/adaptor.d.ts +51 -0
  246. package/dist/web/bridges/adaptor.js +327 -0
  247. package/dist/web/bridges/adaptor.js.map +1 -0
  248. package/dist/web/bridges/adaptor.test.d.ts +1 -0
  249. package/dist/web/bridges/adaptor.test.js +225 -0
  250. package/dist/web/bridges/adaptor.test.js.map +1 -0
  251. package/dist/web/bridges/apps-sdk/bridge.d.ts +6 -1
  252. package/dist/web/bridges/apps-sdk/bridge.js +15 -3
  253. package/dist/web/bridges/apps-sdk/bridge.js.map +1 -1
  254. package/dist/web/bridges/apps-sdk/index.d.ts +0 -1
  255. package/dist/web/bridges/apps-sdk/index.js +0 -1
  256. package/dist/web/bridges/apps-sdk/index.js.map +1 -1
  257. package/dist/web/bridges/apps-sdk/types.d.ts +8 -1
  258. package/dist/web/bridges/apps-sdk/types.js.map +1 -1
  259. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.d.ts +11 -0
  260. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js +11 -0
  261. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js.map +1 -1
  262. package/dist/web/bridges/get-adaptor.d.ts +7 -0
  263. package/dist/web/bridges/get-adaptor.js +9 -7
  264. package/dist/web/bridges/get-adaptor.js.map +1 -1
  265. package/dist/web/bridges/get-adaptor.test.d.ts +1 -0
  266. package/dist/web/bridges/get-adaptor.test.js +32 -0
  267. package/dist/web/bridges/get-adaptor.test.js.map +1 -0
  268. package/dist/web/bridges/index.js.map +1 -1
  269. package/dist/web/bridges/mcp-app/bridge.d.ts +15 -2
  270. package/dist/web/bridges/mcp-app/bridge.js +73 -7
  271. package/dist/web/bridges/mcp-app/bridge.js.map +1 -1
  272. package/dist/web/bridges/mcp-app/bridge.test.d.ts +1 -0
  273. package/dist/web/bridges/mcp-app/bridge.test.js +17 -0
  274. package/dist/web/bridges/mcp-app/bridge.test.js.map +1 -0
  275. package/dist/web/bridges/mcp-app/index.d.ts +0 -1
  276. package/dist/web/bridges/mcp-app/index.js +0 -1
  277. package/dist/web/bridges/mcp-app/index.js.map +1 -1
  278. package/dist/web/bridges/mcp-app/types.d.ts +2 -0
  279. package/dist/web/bridges/mcp-app/types.js.map +1 -1
  280. package/dist/web/bridges/mcp-app/use-mcp-app-context.d.ts +12 -0
  281. package/dist/web/bridges/mcp-app/use-mcp-app-context.js +12 -0
  282. package/dist/web/bridges/mcp-app/use-mcp-app-context.js.map +1 -1
  283. package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js +1 -1
  284. package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js.map +1 -1
  285. package/dist/web/bridges/mcp-app/view-tools.test.d.ts +1 -0
  286. package/dist/web/bridges/mcp-app/view-tools.test.js +143 -0
  287. package/dist/web/bridges/mcp-app/view-tools.test.js.map +1 -0
  288. package/dist/web/bridges/types.d.ts +115 -5
  289. package/dist/web/bridges/types.js +14 -1
  290. package/dist/web/bridges/types.js.map +1 -1
  291. package/dist/web/bridges/types.test.d.ts +1 -0
  292. package/dist/web/bridges/types.test.js +19 -0
  293. package/dist/web/bridges/types.test.js.map +1 -0
  294. package/dist/web/bridges/use-host-context.d.ts +5 -0
  295. package/dist/web/bridges/use-host-context.js +5 -0
  296. package/dist/web/bridges/use-host-context.js.map +1 -1
  297. package/dist/web/components/modal-provider.d.ts +1 -1
  298. package/dist/web/components/modal-provider.js +4 -3
  299. package/dist/web/components/modal-provider.js.map +1 -1
  300. package/dist/web/create-store.d.ts +26 -0
  301. package/dist/web/create-store.js +26 -0
  302. package/dist/web/create-store.js.map +1 -1
  303. package/dist/web/create-store.test.js +10 -7
  304. package/dist/web/create-store.test.js.map +1 -1
  305. package/dist/web/data-llm.d.ts +34 -1
  306. package/dist/web/data-llm.js +28 -0
  307. package/dist/web/data-llm.js.map +1 -1
  308. package/dist/web/data-llm.test.js +20 -7
  309. package/dist/web/data-llm.test.js.map +1 -1
  310. package/dist/web/generate-helpers.d.ts +24 -18
  311. package/dist/web/generate-helpers.js +21 -15
  312. package/dist/web/generate-helpers.js.map +1 -1
  313. package/dist/web/generate-helpers.test-d.js +7 -5
  314. package/dist/web/generate-helpers.test-d.js.map +1 -1
  315. package/dist/web/generate-helpers.test.js +2 -2
  316. package/dist/web/generate-helpers.test.js.map +1 -1
  317. package/dist/web/helpers/state.js.map +1 -1
  318. package/dist/web/helpers/state.test.js.map +1 -1
  319. package/dist/web/hooks/index.d.ts +6 -1
  320. package/dist/web/hooks/index.js +6 -1
  321. package/dist/web/hooks/index.js.map +1 -1
  322. package/dist/web/hooks/test/utils.d.ts +7 -2
  323. package/dist/web/hooks/test/utils.js +14 -3
  324. package/dist/web/hooks/test/utils.js.map +1 -1
  325. package/dist/web/hooks/use-call-tool.d.ts +45 -0
  326. package/dist/web/hooks/use-call-tool.js +28 -0
  327. package/dist/web/hooks/use-call-tool.js.map +1 -1
  328. package/dist/web/hooks/use-call-tool.test-d.js.map +1 -1
  329. package/dist/web/hooks/use-call-tool.test.js +64 -29
  330. package/dist/web/hooks/use-call-tool.test.js.map +1 -1
  331. package/dist/web/hooks/use-display-mode.d.ts +20 -0
  332. package/dist/web/hooks/use-display-mode.js +20 -0
  333. package/dist/web/hooks/use-display-mode.js.map +1 -1
  334. package/dist/web/hooks/use-display-mode.test-d.js.map +1 -1
  335. package/dist/web/hooks/use-display-mode.test.js +57 -21
  336. package/dist/web/hooks/use-display-mode.test.js.map +1 -1
  337. package/dist/web/hooks/use-download.d.ts +3 -0
  338. package/dist/web/hooks/use-download.js +7 -0
  339. package/dist/web/hooks/use-download.js.map +1 -0
  340. package/dist/web/hooks/use-download.test.d.ts +1 -0
  341. package/dist/web/hooks/use-download.test.js +103 -0
  342. package/dist/web/hooks/use-download.test.js.map +1 -0
  343. package/dist/web/hooks/use-files.d.ts +32 -0
  344. package/dist/web/hooks/use-files.js +32 -0
  345. package/dist/web/hooks/use-files.js.map +1 -1
  346. package/dist/web/hooks/use-files.test.js +11 -3
  347. package/dist/web/hooks/use-files.test.js.map +1 -1
  348. package/dist/web/hooks/use-host.d.ts +22 -0
  349. package/dist/web/hooks/use-host.js +30 -0
  350. package/dist/web/hooks/use-host.js.map +1 -0
  351. package/dist/web/hooks/use-host.test.d.ts +1 -0
  352. package/dist/web/hooks/use-host.test.js +59 -0
  353. package/dist/web/hooks/use-host.test.js.map +1 -0
  354. package/dist/web/hooks/use-open-external.d.ts +17 -0
  355. package/dist/web/hooks/use-open-external.js +16 -0
  356. package/dist/web/hooks/use-open-external.js.map +1 -1
  357. package/dist/web/hooks/use-open-external.test.js +15 -5
  358. package/dist/web/hooks/use-open-external.test.js.map +1 -1
  359. package/dist/web/hooks/use-register-view-tool.d.ts +37 -0
  360. package/dist/web/hooks/use-register-view-tool.js +50 -0
  361. package/dist/web/hooks/use-register-view-tool.js.map +1 -0
  362. package/dist/web/hooks/use-request-close.d.ts +16 -0
  363. package/dist/web/hooks/use-request-close.js +21 -0
  364. package/dist/web/hooks/use-request-close.js.map +1 -0
  365. package/dist/web/hooks/use-request-close.test.d.ts +1 -0
  366. package/dist/web/hooks/use-request-close.test.js +47 -0
  367. package/dist/web/hooks/use-request-close.test.js.map +1 -0
  368. package/dist/web/hooks/use-request-modal.d.ts +16 -1
  369. package/dist/web/hooks/use-request-modal.js +16 -1
  370. package/dist/web/hooks/use-request-modal.js.map +1 -1
  371. package/dist/web/hooks/use-request-modal.test.js +11 -1
  372. package/dist/web/hooks/use-request-modal.test.js.map +1 -1
  373. package/dist/web/hooks/use-request-size.d.ts +20 -0
  374. package/dist/web/hooks/use-request-size.js +24 -0
  375. package/dist/web/hooks/use-request-size.js.map +1 -0
  376. package/dist/web/hooks/use-request-size.test.d.ts +1 -0
  377. package/dist/web/hooks/use-request-size.test.js +47 -0
  378. package/dist/web/hooks/use-request-size.test.js.map +1 -0
  379. package/dist/web/hooks/use-send-follow-up-message.d.ts +19 -1
  380. package/dist/web/hooks/use-send-follow-up-message.js +19 -2
  381. package/dist/web/hooks/use-send-follow-up-message.js.map +1 -1
  382. package/dist/web/hooks/use-set-open-in-app-url.d.ts +17 -0
  383. package/dist/web/hooks/use-set-open-in-app-url.js +17 -0
  384. package/dist/web/hooks/use-set-open-in-app-url.js.map +1 -1
  385. package/dist/web/hooks/use-set-open-in-app-url.test.js +26 -12
  386. package/dist/web/hooks/use-set-open-in-app-url.test.js.map +1 -1
  387. package/dist/web/hooks/use-tool-info.d.ts +46 -14
  388. package/dist/web/hooks/use-tool-info.js +29 -7
  389. package/dist/web/hooks/use-tool-info.js.map +1 -1
  390. package/dist/web/hooks/use-tool-info.test-d.js +11 -34
  391. package/dist/web/hooks/use-tool-info.test-d.js.map +1 -1
  392. package/dist/web/hooks/use-tool-info.test.js +42 -37
  393. package/dist/web/hooks/use-tool-info.test.js.map +1 -1
  394. package/dist/web/hooks/use-user.d.ts +5 -2
  395. package/dist/web/hooks/use-user.js +6 -3
  396. package/dist/web/hooks/use-user.js.map +1 -1
  397. package/dist/web/hooks/use-user.test.js +85 -37
  398. package/dist/web/hooks/use-user.test.js.map +1 -1
  399. package/dist/web/hooks/use-view-state.d.ts +21 -0
  400. package/dist/web/hooks/use-view-state.js +19 -9
  401. package/dist/web/hooks/use-view-state.js.map +1 -1
  402. package/dist/web/hooks/use-view-state.test.js +39 -4
  403. package/dist/web/hooks/use-view-state.test.js.map +1 -1
  404. package/dist/web/hooks/use-viewport.d.ts +20 -0
  405. package/dist/web/hooks/use-viewport.js +21 -0
  406. package/dist/web/hooks/use-viewport.js.map +1 -0
  407. package/dist/web/hooks/use-viewport.test.d.ts +1 -0
  408. package/dist/web/hooks/use-viewport.test.js +109 -0
  409. package/dist/web/hooks/use-viewport.test.js.map +1 -0
  410. package/dist/web/index.js.map +1 -1
  411. package/dist/web/mount-view.d.ts +20 -0
  412. package/dist/web/mount-view.js +22 -6
  413. package/dist/web/mount-view.js.map +1 -1
  414. package/dist/web/proxy.js.map +1 -1
  415. package/dist/web/types.d.ts +4 -0
  416. package/dist/web/types.js.map +1 -1
  417. package/package.json +40 -26
  418. package/dist/server/templates/development.hbs +0 -12
  419. package/dist/server/templates/production.hbs +0 -6
  420. package/dist/web/bridges/apps-sdk/adaptor.d.ts +0 -24
  421. package/dist/web/bridges/apps-sdk/adaptor.js +0 -93
  422. package/dist/web/bridges/apps-sdk/adaptor.js.map +0 -1
  423. package/dist/web/bridges/mcp-app/adaptor.d.ts +0 -48
  424. package/dist/web/bridges/mcp-app/adaptor.js +0 -268
  425. package/dist/web/bridges/mcp-app/adaptor.js.map +0 -1
  426. package/dist/web/hooks/use-layout.d.ts +0 -22
  427. package/dist/web/hooks/use-layout.js +0 -23
  428. package/dist/web/hooks/use-layout.js.map +0 -1
  429. package/dist/web/hooks/use-layout.test.js +0 -96
  430. package/dist/web/hooks/use-layout.test.js.map +0 -1
  431. package/dist/web/plugin/data-llm.test.js +0 -81
  432. package/dist/web/plugin/data-llm.test.js.map +0 -1
  433. package/dist/web/plugin/plugin.d.ts +0 -5
  434. package/dist/web/plugin/plugin.js +0 -163
  435. package/dist/web/plugin/plugin.js.map +0 -1
  436. package/dist/web/plugin/scan-views.js.map +0 -1
  437. package/dist/web/plugin/scan-views.test.js.map +0 -1
  438. package/dist/web/plugin/transform-data-llm.d.ts +0 -12
  439. package/dist/web/plugin/transform-data-llm.js +0 -96
  440. package/dist/web/plugin/transform-data-llm.js.map +0 -1
  441. package/dist/web/plugin/transform-data-llm.test.js +0 -81
  442. package/dist/web/plugin/transform-data-llm.test.js.map +0 -1
  443. package/dist/web/plugin/validate-view.d.ts +0 -1
  444. package/dist/web/plugin/validate-view.js.map +0 -1
  445. package/dist/web/plugin/validate-view.test.js.map +0 -1
  446. /package/dist/{web/hooks/use-layout.test.d.ts → cli/build-helpers.test.d.ts} +0 -0
  447. /package/dist/{web/plugin/data-llm.test.d.ts → cli/build-steps.test.d.ts} +0 -0
  448. /package/dist/{web/plugin/scan-views.test.d.ts → context-warnings.test.d.ts} +0 -0
  449. /package/dist/{web/plugin/transform-data-llm.test.d.ts → server/app.test.d.ts} +0 -0
  450. /package/dist/{web/plugin/validate-view.test.d.ts → server/auth-extra.test-d.d.ts} +0 -0
  451. /package/dist/{web/plugin → views}/scan-views.d.ts +0 -0
  452. /package/dist/{web/plugin → views}/scan-views.test.js +0 -0
  453. /package/dist/{web/plugin → views}/validate-view.test.js +0 -0
@@ -10,9 +10,24 @@ function toBase64(data) {
10
10
  }
11
11
  return Buffer.from(data).toString("base64");
12
12
  }
13
+ /**
14
+ * Build an MCP text content block.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * return { content: [text("Found 3 results.")] };
19
+ * ```
20
+ */
13
21
  export function text(value, annotations) {
14
22
  return { type: "text", text: value, ...(annotations && { annotations }) };
15
23
  }
24
+ /**
25
+ * Build an MCP image content block.
26
+ *
27
+ * `data` may be a `Uint8Array` (encoded to base64 for you) or a string that is
28
+ * **already base64-encoded**. Passing a raw byte-string will produce invalid
29
+ * content.
30
+ */
16
31
  export function image(data, mimeType, annotations) {
17
32
  return {
18
33
  type: "image",
@@ -21,6 +36,12 @@ export function image(data, mimeType, annotations) {
21
36
  ...(annotations && { annotations }),
22
37
  };
23
38
  }
39
+ /**
40
+ * Build an MCP audio content block.
41
+ *
42
+ * `data` may be a `Uint8Array` (encoded to base64 for you) or a string that is
43
+ * **already base64-encoded**.
44
+ */
24
45
  export function audio(data, mimeType, annotations) {
25
46
  return {
26
47
  type: "audio",
@@ -29,6 +50,12 @@ export function audio(data, mimeType, annotations) {
29
50
  ...(annotations && { annotations }),
30
51
  };
31
52
  }
53
+ /**
54
+ * Build an MCP embedded resource — the full content travels inline. Use this
55
+ * when the client needs the bytes themselves rather than a link.
56
+ *
57
+ * Pass either `text` (UTF-8 string) or `blob` (base64-encoded bytes).
58
+ */
32
59
  export function embeddedResource(resource, annotations) {
33
60
  return {
34
61
  type: "resource",
@@ -36,6 +63,12 @@ export function embeddedResource(resource, annotations) {
36
63
  ...(annotations && { annotations }),
37
64
  };
38
65
  }
66
+ /**
67
+ * Build an MCP resource link — a `type: "resource_link"` block carrying a URI
68
+ * the client can fetch (or subscribe to) on demand. Use a link when the
69
+ * client should retrieve the bytes itself; use {@link embeddedResource} when
70
+ * the content must travel inline with the response.
71
+ */
39
72
  export function resourceLink(link, annotations) {
40
73
  return {
41
74
  type: "resource_link",
@@ -1 +1 @@
1
- {"version":3,"file":"content-helpers.js","sourceRoot":"","sources":["../../src/server/content-helpers.ts"],"names":[],"mappings":"AAcA;;;;;GAKG;AACH,SAAS,QAAQ,CAAC,IAAyB;IACzC,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,IAAI,CAClB,KAAa,EACb,WAAgC;IAEhC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,WAAW,IAAI,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC;AAC5E,CAAC;AAED,MAAM,UAAU,KAAK,CACnB,IAAyB,EACzB,QAAgB,EAChB,WAAgC;IAEhC,OAAO;QACL,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC;QACpB,QAAQ;QACR,GAAG,CAAC,WAAW,IAAI,EAAE,WAAW,EAAE,CAAC;KACpC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,KAAK,CACnB,IAAyB,EACzB,QAA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ACR,GAAG,CAAC,WAAW,IAAI,EAAE,WAAW,EAAE,CAAC;KACpC,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CACnB,IAAyB,EACzB,QAAgB,EAChB,WAAgC;IAEhC,OAAO;QACL,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC;QACpB,QAAQ;QACR,GAAG,CAAC,WAAW,IAAI,EAAE,WAAW,EAAE,CAAC;KACpC,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAC9B,QAEoD,EACpD,WAAgC;IAEhC,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,QAAQ;QACR,GAAG,CAAC,WAAW,IAAI,EAAE,WAAW,EAAE,CAAC;KACpC,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAC1B,IAOC,EACD,WAAgC;IAEhC,OAAO;QACL,IAAI,EAAE,eAAe;QACrB,GAAG,IAAI;QACP,GAAG,CAAC,WAAW,IAAI,EAAE,WAAW,EAAE,CAAC;KACpC,CAAC;AACJ,CAAC","sourcesContent":["import type {\n AudioContent,\n EmbeddedResource,\n ImageContent,\n ResourceLink,\n TextContent,\n} from \"@modelcontextprotocol/server\";\n\n/**\n * MCP content annotations applied to any returned block.\n *\n * - `audience` — who is meant to see the content (`\"user\"`, `\"assistant\"`, or both).\n * - `priority` — relative importance hint for the host.\n * - `lastModified` — ISO timestamp for when the content was produced.\n */\ntype ContentAnnotations = {\n audience?: (\"user\" | \"assistant\")[];\n priority?: number;\n lastModified?: string;\n};\n\n/**\n * Returns a base64-encoded string.\n * - `Uint8Array` input is encoded via `Buffer.toString(\"base64\")`.\n * - `string` input is assumed to be **already base64-encoded** and is returned\n * as-is. Passing raw/unencoded string bytes will produce invalid MCP content.\n */\nfunction toBase64(data: string | Uint8Array): string {\n if (typeof data === \"string\") {\n return data;\n }\n return Buffer.from(data).toString(\"base64\");\n}\n\n/**\n * Build an MCP text content block.\n *\n * @example\n * ```ts\n * return { content: [text(\"Found 3 results.\")] };\n * ```\n */\nexport function text(\n value: string,\n annotations?: ContentAnnotations,\n): TextContent {\n return { type: \"text\", text: value, ...(annotations && { annotations }) };\n}\n\n/**\n * Build an MCP image content block.\n *\n * `data` may be a `Uint8Array` (encoded to base64 for you) or a string that is\n * **already base64-encoded**. Passing a raw byte-string will produce invalid\n * content.\n */\nexport function image(\n data: string | Uint8Array,\n mimeType: string,\n annotations?: ContentAnnotations,\n): ImageContent {\n return {\n type: \"image\",\n data: toBase64(data),\n mimeType,\n ...(annotations && { annotations }),\n };\n}\n\n/**\n * Build an MCP audio content block.\n *\n * `data` may be a `Uint8Array` (encoded to base64 for you) or a string that is\n * **already base64-encoded**.\n */\nexport function audio(\n data: string | Uint8Array,\n mimeType: string,\n annotations?: ContentAnnotations,\n): AudioContent {\n return {\n type: \"audio\",\n data: toBase64(data),\n mimeType,\n ...(annotations && { annotations }),\n };\n}\n\n/**\n * Build an MCP embedded resource — the full content travels inline. Use this\n * when the client needs the bytes themselves rather than a link.\n *\n * Pass either `text` (UTF-8 string) or `blob` (base64-encoded bytes).\n */\nexport function embeddedResource(\n resource:\n | { uri: string; mimeType?: string; text: string }\n | { uri: string; mimeType?: string; blob: string },\n annotations?: ContentAnnotations,\n): EmbeddedResource {\n return {\n type: \"resource\",\n resource,\n ...(annotations && { annotations }),\n };\n}\n\n/**\n * Build an MCP resource link — a `type: \"resource_link\"` block carrying a URI\n * the client can fetch (or subscribe to) on demand. Use a link when the\n * client should retrieve the bytes itself; use {@link embeddedResource} when\n * the content must travel inline with the response.\n */\nexport function resourceLink(\n link: {\n uri: string;\n name: string;\n title?: string;\n description?: string;\n mimeType?: string;\n size?: number;\n },\n annotations?: ContentAnnotations,\n): ResourceLink {\n return {\n type: \"resource_link\",\n ...link,\n ...(annotations && { annotations }),\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"content-helpers.test.js","sourceRo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AC,OAAO,CAAC;YACR,IAAI,EAAE,UAAU;YAChB,QAAQ,EAAE,EAAE,GAAG,EAAE,eAAe,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,GAAG,EAAE;SACtE,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;QAC/C,MAAM,CAAC,gBAAgB,CAAC,EAAE,GAAG,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;YACvE,IAAI,EAAE,UAAU;YAChB,QAAQ,EAAE,EAAE,GAAG,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE;SACjD,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;QACpD,MAAM,CAAC,YAAY,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;YACxE,IAAI,EAAE,eAAe;YACrB,GAAG,EAAE,WAAW;YAChB,IAAI,EAAE,GAAG;YACT,KAAK,EAAE,GAAG;SACX,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { describe, expect, it } from \"vitest\";\nimport {\n audio,\n embeddedResource,\n image,\n resourceLink,\n text,\n} from \"./content-helpers.js\";\n\ndescribe(\"text\", () => {\n it(\"returns a TextContent without annotations when none given\", () => {\n expect(text(\"hello\")).toEqual({ type: \"text\", text: \"hello\" });\n });\n\n it(\"includes annotations when provided\", () => {\n expect(text(\"hi\", { priority: 1 })).toEqual({\n type: \"text\",\n text: \"hi\",\n annotations: { priority: 1 },\n });\n });\n});\n\ndescribe(\"image\", () => {\n it(\"base64-encodes Uint8Array data\", () => {\n const bytes = new Uint8Array([104, 105]);\n expect(image(bytes, \"image/png\")).toEqual({\n type: \"image\",\n data: \"aGk=\",\n mimeType: \"image/png\",\n });\n });\n\n it(\"passes string data through unchanged (caller is responsible for base64)\", () => {\n expect(image(\"YWxyZWFkeS1iNjQ=\", \"image/png\")).toEqual({\n type: \"image\",\n data: \"YWxyZWFkeS1iNjQ=\",\n mimeType: \"image/png\",\n });\n });\n});\n\ndescribe(\"audio\", () => {\n it(\"base64-encodes Uint8Array data\", () => {\n const bytes = new Uint8Array([104, 105]);\n expect(audio(bytes, \"audio/mpeg\")).toMatchObject({\n type: \"audio\",\n data: \"aGk=\",\n mimeType: \"audio/mpeg\",\n });\n });\n});\n\ndescribe(\"embeddedResource\", () => {\n it(\"wraps a text resource with a type tag\", () => {\n expect(\n embeddedResource({\n uri: \"file:///a.txt\",\n mimeType: \"text/plain\",\n text: \"x\",\n }),\n ).toEqual({\n type: \"resource\",\n resource: { uri: \"file:///a.txt\", mimeType: \"text/plain\", text: \"x\" },\n });\n });\n\n it(\"wraps a blob resource with a type tag\", () => {\n expect(embeddedResource({ uri: \"file:///a.bin\", blob: \"YmFy\" })).toEqual({\n type: \"resource\",\n resource: { uri: \"file:///a.bin\", blob: \"YmFy\" },\n });\n });\n});\n\ndescribe(\"resourceLink\", () => {\n it(\"spreads link fields alongside the type tag\", () => {\n expect(resourceLink({ uri: \"file:///a\", name: \"a\", title: \"A\" })).toEqual({\n type: \"resource_link\",\n uri: \"file:///a\",\n name: \"a\",\n title: \"A\",\n });\n });\n});\n"]}
@@ -1,15 +1,31 @@
1
1
  import type http from "node:http";
2
+ import { type McpHttpHandler } from "@modelcontextprotocol/server";
2
3
  import express from "express";
3
- import type { McpServer } from "./server.js";
4
- export declare function createApp({ mcpServer, httpServer, customMiddleware, errorMiddleware, }: {
5
- mcpServer: McpServer;
4
+ import type { Skybridge } from "./app.js";
5
+ import type { JsonOptions } from "./server.js";
6
+ type SkybridgeApp = Pick<Skybridge, "express" | "createServerInstance" | "ready">;
7
+ /**
8
+ * The `/mcp` fetch handler for a {@link Skybridge} app: a `Request` →
9
+ * `Response` function that builds a fresh MCP server per request.
10
+ *
11
+ * @internal
12
+ */
13
+ export declare function buildMcpHandler(skybridgeApp: SkybridgeApp): McpHttpHandler;
14
+ /**
15
+ * Build the bare Express app a {@link Skybridge} instance owns: the instance
16
+ * plus the built-in `express.json()` body parser, tuned by the `json` config
17
+ * field.
18
+ *
19
+ * @internal
20
+ */
21
+ export declare function createBaseApp(json?: JsonOptions): express.Express;
22
+ export declare function createApp({ app: skybridgeApp, httpServer, mcpHandler, errorMiddleware, }: {
23
+ app: SkybridgeApp;
6
24
  httpServer: http.Server;
7
- customMiddleware?: {
8
- path?: string;
9
- handlers: express.RequestHandler[];
10
- }[];
25
+ mcpHandler?: McpHttpHandler;
11
26
  errorMiddleware?: {
12
27
  path?: string;
13
28
  handlers: express.ErrorRequestHandler[];
14
29
  }[];
15
30
  }): Promise<express.Express>;
31
+ export {};
@@ -1,7 +1,36 @@
1
1
  import path from "node:path";
2
- import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
2
+ import { toNodeHandler } from "@modelcontextprotocol/node";
3
+ import { createMcpHandler, UnsupportedProtocolVersionError, } from "@modelcontextprotocol/server";
3
4
  import cors from "cors";
4
5
  import express from "express";
6
+ /**
7
+ * The `/mcp` fetch handler for a {@link Skybridge} app: a `Request` →
8
+ * `Response` function that builds a fresh MCP server per request.
9
+ *
10
+ * @internal
11
+ */
12
+ export function buildMcpHandler(skybridgeApp) {
13
+ return createMcpHandler(() => skybridgeApp.createServerInstance(), {
14
+ onerror: (error) => {
15
+ if (error instanceof UnsupportedProtocolVersionError) {
16
+ return;
17
+ }
18
+ console.error("Error handling MCP request:", error);
19
+ },
20
+ });
21
+ }
22
+ /**
23
+ * Build the bare Express app a {@link Skybridge} instance owns: the instance
24
+ * plus the built-in `express.json()` body parser, tuned by the `json` config
25
+ * field.
26
+ *
27
+ * @internal
28
+ */
29
+ export function createBaseApp(json) {
30
+ const app = express();
31
+ app.use(express.json(json));
32
+ return app;
33
+ }
5
34
  function parseControlPort(raw) {
6
35
  if (raw === undefined) {
7
36
  return null;
@@ -32,12 +61,12 @@ function defaultErrorHandler(err, _req, res, _next) {
32
61
  });
33
62
  }
34
63
  }
35
- export async function createApp({ mcpServer, httpServer, customMiddleware = [], errorMiddleware = [], }) {
36
- const app = express();
37
- app.use(express.json());
38
- const env = process.env.NODE_ENV || "development";
39
- applyMiddlewares(app, customMiddleware);
40
- if (env !== "production") {
64
+ export async function createApp({ app: skybridgeApp, httpServer, mcpHandler, errorMiddleware = [], }) {
65
+ await skybridgeApp.ready();
66
+ const app = skybridgeApp.express;
67
+ // Read `process.env.NODE_ENV` inline: wrangler/esbuild only substitute the literal expression,
68
+ // so a local const would defeat dead-code elimination of the dev-only imports below.
69
+ if (process.env.NODE_ENV !== "production") {
41
70
  const { devtoolsStaticServer } = await import("@skybridge/devtools");
42
71
  app.use(await devtoolsStaticServer());
43
72
  const { viewsDevServer } = await import("./viewsDevServer.js");
@@ -51,41 +80,24 @@ export async function createApp({ mcpServer, httpServer, customMiddleware = [],
51
80
  console.warn(`Ignoring invalid __TUNNEL_CONTROL_PORT=${process.env.__TUNNEL_CONTROL_PORT}`);
52
81
  }
53
82
  }
54
- if (env === "production") {
83
+ else {
55
84
  const assetsPath = path.join(process.cwd(), "dist", "assets");
56
85
  app.use("/assets", cors());
57
86
  app.use("/assets", express.static(assetsPath));
58
87
  }
59
- app.use("/mcp", mcpMiddleware(mcpServer));
88
+ app.use("/mcp", mcpMiddleware(mcpHandler ?? buildMcpHandler(skybridgeApp)));
60
89
  applyMiddlewares(app, errorMiddleware);
61
90
  app.use("/mcp", defaultErrorHandler);
62
91
  return app;
63
92
  }
64
- const mcpMiddleware = (server) => {
93
+ const mcpMiddleware = (mcpHandler) => {
94
+ const handler = toNodeHandler(mcpHandler);
65
95
  return async (req, res, next) => {
66
- if (req.method !== "POST") {
67
- res.writeHead(405).end(JSON.stringify({
68
- jsonrpc: "2.0",
69
- error: {
70
- code: -32000,
71
- message: "Method not allowed.",
72
- },
73
- id: null,
74
- }));
75
- return;
76
- }
77
96
  try {
78
- const transport = new StreamableHTTPServerTransport({
79
- sessionIdGenerator: undefined,
80
- });
81
- res.on("close", () => {
82
- transport.close();
83
- });
84
- await server.connectStatelessTransport(transport);
85
97
  // Express strips the mount path from req.url (e.g. "/mcp" becomes "/").
86
- // Restore it so the SDK builds the correct requestInfo.url.
98
+ // Restore it so the SDK builds the correct request URL.
87
99
  req.url = req.originalUrl;
88
- await transport.handleRequest(req, res, req.body);
100
+ await handler(req, res, req.body);
89
101
  }
90
102
  catch (error) {
91
103
  next(error);
@@ -1 +1 @@
1
- {"version":3,"file":"express.js","sourceRoot":"","sources":["../../src/server/express.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AACnG,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,OAAO,MAAM,SAAS,CAAC;AAG9B,SAAS,gBAAgB,CAAC,GAAuB;IAC/C,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IACnC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC;QAChD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC;AAED,SAAS,gBAAgB,CACvB,GAAoB,EACpB,WAGE;IAEF,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACrC,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC;YACpB,GAAG,CAAC,GAAG,CAAC,UA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\";\nimport path from \"node:path\";\nimport { toNodeHandler } from \"@modelcontextprotocol/node\";\nimport {\n createMcpHandler,\n type McpHttpHandler,\n UnsupportedProtocolVersionError,\n} from \"@modelcontextprotocol/server\";\nimport cors from \"cors\";\nimport express from \"express\";\nimport type { Skybridge } from \"./app.js\";\nimport type { JsonOptions } from \"./server.js\";\n\ntype SkybridgeApp = Pick<\n Skybridge,\n \"express\" | \"createServerInstance\" | \"ready\"\n>;\n\n/**\n * The `/mcp` fetch handler for a {@link Skybridge} app: a `Request` →\n * `Response` function that builds a fresh MCP server per request.\n *\n * @internal\n */\nexport function buildMcpHandler(skybridgeApp: SkybridgeApp): McpHttpHandler {\n return createMcpHandler(() => skybridgeApp.createServerInstance(), {\n onerror: (error) => {\n if (error instanceof UnsupportedProtocolVersionError) {\n return;\n }\n console.error(\"Error handling MCP request:\", error);\n },\n });\n}\n\n/**\n * Build the bare Express app a {@link Skybridge} instance owns: the instance\n * plus the built-in `express.json()` body parser, tuned by the `json` config\n * field.\n *\n * @internal\n */\nexport function createBaseApp(json?: JsonOptions): express.Express {\n const app = express();\n app.use(express.json(json));\n return app;\n}\n\nfunction parseControlPort(raw: string | undefined): number | null {\n if (raw === undefined) {\n return null;\n }\n const n = Number.parseInt(raw, 10);\n if (!Number.isFinite(n) || n <= 0 || n >= 65536) {\n return null;\n }\n return n;\n}\n\nfunction applyMiddlewares(\n app: express.Express,\n middlewares: Array<{\n path?: string;\n handlers: express.ErrorRequestHandler[];\n }>,\n): void {\n for (const middleware of middlewares) {\n if (middleware.path) {\n app.use(middleware.path, ...middleware.handlers);\n } else {\n app.use(...middleware.handlers);\n }\n }\n}\n\nfunction defaultErrorHandler(\n err: unknown,\n _req: express.Request,\n res: express.Response,\n _next: express.NextFunction,\n) {\n console.error(\"Error handling MCP request:\", err);\n if (!res.headersSent) {\n res.status(500).json({\n jsonrpc: \"2.0\",\n error: { code: -32603, message: \"Internal server error\" },\n id: null,\n });\n }\n}\n\nexport async function createApp({\n app: skybridgeApp,\n httpServer,\n mcpHandler,\n errorMiddleware = [],\n}: {\n app: SkybridgeApp;\n httpServer: http.Server;\n mcpHandler?: McpHttpHandler;\n errorMiddleware?: {\n path?: string;\n handlers: express.ErrorRequestHandler[];\n }[];\n}): Promise<express.Express> {\n await skybridgeApp.ready();\n const app = skybridgeApp.express;\n\n // Read `process.env.NODE_ENV` inline: wrangler/esbuild only substitute the literal expression,\n // so a local const would defeat dead-code elimination of the dev-only imports below.\n if (process.env.NODE_ENV !== \"production\") {\n const { devtoolsStaticServer } = await import(\"@skybridge/devtools\");\n app.use(await devtoolsStaticServer());\n const { viewsDevServer } = await import(\"./viewsDevServer.js\");\n app.use(await viewsDevServer(httpServer));\n\n const controlPort = parseControlPort(process.env.__TUNNEL_CONTROL_PORT);\n if (controlPort !== null) {\n const { createTunnelProxyRouter } = await import(\n \"./tunnel-proxy-router.js\"\n );\n app.use(createTunnelProxyRouter(controlPort));\n } else if (process.env.__TUNNEL_CONTROL_PORT !== undefined) {\n console.warn(\n `Ignoring invalid __TUNNEL_CONTROL_PORT=${process.env.__TUNNEL_CONTROL_PORT}`,\n );\n }\n } else {\n const assetsPath = path.join(process.cwd(), \"dist\", \"assets\");\n\n app.use(\"/assets\", cors());\n app.use(\"/assets\", express.static(assetsPath));\n }\n\n app.use(\"/mcp\", mcpMiddleware(mcpHandler ?? buildMcpHandler(skybridgeApp)));\n\n applyMiddlewares(app, errorMiddleware);\n\n app.use(\"/mcp\", defaultErrorHandler);\n\n return app;\n}\n\nconst mcpMiddleware = (mcpHandler: McpHttpHandler): express.RequestHandler => {\n const handler = toNodeHandler(mcpHandler);\n\n return async (\n req: express.Request,\n res: express.Response,\n next: express.NextFunction,\n ) => {\n try {\n // Express strips the mount path from req.url (e.g. \"/mcp\" becomes \"/\").\n // Restore it so the SDK builds the correct request URL.\n req.url = req.originalUrl;\n await handler(req, res, req.body);\n } catch (error) {\n next(error);\n }\n };\n};\n"]}