skybridge 0.0.0-dev.61ba6ab → 0.0.0-dev.61bfbf3

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 (334) hide show
  1. package/README.md +144 -0
  2. package/bin/run.js +5 -0
  3. package/dist/cli/header.d.ts +4 -0
  4. package/dist/cli/header.js +6 -0
  5. package/dist/cli/header.js.map +1 -0
  6. package/dist/cli/run-command.d.ts +2 -0
  7. package/dist/cli/run-command.js +43 -0
  8. package/dist/cli/run-command.js.map +1 -0
  9. package/dist/cli/telemetry.d.ts +7 -0
  10. package/dist/cli/telemetry.js +123 -0
  11. package/dist/cli/telemetry.js.map +1 -0
  12. package/dist/cli/use-execute-steps.d.ts +11 -0
  13. package/dist/cli/use-execute-steps.js +36 -0
  14. package/dist/cli/use-execute-steps.js.map +1 -0
  15. package/dist/cli/use-nodemon.d.ts +6 -0
  16. package/dist/cli/use-nodemon.js +61 -0
  17. package/dist/cli/use-nodemon.js.map +1 -0
  18. package/dist/cli/use-typescript-check.d.ts +8 -0
  19. package/dist/cli/use-typescript-check.js +59 -0
  20. package/dist/cli/use-typescript-check.js.map +1 -0
  21. package/dist/commands/build.d.ts +9 -0
  22. package/dist/commands/build.js +46 -0
  23. package/dist/commands/build.js.map +1 -0
  24. package/dist/commands/dev.d.ts +9 -0
  25. package/dist/commands/dev.js +31 -0
  26. package/dist/commands/dev.js.map +1 -0
  27. package/dist/commands/start.d.ts +7 -0
  28. package/dist/commands/start.js +28 -0
  29. package/dist/commands/start.js.map +1 -0
  30. package/dist/commands/telemetry/disable.d.ts +5 -0
  31. package/dist/commands/telemetry/disable.js +14 -0
  32. package/dist/commands/telemetry/disable.js.map +1 -0
  33. package/dist/commands/telemetry/enable.d.ts +5 -0
  34. package/dist/commands/telemetry/enable.js +14 -0
  35. package/dist/commands/telemetry/enable.js.map +1 -0
  36. package/dist/commands/telemetry/status.d.ts +5 -0
  37. package/dist/commands/telemetry/status.js +14 -0
  38. package/dist/commands/telemetry/status.js.map +1 -0
  39. package/dist/server/asset-base-url-transform-plugin.d.ts +11 -0
  40. package/dist/server/asset-base-url-transform-plugin.js +34 -0
  41. package/dist/server/asset-base-url-transform-plugin.js.map +1 -0
  42. package/dist/server/asset-base-url-transform-plugin.test.js +56 -0
  43. package/dist/server/asset-base-url-transform-plugin.test.js.map +1 -0
  44. package/dist/{src/server → server}/index.d.ts +0 -1
  45. package/dist/{src/server → server}/index.js +0 -1
  46. package/dist/server/index.js.map +1 -0
  47. package/dist/server/inferUtilityTypes.js.map +1 -0
  48. package/dist/{src/server → server}/server.d.ts +26 -1
  49. package/dist/server/server.js +153 -0
  50. package/dist/server/server.js.map +1 -0
  51. package/dist/{src/server → server}/templateHelper.d.ts +1 -0
  52. package/dist/server/templateHelper.js.map +1 -0
  53. package/dist/server/templates/development.hbs +67 -0
  54. package/dist/{src/server → server}/templates/production.hbs +1 -2
  55. package/dist/{src/server → server}/widgetsDevServer.d.ts +2 -2
  56. package/dist/server/widgetsDevServer.js +57 -0
  57. package/dist/server/widgetsDevServer.js.map +1 -0
  58. package/dist/test/utils.js.map +1 -0
  59. package/dist/{src/test → test}/widget.test.js +123 -14
  60. package/dist/test/widget.test.js.map +1 -0
  61. package/dist/web/bridges/apps-sdk/adaptor.d.ts +22 -0
  62. package/dist/web/bridges/apps-sdk/adaptor.js +64 -0
  63. package/dist/web/bridges/apps-sdk/adaptor.js.map +1 -0
  64. package/dist/web/bridges/apps-sdk/bridge.d.ts +10 -0
  65. package/dist/{src/web/bridges/apps-sdk-bridge.js → web/bridges/apps-sdk/bridge.js} +2 -2
  66. package/dist/web/bridges/apps-sdk/bridge.js.map +1 -0
  67. package/dist/web/bridges/apps-sdk/index.d.ts +5 -0
  68. package/dist/web/bridges/apps-sdk/index.js +5 -0
  69. package/dist/web/bridges/apps-sdk/index.js.map +1 -0
  70. package/dist/{src/web → web/bridges/apps-sdk}/types.d.ts +22 -56
  71. package/dist/{src/web → web/bridges/apps-sdk}/types.js +0 -1
  72. package/dist/web/bridges/apps-sdk/types.js.map +1 -0
  73. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.d.ts +2 -0
  74. package/dist/{src/web/bridges/hooks/use-apps-sdk-bridge.js → web/bridges/apps-sdk/use-apps-sdk-context.js} +3 -3
  75. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js.map +1 -0
  76. package/dist/web/bridges/get-adaptor.d.ts +2 -0
  77. package/dist/web/bridges/get-adaptor.js +8 -0
  78. package/dist/web/bridges/get-adaptor.js.map +1 -0
  79. package/dist/web/bridges/index.d.ts +5 -0
  80. package/dist/web/bridges/index.js +6 -0
  81. package/dist/web/bridges/index.js.map +1 -0
  82. package/dist/web/bridges/mcp-app/adaptor.d.ts +36 -0
  83. package/dist/web/bridges/mcp-app/adaptor.js +188 -0
  84. package/dist/web/bridges/mcp-app/adaptor.js.map +1 -0
  85. package/dist/web/bridges/mcp-app/bridge.d.ts +43 -0
  86. package/dist/{src/web/bridges/mcp-app-bridge.js → web/bridges/mcp-app/bridge.js} +109 -16
  87. package/dist/web/bridges/mcp-app/bridge.js.map +1 -0
  88. package/dist/web/bridges/mcp-app/index.d.ts +4 -0
  89. package/dist/web/bridges/mcp-app/index.js +4 -0
  90. package/dist/web/bridges/mcp-app/index.js.map +1 -0
  91. package/dist/web/bridges/mcp-app/types.d.ts +8 -0
  92. package/dist/web/bridges/mcp-app/types.js.map +1 -0
  93. package/dist/web/bridges/mcp-app/use-mcp-app-context.d.ts +5 -0
  94. package/dist/{src/web/bridges/hooks/use-mcp-app-bridge.js → web/bridges/mcp-app/use-mcp-app-context.js} +3 -3
  95. package/dist/web/bridges/mcp-app/use-mcp-app-context.js.map +1 -0
  96. package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js +66 -0
  97. package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js.map +1 -0
  98. package/dist/web/bridges/types.d.ts +98 -0
  99. package/dist/web/bridges/types.js +2 -0
  100. package/dist/{src/web → web}/bridges/types.js.map +1 -1
  101. package/dist/web/bridges/use-host-context.d.ts +2 -0
  102. package/dist/web/bridges/use-host-context.js +8 -0
  103. package/dist/web/bridges/use-host-context.js.map +1 -0
  104. package/dist/web/components/modal-provider.d.ts +4 -0
  105. package/dist/web/components/modal-provider.js +47 -0
  106. package/dist/web/components/modal-provider.js.map +1 -0
  107. package/dist/{src/web → web}/create-store.js +6 -7
  108. package/dist/web/create-store.js.map +1 -0
  109. package/dist/web/create-store.test.js +126 -0
  110. package/dist/web/create-store.test.js.map +1 -0
  111. package/dist/{src/web → web}/data-llm.js +5 -3
  112. package/dist/web/data-llm.js.map +1 -0
  113. package/dist/web/data-llm.test.js +139 -0
  114. package/dist/web/data-llm.test.js.map +1 -0
  115. package/dist/{src/web → web}/generate-helpers.d.ts +3 -2
  116. package/dist/{src/web → web}/generate-helpers.js +1 -1
  117. package/dist/web/generate-helpers.js.map +1 -0
  118. package/dist/web/generate-helpers.test-d.js.map +1 -0
  119. package/dist/web/generate-helpers.test.js.map +1 -0
  120. package/dist/{src/web → web}/helpers/state.js +13 -8
  121. package/dist/web/helpers/state.js.map +1 -0
  122. package/dist/web/helpers/state.test.js.map +1 -0
  123. package/dist/{src/web → web}/hooks/index.d.ts +1 -1
  124. package/dist/{src/web → web}/hooks/index.js +1 -1
  125. package/dist/web/hooks/index.js.map +1 -0
  126. package/dist/{src/web → web}/hooks/test/utils.d.ts +8 -2
  127. package/dist/web/hooks/test/utils.js +60 -0
  128. package/dist/web/hooks/test/utils.js.map +1 -0
  129. package/dist/{src/web → web}/hooks/use-call-tool.d.ts +2 -1
  130. package/dist/{src/web → web}/hooks/use-call-tool.js +2 -2
  131. package/dist/web/hooks/use-call-tool.js.map +1 -0
  132. package/dist/web/hooks/use-call-tool.test-d.js.map +1 -0
  133. package/dist/{src/web → web}/hooks/use-call-tool.test.js +0 -1
  134. package/dist/web/hooks/use-call-tool.test.js.map +1 -0
  135. package/dist/web/hooks/use-display-mode.js +9 -0
  136. package/dist/web/hooks/use-display-mode.js.map +1 -0
  137. package/dist/web/hooks/use-display-mode.test.js.map +1 -0
  138. package/dist/web/hooks/use-files.d.ts +6 -0
  139. package/dist/web/hooks/use-files.js +9 -0
  140. package/dist/web/hooks/use-files.js.map +1 -0
  141. package/dist/{src/web → web}/hooks/use-files.test.js +5 -4
  142. package/dist/web/hooks/use-files.test.js.map +1 -0
  143. package/dist/{src/web → web}/hooks/use-layout.d.ts +2 -2
  144. package/dist/{src/web → web}/hooks/use-layout.js +4 -4
  145. package/dist/web/hooks/use-layout.js.map +1 -0
  146. package/dist/{src/web → web}/hooks/use-layout.test.js +6 -5
  147. package/dist/web/hooks/use-layout.test.js.map +1 -0
  148. package/dist/{src/web → web}/hooks/use-open-external.js +2 -2
  149. package/dist/web/hooks/use-open-external.js.map +1 -0
  150. package/dist/{src/web → web}/hooks/use-open-external.test.js +1 -1
  151. package/dist/web/hooks/use-open-external.test.js.map +1 -0
  152. package/dist/{src/web → web}/hooks/use-request-modal.d.ts +2 -2
  153. package/dist/web/hooks/use-request-modal.js +16 -0
  154. package/dist/web/hooks/use-request-modal.js.map +1 -0
  155. package/dist/web/hooks/use-request-modal.test.js.map +1 -0
  156. package/dist/{src/web → web}/hooks/use-send-follow-up-message.js +2 -2
  157. package/dist/web/hooks/use-send-follow-up-message.js.map +1 -0
  158. package/dist/web/hooks/use-set-open-in-app-url.d.ts +1 -0
  159. package/dist/web/hooks/use-set-open-in-app-url.js +8 -0
  160. package/dist/web/hooks/use-set-open-in-app-url.js.map +1 -0
  161. package/dist/web/hooks/use-set-open-in-app-url.test.js +49 -0
  162. package/dist/web/hooks/use-set-open-in-app-url.test.js.map +1 -0
  163. package/dist/{src/web → web}/hooks/use-tool-info.js +4 -4
  164. package/dist/web/hooks/use-tool-info.js.map +1 -0
  165. package/dist/web/hooks/use-tool-info.test-d.js.map +1 -0
  166. package/dist/{src/web → web}/hooks/use-tool-info.test.js +4 -4
  167. package/dist/web/hooks/use-tool-info.test.js.map +1 -0
  168. package/dist/{src/web → web}/hooks/use-user.d.ts +1 -1
  169. package/dist/{src/web → web}/hooks/use-user.js +3 -3
  170. package/dist/web/hooks/use-user.js.map +1 -0
  171. package/dist/{src/web → web}/hooks/use-user.test.js +4 -3
  172. package/dist/web/hooks/use-user.test.js.map +1 -0
  173. package/dist/{src/web → web}/hooks/use-widget-state.js +10 -10
  174. package/dist/web/hooks/use-widget-state.js.map +1 -0
  175. package/dist/web/hooks/use-widget-state.test.js.map +1 -0
  176. package/dist/web/index.js.map +1 -0
  177. package/dist/{src/web → web}/mount-widget.js +9 -1
  178. package/dist/web/mount-widget.js.map +1 -0
  179. package/dist/web/plugin/data-llm.test.d.ts +1 -0
  180. package/dist/web/plugin/data-llm.test.js.map +1 -0
  181. package/dist/{src/web → web}/plugin/plugin.js +16 -9
  182. package/dist/web/plugin/plugin.js.map +1 -0
  183. package/dist/web/plugin/transform-data-llm.js.map +1 -0
  184. package/dist/web/plugin/transform-data-llm.test.d.ts +1 -0
  185. package/dist/web/plugin/transform-data-llm.test.js.map +1 -0
  186. package/dist/{src/web → web}/proxy.js +0 -1
  187. package/dist/web/proxy.js.map +1 -0
  188. package/dist/web/types.d.ts +16 -0
  189. package/dist/web/types.js +2 -0
  190. package/dist/web/types.js.map +1 -0
  191. package/package.json +47 -25
  192. package/dist/src/server/devtoolsStaticServer.d.ts +0 -19
  193. package/dist/src/server/devtoolsStaticServer.js +0 -48
  194. package/dist/src/server/devtoolsStaticServer.js.map +0 -1
  195. package/dist/src/server/index.js.map +0 -1
  196. package/dist/src/server/inferUtilityTypes.js.map +0 -1
  197. package/dist/src/server/server.js +0 -82
  198. package/dist/src/server/server.js.map +0 -1
  199. package/dist/src/server/templateHelper.js.map +0 -1
  200. package/dist/src/server/templates/development.hbs +0 -13
  201. package/dist/src/server/widgetsDevServer.js +0 -38
  202. package/dist/src/server/widgetsDevServer.js.map +0 -1
  203. package/dist/src/test/utils.js.map +0 -1
  204. package/dist/src/test/widget.test.js.map +0 -1
  205. package/dist/src/web/bridges/adaptors/apps-sdk-adaptor.d.ts +0 -13
  206. package/dist/src/web/bridges/adaptors/apps-sdk-adaptor.js +0 -33
  207. package/dist/src/web/bridges/adaptors/apps-sdk-adaptor.js.map +0 -1
  208. package/dist/src/web/bridges/adaptors/mcp-app-adaptor.d.ts +0 -16
  209. package/dist/src/web/bridges/adaptors/mcp-app-adaptor.js +0 -115
  210. package/dist/src/web/bridges/adaptors/mcp-app-adaptor.js.map +0 -1
  211. package/dist/src/web/bridges/apps-sdk-bridge.d.ts +0 -10
  212. package/dist/src/web/bridges/apps-sdk-bridge.js.map +0 -1
  213. package/dist/src/web/bridges/hooks/use-adaptor.d.ts +0 -2
  214. package/dist/src/web/bridges/hooks/use-adaptor.js +0 -8
  215. package/dist/src/web/bridges/hooks/use-adaptor.js.map +0 -1
  216. package/dist/src/web/bridges/hooks/use-apps-sdk-bridge.d.ts +0 -2
  217. package/dist/src/web/bridges/hooks/use-apps-sdk-bridge.js.map +0 -1
  218. package/dist/src/web/bridges/hooks/use-bridge.d.ts +0 -2
  219. package/dist/src/web/bridges/hooks/use-bridge.js +0 -8
  220. package/dist/src/web/bridges/hooks/use-bridge.js.map +0 -1
  221. package/dist/src/web/bridges/hooks/use-mcp-app-bridge.d.ts +0 -5
  222. package/dist/src/web/bridges/hooks/use-mcp-app-bridge.js.map +0 -1
  223. package/dist/src/web/bridges/hooks/use-mcp-app-bridge.test.js +0 -41
  224. package/dist/src/web/bridges/hooks/use-mcp-app-bridge.test.js.map +0 -1
  225. package/dist/src/web/bridges/index.d.ts +0 -4
  226. package/dist/src/web/bridges/index.js +0 -5
  227. package/dist/src/web/bridges/index.js.map +0 -1
  228. package/dist/src/web/bridges/mcp-app-bridge.d.ts +0 -38
  229. package/dist/src/web/bridges/mcp-app-bridge.js.map +0 -1
  230. package/dist/src/web/bridges/types.d.ts +0 -57
  231. package/dist/src/web/create-store.js.map +0 -1
  232. package/dist/src/web/create-store.test.js +0 -70
  233. package/dist/src/web/create-store.test.js.map +0 -1
  234. package/dist/src/web/data-llm.js.map +0 -1
  235. package/dist/src/web/data-llm.test.js +0 -76
  236. package/dist/src/web/data-llm.test.js.map +0 -1
  237. package/dist/src/web/generate-helpers.js.map +0 -1
  238. package/dist/src/web/generate-helpers.test-d.js.map +0 -1
  239. package/dist/src/web/generate-helpers.test.js.map +0 -1
  240. package/dist/src/web/helpers/state.js.map +0 -1
  241. package/dist/src/web/helpers/state.test.js.map +0 -1
  242. package/dist/src/web/hooks/index.js.map +0 -1
  243. package/dist/src/web/hooks/test/utils.js +0 -40
  244. package/dist/src/web/hooks/test/utils.js.map +0 -1
  245. package/dist/src/web/hooks/use-call-tool.js.map +0 -1
  246. package/dist/src/web/hooks/use-call-tool.test-d.js.map +0 -1
  247. package/dist/src/web/hooks/use-call-tool.test.js.map +0 -1
  248. package/dist/src/web/hooks/use-display-mode.js +0 -10
  249. package/dist/src/web/hooks/use-display-mode.js.map +0 -1
  250. package/dist/src/web/hooks/use-display-mode.test.js.map +0 -1
  251. package/dist/src/web/hooks/use-files.d.ts +0 -10
  252. package/dist/src/web/hooks/use-files.js +0 -7
  253. package/dist/src/web/hooks/use-files.js.map +0 -1
  254. package/dist/src/web/hooks/use-files.test.js.map +0 -1
  255. package/dist/src/web/hooks/use-layout.js.map +0 -1
  256. package/dist/src/web/hooks/use-layout.test.js.map +0 -1
  257. package/dist/src/web/hooks/use-open-external.js.map +0 -1
  258. package/dist/src/web/hooks/use-open-external.test.js.map +0 -1
  259. package/dist/src/web/hooks/use-openai-global.d.ts +0 -3
  260. package/dist/src/web/hooks/use-openai-global.js +0 -6
  261. package/dist/src/web/hooks/use-openai-global.js.map +0 -1
  262. package/dist/src/web/hooks/use-request-modal.js +0 -14
  263. package/dist/src/web/hooks/use-request-modal.js.map +0 -1
  264. package/dist/src/web/hooks/use-request-modal.test.js.map +0 -1
  265. package/dist/src/web/hooks/use-send-follow-up-message.js.map +0 -1
  266. package/dist/src/web/hooks/use-tool-info.js.map +0 -1
  267. package/dist/src/web/hooks/use-tool-info.test-d.js.map +0 -1
  268. package/dist/src/web/hooks/use-tool-info.test.js.map +0 -1
  269. package/dist/src/web/hooks/use-user.js.map +0 -1
  270. package/dist/src/web/hooks/use-user.test.js.map +0 -1
  271. package/dist/src/web/hooks/use-widget-state.js.map +0 -1
  272. package/dist/src/web/hooks/use-widget-state.test.js.map +0 -1
  273. package/dist/src/web/index.js.map +0 -1
  274. package/dist/src/web/mount-widget.js.map +0 -1
  275. package/dist/src/web/plugin/data-llm.test.js.map +0 -1
  276. package/dist/src/web/plugin/plugin.js.map +0 -1
  277. package/dist/src/web/plugin/transform-data-llm.js.map +0 -1
  278. package/dist/src/web/plugin/transform-data-llm.test.js.map +0 -1
  279. package/dist/src/web/proxy.js.map +0 -1
  280. package/dist/src/web/types.js.map +0 -1
  281. package/dist/vitest.config.d.ts +0 -2
  282. package/dist/vitest.config.js +0 -8
  283. package/dist/vitest.config.js.map +0 -1
  284. /package/dist/{src/test/widget.test.d.ts → server/asset-base-url-transform-plugin.test.d.ts} +0 -0
  285. /package/dist/{src/server → server}/inferUtilityTypes.d.ts +0 -0
  286. /package/dist/{src/server → server}/inferUtilityTypes.js +0 -0
  287. /package/dist/{src/server → server}/templateHelper.js +0 -0
  288. /package/dist/{src/test → test}/utils.d.ts +0 -0
  289. /package/dist/{src/test → test}/utils.js +0 -0
  290. /package/dist/{src/web/bridges/hooks/use-mcp-app-bridge.test.d.ts → test/widget.test.d.ts} +0 -0
  291. /package/dist/{src/web/bridges → web/bridges/mcp-app}/types.js +0 -0
  292. /package/dist/{src/web/create-store.test.d.ts → web/bridges/mcp-app/use-mcp-app-context.test.d.ts} +0 -0
  293. /package/dist/{src/web → web}/create-store.d.ts +0 -0
  294. /package/dist/{src/web/data-llm.test.d.ts → web/create-store.test.d.ts} +0 -0
  295. /package/dist/{src/web → web}/data-llm.d.ts +0 -0
  296. /package/dist/{src/web/plugin → web}/data-llm.test.d.ts +0 -0
  297. /package/dist/{src/web → web}/generate-helpers.test-d.d.ts +0 -0
  298. /package/dist/{src/web → web}/generate-helpers.test-d.js +0 -0
  299. /package/dist/{src/web → web}/generate-helpers.test.d.ts +0 -0
  300. /package/dist/{src/web → web}/generate-helpers.test.js +0 -0
  301. /package/dist/{src/web → web}/helpers/state.d.ts +0 -0
  302. /package/dist/{src/web → web}/helpers/state.test.d.ts +0 -0
  303. /package/dist/{src/web → web}/helpers/state.test.js +0 -0
  304. /package/dist/{src/web → web}/hooks/use-call-tool.test-d.d.ts +0 -0
  305. /package/dist/{src/web → web}/hooks/use-call-tool.test-d.js +0 -0
  306. /package/dist/{src/web → web}/hooks/use-call-tool.test.d.ts +0 -0
  307. /package/dist/{src/web → web}/hooks/use-display-mode.d.ts +0 -0
  308. /package/dist/{src/web → web}/hooks/use-display-mode.test.d.ts +0 -0
  309. /package/dist/{src/web → web}/hooks/use-display-mode.test.js +0 -0
  310. /package/dist/{src/web → web}/hooks/use-files.test.d.ts +0 -0
  311. /package/dist/{src/web → web}/hooks/use-layout.test.d.ts +0 -0
  312. /package/dist/{src/web → web}/hooks/use-open-external.d.ts +0 -0
  313. /package/dist/{src/web → web}/hooks/use-open-external.test.d.ts +0 -0
  314. /package/dist/{src/web → web}/hooks/use-request-modal.test.d.ts +0 -0
  315. /package/dist/{src/web → web}/hooks/use-request-modal.test.js +0 -0
  316. /package/dist/{src/web → web}/hooks/use-send-follow-up-message.d.ts +0 -0
  317. /package/dist/{src/web/hooks/use-tool-info.test-d.d.ts → web/hooks/use-set-open-in-app-url.test.d.ts} +0 -0
  318. /package/dist/{src/web → web}/hooks/use-tool-info.d.ts +0 -0
  319. /package/dist/{src/web/hooks/use-tool-info.test.d.ts → web/hooks/use-tool-info.test-d.d.ts} +0 -0
  320. /package/dist/{src/web → web}/hooks/use-tool-info.test-d.js +0 -0
  321. /package/dist/{src/web/hooks/use-user.test.d.ts → web/hooks/use-tool-info.test.d.ts} +0 -0
  322. /package/dist/{src/web/hooks/use-widget-state.test.d.ts → web/hooks/use-user.test.d.ts} +0 -0
  323. /package/dist/{src/web → web}/hooks/use-widget-state.d.ts +0 -0
  324. /package/dist/{src/web/plugin/transform-data-llm.test.d.ts → web/hooks/use-widget-state.test.d.ts} +0 -0
  325. /package/dist/{src/web → web}/hooks/use-widget-state.test.js +0 -0
  326. /package/dist/{src/web → web}/index.d.ts +0 -0
  327. /package/dist/{src/web → web}/index.js +0 -0
  328. /package/dist/{src/web → web}/mount-widget.d.ts +0 -0
  329. /package/dist/{src/web → web}/plugin/data-llm.test.js +0 -0
  330. /package/dist/{src/web → web}/plugin/plugin.d.ts +0 -0
  331. /package/dist/{src/web → web}/plugin/transform-data-llm.d.ts +0 -0
  332. /package/dist/{src/web → web}/plugin/transform-data-llm.js +0 -0
  333. /package/dist/{src/web → web}/plugin/transform-data-llm.test.js +0 -0
  334. /package/dist/{src/web → web}/proxy.d.ts +0 -0
