skybridge 0.0.0-dev.ecf87cf → 0.0.0-dev.ed005a8

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 (645) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +155 -0
  3. package/bin/run.js +5 -0
  4. package/dist/cli/build-helpers.d.ts +11 -0
  5. package/dist/cli/build-helpers.js +107 -0
  6. package/dist/cli/build-helpers.js.map +1 -0
  7. package/dist/cli/build-helpers.test.js +132 -0
  8. package/dist/cli/build-helpers.test.js.map +1 -0
  9. package/dist/cli/build-steps.d.ts +2 -0
  10. package/dist/cli/build-steps.js +73 -0
  11. package/dist/cli/build-steps.js.map +1 -0
  12. package/dist/cli/build-steps.test.js +52 -0
  13. package/dist/cli/build-steps.test.js.map +1 -0
  14. package/dist/cli/detect-port.d.ts +18 -0
  15. package/dist/cli/detect-port.js +49 -0
  16. package/dist/cli/detect-port.js.map +1 -0
  17. package/dist/cli/header.d.ts +4 -0
  18. package/dist/cli/header.js +6 -0
  19. package/dist/cli/header.js.map +1 -0
  20. package/dist/cli/resolve-skybridge-config.d.ts +5 -0
  21. package/dist/cli/resolve-skybridge-config.js +18 -0
  22. package/dist/cli/resolve-skybridge-config.js.map +1 -0
  23. package/dist/cli/run-command.d.ts +2 -0
  24. package/dist/cli/run-command.js +43 -0
  25. package/dist/cli/run-command.js.map +1 -0
  26. package/dist/cli/run-plain.d.ts +18 -0
  27. package/dist/cli/run-plain.js +89 -0
  28. package/dist/cli/run-plain.js.map +1 -0
  29. package/dist/cli/telemetry.d.ts +7 -0
  30. package/dist/cli/telemetry.js +123 -0
  31. package/dist/cli/telemetry.js.map +1 -0
  32. package/dist/cli/tunnel-control-server.d.ts +9 -0
  33. package/dist/cli/tunnel-control-server.js +31 -0
  34. package/dist/cli/tunnel-control-server.js.map +1 -0
  35. package/dist/cli/tunnel-control-server.test.js +39 -0
  36. package/dist/cli/tunnel-control-server.test.js.map +1 -0
  37. package/dist/cli/tunnel-handler.d.ts +3 -0
  38. package/dist/cli/tunnel-handler.js +48 -0
  39. package/dist/cli/tunnel-handler.js.map +1 -0
  40. package/dist/cli/tunnel-handler.test.js +105 -0
  41. package/dist/cli/tunnel-handler.test.js.map +1 -0
  42. package/dist/cli/tunnel.d.ts +57 -0
  43. package/dist/cli/tunnel.js +154 -0
  44. package/dist/cli/tunnel.js.map +1 -0
  45. package/dist/cli/tunnel.test.js +190 -0
  46. package/dist/cli/tunnel.test.js.map +1 -0
  47. package/dist/cli/types.d.ts +5 -0
  48. package/dist/cli/types.js.map +1 -0
  49. package/dist/cli/use-execute-steps.d.ts +11 -0
  50. package/dist/cli/use-execute-steps.js +36 -0
  51. package/dist/cli/use-execute-steps.js.map +1 -0
  52. package/dist/cli/use-messages.d.ts +3 -0
  53. package/dist/cli/use-messages.js +11 -0
  54. package/dist/cli/use-messages.js.map +1 -0
  55. package/dist/cli/use-nodemon.d.ts +16 -0
  56. package/dist/cli/use-nodemon.js +92 -0
  57. package/dist/cli/use-nodemon.js.map +1 -0
  58. package/dist/cli/use-open-browser.d.ts +1 -0
  59. package/dist/cli/use-open-browser.js +44 -0
  60. package/dist/cli/use-open-browser.js.map +1 -0
  61. package/dist/cli/use-tunnel.d.ts +14 -0
  62. package/dist/cli/use-tunnel.js +131 -0
  63. package/dist/cli/use-tunnel.js.map +1 -0
  64. package/dist/cli/use-typescript-check.d.ts +15 -0
  65. package/dist/cli/use-typescript-check.js +97 -0
  66. package/dist/cli/use-typescript-check.js.map +1 -0
  67. package/dist/commands/build.d.ts +6 -0
  68. package/dist/commands/build.js +31 -0
  69. package/dist/commands/build.js.map +1 -0
  70. package/dist/commands/create.d.ts +9 -0
  71. package/dist/commands/create.js +30 -0
  72. package/dist/commands/create.js.map +1 -0
  73. package/dist/commands/dev.d.ts +13 -0
  74. package/dist/commands/dev.js +128 -0
  75. package/dist/commands/dev.js.map +1 -0
  76. package/dist/commands/start.d.ts +9 -0
  77. package/dist/commands/start.js +55 -0
  78. package/dist/commands/start.js.map +1 -0
  79. package/dist/commands/telemetry/disable.d.ts +5 -0
  80. package/dist/commands/telemetry/disable.js +14 -0
  81. package/dist/commands/telemetry/disable.js.map +1 -0
  82. package/dist/commands/telemetry/enable.d.ts +5 -0
  83. package/dist/commands/telemetry/enable.js +14 -0
  84. package/dist/commands/telemetry/enable.js.map +1 -0
  85. package/dist/commands/telemetry/status.d.ts +5 -0
  86. package/dist/commands/telemetry/status.js +14 -0
  87. package/dist/commands/telemetry/status.js.map +1 -0
  88. package/dist/context-warnings.d.ts +5 -0
  89. package/dist/context-warnings.js +31 -0
  90. package/dist/context-warnings.js.map +1 -0
  91. package/dist/context-warnings.test.js +28 -0
  92. package/dist/context-warnings.test.js.map +1 -0
  93. package/dist/server/app.d.ts +194 -0
  94. package/dist/server/app.js +266 -0
  95. package/dist/server/app.js.map +1 -0
  96. package/dist/server/app.test.js +97 -0
  97. package/dist/server/app.test.js.map +1 -0
  98. package/dist/server/asset-base-url-transform-plugin.d.ts +11 -0
  99. package/dist/server/asset-base-url-transform-plugin.js +48 -0
  100. package/dist/server/asset-base-url-transform-plugin.js.map +1 -0
  101. package/dist/server/asset-base-url-transform-plugin.test.js +134 -0
  102. package/dist/server/asset-base-url-transform-plugin.test.js.map +1 -0
  103. package/dist/server/auth/discovery.d.ts +33 -0
  104. package/dist/server/auth/discovery.js +56 -0
  105. package/dist/server/auth/discovery.js.map +1 -0
  106. package/dist/server/auth/discovery.test.js +93 -0
  107. package/dist/server/auth/discovery.test.js.map +1 -0
  108. package/dist/server/auth/index.d.ts +48 -0
  109. package/dist/server/auth/index.js +2 -0
  110. package/dist/server/auth/index.js.map +1 -0
  111. package/dist/server/auth/providers/auth0.d.ts +40 -0
  112. package/dist/server/auth/providers/auth0.js +36 -0
  113. package/dist/server/auth/providers/auth0.js.map +1 -0
  114. package/dist/server/auth/providers/auth0.test.js +50 -0
  115. package/dist/server/auth/providers/auth0.test.js.map +1 -0
  116. package/dist/server/auth/providers/authplane.d.ts +49 -0
  117. package/dist/server/auth/providers/authplane.js +57 -0
  118. package/dist/server/auth/providers/authplane.js.map +1 -0
  119. package/dist/server/auth/providers/authplane.test.js +143 -0
  120. package/dist/server/auth/providers/authplane.test.js.map +1 -0
  121. package/dist/server/auth/providers/clerk.d.ts +51 -0
  122. package/dist/server/auth/providers/clerk.js +19 -0
  123. package/dist/server/auth/providers/clerk.js.map +1 -0
  124. package/dist/server/auth/providers/clerk.test.js +30 -0
  125. package/dist/server/auth/providers/clerk.test.js.map +1 -0
  126. package/dist/server/auth/providers/custom.d.ts +40 -0
  127. package/dist/server/auth/providers/custom.js +59 -0
  128. package/dist/server/auth/providers/custom.js.map +1 -0
  129. package/dist/server/auth/providers/custom.test.js +161 -0
  130. package/dist/server/auth/providers/custom.test.js.map +1 -0
  131. package/dist/server/auth/providers/descope.d.ts +44 -0
  132. package/dist/server/auth/providers/descope.js +44 -0
  133. package/dist/server/auth/providers/descope.js.map +1 -0
  134. package/dist/server/auth/providers/descope.test.js +62 -0
  135. package/dist/server/auth/providers/descope.test.js.map +1 -0
  136. package/dist/server/auth/providers/shared.d.ts +2 -0
  137. package/dist/server/auth/providers/shared.js +6 -0
  138. package/dist/server/auth/providers/shared.js.map +1 -0
  139. package/dist/server/auth/providers/shared.test.js +10 -0
  140. package/dist/server/auth/providers/shared.test.js.map +1 -0
  141. package/dist/server/auth/providers/stytch.d.ts +25 -0
  142. package/dist/server/auth/providers/stytch.js +16 -0
  143. package/dist/server/auth/providers/stytch.js.map +1 -0
  144. package/dist/server/auth/providers/verify-spy.d.ts +12 -0
  145. package/dist/server/auth/providers/verify-spy.js +21 -0
  146. package/dist/server/auth/providers/verify-spy.js.map +1 -0
  147. package/dist/server/auth/providers/workos.d.ts +33 -0
  148. package/dist/server/auth/providers/workos.js +15 -0
  149. package/dist/server/auth/providers/workos.js.map +1 -0
  150. package/dist/server/auth/security-schemes.d.ts +23 -0
  151. package/dist/server/auth/security-schemes.js +64 -0
  152. package/dist/server/auth/security-schemes.js.map +1 -0
  153. package/dist/server/auth/security-schemes.test.js +99 -0
  154. package/dist/server/auth/security-schemes.test.js.map +1 -0
  155. package/dist/server/auth/setup.d.ts +6 -0
  156. package/dist/server/auth/setup.js +91 -0
  157. package/dist/server/auth/setup.js.map +1 -0
  158. package/dist/server/auth/setup.test.js +514 -0
  159. package/dist/server/auth/setup.test.js.map +1 -0
  160. package/dist/server/auth/verify.d.ts +46 -0
  161. package/dist/server/auth/verify.js +62 -0
  162. package/dist/server/auth/verify.js.map +1 -0
  163. package/dist/server/auth/verify.test.js +149 -0
  164. package/dist/server/auth/verify.test.js.map +1 -0
  165. package/dist/server/auth-extra.test-d.js +130 -0
  166. package/dist/server/auth-extra.test-d.js.map +1 -0
  167. package/dist/server/auth.d.ts +57 -0
  168. package/dist/server/auth.js +27 -0
  169. package/dist/server/auth.js.map +1 -0
  170. package/dist/server/build-manifest.test.js +28 -0
  171. package/dist/server/build-manifest.test.js.map +1 -0
  172. package/dist/server/content-helpers.d.ts +67 -0
  173. package/dist/server/content-helpers.js +79 -0
  174. package/dist/server/content-helpers.js.map +1 -0
  175. package/dist/server/content-helpers.test.d.ts +1 -0
  176. package/dist/server/content-helpers.test.js +70 -0
  177. package/dist/server/content-helpers.test.js.map +1 -0
  178. package/dist/server/express.d.ts +31 -0
  179. package/dist/server/express.js +107 -0
  180. package/dist/server/express.js.map +1 -0
  181. package/dist/server/express.test.d.ts +1 -0
  182. package/dist/server/express.test.js +608 -0
  183. package/dist/server/express.test.js.map +1 -0
  184. package/dist/server/file-ref.d.ts +28 -0
  185. package/dist/server/file-ref.js +27 -0
  186. package/dist/server/file-ref.js.map +1 -0
  187. package/dist/server/host.d.ts +2 -0
  188. package/dist/server/host.js +11 -0
  189. package/dist/server/host.js.map +1 -0
  190. package/dist/server/host.test.d.ts +1 -0
  191. package/dist/server/host.test.js +13 -0
  192. package/dist/server/host.test.js.map +1 -0
  193. package/dist/server/index.d.ts +22 -0
  194. package/dist/server/index.js +18 -0
  195. package/dist/server/index.js.map +1 -0
  196. package/dist/{src/server → server}/inferUtilityTypes.d.ts +6 -6
  197. package/dist/server/inferUtilityTypes.js.map +1 -0
  198. package/dist/server/mcp-errors.test.d.ts +1 -0
  199. package/dist/server/mcp-errors.test.js +41 -0
  200. package/dist/server/mcp-errors.test.js.map +1 -0
  201. package/dist/server/metric.d.ts +14 -0
  202. package/dist/server/metric.js +62 -0
  203. package/dist/server/metric.js.map +1 -0
  204. package/dist/server/middleware.d.ts +162 -0
  205. package/dist/server/middleware.js +126 -0
  206. package/dist/server/middleware.js.map +1 -0
  207. package/dist/server/middleware.test-d.d.ts +1 -0
  208. package/dist/server/middleware.test-d.js +75 -0
  209. package/dist/server/middleware.test-d.js.map +1 -0
  210. package/dist/server/middleware.test.d.ts +1 -0
  211. package/dist/server/middleware.test.js +601 -0
  212. package/dist/server/middleware.test.js.map +1 -0
  213. package/dist/server/register-tool.test.d.ts +1 -0
  214. package/dist/server/register-tool.test.js +27 -0
  215. package/dist/server/register-tool.test.js.map +1 -0
  216. package/dist/server/requestOrigin.d.ts +7 -0
  217. package/dist/server/requestOrigin.js +25 -0
  218. package/dist/server/requestOrigin.js.map +1 -0
  219. package/dist/server/server.d.ts +420 -0
  220. package/dist/server/server.js +546 -0
  221. package/dist/server/server.js.map +1 -0
  222. package/dist/server/skills-integration.test.d.ts +1 -0
  223. package/dist/server/skills-integration.test.js +86 -0
  224. package/dist/server/skills-integration.test.js.map +1 -0
  225. package/dist/server/skills.d.ts +27 -0
  226. package/dist/server/skills.js +188 -0
  227. package/dist/server/skills.js.map +1 -0
  228. package/dist/server/skills.test.d.ts +1 -0
  229. package/dist/server/skills.test.js +243 -0
  230. package/dist/server/skills.test.js.map +1 -0
  231. package/dist/{src/server → server}/templateHelper.d.ts +2 -7
  232. package/dist/server/templateHelper.js +11 -0
  233. package/dist/server/templateHelper.js.map +1 -0
  234. package/dist/server/templates.generated.d.ts +4 -0
  235. package/dist/server/templates.generated.js +43 -0
  236. package/dist/server/templates.generated.js.map +1 -0
  237. package/dist/server/tool-extra.test.d.ts +1 -0
  238. package/dist/server/tool-extra.test.js +88 -0
  239. package/dist/server/tool-extra.test.js.map +1 -0
  240. package/dist/server/tunnel-proxy-router.d.ts +7 -0
  241. package/dist/server/tunnel-proxy-router.js +110 -0
  242. package/dist/server/tunnel-proxy-router.js.map +1 -0
  243. package/dist/server/tunnel-proxy-router.test.d.ts +1 -0
  244. package/dist/server/tunnel-proxy-router.test.js +229 -0
  245. package/dist/server/tunnel-proxy-router.test.js.map +1 -0
  246. package/dist/server/view-name.test-d.d.ts +1 -0
  247. package/dist/server/view-name.test-d.js +8 -0
  248. package/dist/server/view-name.test-d.js.map +1 -0
  249. package/dist/server/view-resource-resolution.test.d.ts +6 -0
  250. package/dist/server/view-resource-resolution.test.js +176 -0
  251. package/dist/server/view-resource-resolution.test.js.map +1 -0
  252. package/dist/server/viewsDevServer.d.ts +14 -0
  253. package/dist/server/viewsDevServer.js +48 -0
  254. package/dist/server/viewsDevServer.js.map +1 -0
  255. package/dist/{src/test → test}/utils.d.ts +21 -31
  256. package/dist/test/utils.js +266 -0
  257. package/dist/test/utils.js.map +1 -0
  258. package/dist/test/view.test.d.ts +1 -0
  259. package/dist/test/view.test.js +540 -0
  260. package/dist/test/view.test.js.map +1 -0
  261. package/dist/version.d.ts +1 -0
  262. package/dist/version.js +3 -0
  263. package/dist/version.js.map +1 -0
  264. package/dist/views/index.d.ts +10 -0
  265. package/dist/views/index.js +3 -0
  266. package/dist/views/index.js.map +1 -0
  267. package/dist/views/scan-views.d.ts +16 -0
  268. package/dist/views/scan-views.js +88 -0
  269. package/dist/views/scan-views.js.map +1 -0
  270. package/dist/views/scan-views.test.d.ts +1 -0
  271. package/dist/views/scan-views.test.js +99 -0
  272. package/dist/views/scan-views.test.js.map +1 -0
  273. package/dist/views/validate-view.d.ts +1 -0
  274. package/dist/views/validate-view.js +9 -0
  275. package/dist/views/validate-view.js.map +1 -0
  276. package/dist/views/validate-view.test.d.ts +1 -0
  277. package/dist/views/validate-view.test.js +24 -0
  278. package/dist/views/validate-view.test.js.map +1 -0
  279. package/dist/web/bridges/adaptor.d.ts +51 -0
  280. package/dist/web/bridges/adaptor.js +327 -0
  281. package/dist/web/bridges/adaptor.js.map +1 -0
  282. package/dist/web/bridges/adaptor.test.d.ts +1 -0
  283. package/dist/web/bridges/adaptor.test.js +225 -0
  284. package/dist/web/bridges/adaptor.test.js.map +1 -0
  285. package/dist/web/bridges/apps-sdk/bridge.d.ts +15 -0
  286. package/dist/web/bridges/apps-sdk/bridge.js +58 -0
  287. package/dist/web/bridges/apps-sdk/bridge.js.map +1 -0
  288. package/dist/web/bridges/apps-sdk/index.d.ts +4 -0
  289. package/dist/web/bridges/apps-sdk/index.js +4 -0
  290. package/dist/web/bridges/apps-sdk/index.js.map +1 -0
  291. package/dist/web/bridges/apps-sdk/types.d.ts +133 -0
  292. package/dist/{src/web → web/bridges/apps-sdk}/types.js +0 -1
  293. package/dist/web/bridges/apps-sdk/types.js.map +1 -0
  294. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.d.ts +13 -0
  295. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js +18 -0
  296. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js.map +1 -0
  297. package/dist/web/bridges/get-adaptor.d.ts +9 -0
  298. package/dist/web/bridges/get-adaptor.js +10 -0
  299. package/dist/web/bridges/get-adaptor.js.map +1 -0
  300. package/dist/web/bridges/get-adaptor.test.d.ts +1 -0
  301. package/dist/web/bridges/get-adaptor.test.js +32 -0
  302. package/dist/web/bridges/get-adaptor.test.js.map +1 -0
  303. package/dist/web/bridges/index.d.ts +5 -0
  304. package/dist/web/bridges/index.js +6 -0
  305. package/dist/web/bridges/index.js.map +1 -0
  306. package/dist/web/bridges/mcp-app/bridge.d.ts +39 -0
  307. package/dist/web/bridges/mcp-app/bridge.js +168 -0
  308. package/dist/web/bridges/mcp-app/bridge.js.map +1 -0
  309. package/dist/web/bridges/mcp-app/bridge.test.d.ts +1 -0
  310. package/dist/web/bridges/mcp-app/bridge.test.js +17 -0
  311. package/dist/web/bridges/mcp-app/bridge.test.js.map +1 -0
  312. package/dist/web/bridges/mcp-app/index.d.ts +3 -0
  313. package/dist/web/bridges/mcp-app/index.js +3 -0
  314. package/dist/web/bridges/mcp-app/index.js.map +1 -0
  315. package/dist/web/bridges/mcp-app/types.d.ts +10 -0
  316. package/dist/web/bridges/mcp-app/types.js +2 -0
  317. package/dist/web/bridges/mcp-app/types.js.map +1 -0
  318. package/dist/web/bridges/mcp-app/use-mcp-app-context.d.ts +19 -0
  319. package/dist/web/bridges/mcp-app/use-mcp-app-context.js +19 -0
  320. package/dist/web/bridges/mcp-app/use-mcp-app-context.js.map +1 -0
  321. package/dist/web/bridges/mcp-app/use-mcp-app-context.test.d.ts +1 -0
  322. package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js +26 -0
  323. package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js.map +1 -0
  324. package/dist/web/bridges/mcp-app/view-tools.test.d.ts +1 -0
  325. package/dist/web/bridges/mcp-app/view-tools.test.js +143 -0
  326. package/dist/web/bridges/mcp-app/view-tools.test.js.map +1 -0
  327. package/dist/web/bridges/types.d.ts +219 -0
  328. package/dist/web/bridges/types.js +15 -0
  329. package/dist/web/bridges/types.js.map +1 -0
  330. package/dist/web/bridges/types.test.d.ts +1 -0
  331. package/dist/web/bridges/types.test.js +19 -0
  332. package/dist/web/bridges/types.test.js.map +1 -0
  333. package/dist/web/bridges/use-host-context.d.ts +7 -0
  334. package/dist/web/bridges/use-host-context.js +13 -0
  335. package/dist/web/bridges/use-host-context.js.map +1 -0
  336. package/dist/web/components/modal-provider.d.ts +4 -0
  337. package/dist/web/components/modal-provider.js +46 -0
  338. package/dist/web/components/modal-provider.js.map +1 -0
  339. package/dist/web/create-store.d.ts +29 -0
  340. package/dist/web/create-store.js +64 -0
  341. package/dist/web/create-store.js.map +1 -0
  342. package/dist/web/create-store.test.d.ts +1 -0
  343. package/dist/web/create-store.test.js +132 -0
  344. package/dist/web/create-store.test.js.map +1 -0
  345. package/dist/web/data-llm.d.ts +47 -0
  346. package/dist/{src/web → web}/data-llm.js +39 -7
  347. package/dist/web/data-llm.js.map +1 -0
  348. package/dist/web/data-llm.test.d.ts +1 -0
  349. package/dist/web/data-llm.test.js +155 -0
  350. package/dist/web/data-llm.test.js.map +1 -0
  351. package/dist/{src/web → web}/generate-helpers.d.ts +41 -32
  352. package/dist/{src/web → web}/generate-helpers.js +36 -28
  353. package/dist/web/generate-helpers.js.map +1 -0
  354. package/dist/web/generate-helpers.test-d.d.ts +1 -0
  355. package/dist/{src/web → web}/generate-helpers.test-d.js +35 -30
  356. package/dist/web/generate-helpers.test-d.js.map +1 -0
  357. package/dist/web/generate-helpers.test.d.ts +1 -0
  358. package/dist/{src/web → web}/generate-helpers.test.js +2 -2
  359. package/dist/web/generate-helpers.test.js.map +1 -0
  360. package/dist/{src/web → web}/helpers/state.d.ts +2 -2
  361. package/dist/web/helpers/state.js +45 -0
  362. package/dist/web/helpers/state.js.map +1 -0
  363. package/dist/web/helpers/state.test.d.ts +1 -0
  364. package/dist/{src/web → web}/helpers/state.test.js +9 -9
  365. package/dist/web/helpers/state.test.js.map +1 -0
  366. package/dist/web/hooks/index.d.ts +16 -0
  367. package/dist/web/hooks/index.js +17 -0
  368. package/dist/web/hooks/index.js.map +1 -0
  369. package/dist/web/hooks/test/utils.d.ts +21 -0
  370. package/dist/web/hooks/test/utils.js +75 -0
  371. package/dist/web/hooks/test/utils.js.map +1 -0
  372. package/dist/{src/web → web}/hooks/use-call-tool.d.ts +47 -1
  373. package/dist/web/hooks/use-call-tool.js +96 -0
  374. package/dist/web/hooks/use-call-tool.js.map +1 -0
  375. package/dist/web/hooks/use-call-tool.test-d.d.ts +1 -0
  376. package/dist/web/hooks/use-call-tool.test-d.js.map +1 -0
  377. package/dist/web/hooks/use-call-tool.test.d.ts +1 -0
  378. package/dist/{src/web → web}/hooks/use-call-tool.test.js +84 -24
  379. package/dist/web/hooks/use-call-tool.test.js.map +1 -0
  380. package/dist/web/hooks/use-display-mode.d.ts +24 -0
  381. package/dist/web/hooks/use-display-mode.js +29 -0
  382. package/dist/web/hooks/use-display-mode.js.map +1 -0
  383. package/dist/web/hooks/use-display-mode.test-d.d.ts +1 -0
  384. package/dist/web/hooks/use-display-mode.test-d.js +8 -0
  385. package/dist/web/hooks/use-display-mode.test-d.js.map +1 -0
  386. package/dist/web/hooks/use-display-mode.test.d.ts +1 -0
  387. package/dist/web/hooks/use-display-mode.test.js +77 -0
  388. package/dist/web/hooks/use-display-mode.test.js.map +1 -0
  389. package/dist/web/hooks/use-download.d.ts +3 -0
  390. package/dist/web/hooks/use-download.js +7 -0
  391. package/dist/web/hooks/use-download.js.map +1 -0
  392. package/dist/web/hooks/use-download.test.d.ts +1 -0
  393. package/dist/web/hooks/use-download.test.js +103 -0
  394. package/dist/web/hooks/use-download.test.js.map +1 -0
  395. package/dist/web/hooks/use-files.d.ts +39 -0
  396. package/dist/web/hooks/use-files.js +42 -0
  397. package/dist/web/hooks/use-files.js.map +1 -0
  398. package/dist/web/hooks/use-files.test.d.ts +1 -0
  399. package/dist/web/hooks/use-files.test.js +62 -0
  400. package/dist/web/hooks/use-files.test.js.map +1 -0
  401. package/dist/web/hooks/use-host.d.ts +22 -0
  402. package/dist/web/hooks/use-host.js +30 -0
  403. package/dist/web/hooks/use-host.js.map +1 -0
  404. package/dist/web/hooks/use-host.test.d.ts +1 -0
  405. package/dist/web/hooks/use-host.test.js +59 -0
  406. package/dist/web/hooks/use-host.test.js.map +1 -0
  407. package/dist/web/hooks/use-open-external.d.ts +20 -0
  408. package/dist/web/hooks/use-open-external.js +24 -0
  409. package/dist/web/hooks/use-open-external.js.map +1 -0
  410. package/dist/web/hooks/use-open-external.test.d.ts +1 -0
  411. package/dist/web/hooks/use-open-external.test.js +75 -0
  412. package/dist/web/hooks/use-open-external.test.js.map +1 -0
  413. package/dist/web/hooks/use-register-view-tool.d.ts +37 -0
  414. package/dist/web/hooks/use-register-view-tool.js +50 -0
  415. package/dist/web/hooks/use-register-view-tool.js.map +1 -0
  416. package/dist/web/hooks/use-request-close.d.ts +16 -0
  417. package/dist/web/hooks/use-request-close.js +21 -0
  418. package/dist/web/hooks/use-request-close.js.map +1 -0
  419. package/dist/web/hooks/use-request-close.test.d.ts +1 -0
  420. package/dist/web/hooks/use-request-close.test.js +47 -0
  421. package/dist/web/hooks/use-request-close.test.js.map +1 -0
  422. package/dist/web/hooks/use-request-modal.d.ts +24 -0
  423. package/dist/web/hooks/use-request-modal.js +31 -0
  424. package/dist/web/hooks/use-request-modal.js.map +1 -0
  425. package/dist/web/hooks/use-request-modal.test.d.ts +1 -0
  426. package/dist/{src/web → web}/hooks/use-request-modal.test.js +16 -2
  427. package/dist/web/hooks/use-request-modal.test.js.map +1 -0
  428. package/dist/web/hooks/use-request-size.d.ts +20 -0
  429. package/dist/web/hooks/use-request-size.js +24 -0
  430. package/dist/web/hooks/use-request-size.js.map +1 -0
  431. package/dist/web/hooks/use-request-size.test.d.ts +1 -0
  432. package/dist/web/hooks/use-request-size.test.js +47 -0
  433. package/dist/web/hooks/use-request-size.test.js.map +1 -0
  434. package/dist/web/hooks/use-send-follow-up-message.d.ts +19 -0
  435. package/dist/web/hooks/use-send-follow-up-message.js +25 -0
  436. package/dist/web/hooks/use-send-follow-up-message.js.map +1 -0
  437. package/dist/web/hooks/use-set-open-in-app-url.d.ts +18 -0
  438. package/dist/web/hooks/use-set-open-in-app-url.js +25 -0
  439. package/dist/web/hooks/use-set-open-in-app-url.js.map +1 -0
  440. package/dist/web/hooks/use-set-open-in-app-url.test.d.ts +1 -0
  441. package/dist/web/hooks/use-set-open-in-app-url.test.js +57 -0
  442. package/dist/web/hooks/use-set-open-in-app-url.test.js.map +1 -0
  443. package/dist/web/hooks/use-tool-info.d.ts +68 -0
  444. package/dist/web/hooks/use-tool-info.js +48 -0
  445. package/dist/web/hooks/use-tool-info.js.map +1 -0
  446. package/dist/web/hooks/use-tool-info.test-d.d.ts +1 -0
  447. package/dist/{src/web → web}/hooks/use-tool-info.test-d.js +19 -6
  448. package/dist/web/hooks/use-tool-info.test-d.js.map +1 -0
  449. package/dist/web/hooks/use-tool-info.test.d.ts +1 -0
  450. package/dist/web/hooks/use-tool-info.test.js +135 -0
  451. package/dist/web/hooks/use-tool-info.test.js.map +1 -0
  452. package/dist/{src/web → web}/hooks/use-user.d.ts +5 -2
  453. package/dist/web/hooks/use-user.js +38 -0
  454. package/dist/web/hooks/use-user.js.map +1 -0
  455. package/dist/web/hooks/use-user.test.d.ts +1 -0
  456. package/dist/web/hooks/use-user.test.js +170 -0
  457. package/dist/web/hooks/use-user.test.js.map +1 -0
  458. package/dist/web/hooks/use-view-state.d.ts +25 -0
  459. package/dist/web/hooks/use-view-state.js +42 -0
  460. package/dist/web/hooks/use-view-state.js.map +1 -0
  461. package/dist/web/hooks/use-view-state.test.d.ts +1 -0
  462. package/dist/web/hooks/use-view-state.test.js +212 -0
  463. package/dist/web/hooks/use-view-state.test.js.map +1 -0
  464. package/dist/web/hooks/use-viewport.d.ts +20 -0
  465. package/dist/web/hooks/use-viewport.js +21 -0
  466. package/dist/web/hooks/use-viewport.js.map +1 -0
  467. package/dist/web/hooks/use-viewport.test.d.ts +1 -0
  468. package/dist/web/hooks/use-viewport.test.js +109 -0
  469. package/dist/web/hooks/use-viewport.test.js.map +1 -0
  470. package/dist/{src/web → web}/index.d.ts +1 -2
  471. package/dist/{src/web → web}/index.js +1 -2
  472. package/dist/web/index.js.map +1 -0
  473. package/dist/web/mount-view.d.ts +21 -0
  474. package/dist/web/mount-view.js +43 -0
  475. package/dist/web/mount-view.js.map +1 -0
  476. package/dist/{src/web → web}/proxy.js +0 -1
  477. package/dist/web/proxy.js.map +1 -0
  478. package/dist/web/types.d.ts +20 -0
  479. package/dist/web/types.js +2 -0
  480. package/dist/web/types.js.map +1 -0
  481. package/package.json +86 -41
  482. package/tsconfig.base.json +33 -0
  483. package/dist/src/server/devtoolsStaticServer.d.ts +0 -15
  484. package/dist/src/server/devtoolsStaticServer.js +0 -38
  485. package/dist/src/server/devtoolsStaticServer.js.map +0 -1
  486. package/dist/src/server/index.d.ts +0 -5
  487. package/dist/src/server/index.js +0 -4
  488. package/dist/src/server/index.js.map +0 -1
  489. package/dist/src/server/inferUtilityTypes.js.map +0 -1
  490. package/dist/src/server/server.d.ts +0 -74
  491. package/dist/src/server/server.js +0 -82
  492. package/dist/src/server/server.js.map +0 -1
  493. package/dist/src/server/templateHelper.js +0 -30
  494. package/dist/src/server/templateHelper.js.map +0 -1
  495. package/dist/src/server/templates/development.hbs +0 -13
  496. package/dist/src/server/templates/production.hbs +0 -7
  497. package/dist/src/server/widgetsDevServer.d.ts +0 -12
  498. package/dist/src/server/widgetsDevServer.js +0 -39
  499. package/dist/src/server/widgetsDevServer.js.map +0 -1
  500. package/dist/src/test/utils.js +0 -242
  501. package/dist/src/test/utils.js.map +0 -1
  502. package/dist/src/test/widget.test.js +0 -146
  503. package/dist/src/test/widget.test.js.map +0 -1
  504. package/dist/src/web/bridges/apps-sdk-adapter.d.ts +0 -2
  505. package/dist/src/web/bridges/apps-sdk-adapter.js +0 -4
  506. package/dist/src/web/bridges/apps-sdk-adapter.js.map +0 -1
  507. package/dist/src/web/bridges/apps-sdk-bridge.d.ts +0 -8
  508. package/dist/src/web/bridges/apps-sdk-bridge.js +0 -41
  509. package/dist/src/web/bridges/apps-sdk-bridge.js.map +0 -1
  510. package/dist/src/web/bridges/get-bridge-methods.d.ts +0 -2
  511. package/dist/src/web/bridges/get-bridge-methods.js +0 -8
  512. package/dist/src/web/bridges/get-bridge-methods.js.map +0 -1
  513. package/dist/src/web/bridges/hooks/use-apps-sdk-bridge.d.ts +0 -2
  514. package/dist/src/web/bridges/hooks/use-apps-sdk-bridge.js +0 -7
  515. package/dist/src/web/bridges/hooks/use-apps-sdk-bridge.js.map +0 -1
  516. package/dist/src/web/bridges/hooks/use-bridge.d.ts +0 -2
  517. package/dist/src/web/bridges/hooks/use-bridge.js +0 -90
  518. package/dist/src/web/bridges/hooks/use-bridge.js.map +0 -1
  519. package/dist/src/web/bridges/hooks/use-mcp-app-bridge.d.ts +0 -4
  520. package/dist/src/web/bridges/hooks/use-mcp-app-bridge.js +0 -7
  521. package/dist/src/web/bridges/hooks/use-mcp-app-bridge.js.map +0 -1
  522. package/dist/src/web/bridges/hooks/use-mcp-app-bridge.test.js +0 -58
  523. package/dist/src/web/bridges/hooks/use-mcp-app-bridge.test.js.map +0 -1
  524. package/dist/src/web/bridges/index.d.ts +0 -4
  525. package/dist/src/web/bridges/index.js +0 -5
  526. package/dist/src/web/bridges/index.js.map +0 -1
  527. package/dist/src/web/bridges/mcp-app-adapter.d.ts +0 -2
  528. package/dist/src/web/bridges/mcp-app-adapter.js +0 -12
  529. package/dist/src/web/bridges/mcp-app-adapter.js.map +0 -1
  530. package/dist/src/web/bridges/mcp-app-bridge.d.ts +0 -30
  531. package/dist/src/web/bridges/mcp-app-bridge.js +0 -139
  532. package/dist/src/web/bridges/mcp-app-bridge.js.map +0 -1
  533. package/dist/src/web/bridges/types.d.ts +0 -32
  534. package/dist/src/web/bridges/types.js.map +0 -1
  535. package/dist/src/web/create-store.d.ts +0 -3
  536. package/dist/src/web/create-store.js +0 -25
  537. package/dist/src/web/create-store.js.map +0 -1
  538. package/dist/src/web/create-store.test.js +0 -70
  539. package/dist/src/web/create-store.test.js.map +0 -1
  540. package/dist/src/web/data-llm.d.ts +0 -14
  541. package/dist/src/web/data-llm.js.map +0 -1
  542. package/dist/src/web/data-llm.test.js +0 -76
  543. package/dist/src/web/data-llm.test.js.map +0 -1
  544. package/dist/src/web/generate-helpers.js.map +0 -1
  545. package/dist/src/web/generate-helpers.test-d.js.map +0 -1
  546. package/dist/src/web/generate-helpers.test.js.map +0 -1
  547. package/dist/src/web/helpers/state.js +0 -40
  548. package/dist/src/web/helpers/state.js.map +0 -1
  549. package/dist/src/web/helpers/state.test.js.map +0 -1
  550. package/dist/src/web/hooks/index.d.ts +0 -11
  551. package/dist/src/web/hooks/index.js +0 -12
  552. package/dist/src/web/hooks/index.js.map +0 -1
  553. package/dist/src/web/hooks/use-call-tool.js +0 -60
  554. package/dist/src/web/hooks/use-call-tool.js.map +0 -1
  555. package/dist/src/web/hooks/use-call-tool.test-d.js.map +0 -1
  556. package/dist/src/web/hooks/use-call-tool.test.js.map +0 -1
  557. package/dist/src/web/hooks/use-display-mode.d.ts +0 -4
  558. package/dist/src/web/hooks/use-display-mode.js +0 -10
  559. package/dist/src/web/hooks/use-display-mode.js.map +0 -1
  560. package/dist/src/web/hooks/use-display-mode.test.js +0 -41
  561. package/dist/src/web/hooks/use-display-mode.test.js.map +0 -1
  562. package/dist/src/web/hooks/use-files.d.ts +0 -10
  563. package/dist/src/web/hooks/use-files.js +0 -7
  564. package/dist/src/web/hooks/use-files.js.map +0 -1
  565. package/dist/src/web/hooks/use-files.test.js +0 -29
  566. package/dist/src/web/hooks/use-files.test.js.map +0 -1
  567. package/dist/src/web/hooks/use-layout.d.ts +0 -22
  568. package/dist/src/web/hooks/use-layout.js +0 -23
  569. package/dist/src/web/hooks/use-layout.js.map +0 -1
  570. package/dist/src/web/hooks/use-layout.test.js +0 -46
  571. package/dist/src/web/hooks/use-layout.test.js.map +0 -1
  572. package/dist/src/web/hooks/use-open-external.d.ts +0 -1
  573. package/dist/src/web/hooks/use-open-external.js +0 -6
  574. package/dist/src/web/hooks/use-open-external.js.map +0 -1
  575. package/dist/src/web/hooks/use-open-external.test.js +0 -24
  576. package/dist/src/web/hooks/use-open-external.test.js.map +0 -1
  577. package/dist/src/web/hooks/use-openai-global.d.ts +0 -3
  578. package/dist/src/web/hooks/use-openai-global.js +0 -6
  579. package/dist/src/web/hooks/use-openai-global.js.map +0 -1
  580. package/dist/src/web/hooks/use-request-modal.d.ts +0 -9
  581. package/dist/src/web/hooks/use-request-modal.js +0 -14
  582. package/dist/src/web/hooks/use-request-modal.js.map +0 -1
  583. package/dist/src/web/hooks/use-request-modal.test.js.map +0 -1
  584. package/dist/src/web/hooks/use-send-follow-up-message.d.ts +0 -1
  585. package/dist/src/web/hooks/use-send-follow-up-message.js +0 -11
  586. package/dist/src/web/hooks/use-send-follow-up-message.js.map +0 -1
  587. package/dist/src/web/hooks/use-tool-info.d.ts +0 -25
  588. package/dist/src/web/hooks/use-tool-info.js +0 -20
  589. package/dist/src/web/hooks/use-tool-info.js.map +0 -1
  590. package/dist/src/web/hooks/use-tool-info.test-d.js.map +0 -1
  591. package/dist/src/web/hooks/use-tool-info.test.js +0 -60
  592. package/dist/src/web/hooks/use-tool-info.test.js.map +0 -1
  593. package/dist/src/web/hooks/use-user.js +0 -19
  594. package/dist/src/web/hooks/use-user.js.map +0 -1
  595. package/dist/src/web/hooks/use-user.test.js +0 -44
  596. package/dist/src/web/hooks/use-user.test.js.map +0 -1
  597. package/dist/src/web/hooks/use-widget-state.d.ts +0 -4
  598. package/dist/src/web/hooks/use-widget-state.js +0 -32
  599. package/dist/src/web/hooks/use-widget-state.js.map +0 -1
  600. package/dist/src/web/hooks/use-widget-state.test.js +0 -61
  601. package/dist/src/web/hooks/use-widget-state.test.js.map +0 -1
  602. package/dist/src/web/index.js.map +0 -1
  603. package/dist/src/web/mount-widget.d.ts +0 -1
  604. package/dist/src/web/mount-widget.js +0 -19
  605. package/dist/src/web/mount-widget.js.map +0 -1
  606. package/dist/src/web/plugin/data-llm.test.js +0 -81
  607. package/dist/src/web/plugin/data-llm.test.js.map +0 -1
  608. package/dist/src/web/plugin/plugin.d.ts +0 -2
  609. package/dist/src/web/plugin/plugin.js +0 -39
  610. package/dist/src/web/plugin/plugin.js.map +0 -1
  611. package/dist/src/web/plugin/transform-data-llm.d.ts +0 -12
  612. package/dist/src/web/plugin/transform-data-llm.js +0 -93
  613. package/dist/src/web/plugin/transform-data-llm.js.map +0 -1
  614. package/dist/src/web/plugin/transform-data-llm.test.js +0 -81
  615. package/dist/src/web/plugin/transform-data-llm.test.js.map +0 -1
  616. package/dist/src/web/proxy.js.map +0 -1
  617. package/dist/src/web/types.d.ts +0 -151
  618. package/dist/src/web/types.js.map +0 -1
  619. package/dist/vitest.config.d.ts +0 -2
  620. package/dist/vitest.config.js +0 -8
  621. package/dist/vitest.config.js.map +0 -1
  622. /package/dist/{src/test/widget.test.d.ts → cli/build-helpers.test.d.ts} +0 -0
  623. /package/dist/{src/web/bridges/hooks/use-mcp-app-bridge.test.d.ts → cli/build-steps.test.d.ts} +0 -0
  624. /package/dist/{src/web/create-store.test.d.ts → cli/tunnel-control-server.test.d.ts} +0 -0
  625. /package/dist/{src/web/data-llm.test.d.ts → cli/tunnel-handler.test.d.ts} +0 -0
  626. /package/dist/{src/web/generate-helpers.test-d.d.ts → cli/tunnel.test.d.ts} +0 -0
  627. /package/dist/{src/web/bridges → cli}/types.js +0 -0
  628. /package/dist/{src/web/generate-helpers.test.d.ts → context-warnings.test.d.ts} +0 -0
  629. /package/dist/{src/web/helpers/state.test.d.ts → server/app.test.d.ts} +0 -0
  630. /package/dist/{src/web/hooks/use-call-tool.test-d.d.ts → server/asset-base-url-transform-plugin.test.d.ts} +0 -0
  631. /package/dist/{src/web/hooks/use-display-mode.test.d.ts → server/auth/discovery.test.d.ts} +0 -0
  632. /package/dist/{src/web/hooks/use-files.test.d.ts → server/auth/providers/auth0.test.d.ts} +0 -0
  633. /package/dist/{src/web/hooks/use-layout.test.d.ts → server/auth/providers/authplane.test.d.ts} +0 -0
  634. /package/dist/{src/web/hooks/use-open-external.test.d.ts → server/auth/providers/clerk.test.d.ts} +0 -0
  635. /package/dist/{src/web/hooks/use-request-modal.test.d.ts → server/auth/providers/custom.test.d.ts} +0 -0
  636. /package/dist/{src/web/hooks/use-tool-info.test-d.d.ts → server/auth/providers/descope.test.d.ts} +0 -0
  637. /package/dist/{src/web/hooks/use-tool-info.test.d.ts → server/auth/providers/shared.test.d.ts} +0 -0
  638. /package/dist/{src/web/hooks/use-user.test.d.ts → server/auth/security-schemes.test.d.ts} +0 -0
  639. /package/dist/{src/web/hooks/use-widget-state.test.d.ts → server/auth/setup.test.d.ts} +0 -0
  640. /package/dist/{src/web/plugin/data-llm.test.d.ts → server/auth/verify.test.d.ts} +0 -0
  641. /package/dist/{src/web/hooks/use-call-tool.test.d.ts → server/auth-extra.test-d.d.ts} +0 -0
  642. /package/dist/{src/web/plugin/transform-data-llm.test.d.ts → server/build-manifest.test.d.ts} +0 -0
  643. /package/dist/{src/server → server}/inferUtilityTypes.js +0 -0
  644. /package/dist/{src/web → web}/hooks/use-call-tool.test-d.js +0 -0
  645. /package/dist/{src/web → web}/proxy.d.ts +0 -0
