skybridge 0.0.0-dev.c8e68ef → 0.0.0-dev.c8ed98d

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 (246) hide show
  1. package/README.md +132 -124
  2. package/dist/cli/build-helpers.d.ts +7 -0
  3. package/dist/cli/build-helpers.js +82 -0
  4. package/dist/cli/build-helpers.js.map +1 -0
  5. package/dist/cli/build-helpers.test.d.ts +1 -0
  6. package/dist/cli/build-helpers.test.js +64 -0
  7. package/dist/cli/build-helpers.test.js.map +1 -0
  8. package/dist/cli/detect-port.d.ts +2 -2
  9. package/dist/cli/detect-port.js +9 -20
  10. package/dist/cli/detect-port.js.map +1 -1
  11. package/dist/cli/resolve-views-dir.d.ts +1 -0
  12. package/dist/cli/resolve-views-dir.js +17 -0
  13. package/dist/cli/resolve-views-dir.js.map +1 -0
  14. package/dist/cli/use-typescript-check.js +1 -1
  15. package/dist/cli/use-typescript-check.js.map +1 -1
  16. package/dist/commands/build.d.ts +0 -1
  17. package/dist/commands/build.js +18 -30
  18. package/dist/commands/build.js.map +1 -1
  19. package/dist/commands/create.d.ts +9 -0
  20. package/dist/commands/create.js +30 -0
  21. package/dist/commands/create.js.map +1 -0
  22. package/dist/commands/dev.js +16 -0
  23. package/dist/commands/dev.js.map +1 -1
  24. package/dist/commands/start.js +7 -1
  25. package/dist/commands/start.js.map +1 -1
  26. package/dist/server/asset-base-url-transform-plugin.d.ts +1 -0
  27. package/dist/server/asset-base-url-transform-plugin.js +16 -1
  28. package/dist/server/asset-base-url-transform-plugin.js.map +1 -1
  29. package/dist/server/asset-base-url-transform-plugin.test.js +51 -1
  30. package/dist/server/asset-base-url-transform-plugin.test.js.map +1 -1
  31. package/dist/server/auth/discovery.d.ts +32 -0
  32. package/dist/server/auth/discovery.js +44 -0
  33. package/dist/server/auth/discovery.js.map +1 -0
  34. package/dist/server/auth/discovery.test.d.ts +1 -0
  35. package/dist/server/auth/discovery.test.js +71 -0
  36. package/dist/server/auth/discovery.test.js.map +1 -0
  37. package/dist/server/auth/index.d.ts +18 -0
  38. package/dist/server/auth/index.js +2 -0
  39. package/dist/server/auth/index.js.map +1 -0
  40. package/dist/server/auth/providers/custom.d.ts +12 -0
  41. package/dist/server/auth/providers/custom.js +28 -0
  42. package/dist/server/auth/providers/custom.js.map +1 -0
  43. package/dist/server/auth/providers/custom.test.d.ts +1 -0
  44. package/dist/server/auth/providers/custom.test.js +91 -0
  45. package/dist/server/auth/providers/custom.test.js.map +1 -0
  46. package/dist/server/auth/setup.d.ts +4 -0
  47. package/dist/server/auth/setup.js +51 -0
  48. package/dist/server/auth/setup.js.map +1 -0
  49. package/dist/server/auth/setup.test.d.ts +1 -0
  50. package/dist/server/auth/setup.test.js +185 -0
  51. package/dist/server/auth/setup.test.js.map +1 -0
  52. package/dist/server/auth/verify.d.ts +11 -0
  53. package/dist/server/auth/verify.js +37 -0
  54. package/dist/server/auth/verify.js.map +1 -0
  55. package/dist/server/auth/verify.test.d.ts +1 -0
  56. package/dist/server/auth/verify.test.js +87 -0
  57. package/dist/server/auth/verify.test.js.map +1 -0
  58. package/dist/server/auth.d.ts +20 -0
  59. package/dist/server/auth.js +28 -0
  60. package/dist/server/auth.js.map +1 -0
  61. package/dist/server/build-manifest.test.d.ts +1 -0
  62. package/dist/server/build-manifest.test.js +27 -0
  63. package/dist/server/build-manifest.test.js.map +1 -0
  64. package/dist/server/content-helpers.d.ts +40 -0
  65. package/dist/server/content-helpers.js +33 -0
  66. package/dist/server/content-helpers.js.map +1 -1
  67. package/dist/server/express.test.js +61 -0
  68. package/dist/server/express.test.js.map +1 -1
  69. package/dist/server/file-ref.d.ts +20 -0
  70. package/dist/server/file-ref.js +19 -0
  71. package/dist/server/file-ref.js.map +1 -1
  72. package/dist/server/index.d.ts +5 -2
  73. package/dist/server/index.js +3 -1
  74. package/dist/server/index.js.map +1 -1
  75. package/dist/server/middleware.d.ts +16 -3
  76. package/dist/server/middleware.js.map +1 -1
  77. package/dist/server/requestOrigin.d.ts +7 -0
  78. package/dist/server/requestOrigin.js +25 -0
  79. package/dist/server/requestOrigin.js.map +1 -0
  80. package/dist/server/server.d.ts +220 -6
  81. package/dist/server/server.js +290 -159
  82. package/dist/server/server.js.map +1 -1
  83. package/dist/server/view-resource-resolution.test.d.ts +6 -0
  84. package/dist/server/view-resource-resolution.test.js +88 -0
  85. package/dist/server/view-resource-resolution.test.js.map +1 -0
  86. package/dist/test/view.test.js +97 -94
  87. package/dist/test/view.test.js.map +1 -1
  88. package/dist/web/bridges/adaptor.d.ts +51 -0
  89. package/dist/web/bridges/adaptor.js +312 -0
  90. package/dist/web/bridges/adaptor.js.map +1 -0
  91. package/dist/web/bridges/adaptor.test.d.ts +1 -0
  92. package/dist/web/bridges/adaptor.test.js +205 -0
  93. package/dist/web/bridges/adaptor.test.js.map +1 -0
  94. package/dist/web/bridges/apps-sdk/bridge.d.ts +1 -0
  95. package/dist/web/bridges/apps-sdk/bridge.js +3 -3
  96. package/dist/web/bridges/apps-sdk/bridge.js.map +1 -1
  97. package/dist/web/bridges/apps-sdk/index.d.ts +0 -1
  98. package/dist/web/bridges/apps-sdk/index.js +0 -1
  99. package/dist/web/bridges/apps-sdk/index.js.map +1 -1
  100. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.d.ts +11 -0
  101. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js +11 -0
  102. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js.map +1 -1
  103. package/dist/web/bridges/get-adaptor.d.ts +9 -0
  104. package/dist/web/bridges/get-adaptor.js +19 -5
  105. package/dist/web/bridges/get-adaptor.js.map +1 -1
  106. package/dist/web/bridges/get-adaptor.test.d.ts +1 -0
  107. package/dist/web/bridges/get-adaptor.test.js +32 -0
  108. package/dist/web/bridges/get-adaptor.test.js.map +1 -0
  109. package/dist/web/bridges/host-context-stores.d.ts +27 -0
  110. package/dist/web/bridges/host-context-stores.js +73 -0
  111. package/dist/web/bridges/host-context-stores.js.map +1 -0
  112. package/dist/web/bridges/mcp-app/bridge.d.ts +4 -2
  113. package/dist/web/bridges/mcp-app/bridge.js +23 -4
  114. package/dist/web/bridges/mcp-app/bridge.js.map +1 -1
  115. package/dist/web/bridges/mcp-app/bridge.test.d.ts +1 -0
  116. package/dist/web/bridges/mcp-app/bridge.test.js +17 -0
  117. package/dist/web/bridges/mcp-app/bridge.test.js.map +1 -0
  118. package/dist/web/bridges/mcp-app/index.d.ts +0 -1
  119. package/dist/web/bridges/mcp-app/index.js +0 -1
  120. package/dist/web/bridges/mcp-app/index.js.map +1 -1
  121. package/dist/web/bridges/mcp-app/use-mcp-app-context.d.ts +12 -0
  122. package/dist/web/bridges/mcp-app/use-mcp-app-context.js +12 -0
  123. package/dist/web/bridges/mcp-app/use-mcp-app-context.js.map +1 -1
  124. package/dist/web/bridges/mcp-app/view-tools.test.d.ts +1 -0
  125. package/dist/web/bridges/mcp-app/view-tools.test.js +143 -0
  126. package/dist/web/bridges/mcp-app/view-tools.test.js.map +1 -0
  127. package/dist/web/bridges/types.d.ts +103 -1
  128. package/dist/web/bridges/types.js +14 -1
  129. package/dist/web/bridges/types.js.map +1 -1
  130. package/dist/web/bridges/types.test.d.ts +1 -0
  131. package/dist/web/bridges/types.test.js +19 -0
  132. package/dist/web/bridges/types.test.js.map +1 -0
  133. package/dist/web/bridges/use-host-context.d.ts +5 -0
  134. package/dist/web/bridges/use-host-context.js +5 -0
  135. package/dist/web/bridges/use-host-context.js.map +1 -1
  136. package/dist/web/components/modal-provider.js +4 -3
  137. package/dist/web/components/modal-provider.js.map +1 -1
  138. package/dist/web/create-store.d.ts +26 -0
  139. package/dist/web/create-store.js +26 -0
  140. package/dist/web/create-store.js.map +1 -1
  141. package/dist/web/create-store.test.js +7 -5
  142. package/dist/web/create-store.test.js.map +1 -1
  143. package/dist/web/data-llm.d.ts +33 -0
  144. package/dist/web/data-llm.js +28 -0
  145. package/dist/web/data-llm.js.map +1 -1
  146. package/dist/web/data-llm.test.js +8 -5
  147. package/dist/web/data-llm.test.js.map +1 -1
  148. package/dist/web/generate-helpers.d.ts +2 -0
  149. package/dist/web/generate-helpers.js +2 -0
  150. package/dist/web/generate-helpers.js.map +1 -1
  151. package/dist/web/generate-helpers.test-d.js +4 -2
  152. package/dist/web/generate-helpers.test-d.js.map +1 -1
  153. package/dist/web/hooks/index.d.ts +2 -0
  154. package/dist/web/hooks/index.js +2 -0
  155. package/dist/web/hooks/index.js.map +1 -1
  156. package/dist/web/hooks/test/utils.d.ts +6 -2
  157. package/dist/web/hooks/test/utils.js +13 -2
  158. package/dist/web/hooks/test/utils.js.map +1 -1
  159. package/dist/web/hooks/use-call-tool.d.ts +45 -0
  160. package/dist/web/hooks/use-call-tool.js +28 -0
  161. package/dist/web/hooks/use-call-tool.js.map +1 -1
  162. package/dist/web/hooks/use-call-tool.test.js +61 -23
  163. package/dist/web/hooks/use-call-tool.test.js.map +1 -1
  164. package/dist/web/hooks/use-display-mode.d.ts +20 -0
  165. package/dist/web/hooks/use-display-mode.js +20 -0
  166. package/dist/web/hooks/use-display-mode.js.map +1 -1
  167. package/dist/web/hooks/use-display-mode.test.js +55 -20
  168. package/dist/web/hooks/use-display-mode.test.js.map +1 -1
  169. package/dist/web/hooks/use-download.d.ts +5 -0
  170. package/dist/web/hooks/use-download.js +8 -0
  171. package/dist/web/hooks/use-download.js.map +1 -0
  172. package/dist/web/hooks/use-download.test.d.ts +1 -0
  173. package/dist/web/hooks/use-download.test.js +103 -0
  174. package/dist/web/hooks/use-download.test.js.map +1 -0
  175. package/dist/web/hooks/use-files.d.ts +32 -0
  176. package/dist/web/hooks/use-files.js +32 -0
  177. package/dist/web/hooks/use-files.js.map +1 -1
  178. package/dist/web/hooks/use-files.test.js +10 -2
  179. package/dist/web/hooks/use-files.test.js.map +1 -1
  180. package/dist/web/hooks/use-layout.d.ts +2 -0
  181. package/dist/web/hooks/use-layout.js +2 -0
  182. package/dist/web/hooks/use-layout.js.map +1 -1
  183. package/dist/web/hooks/use-layout.test.js +59 -26
  184. package/dist/web/hooks/use-layout.test.js.map +1 -1
  185. package/dist/web/hooks/use-open-external.d.ts +17 -0
  186. package/dist/web/hooks/use-open-external.js +16 -0
  187. package/dist/web/hooks/use-open-external.js.map +1 -1
  188. package/dist/web/hooks/use-open-external.test.js +19 -5
  189. package/dist/web/hooks/use-open-external.test.js.map +1 -1
  190. package/dist/web/hooks/use-register-view-tool.d.ts +38 -0
  191. package/dist/web/hooks/use-register-view-tool.js +50 -0
  192. package/dist/web/hooks/use-register-view-tool.js.map +1 -0
  193. package/dist/web/hooks/use-request-close.d.ts +14 -0
  194. package/dist/web/hooks/use-request-close.js +13 -0
  195. package/dist/web/hooks/use-request-close.js.map +1 -1
  196. package/dist/web/hooks/use-request-close.test.js +34 -40
  197. package/dist/web/hooks/use-request-close.test.js.map +1 -1
  198. package/dist/web/hooks/use-request-modal.d.ts +16 -1
  199. package/dist/web/hooks/use-request-modal.js +16 -1
  200. package/dist/web/hooks/use-request-modal.js.map +1 -1
  201. package/dist/web/hooks/use-request-modal.test.js +10 -0
  202. package/dist/web/hooks/use-request-modal.test.js.map +1 -1
  203. package/dist/web/hooks/use-request-size.d.ts +17 -0
  204. package/dist/web/hooks/use-request-size.js +16 -0
  205. package/dist/web/hooks/use-request-size.js.map +1 -1
  206. package/dist/web/hooks/use-request-size.test.js +35 -53
  207. package/dist/web/hooks/use-request-size.test.js.map +1 -1
  208. package/dist/web/hooks/use-send-follow-up-message.d.ts +17 -0
  209. package/dist/web/hooks/use-send-follow-up-message.js +17 -0
  210. package/dist/web/hooks/use-send-follow-up-message.js.map +1 -1
  211. package/dist/web/hooks/use-set-open-in-app-url.d.ts +17 -0
  212. package/dist/web/hooks/use-set-open-in-app-url.js +17 -0
  213. package/dist/web/hooks/use-set-open-in-app-url.js.map +1 -1
  214. package/dist/web/hooks/use-set-open-in-app-url.test.js +28 -8
  215. package/dist/web/hooks/use-set-open-in-app-url.test.js.map +1 -1
  216. package/dist/web/hooks/use-tool-info.d.ts +53 -2
  217. package/dist/web/hooks/use-tool-info.js +30 -7
  218. package/dist/web/hooks/use-tool-info.js.map +1 -1
  219. package/dist/web/hooks/use-tool-info.test-d.js +11 -29
  220. package/dist/web/hooks/use-tool-info.test-d.js.map +1 -1
  221. package/dist/web/hooks/use-tool-info.test.js +42 -32
  222. package/dist/web/hooks/use-tool-info.test.js.map +1 -1
  223. package/dist/web/hooks/use-user.d.ts +2 -0
  224. package/dist/web/hooks/use-user.js +2 -0
  225. package/dist/web/hooks/use-user.js.map +1 -1
  226. package/dist/web/hooks/use-user.test.js +81 -35
  227. package/dist/web/hooks/use-user.test.js.map +1 -1
  228. package/dist/web/hooks/use-view-state.d.ts +21 -0
  229. package/dist/web/hooks/use-view-state.js.map +1 -1
  230. package/dist/web/hooks/use-view-state.test.js +6 -2
  231. package/dist/web/hooks/use-view-state.test.js.map +1 -1
  232. package/dist/web/mount-view.d.ts +19 -0
  233. package/dist/web/mount-view.js +19 -0
  234. package/dist/web/mount-view.js.map +1 -1
  235. package/dist/web/plugin/plugin.d.ts +28 -0
  236. package/dist/web/plugin/plugin.js +26 -0
  237. package/dist/web/plugin/plugin.js.map +1 -1
  238. package/dist/web/types.d.ts +4 -0
  239. package/dist/web/types.js.map +1 -1
  240. package/package.json +10 -3
  241. package/dist/web/bridges/apps-sdk/adaptor.d.ts +0 -26
  242. package/dist/web/bridges/apps-sdk/adaptor.js +0 -102
  243. package/dist/web/bridges/apps-sdk/adaptor.js.map +0 -1
  244. package/dist/web/bridges/mcp-app/adaptor.d.ts +0 -50
  245. package/dist/web/bridges/mcp-app/adaptor.js +0 -271
  246. package/dist/web/bridges/mcp-app/adaptor.js.map +0 -1
