skybridge 0.0.0-dev.cc48d14 → 0.0.0-dev.cd1bd15

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 (268) hide show
  1. package/LICENSE +21 -0
  2. package/bin/run.js +5 -0
  3. package/dist/{src/server → server}/index.d.ts +0 -1
  4. package/dist/{src/server → server}/index.js +0 -1
  5. package/dist/server/index.js.map +1 -0
  6. package/dist/server/inferUtilityTypes.js.map +1 -0
  7. package/dist/{src/server → server}/server.d.ts +28 -1
  8. package/dist/server/server.js +130 -0
  9. package/dist/server/server.js.map +1 -0
  10. package/dist/server/templateHelper.js.map +1 -0
  11. package/dist/server/templates/development.hbs +66 -0
  12. package/dist/{src/server → server}/widgetsDevServer.d.ts +2 -2
  13. package/dist/{src/server → server}/widgetsDevServer.js +11 -3
  14. package/dist/server/widgetsDevServer.js.map +1 -0
  15. package/dist/test/utils.js.map +1 -0
  16. package/dist/{src/test → test}/widget.test.js +116 -12
  17. package/dist/test/widget.test.js.map +1 -0
  18. package/dist/web/bridges/adaptors/apps-sdk-adaptor.d.ts +13 -0
  19. package/dist/web/bridges/adaptors/apps-sdk-adaptor.js +33 -0
  20. package/dist/web/bridges/adaptors/apps-sdk-adaptor.js.map +1 -0
  21. package/dist/web/bridges/adaptors/mcp-app-adaptor.d.ts +16 -0
  22. package/dist/web/bridges/adaptors/mcp-app-adaptor.js +115 -0
  23. package/dist/web/bridges/adaptors/mcp-app-adaptor.js.map +1 -0
  24. package/dist/{src/web → web}/bridges/apps-sdk-bridge.d.ts +4 -2
  25. package/dist/{src/web → web}/bridges/apps-sdk-bridge.js +19 -14
  26. package/dist/web/bridges/apps-sdk-bridge.js.map +1 -0
  27. package/dist/web/bridges/hooks/use-adaptor.d.ts +2 -0
  28. package/dist/web/bridges/hooks/use-adaptor.js +8 -0
  29. package/dist/web/bridges/hooks/use-adaptor.js.map +1 -0
  30. package/dist/web/bridges/hooks/use-apps-sdk-bridge.js.map +1 -0
  31. package/dist/{src/web → web}/bridges/hooks/use-bridge.d.ts +1 -1
  32. package/dist/web/bridges/hooks/use-bridge.js +8 -0
  33. package/dist/web/bridges/hooks/use-bridge.js.map +1 -0
  34. package/dist/web/bridges/hooks/use-mcp-app-bridge.d.ts +5 -0
  35. package/dist/{src/web → web}/bridges/hooks/use-mcp-app-bridge.js +1 -1
  36. package/dist/web/bridges/hooks/use-mcp-app-bridge.js.map +1 -0
  37. package/dist/web/bridges/hooks/use-mcp-app-bridge.test.js +62 -0
  38. package/dist/web/bridges/hooks/use-mcp-app-bridge.test.js.map +1 -0
  39. package/dist/{src/web → web}/bridges/index.d.ts +1 -1
  40. package/dist/{src/web → web}/bridges/index.js +1 -1
  41. package/dist/web/bridges/index.js.map +1 -0
  42. package/dist/web/bridges/mcp-app-bridge.d.ts +46 -0
  43. package/dist/web/bridges/mcp-app-bridge.js +217 -0
  44. package/dist/web/bridges/mcp-app-bridge.js.map +1 -0
  45. package/dist/web/bridges/types.d.ts +57 -0
  46. package/dist/{src/web → web}/bridges/types.js.map +1 -1
  47. package/dist/web/create-store.js.map +1 -0
  48. package/dist/web/create-store.test.js.map +1 -0
  49. package/dist/{src/web → web}/data-llm.js +4 -2
  50. package/dist/web/data-llm.js.map +1 -0
  51. package/dist/web/data-llm.test.js.map +1 -0
  52. package/dist/web/generate-helpers.js.map +1 -0
  53. package/dist/{src/web → web}/generate-helpers.test-d.js +4 -1
  54. package/dist/web/generate-helpers.test-d.js.map +1 -0
  55. package/dist/web/generate-helpers.test.js.map +1 -0
  56. package/dist/web/helpers/state.js.map +1 -0
  57. package/dist/web/helpers/state.test.js.map +1 -0
  58. package/dist/web/hooks/index.js.map +1 -0
  59. package/dist/web/hooks/test/utils.d.ts +10 -0
  60. package/dist/web/hooks/test/utils.js +40 -0
  61. package/dist/web/hooks/test/utils.js.map +1 -0
  62. package/dist/{src/web → web}/hooks/use-call-tool.d.ts +1 -1
  63. package/dist/{src/web → web}/hooks/use-call-tool.js +12 -4
  64. package/dist/web/hooks/use-call-tool.js.map +1 -0
  65. package/dist/{src/web → web}/hooks/use-call-tool.test-d.js +1 -1
  66. package/dist/web/hooks/use-call-tool.test-d.js.map +1 -0
  67. package/dist/{src/web → web}/hooks/use-call-tool.test.js +28 -3
  68. package/dist/web/hooks/use-call-tool.test.js.map +1 -0
  69. package/dist/web/hooks/use-display-mode.d.ts +4 -0
  70. package/dist/web/hooks/use-display-mode.js +10 -0
  71. package/dist/web/hooks/use-display-mode.js.map +1 -0
  72. package/dist/web/hooks/use-display-mode.test.js.map +1 -0
  73. package/dist/web/hooks/use-files.js.map +1 -0
  74. package/dist/web/hooks/use-files.test.js.map +1 -0
  75. package/dist/web/hooks/use-layout.js.map +1 -0
  76. package/dist/web/hooks/use-layout.test.js +95 -0
  77. package/dist/web/hooks/use-layout.test.js.map +1 -0
  78. package/dist/web/hooks/use-open-external.js +8 -0
  79. package/dist/web/hooks/use-open-external.js.map +1 -0
  80. package/dist/web/hooks/use-open-external.test.js +50 -0
  81. package/dist/web/hooks/use-open-external.test.js.map +1 -0
  82. package/dist/web/hooks/use-openai-global.js.map +1 -0
  83. package/dist/web/hooks/use-request-modal.js.map +1 -0
  84. package/dist/web/hooks/use-request-modal.test.js.map +1 -0
  85. package/dist/web/hooks/use-send-follow-up-message.js +8 -0
  86. package/dist/web/hooks/use-send-follow-up-message.js.map +1 -0
  87. package/dist/{src/web → web}/hooks/use-tool-info.d.ts +12 -1
  88. package/dist/web/hooks/use-tool-info.js +26 -0
  89. package/dist/web/hooks/use-tool-info.js.map +1 -0
  90. package/dist/{src/web → web}/hooks/use-tool-info.test-d.js +40 -4
  91. package/dist/web/hooks/use-tool-info.test-d.js.map +1 -0
  92. package/dist/web/hooks/use-tool-info.test.js +130 -0
  93. package/dist/web/hooks/use-tool-info.test.js.map +1 -0
  94. package/dist/{src/web → web}/hooks/use-user.js +2 -2
  95. package/dist/web/hooks/use-user.js.map +1 -0
  96. package/dist/web/hooks/use-user.test.js +93 -0
  97. package/dist/web/hooks/use-user.test.js.map +1 -0
  98. package/dist/web/hooks/use-widget-state.js.map +1 -0
  99. package/dist/web/hooks/use-widget-state.test.js.map +1 -0
  100. package/dist/web/index.js.map +1 -0
  101. package/dist/web/mount-widget.js.map +1 -0
  102. package/dist/web/plugin/data-llm.test.js.map +1 -0
  103. package/dist/web/plugin/plugin.js.map +1 -0
  104. package/dist/{src/web → web}/plugin/transform-data-llm.js +6 -3
  105. package/dist/web/plugin/transform-data-llm.js.map +1 -0
  106. package/dist/web/plugin/transform-data-llm.test.js.map +1 -0
  107. package/dist/web/proxy.js.map +1 -0
  108. package/dist/{src/web → web}/types.d.ts +3 -5
  109. package/dist/web/types.js.map +1 -0
  110. package/package.json +43 -30
  111. package/dist/src/server/devtoolsStaticServer.d.ts +0 -15
  112. package/dist/src/server/devtoolsStaticServer.js +0 -38
  113. package/dist/src/server/devtoolsStaticServer.js.map +0 -1
  114. package/dist/src/server/index.js.map +0 -1
  115. package/dist/src/server/inferUtilityTypes.js.map +0 -1
  116. package/dist/src/server/server.js +0 -82
  117. package/dist/src/server/server.js.map +0 -1
  118. package/dist/src/server/templateHelper.js.map +0 -1
  119. package/dist/src/server/templates/development.hbs +0 -13
  120. package/dist/src/server/widgetsDevServer.js.map +0 -1
  121. package/dist/src/test/utils.js.map +0 -1
  122. package/dist/src/test/widget.test.js.map +0 -1
  123. package/dist/src/web/bridges/apps-sdk-adapter.d.ts +0 -2
  124. package/dist/src/web/bridges/apps-sdk-adapter.js +0 -4
  125. package/dist/src/web/bridges/apps-sdk-adapter.js.map +0 -1
  126. package/dist/src/web/bridges/apps-sdk-bridge.js.map +0 -1
  127. package/dist/src/web/bridges/get-bridge-methods.d.ts +0 -2
  128. package/dist/src/web/bridges/get-bridge-methods.js +0 -8
  129. package/dist/src/web/bridges/get-bridge-methods.js.map +0 -1
  130. package/dist/src/web/bridges/hooks/use-apps-sdk-bridge.js.map +0 -1
  131. package/dist/src/web/bridges/hooks/use-bridge.js +0 -61
  132. package/dist/src/web/bridges/hooks/use-bridge.js.map +0 -1
  133. package/dist/src/web/bridges/hooks/use-mcp-app-bridge.d.ts +0 -4
  134. package/dist/src/web/bridges/hooks/use-mcp-app-bridge.js.map +0 -1
  135. package/dist/src/web/bridges/hooks/use-mcp-app-bridge.test.js +0 -58
  136. package/dist/src/web/bridges/hooks/use-mcp-app-bridge.test.js.map +0 -1
  137. package/dist/src/web/bridges/index.js.map +0 -1
  138. package/dist/src/web/bridges/mcp-app-adapter.d.ts +0 -2
  139. package/dist/src/web/bridges/mcp-app-adapter.js +0 -12
  140. package/dist/src/web/bridges/mcp-app-adapter.js.map +0 -1
  141. package/dist/src/web/bridges/mcp-app-bridge.d.ts +0 -29
  142. package/dist/src/web/bridges/mcp-app-bridge.js +0 -130
  143. package/dist/src/web/bridges/mcp-app-bridge.js.map +0 -1
  144. package/dist/src/web/bridges/types.d.ts +0 -22
  145. package/dist/src/web/create-store.js.map +0 -1
  146. package/dist/src/web/create-store.test.js.map +0 -1
  147. package/dist/src/web/data-llm.js.map +0 -1
  148. package/dist/src/web/data-llm.test.js.map +0 -1
  149. package/dist/src/web/generate-helpers.js.map +0 -1
  150. package/dist/src/web/generate-helpers.test-d.js.map +0 -1
  151. package/dist/src/web/generate-helpers.test.js.map +0 -1
  152. package/dist/src/web/helpers/state.js.map +0 -1
  153. package/dist/src/web/helpers/state.test.js.map +0 -1
  154. package/dist/src/web/hooks/index.js.map +0 -1
  155. package/dist/src/web/hooks/use-call-tool.js.map +0 -1
  156. package/dist/src/web/hooks/use-call-tool.test-d.js.map +0 -1
  157. package/dist/src/web/hooks/use-call-tool.test.js.map +0 -1
  158. package/dist/src/web/hooks/use-display-mode.d.ts +0 -4
  159. package/dist/src/web/hooks/use-display-mode.js +0 -10
  160. package/dist/src/web/hooks/use-display-mode.js.map +0 -1
  161. package/dist/src/web/hooks/use-display-mode.test.js.map +0 -1
  162. package/dist/src/web/hooks/use-files.js.map +0 -1
  163. package/dist/src/web/hooks/use-files.test.js.map +0 -1
  164. package/dist/src/web/hooks/use-layout.js.map +0 -1
  165. package/dist/src/web/hooks/use-layout.test.js +0 -46
  166. package/dist/src/web/hooks/use-layout.test.js.map +0 -1
  167. package/dist/src/web/hooks/use-open-external.js +0 -6
  168. package/dist/src/web/hooks/use-open-external.js.map +0 -1
  169. package/dist/src/web/hooks/use-open-external.test.js +0 -24
  170. package/dist/src/web/hooks/use-open-external.test.js.map +0 -1
  171. package/dist/src/web/hooks/use-openai-global.js.map +0 -1
  172. package/dist/src/web/hooks/use-request-modal.js.map +0 -1
  173. package/dist/src/web/hooks/use-request-modal.test.js.map +0 -1
  174. package/dist/src/web/hooks/use-send-follow-up-message.js +0 -11
  175. package/dist/src/web/hooks/use-send-follow-up-message.js.map +0 -1
  176. package/dist/src/web/hooks/use-tool-info.js +0 -20
  177. package/dist/src/web/hooks/use-tool-info.js.map +0 -1
  178. package/dist/src/web/hooks/use-tool-info.test-d.js.map +0 -1
  179. package/dist/src/web/hooks/use-tool-info.test.js +0 -60
  180. package/dist/src/web/hooks/use-tool-info.test.js.map +0 -1
  181. package/dist/src/web/hooks/use-user.js.map +0 -1
  182. package/dist/src/web/hooks/use-user.test.js +0 -44
  183. package/dist/src/web/hooks/use-user.test.js.map +0 -1
  184. package/dist/src/web/hooks/use-widget-state.js.map +0 -1
  185. package/dist/src/web/hooks/use-widget-state.test.js.map +0 -1
  186. package/dist/src/web/index.js.map +0 -1
  187. package/dist/src/web/mount-widget.js.map +0 -1
  188. package/dist/src/web/plugin/data-llm.test.js.map +0 -1
  189. package/dist/src/web/plugin/plugin.js.map +0 -1
  190. package/dist/src/web/plugin/transform-data-llm.js.map +0 -1
  191. package/dist/src/web/plugin/transform-data-llm.test.js.map +0 -1
  192. package/dist/src/web/proxy.js.map +0 -1
  193. package/dist/src/web/types.js.map +0 -1
  194. package/dist/vitest.config.d.ts +0 -2
  195. package/dist/vitest.config.js +0 -8
  196. package/dist/vitest.config.js.map +0 -1
  197. /package/dist/{src/server → server}/inferUtilityTypes.d.ts +0 -0
  198. /package/dist/{src/server → server}/inferUtilityTypes.js +0 -0
  199. /package/dist/{src/server → server}/templateHelper.d.ts +0 -0
  200. /package/dist/{src/server → server}/templateHelper.js +0 -0
  201. /package/dist/{src/server → server}/templates/production.hbs +0 -0
  202. /package/dist/{src/test → test}/utils.d.ts +0 -0
  203. /package/dist/{src/test → test}/utils.js +0 -0
  204. /package/dist/{src/test → test}/widget.test.d.ts +0 -0
  205. /package/dist/{src/web → web}/bridges/hooks/use-apps-sdk-bridge.d.ts +0 -0
  206. /package/dist/{src/web → web}/bridges/hooks/use-apps-sdk-bridge.js +0 -0
  207. /package/dist/{src/web → web}/bridges/hooks/use-mcp-app-bridge.test.d.ts +0 -0
  208. /package/dist/{src/web → web}/bridges/types.js +0 -0
  209. /package/dist/{src/web → web}/create-store.d.ts +0 -0
  210. /package/dist/{src/web → web}/create-store.js +0 -0
  211. /package/dist/{src/web → web}/create-store.test.d.ts +0 -0
  212. /package/dist/{src/web → web}/create-store.test.js +0 -0
  213. /package/dist/{src/web → web}/data-llm.d.ts +0 -0
  214. /package/dist/{src/web → web}/data-llm.test.d.ts +0 -0
  215. /package/dist/{src/web → web}/data-llm.test.js +0 -0
  216. /package/dist/{src/web → web}/generate-helpers.d.ts +0 -0
  217. /package/dist/{src/web → web}/generate-helpers.js +0 -0
  218. /package/dist/{src/web → web}/generate-helpers.test-d.d.ts +0 -0
  219. /package/dist/{src/web → web}/generate-helpers.test.d.ts +0 -0
  220. /package/dist/{src/web → web}/generate-helpers.test.js +0 -0
  221. /package/dist/{src/web → web}/helpers/state.d.ts +0 -0
  222. /package/dist/{src/web → web}/helpers/state.js +0 -0
  223. /package/dist/{src/web → web}/helpers/state.test.d.ts +0 -0
  224. /package/dist/{src/web → web}/helpers/state.test.js +0 -0
  225. /package/dist/{src/web → web}/hooks/index.d.ts +0 -0
  226. /package/dist/{src/web → web}/hooks/index.js +0 -0
  227. /package/dist/{src/web → web}/hooks/use-call-tool.test-d.d.ts +0 -0
  228. /package/dist/{src/web → web}/hooks/use-call-tool.test.d.ts +0 -0
  229. /package/dist/{src/web → web}/hooks/use-display-mode.test.d.ts +0 -0
  230. /package/dist/{src/web → web}/hooks/use-display-mode.test.js +0 -0
  231. /package/dist/{src/web → web}/hooks/use-files.d.ts +0 -0
  232. /package/dist/{src/web → web}/hooks/use-files.js +0 -0
  233. /package/dist/{src/web → web}/hooks/use-files.test.d.ts +0 -0
  234. /package/dist/{src/web → web}/hooks/use-files.test.js +0 -0
  235. /package/dist/{src/web → web}/hooks/use-layout.d.ts +0 -0
  236. /package/dist/{src/web → web}/hooks/use-layout.js +0 -0
  237. /package/dist/{src/web → web}/hooks/use-layout.test.d.ts +0 -0
  238. /package/dist/{src/web → web}/hooks/use-open-external.d.ts +0 -0
  239. /package/dist/{src/web → web}/hooks/use-open-external.test.d.ts +0 -0
  240. /package/dist/{src/web → web}/hooks/use-openai-global.d.ts +0 -0
  241. /package/dist/{src/web → web}/hooks/use-openai-global.js +0 -0
  242. /package/dist/{src/web → web}/hooks/use-request-modal.d.ts +0 -0
  243. /package/dist/{src/web → web}/hooks/use-request-modal.js +0 -0
  244. /package/dist/{src/web → web}/hooks/use-request-modal.test.d.ts +0 -0
  245. /package/dist/{src/web → web}/hooks/use-request-modal.test.js +0 -0
  246. /package/dist/{src/web → web}/hooks/use-send-follow-up-message.d.ts +0 -0
  247. /package/dist/{src/web → web}/hooks/use-tool-info.test-d.d.ts +0 -0
  248. /package/dist/{src/web → web}/hooks/use-tool-info.test.d.ts +0 -0
  249. /package/dist/{src/web → web}/hooks/use-user.d.ts +0 -0
  250. /package/dist/{src/web → web}/hooks/use-user.test.d.ts +0 -0
  251. /package/dist/{src/web → web}/hooks/use-widget-state.d.ts +0 -0
  252. /package/dist/{src/web → web}/hooks/use-widget-state.js +0 -0
  253. /package/dist/{src/web → web}/hooks/use-widget-state.test.d.ts +0 -0
  254. /package/dist/{src/web → web}/hooks/use-widget-state.test.js +0 -0
  255. /package/dist/{src/web → web}/index.d.ts +0 -0
  256. /package/dist/{src/web → web}/index.js +0 -0
  257. /package/dist/{src/web → web}/mount-widget.d.ts +0 -0
  258. /package/dist/{src/web → web}/mount-widget.js +0 -0
  259. /package/dist/{src/web → web}/plugin/data-llm.test.d.ts +0 -0
  260. /package/dist/{src/web → web}/plugin/data-llm.test.js +0 -0
  261. /package/dist/{src/web → web}/plugin/plugin.d.ts +0 -0
  262. /package/dist/{src/web → web}/plugin/plugin.js +0 -0
  263. /package/dist/{src/web → web}/plugin/transform-data-llm.d.ts +0 -0
  264. /package/dist/{src/web → web}/plugin/transform-data-llm.test.d.ts +0 -0
  265. /package/dist/{src/web → web}/plugin/transform-data-llm.test.js +0 -0
  266. /package/dist/{src/web → web}/proxy.d.ts +0 -0
  267. /package/dist/{src/web → web}/proxy.js +0 -0
  268. /package/dist/{src/web → web}/types.js +0 -0
