skybridge 0.0.0-dev.f1ff41a → 0.0.0-dev.f2073a1

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 (531) hide show
  1. package/README.md +126 -115
  2. package/dist/cli/build-helpers.d.ts +11 -0
  3. package/dist/cli/build-helpers.js +107 -0
  4. package/dist/cli/build-helpers.js.map +1 -0
  5. package/dist/cli/build-helpers.test.js +132 -0
  6. package/dist/cli/build-helpers.test.js.map +1 -0
  7. package/dist/cli/build-steps.d.ts +2 -0
  8. package/dist/cli/build-steps.js +73 -0
  9. package/dist/cli/build-steps.js.map +1 -0
  10. package/dist/cli/build-steps.test.js +52 -0
  11. package/dist/cli/build-steps.test.js.map +1 -0
  12. package/dist/cli/detect-port.d.ts +18 -0
  13. package/dist/cli/detect-port.js +49 -0
  14. package/dist/cli/detect-port.js.map +1 -0
  15. package/dist/cli/header.d.ts +1 -1
  16. package/dist/cli/header.js +1 -1
  17. package/dist/cli/header.js.map +1 -1
  18. package/dist/cli/resolve-skybridge-config.d.ts +5 -0
  19. package/dist/cli/resolve-skybridge-config.js +18 -0
  20. package/dist/cli/resolve-skybridge-config.js.map +1 -0
  21. package/dist/cli/run-command.js.map +1 -1
  22. package/dist/cli/run-plain.d.ts +18 -0
  23. package/dist/cli/run-plain.js +90 -0
  24. package/dist/cli/run-plain.js.map +1 -0
  25. package/dist/cli/telemetry.js +2 -0
  26. package/dist/cli/telemetry.js.map +1 -1
  27. package/dist/cli/tunnel-control-server.d.ts +9 -0
  28. package/dist/cli/tunnel-control-server.js +31 -0
  29. package/dist/cli/tunnel-control-server.js.map +1 -0
  30. package/dist/cli/tunnel-control-server.test.js +39 -0
  31. package/dist/cli/tunnel-control-server.test.js.map +1 -0
  32. package/dist/cli/tunnel-handler.d.ts +3 -0
  33. package/dist/cli/tunnel-handler.js +48 -0
  34. package/dist/cli/tunnel-handler.js.map +1 -0
  35. package/dist/cli/tunnel-handler.test.js +105 -0
  36. package/dist/cli/tunnel-handler.test.js.map +1 -0
  37. package/dist/cli/tunnel.d.ts +57 -0
  38. package/dist/cli/tunnel.js +154 -0
  39. package/dist/cli/tunnel.js.map +1 -0
  40. package/dist/cli/tunnel.test.js +190 -0
  41. package/dist/cli/tunnel.test.js.map +1 -0
  42. package/dist/cli/types.d.ts +5 -0
  43. package/dist/cli/types.js +2 -0
  44. package/dist/cli/types.js.map +1 -0
  45. package/dist/cli/use-execute-steps.d.ts +1 -1
  46. package/dist/cli/use-execute-steps.js.map +1 -1
  47. package/dist/cli/use-messages.d.ts +3 -0
  48. package/dist/cli/use-messages.js +11 -0
  49. package/dist/cli/use-messages.js.map +1 -0
  50. package/dist/cli/use-nodemon.d.ts +26 -6
  51. package/dist/cli/use-nodemon.js +99 -54
  52. package/dist/cli/use-nodemon.js.map +1 -1
  53. package/dist/cli/use-open-browser.d.ts +1 -0
  54. package/dist/cli/use-open-browser.js +44 -0
  55. package/dist/cli/use-open-browser.js.map +1 -0
  56. package/dist/cli/use-tunnel.d.ts +14 -0
  57. package/dist/cli/use-tunnel.js +131 -0
  58. package/dist/cli/use-tunnel.js.map +1 -0
  59. package/dist/cli/use-typescript-check.d.ts +9 -2
  60. package/dist/cli/use-typescript-check.js +89 -51
  61. package/dist/cli/use-typescript-check.js.map +1 -1
  62. package/dist/commands/build.d.ts +0 -3
  63. package/dist/commands/build.js +3 -18
  64. package/dist/commands/build.js.map +1 -1
  65. package/dist/commands/create.d.ts +9 -0
  66. package/dist/commands/create.js +30 -0
  67. package/dist/commands/create.js.map +1 -0
  68. package/dist/commands/dev.d.ts +5 -1
  69. package/dist/commands/dev.js +106 -9
  70. package/dist/commands/dev.js.map +1 -1
  71. package/dist/commands/start.d.ts +3 -1
  72. package/dist/commands/start.js +36 -9
  73. package/dist/commands/start.js.map +1 -1
  74. package/dist/commands/telemetry/disable.js.map +1 -1
  75. package/dist/commands/telemetry/enable.js.map +1 -1
  76. package/dist/commands/telemetry/status.js.map +1 -1
  77. package/dist/context-warnings.d.ts +5 -0
  78. package/dist/context-warnings.js +31 -0
  79. package/dist/context-warnings.js.map +1 -0
  80. package/dist/context-warnings.test.d.ts +1 -0
  81. package/dist/context-warnings.test.js +28 -0
  82. package/dist/context-warnings.test.js.map +1 -0
  83. package/dist/server/app.d.ts +194 -0
  84. package/dist/server/app.js +266 -0
  85. package/dist/server/app.js.map +1 -0
  86. package/dist/server/app.test.d.ts +1 -0
  87. package/dist/server/app.test.js +97 -0
  88. package/dist/server/app.test.js.map +1 -0
  89. package/dist/server/asset-base-url-transform-plugin.d.ts +6 -6
  90. package/dist/server/asset-base-url-transform-plugin.js +25 -11
  91. package/dist/server/asset-base-url-transform-plugin.js.map +1 -1
  92. package/dist/server/asset-base-url-transform-plugin.test.js +92 -14
  93. package/dist/server/asset-base-url-transform-plugin.test.js.map +1 -1
  94. package/dist/server/auth/discovery.d.ts +33 -0
  95. package/dist/server/auth/discovery.js +56 -0
  96. package/dist/server/auth/discovery.js.map +1 -0
  97. package/dist/server/auth/discovery.test.d.ts +1 -0
  98. package/dist/server/auth/discovery.test.js +93 -0
  99. package/dist/server/auth/discovery.test.js.map +1 -0
  100. package/dist/server/auth/index.d.ts +48 -0
  101. package/dist/server/auth/index.js +2 -0
  102. package/dist/server/auth/index.js.map +1 -0
  103. package/dist/server/auth/providers/auth0.d.ts +40 -0
  104. package/dist/server/auth/providers/auth0.js +36 -0
  105. package/dist/server/auth/providers/auth0.js.map +1 -0
  106. package/dist/server/auth/providers/auth0.test.d.ts +1 -0
  107. package/dist/server/auth/providers/auth0.test.js +50 -0
  108. package/dist/server/auth/providers/auth0.test.js.map +1 -0
  109. package/dist/server/auth/providers/authplane.d.ts +49 -0
  110. package/dist/server/auth/providers/authplane.js +57 -0
  111. package/dist/server/auth/providers/authplane.js.map +1 -0
  112. package/dist/server/auth/providers/authplane.test.d.ts +1 -0
  113. package/dist/server/auth/providers/authplane.test.js +143 -0
  114. package/dist/server/auth/providers/authplane.test.js.map +1 -0
  115. package/dist/server/auth/providers/clerk.d.ts +51 -0
  116. package/dist/server/auth/providers/clerk.js +19 -0
  117. package/dist/server/auth/providers/clerk.js.map +1 -0
  118. package/dist/server/auth/providers/clerk.test.d.ts +1 -0
  119. package/dist/server/auth/providers/clerk.test.js +30 -0
  120. package/dist/server/auth/providers/clerk.test.js.map +1 -0
  121. package/dist/server/auth/providers/custom.d.ts +42 -0
  122. package/dist/server/auth/providers/custom.js +59 -0
  123. package/dist/server/auth/providers/custom.js.map +1 -0
  124. package/dist/server/auth/providers/custom.test.d.ts +1 -0
  125. package/dist/server/auth/providers/custom.test.js +161 -0
  126. package/dist/server/auth/providers/custom.test.js.map +1 -0
  127. package/dist/server/auth/providers/descope.d.ts +44 -0
  128. package/dist/server/auth/providers/descope.js +44 -0
  129. package/dist/server/auth/providers/descope.js.map +1 -0
  130. package/dist/server/auth/providers/descope.test.d.ts +1 -0
  131. package/dist/server/auth/providers/descope.test.js +62 -0
  132. package/dist/server/auth/providers/descope.test.js.map +1 -0
  133. package/dist/server/auth/providers/shared.d.ts +2 -0
  134. package/dist/server/auth/providers/shared.js +6 -0
  135. package/dist/server/auth/providers/shared.js.map +1 -0
  136. package/dist/server/auth/providers/shared.test.d.ts +1 -0
  137. package/dist/server/auth/providers/shared.test.js +10 -0
  138. package/dist/server/auth/providers/shared.test.js.map +1 -0
  139. package/dist/server/auth/providers/stytch.d.ts +25 -0
  140. package/dist/server/auth/providers/stytch.js +16 -0
  141. package/dist/server/auth/providers/stytch.js.map +1 -0
  142. package/dist/server/auth/providers/verify-spy.d.ts +12 -0
  143. package/dist/server/auth/providers/verify-spy.js +21 -0
  144. package/dist/server/auth/providers/verify-spy.js.map +1 -0
  145. package/dist/server/auth/providers/workos.d.ts +34 -0
  146. package/dist/server/auth/providers/workos.js +16 -0
  147. package/dist/server/auth/providers/workos.js.map +1 -0
  148. package/dist/server/auth/security-schemes.d.ts +23 -0
  149. package/dist/server/auth/security-schemes.js +64 -0
  150. package/dist/server/auth/security-schemes.js.map +1 -0
  151. package/dist/server/auth/security-schemes.test.d.ts +1 -0
  152. package/dist/server/auth/security-schemes.test.js +99 -0
  153. package/dist/server/auth/security-schemes.test.js.map +1 -0
  154. package/dist/server/auth/setup.d.ts +6 -0
  155. package/dist/server/auth/setup.js +91 -0
  156. package/dist/server/auth/setup.js.map +1 -0
  157. package/dist/server/auth/setup.test.d.ts +1 -0
  158. package/dist/server/auth/setup.test.js +514 -0
  159. package/dist/server/auth/setup.test.js.map +1 -0
  160. package/dist/server/auth/verify.d.ts +48 -0
  161. package/dist/server/auth/verify.js +62 -0
  162. package/dist/server/auth/verify.js.map +1 -0
  163. package/dist/server/auth/verify.test.d.ts +1 -0
  164. package/dist/server/auth/verify.test.js +165 -0
  165. package/dist/server/auth/verify.test.js.map +1 -0
  166. package/dist/server/auth-extra.test-d.d.ts +1 -0
  167. package/dist/server/auth-extra.test-d.js +130 -0
  168. package/dist/server/auth-extra.test-d.js.map +1 -0
  169. package/dist/server/auth.d.ts +57 -0
  170. package/dist/server/auth.js +27 -0
  171. package/dist/server/auth.js.map +1 -0
  172. package/dist/server/build-manifest.test.d.ts +1 -0
  173. package/dist/server/build-manifest.test.js +28 -0
  174. package/dist/server/build-manifest.test.js.map +1 -0
  175. package/dist/server/content-helpers.d.ts +67 -0
  176. package/dist/server/content-helpers.js +79 -0
  177. package/dist/server/content-helpers.js.map +1 -0
  178. package/dist/server/content-helpers.test.d.ts +1 -0
  179. package/dist/server/content-helpers.test.js +70 -0
  180. package/dist/server/content-helpers.test.js.map +1 -0
  181. package/dist/server/events.d.ts +113 -0
  182. package/dist/server/events.js +318 -0
  183. package/dist/server/events.js.map +1 -0
  184. package/dist/server/events.test.d.ts +1 -0
  185. package/dist/server/events.test.js +172 -0
  186. package/dist/server/events.test.js.map +1 -0
  187. package/dist/server/express.d.ts +31 -0
  188. package/dist/server/express.js +112 -0
  189. package/dist/server/express.js.map +1 -0
  190. package/dist/server/express.test.d.ts +1 -0
  191. package/dist/server/express.test.js +609 -0
  192. package/dist/server/express.test.js.map +1 -0
  193. package/dist/server/file-ref.d.ts +28 -0
  194. package/dist/server/file-ref.js +27 -0
  195. package/dist/server/file-ref.js.map +1 -0
  196. package/dist/server/form-input.d.ts +120 -0
  197. package/dist/server/form-input.js +89 -0
  198. package/dist/server/form-input.js.map +1 -0
  199. package/dist/server/host.d.ts +2 -0
  200. package/dist/server/host.js +11 -0
  201. package/dist/server/host.js.map +1 -0
  202. package/dist/server/host.test.d.ts +1 -0
  203. package/dist/server/host.test.js +13 -0
  204. package/dist/server/host.test.js.map +1 -0
  205. package/dist/server/index.d.ts +23 -3
  206. package/dist/server/index.js +19 -2
  207. package/dist/server/index.js.map +1 -1
  208. package/dist/server/inferUtilityTypes.d.ts +6 -6
  209. package/dist/server/inferUtilityTypes.js.map +1 -1
  210. package/dist/server/mcp-errors.test.d.ts +1 -0
  211. package/dist/server/mcp-errors.test.js +41 -0
  212. package/dist/server/mcp-errors.test.js.map +1 -0
  213. package/dist/server/metric.d.ts +14 -0
  214. package/dist/server/metric.js +62 -0
  215. package/dist/server/metric.js.map +1 -0
  216. package/dist/server/middleware.d.ts +162 -0
  217. package/dist/server/middleware.js +126 -0
  218. package/dist/server/middleware.js.map +1 -0
  219. package/dist/server/middleware.test-d.d.ts +1 -0
  220. package/dist/server/middleware.test-d.js +75 -0
  221. package/dist/server/middleware.test-d.js.map +1 -0
  222. package/dist/server/middleware.test.d.ts +1 -0
  223. package/dist/server/middleware.test.js +601 -0
  224. package/dist/server/middleware.test.js.map +1 -0
  225. package/dist/server/register-tool.test.d.ts +1 -0
  226. package/dist/server/register-tool.test.js +230 -0
  227. package/dist/server/register-tool.test.js.map +1 -0
  228. package/dist/server/requestOrigin.d.ts +7 -0
  229. package/dist/server/requestOrigin.js +25 -0
  230. package/dist/server/requestOrigin.js.map +1 -0
  231. package/dist/server/server.d.ts +629 -64
  232. package/dist/server/server.js +767 -121
  233. package/dist/server/server.js.map +1 -1
  234. package/dist/server/skills-integration.test.d.ts +1 -0
  235. package/dist/server/skills-integration.test.js +86 -0
  236. package/dist/server/skills-integration.test.js.map +1 -0
  237. package/dist/server/skills.d.ts +27 -0
  238. package/dist/server/skills.js +188 -0
  239. package/dist/server/skills.js.map +1 -0
  240. package/dist/server/skills.test.d.ts +1 -0
  241. package/dist/server/skills.test.js +243 -0
  242. package/dist/server/skills.test.js.map +1 -0
  243. package/dist/server/templateHelper.d.ts +2 -8
  244. package/dist/server/templateHelper.js +3 -22
  245. package/dist/server/templateHelper.js.map +1 -1
  246. package/dist/server/templates.generated.d.ts +4 -0
  247. package/dist/server/templates.generated.js +43 -0
  248. package/dist/server/templates.generated.js.map +1 -0
  249. package/dist/server/tool-extra.test.d.ts +1 -0
  250. package/dist/server/tool-extra.test.js +167 -0
  251. package/dist/server/tool-extra.test.js.map +1 -0
  252. package/dist/server/tunnel-proxy-router.d.ts +7 -0
  253. package/dist/server/tunnel-proxy-router.js +110 -0
  254. package/dist/server/tunnel-proxy-router.js.map +1 -0
  255. package/dist/server/tunnel-proxy-router.test.d.ts +1 -0
  256. package/dist/server/tunnel-proxy-router.test.js +229 -0
  257. package/dist/server/tunnel-proxy-router.test.js.map +1 -0
  258. package/dist/server/view-name.test-d.d.ts +1 -0
  259. package/dist/server/view-name.test-d.js +8 -0
  260. package/dist/server/view-name.test-d.js.map +1 -0
  261. package/dist/server/view-resource-resolution.test.d.ts +6 -0
  262. package/dist/server/view-resource-resolution.test.js +176 -0
  263. package/dist/server/view-resource-resolution.test.js.map +1 -0
  264. package/dist/server/viewsDevServer.d.ts +14 -0
  265. package/dist/server/viewsDevServer.js +48 -0
  266. package/dist/server/viewsDevServer.js.map +1 -0
  267. package/dist/test/utils.d.ts +21 -31
  268. package/dist/test/utils.js +222 -198
  269. package/dist/test/utils.js.map +1 -1
  270. package/dist/test/view.test.d.ts +1 -0
  271. package/dist/test/view.test.js +540 -0
  272. package/dist/test/view.test.js.map +1 -0
  273. package/dist/version.d.ts +1 -0
  274. package/dist/version.js +3 -0
  275. package/dist/version.js.map +1 -0
  276. package/dist/views/index.d.ts +10 -0
  277. package/dist/views/index.js +3 -0
  278. package/dist/views/index.js.map +1 -0
  279. package/dist/views/scan-views.d.ts +16 -0
  280. package/dist/views/scan-views.js +88 -0
  281. package/dist/views/scan-views.js.map +1 -0
  282. package/dist/views/scan-views.test.d.ts +1 -0
  283. package/dist/views/scan-views.test.js +99 -0
  284. package/dist/views/scan-views.test.js.map +1 -0
  285. package/dist/views/validate-view.d.ts +1 -0
  286. package/dist/views/validate-view.js +9 -0
  287. package/dist/views/validate-view.js.map +1 -0
  288. package/dist/views/validate-view.test.d.ts +1 -0
  289. package/dist/views/validate-view.test.js +24 -0
  290. package/dist/views/validate-view.test.js.map +1 -0
  291. package/dist/web/bridges/adaptor.d.ts +62 -0
  292. package/dist/web/bridges/adaptor.js +471 -0
  293. package/dist/web/bridges/adaptor.js.map +1 -0
  294. package/dist/web/bridges/adaptor.test.d.ts +1 -0
  295. package/dist/web/bridges/adaptor.test.js +264 -0
  296. package/dist/web/bridges/adaptor.test.js.map +1 -0
  297. package/dist/web/bridges/apps-sdk/bridge.d.ts +7 -2
  298. package/dist/web/bridges/apps-sdk/bridge.js +15 -3
  299. package/dist/web/bridges/apps-sdk/bridge.js.map +1 -1
  300. package/dist/web/bridges/apps-sdk/index.d.ts +1 -2
  301. package/dist/web/bridges/apps-sdk/index.js +0 -1
  302. package/dist/web/bridges/apps-sdk/index.js.map +1 -1
  303. package/dist/web/bridges/apps-sdk/types.d.ts +32 -14
  304. package/dist/web/bridges/apps-sdk/types.js.map +1 -1
  305. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.d.ts +11 -0
  306. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js +11 -0
  307. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js.map +1 -1
  308. package/dist/web/bridges/get-adaptor.d.ts +7 -0
  309. package/dist/web/bridges/get-adaptor.js +9 -7
  310. package/dist/web/bridges/get-adaptor.js.map +1 -1
  311. package/dist/web/bridges/get-adaptor.test.d.ts +1 -0
  312. package/dist/web/bridges/get-adaptor.test.js +32 -0
  313. package/dist/web/bridges/get-adaptor.test.js.map +1 -0
  314. package/dist/web/bridges/index.js.map +1 -1
  315. package/dist/web/bridges/mcp-app/bridge.d.ts +27 -31
  316. package/dist/web/bridges/mcp-app/bridge.js +118 -198
  317. package/dist/web/bridges/mcp-app/bridge.js.map +1 -1
  318. package/dist/web/bridges/mcp-app/bridge.test.d.ts +1 -0
  319. package/dist/web/bridges/mcp-app/bridge.test.js +17 -0
  320. package/dist/web/bridges/mcp-app/bridge.test.js.map +1 -0
  321. package/dist/web/bridges/mcp-app/index.d.ts +0 -1
  322. package/dist/web/bridges/mcp-app/index.js +0 -1
  323. package/dist/web/bridges/mcp-app/index.js.map +1 -1
  324. package/dist/web/bridges/mcp-app/types.d.ts +19 -2
  325. package/dist/web/bridges/mcp-app/types.js.map +1 -1
  326. package/dist/web/bridges/mcp-app/use-mcp-app-context.d.ts +17 -3
  327. package/dist/web/bridges/mcp-app/use-mcp-app-context.js +14 -2
  328. package/dist/web/bridges/mcp-app/use-mcp-app-context.js.map +1 -1
  329. package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js +2 -42
  330. package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js.map +1 -1
  331. package/dist/web/bridges/mcp-app/view-tools.test.d.ts +1 -0
  332. package/dist/web/bridges/mcp-app/view-tools.test.js +143 -0
  333. package/dist/web/bridges/mcp-app/view-tools.test.js.map +1 -0
  334. package/dist/web/bridges/types.d.ts +189 -15
  335. package/dist/web/bridges/types.js +14 -1
  336. package/dist/web/bridges/types.js.map +1 -1
  337. package/dist/web/bridges/types.test.d.ts +1 -0
  338. package/dist/web/bridges/types.test.js +19 -0
  339. package/dist/web/bridges/types.test.js.map +1 -0
  340. package/dist/web/bridges/use-host-context.d.ts +5 -0
  341. package/dist/web/bridges/use-host-context.js +5 -0
  342. package/dist/web/bridges/use-host-context.js.map +1 -1
  343. package/dist/web/components/modal-provider.d.ts +1 -1
  344. package/dist/web/components/modal-provider.js +5 -6
  345. package/dist/web/components/modal-provider.js.map +1 -1
  346. package/dist/web/create-store.d.ts +26 -0
  347. package/dist/web/create-store.js +43 -3
  348. package/dist/web/create-store.js.map +1 -1
  349. package/dist/web/create-store.test.js +33 -27
  350. package/dist/web/create-store.test.js.map +1 -1
  351. package/dist/web/data-llm.d.ts +35 -2
  352. package/dist/web/data-llm.js +34 -5
  353. package/dist/web/data-llm.js.map +1 -1
  354. package/dist/web/data-llm.test.js +59 -37
  355. package/dist/web/data-llm.test.js.map +1 -1
  356. package/dist/web/generate-helpers.d.ts +40 -32
  357. package/dist/web/generate-helpers.js +38 -30
  358. package/dist/web/generate-helpers.js.map +1 -1
  359. package/dist/web/generate-helpers.test-d.js +33 -31
  360. package/dist/web/generate-helpers.test-d.js.map +1 -1
  361. package/dist/web/generate-helpers.test.js +2 -2
  362. package/dist/web/generate-helpers.test.js.map +1 -1
  363. package/dist/web/helpers/state.d.ts +2 -2
  364. package/dist/web/helpers/state.js +11 -11
  365. package/dist/web/helpers/state.js.map +1 -1
  366. package/dist/web/helpers/state.test.js +9 -9
  367. package/dist/web/helpers/state.test.js.map +1 -1
  368. package/dist/web/hooks/index.d.ts +12 -3
  369. package/dist/web/hooks/index.js +11 -2
  370. package/dist/web/hooks/index.js.map +1 -1
  371. package/dist/web/hooks/openai-extensions.test.d.ts +1 -0
  372. package/dist/web/hooks/openai-extensions.test.js +107 -0
  373. package/dist/web/hooks/openai-extensions.test.js.map +1 -0
  374. package/dist/web/hooks/test/utils.d.ts +7 -2
  375. package/dist/web/hooks/test/utils.js +18 -3
  376. package/dist/web/hooks/test/utils.js.map +1 -1
  377. package/dist/web/hooks/use-call-tool.d.ts +47 -2
  378. package/dist/web/hooks/use-call-tool.js +43 -10
  379. package/dist/web/hooks/use-call-tool.js.map +1 -1
  380. package/dist/web/hooks/use-call-tool.test-d.js.map +1 -1
  381. package/dist/web/hooks/use-call-tool.test.js +75 -29
  382. package/dist/web/hooks/use-call-tool.test.js.map +1 -1
  383. package/dist/web/hooks/use-deep-link.d.ts +22 -0
  384. package/dist/web/hooks/use-deep-link.js +34 -0
  385. package/dist/web/hooks/use-deep-link.js.map +1 -0
  386. package/dist/web/hooks/use-display-mode.d.ts +23 -3
  387. package/dist/web/hooks/use-display-mode.js +20 -0
  388. package/dist/web/hooks/use-display-mode.js.map +1 -1
  389. package/dist/web/hooks/use-display-mode.test-d.d.ts +1 -0
  390. package/dist/web/hooks/use-display-mode.test-d.js +8 -0
  391. package/dist/web/hooks/use-display-mode.test-d.js.map +1 -0
  392. package/dist/web/hooks/use-display-mode.test.js +57 -21
  393. package/dist/web/hooks/use-display-mode.test.js.map +1 -1
  394. package/dist/web/hooks/use-download.d.ts +3 -0
  395. package/dist/web/hooks/use-download.js +7 -0
  396. package/dist/web/hooks/use-download.js.map +1 -0
  397. package/dist/web/hooks/use-download.test.d.ts +1 -0
  398. package/dist/web/hooks/use-download.test.js +103 -0
  399. package/dist/web/hooks/use-download.test.js.map +1 -0
  400. package/dist/web/hooks/use-file-resource.d.ts +37 -0
  401. package/dist/web/hooks/use-file-resource.js +98 -0
  402. package/dist/web/hooks/use-file-resource.js.map +1 -0
  403. package/dist/web/hooks/use-file-resource.test.d.ts +1 -0
  404. package/dist/web/hooks/use-file-resource.test.js +65 -0
  405. package/dist/web/hooks/use-file-resource.test.js.map +1 -0
  406. package/dist/web/hooks/use-files.d.ts +34 -1
  407. package/dist/web/hooks/use-files.js +33 -0
  408. package/dist/web/hooks/use-files.js.map +1 -1
  409. package/dist/web/hooks/use-files.test.js +36 -4
  410. package/dist/web/hooks/use-files.test.js.map +1 -1
  411. package/dist/web/hooks/use-host.d.ts +44 -0
  412. package/dist/web/hooks/use-host.js +45 -0
  413. package/dist/web/hooks/use-host.js.map +1 -0
  414. package/dist/web/hooks/use-host.test.d.ts +1 -0
  415. package/dist/web/hooks/use-host.test.js +59 -0
  416. package/dist/web/hooks/use-host.test.js.map +1 -0
  417. package/dist/web/hooks/use-model-context.d.ts +44 -0
  418. package/dist/web/hooks/use-model-context.js +63 -0
  419. package/dist/web/hooks/use-model-context.js.map +1 -0
  420. package/dist/web/hooks/use-open-external.d.ts +20 -1
  421. package/dist/web/hooks/use-open-external.js +17 -1
  422. package/dist/web/hooks/use-open-external.js.map +1 -1
  423. package/dist/web/hooks/use-open-external.test.js +40 -15
  424. package/dist/web/hooks/use-open-external.test.js.map +1 -1
  425. package/dist/web/hooks/use-open-file.d.ts +20 -0
  426. package/dist/web/hooks/use-open-file.js +25 -0
  427. package/dist/web/hooks/use-open-file.js.map +1 -0
  428. package/dist/web/hooks/use-register-view-tool.d.ts +37 -0
  429. package/dist/web/hooks/use-register-view-tool.js +50 -0
  430. package/dist/web/hooks/use-register-view-tool.js.map +1 -0
  431. package/dist/web/hooks/use-request-close.d.ts +16 -0
  432. package/dist/web/hooks/use-request-close.js +21 -0
  433. package/dist/web/hooks/use-request-close.js.map +1 -0
  434. package/dist/web/hooks/use-request-close.test.d.ts +1 -0
  435. package/dist/web/hooks/use-request-close.test.js +47 -0
  436. package/dist/web/hooks/use-request-close.test.js.map +1 -0
  437. package/dist/web/hooks/use-request-modal.d.ts +16 -1
  438. package/dist/web/hooks/use-request-modal.js +19 -4
  439. package/dist/web/hooks/use-request-modal.js.map +1 -1
  440. package/dist/web/hooks/use-request-modal.test.js +16 -2
  441. package/dist/web/hooks/use-request-modal.test.js.map +1 -1
  442. package/dist/web/hooks/use-request-size.d.ts +20 -0
  443. package/dist/web/hooks/use-request-size.js +24 -0
  444. package/dist/web/hooks/use-request-size.js.map +1 -0
  445. package/dist/web/hooks/use-request-size.test.d.ts +1 -0
  446. package/dist/web/hooks/use-request-size.test.js +47 -0
  447. package/dist/web/hooks/use-request-size.test.js.map +1 -0
  448. package/dist/web/hooks/use-send-follow-up-message.d.ts +25 -1
  449. package/dist/web/hooks/use-send-follow-up-message.js +25 -2
  450. package/dist/web/hooks/use-send-follow-up-message.js.map +1 -1
  451. package/dist/web/hooks/use-set-open-in-app-url.d.ts +17 -0
  452. package/dist/web/hooks/use-set-open-in-app-url.js +17 -0
  453. package/dist/web/hooks/use-set-open-in-app-url.js.map +1 -1
  454. package/dist/web/hooks/use-set-open-in-app-url.test.js +29 -21
  455. package/dist/web/hooks/use-set-open-in-app-url.test.js.map +1 -1
  456. package/dist/web/hooks/use-tool-info.d.ts +46 -14
  457. package/dist/web/hooks/use-tool-info.js +29 -7
  458. package/dist/web/hooks/use-tool-info.js.map +1 -1
  459. package/dist/web/hooks/use-tool-info.test-d.js +11 -34
  460. package/dist/web/hooks/use-tool-info.test-d.js.map +1 -1
  461. package/dist/web/hooks/use-tool-info.test.js +43 -38
  462. package/dist/web/hooks/use-tool-info.test.js.map +1 -1
  463. package/dist/web/hooks/use-user.d.ts +5 -2
  464. package/dist/web/hooks/use-user.js +23 -4
  465. package/dist/web/hooks/use-user.js.map +1 -1
  466. package/dist/web/hooks/use-user.test.js +105 -29
  467. package/dist/web/hooks/use-user.test.js.map +1 -1
  468. package/dist/web/hooks/use-view-state.d.ts +25 -0
  469. package/dist/web/hooks/use-view-state.js +42 -0
  470. package/dist/web/hooks/use-view-state.js.map +1 -0
  471. package/dist/web/hooks/use-view-state.test.d.ts +1 -0
  472. package/dist/web/hooks/use-view-state.test.js +212 -0
  473. package/dist/web/hooks/use-view-state.test.js.map +1 -0
  474. package/dist/web/hooks/use-viewport.d.ts +20 -0
  475. package/dist/web/hooks/use-viewport.js +21 -0
  476. package/dist/web/hooks/use-viewport.js.map +1 -0
  477. package/dist/web/hooks/use-viewport.test.d.ts +1 -0
  478. package/dist/web/hooks/use-viewport.test.js +109 -0
  479. package/dist/web/hooks/use-viewport.test.js.map +1 -0
  480. package/dist/web/index.d.ts +1 -2
  481. package/dist/web/index.js +1 -2
  482. package/dist/web/index.js.map +1 -1
  483. package/dist/web/mount-view.d.ts +21 -0
  484. package/dist/web/mount-view.js +43 -0
  485. package/dist/web/mount-view.js.map +1 -0
  486. package/dist/web/proxy.js.map +1 -1
  487. package/dist/web/types.d.ts +4 -0
  488. package/dist/web/types.js.map +1 -1
  489. package/package.json +55 -29
  490. package/tsconfig.base.json +33 -0
  491. package/dist/server/templates/development.hbs +0 -67
  492. package/dist/server/templates/production.hbs +0 -6
  493. package/dist/server/widgetsDevServer.d.ts +0 -12
  494. package/dist/server/widgetsDevServer.js +0 -57
  495. package/dist/server/widgetsDevServer.js.map +0 -1
  496. package/dist/test/widget.test.js +0 -255
  497. package/dist/test/widget.test.js.map +0 -1
  498. package/dist/web/bridges/apps-sdk/adaptor.d.ts +0 -22
  499. package/dist/web/bridges/apps-sdk/adaptor.js +0 -64
  500. package/dist/web/bridges/apps-sdk/adaptor.js.map +0 -1
  501. package/dist/web/bridges/mcp-app/adaptor.d.ts +0 -36
  502. package/dist/web/bridges/mcp-app/adaptor.js +0 -188
  503. package/dist/web/bridges/mcp-app/adaptor.js.map +0 -1
  504. package/dist/web/hooks/use-layout.d.ts +0 -22
  505. package/dist/web/hooks/use-layout.js +0 -23
  506. package/dist/web/hooks/use-layout.js.map +0 -1
  507. package/dist/web/hooks/use-layout.test.js +0 -96
  508. package/dist/web/hooks/use-layout.test.js.map +0 -1
  509. package/dist/web/hooks/use-widget-state.d.ts +0 -4
  510. package/dist/web/hooks/use-widget-state.js +0 -32
  511. package/dist/web/hooks/use-widget-state.js.map +0 -1
  512. package/dist/web/hooks/use-widget-state.test.js +0 -61
  513. package/dist/web/hooks/use-widget-state.test.js.map +0 -1
  514. package/dist/web/mount-widget.d.ts +0 -1
  515. package/dist/web/mount-widget.js +0 -27
  516. package/dist/web/mount-widget.js.map +0 -1
  517. package/dist/web/plugin/data-llm.test.js +0 -81
  518. package/dist/web/plugin/data-llm.test.js.map +0 -1
  519. package/dist/web/plugin/plugin.d.ts +0 -2
  520. package/dist/web/plugin/plugin.js +0 -46
  521. package/dist/web/plugin/plugin.js.map +0 -1
  522. package/dist/web/plugin/transform-data-llm.d.ts +0 -12
  523. package/dist/web/plugin/transform-data-llm.js +0 -96
  524. package/dist/web/plugin/transform-data-llm.js.map +0 -1
  525. package/dist/web/plugin/transform-data-llm.test.js +0 -81
  526. package/dist/web/plugin/transform-data-llm.test.js.map +0 -1
  527. /package/dist/{test/widget.test.d.ts → cli/build-helpers.test.d.ts} +0 -0
  528. /package/dist/{web/hooks/use-layout.test.d.ts → cli/build-steps.test.d.ts} +0 -0
  529. /package/dist/{web/hooks/use-widget-state.test.d.ts → cli/tunnel-control-server.test.d.ts} +0 -0
  530. /package/dist/{web/plugin/data-llm.test.d.ts → cli/tunnel-handler.test.d.ts} +0 -0
  531. /package/dist/{web/plugin/transform-data-llm.test.d.ts → cli/tunnel.test.d.ts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"use-open-external.test.js","sourceRoot":"","sources":["../../../src/web/hooks/use-open-external.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;QAC7B,IAAI,gBAA0C,CAAC;QAE/C,UAAU,CAAC,GAAG,EAAE;YACd,gBAAgB,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;YAC3B,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE;gBACtB,YAAY,EAAE,gBAAgB;aAC/B,CAAC,CAAC;YACH,EAAE,CAAC,UAAU,CAAC,WAAW,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAC;QACvD,CAAC,CAAC,CAAC;QAEH,SAAS,CAAC,GAAG,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AE,EAAE,GAAG,EAAE,IAAI,EAAE;iBACtB,CAAC,EACF,GAAG,CACJ,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { renderHook, waitFor } from \"@testing-library/react\";\nimport { afterEach, beforeEach, describe, expect, it, vi } from \"vitest\";\nimport { HostAdaptor } from \"../bridges/adaptor.js\";\nimport { McpAppBridge } from \"../bridges/mcp-app/bridge.js\";\nimport {\n getMcpAppHostPostMessageMock,\n MockResizeObserver,\n} from \"./test/utils.js\";\nimport { useOpenExternal } from \"./use-open-external.js\";\n\ndescribe(\"useOpenExternal\", () => {\n describe(\"apps-sdk host\", () => {\n let openExternalMock: ReturnType<typeof vi.fn>;\n let postMessageMock: ReturnType<typeof getMcpAppHostPostMessageMock>;\n\n beforeEach(() => {\n openExternalMock = vi.fn();\n vi.stubGlobal(\"openai\", {\n openExternal: openExternalMock,\n });\n vi.stubGlobal(\"skybridge\", {});\n vi.stubGlobal(\"ResizeObserver\", MockResizeObserver);\n postMessageMock = getMcpAppHostPostMessageMock();\n vi.stubGlobal(\"parent\", { postMessage: postMessageMock });\n });\n\n afterEach(() => {\n HostAdaptor.resetInstance();\n McpAppBridge.resetInstance();\n vi.unstubAllGlobals();\n vi.resetAllMocks();\n });\n\n it(\"should call window.openai.openExternal even without a redirectUrl option\", () => {\n const { result } = renderHook(() => useOpenExternal());\n\n const href = \"https://example.com\";\n result.current(href);\n\n expect(openExternalMock).toHaveBeenCalledTimes(1);\n expect(openExternalMock).toHaveBeenCalledWith({ href });\n expect(postMessageMock).not.toHaveBeenCalledWith(\n expect.objectContaining({ method: \"ui/open-link\" }),\n \"*\",\n );\n });\n\n it(\"should call window.openai.openExternal when redirectUrl is false\", () => {\n const { result } = renderHook(() => useOpenExternal());\n\n const href = \"https://example.com\";\n result.current(href, { redirectUrl: false });\n\n expect(openExternalMock).toHaveBeenCalledTimes(1);\n expect(openExternalMock).toHaveBeenCalledWith({\n href,\n redirectUrl: false,\n });\n });\n });\n\n describe(\"mcp-app host\", () => {\n let postMessageMock: ReturnType<typeof getMcpAppHostPostMessageMock>;\n\n beforeEach(() => {\n vi.stubGlobal(\"openai\", undefined);\n vi.stubGlobal(\"skybridge\", {});\n vi.stubGlobal(\"ResizeObserver\", MockResizeObserver);\n postMessageMock = getMcpAppHostPostMessageMock();\n vi.stubGlobal(\"parent\", { postMessage: postMessageMock });\n });\n\n afterEach(async () => {\n HostAdaptor.resetInstance();\n McpAppBridge.resetInstance();\n vi.unstubAllGlobals();\n vi.resetAllMocks();\n });\n\n it(\"should return a function that sends ui/open-link request to the MCP host\", async () => {\n const { result } = renderHook(() => useOpenExternal());\n\n const href = \"https://example.com\";\n result.current(href, { redirectUrl: false });\n\n await waitFor(() => {\n expect(postMessageMock).toHaveBeenCalledWith(\n expect.objectContaining({\n jsonrpc: \"2.0\",\n method: \"ui/open-link\",\n params: { url: href },\n }),\n \"*\",\n );\n });\n });\n });\n});\n"]}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Ask ChatGPT to open a local file by its absolute path, through the OpenAI
