skybridge 0.0.0-dev.ff4b4a2 → 0.0.0-dev.ffaef7a

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 (434) hide show
  1. package/README.md +124 -115
  2. package/dist/cli/build-helpers.d.ts +10 -0
  3. package/dist/cli/build-helpers.js +93 -0
  4. package/dist/cli/build-helpers.js.map +1 -0
  5. package/dist/cli/build-helpers.test.js +89 -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 +68 -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 +18 -0
  13. package/dist/cli/detect-port.js +50 -0
  14. package/dist/cli/detect-port.js.map +1 -0
  15. package/dist/cli/header.d.ts +1 -1
  16. package/dist/cli/header.js +1 -1
  17. package/dist/cli/header.js.map +1 -1
  18. package/dist/cli/resolve-views-dir.d.ts +1 -0
  19. package/dist/cli/resolve-views-dir.js +17 -0
  20. package/dist/cli/resolve-views-dir.js.map +1 -0
  21. package/dist/cli/run-command.js.map +1 -1
  22. package/dist/cli/run-plain.d.ts +18 -0
  23. package/dist/cli/run-plain.js +89 -0
  24. package/dist/cli/run-plain.js.map +1 -0
  25. package/dist/cli/telemetry.js.map +1 -1
  26. package/dist/cli/tunnel-control-server.d.ts +9 -0
  27. package/dist/cli/tunnel-control-server.js +31 -0
  28. package/dist/cli/tunnel-control-server.js.map +1 -0
  29. package/dist/cli/tunnel-control-server.test.d.ts +1 -0
  30. package/dist/cli/tunnel-control-server.test.js +39 -0
  31. package/dist/cli/tunnel-control-server.test.js.map +1 -0
  32. package/dist/cli/tunnel-handler.d.ts +3 -0
  33. package/dist/cli/tunnel-handler.js +48 -0
  34. package/dist/cli/tunnel-handler.js.map +1 -0
  35. package/dist/cli/tunnel-handler.test.d.ts +1 -0
  36. package/dist/cli/tunnel-handler.test.js +105 -0
  37. package/dist/cli/tunnel-handler.test.js.map +1 -0
  38. package/dist/cli/tunnel.d.ts +57 -0
  39. package/dist/cli/tunnel.js +154 -0
  40. package/dist/cli/tunnel.js.map +1 -0
  41. package/dist/cli/tunnel.test.d.ts +1 -0
  42. package/dist/cli/tunnel.test.js +190 -0
  43. package/dist/cli/tunnel.test.js.map +1 -0
  44. package/dist/cli/types.d.ts +5 -0
  45. package/dist/cli/types.js +2 -0
  46. package/dist/cli/types.js.map +1 -0
  47. package/dist/cli/use-execute-steps.d.ts +1 -1
  48. package/dist/cli/use-execute-steps.js.map +1 -1
  49. package/dist/cli/use-messages.d.ts +3 -0
  50. package/dist/cli/use-messages.js +11 -0
  51. package/dist/cli/use-messages.js.map +1 -0
  52. package/dist/cli/use-nodemon.d.ts +16 -6
  53. package/dist/cli/use-nodemon.js +77 -54
  54. package/dist/cli/use-nodemon.js.map +1 -1
  55. package/dist/cli/use-open-browser.d.ts +1 -0
  56. package/dist/cli/use-open-browser.js +44 -0
  57. package/dist/cli/use-open-browser.js.map +1 -0
  58. package/dist/cli/use-tunnel.d.ts +14 -0
  59. package/dist/cli/use-tunnel.js +131 -0
  60. package/dist/cli/use-tunnel.js.map +1 -0
  61. package/dist/cli/use-typescript-check.d.ts +9 -2
  62. package/dist/cli/use-typescript-check.js +89 -51
  63. package/dist/cli/use-typescript-check.js.map +1 -1
  64. package/dist/commands/build.d.ts +0 -3
  65. package/dist/commands/build.js +3 -18
  66. package/dist/commands/build.js.map +1 -1
  67. package/dist/commands/create.d.ts +9 -0
  68. package/dist/commands/create.js +30 -0
  69. package/dist/commands/create.js.map +1 -0
  70. package/dist/commands/dev.d.ts +5 -1
  71. package/dist/commands/dev.js +105 -8
  72. package/dist/commands/dev.js.map +1 -1
  73. package/dist/commands/start.d.ts +3 -1
  74. package/dist/commands/start.js +37 -15
  75. package/dist/commands/start.js.map +1 -1
  76. package/dist/commands/telemetry/disable.js.map +1 -1
  77. package/dist/commands/telemetry/enable.js.map +1 -1
  78. package/dist/commands/telemetry/status.js.map +1 -1
  79. package/dist/server/asset-base-url-transform-plugin.d.ts +6 -6
  80. package/dist/server/asset-base-url-transform-plugin.js +25 -11
  81. package/dist/server/asset-base-url-transform-plugin.js.map +1 -1
  82. package/dist/server/asset-base-url-transform-plugin.test.js +92 -14
  83. package/dist/server/asset-base-url-transform-plugin.test.js.map +1 -1
  84. package/dist/server/auth/discovery.d.ts +32 -0
  85. package/dist/server/auth/discovery.js +56 -0
  86. package/dist/server/auth/discovery.js.map +1 -0
  87. package/dist/server/auth/discovery.test.d.ts +1 -0
  88. package/dist/server/auth/discovery.test.js +93 -0
  89. package/dist/server/auth/discovery.test.js.map +1 -0
  90. package/dist/server/auth/index.d.ts +18 -0
  91. package/dist/server/auth/index.js +2 -0
  92. package/dist/server/auth/index.js.map +1 -0
  93. package/dist/server/auth/providers/auth0.d.ts +18 -0
  94. package/dist/server/auth/providers/auth0.js +31 -0
  95. package/dist/server/auth/providers/auth0.js.map +1 -0
  96. package/dist/server/auth/providers/auth0.test.d.ts +1 -0
  97. package/dist/server/auth/providers/auth0.test.js +48 -0
  98. package/dist/server/auth/providers/auth0.test.js.map +1 -0
  99. package/dist/server/auth/providers/clerk.d.ts +14 -0
  100. package/dist/server/auth/providers/clerk.js +16 -0
  101. package/dist/server/auth/providers/clerk.js.map +1 -0
  102. package/dist/server/auth/providers/clerk.test.d.ts +1 -0
  103. package/dist/server/auth/providers/clerk.test.js +28 -0
  104. package/dist/server/auth/providers/clerk.test.js.map +1 -0
  105. package/dist/server/auth/providers/custom.d.ts +24 -0
  106. package/dist/server/auth/providers/custom.js +37 -0
  107. package/dist/server/auth/providers/custom.js.map +1 -0
  108. package/dist/server/auth/providers/custom.test.d.ts +1 -0
  109. package/dist/server/auth/providers/custom.test.js +107 -0
  110. package/dist/server/auth/providers/custom.test.js.map +1 -0
  111. package/dist/server/auth/providers/descope.d.ts +15 -0
  112. package/dist/server/auth/providers/descope.js +33 -0
  113. package/dist/server/auth/providers/descope.js.map +1 -0
  114. package/dist/server/auth/providers/descope.test.d.ts +1 -0
  115. package/dist/server/auth/providers/descope.test.js +37 -0
  116. package/dist/server/auth/providers/descope.test.js.map +1 -0
  117. package/dist/server/auth/providers/shared.d.ts +2 -0
  118. package/dist/server/auth/providers/shared.js +6 -0
  119. package/dist/server/auth/providers/shared.js.map +1 -0
  120. package/dist/server/auth/providers/shared.test.d.ts +1 -0
  121. package/dist/server/auth/providers/shared.test.js +10 -0
  122. package/dist/server/auth/providers/shared.test.js.map +1 -0
  123. package/dist/server/auth/providers/stytch.d.ts +12 -0
  124. package/dist/server/auth/providers/stytch.js +13 -0
  125. package/dist/server/auth/providers/stytch.js.map +1 -0
  126. package/dist/server/auth/providers/workos.d.ts +11 -0
  127. package/dist/server/auth/providers/workos.js +12 -0
  128. package/dist/server/auth/providers/workos.js.map +1 -0
  129. package/dist/server/auth/security-schemes.d.ts +13 -0
  130. package/dist/server/auth/security-schemes.js +53 -0
  131. package/dist/server/auth/security-schemes.js.map +1 -0
  132. package/dist/server/auth/security-schemes.test.d.ts +1 -0
  133. package/dist/server/auth/security-schemes.test.js +90 -0
  134. package/dist/server/auth/security-schemes.test.js.map +1 -0
  135. package/dist/server/auth/setup.d.ts +6 -0
  136. package/dist/server/auth/setup.js +98 -0
  137. package/dist/server/auth/setup.js.map +1 -0
  138. package/dist/server/auth/setup.test.d.ts +1 -0
  139. package/dist/server/auth/setup.test.js +450 -0
  140. package/dist/server/auth/setup.test.js.map +1 -0
  141. package/dist/server/auth/verify.d.ts +12 -0
  142. package/dist/server/auth/verify.js +38 -0
  143. package/dist/server/auth/verify.js.map +1 -0
  144. package/dist/server/auth/verify.test.d.ts +1 -0
  145. package/dist/server/auth/verify.test.js +100 -0
  146. package/dist/server/auth/verify.test.js.map +1 -0
  147. package/dist/server/auth.d.ts +20 -0
  148. package/dist/server/auth.js +28 -0
  149. package/dist/server/auth.js.map +1 -0
  150. package/dist/server/build-manifest.test.d.ts +1 -0
  151. package/dist/server/build-manifest.test.js +27 -0
  152. package/dist/server/build-manifest.test.js.map +1 -0
  153. package/dist/server/content-helpers.d.ts +67 -0
  154. package/dist/server/content-helpers.js +79 -0
  155. package/dist/server/content-helpers.js.map +1 -0
  156. package/dist/server/content-helpers.test.d.ts +1 -0
  157. package/dist/server/content-helpers.test.js +70 -0
  158. package/dist/server/content-helpers.test.js.map +1 -0
  159. package/dist/server/express.d.ts +11 -0
  160. package/dist/server/express.js +101 -0
  161. package/dist/server/express.js.map +1 -0
  162. package/dist/server/express.test.d.ts +1 -0
  163. package/dist/server/express.test.js +491 -0
  164. package/dist/server/express.test.js.map +1 -0
  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/index.d.ts +14 -3
  169. package/dist/server/index.js +11 -2
  170. package/dist/server/index.js.map +1 -1
  171. package/dist/server/inferUtilityTypes.d.ts +6 -6
  172. package/dist/server/inferUtilityTypes.js.map +1 -1
  173. package/dist/server/metric.d.ts +14 -0
  174. package/dist/server/metric.js +62 -0
  175. package/dist/server/metric.js.map +1 -0
  176. package/dist/server/middleware.d.ts +137 -0
  177. package/dist/server/middleware.js +93 -0
  178. package/dist/server/middleware.js.map +1 -0
  179. package/dist/server/middleware.test-d.d.ts +1 -0
  180. package/dist/server/middleware.test-d.js +75 -0
  181. package/dist/server/middleware.test-d.js.map +1 -0
  182. package/dist/server/middleware.test.d.ts +1 -0
  183. package/dist/server/middleware.test.js +493 -0
  184. package/dist/server/middleware.test.js.map +1 -0
  185. package/dist/server/requestOrigin.d.ts +7 -0
  186. package/dist/server/requestOrigin.js +25 -0
  187. package/dist/server/requestOrigin.js.map +1 -0
  188. package/dist/server/server.d.ts +391 -58
  189. package/dist/server/server.js +644 -111
  190. package/dist/server/server.js.map +1 -1
  191. package/dist/server/templateHelper.d.ts +5 -8
  192. package/dist/server/templateHelper.js +3 -22
  193. package/dist/server/templateHelper.js.map +1 -1
  194. package/dist/server/templates.generated.d.ts +4 -0
  195. package/dist/server/templates.generated.js +47 -0
  196. package/dist/server/templates.generated.js.map +1 -0
  197. package/dist/server/tunnel-proxy-router.d.ts +7 -0
  198. package/dist/server/tunnel-proxy-router.js +110 -0
  199. package/dist/server/tunnel-proxy-router.js.map +1 -0
  200. package/dist/server/tunnel-proxy-router.test.d.ts +1 -0
  201. package/dist/server/tunnel-proxy-router.test.js +229 -0
  202. package/dist/server/tunnel-proxy-router.test.js.map +1 -0
  203. package/dist/server/view-name.test-d.d.ts +1 -0
  204. package/dist/server/view-name.test-d.js +8 -0
  205. package/dist/server/view-name.test-d.js.map +1 -0
  206. package/dist/server/view-resource-resolution.test.d.ts +6 -0
  207. package/dist/server/view-resource-resolution.test.js +171 -0
  208. package/dist/server/view-resource-resolution.test.js.map +1 -0
  209. package/dist/server/viewsDevServer.d.ts +14 -0
  210. package/dist/server/viewsDevServer.js +45 -0
  211. package/dist/server/viewsDevServer.js.map +1 -0
  212. package/dist/test/utils.d.ts +13 -21
  213. package/dist/test/utils.js +42 -37
  214. package/dist/test/utils.js.map +1 -1
  215. package/dist/test/view.test.d.ts +1 -0
  216. package/dist/test/view.test.js +536 -0
  217. package/dist/test/view.test.js.map +1 -0
  218. package/dist/version.d.ts +1 -0
  219. package/dist/version.js +3 -0
  220. package/dist/version.js.map +1 -0
  221. package/dist/web/bridges/adaptor.d.ts +51 -0
  222. package/dist/web/bridges/adaptor.js +330 -0
  223. package/dist/web/bridges/adaptor.js.map +1 -0
  224. package/dist/web/bridges/adaptor.test.d.ts +1 -0
  225. package/dist/web/bridges/adaptor.test.js +208 -0
  226. package/dist/web/bridges/adaptor.test.js.map +1 -0
  227. package/dist/web/bridges/apps-sdk/bridge.d.ts +7 -2
  228. package/dist/web/bridges/apps-sdk/bridge.js +15 -3
  229. package/dist/web/bridges/apps-sdk/bridge.js.map +1 -1
  230. package/dist/web/bridges/apps-sdk/index.d.ts +1 -2
  231. package/dist/web/bridges/apps-sdk/index.js +0 -1
  232. package/dist/web/bridges/apps-sdk/index.js.map +1 -1
  233. package/dist/web/bridges/apps-sdk/types.d.ts +32 -14
  234. package/dist/web/bridges/apps-sdk/types.js.map +1 -1
  235. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.d.ts +11 -0
  236. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js +11 -0
  237. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js.map +1 -1
  238. package/dist/web/bridges/get-adaptor.d.ts +7 -0
  239. package/dist/web/bridges/get-adaptor.js +9 -7
  240. package/dist/web/bridges/get-adaptor.js.map +1 -1
  241. package/dist/web/bridges/get-adaptor.test.d.ts +1 -0
  242. package/dist/web/bridges/get-adaptor.test.js +32 -0
  243. package/dist/web/bridges/get-adaptor.test.js.map +1 -0
  244. package/dist/web/bridges/index.js.map +1 -1
  245. package/dist/web/bridges/mcp-app/bridge.d.ts +27 -31
  246. package/dist/web/bridges/mcp-app/bridge.js +109 -198
  247. package/dist/web/bridges/mcp-app/bridge.js.map +1 -1
  248. package/dist/web/bridges/mcp-app/bridge.test.d.ts +1 -0
  249. package/dist/web/bridges/mcp-app/bridge.test.js +17 -0
  250. package/dist/web/bridges/mcp-app/bridge.test.js.map +1 -0
  251. package/dist/web/bridges/mcp-app/index.d.ts +0 -1
  252. package/dist/web/bridges/mcp-app/index.js +0 -1
  253. package/dist/web/bridges/mcp-app/index.js.map +1 -1
  254. package/dist/web/bridges/mcp-app/types.js.map +1 -1
  255. package/dist/web/bridges/mcp-app/use-mcp-app-context.d.ts +17 -3
  256. package/dist/web/bridges/mcp-app/use-mcp-app-context.js +14 -2
  257. package/dist/web/bridges/mcp-app/use-mcp-app-context.js.map +1 -1
  258. package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js +1 -41
  259. package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js.map +1 -1
  260. package/dist/web/bridges/mcp-app/view-tools.test.d.ts +1 -0
  261. package/dist/web/bridges/mcp-app/view-tools.test.js +143 -0
  262. package/dist/web/bridges/mcp-app/view-tools.test.js.map +1 -0
  263. package/dist/web/bridges/types.d.ts +130 -14
  264. package/dist/web/bridges/types.js +14 -1
  265. package/dist/web/bridges/types.js.map +1 -1
  266. package/dist/web/bridges/types.test.d.ts +1 -0
  267. package/dist/web/bridges/types.test.js +19 -0
  268. package/dist/web/bridges/types.test.js.map +1 -0
  269. package/dist/web/bridges/use-host-context.d.ts +5 -0
  270. package/dist/web/bridges/use-host-context.js +5 -0
  271. package/dist/web/bridges/use-host-context.js.map +1 -1
  272. package/dist/web/components/modal-provider.d.ts +1 -1
  273. package/dist/web/components/modal-provider.js +5 -6
  274. package/dist/web/components/modal-provider.js.map +1 -1
  275. package/dist/web/create-store.d.ts +26 -0
  276. package/dist/web/create-store.js +43 -3
  277. package/dist/web/create-store.js.map +1 -1
  278. package/dist/web/create-store.test.js +31 -25
  279. package/dist/web/create-store.test.js.map +1 -1
  280. package/dist/web/data-llm.d.ts +35 -2
  281. package/dist/web/data-llm.js +31 -3
  282. package/dist/web/data-llm.js.map +1 -1
  283. package/dist/web/data-llm.test.js +50 -35
  284. package/dist/web/data-llm.test.js.map +1 -1
  285. package/dist/web/generate-helpers.d.ts +22 -18
  286. package/dist/web/generate-helpers.js +22 -18
  287. package/dist/web/generate-helpers.js.map +1 -1
  288. package/dist/web/generate-helpers.test-d.js +30 -28
  289. package/dist/web/generate-helpers.test-d.js.map +1 -1
  290. package/dist/web/generate-helpers.test.js.map +1 -1
  291. package/dist/web/helpers/state.d.ts +2 -2
  292. package/dist/web/helpers/state.js +11 -11
  293. package/dist/web/helpers/state.js.map +1 -1
  294. package/dist/web/helpers/state.test.js +9 -9
  295. package/dist/web/helpers/state.test.js.map +1 -1
  296. package/dist/web/hooks/index.d.ts +6 -2
  297. package/dist/web/hooks/index.js +5 -1
  298. package/dist/web/hooks/index.js.map +1 -1
  299. package/dist/web/hooks/test/utils.d.ts +6 -2
  300. package/dist/web/hooks/test/utils.js +17 -2
  301. package/dist/web/hooks/test/utils.js.map +1 -1
  302. package/dist/web/hooks/use-call-tool.d.ts +45 -0
  303. package/dist/web/hooks/use-call-tool.js +28 -0
  304. package/dist/web/hooks/use-call-tool.js.map +1 -1
  305. package/dist/web/hooks/use-call-tool.test-d.js.map +1 -1
  306. package/dist/web/hooks/use-call-tool.test.js +62 -27
  307. package/dist/web/hooks/use-call-tool.test.js.map +1 -1
  308. package/dist/web/hooks/use-display-mode.d.ts +23 -3
  309. package/dist/web/hooks/use-display-mode.js +20 -0
  310. package/dist/web/hooks/use-display-mode.js.map +1 -1
  311. package/dist/web/hooks/use-display-mode.test-d.d.ts +1 -0
  312. package/dist/web/hooks/use-display-mode.test-d.js +8 -0
  313. package/dist/web/hooks/use-display-mode.test-d.js.map +1 -0
  314. package/dist/web/hooks/use-display-mode.test.js +56 -20
  315. package/dist/web/hooks/use-display-mode.test.js.map +1 -1
  316. package/dist/web/hooks/use-download.d.ts +5 -0
  317. package/dist/web/hooks/use-download.js +8 -0
  318. package/dist/web/hooks/use-download.js.map +1 -0
  319. package/dist/web/hooks/use-download.test.d.ts +1 -0
  320. package/dist/web/hooks/use-download.test.js +103 -0
  321. package/dist/web/hooks/use-download.test.js.map +1 -0
  322. package/dist/web/hooks/use-files.d.ts +34 -1
  323. package/dist/web/hooks/use-files.js +33 -0
  324. package/dist/web/hooks/use-files.js.map +1 -1
  325. package/dist/web/hooks/use-files.test.js +35 -3
  326. package/dist/web/hooks/use-files.test.js.map +1 -1
  327. package/dist/web/hooks/use-layout.d.ts +2 -0
  328. package/dist/web/hooks/use-layout.js +2 -0
  329. package/dist/web/hooks/use-layout.js.map +1 -1
  330. package/dist/web/hooks/use-layout.test.js +62 -29
  331. package/dist/web/hooks/use-layout.test.js.map +1 -1
  332. package/dist/web/hooks/use-open-external.d.ts +20 -1
  333. package/dist/web/hooks/use-open-external.js +17 -1
  334. package/dist/web/hooks/use-open-external.js.map +1 -1
  335. package/dist/web/hooks/use-open-external.test.js +38 -13
  336. package/dist/web/hooks/use-open-external.test.js.map +1 -1
  337. package/dist/web/hooks/use-register-view-tool.d.ts +38 -0
  338. package/dist/web/hooks/use-register-view-tool.js +50 -0
  339. package/dist/web/hooks/use-register-view-tool.js.map +1 -0
  340. package/dist/web/hooks/use-request-close.d.ts +16 -0
  341. package/dist/web/hooks/use-request-close.js +21 -0
  342. package/dist/web/hooks/use-request-close.js.map +1 -0
  343. package/dist/web/hooks/use-request-close.test.d.ts +1 -0
  344. package/dist/web/hooks/use-request-close.test.js +47 -0
  345. package/dist/web/hooks/use-request-close.test.js.map +1 -0
  346. package/dist/web/hooks/use-request-modal.d.ts +16 -1
  347. package/dist/web/hooks/use-request-modal.js +19 -4
  348. package/dist/web/hooks/use-request-modal.js.map +1 -1
  349. package/dist/web/hooks/use-request-modal.test.js +15 -1
  350. package/dist/web/hooks/use-request-modal.test.js.map +1 -1
  351. package/dist/web/hooks/use-request-size.d.ts +20 -0
  352. package/dist/web/hooks/use-request-size.js +24 -0
  353. package/dist/web/hooks/use-request-size.js.map +1 -0
  354. package/dist/web/hooks/use-request-size.test.d.ts +1 -0
  355. package/dist/web/hooks/use-request-size.test.js +47 -0
  356. package/dist/web/hooks/use-request-size.test.js.map +1 -0
  357. package/dist/web/hooks/use-send-follow-up-message.d.ts +19 -1
  358. package/dist/web/hooks/use-send-follow-up-message.js +19 -2
  359. package/dist/web/hooks/use-send-follow-up-message.js.map +1 -1
  360. package/dist/web/hooks/use-set-open-in-app-url.d.ts +17 -0
  361. package/dist/web/hooks/use-set-open-in-app-url.js +17 -0
  362. package/dist/web/hooks/use-set-open-in-app-url.js.map +1 -1
  363. package/dist/web/hooks/use-set-open-in-app-url.test.js +30 -16
  364. package/dist/web/hooks/use-set-open-in-app-url.test.js.map +1 -1
  365. package/dist/web/hooks/use-tool-info.d.ts +53 -2
  366. package/dist/web/hooks/use-tool-info.js +30 -7
  367. package/dist/web/hooks/use-tool-info.js.map +1 -1
  368. package/dist/web/hooks/use-tool-info.test-d.js +11 -29
  369. package/dist/web/hooks/use-tool-info.test-d.js.map +1 -1
  370. package/dist/web/hooks/use-tool-info.test.js +43 -33
  371. package/dist/web/hooks/use-tool-info.test.js.map +1 -1
  372. package/dist/web/hooks/use-user.d.ts +2 -0
  373. package/dist/web/hooks/use-user.js +20 -2
  374. package/dist/web/hooks/use-user.js.map +1 -1
  375. package/dist/web/hooks/use-user.test.js +101 -27
  376. package/dist/web/hooks/use-user.test.js.map +1 -1
  377. package/dist/web/hooks/use-view-state.d.ts +25 -0
  378. package/dist/web/hooks/use-view-state.js +32 -0
  379. package/dist/web/hooks/use-view-state.js.map +1 -0
  380. package/dist/web/hooks/use-view-state.test.d.ts +1 -0
  381. package/dist/web/hooks/use-view-state.test.js +181 -0
  382. package/dist/web/hooks/use-view-state.test.js.map +1 -0
  383. package/dist/web/index.d.ts +1 -2
  384. package/dist/web/index.js +1 -2
  385. package/dist/web/index.js.map +1 -1
  386. package/dist/web/mount-view.d.ts +20 -0
  387. package/dist/web/{mount-widget.js → mount-view.js} +21 -2
  388. package/dist/web/mount-view.js.map +1 -0
  389. package/dist/web/plugin/data-llm.test.js.map +1 -1
  390. package/dist/web/plugin/plugin.d.ts +32 -1
  391. package/dist/web/plugin/plugin.js +160 -18
  392. package/dist/web/plugin/plugin.js.map +1 -1
  393. package/dist/web/plugin/scan-views.d.ts +16 -0
  394. package/dist/web/plugin/scan-views.js +88 -0
  395. package/dist/web/plugin/scan-views.js.map +1 -0
  396. package/dist/web/plugin/scan-views.test.d.ts +1 -0
  397. package/dist/web/plugin/scan-views.test.js +99 -0
  398. package/dist/web/plugin/scan-views.test.js.map +1 -0
  399. package/dist/web/plugin/transform-data-llm.js +1 -1
  400. package/dist/web/plugin/transform-data-llm.js.map +1 -1
  401. package/dist/web/plugin/transform-data-llm.test.js.map +1 -1
  402. package/dist/web/plugin/validate-view.d.ts +1 -0
  403. package/dist/web/plugin/validate-view.js +9 -0
  404. package/dist/web/plugin/validate-view.js.map +1 -0
  405. package/dist/web/plugin/validate-view.test.d.ts +1 -0
  406. package/dist/web/plugin/validate-view.test.js +24 -0
  407. package/dist/web/plugin/validate-view.test.js.map +1 -0
  408. package/dist/web/proxy.js.map +1 -1
  409. package/dist/web/types.d.ts +4 -0
  410. package/dist/web/types.js.map +1 -1
  411. package/package.json +51 -30
  412. package/tsconfig.base.json +33 -0
  413. package/dist/server/templates/development.hbs +0 -67
  414. package/dist/server/templates/production.hbs +0 -6
  415. package/dist/server/widgetsDevServer.d.ts +0 -12
  416. package/dist/server/widgetsDevServer.js +0 -57
  417. package/dist/server/widgetsDevServer.js.map +0 -1
  418. package/dist/test/widget.test.js +0 -255
  419. package/dist/test/widget.test.js.map +0 -1
  420. package/dist/web/bridges/apps-sdk/adaptor.d.ts +0 -22
  421. package/dist/web/bridges/apps-sdk/adaptor.js +0 -64
  422. package/dist/web/bridges/apps-sdk/adaptor.js.map +0 -1
  423. package/dist/web/bridges/mcp-app/adaptor.d.ts +0 -36
  424. package/dist/web/bridges/mcp-app/adaptor.js +0 -185
  425. package/dist/web/bridges/mcp-app/adaptor.js.map +0 -1
  426. package/dist/web/hooks/use-widget-state.d.ts +0 -4
  427. package/dist/web/hooks/use-widget-state.js +0 -32
  428. package/dist/web/hooks/use-widget-state.js.map +0 -1
  429. package/dist/web/hooks/use-widget-state.test.js +0 -61
  430. package/dist/web/hooks/use-widget-state.test.js.map +0 -1
  431. package/dist/web/mount-widget.d.ts +0 -1
  432. package/dist/web/mount-widget.js.map +0 -1
  433. /package/dist/{test/widget.test.d.ts → cli/build-helpers.test.d.ts} +0 -0
  434. /package/dist/{web/hooks/use-widget-state.test.d.ts → cli/build-steps.test.d.ts} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"middleware.test.js","sourceRoot":"","sources":["../../src/server/middleware.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,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client/index.js\";\nimport { InMemoryTransport } from \"@modelcontextprotocol/sdk/inMemory.js\";\nimport { describe, expect, it, vi } from \"vitest\";\nimport { z } from \"zod\";\nimport {\n buildMiddlewareChain,\n getHandlerMaps,\n type McpExtra,\n type McpMiddlewareEntry,\n type McpMiddlewareFn,\n matchesFilter,\n} from \"./middleware.js\";\nimport { McpServer } from \"./server.js\";\n\n// ---------------------------------------------------------------------------\n// matchesFilter\n// ---------------------------------------------------------------------------\ndescribe(\"matchesFilter\", () => {\n it(\"matches exact method\", () => {\n expect(matchesFilter(\"tools/call\", \"tools/call\", false)).toBe(true);\n });\n\n it(\"rejects non-matching exact method\", () => {\n expect(matchesFilter(\"tools/list\", \"tools/call\", false)).toBe(false);\n });\n\n it(\"matches wildcard\", () => {\n expect(matchesFilter(\"tools/call\", \"tools/*\", false)).toBe(true);\n expect(matchesFilter(\"tools/list\", \"tools/*\", false)).toBe(true);\n });\n\n it(\"rejects non-matching wildcard\", () => {\n expect(matchesFilter(\"resources/read\", \"tools/*\", false)).toBe(false);\n });\n\n it('category \"request\" matches when isNotification=false', () => {\n expect(matchesFilter(\"tools/call\", \"request\", false)).toBe(true);\n });\n\n it('category \"request\" rejects when isNotification=true', () => {\n expect(matchesFilter(\"notifications/initialized\", \"request\", true)).toBe(\n false,\n );\n });\n\n it('category \"notification\" matches when isNotification=true', () => {\n expect(\n matchesFilter(\"notifications/initialized\", \"notification\", true),\n ).toBe(true);\n });\n\n it('category \"notification\" rejects when isNotification=false', () => {\n expect(matchesFilter(\"tools/call\", \"notification\", false)).toBe(false);\n });\n});\n\n// ---------------------------------------------------------------------------\n// buildMiddlewareChain\n// ---------------------------------------------------------------------------\ndescribe(\"buildMiddlewareChain\", () => {\n const fakeExtra = {} as McpExtra;\n\n const makeHandler = (returnValue: unknown) => vi.fn(async () => returnValue);\n\n const makeEntry = (\n filter: McpMiddlewareEntry[\"filter\"],\n handler: McpMiddlewareFn,\n ): McpMiddlewareEntry => ({ filter, handler });\n\n it(\"returns original handler when no middleware applies\", () => {\n const original = makeHandler(\"result\");\n const chain = buildMiddlewareChain(\"tools/call\", false, original, [\n makeEntry(\"resources/*\", async (_req, _extra, next) => next()),\n ]);\n expect(chain).toBe(original);\n });\n\n it(\"catch-all middleware runs for any method\", async () => {\n const original = makeHandler(\"ok\");\n const spy = vi.fn();\n const chain = buildMiddlewareChain(\"tools/call\", false, original, [\n makeEntry(null, async (request, _extra, next) => {\n spy(request.method);\n return next();\n }),\n ]);\n const result = await chain({ method: \"tools/call\", params: {} }, fakeExtra);\n expect(spy).toHaveBeenCalledWith(\"tools/call\");\n expect(result).toBe(\"ok\");\n });\n\n it(\"method-scoped middleware only runs for matching methods\", async () => {\n const original = makeHandler(\"ok\");\n const spy = vi.fn();\n const entries = [\n makeEntry(\"tools/call\", async (_req, _extra, next) => {\n spy(\"tools/call\");\n return next();\n }),\n ];\n\n // Matching\n const chain1 = buildMiddlewareChain(\"tools/call\", false, original, entries);\n await chain1({ method: \"tools/call\", params: {} }, fakeExtra);\n expect(spy).toHaveBeenCalledTimes(1);\n\n // Non-matching — returns original handler directly\n const chain2 = buildMiddlewareChain(\"tools/list\", false, original, entries);\n expect(chain2).toBe(original);\n });\n\n it(\"executes middleware in registration order (onion model)\", async () => {\n const calls: string[] = [];\n const original = makeHandler(\"result\");\n\n const chain = buildMiddlewareChain(\"tools/call\", false, original, [\n makeEntry(null, async (_req, _extra, next) => {\n calls.push(\"A:before\");\n const result = await next();\n calls.push(\"A:after\");\n return result;\n }),\n makeEntry(null, async (_req, _extra, next) => {\n calls.push(\"B:before\");\n const result = await next();\n calls.push(\"B:after\");\n return result;\n }),\n ]);\n\n await chain({ method: \"tools/call\", params: {} }, fakeExtra);\n expect(calls).toEqual([\"A:before\", \"B:before\", \"B:after\", \"A:after\"]);\n });\n\n it(\"short-circuit (no next() call) skips handler\", async () => {\n const original = makeHandler(\"original\");\n const chain = buildMiddlewareChain(\"tools/call\", false, original, [\n makeEntry(null, async () => \"short-circuited\"),\n ]);\n const result = await chain({ method: \"tools/call\", params: {} }, fakeExtra);\n expect(result).toBe(\"short-circuited\");\n expect(original).not.toHaveBeenCalled();\n });\n\n it(\"middleware can modify result post-next()\", async () => {\n const original = makeHandler({ value: 1 });\n const chain = buildMiddlewareChain(\"tools/call\", false, original, [\n makeEntry(null, async (_req, _extra, next) => {\n const result = (await next()) as { value: number };\n return { value: result.value + 10 };\n }),\n ]);\n const result = await chain({ method: \"tools/call\", params: {} }, fakeExtra);\n expect(result).toEqual({ value: 11 });\n });\n\n it(\"throws on double next() call\", async () => {\n const original = makeHandler(\"ok\");\n const chain = buildMiddlewareChain(\"tools/call\", false, original, [\n makeEntry(null, async (_req, _extra, next) => {\n await next();\n return next(); // double call\n }),\n ]);\n await expect(\n chain({ method: \"tools/call\", params: {} }, fakeExtra),\n ).rejects.toThrow(\"next() called multiple times\");\n });\n\n it(\"propagates errors from handler and middleware\", async () => {\n // Error from original handler bubbles through middleware\n const failingHandler = vi.fn(async () => {\n throw new Error(\"handler boom\");\n });\n const chain1 = buildMiddlewareChain(\"tools/call\", false, failingHandler, [\n makeEntry(null, async (_req, _extra, next) => next()),\n ]);\n await expect(\n chain1({ method: \"tools/call\", params: {} }, fakeExtra),\n ).rejects.toThrow(\"handler boom\");\n\n // Error thrown inside middleware propagates\n const chain2 = buildMiddlewareChain(\n \"tools/call\",\n false,\n makeHandler(\"ok\"),\n [\n makeEntry(null, async () => {\n throw new Error(\"middleware boom\");\n }),\n ],\n );\n await expect(\n chain2({ method: \"tools/call\", params: {} }, fakeExtra),\n ).rejects.toThrow(\"middleware boom\");\n });\n\n it(\"passes extra as undefined for notifications (isNotification=true)\", async () => {\n const original = makeHandler(undefined);\n let capturedExtra: McpExtra | undefined = {} as McpExtra;\n const chain = buildMiddlewareChain(\n \"notifications/initialized\",\n true,\n original,\n [\n makeEntry(null, async (_req, extra, next) => {\n capturedExtra = extra;\n return next();\n }),\n ],\n );\n await chain({ method: \"notifications/initialized\" });\n expect(capturedExtra).toBeUndefined();\n });\n\n it(\"defaults params to empty object when rawRequest has no params\", async () => {\n const original = makeHandler(\"ok\");\n let capturedParams: Record<string, unknown> | undefined;\n const chain = buildMiddlewareChain(\"tools/call\", false, original, [\n makeEntry(null, async (request, _extra, next) => {\n capturedParams = request.params;\n return next();\n }),\n ]);\n await chain({ method: \"tools/call\" }, fakeExtra);\n expect(capturedParams).toEqual({});\n });\n\n it(\"propagates in-place param mutation to original handler\", async () => {\n let handlerReceivedName = \"\";\n const original = vi.fn(async (rawReq: { params: { name: string } }) => {\n handlerReceivedName = rawReq.params.name;\n return \"ok\";\n });\n\n const chain = buildMiddlewareChain(\n \"tools/call\",\n false,\n original as unknown as (...args: unknown[]) => Promise<unknown>,\n [\n makeEntry(null, async (request, _extra, next) => {\n request.params.name = \"mutated\";\n return next();\n }),\n ],\n );\n\n await chain({ params: { name: \"original\" } }, fakeExtra);\n expect(handlerReceivedName).toBe(\"mutated\");\n });\n\n it(\"propagates full param replacement to original handler\", async () => {\n let handlerReceivedParams: Record<string, unknown> = {};\n const original = vi.fn(\n async (rawReq: { params: Record<string, unknown> }) => {\n handlerReceivedParams = rawReq.params;\n return \"ok\";\n },\n );\n\n const chain = buildMiddlewareChain(\n \"tools/call\",\n false,\n original as unknown as (...args: unknown[]) => Promise<unknown>,\n [\n makeEntry(null, async (request, _extra, next) => {\n request.params = { replaced: true };\n return next();\n }),\n ],\n );\n\n await chain({ params: { original: true } }, fakeExtra);\n expect(handlerReceivedParams).toEqual({ replaced: true });\n });\n});\n\n// ---------------------------------------------------------------------------\n// McpServer.mcpMiddleware() integration tests\n// ---------------------------------------------------------------------------\ndescribe(\"McpServer.mcpMiddleware()\", () => {\n function createClient() {\n return new Client({ name: \"test-client\", version: \"1.0.0\" });\n }\n\n it(\"returns this for chaining\", () => {\n const server = new McpServer({ name: \"test\", version: \"1.0.0\" });\n const result = server.mcpMiddleware(async (_req, _extra, next) => next());\n expect(result).toBe(server);\n });\n\n it(\"intercepts tools/call and exposes request params\", async () => {\n let capturedMethod = \"\";\n let capturedParams: Record<string, unknown> = {};\n\n const server = new McpServer({ name: \"test\", version: \"1.0.0\" });\n\n server.registerTool(\n {\n name: \"greet\",\n description: \"greet\",\n inputSchema: { name: z.string() },\n },\n (args) => ({\n content: [{ type: \"text\" as const, text: `hi ${args.name}` }],\n }),\n );\n\n server.mcpMiddleware(\"tools/call\", async (request, _extra, next) => {\n capturedMethod = request.method;\n capturedParams = request.params;\n return next();\n });\n\n const client = createClient();\n const [clientTransport, serverTransport] =\n InMemoryTransport.createLinkedPair();\n await server.connect(serverTransport);\n await client.connect(clientTransport);\n\n const result = await client.callTool({\n name: \"greet\",\n arguments: { name: \"World\" },\n });\n expect(capturedMethod).toBe(\"tools/call\");\n expect(capturedParams).toMatchObject({\n name: \"greet\",\n arguments: { name: \"World\" },\n });\n expect(result.content).toEqual([{ type: \"text\", text: \"hi World\" }]);\n\n await client.close();\n await server.close();\n });\n\n it(\"array filter works\", async () => {\n const matchedMethods: string[] = [];\n\n const server = new McpServer({ name: \"test\", version: \"1.0.0\" });\n\n server.registerTool({ name: \"t1\", description: \"t1\" }, () => ({\n content: [{ type: \"text\" as const, text: \"ok\" }],\n }));\n\n server.mcpMiddleware(\n [\"tools/call\", \"tools/list\"],\n async (request, _extra, next) => {\n matchedMethods.push(request.method);\n return next();\n },\n );\n\n const client = createClient();\n const [clientTransport, serverTransport] =\n InMemoryTransport.createLinkedPair();\n await server.connect(serverTransport);\n await client.connect(clientTransport);\n\n await client.listTools();\n await client.callTool({ name: \"t1\" });\n\n expect(matchedMethods).toEqual([\"tools/list\", \"tools/call\"]);\n\n await client.close();\n await server.close();\n });\n\n it(\"throws if registered after connect()\", async () => {\n const server = new McpServer({ name: \"test\", version: \"1.0.0\" });\n\n const [_clientTransport, serverTransport] =\n InMemoryTransport.createLinkedPair();\n await server.connect(serverTransport);\n\n expect(() =>\n server.mcpMiddleware(async (_req, _extra, next) => next()),\n ).toThrow(\"Cannot register MCP middleware after run() or connect()\");\n\n await server.close();\n });\n\n it(\"throws when filter provided without handler\", () => {\n const server = new McpServer({ name: \"test\", version: \"1.0.0\" });\n expect(() =>\n // @ts-expect-error intentionally passing filter without handler\n server.mcpMiddleware(\"tools/call\"),\n ).toThrow(\"mcpMiddleware requires a handler function\");\n });\n\n it(\"catch-all middleware + filtered middleware stack correctly\", async () => {\n const calls: string[] = [];\n\n const server = new McpServer({ name: \"test\", version: \"1.0.0\" });\n\n server.registerTool({ name: \"t1\", description: \"t1\" }, () => ({\n content: [{ type: \"text\" as const, text: \"ok\" }],\n }));\n\n server\n .mcpMiddleware(async (request, _extra, next) => {\n calls.push(`global:${request.method}`);\n return next();\n })\n .mcpMiddleware(\"tools/call\", async (_req, _extra, next) => {\n calls.push(\"tools-only\");\n return next();\n });\n\n const client = createClient();\n const [clientTransport, serverTransport] =\n InMemoryTransport.createLinkedPair();\n await server.connect(serverTransport);\n await client.connect(clientTransport);\n\n await client.listTools();\n await client.callTool({ name: \"t1\" });\n\n // Catch-all also intercepts initialize + notifications/initialized from handshake.\n // tools/list: only global middleware runs\n // tools/call: global + tools-only both run\n expect(calls).toContain(\"global:tools/list\");\n expect(calls).toContain(\"global:tools/call\");\n expect(calls).toContain(\"tools-only\");\n // \"tools-only\" must come right after \"global:tools/call\"\n const toolsCallIdx = calls.indexOf(\"global:tools/call\");\n expect(calls[toolsCallIdx + 1]).toBe(\"tools-only\");\n\n await client.close();\n await server.close();\n });\n\n it(\"notification middleware receives extra as undefined\", async () => {\n let capturedExtra: unknown = \"sentinel\";\n\n const server = new McpServer({ name: \"test\", version: \"1.0.0\" });\n\n server.registerTool({ name: \"t1\", description: \"t1\" }, () => ({\n content: [{ type: \"text\" as const, text: \"ok\" }],\n }));\n\n server.mcpMiddleware(\"notification\", async (_request, extra, next) => {\n capturedExtra = extra;\n return next();\n });\n\n const client = createClient();\n const [clientTransport, serverTransport] =\n InMemoryTransport.createLinkedPair();\n await server.connect(serverTransport);\n await client.connect(clientTransport);\n\n // The client sends notifications/initialized automatically on connect.\n await client.listTools();\n expect(capturedExtra).toBeUndefined();\n\n await client.close();\n await server.close();\n });\n\n it(\"wildcard filter intercepts matching methods only\", async () => {\n const matchedMethods: string[] = [];\n\n const server = new McpServer({ name: \"test\", version: \"1.0.0\" });\n\n server.registerTool({ name: \"t1\", description: \"t1\" }, () => ({\n content: [{ type: \"text\" as const, text: \"ok\" }],\n }));\n\n server.mcpMiddleware(\"tools/*\", async (request, _extra, next) => {\n matchedMethods.push(request.method);\n return next();\n });\n\n const client = createClient();\n const [clientTransport, serverTransport] =\n InMemoryTransport.createLinkedPair();\n await server.connect(serverTransport);\n await client.connect(clientTransport);\n\n await client.listTools();\n await client.callTool({ name: \"t1\" });\n\n expect(matchedMethods).toContain(\"tools/list\");\n expect(matchedMethods).toContain(\"tools/call\");\n // Should not match initialize or notifications\n expect(matchedMethods).not.toContain(\"initialize\");\n expect(matchedMethods).not.toContain(\"notifications/initialized\");\n\n await client.close();\n await server.close();\n });\n\n it(\"middleware can modify tool result via McpServer integration\", async () => {\n const server = new McpServer({ name: \"test\", version: \"1.0.0\" });\n\n server.registerTool(\n {\n name: \"greet\",\n description: \"greet\",\n inputSchema: { name: z.string() },\n },\n (args) => ({\n content: [{ type: \"text\" as const, text: `hi ${args.name}` }],\n }),\n );\n\n server.mcpMiddleware(\"tools/call\", async (_req, _extra, next) => {\n const result = (await next()) as {\n content: { type: string; text: string }[];\n };\n return {\n ...result,\n content: [\n ...result.content,\n { type: \"text\" as const, text: \" (modified)\" },\n ],\n };\n });\n\n const client = createClient();\n const [clientTransport, serverTransport] =\n InMemoryTransport.createLinkedPair();\n await server.connect(serverTransport);\n await client.connect(clientTransport);\n\n const result = await client.callTool({\n name: \"greet\",\n arguments: { name: \"World\" },\n });\n expect(result.content).toEqual([\n { type: \"text\", text: \"hi World\" },\n { type: \"text\", text: \" (modified)\" },\n ]);\n\n await client.close();\n await server.close();\n });\n\n it(\"middleware can short-circuit via McpServer integration\", async () => {\n const handlerCalled = vi.fn();\n\n const server = new McpServer({ name: \"test\", version: \"1.0.0\" });\n\n server.registerTool({ name: \"t1\", description: \"t1\" }, () => {\n handlerCalled();\n return {\n content: [{ type: \"text\" as const, text: \"original\" }],\n };\n });\n\n server.mcpMiddleware(\"tools/call\", async () => ({\n content: [{ type: \"text\" as const, text: \"short-circuited\" }],\n }));\n\n const client = createClient();\n const [clientTransport, serverTransport] =\n InMemoryTransport.createLinkedPair();\n await server.connect(serverTransport);\n await client.connect(clientTransport);\n\n const result = await client.callTool({ name: \"t1\" });\n expect(result.content).toEqual([{ type: \"text\", text: \"short-circuited\" }]);\n expect(handlerCalled).not.toHaveBeenCalled();\n\n await client.close();\n await server.close();\n });\n\n it(\"middleware can mutate tool call params via McpServer integration\", async () => {\n let receivedName = \"\";\n\n const server = new McpServer({ name: \"test\", version: \"1.0.0\" });\n\n server.registerTool(\n {\n name: \"greet\",\n description: \"greet\",\n inputSchema: { name: z.string() },\n },\n (args) => {\n receivedName = args.name;\n return {\n content: [{ type: \"text\" as const, text: `hi ${args.name}` }],\n };\n },\n );\n\n server.mcpMiddleware(\"tools/call\", async (request, _extra, next) => {\n request.params.arguments = { name: \"Overridden\" };\n return next();\n });\n\n const client = createClient();\n const [clientTransport, serverTransport] =\n InMemoryTransport.createLinkedPair();\n await server.connect(serverTransport);\n await client.connect(clientTransport);\n\n await client.callTool({\n name: \"greet\",\n arguments: { name: \"Original\" },\n });\n expect(receivedName).toBe(\"Overridden\");\n\n await client.close();\n await server.close();\n });\n\n it(\"category 'request' filter matches requests but not notifications\", async () => {\n const matchedMethods: string[] = [];\n\n const server = new McpServer({ name: \"test\", version: \"1.0.0\" });\n\n server.registerTool({ name: \"t1\", description: \"t1\" }, () => ({\n content: [{ type: \"text\" as const, text: \"ok\" }],\n }));\n\n server.mcpMiddleware(\"request\", async (request, _extra, next) => {\n matchedMethods.push(request.method);\n return next();\n });\n\n const client = createClient();\n const [clientTransport, serverTransport] =\n InMemoryTransport.createLinkedPair();\n await server.connect(serverTransport);\n await client.connect(clientTransport);\n\n await client.listTools();\n await client.callTool({ name: \"t1\" });\n\n expect(matchedMethods).toContain(\"tools/list\");\n expect(matchedMethods).toContain(\"tools/call\");\n expect(matchedMethods).not.toContain(\"notifications/initialized\");\n\n await client.close();\n await server.close();\n });\n});\n\n// ---------------------------------------------------------------------------\n// getHandlerMaps\n// ---------------------------------------------------------------------------\ndescribe(\"getHandlerMaps\", () => {\n it(\"throws for incompatible server objects\", () => {\n // Empty object\n expect(() => getHandlerMaps({} as never)).toThrow(\n \"Incompatible MCP SDK version\",\n );\n // Only _requestHandlers (missing _notificationHandlers)\n expect(() =>\n getHandlerMaps({ _requestHandlers: new Map() } as never),\n ).toThrow(\"Incompatible MCP SDK version\");\n // Non-Map values\n expect(() =>\n getHandlerMaps({\n _requestHandlers: {},\n _notificationHandlers: {},\n } as never),\n ).toThrow(\"Incompatible MCP SDK version\");\n });\n\n it(\"returns handler maps from valid server\", () => {\n const reqMap = new Map();\n const notifMap = new Map();\n const fake = {\n _requestHandlers: reqMap,\n _notificationHandlers: notifMap,\n };\n const result = getHandlerMaps(fake as never);\n expect(result.requestHandlers).toBe(reqMap);\n expect(result.notificationHandlers).toBe(notifMap);\n });\n});\n"]}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Resolves this server's public origin from request headers, in precedence