@@ -0,0 +1,5 @@
1
+ export * from "./apps-sdk/index.js";
2
+ export { getAdaptor } from "./get-adaptor.js";
3
+ export * from "./mcp-app/index.js";
4
+ export * from "./types.js";
5
+ export { useHostContext } from "./use-host-context.js";
@@ -0,0 +1,6 @@
1
+ export * from "./apps-sdk/index.js";
2
+ export { getAdaptor } from "./get-adaptor.js";
3
+ export * from "./mcp-app/index.js";
4
+ export * from "./types.js";
5
+ export { useHostContext } from "./use-host-context.js";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/web/bridges/index.tsx"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,36 @@
1
+ import type { McpUiRequestDisplayModeResult } from "@modelcontextprotocol/ext-apps";
2
+ import type { Adaptor, CallToolResponse, DisplayMode, HostContext, HostContextStore, RequestModalOptions, SetWidgetStateAction } from "../types.js";
3
+ export declare class McpAppAdaptor implements Adaptor {
4
+ private static instance;
5
+ private stores;
6
+ private _widgetState;
7
+ private widgetStateListeners;
8
+ private _viewState;
9
+ private viewListeners;
10
+ private constructor();
11
+ static getInstance(): McpAppAdaptor;
12
+ static resetInstance(): void;
13
+ getHostContextStore<K extends keyof HostContext>(key: K): HostContextStore<K>;
14
+ callTool: <ToolArgs extends Record<string, unknown> | null = null, ToolResponse extends CallToolResponse = CallToolResponse>(name: string, args: ToolArgs) => Promise<ToolResponse>;
15
+ requestDisplayMode: (mode: DisplayMode) => Promise<McpUiRequestDisplayModeResult>;
16
+ sendFollowUpMessage: (prompt: string) => Promise<void>;
17
+ openExternal(href: string): void;
18
+ private initializeStores;
19
+ setWidgetState: (stateOrUpdater: SetWidgetStateAction) => Promise<void>;
20
+ /**
21
+ * @throws File upload is not supported in MCP App.
22
+ */
23
+ uploadFile(): Promise<{
24
+ fileId: string;
25
+ }>;
26
+ /**
27
+ * @throws File download is not supported in MCP App.
28
+ */
29
+ getFileDownloadUrl(): Promise<{
30
+ downloadUrl: string;
31
+ }>;
32
+ openModal(options: RequestModalOptions): void;
33
+ closeModal(): void;
34
+ setOpenInAppUrl(_href: string): Promise<void>;
35
+ private createHostContextStore;
36
+ }
@@ -0,0 +1,188 @@
1
+ import { dequal } from "dequal/lite";
2
+ import { McpAppBridge } from "./bridge.js";
3
+ export class McpAppAdaptor {
4
+ static instance = null;
5
+ stores;
6
+ _widgetState = null;
7
+ widgetStateListeners = new Set();
8
+ _viewState = {
9
+ mode: "inline",
10
+ };
11
+ viewListeners = new Set();
12
+ constructor() {
13
+ this.stores = this.initializeStores();
14
+ }
15
+ static getInstance() {
16
+ if (!McpAppAdaptor.instance) {
17
+ McpAppAdaptor.instance = new McpAppAdaptor();
18
+ }
19
+ return McpAppAdaptor.instance;
20
+ }
21
+ static resetInstance() {
22
+ McpAppAdaptor.instance = null;
23
+ }
24
+ getHostContextStore(key) {
25
+ return this.stores[key];
26
+ }
27
+ callTool = async (name, args) => {
28
+ const bridge = McpAppBridge.getInstance();
29
+ const response = await bridge.request({
30
+ method: "tools/call",
31
+ params: {
32
+ name,
33
+ arguments: args ?? undefined,
34
+ },
35
+ });
36
+ const result = response.content
37
+ .filter((content) => content.type === "text")
38
+ .map(({ text }) => text)
39
+ .join("\n");
40
+ return {
41
+ content: response.content,
42
+ structuredContent: response.structuredContent ?? {},
43
+ isError: response.isError ?? false,
44
+ result,
45
+ meta: response._meta ?? {},
46
+ };
47
+ };
48
+ requestDisplayMode = (mode) => {
49
+ const bridge = McpAppBridge.getInstance();
50
+ if (mode !== "modal") {
51
+ return bridge.request({
52
+ method: "ui/request-display-mode",
53
+ params: { mode },
54
+ });
55
+ }
56
+ throw new Error("Modal display mode is not accessible in MCP App.");
57
+ };
58
+ sendFollowUpMessage = async (prompt) => {
59
+ const bridge = McpAppBridge.getInstance();
60
+ await bridge.request({
61
+ method: "ui/message",
62
+ params: {
63
+ role: "user",
64
+ content: [
65
+ {
66
+ type: "text",
67
+ text: prompt,
68
+ },
69
+ ],
70
+ },
71
+ });
72
+ };
73
+ openExternal(href) {
74
+ const bridge = McpAppBridge.getInstance();
75
+ bridge.request({
76
+ method: "ui/open-link",
77
+ params: { url: href },
78
+ });
79
+ }
80
+ initializeStores() {
81
+ return {
82
+ theme: this.createHostContextStore(["theme"], ({ theme }) => theme ?? "light"),
83
+ locale: this.createHostContextStore(["locale"], ({ locale }) => locale ?? "en-US"),
84
+ safeArea: this.createHostContextStore(["safeAreaInsets"], ({ safeAreaInsets }) => ({
85
+ insets: safeAreaInsets ?? { top: 0, right: 0, bottom: 0, left: 0 },
86
+ })),
87
+ displayMode: this.createHostContextStore(["displayMode"], ({ displayMode }) => displayMode ?? "inline"),
88
+ maxHeight: this.createHostContextStore(["containerDimensions"], ({ containerDimensions }) => {
89
+ if (containerDimensions && "maxHeight" in containerDimensions) {
90
+ return containerDimensions.maxHeight;
91
+ }
92
+ return undefined;
93
+ }),
94
+ userAgent: this.createHostContextStore(["platform", "deviceCapabilities"], ({ platform, deviceCapabilities }) => ({
95
+ device: {
96
+ type: platform === "web" ? "desktop" : (platform ?? "unknown"),
97
+ },
98
+ capabilities: {
99
+ hover: true,
100
+ touch: true,
101
+ ...deviceCapabilities,
102
+ },
103
+ })),
104
+ toolInput: this.createHostContextStore(["toolInput"], ({ toolInput }) => toolInput ?? null),
105
+ toolOutput: this.createHostContextStore(["toolResult"], ({ toolResult }) => toolResult?.structuredContent ?? null),
106
+ toolResponseMetadata: this.createHostContextStore(["toolResult"], ({ toolResult }) => toolResult?._meta ?? null),
107
+ view: {
108
+ subscribe: (onChange) => {
109
+ this.viewListeners.add(onChange);
110
+ return () => {
111
+ this.viewListeners.delete(onChange);
112
+ };
113
+ },
114
+ getSnapshot: () => this._viewState,
115
+ },
116
+ widgetState: {
117
+ subscribe: (onChange) => {
118
+ this.widgetStateListeners.add(onChange);
119
+ return () => {
120
+ this.widgetStateListeners.delete(onChange);
121
+ };
122
+ },
123
+ getSnapshot: () => this._widgetState,
124
+ },
125
+ };
126
+ }
127
+ setWidgetState = async (stateOrUpdater) => {
128
+ const newState = typeof stateOrUpdater === "function"
129
+ ? stateOrUpdater(this._widgetState)
130
+ : stateOrUpdater;
131
+ const bridge = McpAppBridge.getInstance();
132
+ await bridge.request({
133
+ method: "ui/update-model-context",
134
+ params: {
135
+ structuredContent: newState,
136
+ content: [{ type: "text", text: JSON.stringify(newState) }],
137
+ },
138
+ });
139
+ this._widgetState = newState;
140
+ this.widgetStateListeners.forEach((listener) => {
141
+ listener();
142
+ });
143
+ };
144
+ /**
145
+ * @throws File upload is not supported in MCP App.
146
+ */
147
+ uploadFile() {
148
+ throw new Error("File upload is not supported in MCP App.");
149
+ }
150
+ /**
151
+ * @throws File download is not supported in MCP App.
152
+ */
153
+ getFileDownloadUrl() {
154
+ throw new Error("File download is not supported in MCP App.");
155
+ }
156
+ openModal(options) {
157
+ this._viewState = { mode: "modal", params: options.params };
158
+ this.viewListeners.forEach((listener) => {
159
+ listener();
160
+ });
161
+ }
162
+ closeModal() {
163
+ this._viewState = { mode: "inline" };
164
+ this.viewListeners.forEach((listener) => {
165
+ listener();
166
+ });
167
+ }
168
+ setOpenInAppUrl(_href) {
169
+ throw new Error("setOpenInAppUrl is not implemented in MCP App.");
170
+ }
171
+ createHostContextStore(keys, computeSnapshot) {
172
+ const bridge = McpAppBridge.getInstance();
173
+ let cachedValue;
174
+ return {
175
+ subscribe: bridge.subscribe(keys),
176
+ getSnapshot: () => {
177
+ const context = Object.fromEntries(keys.map((k) => [k, bridge.getSnapshot(k)]));
178
+ const newValue = computeSnapshot(context);
179
+ if (cachedValue !== undefined && dequal(cachedValue, newValue)) {
180
+ return cachedValue;
181
+ }
182
+ cachedValue = newValue;
183
+ return newValue;
184
+ },
185
+ };
186
+ }
187
+ }
188
+ //# sourceMappingURL=adaptor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adaptor.js","sourceRoot":"","sources":["../../../../src/web/bridges/mcp-app/adaptor.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAUrC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAO3C,MAAM,OAAO,aAAa;IAChB,MAAM,CAAC,QAAQ,GAAyB,IAAI,CAAC;IAC7C,MAAM,CAEZ;IACM,YAAY,GAA+B,IAAI,CAAC;IAChD,oBAAoB,GAAG,IAAI,GAAG,EAAc,CAAC;IAE7C,UAAU,GAAwB;QACxC,IAAI,EAAE,QAAQ;KACf,CAAC;IACM,aAAa,GAAG,IAAI,GAAG,EAAc,CAAC;IAE9C;QACE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;IACxC,CAAC;IAEM,MAAM,CAAC,WAAW;QACvB,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC;YAC5B,aAAa,CAAC,QAAQ,GAA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Ae,CAAC,OAAO,CAAC,CAAC;gBAE1C,IAAI,WAAW,KAAK,SAAS,IAAI,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,EAAE,CAAC;oBAC/D,OAAO,WAAW,CAAC;gBACrB,CAAC;gBAED,WAAW,GAAG,QAAQ,CAAC;gBACvB,OAAO,QAAQ,CAAC;YAClB,CAAC;SACF,CAAC;IACJ,CAAC"}
@@ -0,0 +1,43 @@
1
+ import type { McpUiHostContext, McpUiInitializeRequest } from "@modelcontextprotocol/ext-apps";
2
+ import type { Bridge, Subscribe } from "../types.js";
3
+ import type { McpAppContext, McpAppContextKey } from "./types.js";
4
+ type McpAppInitializationOptions = Pick<McpUiInitializeRequest["params"], "appInfo">;
5
+ export declare class McpAppBridge implements Bridge<McpUiHostContext> {
6
+ private static instance;
7
+ context: McpAppContext;
8
+ private listeners;
9
+ private pendingRequests;
10
+ private nextId;
11
+ private initialized;
12
+ private appInitializationOptions;
13
+ private requestTimeout;
14
+ private cleanupSizeObserver;
15
+ constructor(options: McpAppInitializationOptions, requestTimeout?: number);
16
+ static getInstance(options?: Partial<McpAppInitializationOptions>, requestTimeout?: number): McpAppBridge;
17
+ subscribe(key: McpAppContextKey): Subscribe;
18
+ subscribe(keys: readonly McpAppContextKey[]): Subscribe;
19
+ getSnapshot<K extends keyof McpAppContext>(key: K): McpAppContext[K];
20
+ cleanup: () => void;
21
+ static resetInstance(): void;
22
+ request<R extends {
23
+ method: string;
24
+ params?: unknown;
25
+ }, T>({ method, params, }: R): Promise<T>;
26
+ private emit;
27
+ private updateContext;
28
+ private init;
29
+ private handleMessage;
30
+ private handleResponse;
31
+ private handleNotification;
32
+ private handleRequest;
33
+ private connect;
34
+ private notify;
35
+ private sendSizeChanged;
36
+ /**
37
+ * Set up automatic size change notifications using ResizeObserver.
38
+ * Based on @modelcontextprotocol/ext-apps App.setupSizeChangedNotifications
39
+ * @see https://github.com/modelcontextprotocol/ext-apps/blob/main/src/app.ts#L940-L989
40
+ */
41
+ private setupSizeChangedNotifications;
42
+ }
43
+ export {};
@@ -1,4 +1,12 @@
1
1
  const LATEST_PROTOCOL_VERSION = "2025-11-21";