3
+ * MCP extensions (`openai/files/open`). ChatGPT desktop only, with a path on
4
+ * the machine that runs ChatGPT, which shows the file in its built-in viewer
5
+ * rather than in the app's own file entrypoint. Rejects with `NotSupportedError` on
6
+ * hosts that don't advertise `openai/files`: check `useHost().openaiCapabilities.files`
7
+ * before showing the control.
8
+ *
9
+ * @example
10
+ * ```tsx
11
+ * const { openaiCapabilities } = useHost();
12
+ * const openFile = useOpenFile();
13
+ * if (openaiCapabilities.files) {
14
+ * return <button onClick={() => openFile(part.path)}>Open in ChatGPT</button>;
15
+ * }
16
+ * ```
17
+ *
18
+ * @see https://docs.skybridge.tech/api-reference/use-open-file
19
+ */
20
+ export declare function useOpenFile(): (path: string) => Promise<void>;
@@ -0,0 +1,25 @@
1
+ import { useCallback } from "react";
2
+ import { getAdaptor } from "../bridges/index.js";
3
+ /**
4
+ * Ask ChatGPT to open a local file by its absolute path, through the OpenAI
5
+ * MCP extensions (`openai/files/open`). ChatGPT desktop only, with a path on
6
+ * the machine that runs ChatGPT, which shows the file in its built-in viewer
7
+ * rather than in the app's own file entrypoint. Rejects with `NotSupportedError` on
8
+ * hosts that don't advertise `openai/files`: check `useHost().openaiCapabilities.files`
9
+ * before showing the control.
10
+ *
11
+ * @example
12
+ * ```tsx
13
+ * const { openaiCapabilities } = useHost();
14
+ * const openFile = useOpenFile();
15
+ * if (openaiCapabilities.files) {
16
+ * return <button onClick={() => openFile(part.path)}>Open in ChatGPT</button>;
17
+ * }
18
+ * ```
19
+ *
20
+ * @see https://docs.skybridge.tech/api-reference/use-open-file
21
+ */
22
+ export function useOpenFile() {
23
+ return useCallback((path) => getAdaptor().openFile(path), []);
24
+ }
25
+ //# sourceMappingURL=use-open-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-open-file.js","sourceRoot":"","sources":["../../../src/web/hooks/use-open-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,WAAW;IACzB,OAAO,WAAW,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,UAAU,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;AACxE,CAAC","sourcesContent":["import { useCallback } from \"react\";\nimport { getAdaptor } from \"../bridges/index.js\";\n\n/**\n * Ask ChatGPT to open a local file by its absolute path, through the OpenAI\n * MCP extensions (`openai/files/open`). ChatGPT desktop only, with a path on\n * the machine that runs ChatGPT, which shows the file in its built-in viewer\n * rather than in the app's own file entrypoint. Rejects with `NotSupportedError` on\n * hosts that don't advertise `openai/files`: check `useHost().openaiCapabilities.files`\n * before showing the control.\n *\n * @example\n * ```tsx\n * const { openaiCapabilities } = useHost();\n * const openFile = useOpenFile();\n * if (openaiCapabilities.files) {\n * return <button onClick={() => openFile(part.path)}>Open in ChatGPT</button>;\n * }\n * ```\n *\n * @see https://docs.skybridge.tech/api-reference/use-open-file\n */\nexport function useOpenFile(): (path: string) => Promise<void> {\n return useCallback((path: string) => getAdaptor().openFile(path), []);\n}\n"]}
@@ -0,0 +1,37 @@
1
+ import type { ViewToolConfig, ViewToolHandler, ViewToolInputShape } from "../bridges/types.js";
2
+ /**
3
+ * Register a tool the view exposes to the host and model — the MCP Apps
4
+ * "app-provided tools" feature. A view tool runs *inside the view*: the host
5
+ * discovers it via `tools/list` and invokes it via `tools/call`, and the
6
+ * handler executes against the view's live state. It is the inverse of
7
+ * {@link useCallTool} (which calls a server tool). Registered on mount, removed
8
+ * on unmount; re-registered when `config.name` changes.
9
+ *
10
+ * MCP Apps only — on the ChatGPT (`window.openai`) runtime it is a no-op.
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * import * as z from "zod";
15
+ * import { useRegisterViewTool } from "skybridge/web";
16
+ *
17
+ * useRegisterViewTool(
18
+ * {
19
+ * name: "chess_make_move",
20
+ * description: "Play a move in algebraic notation, e.g. 'e4' or 'Nf3'.",
21
+ * inputSchema: { san: z.string() },
22
+ * annotations: { readOnlyHint: false },
23
+ * },
24
+ * ({ san }) => {
25
+ * const move = game.move(san);
26
+ * return {
27
+ * content: [{ type: "text", text: move ? `Played ${move.san}` : "Illegal move" }],
28
+ * structuredContent: { fen: game.fen() },
29
+ * isError: !move,
30
+ * };
31
+ * },
32
+ * );
33
+ * ```
34
+ *
35
+ * @see https://docs.skybridge.tech/api-reference/use-register-view-tool
36
+ */
37
+ export declare const useRegisterViewTool: <TInput extends ViewToolInputShape = ViewToolInputShape>(config: ViewToolConfig<TInput>, handler: ViewToolHandler<TInput>) => void;
@@ -0,0 +1,50 @@
1
+ import { useEffect, useRef } from "react";
2
+ import { getAdaptor } from "../bridges/index.js";
3
+ /**
4
+ * Register a tool the view exposes to the host and model — the MCP Apps
5
+ * "app-provided tools" feature. A view tool runs *inside the view*: the host
6
+ * discovers it via `tools/list` and invokes it via `tools/call`, and the
7
+ * handler executes against the view's live state. It is the inverse of
8
+ * {@link useCallTool} (which calls a server tool). Registered on mount, removed
9
+ * on unmount; re-registered when `config.name` changes.
10
+ *
11
+ * MCP Apps only — on the ChatGPT (`window.openai`) runtime it is a no-op.
12
+ *
13
+ * @example
14
+ * ```tsx
15
+ * import * as z from "zod";
16
+ * import { useRegisterViewTool } from "skybridge/web";
17
+ *
18
+ * useRegisterViewTool(
19
+ * {
20
+ * name: "chess_make_move",
21
+ * description: "Play a move in algebraic notation, e.g. 'e4' or 'Nf3'.",
22
+ * inputSchema: { san: z.string() },
23
+ * annotations: { readOnlyHint: false },
24
+ * },
25
+ * ({ san }) => {
26
+ * const move = game.move(san);
27
+ * return {
28
+ * content: [{ type: "text", text: move ? `Played ${move.san}` : "Illegal move" }],
29
+ * structuredContent: { fen: game.fen() },
30
+ * isError: !move,
31
+ * };
32
+ * },
33
+ * );
34
+ * ```
35
+ *
36
+ * @see https://docs.skybridge.tech/api-reference/use-register-view-tool
37
+ */
38
+ export const useRegisterViewTool = (config, handler) => {
39
+ const { name } = config;
40
+ const configRef = useRef(config);
41
+ configRef.current = config;
42
+ const handlerRef = useRef(handler);
43
+ handlerRef.current = handler;
44
+ useEffect(() => {
45
+ const adaptor = getAdaptor();
46
+ const wrappedHandler = (args) => handlerRef.current(args);
47
+ return adaptor.registerViewTool({ ...configRef.current, name }, wrappedHandler);
48
+ }, [name]);
49
+ };
50
+ //# sourceMappingURL=use-register-view-tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-register-view-tool.js","sourceRoot":"","sources":["../../../src/web/hooks/use-register-view-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAQjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAGjC,MAA8B,EAC9B,OAAgC,EAChC,EAAE;IACF,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC;IACxB,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IACjC,SAAS,CAAC,OAAO,GAAG,MAAM,CAAC;IAC3B,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;IACnC,UAAU,CAAC,OAAO,GAAG,OAAO,CAAC;IAE7B,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;QAC7B,MAAM,cAAc,GAAuB,CAAC,IAAI,EAAE,EAAE,CAClD,UAAU,CAAC,OAAO,CAAC,IAA8C,CAAC,CAAC;QAErE,OAAO,OAAO,CAAC,gBAAgB,CAC7B,EAAE,GAAG,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,EAC9B,cAAc,CACf,CAAC;IACJ,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;AACb,CAAC,CAAC","sourcesContent":["import { useEffect, useRef } from \"react\";\nimport { getAdaptor } from \"../bridges/index.js\";\nimport type {\n AnyViewToolHandler,\n ViewToolConfig,\n ViewToolHandler,\n ViewToolInputShape,\n} from \"../bridges/types.js\";\n\n/**\n * Register a tool the view exposes to the host and model — the MCP Apps\n * \"app-provided tools\" feature. A view tool runs *inside the view*: the host\n * discovers it via `tools/list` and invokes it via `tools/call`, and the\n * handler executes against the view's live state. It is the inverse of\n * {@link useCallTool} (which calls a server tool). Registered on mount, removed\n * on unmount; re-registered when `config.name` changes.\n *\n * MCP Apps only — on the ChatGPT (`window.openai`) runtime it is a no-op.\n *\n * @example\n * ```tsx\n * import * as z from \"zod\";\n * import { useRegisterViewTool } from \"skybridge/web\";\n *\n * useRegisterViewTool(\n * {\n * name: \"chess_make_move\",\n * description: \"Play a move in algebraic notation, e.g. 'e4' or 'Nf3'.\",\n * inputSchema: { san: z.string() },\n * annotations: { readOnlyHint: false },\n * },\n * ({ san }) => {\n * const move = game.move(san);\n * return {\n * content: [{ type: \"text\", text: move ? `Played ${move.san}` : \"Illegal move\" }],\n * structuredContent: { fen: game.fen() },\n * isError: !move,\n * };\n * },\n * );\n * ```\n *\n * @see https://docs.skybridge.tech/api-reference/use-register-view-tool\n */\nexport const useRegisterViewTool = <\n TInput extends ViewToolInputShape = ViewToolInputShape,\n>(\n config: ViewToolConfig<TInput>,\n handler: ViewToolHandler<TInput>,\n) => {\n const { name } = config;\n const configRef = useRef(config);\n configRef.current = config;\n const handlerRef = useRef(handler);\n handlerRef.current = handler;\n\n useEffect(() => {\n const adaptor = getAdaptor();\n const wrappedHandler: AnyViewToolHandler = (args) =>\n handlerRef.current(args as Parameters<ViewToolHandler<TInput>>[0]);\n\n return adaptor.registerViewTool(\n { ...configRef.current, name },\n wrappedHandler,\n );\n }, [name]);\n};\n"]}
@@ -0,0 +1,16 @@
1
+ /** Function that asks the host to close the current view, returned by {@link useRequestClose}. */
2
+ export type RequestCloseFn = () => Promise<void>;
3
+ /**
4
+ * Ask the host to close (dismiss) the current view. The host decides whether
5
+ * to honor the request. Useful from modal views or after a terminal action
6
+ * like "Done".
7
+ *
8
+ * @example
9
+ * ```tsx
10
+ * const close = useRequestClose();
11
+ * <button onClick={() => close()}>Done</button>
12
+ * ```
13
+ *
14
+ * @see https://docs.skybridge.tech/api-reference/use-request-close
15
+ */
16
+ export declare function useRequestClose(): RequestCloseFn;
@@ -0,0 +1,21 @@
1
+ import { useCallback } from "react";
2
+ import { getAdaptor } from "../bridges/index.js";
3
+ /**
4
+ * Ask the host to close (dismiss) the current view. The host decides whether
5
+ * to honor the request. Useful from modal views or after a terminal action
6
+ * like "Done".
7
+ *
8
+ * @example
9
+ * ```tsx
10
+ * const close = useRequestClose();
11
+ * <button onClick={() => close()}>Done</button>
12
+ * ```
13
+ *
14
+ * @see https://docs.skybridge.tech/api-reference/use-request-close
15
+ */
16
+ export function useRequestClose() {
17
+ const adaptor = getAdaptor();
18
+ const requestClose = useCallback(() => adaptor.requestClose(), [adaptor]);
19
+ return requestClose;
20
+ }
21
+ //# sourceMappingURL=use-request-close.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-request-close.js","sourceRoot":"","sources":["../../../src/web/hooks/use-request-close.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAKjD;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,eAAe;IAC7B,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,MAAM,YAAY,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAE1E,OAAO,YAAY,CAAC;AACtB,CAAC","sourcesContent":["import { useCallback } from \"react\";\nimport { getAdaptor } from \"../bridges/index.js\";\n\n/** Function that asks the host to close the current view, returned by {@link useRequestClose}. */\nexport type RequestCloseFn = () => Promise<void>;\n\n/**\n * Ask the host to close (dismiss) the current view. The host decides whether\n * to honor the request. Useful from modal views or after a terminal action\n * like \"Done\".\n *\n * @example\n * ```tsx\n * const close = useRequestClose();\n * <button onClick={() => close()}>Done</button>\n * ```\n *\n * @see https://docs.skybridge.tech/api-reference/use-request-close\n */\nexport function useRequestClose(): RequestCloseFn {\n const adaptor = getAdaptor();\n const requestClose = useCallback(() => adaptor.requestClose(), [adaptor]);\n\n return requestClose;\n}\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,47 @@
1
+ import { act, renderHook } from "@testing-library/react";
2
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
3
+ import { HostAdaptor } from "../bridges/adaptor.js";
4
+ import { getAdaptor } from "../bridges/get-adaptor.js";
5
+ import { McpAppBridge } from "../bridges/mcp-app/bridge.js";
6
+ import { useRequestClose } from "./use-request-close.js";
7
+ describe("useRequestClose", () => {
8
+ beforeEach(() => {
9
+ HostAdaptor.resetInstance();
10
+ McpAppBridge.resetInstance();
11
+ vi.stubGlobal("skybridge", {});
12
+ vi.stubGlobal("openai", undefined);
13
+ vi.stubGlobal("parent", { postMessage: vi.fn() });
14
+ });
15
+ afterEach(() => {
16
+ vi.unstubAllGlobals();
17
+ vi.resetAllMocks();
18
+ HostAdaptor.resetInstance();
19
+ McpAppBridge.resetInstance();
20
+ });
21
+ it("calls app.requestTeardown via the MCP path", async () => {
22
+ const requestTeardown = vi.fn().mockResolvedValue(undefined);
23
+ // biome-ignore lint/suspicious/noExplicitAny: test seam
24
+ const adaptor = getAdaptor();
25
+ adaptor.mcp.getApp = vi.fn().mockResolvedValue({ requestTeardown });
26
+ const { result } = renderHook(() => useRequestClose());
27
+ await act(async () => {
28
+ await result.current();
29
+ });
30
+ expect(requestTeardown).toHaveBeenCalledTimes(1);
31
+ });
32
+ it("calls app.requestTeardown even when window.openai is present", async () => {
33
+ vi.stubGlobal("openai", { requestClose: vi.fn() });
34
+ HostAdaptor.resetInstance();
35
+ McpAppBridge.resetInstance();
36
+ const requestTeardown = vi.fn().mockResolvedValue(undefined);
37
+ // biome-ignore lint/suspicious/noExplicitAny: test seam
38
+ const adaptor = getAdaptor();
39
+ adaptor.mcp.getApp = vi.fn().mockResolvedValue({ requestTeardown });
40
+ const { result } = renderHook(() => useRequestClose());
41
+ await act(async () => {
42
+ await result.current();
43
+ });
44
+ expect(requestTeardown).toHaveBeenCalledTimes(1);
45
+ });
46
+ });
47
+ //# sourceMappingURL=use-request-close.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-request-close.test.js","sourceRoot":"","sources":["../../../src/web/hooks/use-request-close.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,Q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AAC,GAAG,EAAE,CAAC,eAAe,EAAE,CAAC,CAAC;QACvD,MAAM,GAAG,CAAC,KAAK,IAAI,EAAE;YACnB,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;QACzB,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,eAAe,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8DAA8D,EAAE,KAAK,IAAI,EAAE;QAC5E,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,EAAE,YAAY,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QACnD,WAAW,CAAC,aAAa,EAAE,CAAC;QAC5B,YAAY,CAAC,aAAa,EAAE,CAAC;QAE7B,MAAM,eAAe,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;QAC7D,wDAAwD;QACxD,MAAM,OAAO,GAAG,UAAU,EAAS,CAAC;QACpC,OAAO,CAAC,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,EAAE,eAAe,EAAE,CAAC,CAAC;QAEpE,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,eAAe,EAAE,CAAC,CAAC;QACvD,MAAM,GAAG,CAAC,KAAK,IAAI,EAAE;YACnB,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;QACzB,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,eAAe,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { act, renderHook } from \"@testing-library/react\";\nimport { afterEach, beforeEach, describe, expect, it, vi } from \"vitest\";\nimport { HostAdaptor } from \"../bridges/adaptor.js\";\nimport { getAdaptor } from \"../bridges/get-adaptor.js\";\nimport { McpAppBridge } from \"../bridges/mcp-app/bridge.js\";\nimport { useRequestClose } from \"./use-request-close.js\";\n\ndescribe(\"useRequestClose\", () => {\n beforeEach(() => {\n HostAdaptor.resetInstance();\n McpAppBridge.resetInstance();\n vi.stubGlobal(\"skybridge\", {});\n vi.stubGlobal(\"openai\", undefined);\n vi.stubGlobal(\"parent\", { postMessage: vi.fn() });\n });\n\n afterEach(() => {\n vi.unstubAllGlobals();\n vi.resetAllMocks();\n HostAdaptor.resetInstance();\n McpAppBridge.resetInstance();\n });\n\n it(\"calls app.requestTeardown via the MCP path\", async () => {\n const requestTeardown = vi.fn().mockResolvedValue(undefined);\n // biome-ignore lint/suspicious/noExplicitAny: test seam\n const adaptor = getAdaptor() as any;\n adaptor.mcp.getApp = vi.fn().mockResolvedValue({ requestTeardown });\n\n const { result } = renderHook(() => useRequestClose());\n await act(async () => {\n await result.current();\n });\n\n expect(requestTeardown).toHaveBeenCalledTimes(1);\n });\n\n it(\"calls app.requestTeardown even when window.openai is present\", async () => {\n vi.stubGlobal(\"openai\", { requestClose: vi.fn() });\n HostAdaptor.resetInstance();\n McpAppBridge.resetInstance();\n\n const requestTeardown = vi.fn().mockResolvedValue(undefined);\n // biome-ignore lint/suspicious/noExplicitAny: test seam\n const adaptor = getAdaptor() as any;\n adaptor.mcp.getApp = vi.fn().mockResolvedValue({ requestTeardown });\n\n const { result } = renderHook(() => useRequestClose());\n await act(async () => {\n await result.current();\n });\n\n expect(requestTeardown).toHaveBeenCalledTimes(1);\n });\n});\n"]}
@@ -1,6 +1,21 @@
1
1
  import { type RequestModalOptions } from "../bridges/index.js";