3
+ * `x-forwarded-host` → `host` → localhost dev fallback. Shared by view serving
4
+ * and OAuth metadata so the two can't drift. `Origin` is deliberately ignored:
5
+ * it carries the *caller's* site, not this server's.
6
+ */
7
+ export declare function resolveServerOrigin(header: (key: string) => string | undefined): string;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Resolves this server's public origin from request headers, in precedence
3
+ * `x-forwarded-host` → `host` → localhost dev fallback. Shared by view serving
4
+ * and OAuth metadata so the two can't drift. `Origin` is deliberately ignored:
5
+ * it carries the *caller's* site, not this server's.
6
+ */
7
+ export function resolveServerOrigin(header) {
8
+ // Proxies may send X-Forwarded-* as a comma-separated chain; the client-facing
9
+ // hop is the first entry.
10
+ const firstHop = (value) => value?.split(",")[0]?.trim();
11
+ const forwardedHost = firstHop(header("x-forwarded-host"));
12
+ if (forwardedHost) {
13
+ const proto = firstHop(header("x-forwarded-proto")) || "https";
14
+ return `${proto}://${forwardedHost}`;
15
+ }
16
+ const host = header("host");
17
+ if (host) {
18
+ const proto = ["127.0.0.1:", "localhost:"].some((p) => host.startsWith(p))
19
+ ? "http"
20
+ : "https";
21
+ return `${proto}://${host}`;
22
+ }
23
+ return `http://localhost:${process.env.__PORT || "3000"}`;
24
+ }
25
+ //# sourceMappingURL=requestOrigin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requestOrigin.js","sourceRoot":"","sources":["../../src/server/requestOrigin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CACjC,MAA2C;IAE3C,+EAA+E;IAC/E,0BAA0B;IAC1B,MAAM,QAAQ,GAAG,CAAC,KAAyB,EAAE,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;IAC7E,MAAM,aAAa,GAAG,QAAQ,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAC3D,IAAI,aAAa,EAAE,CAAC;QAClB,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC,IAAI,OAAO,CAAC;QAC/D,OAAO,GAAG,KAAK,MAAM,aAAa,EAAE,CAAC;IACvC,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5B,IAAI,IAAI,EAAE,CAAC;QACT,MAAM,KAAK,GAAG,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YACxE,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,OAAO,CAAC;QACZ,OAAO,GAAG,KAAK,MAAM,IAAI,EAAE,CAAC;IAC9B,CAAC;IACD,OAAO,oBAAoB,OAAO,CAAC,GAAG,CAAC,MAAM,IAAI,MAAM,EAAE,CAAC;AAC5D,CAAC","sourcesContent":["/**\n * Resolves this server's public origin from request headers, in precedence\n * `x-forwarded-host` → `host` → localhost dev fallback. Shared by view serving\n * and OAuth metadata so the two can't drift. `Origin` is deliberately ignored:\n * it carries the *caller's* site, not this server's.\n */\nexport function resolveServerOrigin(\n header: (key: string) => string | undefined,\n): string {\n // Proxies may send X-Forwarded-* as a comma-separated chain; the client-facing\n // hop is the first entry.\n const firstHop = (value: string | undefined) => value?.split(\",\")[0]?.trim();\n const forwardedHost = firstHop(header(\"x-forwarded-host\"));\n if (forwardedHost) {\n const proto = firstHop(header(\"x-forwarded-proto\")) || \"https\";\n return `${proto}://${forwardedHost}`;\n }\n const host = header(\"host\");\n if (host) {\n const proto = [\"127.0.0.1:\", \"localhost:\"].some((p) => host.startsWith(p))\n ? \"http\"\n : \"https\";\n return `${proto}://${host}`;\n }\n return `http://localhost:${process.env.__PORT || \"3000\"}`;\n}\n"]}
@@ -1,43 +1,157 @@
1
- import type { McpUiResourceMeta } from "@modelcontextprotocol/ext-apps";
2
- import { McpServer as McpServerBase, type RegisteredTool } from "@modelcontextprotocol/sdk/server/mcp.js";
1
+ import type { McpUiToolMeta } from "@modelcontextprotocol/ext-apps";
2
+ import { type ServerOptions } from "@modelcontextprotocol/sdk/server/index.js";
3
+ import { McpServer as McpServerBase } from "@modelcontextprotocol/sdk/server/mcp.js";
3
4
  import type { AnySchema, SchemaOutput, ZodRawShapeCompat } from "@modelcontextprotocol/sdk/server/zod-compat.js";