@@ -0,0 +1,17 @@
1
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
2
+ import { McpAppBridge } from "./bridge.js";
3
+ describe("McpAppBridge.getInstance", () => {
4
+ beforeEach(() => {
5
+ McpAppBridge.resetInstance();
6
+ vi.stubGlobal("parent", { postMessage: vi.fn() });
7
+ });
8
+ afterEach(() => {
9
+ vi.unstubAllGlobals();
10
+ McpAppBridge.resetInstance();
11
+ });
12
+ it("instantiates without injected globals", () => {
13
+ vi.stubGlobal("skybridge", {});
14
+ expect(() => McpAppBridge.getInstance()).not.toThrow();
15
+ });
16
+ });
17
+ //# sourceMappingURL=bridge.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridge.test.js","sourceRoot":"","sources":["../../../../src/web/bridges/mcp-app/bridge.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACxC,UAAU,CAAC,GAAG,EAAE;QACd,YAAY,CAAC,aAAa,EAAE,CAAC;QAC7B,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,EAAE,WAAW,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;IACH,SAAS,CAAC,GAAG,EAAE;QACb,EAAE,CAAC,gBAAgB,EAAE,CAAC;QACtB,YAAY,CAAC,aAAa,EAAE,CAAC;IAC/B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;QAC/C,EAAE,CAAC,UAAU,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QAC/B,MAAM,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;IACzD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { afterEach, beforeEach, describe, expect, it, vi } from \"vitest\";\nimport { McpAppBridge } from \"./bridge.js\";\n\ndescribe(\"McpAppBridge.getInstance\", () => {\n beforeEach(() => {\n McpAppBridge.resetInstance();\n vi.stubGlobal(\"parent\", { postMessage: vi.fn() });\n });\n afterEach(() => {\n vi.unstubAllGlobals();\n McpAppBridge.resetInstance();\n });\n\n it(\"instantiates without injected globals\", () => {\n vi.stubGlobal(\"skybridge\", {});\n expect(() => McpAppBridge.getInstance()).not.toThrow();\n });\n});\n"]}
@@ -0,0 +1,3 @@
1
+ export { McpAppBridge } from "./bridge.js";
2
+ export type { McpAppContext, McpAppContextKey, McpToolState, } from "./types.js";
3
+ export { useMcpAppContext } from "./use-mcp-app-context.js";
@@ -0,0 +1,3 @@
1
+ export { McpAppBridge } from "./bridge.js";
2
+ export { useMcpAppContext } from "./use-mcp-app-context.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/web/bridges/mcp-app/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAM3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC","sourcesContent":["export { McpAppBridge } from \"./bridge.js\";\nexport type {\n McpAppContext,\n McpAppContextKey,\n McpToolState,\n} from \"./types.js\";\nexport { useMcpAppContext } from \"./use-mcp-app-context.js\";\n"]}
@@ -0,0 +1,10 @@
1
+ import type { McpUiHostContext, McpUiToolCancelledNotification, McpUiToolInputNotification, McpUiToolResultNotification } from "@modelcontextprotocol/ext-apps";
2
+ import type { Implementation } from "@modelcontextprotocol/sdk/types.js";
3
+ export type McpToolState = {
4
+ toolInput: NonNullable<McpUiToolInputNotification["params"]["arguments"]> | null;
5
+ toolResult: McpUiToolResultNotification["params"] | null;
6
+ toolCancelled: McpUiToolCancelledNotification["params"] | null;
7
+ hostInfo: Implementation | null;
8
+ };
9
+ export type McpAppContext = McpUiHostContext & McpToolState;
10
+ export type McpAppContextKey = keyof McpAppContext;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/web/bridges/mcp-app/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n McpUiHostContext,\n McpUiToolCancelledNotification,\n McpUiToolInputNotification,\n McpUiToolResultNotification,\n} from \"@modelcontextprotocol/ext-apps\";\nimport type { Implementation } from \"@modelcontextprotocol/sdk/types.js\";\n\nexport type McpToolState = {\n toolInput: NonNullable<\n McpUiToolInputNotification[\"params\"][\"arguments\"]\n > | null;\n toolResult: McpUiToolResultNotification[\"params\"] | null;\n toolCancelled: McpUiToolCancelledNotification[\"params\"] | null;\n hostInfo: Implementation | null;\n};\n\nexport type McpAppContext = McpUiHostContext & McpToolState;\n\nexport type McpAppContextKey = keyof McpAppContext;\n"]}
@@ -0,0 +1,19 @@
1
+ import type { Implementation } from "@modelcontextprotocol/sdk/types.js";
2
+ import type { McpAppContext } from "./types.js";
3
+ type McpAppInitializationOptions = {
4
+ appInfo: Implementation;
5
+ };
6
+ /**
7
+ * Read a single key from the raw MCP Apps (`ext-apps`) bridge context.
8
+ *
9
+ * Advanced escape hatch — prefer the cross-host hooks (`useToolInfo`,
10
+ * `useViewport`, etc.) which work in both MCP Apps and Apps SDK. Reach for this
11
+ * when you need protocol-level fields not surfaced by the public hooks.
12
+ *
13
+ * `options.appInfo` is honored only on the first call that creates the
14
+ * underlying bridge; subsequent calls reuse the singleton.
15
+ *
16
+ * @see https://docs.skybridge.tech/api-reference/use-mcp-app-context
17
+ */
18
+ export declare function useMcpAppContext<K extends keyof McpAppContext>(key: K, options?: Partial<McpAppInitializationOptions>): McpAppContext[K];
19
+ export {};
@@ -0,0 +1,19 @@
1
+ import { useSyncExternalStore } from "react";
2
+ import { McpAppBridge } from "./bridge.js";
3
+ /**
4
+ * Read a single key from the raw MCP Apps (`ext-apps`) bridge context.
5
+ *
6
+ * Advanced escape hatch — prefer the cross-host hooks (`useToolInfo`,
7
+ * `useViewport`, etc.) which work in both MCP Apps and Apps SDK. Reach for this
8
+ * when you need protocol-level fields not surfaced by the public hooks.
9
+ *
10
+ * `options.appInfo` is honored only on the first call that creates the
11
+ * underlying bridge; subsequent calls reuse the singleton.
12
+ *
13
+ * @see https://docs.skybridge.tech/api-reference/use-mcp-app-context
14
+ */
15
+ export function useMcpAppContext(key, options) {
16
+ const bridge = McpAppBridge.getInstance(options);
17
+ return useSyncExternalStore(bridge.subscribe(key), () => bridge.getSnapshot(key));
18
+ }
19
+ //# sourceMappingURL=use-mcp-app-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-mcp-app-context.js","sourceRoot":"","sources":["../../../../src/web/bridges/mcp-app/use-mcp-app-context.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAO3C;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,gBAAgB,CAC9B,GAAM,EACN,OAA8C;IAE9C,MAAM,MAAM,GAAG,YAAY,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IACjD,OAAO,oBAAoB,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CACtD,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CACxB,CAAC;AACJ,CAAC","sourcesContent":["import type { Implementation } from \"@modelcontextprotocol/sdk/types.js\";\n\nimport { useSyncExternalStore } from \"react\";\nimport { McpAppBridge } from \"./bridge.js\";\nimport type { McpAppContext } from \"./types.js\";\n\ntype McpAppInitializationOptions = {\n appInfo: Implementation;\n};\n\n/**\n * Read a single key from the raw MCP Apps (`ext-apps`) bridge context.\n *\n * Advanced escape hatch — prefer the cross-host hooks (`useToolInfo`,\n * `useViewport`, etc.) which work in both MCP Apps and Apps SDK. Reach for this\n * when you need protocol-level fields not surfaced by the public hooks.\n *\n * `options.appInfo` is honored only on the first call that creates the\n * underlying bridge; subsequent calls reuse the singleton.\n *\n * @see https://docs.skybridge.tech/api-reference/use-mcp-app-context\n */\nexport function useMcpAppContext<K extends keyof McpAppContext>(\n key: K,\n options?: Partial<McpAppInitializationOptions>,\n): McpAppContext[K] {\n const bridge = McpAppBridge.getInstance(options);\n return useSyncExternalStore(bridge.subscribe(key), () =>\n bridge.getSnapshot(key),\n );\n}\n"]}
@@ -0,0 +1,26 @@
1
+ import { renderHook, waitFor } from "@testing-library/react";
2
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
3
+ import { getMcpAppHostPostMessageMock, MockResizeObserver, } from "../../hooks/test/utils.js";
4
+ import { McpAppBridge } from "./bridge.js";
5
+ import { useMcpAppContext } from "./use-mcp-app-context.js";
6
+ describe("useMcpAppContext", () => {
7
+ beforeEach(async () => {
8
+ vi.stubGlobal("skybridge", {});
9
+ vi.stubGlobal("ResizeObserver", MockResizeObserver);
10
+ McpAppBridge.resetInstance();
11
+ });
12
+ afterEach(() => {
13
+ vi.unstubAllGlobals();
14
+ vi.clearAllMocks();
15
+ });
16
+ it("should return the theme value from host context and update on notification", async () => {
17
+ vi.stubGlobal("parent", {
18
+ postMessage: getMcpAppHostPostMessageMock({ theme: "light" }),
19
+ });
20
+ const { result } = renderHook(() => useMcpAppContext("theme"));
21
+ await waitFor(() => {
22
+ expect(result.current).toBe("light");
23
+ });
24
+ });
25
+ });
26
+ //# sourceMappingURL=use-mcp-app-context.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-mcp-app-context.test.js","sourceRoot":"","sources":["../../../../src/web/bridges/mcp-app/use-mcp-app-context.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,EACL,4BAA4B,EAC5B,kBAAkB,GACnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,UAAU,CAAC,KAAK,IAAI,EAAE;QACpB,EAAE,CAAC,UAAU,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QAC/B,EAAE,CAAC,UAAU,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,CAAC;QACpD,YAAY,CAAC,aAAa,EAAE,CAAC;IAC/B,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,EAAE,CAAC,gBAAgB,EAAE,CAAC;QACtB,EAAE,CAAC,aAAa,EAAE,CAAC;IACrB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4EAA4E,EAAE,KAAK,IAAI,EAAE;QAC1F,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE;YACtB,WAAW,EAAE,4BAA4B,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;SAC9D,CAAC,CAAC;QACH,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;QAE/D,MAAM,OAAO,CAAC,GAAG,EAAE;YACjB,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { renderHook, waitFor } from \"@testing-library/react\";\nimport { afterEach, beforeEach, describe, expect, it, vi } from \"vitest\";\nimport {\n getMcpAppHostPostMessageMock,\n MockResizeObserver,\n} from \"../../hooks/test/utils.js\";\nimport { McpAppBridge } from \"./bridge.js\";\nimport { useMcpAppContext } from \"./use-mcp-app-context.js\";\n\ndescribe(\"useMcpAppContext\", () => {\n beforeEach(async () => {\n vi.stubGlobal(\"skybridge\", {});\n vi.stubGlobal(\"ResizeObserver\", MockResizeObserver);\n McpAppBridge.resetInstance();\n });\n\n afterEach(() => {\n vi.unstubAllGlobals();\n vi.clearAllMocks();\n });\n\n it(\"should return the theme value from host context and update on notification\", async () => {\n vi.stubGlobal(\"parent\", {\n postMessage: getMcpAppHostPostMessageMock({ theme: \"light\" }),\n });\n const { result } = renderHook(() => useMcpAppContext(\"theme\"));\n\n await waitFor(() => {\n expect(result.current).toBe(\"light\");\n });\n });\n});\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,143 @@
1
+ import { waitFor } from "@testing-library/react";
2
+ import { act } from "react";
3
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
4
+ import * as z from "zod";
5
+ import { MockResizeObserver } from "../../hooks/test/utils.js";
6
+ import { HostAdaptor } from "../adaptor.js";
7
+ import { McpAppBridge } from "./bridge.js";
8
+ const outgoing = [];
9
+ /**
10
+ * Stand-in MCP Apps host: replies to `ui/initialize` and records every message
11
+ * the app posts so tests can assert on responses and notifications.
12
+ */
13
+ function installHostMock() {
14
+ outgoing.length = 0;
15
+ const postMessage = vi.fn((message) => {
16
+ outgoing.push(message);
17
+ if (message.method === "ui/initialize" && message.id !== undefined) {
18
+ act(() => {
19
+ window.dispatchEvent(new MessageEvent("message", {
20
+ source: window.parent,
21
+ data: {
22
+ jsonrpc: "2.0",
23
+ id: message.id,
24
+ result: {
25
+ protocolVersion: "2025-06-18",
26
+ hostInfo: { name: "test-host", version: "1.0.0" },
27
+ hostCapabilities: {},
28
+ hostContext: {},
29
+ },
30
+ },
31
+ }));
32
+ });
33
+ }
34
+ });
35
+ vi.stubGlobal("parent", { postMessage });
36
+ }
37
+ let nextId = 1000;
38
+ /** Send a host → app JSON-RPC request and resolve with the full response (result or error). */
39
+ async function callHost(method, params = {}) {
40
+ const id = ++nextId;
41
+ act(() => {
42
+ window.dispatchEvent(new MessageEvent("message", {
43
+ source: window.parent,
44
+ data: { jsonrpc: "2.0", id, method, params },
45
+ }));
46
+ });
47
+ await waitFor(() => {
48
+ expect(outgoing.some((m) => m.id === id)).toBe(true);
49
+ });
50
+ return outgoing.find((m) => m.id === id);
51
+ }
52
+ describe("McpApp view tools", () => {
53
+ beforeEach(() => {
54
+ vi.stubGlobal("skybridge", {});
55
+ vi.stubGlobal("ResizeObserver", MockResizeObserver);
56
+ McpAppBridge.resetInstance();
57
+ installHostMock();
58
+ });
59
+ afterEach(() => {
60
+ vi.unstubAllGlobals();
61
+ vi.clearAllMocks();
62
+ });
63
+ it("advertises the tools capability during ui/initialize", async () => {
64
+ await McpAppBridge.getInstance().getApp();
65
+ const init = outgoing.find((m) => m.method === "ui/initialize");
66
+ expect(init?.params?.appCapabilities).toMatchObject({
67
+ tools: { listChanged: true },
68
+ });
69
+ });
70
+ it("lists a registered view tool with its input schema", async () => {
71
+ const adaptor = new HostAdaptor();
72
+ await McpAppBridge.getInstance().getApp();
73
+ adaptor.registerViewTool({
74
+ name: "chess_make_move",
75
+ description: "Play a move",
76
+ inputSchema: { san: z.string() },
77
+ annotations: { readOnlyHint: false },
78
+ }, () => ({ content: [{ type: "text", text: "ok" }] }));
79
+ const response = await callHost("tools/list");
80
+ const tools = response?.result?.tools;
81
+ expect(tools).toHaveLength(1);
82
+ const [tool] = tools;
83
+ expect(tool?.name).toBe("chess_make_move");
84
+ expect(tool?.description).toBe("Play a move");
85
+ expect(tool?.inputSchema.properties).toHaveProperty("san");
86
+ expect(tool?.annotations?.readOnlyHint).toBe(false);
87
+ });
88
+ it("invokes the handler with validated args and returns its result", async () => {
89
+ const adaptor = new HostAdaptor();
90
+ await McpAppBridge.getInstance().getApp();
91
+ const handler = vi.fn(({ san }) => ({
92
+ content: [{ type: "text", text: `played ${san}` }],
93
+ structuredContent: { lastMove: san },
94
+ }));
95
+ adaptor.registerViewTool({ name: "chess_make_move", inputSchema: { san: z.string() } }, handler);
96
+ const response = await callHost("tools/call", {
97
+ name: "chess_make_move",
98
+ arguments: { san: "e4" },
99
+ });
100
+ const result = response?.result;
101
+ // ext-apps invokes the callback as `(args, extra)`; assert on the args only.
102
+ expect(handler.mock.calls[0]?.[0]).toEqual({ san: "e4" });
103
+ expect(result?.structuredContent).toEqual({ lastMove: "e4" });
104
+ expect(result?.isError).toBeFalsy();
105
+ expect(result?.content).toEqual([{ type: "text", text: "played e4" }]);
106
+ });
107
+ it("rejects the call without invoking the handler when args are invalid", async () => {
108
+ const adaptor = new HostAdaptor();
109
+ await McpAppBridge.getInstance().getApp();
110
+ const handler = vi.fn(() => ({ content: [] }));
111
+ adaptor.registerViewTool({ name: "chess_make_move", inputSchema: { san: z.string() } }, handler);
112
+ // ext-apps validates input against the schema and rejects with a JSON-RPC
113
+ // error before the handler runs.
114
+ const response = await callHost("tools/call", {
115
+ name: "chess_make_move",
116
+ arguments: { san: 42 },
117
+ });
118
+ expect(handler).not.toHaveBeenCalled();
119
+ expect(response?.error).toBeDefined();
120
+ });
121
+ it("rejects a call to an unknown tool", async () => {
122
+ await McpAppBridge.getInstance().getApp();
123
+ const response = await callHost("tools/call", {
124
+ name: "nope",
125
+ arguments: {},
126
+ });
127
+ expect(response?.error).toBeDefined();
128
+ });
129
+ it("removes the tool and notifies the host when unregistered", async () => {
130
+ const adaptor = new HostAdaptor();
131
+ await McpAppBridge.getInstance().getApp();
132
+ const unregister = adaptor.registerViewTool({ name: "chess_reset" }, () => ({ content: [{ type: "text", text: "reset" }] }));
133
+ await waitFor(() => {
134
+ expect(outgoing.some((m) => m.method === "notifications/tools/list_changed")).toBe(true);
135
+ });
136
+ let listed = await callHost("tools/list");
137
+ expect(listed?.result?.tools).toHaveLength(1);
138
+ unregister();
139
+ listed = await callHost("tools/list");
140
+ expect(listed?.result?.tools).toHaveLength(0);
141
+ });
142
+ });
143
+ //# sourceMappingURL=view-tools.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view-tools.test.js","sourceRoot":"","sources":["../../../../src/web/bridges/mcp-app/view-tools.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAW3C,MAAM,QAAQ,GAAqB,EAAE,CAAC;AAEtC;;;GAGG;AACH,SAAS,eAAe;IACtB,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;IACpB,MAAM,WAAW,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,OAAuB,EAAE,EAAE;QACpD,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,IAAI,OA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,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,kCAAkC,CAAC,CACtE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACf,CAAC,CAAC,CAAC;QAEH,IAAI,MAAM,GAAG,MAAM,QAAQ,CAAC,YAAY,CAAC,CAAC;QAC1C,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QAE9C,UAAU,EAAE,CAAC;QACb,MAAM,GAAG,MAAM,QAAQ,CAAC,YAAY,CAAC,CAAC;QACtC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { waitFor } from \"@testing-library/react\";\nimport { act } from \"react\";\nimport { afterEach, beforeEach, describe, expect, it, vi } from \"vitest\";\nimport * as z from \"zod\";\nimport { MockResizeObserver } from \"../../hooks/test/utils.js\";\nimport { HostAdaptor } from \"../adaptor.js\";\nimport { McpAppBridge } from \"./bridge.js\";\n\ntype JsonRpcMessage = {\n jsonrpc: \"2.0\";\n id?: number;\n method?: string;\n params?: Record<string, unknown>;\n result?: Record<string, unknown>;\n error?: { message: string };\n};\n\nconst outgoing: JsonRpcMessage[] = [];\n\n/**\n * Stand-in MCP Apps host: replies to `ui/initialize` and records every message\n * the app posts so tests can assert on responses and notifications.\n */\nfunction installHostMock() {\n outgoing.length = 0;\n const postMessage = vi.fn((message: JsonRpcMessage) => {\n outgoing.push(message);\n if (message.method === \"ui/initialize\" && message.id !== undefined) {\n act(() => {\n window.dispatchEvent(\n new MessageEvent(\"message\", {\n source: window.parent,\n data: {\n jsonrpc: \"2.0\",\n id: message.id,\n result: {\n protocolVersion: \"2025-06-18\",\n hostInfo: { name: \"test-host\", version: \"1.0.0\" },\n hostCapabilities: {},\n hostContext: {},\n },\n },\n }),\n );\n });\n }\n });\n vi.stubGlobal(\"parent\", { postMessage });\n}\n\nlet nextId = 1000;\n\n/** Send a host → app JSON-RPC request and resolve with the full response (result or error). */\nasync function callHost(method: string, params: Record<string, unknown> = {}) {\n const id = ++nextId;\n act(() => {\n window.dispatchEvent(\n new MessageEvent(\"message\", {\n source: window.parent,\n data: { jsonrpc: \"2.0\", id, method, params },\n }),\n );\n });\n await waitFor(() => {\n expect(outgoing.some((m) => m.id === id)).toBe(true);\n });\n return outgoing.find((m) => m.id === id);\n}\n\ndescribe(\"McpApp view tools\", () => {\n beforeEach(() => {\n vi.stubGlobal(\"skybridge\", {});\n vi.stubGlobal(\"ResizeObserver\", MockResizeObserver);\n McpAppBridge.resetInstance();\n installHostMock();\n });\n\n afterEach(() => {\n vi.unstubAllGlobals();\n vi.clearAllMocks();\n });\n\n it(\"advertises the tools capability during ui/initialize\", async () => {\n await McpAppBridge.getInstance().getApp();\n const init = outgoing.find((m) => m.method === \"ui/initialize\");\n expect(init?.params?.appCapabilities).toMatchObject({\n tools: { listChanged: true },\n });\n });\n\n it(\"lists a registered view tool with its input schema\", async () => {\n const adaptor = new HostAdaptor();\n await McpAppBridge.getInstance().getApp();\n\n adaptor.registerViewTool(\n {\n name: \"chess_make_move\",\n description: \"Play a move\",\n inputSchema: { san: z.string() },\n annotations: { readOnlyHint: false },\n },\n () => ({ content: [{ type: \"text\", text: \"ok\" }] }),\n );\n\n const response = await callHost(\"tools/list\");\n const tools = response?.result?.tools as Array<{\n name: string;\n description?: string;\n inputSchema: { properties?: Record<string, unknown> };\n annotations?: { readOnlyHint?: boolean };\n }>;\n expect(tools).toHaveLength(1);\n const [tool] = tools;\n expect(tool?.name).toBe(\"chess_make_move\");\n expect(tool?.description).toBe(\"Play a move\");\n expect(tool?.inputSchema.properties).toHaveProperty(\"san\");\n expect(tool?.annotations?.readOnlyHint).toBe(false);\n });\n\n it(\"invokes the handler with validated args and returns its result\", async () => {\n const adaptor = new HostAdaptor();\n await McpAppBridge.getInstance().getApp();\n\n const handler = vi.fn(({ san }: { san: string }) => ({\n content: [{ type: \"text\" as const, text: `played ${san}` }],\n structuredContent: { lastMove: san },\n }));\n\n adaptor.registerViewTool(\n { name: \"chess_make_move\", inputSchema: { san: z.string() } },\n handler as never,\n );\n\n const response = await callHost(\"tools/call\", {\n name: \"chess_make_move\",\n arguments: { san: \"e4\" },\n });\n const result = response?.result;\n\n // ext-apps invokes the callback as `(args, extra)`; assert on the args only.\n expect(handler.mock.calls[0]?.[0]).toEqual({ san: \"e4\" });\n expect(result?.structuredContent).toEqual({ lastMove: \"e4\" });\n expect(result?.isError).toBeFalsy();\n expect(result?.content).toEqual([{ type: \"text\", text: \"played e4\" }]);\n });\n\n it(\"rejects the call without invoking the handler when args are invalid\", async () => {\n const adaptor = new HostAdaptor();\n await McpAppBridge.getInstance().getApp();\n\n const handler = vi.fn(() => ({ content: [] }));\n adaptor.registerViewTool(\n { name: \"chess_make_move\", inputSchema: { san: z.string() } },\n handler as never,\n );\n\n // ext-apps validates input against the schema and rejects with a JSON-RPC\n // error before the handler runs.\n const response = await callHost(\"tools/call\", {\n name: \"chess_make_move\",\n arguments: { san: 42 },\n });\n\n expect(handler).not.toHaveBeenCalled();\n expect(response?.error).toBeDefined();\n });\n\n it(\"rejects a call to an unknown tool\", async () => {\n await McpAppBridge.getInstance().getApp();\n const response = await callHost(\"tools/call\", {\n name: \"nope\",\n arguments: {},\n });\n expect(response?.error).toBeDefined();\n });\n\n it(\"removes the tool and notifies the host when unregistered\", async () => {\n const adaptor = new HostAdaptor();\n await McpAppBridge.getInstance().getApp();\n\n const unregister = adaptor.registerViewTool(\n { name: \"chess_reset\" },\n () => ({ content: [{ type: \"text\", text: \"reset\" }] }),\n );\n\n await waitFor(() => {\n expect(\n outgoing.some((m) => m.method === \"notifications/tools/list_changed\"),\n ).toBe(true);\n });\n\n let listed = await callHost(\"tools/list\");\n expect(listed?.result?.tools).toHaveLength(1);\n\n unregister();\n listed = await callHost(\"tools/list\");\n expect(listed?.result?.tools).toHaveLength(0);\n });\n});\n"]}
@@ -0,0 +1,219 @@
1
+ import type { CallToolResult, EmbeddedResource, ResourceLink, ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
2
+ import type { useSyncExternalStore } from "react";
3
+ import type { output as ZodOutput, ZodType } from "zod/v4";
4
+ /**
5
+ * Globals injected on `window.skybridge` by the host. Tells the view where to
6
+ * reach the MCP server.
7
+ */
8
+ export type SkybridgeProperties = {
9
+ serverUrl: string;
10
+ };
11
+ declare global {
12
+ interface Window {
13
+ skybridge: SkybridgeProperties;
14
+ }
15
+ }
16
+ /** Arguments passed to a tool call. `null` for tools that take no input. */
17
+ export type CallToolArgs = Record<string, unknown> | null;
18
+ /**
19
+ * Result of a tool call as surfaced to the view: MCP `content` blocks plus
20
+ * the typed `structuredContent` and optional `meta`. `isError` is set when
21
+ * the server marks the call as failed.
22
+ */
23
+ export type CallToolResponse = {
24
+ content: CallToolResult["content"];
25
+ structuredContent: NonNullable<CallToolResult["structuredContent"]>;
26
+ isError: NonNullable<CallToolResult["isError"]>;
27
+ meta?: CallToolResult["_meta"];
28
+ };
29
+ /**
30
+ * How the view is laid out by the host. `"modal"` is host-driven (see
31
+ * {@link useRequestModal}); `"pip"`, `"inline"`, and `"fullscreen"` are
32
+ * requestable via {@link useDisplayMode}.
33
+ */
34
+ export type DisplayMode = "pip" | "inline" | "fullscreen" | "modal";
35
+ /** Subset of {@link DisplayMode} that the view can request from the host. */
36
+ export type RequestDisplayMode = Exclude<DisplayMode, "modal">;
37
+ /** Host theme. Mirror this in your view's styling for a native feel. */
38
+ export type Theme = "light" | "dark";
39
+ /** Coarse device class reported by the host. `"unknown"` when unavailable. */
40
+ export type DeviceType = "mobile" | "tablet" | "desktop" | "unknown";
41
+ /** Pixel insets the view should keep clear of (notches, home indicators, etc.). */
42
+ export type SafeAreaInsets = {
43
+ top: number;
44
+ right: number;
45
+ bottom: number;
46
+ left: number;
47
+ };
48
+ /** Wrapper around {@link SafeAreaInsets} exposed via {@link useViewport}. */
49
+ export type SafeArea = {
50
+ insets: SafeAreaInsets;
51
+ };
52
+ /** Device and input-capability hints exposed via {@link useUser}. */
53
+ export type UserAgent = {
54
+ device: {
55
+ type: DeviceType;
56
+ };
57
+ capabilities: {
58
+ hover: boolean;
59
+ touch: boolean;
60
+ };
61
+ };
62
+ /**
63
+ * Full snapshot of state the host exposes to the view. Most fields are
64
+ * better accessed through their dedicated hooks (`useViewport`, `useUser`,
65
+ * `useToolInfo`, etc.) — read this directly only for advanced cases.
66
+ */
67
+ export interface HostContext {
68
+ theme: Theme;
69
+ locale: string;
70
+ displayMode: DisplayMode;
71
+ safeArea: SafeArea;
72
+ maxHeight: number | undefined;
73
+ userAgent: UserAgent;
74
+ toolInput: Record<string, unknown> | null;
75
+ toolOutput: Record<string, unknown> | null;
76
+ toolResponseMetadata: Record<string, unknown> | null;
77
+ display: {
78
+ mode: DisplayMode;
79
+ params?: Record<string, unknown>;
80
+ };
81
+ viewState: Record<string, unknown> | null;
82
+ }
83
+ /** @internal `useSyncExternalStore` subscribe signature, re-exported for bridge implementations. */
84
+ export type Subscribe = Parameters<typeof useSyncExternalStore>[0];
85
+ /** @internal Bridge contract implemented by per-host bridge classes. */
86
+ export interface Bridge<Context> {
87
+ subscribe(key: keyof Context): Subscribe;
88
+ subscribe(keys: readonly (keyof Context)[]): Subscribe;
89
+ getSnapshot<K extends keyof Context>(key: K): Context[K] | undefined;
90
+ }
91
+ /** @internal Per-key snapshot store backing {@link useHostContext}. */
92
+ export type HostContextStore<K extends keyof HostContext> = {
93
+ subscribe: Subscribe;
94
+ getSnapshot: () => HostContext[K];
95
+ };
96
+ /** Persisted view state shape (a plain object). See {@link useViewState}. */
97
+ export type ViewState = Record<string, unknown>;
98
+ /** Updater form accepted when writing to view state. */
99
+ export type SetViewStateAction = ViewState | ((prevState: ViewState | null) => ViewState);
100
+ /** Reference to a host-managed file (returned by {@link useFiles}). */
101
+ export type FileMetadata = {
102
+ fileId: string;
103
+ fileName?: string;
104
+ mimeType?: string;
105
+ };
106
+ /** Options for {@link useFiles}'s `upload`. `library: true` saves into the user's library when supported. */
107
+ export type UploadFileOptions = {
108
+ library?: boolean;
109
+ };
110
+ /** Options for {@link useRequestModal}'s `open` call. */
111
+ export type RequestModalOptions = {
112
+ title?: string;
113
+ params?: Record<string, unknown>;
114
+ template?: string;
115
+ anchor?: {
116
+ top?: number;
117
+ left?: number;
118
+ width?: number;
119
+ height?: number;
120
+ };
121
+ };
122
+ /**
123
+ * Options for {@link useOpenExternal}. Set `redirectUrl: false` to tell the
124
+ * host not to append its `?redirectUrl=…` tracking query parameter when
125
+ * opening allowlisted targets.
126
+ */
127
+ export type OpenExternalOptions = {
128
+ redirectUrl?: false;
129
+ };
130
+ /** Options for {@link useSendFollowUpMessage}. */
131
+ export type SendFollowUpMessageOptions = {
132
+ scrollToBottom?: boolean;
133
+ };
134
+ /** Options for {@link useRequestSize}. Omit a dimension to leave it unchanged. */
135
+ export type RequestSizeOptions = {
136
+ width?: number;
137
+ height?: number;
138
+ };
139
+ export type DownloadParams = {
140
+ contents: (EmbeddedResource | ResourceLink)[];
141
+ };
142
+ export type DownloadResult = {
143
+ isError?: boolean;
144
+ };
145
+ /**
146
+ * Shape of a view tool's `inputSchema`: a map of zod schemas. Narrower than
147
+ * the server's `Record<string, StandardSchemaWithJSON>` input shape because the MCP Apps bridge validates with
148
+ * `z.object()` at runtime — other Standard Schema libraries would type-check
149
+ * but throw on the first call.
150
+ */
151
+ export type ViewToolInputShape = Record<string, ZodType>;
152
+ /**
153
+ * Args passed to a {@link ViewToolHandler}, inferred from the tool's
154
+ * `inputSchema` (optionality preserved). Mirrors the server's `registerTool`.
155
+ */
156
+ export type InferViewToolArgs<Shape extends ViewToolInputShape> = {
157
+ [K in keyof Shape as undefined extends ZodOutput<Shape[K]> ? never : K]: ZodOutput<Shape[K]>;
158
+ } & {
159
+ [K in keyof Shape as undefined extends ZodOutput<Shape[K]> ? K : never]?: ZodOutput<Shape[K]>;
160
+ };
161
+ /**
162
+ * Declares a tool the view exposes to the host/model (the MCP Apps
163
+ * "app-provided tools" feature). Mirrors the server-side `registerTool` config.
164
+ * Namespace `name` (e.g. `chess_make_move`) to avoid clashing with server tools.
165
+ */
166
+ export type ViewToolConfig<TInput extends ViewToolInputShape = ViewToolInputShape> = {
167
+ name: string;
168
+ title?: string;
169
+ description?: string;
170
+ inputSchema?: TInput;
171
+ annotations?: ToolAnnotations;
172
+ };
173
+ /**
174
+ * Value a {@link ViewToolHandler} returns — a standard MCP `CallToolResult`
175
+ * (`content` blocks plus optional `structuredContent` / `isError` / `_meta`),
176
+ * exactly as `ext-apps`' app tool callbacks return it.
177
+ */
178
+ export type ViewToolResult = CallToolResult;
179
+ /** Handler run when the host calls a view tool. Receives validated, typed args. */
180
+ export type ViewToolHandler<TInput extends ViewToolInputShape = ViewToolInputShape> = (args: InferViewToolArgs<TInput>) => ViewToolResult | Promise<ViewToolResult>;
181
+ /** @internal Untyped handler signature stored by the adaptor/bridge after type erasure. */
182
+ export type AnyViewToolHandler = (args: Record<string, unknown>) => ViewToolResult | Promise<ViewToolResult>;
183
+ /**
184
+ * @internal
185
+ * Low-level interface every host bridge implements. End-user code should use
186
+ * the React hooks (`useCallTool`, `useViewState`, `useFiles`, …) rather than
187
+ * calling this directly.
188
+ */
189
+ export interface Adaptor {
190
+ getHostContextStore<K extends keyof HostContext>(key: K): HostContextStore<K>;
191
+ callTool<ToolArgs extends CallToolArgs = null, ToolResponse extends CallToolResponse = CallToolResponse>(name: string, args: ToolArgs): Promise<ToolResponse>;
192
+ requestDisplayMode(mode: RequestDisplayMode): Promise<{
193
+ mode: RequestDisplayMode;
194
+ }>;
195
+ requestClose(): Promise<void>;
196
+ requestSize(size: RequestSizeOptions): Promise<void>;
197
+ sendFollowUpMessage(prompt: string, options?: SendFollowUpMessageOptions): Promise<void>;
198
+ openExternal(href: string, options?: OpenExternalOptions): void;
199
+ download(params: DownloadParams): Promise<DownloadResult>;
200
+ setViewState(stateOrUpdater: SetViewStateAction): Promise<void>;
201
+ uploadFile(file: File, options?: UploadFileOptions): Promise<FileMetadata>;
202
+ getFileDownloadUrl(file: FileMetadata): Promise<{
203
+ downloadUrl: string;
204
+ }>;
205
+ selectFiles(): Promise<FileMetadata[]>;
206
+ openModal(options: RequestModalOptions): void;
207
+ setOpenInAppUrl(href: string): Promise<void>;
208
+ closeModal(): void;
209
+ registerViewTool(config: ViewToolConfig, handler: AnyViewToolHandler): () => void;
210
+ }
211
+ /**
212
+ * Thrown when a host bridge method is called in a runtime that doesn't
213
+ * support it (e.g. `uploadFile` outside the Apps SDK runtime).
214
+ */
215
+ export declare class NotSupportedError extends Error {
216
+ readonly method: string;
217
+ readonly reason?: string | undefined;
218
+ constructor(method: string, reason?: string | undefined);
219
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Thrown when a host bridge method is called in a runtime that doesn't
3
+ * support it (e.g. `uploadFile` outside the Apps SDK runtime).
4
+ */
5
+ export class NotSupportedError extends Error {
6
+ method;
7
+ reason;
8
+ constructor(method, reason) {
9
+ super(`${method} is not supported in this runtime${reason ? `: ${reason}` : ""}`);
10
+ this.method = method;
11
+ this.reason = reason;
12
+ this.name = "NotSupportedError";
13
+ }
14
+ }
15
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/web/bridges/types.ts"],"names":[],"mappings":"AAmQA;;;GAGG;AACH,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAExB;IACA;IAFlB,YACkB,MAAc,EACd,MAAe;QAE/B,KAAK,CACH,GAAG,MAAM,oCAAoC,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAC3E,CAAC;QALc,WAAM,GAAN,MAAM,CAAQ;QACd,WAAM,GAAN,MAAM,CAAS;QAK/B,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF","sourcesContent":["import type {\n CallToolResult,\n EmbeddedResource,\n ResourceLink,\n ToolAnnotations,\n} from \"@modelcontextprotocol/sdk/types.js\";\nimport type { useSyncExternalStore } from \"react\";\nimport type { output as ZodOutput, ZodType } from \"zod/v4\";\n\n/**\n * Globals injected on `window.skybridge` by the host. Tells the view where to\n * reach the MCP server.\n */\nexport type SkybridgeProperties = {\n serverUrl: string;\n};\n\ndeclare global {\n interface Window {\n skybridge: SkybridgeProperties;\n }\n}\n\n/** Arguments passed to a tool call. `null` for tools that take no input. */\nexport type CallToolArgs = Record<string, unknown> | null;\n\n/**\n * Result of a tool call as surfaced to the view: MCP `content` blocks plus\n * the typed `structuredContent` and optional `meta`. `isError` is set when\n * the server marks the call as failed.\n */\nexport type CallToolResponse = {\n content: CallToolResult[\"content\"];\n structuredContent: NonNullable<CallToolResult[\"structuredContent\"]>;\n isError: NonNullable<CallToolResult[\"isError\"]>;\n meta?: CallToolResult[\"_meta\"];\n};\n\n/**\n * How the view is laid out by the host. `\"modal\"` is host-driven (see\n * {@link useRequestModal}); `\"pip\"`, `\"inline\"`, and `\"fullscreen\"` are\n * requestable via {@link useDisplayMode}.\n */\nexport type DisplayMode = \"pip\" | \"inline\" | \"fullscreen\" | \"modal\";\n/** Subset of {@link DisplayMode} that the view can request from the host. */\nexport type RequestDisplayMode = Exclude<DisplayMode, \"modal\">;\n\n/** Host theme. Mirror this in your view's styling for a native feel. */\nexport type Theme = \"light\" | \"dark\";\n\n/** Coarse device class reported by the host. `\"unknown\"` when unavailable. */\nexport type DeviceType = \"mobile\" | \"tablet\" | \"desktop\" | \"unknown\";\n\n/** Pixel insets the view should keep clear of (notches, home indicators, etc.). */\nexport type SafeAreaInsets = {\n top: number;\n right: number;\n bottom: number;\n left: number;\n};\n\n/** Wrapper around {@link SafeAreaInsets} exposed via {@link useViewport}. */\nexport type SafeArea = {\n insets: SafeAreaInsets;\n};\n\n/** Device and input-capability hints exposed via {@link useUser}. */\nexport type UserAgent = {\n device: {\n type: DeviceType;\n };\n capabilities: {\n hover: boolean;\n touch: boolean;\n };\n};\n\n/**\n * Full snapshot of state the host exposes to the view. Most fields are\n * better accessed through their dedicated hooks (`useViewport`, `useUser`,\n * `useToolInfo`, etc.) — read this directly only for advanced cases.\n */\nexport interface HostContext {\n theme: Theme;\n locale: string;\n displayMode: DisplayMode;\n safeArea: SafeArea;\n maxHeight: number | undefined;\n userAgent: UserAgent;\n toolInput: Record<string, unknown> | null;\n toolOutput: Record<string, unknown> | null;\n toolResponseMetadata: Record<string, unknown> | null;\n display: {\n mode: DisplayMode;\n params?: Record<string, unknown>;\n };\n viewState: Record<string, unknown> | null;\n}\n\n/** @internal `useSyncExternalStore` subscribe signature, re-exported for bridge implementations. */\nexport type Subscribe = Parameters<typeof useSyncExternalStore>[0];\n\n/** @internal Bridge contract implemented by per-host bridge classes. */\nexport interface Bridge<Context> {\n subscribe(key: keyof Context): Subscribe;\n subscribe(keys: readonly (keyof Context)[]): Subscribe;\n getSnapshot<K extends keyof Context>(key: K): Context[K] | undefined;\n}\n\n/** @internal Per-key snapshot store backing {@link useHostContext}. */\nexport type HostContextStore<K extends keyof HostContext> = {\n subscribe: Subscribe;\n getSnapshot: () => HostContext[K];\n};\n\n/** Persisted view state shape (a plain object). See {@link useViewState}. */\nexport type ViewState = Record<string, unknown>;\n\n/** Updater form accepted when writing to view state. */\nexport type SetViewStateAction =\n | ViewState\n | ((prevState: ViewState | null) => ViewState);\n\n/** Reference to a host-managed file (returned by {@link useFiles}). */\nexport type FileMetadata = {\n fileId: string;\n fileName?: string;\n mimeType?: string;\n};\n\n/** Options for {@link useFiles}'s `upload`. `library: true` saves into the user's library when supported. */\nexport type UploadFileOptions = { library?: boolean };\n\n/** Options for {@link useRequestModal}'s `open` call. */\nexport type RequestModalOptions = {\n title?: string;\n params?: Record<string, unknown>;\n template?: string;\n anchor?: { top?: number; left?: number; width?: number; height?: number };\n};\n\n/**\n * Options for {@link useOpenExternal}. Set `redirectUrl: false` to tell the\n * host not to append its `?redirectUrl=…` tracking query parameter when\n * opening allowlisted targets.\n */\nexport type OpenExternalOptions = {\n redirectUrl?: false;\n};\n\n/** Options for {@link useSendFollowUpMessage}. */\nexport type SendFollowUpMessageOptions = { scrollToBottom?: boolean };\n\n/** Options for {@link useRequestSize}. Omit a dimension to leave it unchanged. */\nexport type RequestSizeOptions = {\n width?: number;\n height?: number;\n};\n\nexport type DownloadParams = {\n contents: (EmbeddedResource | ResourceLink)[];\n};\n\nexport type DownloadResult = {\n isError?: boolean;\n};\n\n/**\n * Shape of a view tool's `inputSchema`: a map of zod schemas. Narrower than\n * the server's `Record<string, StandardSchemaWithJSON>` input shape because the MCP Apps bridge validates with\n * `z.object()` at runtime — other Standard Schema libraries would type-check\n * but throw on the first call.\n */\nexport type ViewToolInputShape = Record<string, ZodType>;\n\n/**\n * Args passed to a {@link ViewToolHandler}, inferred from the tool's\n * `inputSchema` (optionality preserved). Mirrors the server's `registerTool`.\n */\nexport type InferViewToolArgs<Shape extends ViewToolInputShape> = {\n [K in keyof Shape as undefined extends ZodOutput<Shape[K]>\n ? never\n : K]: ZodOutput<Shape[K]>;\n} & {\n [K in keyof Shape as undefined extends ZodOutput<Shape[K]>\n ? K\n : never]?: ZodOutput<Shape[K]>;\n};\n\n/**\n * Declares a tool the view exposes to the host/model (the MCP Apps\n * \"app-provided tools\" feature). Mirrors the server-side `registerTool` config.\n * Namespace `name` (e.g. `chess_make_move`) to avoid clashing with server tools.\n */\nexport type ViewToolConfig<\n TInput extends ViewToolInputShape = ViewToolInputShape,\n> = {\n name: string;\n title?: string;\n description?: string;\n inputSchema?: TInput;\n annotations?: ToolAnnotations;\n};\n\n/**\n * Value a {@link ViewToolHandler} returns — a standard MCP `CallToolResult`\n * (`content` blocks plus optional `structuredContent` / `isError` / `_meta`),\n * exactly as `ext-apps`' app tool callbacks return it.\n */\nexport type ViewToolResult = CallToolResult;\n\n/** Handler run when the host calls a view tool. Receives validated, typed args. */\nexport type ViewToolHandler<\n TInput extends ViewToolInputShape = ViewToolInputShape,\n> = (\n args: InferViewToolArgs<TInput>,\n) => ViewToolResult | Promise<ViewToolResult>;\n\n/** @internal Untyped handler signature stored by the adaptor/bridge after type erasure. */\nexport type AnyViewToolHandler = (\n args: Record<string, unknown>,\n) => ViewToolResult | Promise<ViewToolResult>;\n\n/**\n * @internal\n * Low-level interface every host bridge implements. End-user code should use\n * the React hooks (`useCallTool`, `useViewState`, `useFiles`, …) rather than\n * calling this directly.\n */\nexport interface Adaptor {\n getHostContextStore<K extends keyof HostContext>(key: K): HostContextStore<K>;\n callTool<\n ToolArgs extends CallToolArgs = null,\n ToolResponse extends CallToolResponse = CallToolResponse,\n >(name: string, args: ToolArgs): Promise<ToolResponse>;\n requestDisplayMode(mode: RequestDisplayMode): Promise<{\n mode: RequestDisplayMode;\n }>;\n requestClose(): Promise<void>;\n requestSize(size: RequestSizeOptions): Promise<void>;\n sendFollowUpMessage(\n prompt: string,\n options?: SendFollowUpMessageOptions,\n ): Promise<void>;\n openExternal(href: string, options?: OpenExternalOptions): void;\n download(params: DownloadParams): Promise<DownloadResult>;\n setViewState(stateOrUpdater: SetViewStateAction): Promise<void>;\n uploadFile(file: File, options?: UploadFileOptions): Promise<FileMetadata>;\n getFileDownloadUrl(file: FileMetadata): Promise<{ downloadUrl: string }>;\n selectFiles(): Promise<FileMetadata[]>;\n openModal(options: RequestModalOptions): void;\n setOpenInAppUrl(href: string): Promise<void>;\n closeModal(): void;\n registerViewTool(\n config: ViewToolConfig,\n handler: AnyViewToolHandler,\n ): () => void;\n}\n\n/**\n * Thrown when a host bridge method is called in a runtime that doesn't\n * support it (e.g. `uploadFile` outside the Apps SDK runtime).\n */\nexport class NotSupportedError extends Error {\n constructor(\n public readonly method: string,\n public readonly reason?: string,\n ) {\n super(\n `${method} is not supported in this runtime${reason ? `: ${reason}` : \"\"}`,\n );\n this.name = \"NotSupportedError\";\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,19 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { NotSupportedError } from "./types.js";
3
+ describe("NotSupportedError", () => {
4
+ it("includes method name in message", () => {
5
+ const err = new NotSupportedError("uploadFile");
6
+ expect(err.message).toBe("uploadFile is not supported in this runtime");
7
+ expect(err.name).toBe("NotSupportedError");
8
+ expect(err.method).toBe("uploadFile");
9
+ });
10
+ it("includes reason when provided", () => {
11
+ const err = new NotSupportedError("callTool", "MCP transport unavailable");
12
+ expect(err.message).toBe("callTool is not supported in this runtime: MCP transport unavailable");
13
+ expect(err.reason).toBe("MCP transport unavailable");
14
+ });
15
+ it("is an instance of Error", () => {
16
+ expect(new NotSupportedError("x")).toBeInstanceOf(Error);
17
+ });
18
+ });
19
+ //# sourceMappingURL=types.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.test.js","sourceRoot":"","sources":["../../../src/web/bridges/types.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE;QACzC,MAAM,GAAG,GAAG,IAAI,iBAAiB,CAAC,YAAY,CAAC,CAAC;QAChD,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,6CAA6C,CAAC,CAAC;QACxE,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;QAC3C,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,+BAA+B,EAAE,GAAG,EAAE;QACvC,MAAM,GAAG,GAAG,IAAI,iBAAiB,CAAC,UAAU,EAAE,2BAA2B,CAAC,CAAC;QAC3E,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,CACtB,sEAAsE,CACvE,CAAC;QACF,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yBAAyB,EAAE,GAAG,EAAE;QACjC,MAAM,CAAC,IAAI,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { describe, expect, it } from \"vitest\";\nimport { NotSupportedError } from \"./types.js\";\n\ndescribe(\"NotSupportedError\", () => {\n it(\"includes method name in message\", () => {\n const err = new NotSupportedError(\"uploadFile\");\n expect(err.message).toBe(\"uploadFile is not supported in this runtime\");\n expect(err.name).toBe(\"NotSupportedError\");\n expect(err.method).toBe(\"uploadFile\");\n });\n\n it(\"includes reason when provided\", () => {\n const err = new NotSupportedError(\"callTool\", \"MCP transport unavailable\");\n expect(err.message).toBe(\n \"callTool is not supported in this runtime: MCP transport unavailable\",\n );\n expect(err.reason).toBe(\"MCP transport unavailable\");\n });\n\n it(\"is an instance of Error\", () => {\n expect(new NotSupportedError(\"x\")).toBeInstanceOf(Error);\n });\n});\n"]}
@@ -0,0 +1,7 @@
1
+ import type { HostContext } from "./types.js";
2
+ /**
3
+ * @internal
4
+ * Subscribe to a single {@link HostContext} key via `useSyncExternalStore`.
5
+ * Used to build the higher-level hooks; prefer those for app code.
6
+ */
7
+ export declare const useHostContext: <K extends keyof HostContext>(key: K) => HostContext[K];
@@ -0,0 +1,13 @@
1
+ import { useSyncExternalStore } from "react";
2
+ import { getAdaptor } from "./get-adaptor.js";
3
+ /**
4
+ * @internal
5
+ * Subscribe to a single {@link HostContext} key via `useSyncExternalStore`.
6
+ * Used to build the higher-level hooks; prefer those for app code.
7
+ */
8
+ export const useHostContext = (key) => {
9
+ const adaptor = getAdaptor();
10
+ const store = adaptor.getHostContextStore(key);
11
+ return useSyncExternalStore(store.subscribe, store.getSnapshot);
12
+ };
13
+ //# sourceMappingURL=use-host-context.js.map