2
2
  /**
3
- * Triggers a modal containing the widget rendered in display mode "modal"
3
+ * Open the current view in a modal overlay (`displayMode === "modal"`).
4
+ *
5
+ * Returns `{ isOpen, params, open }`: `open(opts)` triggers the host to render
6
+ * the view in a modal, optionally passing `params` that are surfaced back via
7
+ * `params` here. Useful for confirmation flows, detail panels, or any modal
8
+ * lifecycle owned by the host.
9
+ *
10
+ * Use {@link useDisplayMode} for non-modal display modes.
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * const { isOpen, open } = useRequestModal();
15
+ * <button onClick={() => open({ params: { id: 42 } })}>Show details</button>
16
+ * ```
17
+ *
18
+ * @see https://docs.skybridge.tech/api-reference/use-request-modal
4
19
  */
5
20
  export declare function useRequestModal(): {
6
21
  isOpen: boolean;
@@ -1,15 +1,30 @@
1
1
  import { useCallback } from "react";
2
2
  import { getAdaptor, useHostContext, } from "../bridges/index.js";
3
3
  /**
4
- * Triggers a modal containing the widget rendered in display mode "modal"
4
+ * Open the current view in a modal overlay (`displayMode === "modal"`).
5
+ *
6
+ * Returns `{ isOpen, params, open }`: `open(opts)` triggers the host to render
7
+ * the view in a modal, optionally passing `params` that are surfaced back via
8
+ * `params` here. Useful for confirmation flows, detail panels, or any modal
9
+ * lifecycle owned by the host.
10
+ *
11
+ * Use {@link useDisplayMode} for non-modal display modes.
12
+ *
13
+ * @example
14
+ * ```tsx
15
+ * const { isOpen, open } = useRequestModal();
16
+ * <button onClick={() => open({ params: { id: 42 } })}>Show details</button>
17
+ * ```
18
+ *
19
+ * @see https://docs.skybridge.tech/api-reference/use-request-modal
5
20
  */
6
21
  export function useRequestModal() {
7
22
  const adaptor = getAdaptor();
8
- const view = useHostContext("view");
23
+ const display = useHostContext("display");
9
24
  const open = useCallback((opts) => adaptor.openModal(opts), [adaptor]);
10
25
  return {
11
- isOpen: view.mode === "modal",
12
- params: view.params,
26
+ isOpen: display.mode === "modal",
27
+ params: display.params,
13
28
  open,
14
29
  };
15
30
  }
@@ -1 +1 @@
1
- {"version":3,"file":"use-request-modal.js","sourceRoot":"","sources":["../../../src/web/hooks/use-request-modal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EACL,UAAU,EAEV,cAAc,GACf,MAAM,qBAAqB,CAAC;AAE7B;;GAEG;AACH,MAAM,UAAU,eAAe;IAC7B,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,MAAM,IAAI,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IACpC,MAAM,IAAI,GAAG,WAAW,CACtB,CAAC,IAAyB,EAAE,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,EACtD,CAAC,OAAO,CAAC,CACV,CAAC;IACF,OAAO;QACL,MAAM,EAAE,IAAI,CAAC,IAAI,KAAK,OAAO;QAC7B,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,IAAI;KACL,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"use-request-modal.js","sourceRoot":"","sources":["../../../src/web/hooks/use-request-modal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EACL,UAAU,EAEV,cAAc,GACf,MAAM,qBAAqB,CAAC;AAE7B;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,eAAe;IAC7B,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,MAAM,OAAO,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;IAC1C,MAAM,IAAI,GAAG,WAAW,CACtB,CAAC,IAAyB,EAAE,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,EACtD,CAAC,OAAO,CAAC,CACV,CAAC;IACF,OAAO;QACL,MAAM,EAAE,OAAO,CAAC,IAAI,KAAK,OAAO;QAChC,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,IAAI;KACL,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback } from \"react\";\nimport {\n getAdaptor,\n type RequestModalOptions,\n useHostContext,\n} from \"../bridges/index.js\";\n\n/**\n * Open the current view in a modal overlay (`displayMode === \"modal\"`).\n *\n * Returns `{ isOpen, params, open }`: `open(opts)` triggers the host to render\n * the view in a modal, optionally passing `params` that are surfaced back via\n * `params` here. Useful for confirmation flows, detail panels, or any modal\n * lifecycle owned by the host.\n *\n * Use {@link useDisplayMode} for non-modal display modes.\n *\n * @example\n * ```tsx\n * const { isOpen, open } = useRequestModal();\n * <button onClick={() => open({ params: { id: 42 } })}>Show details</button>\n * ```\n *\n * @see https://docs.skybridge.tech/api-reference/use-request-modal\n */\nexport function useRequestModal() {\n const adaptor = getAdaptor();\n const display = useHostContext(\"display\");\n const open = useCallback(\n (opts: RequestModalOptions) => adaptor.openModal(opts),\n [adaptor],\n );\n return {\n isOpen: display.mode === \"modal\",\n params: display.params,\n open,\n };\n}\n"]}
@@ -1,11 +1,18 @@
1
1
  import { renderHook } from "@testing-library/react";