4
5
  import type { RequestHandlerExtra } from "@modelcontextprotocol/sdk/shared/protocol.js";
5
- import type { CallToolResult, Resource, ServerNotification, ServerRequest, ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
6
+ import type { ContentBlock, Implementation, RequestMeta, ServerNotification, ServerRequest, ServerResult, ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
7
+ import express, { type ErrorRequestHandler, type Express, type RequestHandler } from "express";
8
+ import type { OAuthConfig } from "./auth/index.js";
9
+ import type { McpExtra, McpExtraFor, McpMethodString, McpMiddlewareFilter, McpMiddlewareFn, McpResultFor, McpTypedMiddlewareFn, McpWildcard } from "./middleware.js";
10
+ /**
11
+ * Type marker for a registered tool — carries its input, output, and response
12
+ * metadata shapes so views can infer types from `typeof server`.
13
+ *
14
+ * You normally never construct this by hand; it is produced by `registerTool`
15
+ * and consumed by helpers like {@link InferTools} and {@link generateHelpers}.
16
+ */
6
17
  export type ToolDef<TInput = unknown, TOutput = unknown, TResponseMetadata = unknown> = {
7
18
  input: TInput;
8
19
  output: TOutput;
9
20
  responseMetadata: TResponseMetadata;
10
21
  };
11
22
  /**
12
- * Extended MCP Apps CSP with upcoming fields from ext-apps PR #158
13
- * and Skybridge-specific fields for OpenAI compatibility
14
- * @see https://github.com/modelcontextprotocol/ext-apps/pull/158
23
+ * @deprecated Views now always emit a single ext-apps resource; host targeting
24
+ * no longer applies. Retained for backwards compatibility; will be removed in a
25
+ * future major.
26
+ */
27
+ export type ViewHostType = "apps-sdk" | "mcp-app";
28
+ /**
29
+ * Content Security Policy origins attached to a view's resource. Each list is
30
+ * passed through to the host's CSP for the view iframe; omit a field to inherit
31
+ * the host's default for that directive.
32
+ */
33
+ export interface ViewCsp {
34
+ /** Origins for static assets (images, fonts, scripts, styles). */
35
+ resourceDomains?: string[];
36
+ /** Origins the view may contact via fetch/XHR. */
37
+ connectDomains?: string[];
38
+ /** Origins allowed for iframe embeds (opts into stricter app review). */
39
+ frameDomains?: string[];
40
+ /** Origins that can receive openExternal redirects without the safe-link modal. */
41
+ redirectDomains?: string[];
42
+ /** Origins allowed in `<base href>` tags (mcp-apps only). */
43
+ baseUriDomains?: string[];
44
+ }
45
+ /**
46
+ * Registry of view component names. The Skybridge Vite plugin augments this
47
+ * interface in the generated `.skybridge/views.d.ts` with one key per view
48
+ * file, which narrows {@link ViewName} from `string` to the concrete union.
49
+ */
50
+ export interface ViewNameRegistry {
51
+ }
52
+ /**
53
+ * Resolve view component names from a registry: the union of its keys, or
54
+ * `string` when the registry is empty. The empty case happens before
55
+ * `.skybridge/views.d.ts` is generated; falling back to `string` keeps valid
56
+ * view names from erroring on a fresh checkout, and narrowing kicks in once
57
+ * the generated file augments the registry.
15
58
  */
16
- type ExtendedMcpUiResourceCsp = McpUiResourceMeta["csp"] & {
59
+ export type ViewNameFor<Registry> = [keyof Registry & string] extends [never] ? string : keyof Registry & string;
60
+ /** Union of valid view component names. Narrowed by {@link ViewNameRegistry}. */
61
+ export type ViewName = ViewNameFor<ViewNameRegistry>;
62
+ /**
63
+ * Pass under `view` in a tool's `registerTool` config to render the tool's
64
+ * result through a Skybridge view instead of a plain text response.
65
+ */
66
+ export interface ViewConfig {
67
+ /** Filename of the view module (without extension) — matches a file in your `viewsDir`. */
68
+ component: ViewName;
69
+ /** Human-readable label the host may show alongside the view. */
70
+ description?: string;
17
71
  /**
18
- * Origins that can receive openExternal redirects without safe-link modal (OpenAI-specific)
19
- * @see https://developers.openai.com/apps-sdk/reference#component-resource-_meta-fields
72
+ * @deprecated No-op. Every view emits a single ext-apps resource regardless
73
+ * of this value. Will be removed in a future major.
20
74
  */
21
- redirectDomains?: string[];
22
- };
23
- /** Extended MCP Apps resource metadata with upcoming CSP fields */
24
- type ExtendedMcpUiResourceMeta = Omit<McpUiResourceMeta, "csp"> & {
25
- csp?: ExtendedMcpUiResourceCsp;
75
+ hosts?: ViewHostType[];
76
+ /** Request a visible border around the view (forwarded as `ui.prefersBorder`). */
77
+ prefersBorder?: boolean;
78
+ /** Override the iframe's served domain (advanced; forwarded as `ui.domain`). */
79
+ domain?: string;
80
+ /** Per-view CSP overrides — see {@link ViewCsp}. */
81
+ csp?: ViewCsp;
82
+ /** Free-form metadata forwarded on the view resource's `_meta`. */
83
+ _meta?: Record<string, unknown>;
84
+ }
85
+ export type SecurityScheme = {
86
+ type: "noauth";
87
+ } | {
88
+ type: "oauth2";
89
+ scopes?: string[];
26
90
  };
27
- /** User-provided resource configuration with optional CSP override */
28
- export type WidgetResourceMeta = {
29
- ui?: ExtendedMcpUiResourceMeta;
30
- } & Resource["_meta"];
31
- export type WidgetHostType = "apps-sdk" | "mcp-app";
32
- type McpServerOriginalResourceConfig = Omit<Resource, "uri" | "name" | "mimeType" | "_meta"> & {
33
- _meta?: WidgetResourceMeta;
34
- /** Restrict host types to a specific subset */
35
- hosts?: WidgetHostType[];
91
+ export type ToolAuth = {
92
+ public?: boolean;
93
+ scopes?: string[];
36
94
  };
37
- type McpServerOriginalToolConfig = Omit<Parameters<typeof McpServerBase.prototype.registerTool<ZodRawShapeCompat, ZodRawShapeCompat>>[1], "inputSchema" | "outputSchema">;
95
+ /**
96
+ * Options forwarded to the built-in `express.json()` body parser. Derived
97
+ * from Express's own types so the public API doesn't depend on `body-parser`.
98
+ */
99
+ export type JsonOptions = NonNullable<Parameters<typeof express.json>[0]>;
100
+ /** Skybridge-specific server options, passed as the third `McpServer` constructor argument. */
101
+ export interface SkybridgeServerOptions {
102
+ /** Options for the built-in `express.json()` middleware, e.g. `{ limit: "10mb" }`. */
103
+ json?: JsonOptions;
104
+ /** Resource-server OAuth config. When set, mounts well-known metadata and bearer auth on `/mcp`. */
105
+ oauth?: OAuthConfig;
106
+ }
107
+ /**
108
+ * Well-known keys recognized by host runtimes when set on a tool's `_meta`.
109
+ * Use {@link ToolMeta} to also pass arbitrary custom metadata alongside these.
110
+ *
111
+ * @see https://developers.openai.com/apps-sdk/reference#tool-descriptor-parameters
112
+ */
113
+ export interface KnownToolMeta {
114
+ /** Apps SDK: allow the rendered view to call this tool from inside its iframe. */
115
+ "openai/widgetAccessible"?: boolean;
116
+ /** Apps SDK: status text shown while the tool is running (e.g. `"Searching trips"`). */
117
+ "openai/toolInvocation/invoking"?: string;
118
+ /** Apps SDK: status text shown once the tool returns (e.g. `"Found 3 trips"`). */
119
+ "openai/toolInvocation/invoked"?: string;
120
+ /** Apps SDK: input parameters that hold file references — the host attaches uploaded files to them. */
121
+ "openai/fileParams"?: string[];
122
+ /** MCP Apps: control whether the tool is exposed to the model, the app, or both. */
123
+ ui?: Pick<McpUiToolMeta, "visibility">;
124
+ securitySchemes?: SecurityScheme[];
125
+ }
126
+ /** {@link KnownToolMeta} merged with arbitrary string-keyed metadata for custom flags. */
127
+ export type ToolMeta = KnownToolMeta & Record<string, unknown>;
128
+ /**
129
+ * Convenient return type for tool handlers — a plain string, a single
130
+ * {@link ContentBlock}, or an array. Skybridge normalizes it to the MCP
131
+ * `content: ContentBlock[]` shape before responding.
132
+ */
133
+ export type HandlerContent = string | ContentBlock | ContentBlock[];
134
+ /**
135
+ * Type-level marker interface for cross-package type inference.
136
+ *
137
+ * Consumers infer tool types via the structural `$types` property rather than
138
+ * the `McpServer` class generic, because class-generic inference breaks when
139
+ * `McpServer` comes from different package installations (e.g. a consumer
140
+ * with its own `skybridge` dep vs. the in-tree workspace version).
141
+ *
142
+ * Inspired by tRPC's `_def` pattern and Hono's type markers.
143
+ */
144
+ export interface McpServerTypes<TTools extends Record<string, ToolDef>> {
145
+ readonly tools: TTools;
146
+ }
38
147
  type Simplify<T> = {
39
148
  [K in keyof T]: T[K];
40
149
  };
150
+ type ShapeOutput<Shape extends ZodRawShapeCompat> = Simplify<{
151
+ [K in keyof Shape as undefined extends SchemaOutput<Shape[K]> ? never : K]: SchemaOutput<Shape[K]>;
152
+ } & {
153
+ [K in keyof Shape as undefined extends SchemaOutput<Shape[K]> ? K : never]?: SchemaOutput<Shape[K]>;
154
+ }>;
41
155
  type ExtractStructuredContent<T> = T extends {
42
156
  structuredContent: infer SC;
43
157
  } ? Simplify<SC> : never;
@@ -48,52 +162,271 @@ type ExtractMeta<T> = [Extract<T, {
48
162
  }> extends {
49
163
  _meta: infer M;
50
164
  } ? Simplify<M> : unknown;
51
- /**
52
- * Type-level marker interface for cross-package type inference.
53
- * This enables TypeScript to infer tool types across package boundaries
54
- * using structural typing on the $types property, rather than relying on
55
- * class generic inference which fails when McpServer comes from different
56
- * package installations.
57
- *
58
- * Inspired by tRPC's _def pattern and Hono's type markers.
59
- */
60
- export interface McpServerTypes<TTools extends Record<string, ToolDef>> {
61
- readonly tools: TTools;
62
- }
63
- type ShapeOutput<Shape extends ZodRawShapeCompat> = Simplify<{
64
- [K in keyof Shape as undefined extends SchemaOutput<Shape[K]> ? never : K]: SchemaOutput<Shape[K]>;
65
- } & {
66
- [K in keyof Shape as undefined extends SchemaOutput<Shape[K]> ? K : never]?: SchemaOutput<Shape[K]>;
67
- }>;
68
165
  type AddTool<TTools, TName extends string, TInput extends ZodRawShapeCompat, TOutput, TResponseMetadata = unknown> = McpServer<TTools & {
69
166
  [K in TName]: ToolDef<ShapeOutput<TInput>, TOutput, TResponseMetadata>;
70
167
  }>;
71
- type ToolConfig<TInput extends ZodRawShapeCompat | AnySchema> = {
168
+ interface ToolConfigBase<TInput extends ZodRawShapeCompat | AnySchema> {
169
+ name: string;
72
170
  title?: string;
73
171
  description?: string;
74
172
  inputSchema?: TInput;
75
173
  outputSchema?: ZodRawShapeCompat | AnySchema;
76
174
  annotations?: ToolAnnotations;
77
- _meta?: Record<string, unknown>;
175
+ view?: ViewConfig;
176
+ _meta?: ToolMeta;
177
+ }
178
+ type ToolConfig<TInput extends ZodRawShapeCompat | AnySchema> = (ToolConfigBase<TInput> & {
179
+ auth?: ToolAuth;
180
+ securitySchemes?: never;
181
+ }) | (ToolConfigBase<TInput> & {
182
+ auth?: never;
183
+ /**
184
+ * Declares which auth schemes this tool supports (e.g. `noauth`, `oauth2`).
185
+ * Lets clients label tools that require sign-in before calling, and pass
186
+ * the right scopes through the OAuth flow. Listing both `noauth` and
187
+ * `oauth2` signals that the tool works for anonymous callers and gives
188
+ * enhanced behavior to authenticated ones.
189
+ */
190
+ securitySchemes?: SecurityScheme[];
191
+ });
192
+ /**
193
+ * Optional client-supplied hints attached to `params._meta` on every tool call
194
+ * by the Apps SDK host. Hints only: never use for authorization, and tolerate
195
+ * absence.
196
+ * @see https://developers.openai.com/apps-sdk/reference#_meta-fields-the-client-provides
197
+ */
198
+ export interface ClientHintsMeta {
199
+ /** Requested locale (BCP-47, e.g. `"en-US"`). */
200
+ "openai/locale"?: string;
201
+ /** Browser user-agent */
202
+ "openai/userAgent"?: string;
203
+ /** Coarse user location. May be partially populated. */
204
+ "openai/userLocation"?: {
205
+ city?: string;
206
+ region?: string;
207
+ country?: string;
208
+ timezone?: string;
209
+ longitude?: number;
210
+ latitude?: number;
211
+ };
212
+ /** Anonymized user id. */
213
+ "openai/subject"?: string;
214
+ /** Anonymized conversation id, stable within a ChatGPT session. */
215
+ "openai/session"?: string;
216
+ /** Anonymized organization id, when the user account is part of an organization. */
217
+ "openai/organization"?: string;
218
+ /** Stable id for the currently mounted widget instance. */
219
+ "openai/widgetSessionId"?: string;
220
+ }
221
+ type ToolHandlerExtra = Omit<RequestHandlerExtra<ServerRequest, ServerNotification>, "_meta"> & {
222
+ _meta?: RequestMeta & ClientHintsMeta;
78
223
  };
79
224
  type ToolHandler<TInput extends ZodRawShapeCompat, TReturn extends {
80
- content: CallToolResult["content"];
81
- } = CallToolResult> = (args: ShapeOutput<TInput>, extra: RequestHandlerExtra<ServerRequest, ServerNotification>) => TReturn | Promise<TReturn>;
82
- export declare class McpServer<TTools extends Record<string, ToolDef> = Record<never, ToolDef>> extends McpServerBase {
225
+ content?: HandlerContent;
226
+ } = {
227
+ content?: HandlerContent;
228
+ }> = (args: ShapeOutput<TInput>, extra: ToolHandlerExtra) => TReturn | Promise<TReturn>;
229
+ /**
230
+ * Coerce a tool handler's return value into an MCP `content` array. Strings
231
+ * become a single `TextContent`; a single block is wrapped in an array;
232
+ * `undefined` produces `[]`. Mostly used internally — exported so consumers
233
+ * who build content lazily can apply the same normalization.
234
+ */
235
+ export declare function normalizeContent(content: HandlerContent | undefined): ContentBlock[];
236
+ interface McpServerBaseOmitted extends Omit<McpServerBase, "registerTool" | "connect"> {
237
+ }
238
+ declare const McpServerBaseOmitted: new (...args: ConstructorParameters<typeof McpServerBase>) => McpServerBaseOmitted;
239
+ /**
240
+ * Prime the build-time Vite manifest before user code constructs its
241
+ * `McpServer`. Called from the generated `dist/__entry.js`; not part of the
242
+ * user-facing API.
243
+ *
244
+ * @internal
245
+ */
246
+ export declare function __setBuildManifest(manifest: Record<string, {
247
+ file: string;
248
+ }>): void;
249
+ export declare class McpServer<TTools extends Record<string, ToolDef> = Record<never, ToolDef>> extends McpServerBaseOmitted {
83
250
  readonly $types: McpServerTypes<TTools>;
84
- registerWidget<TName extends string, TInput extends ZodRawShapeCompat, TReturn extends {
85
- content: CallToolResult["content"];
86
- }>(name: TName, resourceConfig: McpServerOriginalResourceConfig, toolConfig: McpServerOriginalToolConfig & {
87
- inputSchema?: TInput;
88
- outputSchema?: ZodRawShapeCompat | AnySchema;
89
- }, toolCallback: ToolHandler<TInput, TReturn>): AddTool<TTools, TName, TInput, ExtractStructuredContent<TReturn>, ExtractMeta<TReturn>>;
90
- registerTool<TName extends string, InputArgs extends ZodRawShapeCompat, TReturn extends {
91
- content: CallToolResult["content"];
92
- }>(name: TName, config: ToolConfig<InputArgs>, cb: ToolHandler<InputArgs, TReturn>): AddTool<TTools, TName, InputArgs, ExtractStructuredContent<TReturn>, ExtractMeta<TReturn>>;
93
- registerTool<InputArgs extends ZodRawShapeCompat>(name: string, config: ToolConfig<InputArgs>, cb: ToolHandler<InputArgs>): RegisteredTool;
94
- private registerWidgetResource;
251
+ /**
252
+ * The underlying Express app. Use this to extend the HTTP server with
253
+ * custom routes, middleware, or settings e.g.
254
+ * `server.express.get("/health", ...)`.
255
+ *
256
+ * `express.json()` is pre-applied tune it via the constructor's third
257
+ * argument, e.g. `new McpServer(info, {}, { json: { limit: "10mb" } })`.
258
+ * Register your handlers before `run()`;
259
+ * after `run()`, dev-mode middleware, the `/mcp` route, and the default
260
+ * error handler are appended in that order.
261
+ *
262
+ * Note: Alpic Cloud only routes traffic to `/mcp` — custom routes work
263
+ * locally and on self-hosted deployments.
264
+ */
265
+ readonly express: Express;
266
+ private customErrorMiddleware;
267
+ private mcpMiddlewareEntries;
268
+ private mcpMiddlewareApplied;
269
+ private claimedViews;
270
+ private viewMetaBuilders;
271
+ /**
272
+ * Maps a view resource's query-less path to its canonical registered URI
273
+ * (the one carrying the `?v=` cache key). Lets `resources/read` resolve the
274
+ * underlying view no matter which version param the consumer sends, since
275
+ * the param is only a cache key, not part of the resource's identity.
276
+ */
277
+ private viewUriByPath;
278
+ private viteManifest;
279
+ private readonly serverInfo;
280
+ private readonly serverOptions?;
281
+ private oauthEnabled;
282
+ private resolveResourceMetadataUrl?;
283
+ private securitySchemesByTool;
284
+ constructor(serverInfo: Implementation, options?: ServerOptions, skybridgeOptions?: SkybridgeServerOptions);
285
+ /**
286
+ * Register Express middleware on the underlying app. Mirrors `app.use` —
287
+ * pass handlers directly or a path-prefixed handler list. Register before
288
+ * {@link McpServer.run}; ordering matches Express.
289
+ *
290
+ * Note: Alpic Cloud only routes traffic to `/mcp`. Custom paths work
291
+ * locally and on self-hosted deployments.
292
+ */
293
+ use(...handlers: RequestHandler[]): this;
294
+ use(path: string, ...handlers: RequestHandler[]): this;
295
+ /**
296
+ * Register Express error-handling middleware to run after the built-in
297
+ * `/mcp` route (or your custom route). Use this to log or transform errors
298
+ * thrown by tool handlers before the default error handler responds.
299
+ *
300
+ * @example
301
+ * ```ts
302
+ * server.useOnError((err, _req, _res, next) => {
303
+ * logger.error(err);
304
+ * next(err);
305
+ * });
306
+ * ```
307
+ */
308
+ useOnError(...handlers: ErrorRequestHandler[]): this;
309
+ useOnError(path: string, ...handlers: ErrorRequestHandler[]): this;
310
+ /** Register MCP protocol-level middleware (catch-all). */
311
+ mcpMiddleware(handler: McpMiddlewareFn): this;
312
+ /** Register MCP protocol-level middleware for all requests (`extra` is `McpExtra`). */
313
+ mcpMiddleware(filter: "request", handler: (request: {
314
+ method: string;
315
+ params: Record<string, unknown>;
316
+ }, extra: McpExtra, next: () => Promise<ServerResult>) => Promise<unknown> | unknown): this;
317
+ /** Register MCP protocol-level middleware for all notifications (`extra` is `undefined`). */
318
+ mcpMiddleware(filter: "notification", handler: (request: {
319
+ method: string;
320
+ params: Record<string, unknown>;
321
+ }, extra: undefined, next: () => Promise<undefined>) => Promise<unknown> | unknown): this;
322
+ /**
323
+ * Register MCP protocol-level middleware for an exact method.
324
+ * Narrows `params`, `extra`, and `next()` result based on the method string.
325
+ */
326
+ mcpMiddleware<M extends McpMethodString>(filter: M, handler: McpTypedMiddlewareFn<M>): this;
327
+ /**
328
+ * Register MCP protocol-level middleware for a wildcard pattern (e.g. `"tools/*"`).
329
+ * `next()` returns the union of result types for matching methods.
330
+ */
331
+ mcpMiddleware<W extends McpWildcard>(filter: W, handler: (request: {
332
+ method: string;
333
+ params: Record<string, unknown>;
334
+ }, extra: McpExtraFor<W>, next: () => Promise<McpResultFor<W>>) => Promise<unknown> | unknown): this;
335
+ /**
336
+ * Register MCP protocol-level middleware with a method filter.
337
+ * Filter can be an exact method (`"tools/call"`), wildcard (`"tools/*"`),
338
+ * category (`"request"` | `"notification"`), or an array of those.
339
+ */
340
+ mcpMiddleware(filter: McpMiddlewareFilter, handler: McpMiddlewareFn): this;
341
+ private applyMcpMiddleware;
342
+ /**
343
+ * Connect to an MCP transport (override of the SDK's `connect`). Use this
344
+ * when you're embedding Skybridge in a host that already manages its own
345
+ * transport (e.g. stdio for desktop apps); for HTTP, prefer {@link McpServer.run}
346
+ * which sets the transport up for you. Locks in any middleware registered
347
+ * via {@link McpServer.mcpMiddleware} — further calls to that method will
348
+ * throw afterwards.
349
+ */
350
+ connect(transport: Parameters<typeof McpServerBase.prototype.connect>[0]): Promise<void>;
351
+ /**
352
+ * Per-request stateless connect. The SDK's `Protocol` only allows one
353
+ * transport per instance, so we can't reuse this `McpServer` across
354
+ * concurrent requests. The SDK's idiomatic fix is a `() => McpServer`
355
+ * factory, but that would break Skybridge's singleton API — so instead
356
+ * we build a fresh underlying `Server` per request and share the main
357
+ * server's handler maps by reference. The cast is unavoidable: there's
358
+ * no public API to inject handler maps. `getHandlerMaps` validates the
359
+ * read side and fails fast on SDK field renames.
360
+ */
361
+ connectStatelessTransport(transport: Parameters<typeof McpServerBase.prototype.connect>[0]): Promise<void>;
362
+ /**
363
+ * Start the HTTP server. Listens on `process.env.__PORT` (default `3000`),
364
+ * mounts the `/mcp` route, applies any custom Express middleware registered
365
+ * via {@link McpServer.use} / {@link McpServer.useOnError}, and locks in
366
+ * any MCP middleware registered via {@link McpServer.mcpMiddleware}.
367
+ *
368
+ * On Cloudflare Workers / workerd, returns an object exposing `fetch` so
369
+ * the runtime can bridge incoming requests to the Node HTTP server. On
370
+ * Vercel (`VERCEL === "1"`), returns the Express app directly so the
371
+ * serverless function entry can call it as a `(req, res)` handler. On
372
+ * Node, returns `undefined` once listening.
373
+ */
374
+ run(): Promise<{
375
+ fetch: (...args: unknown[]) => unknown;
376
+ } | Express | undefined>;
377
+ private enforceOneToolPerView;
378
+ private resolveViewRequestContext;
379
+ private registerViewResources;
380
+ private registerViewResource;
381
+ private serveLegacyAppsSdkUrl;
382
+ private decorateToolHandler;
383
+ private computeViewVersionParam;
384
+ private lookupViewFile;
95
385
  private lookupDistFile;
96
- private lookupDistFileWithIndexFallback;
386
+ /**
387
+ * Inject the Vite manifest as a value rather than letting `readManifest()`
388
+ * load it from disk. Required for runtimes without a usable filesystem
389
+ * (Cloudflare Workers, etc.) — the user's `skybridge build` emits the
390
+ * manifest as a JS module which the entry imports and passes here.
391
+ */
392
+ setViteManifest(manifest: Record<string, {
393
+ file: string;
394
+ }>): this;
97
395
  private readManifest;
396
+ /**
397
+ * Register a tool. Pass a `config` describing the tool (name, schemas,
398
+ * optional {@link ViewConfig}, optional {@link ToolMeta}) and a handler that
399
+ * returns the tool's result.
400
+ *
401
+ * Chain calls to build up a server: each call returns a new `McpServer`
402
+ * type that captures the tool's input/output/`_meta` shape so the
403
+ * resulting `typeof server` can drive {@link generateHelpers}.
404
+ *
405
+ * The handler's return shape determines the output types: the
406
+ * `structuredContent` field becomes the tool's typed output, and `_meta`
407
+ * becomes its `responseMetadata`. The `content` field is normalized through
408
+ * {@link normalizeContent}.
409
+ *
410
+ * @example
411
+ * ```ts
412
+ * server.registerTool({
413
+ * name: "search",
414
+ * inputSchema: { query: z.string() },
415
+ * outputSchema: { results: z.array(z.string()) },
416
+ * view: { component: "search" },
417
+ * }, async ({ query }) => ({
418
+ * content: `Found results for ${query}`,
419
+ * structuredContent: { results: [...] },
420
+ * }));
421
+ * ```
422
+ *
423
+ * @see https://docs.skybridge.tech/api-reference/register-tool
424
+ */
425
+ registerTool<TName extends string, InputArgs extends ZodRawShapeCompat, TReturn extends {
426
+ content?: HandlerContent;
427
+ }>(config: ToolConfig<InputArgs> & {
428
+ name: TName;
429
+ }, cb: ToolHandler<InputArgs, TReturn>): AddTool<TTools, TName, InputArgs, ExtractStructuredContent<TReturn>, ExtractMeta<TReturn>>;
430
+ registerTool<InputArgs extends ZodRawShapeCompat>(config: ToolConfig<InputArgs>, cb: ToolHandler<InputArgs>): this;
98
431
  }
99
432
  export {};