@@ -0,0 +1,16 @@
1
+ import type { McpUiRequestDisplayModeResult } from "@modelcontextprotocol/ext-apps";
2
+ import type { Adaptor, BridgeInterface, CallToolResponse, DisplayMode, ExternalStore } from "../types.js";
3
+ export declare class McpAppAdaptor implements Adaptor {
4
+ private static instance;
5
+ private stores;
6
+ private constructor();
7
+ static getInstance(): McpAppAdaptor;
8
+ static resetInstance(): void;
9
+ getExternalStore<K extends keyof BridgeInterface>(key: K): ExternalStore<K>;
10
+ callTool: <ToolArgs extends Record<string, unknown> | null = null, ToolResponse extends CallToolResponse = CallToolResponse>(name: string, args: ToolArgs) => Promise<ToolResponse>;
11
+ requestDisplayMode: (mode: DisplayMode) => Promise<McpUiRequestDisplayModeResult>;
12
+ sendFollowUpMessage: (prompt: string) => Promise<void>;
13
+ openExternal(href: string): void;
14
+ private initializeStores;
15
+ private createExternalStore;
16
+ }
@@ -0,0 +1,115 @@
1
+ import { dequal } from "dequal/lite";
2
+ import { McpAppBridge, } from "../mcp-app-bridge.js";
3
+ export class McpAppAdaptor {
4
+ static instance = null;
5
+ stores;
6
+ constructor() {
7
+ this.stores = this.initializeStores();
8
+ }
9
+ static getInstance() {
10
+ if (!McpAppAdaptor.instance) {
11
+ McpAppAdaptor.instance = new McpAppAdaptor();
12
+ }
13
+ return McpAppAdaptor.instance;
14
+ }
15
+ static resetInstance() {
16
+ McpAppAdaptor.instance = null;
17
+ }
18
+ getExternalStore(key) {
19
+ return this.stores[key];
20
+ }
21
+ callTool = async (name, args) => {
22
+ const bridge = McpAppBridge.getInstance();
23
+ const response = await bridge.request({
24
+ method: "tools/call",
25
+ params: {
26
+ name,
27
+ arguments: args ?? undefined,
28
+ },
29
+ });
30
+ const result = response.content
31
+ .filter((content) => content.type === "text")
32
+ .map(({ text }) => text)
33
+ .join("\n");
34
+ return {
35
+ content: response.content,
36
+ structuredContent: response.structuredContent ?? {},
37
+ isError: response.isError ?? false,
38
+ result,
39
+ _meta: response._meta ?? {},
40
+ };
41
+ };
42
+ requestDisplayMode = (mode) => {
43
+ const bridge = McpAppBridge.getInstance();
44
+ if (mode !== "modal") {
45
+ return bridge.request({
46
+ method: "ui/request-display-mode",
47
+ params: { mode },
48
+ });
49
+ }
50
+ throw new Error("Modal display mode is not accessible in MCP App.");
51
+ };
52
+ sendFollowUpMessage = async (prompt) => {
53
+ const bridge = McpAppBridge.getInstance();
54
+ await bridge.request({
55
+ method: "ui/message",
56
+ params: {
57
+ role: "user",
58
+ content: [
59
+ {
60
+ type: "text",
61
+ text: prompt,
62
+ },
63
+ ],
64
+ },
65
+ });
66
+ };
67
+ openExternal(href) {
68
+ const bridge = McpAppBridge.getInstance();
69
+ bridge.request({
70
+ method: "ui/open-link",
71
+ params: { url: href },
72
+ });
73
+ }
74
+ initializeStores() {
75
+ return {
76
+ theme: this.createExternalStore(["theme"], ({ theme }) => theme ?? "light"),
77
+ locale: this.createExternalStore(["locale"], ({ locale }) => locale ?? "en-US"),
78
+ safeArea: this.createExternalStore(["safeAreaInsets"], ({ safeAreaInsets }) => ({
79
+ insets: safeAreaInsets ?? { top: 0, right: 0, bottom: 0, left: 0 },
80
+ })),
81
+ displayMode: this.createExternalStore(["displayMode"], ({ displayMode }) => displayMode ?? "inline"),
82
+ maxHeight: this.createExternalStore(["viewport"], ({ viewport }) => viewport?.maxHeight ?? window.innerHeight),
83
+ userAgent: this.createExternalStore(["platform", "deviceCapabilities"], ({ platform, deviceCapabilities }) => ({
84
+ device: {
85
+ type: platform === "web" ? "desktop" : (platform ?? "unknown"),
86
+ },
87
+ capabilities: {
88
+ hover: true,
89
+ touch: true,
90
+ ...deviceCapabilities,
91
+ },
92
+ })),
93
+ toolInput: this.createExternalStore(["toolInput"], ({ toolInput }) => toolInput ?? null),
94
+ toolOutput: this.createExternalStore(["toolResult"], ({ toolResult }) => toolResult?.structuredContent ?? null),
95
+ toolResponseMetadata: this.createExternalStore(["toolResult"], ({ toolResult }) => toolResult?._meta ?? null),
96
+ };
97
+ }
98
+ createExternalStore(keys, computeSnapshot) {
99
+ const bridge = McpAppBridge.getInstance();
100
+ let cachedValue;
101
+ return {
102
+ subscribe: bridge.subscribe(keys),
103
+ getSnapshot: () => {
104
+ const context = Object.fromEntries(keys.map((k) => [k, bridge.getSnapshot(k)]));
105
+ const newValue = computeSnapshot(context);
106
+ if (cachedValue !== undefined && dequal(cachedValue, newValue)) {
107
+ return cachedValue;
108
+ }
109
+ cachedValue = newValue;
110
+ return newValue;
111
+ },
112
+ };
113
+ }
114
+ }
115
+ //# sourceMappingURL=mcp-app-adaptor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-app-adaptor.js","sourceRoot":"","sources":["../../../../src/web/bridges/adaptors/mcp-app-adaptor.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EACL,YAAY,GAGb,MAAM,sBAAsB,CAAC;AAa9B,MAAM,OAAO,aAAa;IAChB,MAAM,CAAC,QAAQ,GAAyB,IAAI,CAAC;IAC7C,MAAM,CAEZ;IACF;QACE,IAAI,CAAC,MAAM,GAAG,IAAI,C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AAE,CAAC,UAAU,EAAE,KAAK,IAAI,IAAI,CAC9C;SACF,CAAC;IACJ,CAAC;IAEO,mBAAmB,CACzB,IAAU,EACV,eAAkD;QAElD,MAAM,MAAM,GAAG,YAAY,CAAC,WAAW,EAAE,CAAC;QAC1C,IAAI,WAA0B,CAAC;QAE/B,OAAO;YACL,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC;YACjC,WAAW,EAAE,GAAG,EAAE;gBAChB,MAAM,OAAO,GAAG,MAAM,CAAC,WAAW,CAChC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CACvB,CAAC;gBACvB,MAAM,QAAQ,GAAG,eAAe,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"}
@@ -1,8 +1,10 @@
1
1
  import { type OpenAiProperties } from "../types.js";
