skybridge 0.0.0-dev.f03017e → 0.0.0-dev.f0394fc

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 (513) hide show
  1. package/README.md +126 -124
  2. package/dist/cli/build-helpers.d.ts +11 -0
  3. package/dist/cli/build-helpers.js +113 -0
  4. package/dist/cli/build-helpers.js.map +1 -0
  5. package/dist/cli/build-helpers.test.js +143 -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 +84 -0
  9. package/dist/cli/build-steps.js.map +1 -0
  10. package/dist/cli/build-steps.test.js +72 -0
  11. package/dist/cli/build-steps.test.js.map +1 -0
  12. package/dist/cli/detect-port.d.ts +2 -2
  13. package/dist/cli/detect-port.js +8 -20
  14. package/dist/cli/detect-port.js.map +1 -1
  15. package/dist/cli/header.d.ts +1 -1
  16. package/dist/cli/header.js.map +1 -1
  17. package/dist/cli/resolve-skybridge-config.d.ts +6 -0
  18. package/dist/cli/resolve-skybridge-config.js +28 -0
  19. package/dist/cli/resolve-skybridge-config.js.map +1 -0
  20. package/dist/cli/run-command.js.map +1 -1
  21. package/dist/cli/run-plain.d.ts +18 -0
  22. package/dist/cli/run-plain.js +90 -0
  23. package/dist/cli/run-plain.js.map +1 -0
  24. package/dist/cli/telemetry.js +2 -0
  25. package/dist/cli/telemetry.js.map +1 -1
  26. package/dist/cli/tunnel-control-server.d.ts +9 -0
  27. package/dist/cli/tunnel-control-server.js +31 -0
  28. package/dist/cli/tunnel-control-server.js.map +1 -0
  29. package/dist/cli/tunnel-control-server.test.js +39 -0
  30. package/dist/cli/tunnel-control-server.test.js.map +1 -0
  31. package/dist/cli/tunnel-handler.d.ts +3 -0
  32. package/dist/cli/tunnel-handler.js +48 -0
  33. package/dist/cli/tunnel-handler.js.map +1 -0
  34. package/dist/cli/tunnel-handler.test.js +105 -0
  35. package/dist/cli/tunnel-handler.test.js.map +1 -0
  36. package/dist/cli/tunnel.d.ts +57 -0
  37. package/dist/cli/tunnel.js +154 -0
  38. package/dist/cli/tunnel.js.map +1 -0
  39. package/dist/cli/tunnel.test.js +190 -0
  40. package/dist/cli/tunnel.test.js.map +1 -0
  41. package/dist/cli/types.js.map +1 -1
  42. package/dist/cli/use-execute-steps.d.ts +1 -1
  43. package/dist/cli/use-execute-steps.js.map +1 -1
  44. package/dist/cli/use-messages.js.map +1 -1
  45. package/dist/cli/use-nodemon.d.ts +25 -1
  46. package/dist/cli/use-nodemon.js +97 -55
  47. package/dist/cli/use-nodemon.js.map +1 -1
  48. package/dist/cli/use-open-browser.d.ts +1 -0
  49. package/dist/cli/use-open-browser.js +44 -0
  50. package/dist/cli/use-open-browser.js.map +1 -0
  51. package/dist/cli/use-tunnel.d.ts +1 -1
  52. package/dist/cli/use-tunnel.js +102 -68
  53. package/dist/cli/use-tunnel.js.map +1 -1
  54. package/dist/cli/use-typescript-check.d.ts +9 -2
  55. package/dist/cli/use-typescript-check.js +91 -51
  56. package/dist/cli/use-typescript-check.js.map +1 -1
  57. package/dist/commands/build.d.ts +0 -3
  58. package/dist/commands/build.js +2 -38
  59. package/dist/commands/build.js.map +1 -1
  60. package/dist/commands/create.d.ts +9 -0
  61. package/dist/commands/create.js +30 -0
  62. package/dist/commands/create.js.map +1 -0
  63. package/dist/commands/dev.d.ts +2 -0
  64. package/dist/commands/dev.js +84 -5
  65. package/dist/commands/dev.js.map +1 -1
  66. package/dist/commands/start.js +7 -1
  67. package/dist/commands/start.js.map +1 -1
  68. package/dist/commands/telemetry/disable.js.map +1 -1
  69. package/dist/commands/telemetry/enable.js.map +1 -1
  70. package/dist/commands/telemetry/status.js.map +1 -1
  71. package/dist/context-warnings.d.ts +5 -0
  72. package/dist/context-warnings.js +31 -0
  73. package/dist/context-warnings.js.map +1 -0
  74. package/dist/context-warnings.test.js +28 -0
  75. package/dist/context-warnings.test.js.map +1 -0
  76. package/dist/server/app.d.ts +211 -0
  77. package/dist/server/app.js +277 -0
  78. package/dist/server/app.js.map +1 -0
  79. package/dist/server/app.test.d.ts +1 -0
  80. package/dist/server/app.test.js +178 -0
  81. package/dist/server/app.test.js.map +1 -0
  82. package/dist/server/asset-base-url-transform-plugin.d.ts +1 -0
  83. package/dist/server/asset-base-url-transform-plugin.js +17 -2
  84. package/dist/server/asset-base-url-transform-plugin.js.map +1 -1
  85. package/dist/server/asset-base-url-transform-plugin.test.js +80 -1
  86. package/dist/server/asset-base-url-transform-plugin.test.js.map +1 -1
  87. package/dist/server/auth/discovery.d.ts +33 -0
  88. package/dist/server/auth/discovery.js +56 -0
  89. package/dist/server/auth/discovery.js.map +1 -0
  90. package/dist/server/auth/discovery.test.d.ts +1 -0
  91. package/dist/server/auth/discovery.test.js +93 -0
  92. package/dist/server/auth/discovery.test.js.map +1 -0
  93. package/dist/server/auth/index.d.ts +48 -0
  94. package/dist/server/auth/index.js +2 -0
  95. package/dist/server/auth/index.js.map +1 -0
  96. package/dist/server/auth/providers/auth0.d.ts +40 -0
  97. package/dist/server/auth/providers/auth0.js +36 -0
  98. package/dist/server/auth/providers/auth0.js.map +1 -0
  99. package/dist/server/auth/providers/auth0.test.d.ts +1 -0
  100. package/dist/server/auth/providers/auth0.test.js +50 -0
  101. package/dist/server/auth/providers/auth0.test.js.map +1 -0
  102. package/dist/server/auth/providers/authplane.d.ts +49 -0
  103. package/dist/server/auth/providers/authplane.js +57 -0
  104. package/dist/server/auth/providers/authplane.js.map +1 -0
  105. package/dist/server/auth/providers/authplane.test.d.ts +1 -0
  106. package/dist/server/auth/providers/authplane.test.js +143 -0
  107. package/dist/server/auth/providers/authplane.test.js.map +1 -0
  108. package/dist/server/auth/providers/clerk.d.ts +51 -0
  109. package/dist/server/auth/providers/clerk.js +19 -0
  110. package/dist/server/auth/providers/clerk.js.map +1 -0
  111. package/dist/server/auth/providers/clerk.test.d.ts +1 -0
  112. package/dist/server/auth/providers/clerk.test.js +30 -0
  113. package/dist/server/auth/providers/clerk.test.js.map +1 -0
  114. package/dist/server/auth/providers/custom.d.ts +42 -0
  115. package/dist/server/auth/providers/custom.js +59 -0
  116. package/dist/server/auth/providers/custom.js.map +1 -0
  117. package/dist/server/auth/providers/custom.test.d.ts +1 -0
  118. package/dist/server/auth/providers/custom.test.js +161 -0
  119. package/dist/server/auth/providers/custom.test.js.map +1 -0
  120. package/dist/server/auth/providers/descope.d.ts +44 -0
  121. package/dist/server/auth/providers/descope.js +44 -0
  122. package/dist/server/auth/providers/descope.js.map +1 -0
  123. package/dist/server/auth/providers/descope.test.d.ts +1 -0
  124. package/dist/server/auth/providers/descope.test.js +62 -0
  125. package/dist/server/auth/providers/descope.test.js.map +1 -0
  126. package/dist/server/auth/providers/shared.d.ts +2 -0
  127. package/dist/server/auth/providers/shared.js +6 -0
  128. package/dist/server/auth/providers/shared.js.map +1 -0
  129. package/dist/server/auth/providers/shared.test.d.ts +1 -0
  130. package/dist/server/auth/providers/shared.test.js +10 -0
  131. package/dist/server/auth/providers/shared.test.js.map +1 -0
  132. package/dist/server/auth/providers/stytch.d.ts +25 -0
  133. package/dist/server/auth/providers/stytch.js +16 -0
  134. package/dist/server/auth/providers/stytch.js.map +1 -0
  135. package/dist/server/auth/providers/verify-spy.d.ts +12 -0
  136. package/dist/server/auth/providers/verify-spy.js +21 -0
  137. package/dist/server/auth/providers/verify-spy.js.map +1 -0
  138. package/dist/server/auth/providers/workos.d.ts +34 -0
  139. package/dist/server/auth/providers/workos.js +16 -0
  140. package/dist/server/auth/providers/workos.js.map +1 -0
  141. package/dist/server/auth/security-schemes.d.ts +23 -0
  142. package/dist/server/auth/security-schemes.js +64 -0
  143. package/dist/server/auth/security-schemes.js.map +1 -0
  144. package/dist/server/auth/security-schemes.test.d.ts +1 -0
  145. package/dist/server/auth/security-schemes.test.js +99 -0
  146. package/dist/server/auth/security-schemes.test.js.map +1 -0
  147. package/dist/server/auth/setup.d.ts +6 -0
  148. package/dist/server/auth/setup.js +91 -0
  149. package/dist/server/auth/setup.js.map +1 -0
  150. package/dist/server/auth/setup.test.d.ts +1 -0
  151. package/dist/server/auth/setup.test.js +514 -0
  152. package/dist/server/auth/setup.test.js.map +1 -0
  153. package/dist/server/auth/verify.d.ts +48 -0
  154. package/dist/server/auth/verify.js +62 -0
  155. package/dist/server/auth/verify.js.map +1 -0
  156. package/dist/server/auth/verify.test.d.ts +1 -0
  157. package/dist/server/auth/verify.test.js +165 -0
  158. package/dist/server/auth/verify.test.js.map +1 -0
  159. package/dist/server/auth-extra.test-d.d.ts +1 -0
  160. package/dist/server/auth-extra.test-d.js +130 -0
  161. package/dist/server/auth-extra.test-d.js.map +1 -0
  162. package/dist/server/auth.d.ts +57 -0
  163. package/dist/server/auth.js +27 -0
  164. package/dist/server/auth.js.map +1 -0
  165. package/dist/server/build-manifest.test.d.ts +1 -0
  166. package/dist/server/build-manifest.test.js +28 -0
  167. package/dist/server/build-manifest.test.js.map +1 -0
  168. package/dist/server/content-helpers.d.ts +41 -1
  169. package/dist/server/content-helpers.js +33 -0
  170. package/dist/server/content-helpers.js.map +1 -1
  171. package/dist/server/content-helpers.test.js.map +1 -1
  172. package/dist/server/events.d.ts +113 -0
  173. package/dist/server/events.js +318 -0
  174. package/dist/server/events.js.map +1 -0
  175. package/dist/server/events.test.d.ts +1 -0
  176. package/dist/server/events.test.js +172 -0
  177. package/dist/server/events.test.js.map +1 -0
  178. package/dist/server/express.d.ts +24 -7
  179. package/dist/server/express.js +66 -30
  180. package/dist/server/express.js.map +1 -1
  181. package/dist/server/express.test.js +445 -81
  182. package/dist/server/express.test.js.map +1 -1
  183. package/dist/server/file-ref.d.ts +28 -0
  184. package/dist/server/file-ref.js +27 -0
  185. package/dist/server/file-ref.js.map +1 -0
  186. package/dist/server/form-input.d.ts +120 -0
  187. package/dist/server/form-input.js +89 -0
  188. package/dist/server/form-input.js.map +1 -0
  189. package/dist/server/host.d.ts +2 -0
  190. package/dist/server/host.js +11 -0
  191. package/dist/server/host.js.map +1 -0
  192. package/dist/server/host.test.d.ts +1 -0
  193. package/dist/server/host.test.js +13 -0
  194. package/dist/server/host.test.js.map +1 -0
  195. package/dist/server/index.d.ts +20 -2
  196. package/dist/server/index.js +17 -1
  197. package/dist/server/index.js.map +1 -1
  198. package/dist/server/inferUtilityTypes.d.ts +6 -6
  199. package/dist/server/inferUtilityTypes.js.map +1 -1
  200. package/dist/server/mcp-errors.test.d.ts +1 -0
  201. package/dist/server/mcp-errors.test.js +229 -0
  202. package/dist/server/mcp-errors.test.js.map +1 -0
  203. package/dist/server/metric.d.ts +5 -3
  204. package/dist/server/metric.js +5 -5
  205. package/dist/server/metric.js.map +1 -1
  206. package/dist/server/middleware.d.ts +51 -13
  207. package/dist/server/middleware.js +33 -0
  208. package/dist/server/middleware.js.map +1 -1
  209. package/dist/server/middleware.test-d.js +1 -1
  210. package/dist/server/middleware.test-d.js.map +1 -1
  211. package/dist/server/middleware.test.js +242 -134
  212. package/dist/server/middleware.test.js.map +1 -1
  213. package/dist/server/register-tool.test.d.ts +1 -0
  214. package/dist/server/register-tool.test.js +230 -0
  215. package/dist/server/register-tool.test.js.map +1 -0
  216. package/dist/server/requestOrigin.d.ts +7 -0
  217. package/dist/server/requestOrigin.js +25 -0
  218. package/dist/server/requestOrigin.js.map +1 -0
  219. package/dist/server/server.d.ts +548 -56
  220. package/dist/server/server.js +685 -286
  221. package/dist/server/server.js.map +1 -1
  222. package/dist/server/skills-integration.test.d.ts +1 -0
  223. package/dist/server/skills-integration.test.js +86 -0
  224. package/dist/server/skills-integration.test.js.map +1 -0
  225. package/dist/server/skills.d.ts +27 -0
  226. package/dist/server/skills.js +188 -0
  227. package/dist/server/skills.js.map +1 -0
  228. package/dist/server/skills.test.d.ts +1 -0
  229. package/dist/server/skills.test.js +243 -0
  230. package/dist/server/skills.test.js.map +1 -0
  231. package/dist/server/templateHelper.d.ts +0 -5
  232. package/dist/server/templateHelper.js +3 -22
  233. package/dist/server/templateHelper.js.map +1 -1
  234. package/dist/server/templates.generated.d.ts +4 -0
  235. package/dist/server/templates.generated.js +43 -0
  236. package/dist/server/templates.generated.js.map +1 -0
  237. package/dist/server/tool-extra.test.d.ts +1 -0
  238. package/dist/server/tool-extra.test.js +167 -0
  239. package/dist/server/tool-extra.test.js.map +1 -0
  240. package/dist/server/tunnel-proxy-router.d.ts +7 -0
  241. package/dist/server/tunnel-proxy-router.js +110 -0
  242. package/dist/server/tunnel-proxy-router.js.map +1 -0
  243. package/dist/server/tunnel-proxy-router.test.d.ts +1 -0
  244. package/dist/server/tunnel-proxy-router.test.js +229 -0
  245. package/dist/server/tunnel-proxy-router.test.js.map +1 -0
  246. package/dist/server/view-name.test-d.d.ts +1 -0
  247. package/dist/server/view-name.test-d.js +8 -0
  248. package/dist/server/view-name.test-d.js.map +1 -0
  249. package/dist/server/view-resource-resolution.test.d.ts +6 -0
  250. package/dist/server/view-resource-resolution.test.js +176 -0
  251. package/dist/server/view-resource-resolution.test.js.map +1 -0
  252. package/dist/server/viewsDevServer.js +4 -1
  253. package/dist/server/viewsDevServer.js.map +1 -1
  254. package/dist/test/utils.d.ts +9 -11
  255. package/dist/test/utils.js +220 -201
  256. package/dist/test/utils.js.map +1 -1
  257. package/dist/test/view.test.js +199 -113
  258. package/dist/test/view.test.js.map +1 -1
  259. package/dist/version.js +1 -3
  260. package/dist/version.js.map +1 -1
  261. package/dist/views/index.d.ts +10 -0
  262. package/dist/views/index.js +3 -0
  263. package/dist/views/index.js.map +1 -0
  264. package/dist/{web/plugin → views}/scan-views.d.ts +8 -0
  265. package/dist/{web/plugin → views}/scan-views.js +26 -8
  266. package/dist/views/scan-views.js.map +1 -0
  267. package/dist/views/scan-views.test.d.ts +1 -0
  268. package/dist/{web/plugin → views}/scan-views.test.js +33 -1
  269. package/dist/views/scan-views.test.js.map +1 -0
  270. package/dist/views/validate-view.d.ts +1 -0
  271. package/dist/{web/plugin → views}/validate-view.js +2 -2
  272. package/dist/views/validate-view.js.map +1 -0
  273. package/dist/views/validate-view.test.d.ts +1 -0
  274. package/dist/views/validate-view.test.js.map +1 -0
  275. package/dist/web/bridges/adaptor.d.ts +62 -0
  276. package/dist/web/bridges/adaptor.js +477 -0
  277. package/dist/web/bridges/adaptor.js.map +1 -0
  278. package/dist/web/bridges/adaptor.test.d.ts +1 -0
  279. package/dist/web/bridges/adaptor.test.js +281 -0
  280. package/dist/web/bridges/adaptor.test.js.map +1 -0
  281. package/dist/web/bridges/apps-sdk/bridge.d.ts +6 -1
  282. package/dist/web/bridges/apps-sdk/bridge.js +15 -3
  283. package/dist/web/bridges/apps-sdk/bridge.js.map +1 -1
  284. package/dist/web/bridges/apps-sdk/index.d.ts +0 -1
  285. package/dist/web/bridges/apps-sdk/index.js +0 -1
  286. package/dist/web/bridges/apps-sdk/index.js.map +1 -1
  287. package/dist/web/bridges/apps-sdk/types.d.ts +10 -4
  288. package/dist/web/bridges/apps-sdk/types.js.map +1 -1
  289. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.d.ts +11 -0
  290. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js +11 -0
  291. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js.map +1 -1
  292. package/dist/web/bridges/get-adaptor.d.ts +7 -0
  293. package/dist/web/bridges/get-adaptor.js +9 -7
  294. package/dist/web/bridges/get-adaptor.js.map +1 -1
  295. package/dist/web/bridges/get-adaptor.test.d.ts +1 -0
  296. package/dist/web/bridges/get-adaptor.test.js +32 -0
  297. package/dist/web/bridges/get-adaptor.test.js.map +1 -0
  298. package/dist/web/bridges/index.js.map +1 -1
  299. package/dist/web/bridges/mcp-app/bridge.d.ts +15 -2
  300. package/dist/web/bridges/mcp-app/bridge.js +80 -7
  301. package/dist/web/bridges/mcp-app/bridge.js.map +1 -1
  302. package/dist/web/bridges/mcp-app/bridge.test.d.ts +1 -0
  303. package/dist/web/bridges/mcp-app/bridge.test.js +17 -0
  304. package/dist/web/bridges/mcp-app/bridge.test.js.map +1 -0
  305. package/dist/web/bridges/mcp-app/index.d.ts +0 -1
  306. package/dist/web/bridges/mcp-app/index.js +0 -1
  307. package/dist/web/bridges/mcp-app/index.js.map +1 -1
  308. package/dist/web/bridges/mcp-app/types.d.ts +19 -2
  309. package/dist/web/bridges/mcp-app/types.js.map +1 -1
  310. package/dist/web/bridges/mcp-app/use-mcp-app-context.d.ts +13 -1
  311. package/dist/web/bridges/mcp-app/use-mcp-app-context.js +12 -0
  312. package/dist/web/bridges/mcp-app/use-mcp-app-context.js.map +1 -1
  313. package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js +1 -1
  314. package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js.map +1 -1
  315. package/dist/web/bridges/mcp-app/view-tools.test.d.ts +1 -0
  316. package/dist/web/bridges/mcp-app/view-tools.test.js +143 -0
  317. package/dist/web/bridges/mcp-app/view-tools.test.js.map +1 -0
  318. package/dist/web/bridges/types.d.ts +174 -11
  319. package/dist/web/bridges/types.js +14 -1
  320. package/dist/web/bridges/types.js.map +1 -1
  321. package/dist/web/bridges/types.test.d.ts +1 -0
  322. package/dist/web/bridges/types.test.js +19 -0
  323. package/dist/web/bridges/types.test.js.map +1 -0
  324. package/dist/web/bridges/use-host-context.d.ts +5 -0
  325. package/dist/web/bridges/use-host-context.js +5 -0
  326. package/dist/web/bridges/use-host-context.js.map +1 -1
  327. package/dist/web/components/modal-provider.d.ts +1 -1
  328. package/dist/web/components/modal-provider.js +4 -3
  329. package/dist/web/components/modal-provider.js.map +1 -1
  330. package/dist/web/create-store.d.ts +26 -0
  331. package/dist/web/create-store.js +35 -9
  332. package/dist/web/create-store.js.map +1 -1
  333. package/dist/web/create-store.test.js +24 -23
  334. package/dist/web/create-store.test.js.map +1 -1
  335. package/dist/web/data-llm.d.ts +35 -2
  336. package/dist/web/data-llm.js +34 -5
  337. package/dist/web/data-llm.js.map +1 -1
  338. package/dist/web/data-llm.test.js +48 -29
  339. package/dist/web/data-llm.test.js.map +1 -1
  340. package/dist/web/generate-helpers.d.ts +25 -19
  341. package/dist/web/generate-helpers.js +23 -17
  342. package/dist/web/generate-helpers.js.map +1 -1
  343. package/dist/web/generate-helpers.test-d.js +14 -12
  344. package/dist/web/generate-helpers.test-d.js.map +1 -1
  345. package/dist/web/generate-helpers.test.js +2 -2
  346. package/dist/web/generate-helpers.test.js.map +1 -1
  347. package/dist/web/helpers/state.d.ts +2 -2
  348. package/dist/web/helpers/state.js +11 -11
  349. package/dist/web/helpers/state.js.map +1 -1
  350. package/dist/web/helpers/state.test.js +9 -9
  351. package/dist/web/helpers/state.test.js.map +1 -1
  352. package/dist/web/hooks/index.d.ts +11 -2
  353. package/dist/web/hooks/index.js +11 -2
  354. package/dist/web/hooks/index.js.map +1 -1
  355. package/dist/web/hooks/openai-extensions.test.d.ts +1 -0
  356. package/dist/web/hooks/openai-extensions.test.js +107 -0
  357. package/dist/web/hooks/openai-extensions.test.js.map +1 -0
  358. package/dist/web/hooks/test/utils.d.ts +7 -2
  359. package/dist/web/hooks/test/utils.js +14 -3
  360. package/dist/web/hooks/test/utils.js.map +1 -1
  361. package/dist/web/hooks/use-call-tool.d.ts +47 -2
  362. package/dist/web/hooks/use-call-tool.js +43 -10
  363. package/dist/web/hooks/use-call-tool.js.map +1 -1
  364. package/dist/web/hooks/use-call-tool.test-d.js.map +1 -1
  365. package/dist/web/hooks/use-call-tool.test.js +75 -29
  366. package/dist/web/hooks/use-call-tool.test.js.map +1 -1
  367. package/dist/web/hooks/use-deep-link.d.ts +22 -0
  368. package/dist/web/hooks/use-deep-link.js +34 -0
  369. package/dist/web/hooks/use-deep-link.js.map +1 -0
  370. package/dist/web/hooks/use-display-mode.d.ts +20 -0
  371. package/dist/web/hooks/use-display-mode.js +20 -0
  372. package/dist/web/hooks/use-display-mode.js.map +1 -1
  373. package/dist/web/hooks/use-display-mode.test-d.js.map +1 -1
  374. package/dist/web/hooks/use-display-mode.test.js +57 -21
  375. package/dist/web/hooks/use-display-mode.test.js.map +1 -1
  376. package/dist/web/hooks/use-download.d.ts +3 -0
  377. package/dist/web/hooks/use-download.js +7 -0
  378. package/dist/web/hooks/use-download.js.map +1 -0
  379. package/dist/web/hooks/use-download.test.d.ts +1 -0
  380. package/dist/web/hooks/use-download.test.js +103 -0
  381. package/dist/web/hooks/use-download.test.js.map +1 -0
  382. package/dist/web/hooks/use-file-resource.d.ts +37 -0
  383. package/dist/web/hooks/use-file-resource.js +98 -0
  384. package/dist/web/hooks/use-file-resource.js.map +1 -0
  385. package/dist/web/hooks/use-file-resource.test.d.ts +1 -0
  386. package/dist/web/hooks/use-file-resource.test.js +65 -0
  387. package/dist/web/hooks/use-file-resource.test.js.map +1 -0
  388. package/dist/web/hooks/use-files.d.ts +32 -0
  389. package/dist/web/hooks/use-files.js +32 -0
  390. package/dist/web/hooks/use-files.js.map +1 -1
  391. package/dist/web/hooks/use-files.test.js +11 -3
  392. package/dist/web/hooks/use-files.test.js.map +1 -1
  393. package/dist/web/hooks/use-host.d.ts +44 -0
  394. package/dist/web/hooks/use-host.js +45 -0
  395. package/dist/web/hooks/use-host.js.map +1 -0
  396. package/dist/web/hooks/use-host.test.d.ts +1 -0
  397. package/dist/web/hooks/use-host.test.js +59 -0
  398. package/dist/web/hooks/use-host.test.js.map +1 -0
  399. package/dist/web/hooks/use-model-context.d.ts +44 -0
  400. package/dist/web/hooks/use-model-context.js +63 -0
  401. package/dist/web/hooks/use-model-context.js.map +1 -0
  402. package/dist/web/hooks/use-open-external.d.ts +17 -0
  403. package/dist/web/hooks/use-open-external.js +16 -0
  404. package/dist/web/hooks/use-open-external.js.map +1 -1
  405. package/dist/web/hooks/use-open-external.test.js +15 -5
  406. package/dist/web/hooks/use-open-external.test.js.map +1 -1
  407. package/dist/web/hooks/use-open-file.d.ts +20 -0
  408. package/dist/web/hooks/use-open-file.js +25 -0
  409. package/dist/web/hooks/use-open-file.js.map +1 -0
  410. package/dist/web/hooks/use-register-view-tool.d.ts +37 -0
  411. package/dist/web/hooks/use-register-view-tool.js +50 -0
  412. package/dist/web/hooks/use-register-view-tool.js.map +1 -0
  413. package/dist/web/hooks/use-request-close.d.ts +16 -0
  414. package/dist/web/hooks/use-request-close.js +21 -0
  415. package/dist/web/hooks/use-request-close.js.map +1 -0
  416. package/dist/web/hooks/use-request-close.test.d.ts +1 -0
  417. package/dist/web/hooks/use-request-close.test.js +47 -0
  418. package/dist/web/hooks/use-request-close.test.js.map +1 -0
  419. package/dist/web/hooks/use-request-modal.d.ts +16 -1
  420. package/dist/web/hooks/use-request-modal.js +19 -4
  421. package/dist/web/hooks/use-request-modal.js.map +1 -1
  422. package/dist/web/hooks/use-request-modal.test.js +12 -2
  423. package/dist/web/hooks/use-request-modal.test.js.map +1 -1
  424. package/dist/web/hooks/use-request-size.d.ts +20 -0
  425. package/dist/web/hooks/use-request-size.js +24 -0
  426. package/dist/web/hooks/use-request-size.js.map +1 -0
  427. package/dist/web/hooks/use-request-size.test.d.ts +1 -0
  428. package/dist/web/hooks/use-request-size.test.js +47 -0
  429. package/dist/web/hooks/use-request-size.test.js.map +1 -0
  430. package/dist/web/hooks/use-send-follow-up-message.d.ts +25 -1
  431. package/dist/web/hooks/use-send-follow-up-message.js +25 -2
  432. package/dist/web/hooks/use-send-follow-up-message.js.map +1 -1
  433. package/dist/web/hooks/use-set-open-in-app-url.d.ts +17 -0
  434. package/dist/web/hooks/use-set-open-in-app-url.js +17 -0
  435. package/dist/web/hooks/use-set-open-in-app-url.js.map +1 -1
  436. package/dist/web/hooks/use-set-open-in-app-url.test.js +26 -12
  437. package/dist/web/hooks/use-set-open-in-app-url.test.js.map +1 -1
  438. package/dist/web/hooks/use-tool-info.d.ts +46 -14
  439. package/dist/web/hooks/use-tool-info.js +29 -7
  440. package/dist/web/hooks/use-tool-info.js.map +1 -1
  441. package/dist/web/hooks/use-tool-info.test-d.js +11 -34
  442. package/dist/web/hooks/use-tool-info.test-d.js.map +1 -1
  443. package/dist/web/hooks/use-tool-info.test.js +42 -37
  444. package/dist/web/hooks/use-tool-info.test.js.map +1 -1
  445. package/dist/web/hooks/use-user.d.ts +5 -2
  446. package/dist/web/hooks/use-user.js +6 -3
  447. package/dist/web/hooks/use-user.js.map +1 -1
  448. package/dist/web/hooks/use-user.test.js +85 -37
  449. package/dist/web/hooks/use-user.test.js.map +1 -1
  450. package/dist/web/hooks/use-view-state.d.ts +25 -0
  451. package/dist/web/hooks/use-view-state.js +42 -0
  452. package/dist/web/hooks/use-view-state.js.map +1 -0
  453. package/dist/web/hooks/use-view-state.test.d.ts +1 -0
  454. package/dist/web/hooks/{use-widget-state.test.js → use-view-state.test.js} +56 -21
  455. package/dist/web/hooks/use-view-state.test.js.map +1 -0
  456. package/dist/web/hooks/use-viewport.d.ts +20 -0
  457. package/dist/web/hooks/use-viewport.js +21 -0
  458. package/dist/web/hooks/use-viewport.js.map +1 -0
  459. package/dist/web/hooks/use-viewport.test.d.ts +1 -0
  460. package/dist/web/hooks/use-viewport.test.js +109 -0
  461. package/dist/web/hooks/use-viewport.test.js.map +1 -0
  462. package/dist/web/index.d.ts +1 -3
  463. package/dist/web/index.js +1 -2
  464. package/dist/web/index.js.map +1 -1
  465. package/dist/web/mount-view.d.ts +21 -0
  466. package/dist/web/mount-view.js +43 -0
  467. package/dist/web/mount-view.js.map +1 -0
  468. package/dist/web/proxy.js.map +1 -1
  469. package/dist/web/types.d.ts +4 -0
  470. package/dist/web/types.js.map +1 -1
  471. package/package.json +46 -28
  472. package/dist/server/templates/development.hbs +0 -12
  473. package/dist/server/templates/production.hbs +0 -6
  474. package/dist/web/bridges/apps-sdk/adaptor.d.ts +0 -24
  475. package/dist/web/bridges/apps-sdk/adaptor.js +0 -87
  476. package/dist/web/bridges/apps-sdk/adaptor.js.map +0 -1
  477. package/dist/web/bridges/mcp-app/adaptor.d.ts +0 -48
  478. package/dist/web/bridges/mcp-app/adaptor.js +0 -268
  479. package/dist/web/bridges/mcp-app/adaptor.js.map +0 -1
  480. package/dist/web/hooks/use-layout.d.ts +0 -22
  481. package/dist/web/hooks/use-layout.js +0 -23
  482. package/dist/web/hooks/use-layout.js.map +0 -1
  483. package/dist/web/hooks/use-layout.test.js +0 -96
  484. package/dist/web/hooks/use-layout.test.js.map +0 -1
  485. package/dist/web/hooks/use-widget-state.d.ts +0 -4
  486. package/dist/web/hooks/use-widget-state.js +0 -32
  487. package/dist/web/hooks/use-widget-state.js.map +0 -1
  488. package/dist/web/hooks/use-widget-state.test.js.map +0 -1
  489. package/dist/web/mount-widget.d.ts +0 -1
  490. package/dist/web/mount-widget.js +0 -27
  491. package/dist/web/mount-widget.js.map +0 -1
  492. package/dist/web/plugin/data-llm.test.js +0 -81
  493. package/dist/web/plugin/data-llm.test.js.map +0 -1
  494. package/dist/web/plugin/plugin.d.ts +0 -5
  495. package/dist/web/plugin/plugin.js +0 -141
  496. package/dist/web/plugin/plugin.js.map +0 -1
  497. package/dist/web/plugin/scan-views.js.map +0 -1
  498. package/dist/web/plugin/scan-views.test.js.map +0 -1
  499. package/dist/web/plugin/transform-data-llm.d.ts +0 -12
  500. package/dist/web/plugin/transform-data-llm.js +0 -96
  501. package/dist/web/plugin/transform-data-llm.js.map +0 -1
  502. package/dist/web/plugin/transform-data-llm.test.js +0 -81
  503. package/dist/web/plugin/transform-data-llm.test.js.map +0 -1
  504. package/dist/web/plugin/validate-view.d.ts +0 -1
  505. package/dist/web/plugin/validate-view.js.map +0 -1
  506. package/dist/web/plugin/validate-view.test.js.map +0 -1
  507. /package/dist/{web/hooks/use-layout.test.d.ts → cli/build-helpers.test.d.ts} +0 -0
  508. /package/dist/{web/hooks/use-widget-state.test.d.ts → cli/build-steps.test.d.ts} +0 -0
  509. /package/dist/{web/plugin/data-llm.test.d.ts → cli/tunnel-control-server.test.d.ts} +0 -0
  510. /package/dist/{web/plugin/scan-views.test.d.ts → cli/tunnel-handler.test.d.ts} +0 -0
  511. /package/dist/{web/plugin/transform-data-llm.test.d.ts → cli/tunnel.test.d.ts} +0 -0
  512. /package/dist/{web/plugin/validate-view.test.d.ts → context-warnings.test.d.ts} +0 -0
  513. /package/dist/{web/plugin → views}/validate-view.test.js +0 -0