2
+ var JsonRpcErrorCode;
3
+ (function (JsonRpcErrorCode) {
4
+ JsonRpcErrorCode[JsonRpcErrorCode["ParseError"] = -32700] = "ParseError";
5
+ JsonRpcErrorCode[JsonRpcErrorCode["InvalidRequest"] = -32600] = "InvalidRequest";
6
+ JsonRpcErrorCode[JsonRpcErrorCode["MethodNotFound"] = -32601] = "MethodNotFound";
7
+ JsonRpcErrorCode[JsonRpcErrorCode["InvalidParams"] = -32602] = "InvalidParams";
8
+ JsonRpcErrorCode[JsonRpcErrorCode["InternalError"] = -32603] = "InternalError";
9
+ })(JsonRpcErrorCode || (JsonRpcErrorCode = {}));
2
10
  export class McpAppBridge {
3
11
  static instance = null;
4
12
  context = {
@@ -12,6 +20,7 @@ export class McpAppBridge {
12
20
  initialized;
13
21
  appInitializationOptions;
14
22
  requestTimeout;
23
+ cleanupSizeObserver = null;
15
24
  constructor(options, requestTimeout = 10_000) {
16
25
  this.requestTimeout = requestTimeout;
17
26
  this.initialized = false;
@@ -20,6 +29,7 @@ export class McpAppBridge {
20
29
  appCapabilities: {},
21
30
  protocolVersion: LATEST_PROTOCOL_VERSION,
22
31
  };
32
+ this.init();
23
33
  }
24
34
  static getInstance(options, requestTimeout) {
25
35
  if (window.skybridge.hostType !== "mcp-app") {
@@ -42,7 +52,6 @@ export class McpAppBridge {
42
52
  for (const key of keys) {
43
53
  this.listeners.set(key, new Set([...(this.listeners.get(key) || []), onChange]));
44
54
  }
45
- this.init();
46
55
  return () => {
47
56
  for (const key of keys) {
48
57
  this.listeners.get(key)?.delete(onChange);
@@ -60,6 +69,8 @@ export class McpAppBridge {
60
69
  });
61
70
  this.pendingRequests.clear();
62
71
  this.listeners.clear();
72
+ this.cleanupSizeObserver?.();
73
+ this.cleanupSizeObserver = null;
63
74
  };
64
75
  static resetInstance() {
65
76
  if (McpAppBridge.instance) {
@@ -109,39 +120,70 @@ export class McpAppBridge {
109
120
  return;
110
121
  }
111
122
  if ("id" in data) {
112
- const request = this.pendingRequests.get(data.id);
113
- if (request) {
114
- clearTimeout(request.timeout);
115
- this.pendingRequests.delete(data.id);
116
- if ("error" in data) {
117
- request.reject(new Error(data.error.message));
118
- return;
119
- }
120
- request.resolve(data.result);
123
+ if ("method" in data) {
124
+ this.handleRequest(data);
125
+ return;
121
126
  }
127
+ this.handleResponse(data);
122
128
  return;
123
129
  }
124
- switch (data.method) {
130
+ this.handleNotification(data);
131
+ };
132
+ handleResponse(response) {
133
+ const request = this.pendingRequests.get(response.id);
134
+ if (request) {
135
+ clearTimeout(request.timeout);
136
+ this.pendingRequests.delete(response.id);
137
+ if ("error" in response) {
138
+ request.reject(new Error(response.error.message));
139
+ return;
140
+ }
141
+ request.resolve(response.result);
142
+ }
143
+ }
144
+ handleNotification = (notification) => {
145
+ switch (notification.method) {
125
146
  case "ui/notifications/host-context-changed":
126
- this.updateContext(data.params);
147
+ this.updateContext(notification.params);
127
148
  return;
128
149
  case "ui/notifications/tool-input":
129
150
  this.updateContext({
130
- toolInput: data.params.arguments ?? {},
151
+ toolInput: notification.params.arguments ?? {},
131
152
  });
132
153
  return;
133
154
  case "ui/notifications/tool-result":
134
155
  this.updateContext({
135
- toolResult: data.params,
156
+ toolResult: notification.params,
136
157
  });
137
158
  return;
138
159
  case "ui/notifications/tool-cancelled":
139
160
  this.updateContext({
140
- toolCancelled: data.params,
161
+ toolCancelled: notification.params,
141
162
  });
142
163
  return;
143
164
  }
144
165
  };
166
+ handleRequest = (request) => {
167
+ switch (request.method) {
168
+ case "ui/resource-teardown":
169
+ this.cleanup();
170
+ window.parent.postMessage({
171
+ jsonrpc: "2.0",
172
+ id: request.id,
173
+ result: {},
174
+ }, "*");
175
+ return;
176
+ default:
177
+ window.parent.postMessage({
178
+ jsonrpc: "2.0",
179
+ id: request.id,
180
+ error: {
181
+ code: JsonRpcErrorCode.MethodNotFound,
182
+ message: "Unsupported Request",
183
+ },
184
+ }, "*");
185
+ }
186
+ };
145
187
  async connect() {
146
188
  try {
147
189
  const result = await this.request({
@@ -150,6 +192,7 @@ export class McpAppBridge {
150
192
  });
151
193
  this.updateContext(result.hostContext);
152
194
  this.notify({ method: "ui/notifications/initialized" });
195
+ this.cleanupSizeObserver = this.setupSizeChangedNotifications();
153
196
  }
154
197
  catch (err) {
155
198
  console.error(err);
@@ -158,5 +201,55 @@ export class McpAppBridge {
158
201
  notify(notification) {
159
202
  window.parent.postMessage({ jsonrpc: "2.0", ...notification }, "*");
160
203
  }
204
+ sendSizeChanged(params) {
205
+ this.notify({ method: "ui/notifications/size-changed", params });
206
+ }
207
+ /**
208
+ * Set up automatic size change notifications using ResizeObserver.
209
+ * Based on @modelcontextprotocol/ext-apps App.setupSizeChangedNotifications
210
+ * @see https://github.com/modelcontextprotocol/ext-apps/blob/main/src/app.ts#L940-L989
211
+ */
212
+ setupSizeChangedNotifications() {
213
+ let scheduled = false;
214
+ let lastWidth = 0;
215
+ let lastHeight = 0;
216
+ const sendBodySizeChanged = () => {
217
+ if (scheduled) {
218
+ return;
219
+ }
220
+ scheduled = true;
221
+ requestAnimationFrame(() => {
222
+ scheduled = false;
223
+ let width;
224
+ let height;
225
+ // In fullscreen mode, use viewport size since the widget should fill
226
+ // the entire available space provided by the host.
227
+ if (this.context.displayMode === "fullscreen") {
228
+ width = window.innerWidth;
229
+ height = window.innerHeight;
230
+ }
231
+ else {
232
+ // Use scrollWidth/scrollHeight to measure actual rendered content size.
233
+ // This works better than fit-content for viewport-based layouts (vw/vh)
234
+ // and fluid elements like maps that want to fill available space.
235
+ const body = document.body;
236
+ width = Math.ceil(body.scrollWidth);
237
+ height = Math.ceil(body.scrollHeight);
238
+ }
239
+ // Only send if size actually changed (prevents feedback loops from
240
+ // style changes)
241
+ if (width !== lastWidth || height !== lastHeight) {
242
+ lastWidth = width;
243
+ lastHeight = height;
244
+ this.sendSizeChanged({ width, height });
245
+ }
246
+ });
247
+ };
248
+ sendBodySizeChanged();
249
+ const resizeObserver = new ResizeObserver(sendBodySizeChanged);
250
+ resizeObserver.observe(document.documentElement);
251
+ resizeObserver.observe(document.body);
252
+ return () => resizeObserver.disconnect();
253
+ }
161
254
  }
162
- //# sourceMappingURL=mcp-app-bridge.js.map
255
+ //# sourceMappingURL=bridge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridge.js","sourceRoot":"","sources":["../../../../src/web/bridges/mcp-app/bridge.ts"],"names":[],"mappings":"AA2BA,MAAM,uBAAuB,GAAG,YAAY,CAAC;AAE7C,IAAK,gBAMJ;AAND,WAAK,gBAAgB;IACnB,wEAAmB,CAAA;IACnB,gFAAuB,CAAA;IACvB,gFAAuB,CAAA;IACvB,8EAAsB,CAAA;IACtB,8EAAsB,CAAA;AACxB,CAAC,EANI,gBAAgB,KAAhB,gBAAgB,QAMpB;AA0BD,MAAM,OAAO,YAAY;IACf,MAAM,CAAC,QAAQ,GAAwB,IAAI,CAAC;IAC7C,OAAO,GAAkB;QAC9B,SAAS,EAAE,IAAI;QACf,aAAa,EAAE,IAAI;QACnB,UAAU,EAAE,IAAI;KACjB,CAAC;IACM,SAAS,GAAG,IAAI,GAAG,EAAqC,CAAC;IACzD,eAAe,GAAG,IAAI,GAAG,EAA4C,CAAC;IACtE,MAAM,GAAG,CAAC,CAAC;IACX,WAAW,CAAU;IACrB,wBAAwB,CAAmC;IAC3D,cAAc,CAAS;IACvB,mBAAmB,GAAwB,IAAI,CAAC;IAExD,YACE,OAAoC,EACpC,iBAAyB,MAAM;QAE/B,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;QACzB,IAAI,CAAC,wBAAwB,GAAG;YAC9B,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,eAAe,EAAE,EAAE;YACnB,eAAe,EAAE,uBAAuB;SACzC,CAAC;QACF,IAAI,CAAC,IAAI,EAAE,CAAC;IACd,CAAC;I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AAC;oBACjD,SAAS,GAAG,KAAK,CAAC;oBAClB,UAAU,GAAG,MAAM,CAAC;oBACpB,IAAI,CAAC,eAAe,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;gBAC1C,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,mBAAmB,EAAE,CAAC;QAEtB,MAAM,cAAc,GAAG,IAAI,cAAc,CAAC,mBAAmB,CAAC,CAAC;QAC/D,cAAc,CAAC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;QACjD,cAAc,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAEtC,OAAO,GAAG,EAAE,CAAC,cAAc,CAAC,UAAU,EAAE,CAAC;IAC3C,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { McpAppAdaptor } from "./adaptor.js";
2
+ export { McpAppBridge } from "./bridge.js";
3
+ export type { McpAppContext, McpAppContextKey, McpToolState, } from "./types.js";
4
+ export { useMcpAppContext } from "./use-mcp-app-context.js";
@@ -0,0 +1,4 @@
1
+ export { McpAppAdaptor } from "./adaptor.js";
2
+ export { McpAppBridge } from "./bridge.js";
3
+ export { useMcpAppContext } from "./use-mcp-app-context.js";
4
+ //# 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,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAM3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { McpUiHostContext, McpUiToolCancelledNotification, McpUiToolInputNotification, McpUiToolResultNotification } from "@modelcontextprotocol/ext-apps";
2
+ export type McpToolState = {
3
+ toolInput: NonNullable<McpUiToolInputNotification["params"]["arguments"]> | null;
4
+ toolResult: McpUiToolResultNotification["params"] | null;
5
+ toolCancelled: McpUiToolCancelledNotification["params"] | null;
6
+ };
7
+ export type McpAppContext = McpUiHostContext & McpToolState;
8
+ export type McpAppContextKey = keyof McpAppContext;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/web/bridges/mcp-app/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ import type { McpUiInitializeRequest } from "@modelcontextprotocol/ext-apps";
2
+ import type { McpAppContext } from "./types.js";
3
+ type McpAppInitializationOptions = Pick<McpUiInitializeRequest["params"], "appInfo">;
4
+ export declare function useMcpAppContext<K extends keyof McpAppContext>(key: K, options?: Partial<McpAppInitializationOptions>, requestTimeout?: number): McpAppContext[K];
5
+ export {};
@@ -1,7 +1,7 @@
1
1
  import { useSyncExternalStore } from "react";
2
- import { McpAppBridge } from "../mcp-app-bridge.js";
3
- export function useMcpAppBridge(key, options, requestTimeout) {
2
+ import { McpAppBridge } from "./bridge.js";
3
+ export function useMcpAppContext(key, options, requestTimeout) {
4
4
  const bridge = McpAppBridge.getInstance(options, requestTimeout);
5
5
  return useSyncExternalStore(bridge.subscribe(key), () => bridge.getSnapshot(key));
6
6
  }
7
- //# sourceMappingURL=use-mcp-app-bridge.js.map
7
+ //# 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;AAQ3C,MAAM,UAAU,gBAAgB,CAC9B,GAAM,EACN,OAA8C,EAC9C,cAAuB;IAEvB,MAAM,MAAM,GAAG,YAAY,CAAC,WAAW,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IACjE,OAAO,oBAAoB,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CACtD,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CACxB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,66 @@
1
+ import { act, 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", { hostType: "mcp-app" });
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
+ it("should reject the request after timeout", async () => {
26
+ vi.useFakeTimers();
27
+ const consoleErrorSpy = vi
28
+ .spyOn(console, "error")
29
+ .mockImplementation(() => { });
30
+ const nonRespondingMock = vi.fn();
31
+ vi.stubGlobal("parent", { postMessage: nonRespondingMock });
32
+ renderHook(() => useMcpAppContext("theme", undefined, 100));
33
+ expect(nonRespondingMock).toHaveBeenCalledWith(expect.objectContaining({ method: "ui/initialize" }), "*");
34
+ await act(async () => {
35
+ await vi.advanceTimersByTimeAsync(100);
36
+ });
37
+ expect(consoleErrorSpy).toHaveBeenCalledWith(new Error("Request timed out"));
38
+ consoleErrorSpy.mockRestore();
39
+ vi.useRealTimers();
40
+ });
41
+ it("should send size-changed notification after successful initialization", async () => {
42
+ // Mock body dimensions to non-zero (size-changed only sends when dimensions change)
43
+ Object.defineProperty(document.body, "scrollWidth", {
44
+ value: 800,
45
+ configurable: true,
46
+ });
47
+ Object.defineProperty(document.body, "scrollHeight", {
48
+ value: 600,
49
+ configurable: true,
50
+ });
51
+ const postMessageMock = getMcpAppHostPostMessageMock({ theme: "light" });
52
+ vi.stubGlobal("parent", { postMessage: postMessageMock });
53
+ renderHook(() => useMcpAppContext("theme"));
54
+ await waitFor(() => {
55
+ expect(postMessageMock).toHaveBeenCalledWith(expect.objectContaining({
56
+ jsonrpc: "2.0",
57
+ method: "ui/notifications/size-changed",
58
+ params: expect.objectContaining({
59
+ width: expect.any(Number),
60
+ height: expect.any(Number),
61
+ }),
62
+ }), "*");
63
+ });
64
+ });
65
+ });
66
+ //# 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,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAClE,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,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC;QACpD,EAAE,CAAC,UAAU,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,CAAC;QACpD,YAAY,CAAC,aAAa,EAAE,CAAC;IAC/B,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