2
2
  import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
3
+ import { HostAdaptor } from "../bridges/adaptor.js";
4
+ import { AppsSdkBridge } from "../bridges/apps-sdk/bridge.js";
5
+ import { McpAppBridge } from "../bridges/mcp-app/bridge.js";
3
6
  import { useRequestModal } from "./use-request-modal.js";
4
7
  describe("useRequestModal", () => {
5
8
  let requestModalMock;
6
9
  beforeEach(() => {
10
+ HostAdaptor.resetInstance();
11
+ McpAppBridge.resetInstance();
12
+ AppsSdkBridge.resetInstance();
7
13
  requestModalMock = vi.fn();
8
- vi.stubGlobal("skybridge", { hostType: "apps-sdk" });
14
+ vi.stubGlobal("skybridge", {});
15
+ vi.stubGlobal("parent", { postMessage: vi.fn() });
9
16
  vi.stubGlobal("openai", {
10
17
  requestModal: requestModalMock,
11
18
  view: { mode: "inline" },
@@ -14,6 +21,9 @@ describe("useRequestModal", () => {
14
21
  afterEach(() => {
15
22
  vi.unstubAllGlobals();
16
23
  vi.resetAllMocks();
24
+ HostAdaptor.resetInstance();
25
+ McpAppBridge.resetInstance();
26
+ AppsSdkBridge.resetInstance();
17
27
  });
18
28
  it("should return an object with open, isOpen, and params properties where isOpen is false when mode is not modal", () => {
19
29
  const { result } = renderHook(() => useRequestModal());
@@ -48,7 +58,11 @@ describe("useRequestModal", () => {
48
58
  it("should call window.openai.requestModal with the options when open is called", () => {
49
59
  const { result } = renderHook(() => useRequestModal());
50
60
  const { open } = result.current;
51
- const options = { title: "Test Modal" };
61
+ const options = {
62
+ title: "Test Modal",
63
+ params: { foo: "bar" },
64
+ template: "ui://view/modal-template.html",
65
+ };
52
66
  open(options);
53
67
  expect(requestModalMock).toHaveBeenCalledTimes(1);
54
68
  expect(requestModalMock).toHaveBeenCalledWith(options);
@@ -1 +1 @@
1
- {"version":3,"file":"use-request-modal.test.js","sourceRoot":"","sources":["../../../src/web/hooks/use-request-modal.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,IAAI,gBAA0C,CAAC;IAE/C,UAAU,CAAC,GAAG,EAAE;QACd,gBAAgB,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3B,EAAE,CAAC,UAAU,CAAC,WAAW,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAC;QACrD,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE;YACtB,YAAY,EAAE,gBAAgB;YAC9B,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;SACzB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,EAAE,CAAC,gBAAgB,EAAE,CAAC;QACtB,EAAE,CAAC,aAAa,EAAE,CAAC;IACrB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,+GAA+G,EAAE,GAAG,EAAE;QACvH,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,eAAe,EAAE,CAAC,CAAC;QAEvD,MAAM,CAAC,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,IAA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AElC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6EAA6E,EAAE,GAAG,EAAE;QACrF,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,eAAe,EAAE,CAAC,CAAC;QACvD,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC;QAEhC,MAAM,OAAO,GAAG;YACd,KAAK,EAAE,YAAY;YACnB,MAAM,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE;YACtB,QAAQ,EAAE,+BAA+B;SAC1C,CAAC;QACF,IAAI,CAAC,OAAO,CAAC,CAAC;QAEd,MAAM,CAAC,gBAAgB,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QAClD,MAAM,CAAC,gBAAgB,CAAC,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { renderHook } from \"@testing-library/react\";\nimport { afterEach, beforeEach, describe, expect, it, vi } from \"vitest\";\nimport { HostAdaptor } from \"../bridges/adaptor.js\";\nimport { AppsSdkBridge } from \"../bridges/apps-sdk/bridge.js\";\nimport { McpAppBridge } from \"../bridges/mcp-app/bridge.js\";\nimport { useRequestModal } from \"./use-request-modal.js\";\n\ndescribe(\"useRequestModal\", () => {\n let requestModalMock: ReturnType<typeof vi.fn>;\n\n beforeEach(() => {\n HostAdaptor.resetInstance();\n McpAppBridge.resetInstance();\n AppsSdkBridge.resetInstance();\n requestModalMock = vi.fn();\n vi.stubGlobal(\"skybridge\", {});\n vi.stubGlobal(\"parent\", { postMessage: vi.fn() });\n vi.stubGlobal(\"openai\", {\n requestModal: requestModalMock,\n view: { mode: \"inline\" },\n });\n });\n\n afterEach(() => {\n vi.unstubAllGlobals();\n vi.resetAllMocks();\n HostAdaptor.resetInstance();\n McpAppBridge.resetInstance();\n AppsSdkBridge.resetInstance();\n });\n\n it(\"should return an object with open, isOpen, and params properties where isOpen is false when mode is not modal\", () => {\n const { result } = renderHook(() => useRequestModal());\n\n expect(typeof result.current).toBe(\"object\");\n expect(result.current).toHaveProperty(\"open\");\n expect(result.current).toHaveProperty(\"isOpen\");\n expect(result.current).toHaveProperty(\"params\");\n\n const { open, isOpen, params } = result.current;\n expect(typeof open).toBe(\"function\");\n expect(isOpen).toBe(false);\n expect(params).toBeUndefined();\n });\n\n it(\"should return isOpen as true when mode is modal\", () => {\n vi.stubGlobal(\"openai\", {\n requestModal: requestModalMock,\n view: { mode: \"modal\" },\n });\n\n const { result } = renderHook(() => useRequestModal());\n const { isOpen } = result.current;\n\n expect(isOpen).toBe(true);\n });\n\n it(\"should return params from view when available\", () => {\n const testParams = { foo: \"bar\", baz: 42 };\n vi.stubGlobal(\"openai\", {\n requestModal: requestModalMock,\n view: { mode: \"modal\", params: testParams },\n });\n\n const { result } = renderHook(() => useRequestModal());\n const { params } = result.current;\n\n expect(params).toEqual(testParams);\n });\n\n it(\"should call window.openai.requestModal with the options when open is called\", () => {\n const { result } = renderHook(() => useRequestModal());\n const { open } = result.current;\n\n const options = {\n title: \"Test Modal\",\n params: { foo: \"bar\" },\n template: \"ui://view/modal-template.html\",\n };\n open(options);\n\n expect(requestModalMock).toHaveBeenCalledTimes(1);\n expect(requestModalMock).toHaveBeenCalledWith(options);\n });\n});\n"]}
@@ -0,0 +1,20 @@
1
+ import type { RequestSizeOptions } from "../bridges/types.js";
2
+ /** Function that asks the host to resize the view, returned by {@link useRequestSize}. */
3
+ export type RequestSizeFn = (size: RequestSizeOptions) => Promise<void>;
4
+ /**
5
+ * Ask the host to resize the view iframe. The applied size is host-driven —
6
+ * the host decides whether and how to honor the request, and {@link useViewport}
7
+ * still reports the final `maxHeight` it allows.
8
+ *
9
+ * Pair with a `ResizeObserver` on your root element to react to content size
10
+ * changes without hard-coded values.
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * const requestSize = useRequestSize();
15
+ * useEffect(() => { requestSize({ height: rootRef.current!.scrollHeight }); }, [content]);
16
+ * ```
17
+ *
18
+ * @see https://docs.skybridge.tech/api-reference/use-request-size
19
+ */
20
+ export declare function useRequestSize(): RequestSizeFn;
@@ -0,0 +1,24 @@
1
+ import { useCallback } from "react";
2
+ import { getAdaptor } from "../bridges/index.js";
3
+ /**
4
+ * Ask the host to resize the view iframe. The applied size is host-driven —
5
+ * the host decides whether and how to honor the request, and {@link useViewport}
6
+ * still reports the final `maxHeight` it allows.
7
+ *
8
+ * Pair with a `ResizeObserver` on your root element to react to content size
9
+ * changes without hard-coded values.
10
+ *
11
+ * @example
12
+ * ```tsx
13
+ * const requestSize = useRequestSize();
14
+ * useEffect(() => { requestSize({ height: rootRef.current!.scrollHeight }); }, [content]);
15
+ * ```
16
+ *
17
+ * @see https://docs.skybridge.tech/api-reference/use-request-size
18
+ */
19
+ export function useRequestSize() {
20
+ const adaptor = getAdaptor();
21
+ const requestSize = useCallback((size) => adaptor.requestSize(size), [adaptor]);
22
+ return requestSize;
23
+ }
24
+ //# sourceMappingURL=use-request-size.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-request-size.js","sourceRoot":"","sources":["../../../src/web/hooks/use-request-size.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAMjD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,cAAc;IAC5B,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,MAAM,WAAW,GAAG,WAAW,CAC7B,CAAC,IAAwB,EAAE,EAAE,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,EACvD,CAAC,OAAO,CAAC,CACV,CAAC;IAEF,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import { useCallback } from \"react\";\nimport { getAdaptor } from \"../bridges/index.js\";\nimport type { RequestSizeOptions } from \"../bridges/types.js\";\n\n/** Function that asks the host to resize the view, returned by {@link useRequestSize}. */\nexport type RequestSizeFn = (size: RequestSizeOptions) => Promise<void>;\n\n/**\n * Ask the host to resize the view iframe. The applied size is host-driven —\n * the host decides whether and how to honor the request, and {@link useViewport}\n * still reports the final `maxHeight` it allows.\n *\n * Pair with a `ResizeObserver` on your root element to react to content size\n * changes without hard-coded values.\n *\n * @example\n * ```tsx\n * const requestSize = useRequestSize();\n * useEffect(() => { requestSize({ height: rootRef.current!.scrollHeight }); }, [content]);\n * ```\n *\n * @see https://docs.skybridge.tech/api-reference/use-request-size\n */\nexport function useRequestSize(): RequestSizeFn {\n const adaptor = getAdaptor();\n const requestSize = useCallback(\n (size: RequestSizeOptions) => adaptor.requestSize(size),\n [adaptor],\n );\n\n return requestSize;\n}\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,47 @@
1
+ import { renderHook, waitFor } from "@testing-library/react";
2
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
3
+ import { HostAdaptor } from "../bridges/adaptor.js";
4
+ import { McpAppBridge } from "../bridges/mcp-app/bridge.js";
5
+ import { getMcpAppHostPostMessageMock, MockResizeObserver, } from "./test/utils.js";
6
+ import { useRequestSize } from "./use-request-size.js";
7
+ describe("useRequestSize", () => {
8
+ let postMessageMock;
9
+ beforeEach(() => {
10
+ HostAdaptor.resetInstance();
11
+ McpAppBridge.resetInstance();
12
+ vi.stubGlobal("skybridge", {});
13
+ vi.stubGlobal("openai", undefined);
14
+ vi.stubGlobal("ResizeObserver", MockResizeObserver);
15
+ postMessageMock = getMcpAppHostPostMessageMock();
16
+ vi.stubGlobal("parent", { postMessage: postMessageMock });
17
+ });
18
+ afterEach(() => {
19
+ vi.unstubAllGlobals();
20
+ vi.resetAllMocks();
21
+ HostAdaptor.resetInstance();
22
+ McpAppBridge.resetInstance();
23
+ });
24
+ it("sends a ui/notifications/size-changed notification with width and height", async () => {
25
+ const { result } = renderHook(() => useRequestSize());
26
+ await result.current({ width: 800, height: 400 });
27
+ await waitFor(() => {
28
+ expect(postMessageMock).toHaveBeenCalledWith(expect.objectContaining({
29
+ jsonrpc: "2.0",
30
+ method: "ui/notifications/size-changed",
31
+ params: { width: 800, height: 400 },
32
+ }), "*");
33
+ });
34
+ });
35
+ it("forwards height-only payloads as-is", async () => {
36
+ const { result } = renderHook(() => useRequestSize());
37
+ await result.current({ height: 400 });
38
+ await waitFor(() => {
39
+ expect(postMessageMock).toHaveBeenCalledWith(expect.objectContaining({
40
+ jsonrpc: "2.0",
41
+ method: "ui/notifications/size-changed",
42
+ params: { height: 400 },
43
+ }), "*");
44
+ });
45
+ });
46
+ });
47
+ //# sourceMappingURL=use-request-size.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-request-size.test.js","sourceRoot":"","sources":["../../../src/web/hooks/use-request-size.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EACL,4BAA4B,EAC5B,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,IAAI,eAAgE,CAAC;IAErE,UAAU,CAAC,GAAG,EAAE;QACd,WAAW,CAAC,aAAa,EAAE,CAAC;QAC5B,YAAY,CAAC,aAAa,EAAE,CAAC;QAC7B,EAAE,CAAC,UAAU,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QAC/B,EAAE,CAAC,UAAU,CAAC,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;QAEtC,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,EAAE,MAAM,EAAE,GAAG,EAAE;aACxB,CAAC,EACF,GAAG,CACJ,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { renderHook, waitFor } from \"@testing-library/react\";\nimport { afterEach, beforeEach, describe, expect, it, vi } from \"vitest\";\nimport { HostAdaptor } from \"../bridges/adaptor.js\";\nimport { McpAppBridge } from \"../bridges/mcp-app/bridge.js\";\nimport {\n getMcpAppHostPostMessageMock,\n MockResizeObserver,\n} from \"./test/utils.js\";\nimport { useRequestSize } from \"./use-request-size.js\";\n\ndescribe(\"useRequestSize\", () => {\n let postMessageMock: ReturnType<typeof getMcpAppHostPostMessageMock>;\n\n beforeEach(() => {\n HostAdaptor.resetInstance();\n McpAppBridge.resetInstance();\n vi.stubGlobal(\"skybridge\", {});\n vi.stubGlobal(\"openai\", undefined);\n vi.stubGlobal(\"ResizeObserver\", MockResizeObserver);\n postMessageMock = getMcpAppHostPostMessageMock();\n vi.stubGlobal(\"parent\", { postMessage: postMessageMock });\n });\n\n afterEach(() => {\n vi.unstubAllGlobals();\n vi.resetAllMocks();\n HostAdaptor.resetInstance();\n McpAppBridge.resetInstance();\n });\n\n it(\"sends a ui/notifications/size-changed notification with width and height\", async () => {\n const { result } = renderHook(() => useRequestSize());\n\n await result.current({ width: 800, height: 400 });\n\n await waitFor(() => {\n expect(postMessageMock).toHaveBeenCalledWith(\n expect.objectContaining({\n jsonrpc: \"2.0\",\n method: \"ui/notifications/size-changed\",\n params: { width: 800, height: 400 },\n }),\n \"*\",\n );\n });\n });\n\n it(\"forwards height-only payloads as-is\", async () => {\n const { result } = renderHook(() => useRequestSize());\n\n await result.current({ height: 400 });\n\n await waitFor(() => {\n expect(postMessageMock).toHaveBeenCalledWith(\n expect.objectContaining({\n jsonrpc: \"2.0\",\n method: \"ui/notifications/size-changed\",\n params: { height: 400 },\n }),\n \"*\",\n );\n });\n });\n});\n"]}
@@ -1 +1,25 @@
1
- export declare function useSendFollowUpMessage(): (prompt: string) => Promise<void>;
1
+ import { type FollowUpMessage, type SendFollowUpMessageOptions } from "../bridges/index.js";
2
+ /**
3
+ * Send a follow-up message to the LLM on behalf of the view, as if the user
4
+ * had sent it. Use to chain interactions from view UI (e.g. a button that
5
+ * triggers the next assistant turn).
6
+ *
7
+ * Pass `scrollToBottom: false` to keep the chat scroll position when the host
8
+ * posts the message. This option is Apps-SDK-only; it is silently ignored in
9
+ * the MCP Apps runtime.
10
+ *
11
+ * `prompt` can also be an array of content blocks. On ChatGPT, a text block
12
+ * with `_meta["openai/title"]` becomes a labeled item the user can remove, and
13
+ * `target: "new"` sends the message to a new conversation. Both use the OpenAI
14
+ * MCP extensions: other hosts ignore the title, and `target: "new"` rejects
15
+ * with `NotSupportedError` on hosts that don't advertise `openai/message`.
16
+ *
17
+ * @example
18
+ * ```tsx
19
+ * const send = useSendFollowUpMessage();
20
+ * <button onClick={() => send("Summarize the last 5 results")}>Summarize</button>
21
+ * ```
22
+ *
23
+ * @see https://docs.skybridge.tech/api-reference/use-send-follow-up-message
24
+ */
25
+ export declare function useSendFollowUpMessage(): (prompt: FollowUpMessage, options?: SendFollowUpMessageOptions) => Promise<void>;
@@ -1,8 +1,31 @@
1
1
  import { useCallback } from "react";
2
- import { getAdaptor } from "../bridges/index.js";
2
+ import { getAdaptor, } from "../bridges/index.js";
3
+ /**
4
+ * Send a follow-up message to the LLM on behalf of the view, as if the user
5
+ * had sent it. Use to chain interactions from view UI (e.g. a button that
6
+ * triggers the next assistant turn).
7
+ *
8
+ * Pass `scrollToBottom: false` to keep the chat scroll position when the host
9
+ * posts the message. This option is Apps-SDK-only; it is silently ignored in
10
+ * the MCP Apps runtime.
11
+ *
12
+ * `prompt` can also be an array of content blocks. On ChatGPT, a text block
13
+ * with `_meta["openai/title"]` becomes a labeled item the user can remove, and
14
+ * `target: "new"` sends the message to a new conversation. Both use the OpenAI
15
+ * MCP extensions: other hosts ignore the title, and `target: "new"` rejects
16
+ * with `NotSupportedError` on hosts that don't advertise `openai/message`.
17
+ *
18
+ * @example
19
+ * ```tsx
20
+ * const send = useSendFollowUpMessage();
21
+ * <button onClick={() => send("Summarize the last 5 results")}>Summarize</button>
22
+ * ```
23
+ *
24
+ * @see https://docs.skybridge.tech/api-reference/use-send-follow-up-message
25
+ */
3
26
  export function useSendFollowUpMessage() {
4
27
  const adaptor = getAdaptor();
5
- const sendFollowUpMessage = useCallback((prompt) => adaptor.sendFollowUpMessage(prompt), [adaptor]);
28
+ const sendFollowUpMessage = useCallback((prompt, options) => adaptor.sendFollowUpMessage(prompt, options), [adaptor]);
6
29
  return sendFollowUpMessage;
7
30
  }
8
31
  //# sourceMappingURL=use-send-follow-up-message.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-send-follow-up-message.js","sourceRoot":"","sources":["../../../src/web/hooks/use-send-follow-up-message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,MAAM,UAAU,sBAAsB;IACpC,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,MAAM,mBAAmB,GAAG,WAAW,CACrC,CAAC,MAAc,EAAE,EAAE,CAAC,OAAO,CAAC,mBAAmB,CAAC,MAAM,CAAC,EACvD,CAAC,OAAO,CAAC,CACV,CAAC;IAEF,OAAO,mBAAmB,CAAC;AAC7B,CAAC"}
1
+ {"version":3,"file":"use-send-follow-up-message.js","sourceRoot":"","sources":["../../../src/web/hooks/use-send-follow-up-message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAEL,UAAU,GAEX,MAAM,qBAAqB,CAAC;AAE7B;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,sBAAsB;IACpC,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,MAAM,mBAAmB,GAAG,WAAW,CACrC,CAAC,MAAuB,EAAE,OAAoC,EAAE,EAAE,CAChE,OAAO,CAAC,mBAAmB,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9C,CAAC,OAAO,CAAC,CACV,CAAC;IAEF,OAAO,mBAAmB,CAAC;AAC7B,CAAC","sourcesContent":["import { useCallback } from \"react\";\nimport {\n type FollowUpMessage,\n getAdaptor,\n type SendFollowUpMessageOptions,\n} from \"../bridges/index.js\";\n\n/**\n * Send a follow-up message to the LLM on behalf of the view, as if the user\n * had sent it. Use to chain interactions from view UI (e.g. a button that\n * triggers the next assistant turn).\n *\n * Pass `scrollToBottom: false` to keep the chat scroll position when the host\n * posts the message. This option is Apps-SDK-only; it is silently ignored in\n * the MCP Apps runtime.\n *\n * `prompt` can also be an array of content blocks. On ChatGPT, a text block\n * with `_meta[\"openai/title\"]` becomes a labeled item the user can remove, and\n * `target: \"new\"` sends the message to a new conversation. Both use the OpenAI\n * MCP extensions: other hosts ignore the title, and `target: \"new\"` rejects\n * with `NotSupportedError` on hosts that don't advertise `openai/message`.\n *\n * @example\n * ```tsx\n * const send = useSendFollowUpMessage();\n * <button onClick={() => send(\"Summarize the last 5 results\")}>Summarize</button>\n * ```\n *\n * @see https://docs.skybridge.tech/api-reference/use-send-follow-up-message\n */\nexport function useSendFollowUpMessage() {\n const adaptor = getAdaptor();\n const sendFollowUpMessage = useCallback(\n (prompt: FollowUpMessage, options?: SendFollowUpMessageOptions) =>\n adaptor.sendFollowUpMessage(prompt, options),\n [adaptor],\n );\n\n return sendFollowUpMessage;\n}\n"]}
@@ -1 +1,18 @@
1
+ /**
2
+ * Override the target URL the host opens from its fullscreen "Open in <App>"
3
+ * affordance. If unset, the host opens the view's current iframe path.
4
+ *
5
+ * Currently Apps-SDK-only — calling this from MCP Apps throws.
6
+ *
7
+ * Call this once your view has enough context to construct the canonical URL
8
+ * (e.g. a permalink to the entity the user is currently viewing).
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * const setOpenInAppUrl = useSetOpenInAppUrl();
13
+ * useEffect(() => { setOpenInAppUrl(`https://example.com/orders/${orderId}`); }, [orderId]);
14
+ * ```
15
+ *
16
+ * @see https://docs.skybridge.tech/api-reference/use-set-open-in-app-url
17
+ */
1
18
  export declare function useSetOpenInAppUrl(): (href: string) => Promise<void>;