@@ -7,24 +7,28 @@ import { useToolInfo } from "./hooks/use-tool-info.js";
7
7
  * This is the recommended way to use skybridge hooks in your views.
8
8
  * Set this up once in a dedicated file and export the typed hooks for use across your app.
9
9
  *
10
- * @typeParam ServerType - The type of your McpServer instance (use `typeof server`).
11
- * Must be a server instance created with method chaining.
12
- * TypeScript will validate that tools can be inferred from this type.
10
+ * @typeParam AppType - The type of your Skybridge app (use `typeof app`). The
11
+ * handler must return the chained server so the tool
12
+ * types are carried on the app type.
13
13
  *
14
14
  * @example
15
15
  * ```typescript
16
16
  * // src/server.ts
17
- * const server = new McpServer({ name: "my-app", version: "1.0" }, {})
18
- * .registerTool({
19
- * name: "search-trip",
20
- * inputSchema: { destination: z.string() },
21
- * outputSchema: { results: z.array(z.string()) },
22
- * view: { component: "search-trip", description: "Search trips" },
23
- * }, async ({ destination }) => {
24
- * return { content: [{ type: "text", text: `Found trips to ${destination}` }] };
25
- * });
17
+ * export const app = new Skybridge({
18
+ * name: "my-app",
19
+ * version: "1.0",
20
+ * handler: (server) =>
21
+ * server.registerTool({
22
+ * name: "search-trip",
23
+ * inputSchema: { destination: z.string() },
24
+ * outputSchema: { results: z.array(z.string()) },
25
+ * view: { component: "search-trip", description: "Search trips" },
26
+ * }, async ({ destination }) => {
27
+ * return { content: [{ type: "text", text: `Found trips to ${destination}` }] };
28
+ * }),
29
+ * });
26
30
  *
27
- * export type AppType = typeof server;
31
+ * export type AppType = typeof app;
28
32
  * ```