@@ -1,4 +1,3 @@
1
- export { AppsSdkAdaptor } from "./adaptor.js";
2
1
  export { AppsSdkBridge } from "./bridge.js";
3
2
  export type { AppsSdkContext, AppsSdkMethods, AppsSdkWidgetState, ToolResponseEvent, } from "./types.js";
4
3
  export { SET_GLOBALS_EVENT_TYPE, SetGlobalsEvent, TOOL_RESPONSE_EVENT_TYPE, } from "./types.js";
@@ -1,4 +1,3 @@
1
- export { AppsSdkAdaptor } from "./adaptor.js";
2
1
  export { AppsSdkBridge } from "./bridge.js";
3
2
  export { SET_GLOBALS_EVENT_TYPE, SetGlobalsEvent, TOOL_RESPONSE_EVENT_TYPE, } from "./types.js";
4
3
  export { useAppsSdkContext } from "./use-apps-sdk-context.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/web/bridges/apps-sdk/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAO5C,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,wBAAwB,GACzB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC","sourcesContent":["export { AppsSdkAdaptor } from \"./adaptor.js\";\nexport { AppsSdkBridge } from \"./bridge.js\";\nexport type {\n AppsSdkContext,\n AppsSdkMethods,\n AppsSdkWidgetState,\n ToolResponseEvent,\n} from \"./types.js\";\nexport {\n SET_GLOBALS_EVENT_TYPE,\n SetGlobalsEvent,\n TOOL_RESPONSE_EVENT_TYPE,\n} from \"./types.js\";\nexport { useAppsSdkContext } from \"./use-apps-sdk-context.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/web/bridges/apps-sdk/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAO5C,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,wBAAwB,GACzB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC","sourcesContent":["export { AppsSdkBridge } from \"./bridge.js\";\nexport type {\n AppsSdkContext,\n AppsSdkMethods,\n AppsSdkWidgetState,\n ToolResponseEvent,\n} from \"./types.js\";\nexport {\n SET_GLOBALS_EVENT_TYPE,\n SetGlobalsEvent,\n TOOL_RESPONSE_EVENT_TYPE,\n} from \"./types.js\";\nexport { useAppsSdkContext } from \"./use-apps-sdk-context.js\";\n"]}