2
- export declare class AppsSdkBridge {
2
+ import type { Bridge, Subscribe } from "./types.js";
3
+ export declare class AppsSdkBridge implements Bridge<OpenAiProperties> {
3
4
  private static instance;
4
5
  static getInstance(): AppsSdkBridge;
5
6
  static resetInstance(): void;
6
- subscribe: (key: keyof OpenAiProperties) => (onChange: () => void) => () => void;
7
+ subscribe(key: keyof OpenAiProperties): Subscribe;
8
+ subscribe(keys: readonly (keyof OpenAiProperties)[]): Subscribe;
7
9
  getSnapshot: <K extends keyof OpenAiProperties>(key: K) => (import("../types.js").OpenAiMethods<import("../types.js").UnknownObject> & OpenAiProperties<Record<never, unknown>, import("../types.js").UnknownObject, import("../types.js").UnknownObject, import("../types.js").UnknownObject>)[K];
8
10
  }
@@ -16,21 +16,26 @@ export class AppsSdkBridge {
16
16
  AppsSdkBridge.instance = null;
17
17
  }
18
18
  }
19
- subscribe = (key) => (onChange) => {
20
- const handleSetGlobal = (event) => {
21
- const value = event.detail.globals[key];
22
- if (value === undefined) {
23
- return;
24
- }
25
- onChange();
19
+ subscribe(keyOrKeys) {
20
+ const keys = Array.isArray(keyOrKeys)
21
+ ? keyOrKeys
22
+ : [keyOrKeys];
23
+ return (onChange) => {
24
+ const handleSetGlobal = (event) => {
25
+ const hasRelevantChange = keys.some((key) => event.detail.globals[key] !== undefined);
26
+ if (!hasRelevantChange) {
27
+ return;
28
+ }
29
+ onChange();
30
+ };
31
+ window.addEventListener(SET_GLOBALS_EVENT_TYPE, handleSetGlobal, {
32
+ passive: true,
33
+ });
34
+ return () => {
35
+ window.removeEventListener(SET_GLOBALS_EVENT_TYPE, handleSetGlobal);
36
+ };
26
37
  };
27
- window.addEventListener(SET_GLOBALS_EVENT_TYPE, handleSetGlobal, {
28
- passive: true,
29
- });
30
- return () => {
31
- window.removeEventListener(SET_GLOBALS_EVENT_TYPE, handleSetGlobal);
32
- };
33
- };
38
+ }
34
39
  getSnapshot = (key) => {
35
40
  if (window.openai === undefined) {
36
41
  throw new Error(`window.openai is not available. Make sure you're calling the hook requiring ${key} within the OpenAI iFrame skybridge runtime.`);
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apps-sdk-bridge.js","sourceRoot":"","sources":["../../../src/web/bridges/apps-sdk-bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,sBAAsB,GAEvB,MAAM,aAAa,CAAC;AAGrB,MAAM,OAAO,aAAa;IAChB,MAAM,CAAC,QAAQ,GAAyB,IAAI,CAAC;IAE9C,MAAM,CAAC,WAAW;QACvB,IACE,MAAM,CAAC,SAAS,CAAC,QAAQ,KAAK,UAAU;YACxC,MAAM,CAAC,MAAM,KAAK,SAAS,EAC3B,CAAC;YACD,MAAM,IAAI,KAAK,CACb,0DAA0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;QACJ,CAAC;QAED,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { Adaptor } from "../types.js";
2
+ export declare const useAdaptor: () => Adaptor;
@@ -0,0 +1,8 @@
1
+ import { AppsSdkAdaptor } from "../adaptors/apps-sdk-adaptor.js";
2
+ import { McpAppAdaptor } from "../adaptors/mcp-app-adaptor.js";
3
+ export const useAdaptor = () => {
4
+ return window.skybridge.hostType === "apps-sdk"
5
+ ? AppsSdkAdaptor.getInstance()
6
+ : McpAppAdaptor.getInstance();
7
+ };
8
+ //# sourceMappingURL=use-adaptor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-adaptor.js","sourceRoot":"","sources":["../../../../src/web/bridges/hooks/use-adaptor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAG/D,MAAM,CAAC,MAAM,UAAU,GAAG,GAAY,EAAE;IACtC,OAAO,MAAM,CAAC,SAAS,CAAC,QAAQ,KAAK,UAAU;QAC7C,CAAC,CAAC,cAAc,CAAC,WAAW,EAAE;QAC9B,CAAC,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC;AAClC,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-apps-sdk-bridge.js","sourceRoot":"","sources":["../../../../src/web/bridges/hooks/use-apps-sdk-bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAE7C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,MAAM,UAAU,gBAAgB,CAC9B,GAAM;IAEN,MAAM,MAAM,GAAG,aAAa,CAAC,WAAW,EAAE,CAAC;IAC3C,OAAO,oBAAoB,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CACtD,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CACxB,CAAC;AACJ,CAAC"}
@@ -1,2 +1,2 @@
1
- import type { BridgeInterface } from "../types";
1
+ import type { BridgeInterface } from "../types.js";
2
2
  export declare const useBridge: <K extends keyof BridgeInterface>(key: K) => BridgeInterface[K];
@@ -0,0 +1,8 @@
1
+ import { useSyncExternalStore } from "react";
2
+ import { useAdaptor } from "./use-adaptor.js";
3
+ export const useBridge = (key) => {
4
+ const adaptor = useAdaptor();
5
+ const externalStore = adaptor.getExternalStore(key);
6
+ return useSyncExternalStore(externalStore.subscribe, externalStore.getSnapshot);
7
+ };
8
+ //# sourceMappingURL=use-bridge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-bridge.js","sourceRoot":"","sources":["../../../../src/web/bridges/hooks/use-bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAE7C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,GAAM,EACc,EAAE;IACtB,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,MAAM,aAAa,GAAG,OAAO,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;IAEpD,OAAO,oBAAoB,CACzB,aAAa,CAAC,SAAS,EACvB,aAAa,CAAC,WAAW,CAC1B,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { McpUiInitializeRequest } from "@modelcontextprotocol/ext-apps";
2
+ import { type McpAppBridgeContext } from "../mcp-app-bridge.js";
3
+ type McpAppInitializationOptions = Pick<McpUiInitializeRequest["params"], "appInfo">;
4
+ export declare function useMcpAppBridge<K extends keyof McpAppBridgeContext>(key: K, options?: Partial<McpAppInitializationOptions>, requestTimeout?: number): McpAppBridgeContext[K];
5
+ export {};
@@ -1,5 +1,5 @@
1
1
  import { useSyncExternalStore } from "react";
2
- import { McpAppBridge } from "../mcp-app-bridge";
2
+ import { McpAppBridge } from "../mcp-app-bridge.js";
3
3
  export function useMcpAppBridge(key, options, requestTimeout) {
4
4
  const bridge = McpAppBridge.getInstance(options, requestTimeout);
5
5
  return useSyncExternalStore(bridge.subscribe(key), () => bridge.getSnapshot(key));
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-mcp-app-bridge.js","sourceRoot":"","sources":["../../../../src/web/bridges/hooks/use-mcp-app-bridge.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,YAAY,EAA4B,MAAM,sBAAsB,CAAC;AAO9E,MAAM,UAAU,eAAe,CAC7B,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,62 @@
1
+ import { act, renderHook, waitFor } from "@testing-library/react";
2
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
3
+ import { getMcpAppHostPostMessageMock } from "../../hooks/test/utils.js";
4
+ import { McpAppBridge } from "../mcp-app-bridge.js";
5
+ import { useMcpAppBridge } from "./use-mcp-app-bridge.js";
6
+ class MockResizeObserver {
7
+ observe = vi.fn();
8
+ unobserve = vi.fn();
9
+ disconnect = vi.fn();
10
+ }
11
+ describe("useMcpAppBridge", () => {
12
+ beforeEach(async () => {
13
+ vi.stubGlobal("skybridge", { hostType: "mcp-app" });
14
+ vi.stubGlobal("ResizeObserver", MockResizeObserver);
15
+ McpAppBridge.resetInstance();
16
+ });
17
+ afterEach(() => {
18
+ vi.unstubAllGlobals();
19
+ vi.clearAllMocks();
20
+ });
21
+ it("should return the theme value from host context and update on notification", async () => {
22
+ vi.stubGlobal("parent", {
23
+ postMessage: getMcpAppHostPostMessageMock({ theme: "light" }),
24
+ });
25
+ const { result } = renderHook(() => useMcpAppBridge("theme"));
26
+ await waitFor(() => {
27
+ expect(result.current).toBe("light");
28
+ });
29
+ });
30
+ it("should reject the request after timeout", async () => {
31
+ vi.useFakeTimers();
32
+ const consoleErrorSpy = vi
33
+ .spyOn(console, "error")
34
+ .mockImplementation(() => { });
35
+ const nonRespondingMock = vi.fn();
36
+ vi.stubGlobal("parent", { postMessage: nonRespondingMock });
37
+ renderHook(() => useMcpAppBridge("theme", undefined, 100));
38
+ expect(nonRespondingMock).toHaveBeenCalledWith(expect.objectContaining({ method: "ui/initialize" }), "*");
39
+ await act(async () => {
40
+ await vi.advanceTimersByTimeAsync(100);
41
+ });
42
+ expect(consoleErrorSpy).toHaveBeenCalledWith(new Error("Request timed out"));
43
+ consoleErrorSpy.mockRestore();
44
+ vi.useRealTimers();
45
+ });
46
+ it("should send size-changed notification after successful initialization", async () => {
47
+ const postMessageMock = getMcpAppHostPostMessageMock({ theme: "light" });
48
+ vi.stubGlobal("parent", { postMessage: postMessageMock });
49
+ renderHook(() => useMcpAppBridge("theme"));
50
+ await waitFor(() => {
51
+ expect(postMessageMock).toHaveBeenCalledWith(expect.objectContaining({
52
+ jsonrpc: "2.0",
53
+ method: "ui/notifications/size-changed",
54
+ params: expect.objectContaining({
55
+ width: expect.any(Number),
56
+ height: expect.any(Number),
57
+ }),
58
+ }), "*");
59
+ });
60
+ });
61
+ });
62
+ //# sourceMappingURL=use-mcp-app-bridge.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-mcp-app-bridge.test.js","sourceRoot":"","sources":["../../../../src/web/bridges/hooks/use-mcp-app-bridge.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE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,CAAC,CAAC,CAAC;QAE3C,MAAM,OAAO,CAAC,GAAG,EAAE;YACjB,MAAM,CAAC,eAAe,CAAC,CAAC,oBAAoB,CAC1C,MAAM,CAAC,gBAAgB,CAAC;gBACtB,OAAO,EAAE,KAAK;gBACd,MAAM,EAAE,+BAA+B;gBACvC,MAAM,EAAE,MAAM,CAAC,gBAAgB,CAAC;oBAC9B,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC;oBACzB,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC;iBAC3B,CAAC;aACH,CAAC,EACF,GAAG,CACJ,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,4 +1,4 @@
1
- export { getBridgeMethods } from "./get-bridge-methods.js";
1
+ export { useAdaptor } from "./hooks/use-adaptor.js";
2
2
  export { useAppsSdkBridge } from "./hooks/use-apps-sdk-bridge.js";
3
3
  export { useBridge } from "./hooks/use-bridge.js";
4
4
  export { useMcpAppBridge } from "./hooks/use-mcp-app-bridge.js";
@@ -1,4 +1,4 @@
1
- export { getBridgeMethods } from "./get-bridge-methods.js";
1
+ export { useAdaptor } from "./hooks/use-adaptor.js";
2
2
  export { useAppsSdkBridge } from "./hooks/use-apps-sdk-bridge.js";
3
3
  export { useBridge } from "./hooks/use-bridge.js";
4
4
  export { useMcpAppBridge } from "./hooks/use-mcp-app-bridge.js";
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/web/bridges/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC"}
@@ -0,0 +1,46 @@
1
+ import type { McpUiHostContext, McpUiInitializeRequest, McpUiToolCancelledNotification, McpUiToolInputNotification, McpUiToolResultNotification } from "@modelcontextprotocol/ext-apps";
2
+ import type { Bridge, Subscribe } from "./types.js";
3
+ type McpAppInitializationOptions = Pick<McpUiInitializeRequest["params"], "appInfo">;
4
+ export type McpToolState = {
5
+ toolInput: NonNullable<McpUiToolInputNotification["params"]["arguments"]> | null;
6
+ toolResult: McpUiToolResultNotification["params"] | null;
7
+ toolCancelled: McpUiToolCancelledNotification["params"] | null;
8
+ };
9
+ export type McpAppBridgeContext = McpUiHostContext & McpToolState;
10
+ export type McpAppBridgeKey = keyof McpAppBridgeContext;
11
+ export declare class McpAppBridge implements Bridge<McpUiHostContext> {
12
+ private static instance;
13
+ context: McpAppBridgeContext;
14
+ private listeners;
15
+ private pendingRequests;
16
+ private nextId;
17
+ private initialized;
18
+ private appInitializationOptions;
19
+ private requestTimeout;
20
+ private cleanupSizeObserver;
21
+ constructor(options: McpAppInitializationOptions, requestTimeout?: number);
22
+ static getInstance(options?: Partial<McpAppInitializationOptions>, requestTimeout?: number): McpAppBridge;
23
+ subscribe(key: McpAppBridgeKey): Subscribe;
24
+ subscribe(keys: readonly McpAppBridgeKey[]): Subscribe;
25
+ getSnapshot<K extends keyof McpAppBridgeContext>(key: K): McpAppBridgeContext[K];
26
+ cleanup: () => void;
27
+ static resetInstance(): void;
28
+ request<R extends {
29
+ method: string;
30
+ params?: unknown;
31
+ }, T>({ method, params, }: R): Promise<T>;
32
+ private emit;
33
+ private updateContext;
34
+ private init;
35
+ private handleMessage;
36
+ private connect;
37
+ private notify;
38
+ private sendSizeChanged;
39
+ /**
40
+ * Set up automatic size change notifications using ResizeObserver.
41
+ * Based on @modelcontextprotocol/ext-apps App.setupSizeChangedNotifications
42
+ * @see https://github.com/modelcontextprotocol/ext-apps/blob/main/src/app.ts#L940-L989
43
+ */
44
+ private setupSizeChangedNotifications;
45
+ }
46
+ export {};
@@ -0,0 +1,217 @@
1
+ const LATEST_PROTOCOL_VERSION = "2025-11-21";
2
+ export class McpAppBridge {
3
+ static instance = null;
4
+ context = {
5
+ toolInput: null,
6
+ toolCancelled: null,
7
+ toolResult: null,
8
+ };
9
+ listeners = new Map();
10
+ pendingRequests = new Map();
11
+ nextId = 1;
12
+ initialized;
13
+ appInitializationOptions;
14
+ requestTimeout;
15
+ cleanupSizeObserver = null;
16
+ constructor(options, requestTimeout = 10_000) {
17
+ this.requestTimeout = requestTimeout;
18
+ this.initialized = false;
19
+ this.appInitializationOptions = {
20
+ appInfo: options.appInfo,
21
+ appCapabilities: {},
22
+ protocolVersion: LATEST_PROTOCOL_VERSION,
23
+ };
24
+ }
25
+ static getInstance(options, requestTimeout) {
26
+ if (window.skybridge.hostType !== "mcp-app") {
27
+ throw new Error("MCP App Bridge can only be used in the mcp-app runtime");
28
+ }
29
+ if (McpAppBridge.instance && (options || requestTimeout)) {
30
+ console.warn("McpAppBridge.getInstance: options and requestTimeout ignored, instance already exists");
31
+ }
32
+ if (!McpAppBridge.instance) {
33
+ const defaultOptions = {
34
+ appInfo: { name: "skybridge-app", version: "0.0.1" },
35
+ };
36
+ McpAppBridge.instance = new McpAppBridge({ ...defaultOptions, ...options }, requestTimeout);
37
+ }
38
+ return McpAppBridge.instance;
39
+ }
40
+ subscribe(keyOrKeys) {
41
+ const keys = Array.isArray(keyOrKeys) ? keyOrKeys : [keyOrKeys];
42
+ return (onChange) => {
43
+ for (const key of keys) {
44
+ this.listeners.set(key, new Set([...(this.listeners.get(key) || []), onChange]));
45
+ }
46
+ this.init();
47
+ return () => {
48
+ for (const key of keys) {
49
+ this.listeners.get(key)?.delete(onChange);
50
+ }
51
+ };
52
+ };
53
+ }
54
+ getSnapshot(key) {
55
+ return this.context[key];
56
+ }
57
+ cleanup = () => {
58
+ window.removeEventListener("message", this.handleMessage);
59
+ this.pendingRequests.forEach((request) => {
60
+ clearTimeout(request.timeout);
61
+ });
62
+ this.pendingRequests.clear();
63
+ this.listeners.clear();
64
+ this.cleanupSizeObserver?.();
65
+ this.cleanupSizeObserver = null;
66
+ };
67
+ static resetInstance() {
68
+ if (McpAppBridge.instance) {
69
+ McpAppBridge.instance.cleanup();
70
+ McpAppBridge.instance = null;
71
+ }
72
+ }
73
+ request({ method, params, }) {
74
+ const id = this.nextId++;
75
+ const { promise, resolve, reject } = Promise.withResolvers();
76
+ this.pendingRequests.set(id, {
77
+ resolve: resolve,
78
+ reject,
79
+ timeout: setTimeout(() => {
80
+ reject(new Error("Request timed out"));
81
+ this.pendingRequests.delete(id);
82
+ }, this.requestTimeout),
83
+ });
84
+ window.parent.postMessage({ jsonrpc: "2.0", id, method, params }, "*");
85
+ return promise;
86
+ }
87
+ emit(key) {
88
+ this.listeners.get(key)?.forEach((listener) => {
89
+ listener();
90
+ });
91
+ }
92
+ updateContext(context) {
93
+ this.context = { ...this.context, ...context };
94
+ for (const key of Object.keys(context)) {
95
+ this.emit(key);
96
+ }
97
+ }
98
+ init() {
99
+ if (this.initialized) {
100
+ return;
101
+ }
102
+ this.initialized = true;
103
+ if (typeof window === "undefined" || window.parent === window) {
104
+ return;
105
+ }
106
+ window.addEventListener("message", this.handleMessage);
107
+ this.connect();
108
+ }
109
+ handleMessage = (event) => {
110
+ const data = event.data;
111
+ if (data.jsonrpc !== "2.0") {
112
+ return;
113
+ }
114
+ if ("id" in data) {
115
+ const request = this.pendingRequests.get(data.id);
116
+ if (request) {
117
+ clearTimeout(request.timeout);
118
+ this.pendingRequests.delete(data.id);
119
+ if ("error" in data) {
120
+ request.reject(new Error(data.error.message));
121
+ return;
122
+ }
123
+ request.resolve(data.result);
124
+ }
125
+ return;
126
+ }
127
+ switch (data.method) {
128
+ case "ui/notifications/host-context-changed":
129
+ this.updateContext(data.params);
130
+ return;
131
+ case "ui/notifications/tool-input":
132
+ this.updateContext({
133
+ toolInput: data.params.arguments ?? {},
134
+ });
135
+ return;
136
+ case "ui/notifications/tool-result":
137
+ this.updateContext({
138
+ toolResult: data.params,
139
+ });
140
+ return;
141
+ case "ui/notifications/tool-cancelled":
142
+ this.updateContext({
143
+ toolCancelled: data.params,
144
+ });
145
+ return;
146
+ }
147
+ };
148
+ async connect() {
149
+ try {
150
+ const result = await this.request({
151
+ method: "ui/initialize",
152
+ params: this.appInitializationOptions,
153
+ });
154
+ this.updateContext(result.hostContext);
155
+ this.notify({ method: "ui/notifications/initialized" });
156
+ this.cleanupSizeObserver = this.setupSizeChangedNotifications();
157
+ }
158
+ catch (err) {
159
+ console.error(err);
160
+ }
161
+ }
162
+ notify(notification) {
163
+ window.parent.postMessage({ jsonrpc: "2.0", ...notification }, "*");
164
+ }
165
+ sendSizeChanged(params) {
166
+ this.notify({ method: "ui/notifications/size-changed", params });
167
+ }
168
+ /**
169
+ * Set up automatic size change notifications using ResizeObserver.
170
+ * Based on @modelcontextprotocol/ext-apps App.setupSizeChangedNotifications
171
+ * @see https://github.com/modelcontextprotocol/ext-apps/blob/main/src/app.ts#L940-L989
172
+ */
173
+ setupSizeChangedNotifications() {
174
+ let scheduled = false;
175
+ let lastWidth = 0;
176
+ let lastHeight = 0;
177
+ const sendBodySizeChanged = () => {
178
+ if (scheduled) {
179
+ return;
180
+ }
181
+ scheduled = true;
182
+ requestAnimationFrame(() => {
183
+ scheduled = false;
184
+ const html = document.documentElement;
185
+ // Measure actual content size by temporarily setting html to fit-content.
186
+ // This shrinks html to fit body (including body margins), giving us the
187
+ // true minimum size needed by the content.
188
+ const originalWidth = html.style.width;
189
+ const originalHeight = html.style.height;
190
+ html.style.width = "fit-content";
191
+ html.style.height = "fit-content";
192
+ const rect = html.getBoundingClientRect();
193
+ html.style.width = originalWidth;
194
+ html.style.height = originalHeight;
195
+ // Compensate for scrollbar width on Linux/Windows where scrollbars
196
+ // consume space. On systems with overlay scrollbars (macOS), this
197
+ // will be 0.
198
+ const scrollbarWidth = window.innerWidth - html.clientWidth;
199
+ const width = Math.ceil(rect.width + scrollbarWidth);
200
+ const height = Math.ceil(rect.height);
201
+ // Only send if size actually changed (prevents feedback loops from
202
+ // style changes)
203
+ if (width !== lastWidth || height !== lastHeight) {
204
+ lastWidth = width;
205
+ lastHeight = height;
206
+ this.sendSizeChanged({ width, height });
207
+ }
208
+ });
209
+ };
210
+ sendBodySizeChanged();
211
+ const resizeObserver = new ResizeObserver(sendBodySizeChanged);
212
+ resizeObserver.observe(document.documentElement);
213
+ resizeObserver.observe(document.body);
214
+ return () => resizeObserver.disconnect();
215
+ }
216
+ }
217
+ //# sourceMappingURL=mcp-app-bridge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-app-bridge.js","sourceRoot":"","sources":["../../../src/web/bridges/mcp-app-bridge.ts"],"names":[],"mappings":"AAoCA,MAAM,uBAAuB,GAAG,YAAY,CAAC;AAqB7C,MAAM,OAAO,YAAY;IACf,MAAM,CAAC,QAAQ,GAAwB,IAAI,CAAC;IAC7C,OAAO,GAAwB;QACpC,SAAS,EAAE,IAAI;QACf,aAAa,EAAE,IAAI;QACnB,UAAU,EAAE,IAAI;KACjB,CAAC;IACM,SAAS,GAAG,IAAI,GAAG,EAAoC,CAAC;IACxD,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;IACJ,CAAC;IAEM,MAAM,CAAC,WAAW,CACvB,OAA8C,EAC9C,cAAuB;QAEvB,IAAI,MAAM,CAAC,SAAS,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC5C,MAAM,IAAI,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