29
33
  *
30
34
  * @example
@@ -53,6 +57,8 @@ import { useToolInfo } from "./hooks/use-tool-info.js";
53
57
  * // toolInfo.output.structuredContent is typed based on view output schema
54
58
  * }
55
59
  * ```
60
+ *
61
+ * @see https://docs.skybridge.tech/api-reference/generate-helpers
56
62
  */
57
63
  export function generateHelpers() {
58
64
  return {
@@ -60,7 +66,7 @@ export function generateHelpers() {
60
66
  * Typed version of `useCallTool` that provides autocomplete for tool names
61
67
  * and type inference for inputs and outputs.
62
68
  *
63
- * @param name - The name of the tool to call. Autocompletes based on your server's tool registry.
69
+ * @param name - The name of the tool to call. Autocompletes based on your app's tool registry.
64
70
  * @returns A hook with typed `callTool` function and `data` property.
65
71
  *
66
72
  * @example
@@ -75,14 +81,14 @@ export function generateHelpers() {
75
81
  * }
76
82
  * ```
77
83
  */
78
- useCallTool: (name) => {
79
- return useCallTool(name);
84
+ useCallTool: (name, options) => {
85
+ return useCallTool(name, options);
80
86
  },
81
87
  /**
82
88
  * Typed version of `useToolInfo` that provides autocomplete for tool names
83
89
  * and type inference for inputs, outputs, and responseMetadata.
84
90
  *
85
- * @typeParam K - The name of the tool. Autocompletes based on your server's tool registry.
91
+ * @typeParam K - The name of the tool. Autocompletes based on your app's tool registry.
86
92
  * @returns A discriminated union with `status: "pending" | "success"` that narrows correctly.
87
93
  *
88
94
  * @example
@@ -1 +1 @@
1
- {"version":3,"file":"generate-helpers.js","sourceRoot":"","sources":["../../src/web/generate-helpers.ts"],"names":[],"mappings":"AAOA,OAAO,EAIL,WAAW,GACZ,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAkB,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAoBvE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,MAAM,UAAU,eAAe;IAI7B,OAAO;QACL;;;;;;;;;;;;;;;;;;WAkBG;QACH,WAAW,EAAE,CACX,IAAc,EAId,EAAE;YACF,OAAO,WAAW,CAAC,IAAI,CAGtB,CAAC;QACJ,CAAC;QAED;;;;;;;;;;;;;;;;;;;;;;;;;;WA0BG;QACH,WAAW,EAAE,GAIX,EAAE;YACF,OAAO,WAAW,EAIjB,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"generate-helpers.js","sourceRoot":"","sources":["../../src/web/generate-helpers.ts"],"names":[],"mappings":"AAOA,OAAO,EAIL,WAAW,GACZ,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAkB,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAoBvE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH,MAAM,UAAU,eAAe;IAI7B,OAAO;QACL;;;;;;;;;;;;;;;;;;WAkBG;QACH,WAAW,EAAE,CACX,IAAc,EACd,OAAyB,EAIzB,EAAE;YACF,OAAO,WAAW,CAAC,IAAI,EAAE,OAAO,CAG/B,CAAC;QACJ,CAAC;QAED;;;;;;;;;;;;;;;;;;;;;;;;;;WA0BG;QACH,WAAW,EAAE,GAIX,EAAE;YACF,OAAO,WAAW,EAIjB,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type {\n InferTools,\n ToolInput,\n ToolOutput,\n ToolResponseMetadata,\n} from \"../server/index.js\";\nimport type { CallToolOptions, CallToolResponse } from \"./bridges/types.js\";\nimport {\n type CallToolAsyncFn,\n type CallToolFn,\n type CallToolState,\n useCallTool,\n} from \"./hooks/use-call-tool.js\";\nimport { type ToolState, useToolInfo } from \"./hooks/use-tool-info.js\";\nimport type { Objectify, Prettify } from \"./types.js\";\n\ntype TypedCallToolResponse<TOutput> = CallToolResponse & {\n structuredContent: TOutput;\n};\n\ntype TypedCallToolReturn<TInput, TOutput> = Prettify<\n CallToolState<TypedCallToolResponse<TOutput>> & {\n callTool: CallToolFn<TInput, TypedCallToolResponse<TOutput>>;\n callToolAsync: CallToolAsyncFn<TInput, TypedCallToolResponse<TOutput>>;\n }\n>;\n\ntype TypedToolInfoReturn<TInput, TOutput, TResponseMetadata> = ToolState<\n Objectify<TInput>,\n Objectify<TOutput>,\n Objectify<TResponseMetadata>\n>;\n\n/**\n * Creates typed versions of skybridge hooks with full type inference\n * for tool names, inputs, and outputs.\n *\n * This is the recommended way to use skybridge hooks in your views.\n * Set this up once in a dedicated file and export the typed hooks for use across your app.\n *\n * @typeParam AppType - The type of your Skybridge app (use `typeof app`). The\n * handler must return the chained server so the tool\n * types are carried on the app type.\n *\n * @example\n * ```typescript\n * // src/server.ts\n * export const app = new Skybridge({\n * name: \"my-app\",\n * version: \"1.0\",\n * handler: (server) =>\n * server.registerTool({\n * name: \"search-trip\",\n * inputSchema: { destination: z.string() },\n * outputSchema: { results: z.array(z.string()) },\n * view: { component: \"search-trip\", description: \"Search trips\" },\n * }, async ({ destination }) => {\n * return { content: [{ type: \"text\", text: `Found trips to ${destination}` }] };\n * }),\n * });\n *\n * export type AppType = typeof app;\n * ```\n *\n * @example\n * ```typescript\n * // src/helpers.ts (one-time setup)\n * import type { AppType } from \"./server\";\n * import { generateHelpers } from \"skybridge/web\";\n *\n * export const { useCallTool, useToolInfo } = generateHelpers<AppType>();\n * ```\n *\n * @example\n * ```typescript\n * // src/views/search.tsx (usage)\n * import { useCallTool, useToolInfo } from \"../helpers\";\n *\n * export function SearchView() {\n * const { callTool, data } = useCallTool(\"search-trip\");\n * // ^ autocomplete for tool names\n * callTool({ destination: \"Spain\" });\n * // ^ autocomplete for input fields\n *\n * const toolInfo = useToolInfo<\"search-trip\">();\n * // ^ autocomplete for view names\n * // toolInfo.input is typed based on view input schema\n * // toolInfo.output.structuredContent is typed based on view output schema\n * }\n * ```\n *\n * @see https://docs.skybridge.tech/api-reference/generate-helpers\n */\nexport function generateHelpers<AppType = never>() {\n type Tools = InferTools<AppType>;\n type ToolNames = keyof Tools & string;\n\n return {\n /**\n * Typed version of `useCallTool` that provides autocomplete for tool names\n * and type inference for inputs and outputs.\n *\n * @param name - The name of the tool to call. Autocompletes based on your app's tool registry.\n * @returns A hook with typed `callTool` function and `data` property.\n *\n * @example\n * ```typescript\n * const { callTool, data, isPending } = useCallTool(\"search-trip\");\n * // TypeScript knows callTool expects { destination: string }\n * callTool({ destination: \"Spain\" });\n *\n * // data.structuredContent is typed based on your outputSchema\n * if (data) {\n * console.log(data.structuredContent.results);\n * }\n * ```\n */\n useCallTool: <ToolName extends ToolNames>(\n name: ToolName,\n options?: CallToolOptions,\n ): TypedCallToolReturn<\n ToolInput<AppType, ToolName>,\n ToolOutput<AppType, ToolName>\n > => {\n return useCallTool(name, options) as TypedCallToolReturn<\n ToolInput<AppType, ToolName>,\n ToolOutput<AppType, ToolName>\n >;\n },\n\n /**\n * Typed version of `useToolInfo` that provides autocomplete for tool names\n * and type inference for inputs, outputs, and responseMetadata.\n *\n * @typeParam K - The name of the tool. Autocompletes based on your app's tool registry.\n * @returns A discriminated union with `status: \"pending\" | \"success\"` that narrows correctly.\n *\n * @example\n * ```typescript\n * const toolInfo = useToolInfo<\"search-trip\">();\n * // toolInfo.input is typed as { destination: string; ... }\n * // toolInfo.output is typed as { results: Array<...>; ... }\n * // toolInfo.responseMetadata is typed based on _meta in callback return\n * // toolInfo.status narrows correctly: \"pending\" | \"success\"\n *\n * if (toolInfo.isPending) {\n * // TypeScript knows output and responseMetadata are undefined here\n * console.log(toolInfo.input.destination);\n * }\n *\n * if (toolInfo.isSuccess) {\n * // TypeScript knows output and responseMetadata are defined here\n * console.log(toolInfo.output.results);\n * console.log(toolInfo.responseMetadata);\n * }\n * ```\n */\n useToolInfo: <ToolName extends ToolNames>(): TypedToolInfoReturn<\n ToolInput<AppType, ToolName>,\n ToolOutput<AppType, ToolName>,\n ToolResponseMetadata<AppType, ToolName>\n > => {\n return useToolInfo() as TypedToolInfoReturn<\n ToolInput<AppType, ToolName>,\n ToolOutput<AppType, ToolName>,\n ToolResponseMetadata<AppType, ToolName>\n >;\n },\n };\n}\n"]}
@@ -1,9 +1,9 @@
1
1
  import { expectTypeOf, test } from "vitest";
2
- import { createInterfaceTestServer, createTestServer } from "../test/utils.js";
2
+ import { createInterfaceTestApp, createTestApp } from "../test/utils.js";
3
3
  import { generateHelpers } from "./generate-helpers.js";
4
- const server = createTestServer();
5
- const interfaceServer = createInterfaceTestServer();
6
- test("InferTools extracts the tool registry type (widgets + registerTool)", () => {
4
+ const app = createTestApp();
5
+ const interfaceApp = createInterfaceTestApp();
6
+ test("InferTools extracts the tool registry type (views + registerTool)", () => {
7
7
  expectTypeOf().toHaveProperty("search-trip");
8
8
  expectTypeOf().toHaveProperty("get-trip-details");
9
9
  expectTypeOf().toHaveProperty("no-input-view");
@@ -14,7 +14,7 @@ test("InferTools extracts the tool registry type (widgets + registerTool)", () =
14
14
  expectTypeOf().toHaveProperty("tool-with-metadata");
15
15
  expectTypeOf().toHaveProperty("view-with-mixed-returns");
16
16
  });
17
- test("ToolNames returns a union of tool name literals (widgets + registerTool)", () => {
17
+ test("ToolNames returns a union of tool name literals (views + registerTool)", () => {
18
18
  expectTypeOf().toEqualTypeOf();
19
19
  });
20
20
  test("ToolInput extracts the correct input type from Zod schema", () => {
@@ -32,7 +32,7 @@ test("ToolOutput extracts the correct output type from callback (inferred)", ()
32
32
  expectTypeOf().toEqualTypeOf();
33
33
  expectTypeOf().toEqualTypeOf();
34
34
  });
35
- test("generateHelpers provides autocomplete for tool names (widgets + registerTool)", () => {
35
+ test("generateHelpers provides autocomplete for tool names (views + registerTool)", () => {
36
36
  const { useCallTool } = generateHelpers();
37
37
  useCallTool("search-trip");
38
38
  useCallTool("get-trip-details");
@@ -128,16 +128,16 @@ test("useCallTool returns correctly typed data", () => {
128
128
  });
129
129
  test("useCallTool returns correctly typed data for callback-inferred outputs", () => {
130
130
  const { useCallTool } = generateHelpers();
131
- const { data: widgetData } = useCallTool("inferred-output-view");
132
- if (widgetData) {
133
- expectTypeOf(widgetData.structuredContent).toExtend();
131
+ const { data: viewData } = useCallTool("inferred-output-view");
132
+ if (viewData) {
133
+ expectTypeOf(viewData.structuredContent).toExtend();
134
134
  }
135
135
  const { data: toolData } = useCallTool("inferred-tool");
136
136
  if (toolData) {
137
137
  expectTypeOf(toolData.structuredContent).toExtend();
138
138
  }
139
139
  });
140
- test("generateHelpers provides autocomplete for tool names in useToolInfo (widgets + registerTool)", () => {
140
+ test("generateHelpers provides autocomplete for tool names in useToolInfo (views + registerTool)", () => {
141
141
  const { useToolInfo } = generateHelpers();
142
142
  useToolInfo();
143
143
  useToolInfo();
@@ -154,11 +154,13 @@ test("generateHelpers provides autocomplete for tool names in useToolInfo (widge
154
154
  test("useToolInfo infers input and output types", () => {
155
155
  const { useToolInfo } = generateHelpers();
156
156
  const toolInfo = useToolInfo();
157
- // Input is only available when not in idle state
158
- if (!(toolInfo.status === "idle")) {
157
+ // Input is optional in pending — host may not have delivered args yet
158
+ if (toolInfo.status === "pending") {
159
159
  expectTypeOf(toolInfo.input).toExtend();
160
160
  }
161
161
  if (toolInfo.status === "success") {
162
+ // Input is optional in success — the host may not have surfaced args yet
163
+ expectTypeOf(toolInfo.input).toExtend();
162
164
  expectTypeOf(toolInfo.output).toExtend();
163
165
  expectTypeOf(toolInfo.output.results).toBeArray();
164
166
  expectTypeOf(toolInfo.output.totalCount).toBeNumber();
@@ -1 +1 @@
1
- {"version":3,"file":"generate-helpers.test-d.js","sourceRoot":"","sources":["../../src/web/generate-helpers.test-d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAQ5C,OAAO,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,MAAM,MAAM,GAAG,gBAAgB,EAAE,CAAC;AAGlC,MAAM,eAAe,GAAG,yBAAyB,EAAE,CAAC;AAGpD,IAAI,CAAC,qEAAqE,EAAE,GAAG,EAAE;IAG/E,YAAY,EAAS,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;IACpD,YAAY,EAAS,CAAC,cAAc,CAAC,kBAAkB,CAAC,CAAC;IACzD,YAAY,EAAS,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC;IACtD,YAAY,EAAS,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC;IACxD,YAAY,EAAS,CAAC,cAAc,CAAC,sBAAsB,CAAC,CAAC;IAC7D,YAAY,EAAS,CAAC,cAAc,CAAC,eAAe,CAAC,CAA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","sourcesContent":["import { expectTypeOf, test } from \"vitest\";\nimport type {\n InferTools,\n ToolInput,\n ToolNames,\n ToolOutput,\n ToolResponseMetadata,\n} from \"../server/index.js\";\nimport { createInterfaceTestApp, createTestApp } from \"../test/utils.js\";\nimport { generateHelpers } from \"./generate-helpers.js\";\n\nconst app = createTestApp();\ntype TestApp = typeof app;\n\nconst interfaceApp = createInterfaceTestApp();\ntype InterfaceTestApp = typeof interfaceApp;\n\ntest(\"InferTools extracts the tool registry type (views + registerTool)\", () => {\n type Tools = InferTools<TestApp>;\n\n expectTypeOf<Tools>().toHaveProperty(\"search-trip\");\n expectTypeOf<Tools>().toHaveProperty(\"get-trip-details\");\n expectTypeOf<Tools>().toHaveProperty(\"no-input-view\");\n expectTypeOf<Tools>().toHaveProperty(\"calculate-price\");\n expectTypeOf<Tools>().toHaveProperty(\"inferred-output-view\");\n expectTypeOf<Tools>().toHaveProperty(\"inferred-tool\");\n expectTypeOf<Tools>().toHaveProperty(\"view-with-metadata\");\n expectTypeOf<Tools>().toHaveProperty(\"tool-with-metadata\");\n expectTypeOf<Tools>().toHaveProperty(\"view-with-mixed-returns\");\n});\n\ntest(\"ToolNames returns a union of tool name literals (views + registerTool)\", () => {\n type Names = ToolNames<TestApp>;\n\n expectTypeOf<Names>().toEqualTypeOf<\n | \"search-trip\"\n | \"get-trip-details\"\n | \"no-input-view\"\n | \"calculate-price\"\n | \"inferred-output-view\"\n | \"inferred-tool\"\n | \"view-with-metadata\"\n | \"tool-with-metadata\"\n | \"view-with-mixed-returns\"\n >();\n});\n\ntest(\"ToolInput extracts the correct input type from Zod schema\", () => {\n type SearchInput = ToolInput<TestApp, \"search-trip\">;\n\n expectTypeOf<SearchInput>().toEqualTypeOf<{\n destination: string;\n departureDate?: string | undefined;\n maxPrice?: number | undefined;\n }>();\n\n type DetailsInput = ToolInput<TestApp, \"get-trip-details\">;\n\n expectTypeOf<DetailsInput>().toEqualTypeOf<{\n tripId: string;\n }>();\n\n type CalculateInput = ToolInput<TestApp, \"calculate-price\">;\n\n expectTypeOf<CalculateInput>().toEqualTypeOf<{\n tripId: string;\n passengers: number;\n }>();\n});\n\ntest(\"ToolOutput extracts the correct output type from callback's structuredContent\", () => {\n type SearchOutput = ToolOutput<TestApp, \"search-trip\">;\n\n expectTypeOf<SearchOutput>().toEqualTypeOf<{\n results: Array<{\n id: string;\n name: string;\n price: number;\n }>;\n totalCount: number;\n }>();\n\n type DetailsOutput = ToolOutput<TestApp, \"get-trip-details\">;\n\n expectTypeOf<DetailsOutput>().toEqualTypeOf<{\n name: string;\n description: string;\n images: string[];\n }>();\n\n // Note: outputSchema has totalPrice: z.string(), but callback returns number\n // Type is inferred from callback, so totalPrice is number\n type CalculateOutput = ToolOutput<TestApp, \"calculate-price\">;\n\n expectTypeOf<CalculateOutput>().toEqualTypeOf<{\n totalPrice: number;\n currency: string;\n }>();\n\n type NoInputOutput = ToolOutput<TestApp, \"no-input-view\">;\n expectTypeOf<NoInputOutput>().toEqualTypeOf<Record<never, unknown>>();\n});\n\ntest(\"ToolOutput extracts the correct output type from callback (inferred)\", () => {\n type InferredViewOutput = ToolOutput<TestApp, \"inferred-output-view\">;\n\n expectTypeOf<InferredViewOutput>().toEqualTypeOf<{\n inferredResults: { id: string; score: number }[];\n inferredCount: number;\n }>();\n\n type InferredToolOutput = ToolOutput<TestApp, \"inferred-tool\">;\n\n expectTypeOf<InferredToolOutput>().toEqualTypeOf<{\n itemDetails: { name: string; available: boolean };\n fetchedAt: string;\n }>();\n});\n\ntest(\"generateHelpers provides autocomplete for tool names (views + registerTool)\", () => {\n const { useCallTool } = generateHelpers<TestApp>();\n\n useCallTool(\"search-trip\");\n useCallTool(\"get-trip-details\");\n useCallTool(\"no-input-view\");\n useCallTool(\"calculate-price\");\n useCallTool(\"inferred-output-view\");\n useCallTool(\"inferred-tool\");\n useCallTool(\"view-with-metadata\");\n useCallTool(\"tool-with-metadata\");\n useCallTool(\"view-with-mixed-returns\");\n\n // @ts-expect-error - \"invalid-name\" is not a valid tool name\n useCallTool(\"invalid-name\");\n});\n\ntest(\"useCallTool returns correctly typed callTool function\", () => {\n const { useCallTool } = generateHelpers<TestApp>();\n const { callTool } = useCallTool(\"search-trip\");\n\n callTool({ destination: \"Spain\" });\n callTool({ destination: \"France\", departureDate: \"2024-06-01\" });\n callTool({ destination: \"Italy\", maxPrice: 1000 });\n\n const { callTool: calculateTool } = useCallTool(\"calculate-price\");\n calculateTool({ tripId: \"123\", passengers: 2 });\n});\n\ntest(\"callTool can be called without args for tools with no required inputs\", () => {\n const { useCallTool } = generateHelpers<TestApp>();\n const { callTool, callToolAsync } = useCallTool(\"no-input-view\");\n\n callTool();\n\n callTool({});\n\n callToolAsync();\n callToolAsync({});\n});\n\ntest(\"callTool requires args for tools with required inputs\", () => {\n const { useCallTool } = generateHelpers<TestApp>();\n const { callTool } = useCallTool(\"search-trip\");\n\n // @ts-expect-error - \"destination\" is required\n callTool();\n\n // @ts-expect-error - \"destination\" is required\n callTool({});\n\n // This should work\n callTool({ destination: \"Spain\" });\n});\n\ntest(\"callTool supports sideEffects for tools with required inputs\", () => {\n const { useCallTool } = generateHelpers<TestApp>();\n const { callTool } = useCallTool(\"search-trip\");\n\n callTool(\n { destination: \"Spain\" },\n {\n onSuccess: (response, args) => {\n expectTypeOf(response.structuredContent.results).toBeArray();\n expectTypeOf(args.destination).toBeString();\n },\n onError: (error, args) => {\n expectTypeOf(error).toBeUnknown();\n expectTypeOf(args.destination).toBeString();\n },\n onSettled: (response, error, args) => {\n if (response) {\n expectTypeOf(response.structuredContent.totalCount).toBeNumber();\n }\n expectTypeOf(error).toBeUnknown();\n expectTypeOf(args.destination).toBeString();\n },\n },\n );\n});\n\ntest(\"callTool supports sideEffects for tools with no required inputs\", () => {\n const { useCallTool } = generateHelpers<TestApp>();\n const { callTool } = useCallTool(\"no-input-view\");\n\n callTool({\n onSuccess: (response) => {\n expectTypeOf(response).toHaveProperty(\"structuredContent\");\n },\n });\n\n callTool(\n {},\n {\n onSuccess: (response) => {\n expectTypeOf(response).toHaveProperty(\"structuredContent\");\n },\n },\n );\n});\n\ntest(\"callToolAsync returns correctly typed promise\", () => {\n const { useCallTool } = generateHelpers<TestApp>();\n\n const { callToolAsync: searchAsync } = useCallTool(\"search-trip\");\n const searchPromise = searchAsync({ destination: \"Spain\" });\n expectTypeOf(searchPromise).resolves.toHaveProperty(\"structuredContent\");\n\n const { callToolAsync: noInputAsync } = useCallTool(\"no-input-view\");\n const noInputPromise = noInputAsync();\n expectTypeOf(noInputPromise).resolves.toHaveProperty(\"structuredContent\");\n});\n\ntest(\"useCallTool returns correctly typed data\", () => {\n const { useCallTool } = generateHelpers<TestApp>();\n const { data } = useCallTool(\"search-trip\");\n\n if (data) {\n expectTypeOf(data.structuredContent).toExtend<{\n results: Array<{\n id: string;\n name: string;\n price: number;\n }>;\n totalCount: number;\n }>();\n\n expectTypeOf(data.structuredContent.results).toBeArray();\n expectTypeOf(data.structuredContent.totalCount).toBeNumber();\n }\n});\n\ntest(\"useCallTool returns correctly typed data for callback-inferred outputs\", () => {\n const { useCallTool } = generateHelpers<TestApp>();\n\n const { data: viewData } = useCallTool(\"inferred-output-view\");\n if (viewData) {\n expectTypeOf(viewData.structuredContent).toExtend<{\n inferredResults: { id: string; score: number }[];\n inferredCount: number;\n }>();\n }\n\n const { data: toolData } = useCallTool(\"inferred-tool\");\n if (toolData) {\n expectTypeOf(toolData.structuredContent).toExtend<{\n itemDetails: { name: string; available: boolean };\n fetchedAt: string;\n }>();\n }\n});\n\ntest(\"generateHelpers provides autocomplete for tool names in useToolInfo (views + registerTool)\", () => {\n const { useToolInfo } = generateHelpers<TestApp>();\n\n useToolInfo<\"search-trip\">();\n useToolInfo<\"get-trip-details\">();\n useToolInfo<\"no-input-view\">();\n useToolInfo<\"calculate-price\">();\n useToolInfo<\"inferred-output-view\">();\n useToolInfo<\"inferred-tool\">();\n useToolInfo<\"view-with-metadata\">();\n useToolInfo<\"tool-with-metadata\">();\n useToolInfo<\"view-with-mixed-returns\">();\n\n // @ts-expect-error - \"invalid-name\" is not a valid tool name\n useToolInfo<\"invalid-name\">();\n});\n\ntest(\"useToolInfo infers input and output types\", () => {\n const { useToolInfo } = generateHelpers<TestApp>();\n const toolInfo = useToolInfo<\"search-trip\">();\n\n // Input is optional in pending — host may not have delivered args yet\n if (toolInfo.status === \"pending\") {\n expectTypeOf(toolInfo.input).toExtend<\n ToolInput<TestApp, \"search-trip\"> | undefined\n >();\n }\n\n if (toolInfo.status === \"success\") {\n // Input is optional in success — the host may not have surfaced args yet\n expectTypeOf(toolInfo.input).toExtend<\n ToolInput<TestApp, \"search-trip\"> | undefined\n >();\n expectTypeOf(toolInfo.output).toExtend<\n ToolOutput<TestApp, \"search-trip\">\n >();\n expectTypeOf(toolInfo.output.results).toBeArray();\n expectTypeOf(toolInfo.output.totalCount).toBeNumber();\n }\n});\n\ntest(\"ToolResponseMetadata extracts _meta type from callback\", () => {\n type ViewMeta = ToolResponseMetadata<TestApp, \"view-with-metadata\">;\n expectTypeOf<ViewMeta>().toEqualTypeOf<{\n requestId: string;\n timestamp: number;\n cached: boolean;\n }>();\n\n type ToolMeta = ToolResponseMetadata<TestApp, \"tool-with-metadata\">;\n expectTypeOf<ToolMeta>().toEqualTypeOf<{\n executionTime: number;\n source: string;\n }>();\n\n type SearchMeta = ToolResponseMetadata<TestApp, \"search-trip\">;\n expectTypeOf<SearchMeta>().toBeUnknown();\n});\n\ntest(\"useToolInfo infers responseMetadata type from generateHelpers\", () => {\n const { useToolInfo } = generateHelpers<TestApp>();\n const toolInfo = useToolInfo<\"view-with-metadata\">();\n\n if (toolInfo.isSuccess) {\n expectTypeOf(toolInfo.responseMetadata.requestId).toBeString();\n expectTypeOf(toolInfo.responseMetadata.timestamp).toBeNumber();\n expectTypeOf(toolInfo.responseMetadata.cached).toBeBoolean();\n }\n});\n\ntest(\"ToolResponseMetadata extracts _meta from mixed return paths\", () => {\n // View has multiple return paths: some with _meta, some without\n // ExtractMeta should still infer the _meta type from branches that have it\n type MixedMeta = ToolResponseMetadata<TestApp, \"view-with-mixed-returns\">;\n expectTypeOf<MixedMeta>().toEqualTypeOf<{\n processedAt: number;\n region: string;\n }>();\n});\n\ntest(\"ToolOutput extracts correct type when using interface declaration\", () => {\n type InterfaceViewOutput = ToolOutput<InterfaceTestApp, \"interface-view\">;\n\n expectTypeOf<InterfaceViewOutput>().toHaveProperty(\"itemName\");\n expectTypeOf<InterfaceViewOutput[\"itemName\"]>().toBeString();\n expectTypeOf<InterfaceViewOutput[\"quantity\"]>().toBeNumber();\n});\n\ntest(\"ToolResponseMetadata extracts correct type when using interface declaration\", () => {\n type InterfaceViewMeta = ToolResponseMetadata<\n InterfaceTestApp,\n \"interface-view\"\n >;\n\n expectTypeOf<InterfaceViewMeta>().toHaveProperty(\"processedBy\");\n expectTypeOf<InterfaceViewMeta[\"processedBy\"]>().toBeString();\n expectTypeOf<InterfaceViewMeta[\"version\"]>().toBeNumber();\n});\n\ntest(\"generateHelpers works with interface-typed server\", () => {\n const { useCallTool, useToolInfo } = generateHelpers<InterfaceTestApp>();\n\n const { data } = useCallTool(\"interface-view\");\n if (data) {\n expectTypeOf(data.structuredContent.itemName).toBeString();\n expectTypeOf(data.structuredContent.quantity).toBeNumber();\n }\n\n const toolInfo = useToolInfo<\"interface-view\">();\n if (toolInfo.isSuccess) {\n expectTypeOf(toolInfo.output.itemName).toBeString();\n expectTypeOf(toolInfo.output.quantity).toBeNumber();\n expectTypeOf(toolInfo.responseMetadata.processedBy).toBeString();\n expectTypeOf(toolInfo.responseMetadata.version).toBeNumber();\n }\n});\n"]}
@@ -1,7 +1,7 @@
1
1
  import { describe, expect, it } from "vitest";
2
- import { createMinimalTestServer } from "../test/utils.js";
2
+ import { createMinimalTestApp } from "../test/utils.js";
3
3
  import { generateHelpers } from "./generate-helpers.js";
4
- const server = createMinimalTestServer();
4
+ const app = createMinimalTestApp();
5
5
  describe("generateHelpers", () => {
6
6
  it("should return an object with useCallTool hook", () => {
7
7
  const hooks = generateHelpers();
@@ -1 +1 @@
1
- {"version":3,"file":"generate-helpers.test.js","sourceRoot":"","sources":["../../src/web/generate-helpers.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,MAAM,MAAM,GAAG,uBAAuB,EAAE,CAAC;AAGzC,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,EAAE,CAAC,+CAA+C,EAAE,GAAG,EAAE;QACvD,MAAM,KAAK,GAAG,eAAe,EAAc,CAAC;QAC5C,MAAM,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;QAC5C,MAAM,CAAC,OAAO,KAAK,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,+CAA+C,EAAE,GAAG,EAAE;QACvD,MAAM,KAAK,GAAG,eAAe,EAAc,CAAC;QAC5C,MAAM,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;QAC5C,MAAM,CAAC,OAAO,KAAK,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"generate-helpers.test.js","sourceRoot":"","sources":["../../src/web/generate-helpers.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,MAAM,GAAG,GAAG,oBAAoB,EAAE,CAAC;AAGnC,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,EAAE,CAAC,+CAA+C,EAAE,GAAG,EAAE;QACvD,MAAM,KAAK,GAAG,eAAe,EAAW,CAAC;QACzC,MAAM,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;QAC5C,MAAM,CAAC,OAAO,KAAK,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,+CAA+C,EAAE,GAAG,EAAE;QACvD,MAAM,KAAK,GAAG,eAAe,EAAW,CAAC;QACzC,MAAM,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;QAC5C,MAAM,CAAC,OAAO,KAAK,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { describe, expect, it } from \"vitest\";\nimport { createMinimalTestApp } from \"../test/utils.js\";\nimport { generateHelpers } from \"./generate-helpers.js\";\n\nconst app = createMinimalTestApp();\ntype TestApp = typeof app;\n\ndescribe(\"generateHelpers\", () => {\n it(\"should return an object with useCallTool hook\", () => {\n const hooks = generateHelpers<TestApp>();\n expect(hooks).toHaveProperty(\"useCallTool\");\n expect(typeof hooks.useCallTool).toBe(\"function\");\n });\n\n it(\"should return an object with useToolInfo hook\", () => {\n const hooks = generateHelpers<TestApp>();\n expect(hooks).toHaveProperty(\"useToolInfo\");\n expect(typeof hooks.useToolInfo).toBe(\"function\");\n });\n});\n"]}
@@ -1,7 +1,7 @@
1
1
  import { type SuperJSONResult } from "superjson";
2
2
  import type { UnknownObject } from "../types.js";
3
- export declare function filterWidgetContext<T extends UnknownObject>(state?: T | null): T | null;
4
- export declare function injectWidgetContext<T extends UnknownObject>(newState: T | null): T | null;
3
+ export declare function filterViewContext<T extends UnknownObject>(state?: T | null): T | null;
4
+ export declare function injectViewContext<T extends UnknownObject>(newState: T | null): T | null;
5
5
  export declare function serializeState(value: UnknownObject): unknown;
6
6
  export declare function deserializeState(value: SuperJSONResult): unknown;
7
7
  export declare function getInitialState<State extends UnknownObject>(defaultState?: State | (() => State)): State | null;
@@ -1,26 +1,26 @@
1
1
  import superjson, {} from "superjson";
2
2
  import { getAdaptor } from "../bridges/index.js";
3
- import { WIDGET_CONTEXT_KEY } from "../data-llm.js";
4
- export function filterWidgetContext(state) {
3
+ import { VIEW_CONTEXT_KEY } from "../data-llm.js";
4
+ export function filterViewContext(state) {
5
5
  if (state === null || state === undefined) {
6
6
  return null;
7
7
  }
8
- const { [WIDGET_CONTEXT_KEY]: _, ...filteredState } = state;
8
+ const { [VIEW_CONTEXT_KEY]: _, ...filteredState } = state;
9
9
  return filteredState;
10
10
  }
11
- export function injectWidgetContext(newState) {
11
+ export function injectViewContext(newState) {
12
12
  if (newState === null) {
13
13
  return null;
14
14
  }
15
15
  const currentState = getAdaptor()
16
- .getHostContextStore("widgetState")
16
+ .getHostContextStore("viewState")
17
17
  .getSnapshot();
18
18
  if (currentState !== null &&
19
19
  currentState !== undefined &&
20
- WIDGET_CONTEXT_KEY in currentState) {
20
+ VIEW_CONTEXT_KEY in currentState) {
21
21
  return {
22
22
  ...newState,
23
- [WIDGET_CONTEXT_KEY]: currentState[WIDGET_CONTEXT_KEY],
23
+ [VIEW_CONTEXT_KEY]: currentState[VIEW_CONTEXT_KEY],
24
24
  };
25
25
  }
26
26
  return newState;
@@ -32,11 +32,11 @@ export function deserializeState(value) {
32
32
  return superjson.deserialize(value);
33
33
  }
34
34
  export function getInitialState(defaultState) {
35
- const widgetState = getAdaptor()
36
- .getHostContextStore("widgetState")
35
+ const viewState = getAdaptor()
36
+ .getHostContextStore("viewState")
37
37
  .getSnapshot();
38
- if (widgetState !== null && widgetState !== undefined) {
39
- return filterWidgetContext(widgetState);
38
+ if (viewState !== null && viewState !== undefined) {
39
+ return filterViewContext(viewState);
40
40
  }
41
41
  return typeof defaultState === "function"
42
42
  ? defaultState()
@@ -1 +1 @@
1
- {"version":3,"file":"state.js","sourceRoot":"","sources":["../../../src/web/helpers/state.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,EAAE,EAAwB,MAAM,WAAW,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGpD,MAAM,UAAU,mBAAmB,CACjC,KAAgB;IAEhB,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QAC1C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,EAAE,CAAC,kBAAkB,CAAC,EAAE,CAAC,EAAE,GAAG,aAAa,EAAE,GAAG,KAErD,CAAC;IAEF,OAAO,aAAkB,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,QAAkB;IAElB,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,YAAY,GAAG,UAAU,EAAE;SAC9B,mBAAmB,CAAC,aAAa,CAAC;SAClC,WAAW,EAAqD,CAAC;IAEpE,IACE,YAAY,KAAK,IAAI;QACrB,YAAY,KAAK,SAAS;QAC1B,kBAAkB,IAAI,YAAY,EAClC,CAAC;QACD,OAAO;YACL,GAAG,QAAQ;YACX,CAAC,kBAAkB,CAAC,EAAE,YAAY,CAAC,kBAAkB,CAAC;SAClD,CAAC;IACT,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAAoB;IACjD,OAAO,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,mBAAmB;AACzE,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,KAAsB;IACrD,OAAO,SAAS,CAAC,WAAW,CAAC,KA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OAAO;YACL,GAAG,QAAQ;YACX,CAAC,gBAAgB,CAAC,EAAE,YAAY,CAAC,gBAAgB,CAAC;SAC9C,CAAC;IACT,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAAoB;IACjD,OAAO,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,mBAAmB;AACzE,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,KAAsB;IACrD,OAAO,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,YAAoC;IAEpC,MAAM,SAAS,GAAG,UAAU,EAAE;SAC3B,mBAAmB,CAAC,WAAW,CAAC;SAChC,WAAW,EAAkB,CAAC;IAEjC,IAAI,SAAS,KAAK,IAAI,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAClD,OAAO,iBAAiB,CAAC,SAAS,CAAC,CAAC;IACtC,CAAC;IAED,OAAO,OAAO,YAAY,KAAK,UAAU;QACvC,CAAC,CAAC,YAAY,EAAE;QAChB,CAAC,CAAC,CAAC,YAAY,IAAI,IAAI,CAAC,CAAC;AAC7B,CAAC","sourcesContent":["import superjson, { type SuperJSONResult } from \"superjson\";\nimport { getAdaptor } from \"../bridges/index.js\";\nimport { VIEW_CONTEXT_KEY } from \"../data-llm.js\";\nimport type { UnknownObject } from \"../types.js\";\n\nexport function filterViewContext<T extends UnknownObject>(\n state?: T | null,\n): T | null {\n if (state === null || state === undefined) {\n return null;\n }\n\n const { [VIEW_CONTEXT_KEY]: _, ...filteredState } = state as T & {\n [VIEW_CONTEXT_KEY]?: unknown;\n };\n\n return filteredState as T;\n}\n\nexport function injectViewContext<T extends UnknownObject>(\n newState: T | null,\n): T | null {\n if (newState === null) {\n return null;\n }\n\n const currentState = getAdaptor()\n .getHostContextStore(\"viewState\")\n .getSnapshot() as (T & { [VIEW_CONTEXT_KEY]?: unknown }) | null;\n\n if (\n currentState !== null &&\n currentState !== undefined &&\n VIEW_CONTEXT_KEY in currentState\n ) {\n return {\n ...newState,\n [VIEW_CONTEXT_KEY]: currentState[VIEW_CONTEXT_KEY],\n } as T;\n }\n\n return newState;\n}\n\nexport function serializeState(value: UnknownObject) {\n return superjson.parse(superjson.stringify(value)); // Strips functions\n}\n\nexport function deserializeState(value: SuperJSONResult): unknown {\n return superjson.deserialize(value);\n}\n\nexport function getInitialState<State extends UnknownObject>(\n defaultState?: State | (() => State),\n): State | null {\n const viewState = getAdaptor()\n .getHostContextStore(\"viewState\")\n .getSnapshot() as State | null;\n\n if (viewState !== null && viewState !== undefined) {\n return filterViewContext(viewState);\n }\n\n return typeof defaultState === \"function\"\n ? defaultState()\n : (defaultState ?? null);\n}\n"]}
@@ -1,29 +1,29 @@
1
1
  import { describe, expect, it } from "vitest";
2
- import { WIDGET_CONTEXT_KEY } from "../data-llm.js";
3
- import { filterWidgetContext, serializeState } from "./state.js";
2
+ import { VIEW_CONTEXT_KEY } from "../data-llm.js";
3
+ import { filterViewContext, serializeState } from "./state.js";
4
4
  describe("state helpers", () => {
5
- describe("filterWidgetContext", () => {
5
+ describe("filterViewContext", () => {
6
6
  it("should return null when state is null", () => {
7
- expect(filterWidgetContext(null)).toBe(null);
7
+ expect(filterViewContext(null)).toBe(null);
8
8
  });
9
9
  it("should return null when state is undefined", () => {
10
- expect(filterWidgetContext(undefined)).toBe(null);
10
+ expect(filterViewContext(undefined)).toBe(null);
11
11
  });
12
- it("should correctly filter WIDGET_CONTEXT_KEY and preserve other properties", () => {
12
+ it("should correctly filter VIEW_CONTEXT_KEY and preserve other properties", () => {
13
13
  const stateWithContextAndOthers = {
14
14
  a: 1,
15
15
  b: "two",
16
16
  c: { nested: true },
17
- [WIDGET_CONTEXT_KEY]: "context",
17
+ [VIEW_CONTEXT_KEY]: "context",
18
18
  };
19
- const filteredWithContextAndOthers = filterWidgetContext(stateWithContextAndOthers);
19
+ const filteredWithContextAndOthers = filterViewContext(stateWithContextAndOthers);
20
20
  expect(filteredWithContextAndOthers).toEqual({
21
21
  a: 1,
22
22
  b: "two",
23
23
  c: { nested: true },
24
24
  });
25
25
  const stateNoContext = { count: 5, name: "test" };
26
- const filteredNoContext = filterWidgetContext(stateNoContext);
26
+ const filteredNoContext = filterViewContext(stateNoContext);
27
27
  expect(filteredNoContext).toEqual(stateNoContext);
28
28
  });
29
29
  });
@@ -1 +1 @@
1
- {"version":3,"file":"state.test.js","sourceRoot":"","sources":["../../../src/web/helpers/state.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjE,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;QACnC,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;YAC/C,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/C,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;YACpD,MAAM,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,0EAA0E,EAAE,GAAG,EAAE;YAClF,MAAM,yBAAyB,GAAG;gBAChC,CAAC,EAAE,CAAC;gBACJ,CAAC,EAAE,KAAK;gBACR,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;gBACnB,CAAC,kBAAkB,CAAC,EAAE,SAAS;aAChC,CAAC;YACF,MAAM,4BAA4B,GAAG,mBAAmB,CACtD,yBAAy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,MAAM,EAAE,CAAC;YAClD,MAAM,iBAAiB,GAAG,iBAAiB,CAAC,cAAc,CAAC,CAAC;YAC5D,MAAM,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;QAC9B,EAAE,CAAC,gCAAgC,EAAE,GAAG,EAAE;YACxC,MAAM,KAAK,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;YACvC,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,sBAAsB,CAAC,CAAC;YAC9C,MAAM,MAAM,GAAG;gBACb,CAAC,EAAE,CAAC;gBACJ,CAAC,EAAE,MAAM;gBACT,CAAC,EAAE,IAAI;gBACP,KAAK;gBACL,IAAI;gBACJ,QAAQ,EAAE,GAAG,EAAE,CAAC,MAAM;aACvB,CAAC;YACF,MAAM,MAAM,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;YAEtC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;gBACrB,CAAC,EAAE,CAAC;gBACJ,CAAC,EAAE,MAAM;gBACT,CAAC,EAAE,IAAI;gBACP,KAAK,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;gBAC/B,IAAI,EAAE,IAAI,IAAI,CAAC,0BAA0B,CAAC;aAC3C,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { describe, expect, it } from \"vitest\";\nimport { VIEW_CONTEXT_KEY } from \"../data-llm.js\";\nimport { filterViewContext, serializeState } from \"./state.js\";\n\ndescribe(\"state helpers\", () => {\n describe(\"filterViewContext\", () => {\n it(\"should return null when state is null\", () => {\n expect(filterViewContext(null)).toBe(null);\n });\n\n it(\"should return null when state is undefined\", () => {\n expect(filterViewContext(undefined)).toBe(null);\n });\n\n it(\"should correctly filter VIEW_CONTEXT_KEY and preserve other properties\", () => {\n const stateWithContextAndOthers = {\n a: 1,\n b: \"two\",\n c: { nested: true },\n [VIEW_CONTEXT_KEY]: \"context\",\n };\n const filteredWithContextAndOthers = filterViewContext(\n stateWithContextAndOthers,\n );\n expect(filteredWithContextAndOthers).toEqual({\n a: 1,\n b: \"two\",\n c: { nested: true },\n });\n\n const stateNoContext = { count: 5, name: \"test\" };\n const filteredNoContext = filterViewContext(stateNoContext);\n expect(filteredNoContext).toEqual(stateNoContext);\n });\n });\n\n describe(\"serializeState\", () => {\n it(\"should serialize plain objects\", () => {\n const array = [1, \"two\", { three: 3 }];\n const date = new Date(\"2023-01-01T00:00:00Z\");\n const object = {\n a: 1,\n b: \"test\",\n c: true,\n array,\n date,\n function: () => \"test\",\n };\n const result = serializeState(object);\n\n expect(result).toEqual({\n a: 1,\n b: \"test\",\n c: true,\n array: [1, \"two\", { three: 3 }],\n date: new Date(\"2023-01-01T00:00:00.000Z\"),\n });\n });\n });\n});\n"]}
@@ -1,11 +1,20 @@
1
1
  export { type CallToolAsyncFn, type CallToolFn, type CallToolState, type SideEffects, useCallTool, } from "./use-call-tool.js";
2
+ export { useDeepLink } from "./use-deep-link.js";
2
3
  export { useDisplayMode } from "./use-display-mode.js";
4
+ export { type DownloadFn, useDownload } from "./use-download.js";
5
+ export { type FileResourceState, useFileResource, } from "./use-file-resource.js";
3
6
  export { useFiles } from "./use-files.js";
4
- export { type LayoutState, useLayout } from "./use-layout.js";
7
+ export { type Host, type HostInfo, type OpenAIHostCapabilities, useHost, } from "./use-host.js";
8
+ export { type ModelContextState, useModelContext, } from "./use-model-context.js";
5
9
  export { type OpenExternalFn, useOpenExternal } from "./use-open-external.js";
10
+ export { useOpenFile } from "./use-open-file.js";
11
+ export { useRegisterViewTool } from "./use-register-view-tool.js";
12
+ export { type RequestCloseFn, useRequestClose } from "./use-request-close.js";
6
13
  export { useRequestModal } from "./use-request-modal.js";
14
+ export { type RequestSizeFn, useRequestSize } from "./use-request-size.js";
7
15
  export { useSendFollowUpMessage } from "./use-send-follow-up-message.js";
8
16
  export { useSetOpenInAppUrl } from "./use-set-open-in-app-url.js";
9
17
  export { useToolInfo } from "./use-tool-info.js";
10
18
  export { type UserState, useUser } from "./use-user.js";
11
- export { useWidgetState } from "./use-widget-state.js";
19
+ export { useViewState } from "./use-view-state.js";
20
+ export { useViewport, type ViewportState } from "./use-viewport.js";
@@ -1,12 +1,21 @@
1
1
  export { useCallTool, } from "./use-call-tool.js";
2
+ export { useDeepLink } from "./use-deep-link.js";
2
3
  export { useDisplayMode } from "./use-display-mode.js";
4
+ export { useDownload } from "./use-download.js";
5
+ export { useFileResource, } from "./use-file-resource.js";
3
6
  export { useFiles } from "./use-files.js";
4
- export { useLayout } from "./use-layout.js";
7
+ export { useHost, } from "./use-host.js";
8
+ export { useModelContext, } from "./use-model-context.js";
5
9
  export { useOpenExternal } from "./use-open-external.js";
10
+ export { useOpenFile } from "./use-open-file.js";
11
+ export { useRegisterViewTool } from "./use-register-view-tool.js";
12
+ export { useRequestClose } from "./use-request-close.js";
6
13
  export { useRequestModal } from "./use-request-modal.js";
14
+ export { useRequestSize } from "./use-request-size.js";
7
15
  export { useSendFollowUpMessage } from "./use-send-follow-up-message.js";
8
16
  export { useSetOpenInAppUrl } from "./use-set-open-in-app-url.js";
9
17
  export { useToolInfo } from "./use-tool-info.js";
10
18
  export { useUser } from "./use-user.js";
11
- export { useWidgetState } from "./use-widget-state.js";
19
+ export { useViewState } from "./use-view-state.js";
20
+ export { useViewport } from "./use-viewport.js";
12
21
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/web/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,WAAW,GACZ,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,uB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sB,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAkB,OAAO,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAsB,MAAM,mBAAmB,CAAC","sourcesContent":["export {\n type CallToolAsyncFn,\n type CallToolFn,\n type CallToolState,\n type SideEffects,\n useCallTool,\n} from \"./use-call-tool.js\";\nexport { useDeepLink } from \"./use-deep-link.js\";\nexport { useDisplayMode } from \"./use-display-mode.js\";\nexport { type DownloadFn, useDownload } from \"./use-download.js\";\nexport {\n type FileResourceState,\n useFileResource,\n} from \"./use-file-resource.js\";\nexport { useFiles } from \"./use-files.js\";\nexport {\n type Host,\n type HostInfo,\n type OpenAIHostCapabilities,\n useHost,\n} from \"./use-host.js\";\nexport {\n type ModelContextState,\n useModelContext,\n} from \"./use-model-context.js\";\nexport { type OpenExternalFn, useOpenExternal } from \"./use-open-external.js\";\nexport { useOpenFile } from \"./use-open-file.js\";\nexport { useRegisterViewTool } from \"./use-register-view-tool.js\";\nexport { type RequestCloseFn, useRequestClose } from \"./use-request-close.js\";\nexport { useRequestModal } from \"./use-request-modal.js\";\nexport { type RequestSizeFn, useRequestSize } from \"./use-request-size.js\";\nexport { useSendFollowUpMessage } from \"./use-send-follow-up-message.js\";\nexport { useSetOpenInAppUrl } from \"./use-set-open-in-app-url.js\";\nexport { useToolInfo } from \"./use-tool-info.js\";\nexport { type UserState, useUser } from \"./use-user.js\";\nexport { useViewState } from \"./use-view-state.js\";\nexport { useViewport, type ViewportState } from \"./use-viewport.js\";\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,107 @@
1
+ import { act, 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/index.js";
5
+ import { getMcpAppHostPostMessageMock, MockResizeObserver, } from "./test/utils.js";
6
+ import { useDeepLink } from "./use-deep-link.js";
7
+ import { useModelContext } from "./use-model-context.js";
8
+ import { useViewState } from "./use-view-state.js";
9
+ async function notifyHostContext(params) {
10
+ await act(async () => {
11
+ window.dispatchEvent(new MessageEvent("message", {
12
+ source: window.parent,
13
+ data: {
14
+ jsonrpc: "2.0",
15
+ method: "ui/notifications/host-context-changed",
16
+ params,
17
+ },
18
+ }));
19
+ });
20
+ }
21
+ describe("model context and deep links in the view", () => {
22
+ beforeEach(() => {
23
+ vi.stubGlobal("openai", undefined);
24
+ vi.stubGlobal("skybridge", {});
25
+ vi.stubGlobal("ResizeObserver", MockResizeObserver);
26
+ localStorage.clear();
27
+ });
28
+ afterEach(() => {
29
+ HostAdaptor.resetInstance();
30
+ McpAppBridge.resetInstance();
31
+ vi.unstubAllGlobals();
32
+ localStorage.clear();
33
+ });
34
+ it("merges model context with view state and drops it once the user removes it", async () => {
35
+ const postMessage = getMcpAppHostPostMessageMock({}, { hostCapabilities: { updateModelContext: {} } });
36
+ vi.stubGlobal("parent", { postMessage });
37
+ const { result } = renderHook(() => ({
38
+ model: useModelContext(),
39
+ view: useViewState({ tab: "a" }),
40
+ }));
41
+ await waitFor(() => expect(result.current.model.supported).toBe(true));
42
+ const content = [
43
+ {
44
+ type: "text",
45
+ text: "Selected ski",
46
+ _meta: { "openai/title": "Ski" },
47
+ },
48
+ ];
49
+ const lastModelContext = () => postMessage.mock.calls
50
+ .map(([message]) => message)
51
+ .filter((message) => message.method === "ui/update-model-context")
52
+ .at(-1)?.params;
53
+ await act(async () => result.current.model.update({
54
+ content,
55
+ structuredContent: { ski: 1, tab: "x" },
56
+ }));
57
+ await act(async () => result.current.view[1]({ tab: "b" }));
58
+ expect(lastModelContext()).toEqual({
59
+ structuredContent: { ski: 1, tab: "b" },
60
+ content: [
61
+ {
62
+ type: "text",
63
+ text: JSON.stringify({ tab: "b" }),
64
+ annotations: { audience: ["assistant"] },
65
+ },
66
+ ...content,
67
+ ],
68
+ });
69
+ await notifyHostContext({
70
+ "openai/modelContext": { updateId: "one", content },
71
+ });
72
+ expect(result.current.model.context).toEqual({ updateId: "one", content });
73
+ await notifyHostContext({ "openai/modelContext": null });
74
+ expect(result.current.model.context).toBeNull();
75
+ await act(async () => result.current.view[1]({ tab: "c" }));
76
+ expect(lastModelContext()).toEqual({
77
+ structuredContent: { tab: "c" },
78
+ content: [
79
+ {
80
+ type: "text",
81
+ text: JSON.stringify({ tab: "c" }),
82
+ annotations: { audience: ["assistant"] },
83
+ },
84
+ ],
85
+ });
86
+ });
87
+ it("rejects model context updates on hosts without the capability", async () => {
88
+ const postMessage = getMcpAppHostPostMessageMock();
89
+ vi.stubGlobal("parent", { postMessage });
90
+ const { result } = renderHook(useModelContext);
91
+ await expect(result.current.update({ content: [] })).rejects.toThrow("updateModelContext");
92
+ expect(result.current.supported).toBe(false);
93
+ expect(postMessage.mock.calls.some(([message]) => message.method === "ui/update-model-context")).toBe(false);
94
+ });
95
+ it("reads app-relative deep links and ignores ones that leave the app", async () => {
96
+ vi.stubGlobal("parent", {
97
+ postMessage: getMcpAppHostPostMessageMock({
98
+ "openai/deepLink": { url: "/parts?tag=bolt" },
99
+ }),
100
+ });
101
+ const { result } = renderHook(useDeepLink);
102
+ await waitFor(() => expect(result.current).toBe("/parts?tag=bolt"));
103
+ await notifyHostContext({ "openai/deepLink": { url: "//evil.test" } });
104
+ expect(result.current).toBeUndefined();
105
+ });
106
+ });
107
+ //# sourceMappingURL=openai-extensions.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai-extensions.test.js","sourceRoot":"","sources":["../../../src/web/hooks/openai-extensions.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAA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UAAU,CAAC,WAAW,CAAC,CAAC;QAC3C,MAAM,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC;QAEpE,MAAM,iBAAiB,CAAC,EAAE,iBAAiB,EAAE,EAAE,GAAG,EAAE,aAAa,EAAE,EAAE,CAAC,CAAC;QACvE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,CAAC;IACzC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { act, 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/index.js\";\nimport {\n getMcpAppHostPostMessageMock,\n MockResizeObserver,\n} from \"./test/utils.js\";\nimport { useDeepLink } from \"./use-deep-link.js\";\nimport { useModelContext } from \"./use-model-context.js\";\nimport { useViewState } from \"./use-view-state.js\";\n\nasync function notifyHostContext(params: Record<string, unknown>) {\n await act(async () => {\n window.dispatchEvent(\n new MessageEvent(\"message\", {\n source: window.parent,\n data: {\n jsonrpc: \"2.0\",\n method: \"ui/notifications/host-context-changed\",\n params,\n },\n }),\n );\n });\n}\n\ndescribe(\"model context and deep links in the view\", () => {\n beforeEach(() => {\n vi.stubGlobal(\"openai\", undefined);\n vi.stubGlobal(\"skybridge\", {});\n vi.stubGlobal(\"ResizeObserver\", MockResizeObserver);\n localStorage.clear();\n });\n\n afterEach(() => {\n HostAdaptor.resetInstance();\n McpAppBridge.resetInstance();\n vi.unstubAllGlobals();\n localStorage.clear();\n });\n\n it(\"merges model context with view state and drops it once the user removes it\", async () => {\n const postMessage = getMcpAppHostPostMessageMock(\n {},\n { hostCapabilities: { updateModelContext: {} } },\n );\n vi.stubGlobal(\"parent\", { postMessage });\n const { result } = renderHook(() => ({\n model: useModelContext(),\n view: useViewState({ tab: \"a\" }),\n }));\n await waitFor(() => expect(result.current.model.supported).toBe(true));\n const content = [\n {\n type: \"text\" as const,\n text: \"Selected ski\",\n _meta: { \"openai/title\": \"Ski\" },\n },\n ];\n const lastModelContext = () =>\n postMessage.mock.calls\n .map(([message]) => message as { method: string; params?: unknown })\n .filter((message) => message.method === \"ui/update-model-context\")\n .at(-1)?.params;\n\n await act(async () =>\n result.current.model.update({\n content,\n structuredContent: { ski: 1, tab: \"x\" },\n }),\n );\n await act(async () => result.current.view[1]({ tab: \"b\" }));\n expect(lastModelContext()).toEqual({\n structuredContent: { ski: 1, tab: \"b\" },\n content: [\n {\n type: \"text\",\n text: JSON.stringify({ tab: \"b\" }),\n annotations: { audience: [\"assistant\"] },\n },\n ...content,\n ],\n });\n\n await notifyHostContext({\n \"openai/modelContext\": { updateId: \"one\", content },\n });\n expect(result.current.model.context).toEqual({ updateId: \"one\", content });\n await notifyHostContext({ \"openai/modelContext\": null });\n expect(result.current.model.context).toBeNull();\n\n await act(async () => result.current.view[1]({ tab: \"c\" }));\n expect(lastModelContext()).toEqual({\n structuredContent: { tab: \"c\" },\n content: [\n {\n type: \"text\",\n text: JSON.stringify({ tab: \"c\" }),\n annotations: { audience: [\"assistant\"] },\n },\n ],\n });\n });\n\n it(\"rejects model context updates on hosts without the capability\", async () => {\n const postMessage = getMcpAppHostPostMessageMock();\n vi.stubGlobal(\"parent\", { postMessage });\n const { result } = renderHook(useModelContext);\n\n await expect(result.current.update({ content: [] })).rejects.toThrow(\n \"updateModelContext\",\n );\n expect(result.current.supported).toBe(false);\n expect(\n postMessage.mock.calls.some(\n ([message]) => message.method === \"ui/update-model-context\",\n ),\n ).toBe(false);\n });\n\n it(\"reads app-relative deep links and ignores ones that leave the app\", async () => {\n vi.stubGlobal(\"parent\", {\n postMessage: getMcpAppHostPostMessageMock({\n \"openai/deepLink\": { url: \"/parts?tag=bolt\" },\n }),\n });\n const { result } = renderHook(useDeepLink);\n await waitFor(() => expect(result.current).toBe(\"/parts?tag=bolt\"));\n\n await notifyHostContext({ \"openai/deepLink\": { url: \"//evil.test\" } });\n expect(result.current).toBeUndefined();\n });\n});\n"]}
@@ -1,10 +1,15 @@
1
- import type { McpUiHostContext, McpUiToolResultNotification } from "@modelcontextprotocol/ext-apps";
1
+ import type { McpUiDownloadFileResult, McpUiHostCapabilities, McpUiHostContext, McpUiInitializeResult, McpUiToolResultNotification } from "@modelcontextprotocol/ext-apps";
2
2
  export declare class MockResizeObserver {
3
3
  observe(): void;
4
4
  unobserve(): void;
5
5
  disconnect(): void;
6
6
  }
7
- export declare const getMcpAppHostPostMessageMock: (initialContext?: McpUiHostContext) => import("vitest").Mock<(message: {
7
+ export type McpAppHostMockOptions = {
8
+ hostCapabilities?: McpUiHostCapabilities;
9
+ downloadFileResult?: McpUiDownloadFileResult;
10
+ hostInfo?: McpUiInitializeResult["hostInfo"];
11
+ };
12
+ export declare const getMcpAppHostPostMessageMock: (initialContext?: McpUiHostContext, options?: McpAppHostMockOptions) => import("vitest").Mock<(message: {
8
13
  method: string;
9
14
  id: number;
10
15
  }) => void>;