@@ -1,2 +1,13 @@
1
1
  import type { AppsSdkContext } from "./types.js";
2
+ /**
3
+ * Read a single key from the raw Apps SDK (`window.openai`) context.
4
+ *
5
+ * Advanced escape hatch — prefer the cross-host hooks (`useLayout`, `useUser`,
6
+ * `useToolInfo`, etc.) which work in both Apps SDK and MCP Apps. Reach for
7
+ * this when you need ChatGPT-only fields not surfaced by the public hooks.
8
+ *
9
+ * Throws if called outside the Apps SDK runtime.
10
+ *
11
+ * @see https://docs.skybridge.tech/api-reference/use-apps-sdk-context
12
+ */
2
13
  export declare function useAppsSdkContext<K extends keyof AppsSdkContext>(key: K): AppsSdkContext[K];
@@ -1,5 +1,16 @@
1
1
  import { useSyncExternalStore } from "react";
2
2
  import { AppsSdkBridge } from "./bridge.js";
3
+ /**
4
+ * Read a single key from the raw Apps SDK (`window.openai`) context.
5
+ *
6
+ * Advanced escape hatch — prefer the cross-host hooks (`useLayout`, `useUser`,
7
+ * `useToolInfo`, etc.) which work in both Apps SDK and MCP Apps. Reach for
8
+ * this when you need ChatGPT-only fields not surfaced by the public hooks.
9
+ *
10
+ * Throws if called outside the Apps SDK runtime.
11
+ *
12
+ * @see https://docs.skybridge.tech/api-reference/use-apps-sdk-context
13
+ */
3
14
  export function useAppsSdkContext(key) {
4
15
  const bridge = AppsSdkBridge.getInstance();
5
16
  return useSyncExternalStore(bridge.subscribe(key), () => bridge.getSnapshot(key));
@@ -1 +1 @@
1
- {"version":3,"file":"use-apps-sdk-context.js","sourceRoot":"","sources":["../../../../src/web/bridges/apps-sdk/use-apps-sdk-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,MAAM,UAAU,iBAAiB,CAC/B,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","sourcesContent":["import { useSyncExternalStore } from \"react\";\nimport { AppsSdkBridge } from \"./bridge.js\";\nimport type { AppsSdkContext } from \"./types.js\";\n\nexport function useAppsSdkContext<K extends keyof AppsSdkContext>(\n key: K,\n): AppsSdkContext[K] {\n const bridge = AppsSdkBridge.getInstance();\n return useSyncExternalStore(bridge.subscribe(key), () =>\n bridge.getSnapshot(key),\n );\n}\n"]}
1
+ {"version":3,"file":"use-apps-sdk-context.js","sourceRoot":"","sources":["../../../../src/web/bridges/apps-sdk/use-apps-sdk-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C;;;;;;;;;;GAUG;AACH,MAAM,UAAU,iBAAiB,CAC/B,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","sourcesContent":["import { useSyncExternalStore } from \"react\";\nimport { AppsSdkBridge } from \"./bridge.js\";\nimport type { AppsSdkContext } from \"./types.js\";\n\n/**\n * Read a single key from the raw Apps SDK (`window.openai`) context.\n *\n * Advanced escape hatch — prefer the cross-host hooks (`useLayout`, `useUser`,\n * `useToolInfo`, etc.) which work in both Apps SDK and MCP Apps. Reach for\n * this when you need ChatGPT-only fields not surfaced by the public hooks.\n *\n * Throws if called outside the Apps SDK runtime.\n *\n * @see https://docs.skybridge.tech/api-reference/use-apps-sdk-context\n */\nexport function useAppsSdkContext<K extends keyof AppsSdkContext>(\n key: K,\n): AppsSdkContext[K] {\n const bridge = AppsSdkBridge.getInstance();\n return useSyncExternalStore(bridge.subscribe(key), () =>\n bridge.getSnapshot(key),\n );\n}\n"]}
@@ -1,2 +1,11 @@
1
1
  import type { Adaptor } from "./types.js";
2
+ /**
3
+ * @internal
4
+ * Resolve the single host {@link Adaptor} instance. Prefer the documented
5
+ * hooks (`useCallTool`, `useViewState`, etc.) over calling this directly;
6
+ * it's the escape hatch used by the hooks themselves and by advanced
7
+ * integrations.
8
+ */
2
9
  export declare const getAdaptor: () => Adaptor;
10
+ /** @internal Test-only. */
11
+ export declare const _resetAdaptor: () => void;
@@ -1,8 +1,22 @@
1
- import { AppsSdkAdaptor } from "./apps-sdk/adaptor.js";
2
- import { McpAppAdaptor } from "./mcp-app/adaptor.js";
1
+ import { HostAdaptor } from "./adaptor.js";
2
+ let cached = null;
3
+ /**
4
+ * @internal
5
+ * Resolve the single host {@link Adaptor} instance. Prefer the documented
6
+ * hooks (`useCallTool`, `useViewState`, etc.) over calling this directly;
7
+ * it's the escape hatch used by the hooks themselves and by advanced
8
+ * integrations.
9
+ */
3
10
  export const getAdaptor = () => {
4
- return window.skybridge.hostType === "apps-sdk"
5
- ? AppsSdkAdaptor.getInstance()
6
- : McpAppAdaptor.getInstance();
11
+ if (cached) {
12
+ return cached;
13
+ }
14
+ cached = new HostAdaptor();
15
+ return cached;
16
+ };
17
+ /** @internal Test-only. */
18
+ export const _resetAdaptor = () => {
19
+ cached?.cleanup();
20
+ cached = null;
7
21
  };
8
22
  //# sourceMappingURL=get-adaptor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-adaptor.js","sourceRoot":"","sources":["../../../src/web/bridges/get-adaptor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD,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","sourcesContent":["import { AppsSdkAdaptor } from \"./apps-sdk/adaptor.js\";\nimport { McpAppAdaptor } from \"./mcp-app/adaptor.js\";\nimport type { Adaptor } from \"./types.js\";\n\nexport const getAdaptor = (): Adaptor => {\n return window.skybridge.hostType === \"apps-sdk\"\n ? AppsSdkAdaptor.getInstance()\n : McpAppAdaptor.getInstance();\n};\n"]}
1
+ {"version":3,"file":"get-adaptor.js","sourceRoot":"","sources":["../../../src/web/bridges/get-adaptor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAG3C,IAAI,MAAM,GAAuB,IAAI,CAAC;AAEtC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,GAAY,EAAE;IACtC,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;IAC3B,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF,2BAA2B;AAC3B,MAAM,CAAC,MAAM,aAAa,GAAG,GAAS,EAAE;IACtC,MAAM,EAAE,OAAO,EAAE,CAAC;IAClB,MAAM,GAAG,IAAI,CAAC;AAChB,CAAC,CAAC","sourcesContent":["import { HostAdaptor } from \"./adaptor.js\";\nimport type { Adaptor } from \"./types.js\";\n\nlet cached: HostAdaptor | null = null;\n\n/**\n * @internal\n * Resolve the single host {@link Adaptor} instance. Prefer the documented\n * hooks (`useCallTool`, `useViewState`, etc.) over calling this directly;\n * it's the escape hatch used by the hooks themselves and by advanced\n * integrations.\n */\nexport const getAdaptor = (): Adaptor => {\n if (cached) {\n return cached;\n }\n cached = new HostAdaptor();\n return cached;\n};\n\n/** @internal Test-only. */\nexport const _resetAdaptor = (): void => {\n cached?.cleanup();\n cached = null;\n};\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,32 @@
1
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
2
+ import { HostAdaptor } from "./adaptor.js";
3
+ import { AppsSdkBridge } from "./apps-sdk/bridge.js";
4
+ import { _resetAdaptor, getAdaptor } from "./get-adaptor.js";
5
+ import { McpAppBridge } from "./mcp-app/bridge.js";
6
+ describe("getAdaptor", () => {
7
+ beforeEach(() => {
8
+ _resetAdaptor();
9
+ McpAppBridge.resetInstance();
10
+ AppsSdkBridge.resetInstance();
11
+ vi.stubGlobal("parent", { postMessage: vi.fn() });
12
+ });
13
+ afterEach(() => {
14
+ vi.unstubAllGlobals();
15
+ _resetAdaptor();
16
+ McpAppBridge.resetInstance();
17
+ AppsSdkBridge.resetInstance();
18
+ });
19
+ it("returns a HostAdaptor instance", () => {
20
+ vi.stubGlobal("skybridge", { hostType: "mcp-app" });
21
+ vi.stubGlobal("openai", undefined);
22
+ expect(getAdaptor()).toBeInstanceOf(HostAdaptor);
23
+ });
24
+ it("memoizes the instance", () => {
25
+ vi.stubGlobal("skybridge", { hostType: "mcp-app" });
26
+ vi.stubGlobal("openai", undefined);
27
+ const a = getAdaptor();
28
+ const b = getAdaptor();
29
+ expect(a).toBe(b);
30
+ });
31
+ });
32
+ //# sourceMappingURL=get-adaptor.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-adaptor.test.js","sourceRoot":"","sources":["../../../src/web/bridges/get-adaptor.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,WAAW,EAAE,MAAM,cAAc,CAAC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CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { afterEach, beforeEach, describe, expect, it, vi } from \"vitest\";\nimport { HostAdaptor } from \"./adaptor.js\";\nimport { AppsSdkBridge } from \"./apps-sdk/bridge.js\";\nimport { _resetAdaptor, getAdaptor } from \"./get-adaptor.js\";\nimport { McpAppBridge } from \"./mcp-app/bridge.js\";\n\ndescribe(\"getAdaptor\", () => {\n beforeEach(() => {\n _resetAdaptor();\n McpAppBridge.resetInstance();\n AppsSdkBridge.resetInstance();\n vi.stubGlobal(\"parent\", { postMessage: vi.fn() });\n });\n afterEach(() => {\n vi.unstubAllGlobals();\n _resetAdaptor();\n McpAppBridge.resetInstance();\n AppsSdkBridge.resetInstance();\n });\n\n it(\"returns a HostAdaptor instance\", () => {\n vi.stubGlobal(\"skybridge\", { hostType: \"mcp-app\" });\n vi.stubGlobal(\"openai\", undefined);\n expect(getAdaptor()).toBeInstanceOf(HostAdaptor);\n });\n\n it(\"memoizes the instance\", () => {\n vi.stubGlobal(\"skybridge\", { hostType: \"mcp-app\" });\n vi.stubGlobal(\"openai\", undefined);\n const a = getAdaptor();\n const b = getAdaptor();\n expect(a).toBe(b);\n });\n});\n"]}
@@ -0,0 +1,27 @@
1
+ import type { McpAppBridge } from "./mcp-app/bridge.js";
2
+ import type { HostContextStore } from "./types.js";
3
+ /**
4
+ * Build the host-context store map sourced from the MCP App bridge.
5
+ * `display` and `viewState` are *not* included here; those are handled
6
+ * by the adaptor itself because they have transport-specific overlays
7
+ * and additional state (polyfill modal state, localStorage hydration).
8
+ */
9
+ export declare function buildMcpContextStores(bridge: McpAppBridge): {
10
+ theme: HostContextStore<"theme">;
11
+ locale: HostContextStore<"locale">;
12
+ safeArea: HostContextStore<"safeArea">;
13
+ displayMode: HostContextStore<"displayMode">;
14
+ maxHeight: HostContextStore<"maxHeight">;
15
+ userAgent: HostContextStore<"userAgent">;
16
+ toolInput: HostContextStore<"toolInput">;
17
+ toolOutput: HostContextStore<"toolOutput">;
18
+ toolResponseMetadata: HostContextStore<"toolResponseMetadata">;
19
+ };
20
+ /**
21
+ * Build the Apps-SDK-sourced overlay stores (`display`, `viewState`).
22
+ * Used by `HostAdaptor` only when `window.openai` is present.
23
+ */
24
+ export declare function buildAppsSdkOverlayStores(bridge: import("./apps-sdk/bridge.js").AppsSdkBridge): {
25
+ display: HostContextStore<"display">;
26
+ viewState: HostContextStore<"viewState">;
27
+ };
@@ -0,0 +1,73 @@
1
+ import { dequal } from "dequal/lite";
2
+ /**
3
+ * Build a memoized {@link HostContextStore} backed by one or more
4
+ * `McpAppBridge` context keys. Recomputed values are deep-compared via
5
+ * `dequal` so unchanged snapshots return the cached reference.
6
+ */
7
+ function createMcpStore(bridge, keys, computeSnapshot) {
8
+ let cachedValue;
9
+ return {
10
+ subscribe: bridge.subscribe(keys),
11
+ getSnapshot: () => {
12
+ const context = Object.fromEntries(keys.map((k) => [k, bridge.getSnapshot(k)]));
13
+ const newValue = computeSnapshot(context);
14
+ if (cachedValue !== undefined && dequal(cachedValue, newValue)) {
15
+ return cachedValue;
16
+ }
17
+ cachedValue = newValue;
18
+ return newValue;
19
+ },
20
+ };
21
+ }
22
+ /**
23
+ * Build the host-context store map sourced from the MCP App bridge.
24
+ * `display` and `viewState` are *not* included here; those are handled
25
+ * by the adaptor itself because they have transport-specific overlays
26
+ * and additional state (polyfill modal state, localStorage hydration).
27
+ */
28
+ export function buildMcpContextStores(bridge) {
29
+ return {
30
+ theme: createMcpStore(bridge, ["theme"], ({ theme }) => theme ?? "light"),
31
+ locale: createMcpStore(bridge, ["locale"], ({ locale }) => locale ?? "en-US"),
32
+ safeArea: createMcpStore(bridge, ["safeAreaInsets"], ({ safeAreaInsets }) => ({
33
+ insets: safeAreaInsets ?? { top: 0, right: 0, bottom: 0, left: 0 },
34
+ })),
35
+ displayMode: createMcpStore(bridge, ["displayMode"], ({ displayMode }) => displayMode ?? "inline"),
36
+ maxHeight: createMcpStore(bridge, ["containerDimensions"], ({ containerDimensions }) => {
37
+ if (containerDimensions && "maxHeight" in containerDimensions) {
38
+ return containerDimensions.maxHeight;
39
+ }
40
+ return undefined;
41
+ }),
42
+ userAgent: createMcpStore(bridge, ["platform", "deviceCapabilities"], ({ platform, deviceCapabilities }) => ({
43
+ device: {
44
+ type: platform === "web" ? "desktop" : (platform ?? "unknown"),
45
+ },
46
+ capabilities: {
47
+ hover: true,
48
+ touch: true,
49
+ ...deviceCapabilities,
50
+ },
51
+ })),
52
+ toolInput: createMcpStore(bridge, ["toolInput"], ({ toolInput }) => toolInput ?? null),
53
+ toolOutput: createMcpStore(bridge, ["toolResult"], ({ toolResult }) => toolResult?.structuredContent ?? null),
54
+ toolResponseMetadata: createMcpStore(bridge, ["toolResult"], ({ toolResult }) => toolResult?._meta ?? null),
55
+ };
56
+ }
57
+ /**
58
+ * Build the Apps-SDK-sourced overlay stores (`display`, `viewState`).
59
+ * Used by `HostAdaptor` only when `window.openai` is present.
60
+ */
61
+ export function buildAppsSdkOverlayStores(bridge) {
62
+ return {
63
+ display: {
64
+ subscribe: bridge.subscribe("view"),
65
+ getSnapshot: () => bridge.getSnapshot("view"),
66
+ },
67
+ viewState: {
68
+ subscribe: bridge.subscribe("widgetState"),
69
+ getSnapshot: () => bridge.getSnapshot("widgetState")?.modelContent ?? null,
70
+ },
71
+ };
72
+ }
73
+ //# sourceMappingURL=host-context-stores.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host-context-stores.js","sourceRoot":"","sources":["../../../src/web/bridges/host-context-stores.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AASrC;;;;GAIG;AACH,SAAS,cAAc,CACrB,MAAoB,EACpB,IAAU,EACV,eAAkD;IAElD,IAAI,WAA0B,CAAC;IAC/B,OAAO;QACL,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC;QACjC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AAC,WAAW,CAAC,MAAM,CAAC;SAC9C;QACD,SAAS,EAAE;YACT,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC;YAC1C,WAAW,EAAE,GAAG,EAAE,CAChB,MAAM,CAAC,WAAW,CAAC,aAAa,CAAC,EAAE,YAAY,IAAI,IAAI;SAC1D;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { dequal } from \"dequal/lite\";\nimport type { McpAppBridge } from \"./mcp-app/bridge.js\";\nimport type { McpAppContext, McpAppContextKey } from \"./mcp-app/types.js\";\nimport type { HostContextStore } from \"./types.js\";\n\ntype PickContext<K extends readonly McpAppContextKey[]> = {\n [P in K[number]]: McpAppContext[P];\n};\n\n/**\n * Build a memoized {@link HostContextStore} backed by one or more\n * `McpAppBridge` context keys. Recomputed values are deep-compared via\n * `dequal` so unchanged snapshots return the cached reference.\n */\nfunction createMcpStore<const Keys extends readonly McpAppContextKey[], R>(\n bridge: McpAppBridge,\n keys: Keys,\n computeSnapshot: (context: PickContext<Keys>) => R,\n) {\n let cachedValue: R | undefined;\n return {\n subscribe: bridge.subscribe(keys),\n getSnapshot: () => {\n const context = Object.fromEntries(\n keys.map((k) => [k, bridge.getSnapshot(k)]),\n ) as PickContext<Keys>;\n const newValue = computeSnapshot(context);\n if (cachedValue !== undefined && dequal(cachedValue, newValue)) {\n return cachedValue;\n }\n cachedValue = newValue;\n return newValue;\n },\n };\n}\n\n/**\n * Build the host-context store map sourced from the MCP App bridge.\n * `display` and `viewState` are *not* included here; those are handled\n * by the adaptor itself because they have transport-specific overlays\n * and additional state (polyfill modal state, localStorage hydration).\n */\nexport function buildMcpContextStores(bridge: McpAppBridge): {\n theme: HostContextStore<\"theme\">;\n locale: HostContextStore<\"locale\">;\n safeArea: HostContextStore<\"safeArea\">;\n displayMode: HostContextStore<\"displayMode\">;\n maxHeight: HostContextStore<\"maxHeight\">;\n userAgent: HostContextStore<\"userAgent\">;\n toolInput: HostContextStore<\"toolInput\">;\n toolOutput: HostContextStore<\"toolOutput\">;\n toolResponseMetadata: HostContextStore<\"toolResponseMetadata\">;\n} {\n return {\n theme: createMcpStore(bridge, [\"theme\"], ({ theme }) => theme ?? \"light\"),\n locale: createMcpStore(\n bridge,\n [\"locale\"],\n ({ locale }) => locale ?? \"en-US\",\n ),\n safeArea: createMcpStore(\n bridge,\n [\"safeAreaInsets\"],\n ({ safeAreaInsets }) => ({\n insets: safeAreaInsets ?? { top: 0, right: 0, bottom: 0, left: 0 },\n }),\n ),\n displayMode: createMcpStore(\n bridge,\n [\"displayMode\"],\n ({ displayMode }) => displayMode ?? \"inline\",\n ),\n maxHeight: createMcpStore(\n bridge,\n [\"containerDimensions\"],\n ({ containerDimensions }) => {\n if (containerDimensions && \"maxHeight\" in containerDimensions) {\n return containerDimensions.maxHeight;\n }\n return undefined;\n },\n ),\n userAgent: createMcpStore(\n bridge,\n [\"platform\", \"deviceCapabilities\"],\n ({ platform, deviceCapabilities }) => ({\n device: {\n type: platform === \"web\" ? \"desktop\" : (platform ?? \"unknown\"),\n },\n capabilities: {\n hover: true,\n touch: true,\n ...deviceCapabilities,\n },\n }),\n ),\n toolInput: createMcpStore(\n bridge,\n [\"toolInput\"],\n ({ toolInput }) => toolInput ?? null,\n ),\n toolOutput: createMcpStore(\n bridge,\n [\"toolResult\"],\n ({ toolResult }) => toolResult?.structuredContent ?? null,\n ),\n toolResponseMetadata: createMcpStore(\n bridge,\n [\"toolResult\"],\n ({ toolResult }) => toolResult?._meta ?? null,\n ),\n };\n}\n\n/**\n * Build the Apps-SDK-sourced overlay stores (`display`, `viewState`).\n * Used by `HostAdaptor` only when `window.openai` is present.\n */\nexport function buildAppsSdkOverlayStores(\n bridge: import(\"./apps-sdk/bridge.js\").AppsSdkBridge,\n): {\n display: HostContextStore<\"display\">;\n viewState: HostContextStore<\"viewState\">;\n} {\n return {\n display: {\n subscribe: bridge.subscribe(\"view\"),\n getSnapshot: () => bridge.getSnapshot(\"view\"),\n },\n viewState: {\n subscribe: bridge.subscribe(\"widgetState\"),\n getSnapshot: () =>\n bridge.getSnapshot(\"widgetState\")?.modelContent ?? null,\n },\n };\n}\n"]}
@@ -1,7 +1,8 @@
1
1
  import { App } from "@modelcontextprotocol/ext-apps";
2
- import type { Implementation } from "@modelcontextprotocol/sdk/types.js";
3
- import type { Bridge, Subscribe } from "../types.js";
2
+ import { type Implementation } from "@modelcontextprotocol/sdk/types.js";
3
+ import type { AnyViewToolHandler, Bridge, Subscribe, ViewToolConfig } from "../types.js";
4
4
  import type { McpAppContext, McpAppContextKey } from "./types.js";
5
+ /** @internal Singleton bridge over the `ext-apps` JSON-RPC App connection. Used by `HostAdaptor`. */
5
6
  export declare class McpAppBridge implements Bridge<McpAppContext> {
6
7
  private static instance;
7
8
  context: McpAppContext;
@@ -13,6 +14,7 @@ export declare class McpAppBridge implements Bridge<McpAppContext> {
13
14
  });
14
15
  private connect;
15
16
  getApp(): Promise<App>;
17
+ registerViewTool(config: ViewToolConfig, handler: AnyViewToolHandler): () => void;
16
18
  static getInstance(options?: Partial<{
17
19
  appInfo: Implementation;
18
20
  }>): McpAppBridge;
@@ -1,4 +1,7 @@
1
1
  import { App } from "@modelcontextprotocol/ext-apps";
2
+ import { ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
3
+ import * as z from "zod";
4
+ /** @internal Singleton bridge over the `ext-apps` JSON-RPC App connection. Used by `HostAdaptor`. */
2
5
  export class McpAppBridge {
3
6
  static instance = null;
4
7
  context = {
@@ -10,7 +13,10 @@ export class McpAppBridge {
10
13
  app;
11
14
  connectPromise;
12
15
  constructor(options) {
13
- this.app = new App(options.appInfo);
16
+ this.app = new App(options.appInfo, { tools: { listChanged: true } });
17
+ this.app.setRequestHandler(ListToolsRequestSchema, async () => ({
18
+ tools: [],
19
+ }));
14
20
  this.app.ontoolinput = (params) => {
15
21
  this.updateContext({ toolInput: params.arguments ?? {} });
16
22
  };
@@ -44,10 +50,23 @@ export class McpAppBridge {
44
50
  await this.connectPromise;
45
51
  return this.app;
46
52
  }
53
+ registerViewTool(config, handler) {
54
+ const inputSchema = config.inputSchema
55
+ ? z.object(config.inputSchema)
56
+ : z.object({});
57
+ const registered = this.app.registerTool(config.name, {
58
+ ...(config.title !== undefined ? { title: config.title } : {}),
59
+ ...(config.description !== undefined
60
+ ? { description: config.description }
61
+ : {}),
62
+ inputSchema,
63
+ ...(config.annotations ? { annotations: config.annotations } : {}),
64
+ }, handler);
65
+ return () => {
66
+ registered.remove();
67
+ };
68
+ }
47
69
  static getInstance(options) {
48
- if (window.skybridge.hostType !== "mcp-app") {
49
- throw new Error("MCP App Bridge can only be used in the mcp-app runtime");
50
- }
51
70
  if (McpAppBridge.instance && options) {
52
71
  console.warn("McpAppBridge.getInstance: options ignored, instance already exists");
53
72
  }
@@ -1 +1 @@
1
- {"version":3,"file":"bridge.js","sourceRoot":"","sources":["../../../../src/web/bridges/mcp-app/bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,gCAAgC,CAAC;AAKrD,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,GAAG,CAAM;IACT,cAAc,CAAgB;IAEtC,YAAY,OAAoC;QAC9C,IAAI,CAAC,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAEpC,IAAI,CAAC,GAAG,CAAC,WAAW,GAAG,CAAC,MAAM,EAAE,EAAE;YAChC,IAAI,CAAC,aAAa,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,EAAE,EAAE,CAAC,CAAC;QAC5D,CAAC,CAAC;QAEF,IAAI,CAAC,GAAG,CAAC,kBAAkB,GAAG,CAAC,MAAM,EAAE,EAAE;Y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AC;IAC3B,CAAC;IAEM,OAAO,GAAG,GAAG,EAAE;QACpB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC,CAAC;IAEK,MAAM,CAAC,aAAa;QACzB,IAAI,YAAY,CAAC,QAAQ,EAAE,CAAC;YAC1B,YAAY,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;YAChC,YAAY,CAAC,QAAQ,GAAG,IAAI,CAAC;QAC/B,CAAC;IACH,CAAC;IAEO,IAAI,CAAC,GAAqB;QAChC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;YAC5C,QAAQ,EAAE,CAAC;QACb,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,aAAa,CAAC,OAA+B;QACnD,IAAI,CAAC,OAAO,GAAG,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,GAAG,OAAO,EAAE,CAAC;QAC/C,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;YACvC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACjB,CAAC;IACH,CAAC","sourcesContent":["import { App } from \"@modelcontextprotocol/ext-apps\";\nimport type { Implementation } from \"@modelcontextprotocol/sdk/types.js\";\nimport type { Bridge, Subscribe } from \"../types.js\";\nimport type { McpAppContext, McpAppContextKey } from \"./types.js\";\n\nexport class McpAppBridge implements Bridge<McpAppContext> {\n private static instance: McpAppBridge | null = null;\n public context: McpAppContext = {\n toolInput: null,\n toolCancelled: null,\n toolResult: null,\n };\n private listeners = new Map<McpAppContextKey, Set<() => void>>();\n private app: App;\n private connectPromise: Promise<void>;\n\n constructor(options: { appInfo: Implementation }) {\n this.app = new App(options.appInfo);\n\n this.app.ontoolinput = (params) => {\n this.updateContext({ toolInput: params.arguments ?? {} });\n };\n\n this.app.ontoolinputpartial = (params) => {\n this.updateContext({ toolInput: params.arguments ?? {} });\n };\n\n this.app.ontoolresult = (params) => {\n this.updateContext({ toolResult: params });\n };\n\n this.app.ontoolcancelled = (params) => {\n this.updateContext({ toolCancelled: params });\n };\n\n this.app.onhostcontextchanged = (params) => {\n this.updateContext(params);\n };\n\n this.connectPromise = this.connect();\n }\n\n private async connect() {\n try {\n await this.app.connect();\n const hostContext = this.app.getHostContext();\n if (hostContext) {\n this.updateContext(hostContext);\n }\n } catch (err) {\n console.error(err);\n }\n }\n\n public async getApp(): Promise<App> {\n await this.connectPromise;\n return this.app;\n }\n\n public static getInstance(\n options?: Partial<{ appInfo: Implementation }>,\n ): McpAppBridge {\n if (window.skybridge.hostType !== \"mcp-app\") {\n throw new Error(\"MCP App Bridge can only be used in the mcp-app runtime\");\n }\n if (McpAppBridge.instance && options) {\n console.warn(\n \"McpAppBridge.getInstance: options ignored, instance already exists\",\n );\n }\n if (!McpAppBridge.instance) {\n const defaultOptions = {\n appInfo: { name: \"skybridge-app\", version: \"0.0.1\" },\n };\n McpAppBridge.instance = new McpAppBridge({\n ...defaultOptions,\n ...options,\n });\n }\n return McpAppBridge.instance;\n }\n\n public subscribe(key: McpAppContextKey): Subscribe;\n public subscribe(keys: readonly McpAppContextKey[]): Subscribe;\n public subscribe(\n keyOrKeys: McpAppContextKey | readonly McpAppContextKey[],\n ): Subscribe {\n const keys = Array.isArray(keyOrKeys) ? keyOrKeys : [keyOrKeys];\n return (onChange: () => void) => {\n for (const key of keys) {\n this.listeners.set(\n key,\n new Set([...(this.listeners.get(key) || []), onChange]),\n );\n }\n return () => {\n for (const key of keys) {\n this.listeners.get(key)?.delete(onChange);\n }\n };\n };\n }\n\n public getSnapshot<K extends keyof McpAppContext>(key: K): McpAppContext[K] {\n return this.context[key];\n }\n\n public cleanup = () => {\n this.listeners.clear();\n };\n\n public static resetInstance(): void {\n if (McpAppBridge.instance) {\n McpAppBridge.instance.cleanup();\n McpAppBridge.instance = null;\n }\n }\n\n private emit(key: McpAppContextKey) {\n this.listeners.get(key)?.forEach((listener) => {\n listener();\n });\n }\n\n private updateContext(context: Partial<McpAppContext>) {\n this.context = { ...this.context, ...context };\n for (const key of Object.keys(context)) {\n this.emit(key);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"bridge.js","sourceRoot":"","sources":["../../../../src/web/bridges/mcp-app/bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,gCAAgC,CAAC;AACrD,OAAO,EAEL,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AASzB,qGAAqG;AACrG,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,GAAG,CAAM;IACT,cAAc,CAAgB;IAEtC,YAAY,OAAoC;QAC9C,IAAI,CAAC,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;QAEtE,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;YAC9D,KAAK,EAAE,EAAE;SACV,CAAC,CAAC,CAAC;QAEJ,IAAI,CAAC,GAAG,CAAC,WAAW,GAAG,CAAC,MAAM,EAAE,EAAE;YAChC,IAAI,CAAC,aAAa,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,EAAE,EAAE,CAAC,CAAC;QAC5D,CAAC,CAAC;QAEF,IAAI,CAAC,GAAG,CAAC,kBAAkB,GAAG,CAAC,MAAM,EAAE,EAAE;YACvC,IAAI,CAAC,aAAa,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,SA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QAC/C,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;YACvC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACjB,CAAC;IACH,CAAC","sourcesContent":["import { App } from \"@modelcontextprotocol/ext-apps\";\nimport {\n type Implementation,\n ListToolsRequestSchema,\n} from \"@modelcontextprotocol/sdk/types.js\";\nimport * as z from \"zod\";\nimport type {\n AnyViewToolHandler,\n Bridge,\n Subscribe,\n ViewToolConfig,\n} from \"../types.js\";\nimport type { McpAppContext, McpAppContextKey } from \"./types.js\";\n\n/** @internal Singleton bridge over the `ext-apps` JSON-RPC App connection. Used by `HostAdaptor`. */\nexport class McpAppBridge implements Bridge<McpAppContext> {\n private static instance: McpAppBridge | null = null;\n public context: McpAppContext = {\n toolInput: null,\n toolCancelled: null,\n toolResult: null,\n };\n private listeners = new Map<McpAppContextKey, Set<() => void>>();\n private app: App;\n private connectPromise: Promise<void>;\n\n constructor(options: { appInfo: Implementation }) {\n this.app = new App(options.appInfo, { tools: { listChanged: true } });\n\n this.app.setRequestHandler(ListToolsRequestSchema, async () => ({\n tools: [],\n }));\n\n this.app.ontoolinput = (params) => {\n this.updateContext({ toolInput: params.arguments ?? {} });\n };\n\n this.app.ontoolinputpartial = (params) => {\n this.updateContext({ toolInput: params.arguments ?? {} });\n };\n\n this.app.ontoolresult = (params) => {\n this.updateContext({ toolResult: params });\n };\n\n this.app.ontoolcancelled = (params) => {\n this.updateContext({ toolCancelled: params });\n };\n\n this.app.onhostcontextchanged = (params) => {\n this.updateContext(params);\n };\n\n this.connectPromise = this.connect();\n }\n\n private async connect() {\n try {\n await this.app.connect();\n const hostContext = this.app.getHostContext();\n if (hostContext) {\n this.updateContext(hostContext);\n }\n } catch (err) {\n console.error(err);\n }\n }\n\n public async getApp(): Promise<App> {\n await this.connectPromise;\n return this.app;\n }\n\n public registerViewTool(\n config: ViewToolConfig,\n handler: AnyViewToolHandler,\n ): () => void {\n const inputSchema = config.inputSchema\n ? z.object(config.inputSchema)\n : z.object({});\n\n const registered = this.app.registerTool(\n config.name,\n {\n ...(config.title !== undefined ? { title: config.title } : {}),\n ...(config.description !== undefined\n ? { description: config.description }\n : {}),\n inputSchema,\n ...(config.annotations ? { annotations: config.annotations } : {}),\n },\n handler,\n );\n\n return () => {\n registered.remove();\n };\n }\n\n public static getInstance(\n options?: Partial<{ appInfo: Implementation }>,\n ): McpAppBridge {\n if (McpAppBridge.instance && options) {\n console.warn(\n \"McpAppBridge.getInstance: options ignored, instance already exists\",\n );\n }\n if (!McpAppBridge.instance) {\n const defaultOptions = {\n appInfo: { name: \"skybridge-app\", version: \"0.0.1\" },\n };\n McpAppBridge.instance = new McpAppBridge({\n ...defaultOptions,\n ...options,\n });\n }\n return McpAppBridge.instance;\n }\n\n public subscribe(key: McpAppContextKey): Subscribe;\n public subscribe(keys: readonly McpAppContextKey[]): Subscribe;\n public subscribe(\n keyOrKeys: McpAppContextKey | readonly McpAppContextKey[],\n ): Subscribe {\n const keys = Array.isArray(keyOrKeys) ? keyOrKeys : [keyOrKeys];\n return (onChange: () => void) => {\n for (const key of keys) {\n this.listeners.set(\n key,\n new Set([...(this.listeners.get(key) || []), onChange]),\n );\n }\n return () => {\n for (const key of keys) {\n this.listeners.get(key)?.delete(onChange);\n }\n };\n };\n }\n\n public getSnapshot<K extends keyof McpAppContext>(key: K): McpAppContext[K] {\n return this.context[key];\n }\n\n public cleanup = () => {\n this.listeners.clear();\n };\n\n public static resetInstance(): void {\n if (McpAppBridge.instance) {\n McpAppBridge.instance.cleanup();\n McpAppBridge.instance = null;\n }\n }\n\n private emit(key: McpAppContextKey) {\n this.listeners.get(key)?.forEach((listener) => {\n listener();\n });\n }\n\n private updateContext(context: Partial<McpAppContext>) {\n this.context = { ...this.context, ...context };\n for (const key of Object.keys(context)) {\n this.emit(key);\n }\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -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 regardless of injected hostType", () => {
13
+ vi.stubGlobal("skybridge", { hostType: "apps-sdk" });
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,8CAA8C,EAAE,GAAG,EAAE;QACtD,EAAE,CAAC,UAAU,CAAC,WAAW,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAC;QACrD,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 regardless of injected hostType\", () => {\n vi.stubGlobal(\"skybridge\", { hostType: \"apps-sdk\" });\n expect(() => McpAppBridge.getInstance()).not.toThrow();\n });\n});\n"]}
@@ -1,4 +1,3 @@
1
- export { McpAppAdaptor } from "./adaptor.js";
2
1
  export { McpAppBridge } from "./bridge.js";
3
2
  export type { McpAppContext, McpAppContextKey, McpToolState, } from "./types.js";
4
3
  export { useMcpAppContext } from "./use-mcp-app-context.js";
@@ -1,4 +1,3 @@
1
- export { McpAppAdaptor } from "./adaptor.js";
2
1
  export { McpAppBridge } from "./bridge.js";
3
2
  export { useMcpAppContext } from "./use-mcp-app-context.js";
4
3
  //# sourceMappingURL=index.js.map
@@ -1 +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","sourcesContent":["export { McpAppAdaptor } from \"./adaptor.js\";\nexport { 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"]}
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"]}
@@ -3,5 +3,17 @@ import type { McpAppContext } from "./types.js";
3
3
  type McpAppInitializationOptions = {
4
4
  appInfo: Implementation;
5
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
+ * `useLayout`, 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
+ */
6
18
  export declare function useMcpAppContext<K extends keyof McpAppContext>(key: K, options?: Partial<McpAppInitializationOptions>): McpAppContext[K];
7
19
  export {};
@@ -1,5 +1,17 @@
1
1
  import { useSyncExternalStore } from "react";
2
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
+ * `useLayout`, 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
+ */
3
15
  export function useMcpAppContext(key, options) {
4
16
  const bridge = McpAppBridge.getInstance(options);
5
17
  return useSyncExternalStore(bridge.subscribe(key), () => bridge.getSnapshot(key));
@@ -1 +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,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\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"]}
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 * `useLayout`, 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 @@
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", { hostType: "mcp-app" });
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