skybridge 0.0.0-dev.fc7beaf → 0.0.0-dev.fca7959

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 (368) hide show
  1. package/README.md +10 -7
  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 +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/resolve-skybridge-config.d.ts +5 -0
  17. package/dist/cli/resolve-skybridge-config.js +18 -0
  18. package/dist/cli/resolve-skybridge-config.js.map +1 -0
  19. package/dist/cli/run-plain.d.ts +18 -0
  20. package/dist/cli/run-plain.js +89 -0
  21. package/dist/cli/run-plain.js.map +1 -0
  22. package/dist/cli/use-execute-steps.d.ts +1 -1
  23. package/dist/cli/use-nodemon.d.ts +14 -0
  24. package/dist/cli/use-nodemon.js +81 -62
  25. package/dist/cli/use-nodemon.js.map +1 -1
  26. package/dist/cli/use-typescript-check.d.ts +8 -2
  27. package/dist/cli/use-typescript-check.js +70 -67
  28. package/dist/cli/use-typescript-check.js.map +1 -1
  29. package/dist/commands/build.d.ts +0 -3
  30. package/dist/commands/build.js +2 -73
  31. package/dist/commands/build.js.map +1 -1
  32. package/dist/commands/dev.d.ts +1 -0
  33. package/dist/commands/dev.js +48 -0
  34. package/dist/commands/dev.js.map +1 -1
  35. package/dist/commands/start.js +7 -1
  36. package/dist/commands/start.js.map +1 -1
  37. package/dist/context-warnings.d.ts +5 -0
  38. package/dist/context-warnings.js +31 -0
  39. package/dist/context-warnings.js.map +1 -0
  40. package/dist/context-warnings.test.js +28 -0
  41. package/dist/context-warnings.test.js.map +1 -0
  42. package/dist/server/app.d.ts +194 -0
  43. package/dist/server/app.js +266 -0
  44. package/dist/server/app.js.map +1 -0
  45. package/dist/server/app.test.js +97 -0
  46. package/dist/server/app.test.js.map +1 -0
  47. package/dist/server/auth/discovery.d.ts +33 -0
  48. package/dist/server/auth/discovery.js +56 -0
  49. package/dist/server/auth/discovery.js.map +1 -0
  50. package/dist/server/auth/discovery.test.d.ts +1 -0
  51. package/dist/server/auth/discovery.test.js +93 -0
  52. package/dist/server/auth/discovery.test.js.map +1 -0
  53. package/dist/server/auth/index.d.ts +48 -0
  54. package/dist/server/auth/index.js +2 -0
  55. package/dist/server/auth/index.js.map +1 -0
  56. package/dist/server/auth/providers/auth0.d.ts +40 -0
  57. package/dist/server/auth/providers/auth0.js +36 -0
  58. package/dist/server/auth/providers/auth0.js.map +1 -0
  59. package/dist/server/auth/providers/auth0.test.d.ts +1 -0
  60. package/dist/server/auth/providers/auth0.test.js +50 -0
  61. package/dist/server/auth/providers/auth0.test.js.map +1 -0
  62. package/dist/server/auth/providers/authplane.d.ts +49 -0
  63. package/dist/server/auth/providers/authplane.js +57 -0
  64. package/dist/server/auth/providers/authplane.js.map +1 -0
  65. package/dist/server/auth/providers/authplane.test.d.ts +1 -0
  66. package/dist/server/auth/providers/authplane.test.js +143 -0
  67. package/dist/server/auth/providers/authplane.test.js.map +1 -0
  68. package/dist/server/auth/providers/clerk.d.ts +51 -0
  69. package/dist/server/auth/providers/clerk.js +19 -0
  70. package/dist/server/auth/providers/clerk.js.map +1 -0
  71. package/dist/server/auth/providers/clerk.test.d.ts +1 -0
  72. package/dist/server/auth/providers/clerk.test.js +30 -0
  73. package/dist/server/auth/providers/clerk.test.js.map +1 -0
  74. package/dist/server/auth/providers/custom.d.ts +40 -0
  75. package/dist/server/auth/providers/custom.js +59 -0
  76. package/dist/server/auth/providers/custom.js.map +1 -0
  77. package/dist/server/auth/providers/custom.test.d.ts +1 -0
  78. package/dist/server/auth/providers/custom.test.js +161 -0
  79. package/dist/server/auth/providers/custom.test.js.map +1 -0
  80. package/dist/server/auth/providers/descope.d.ts +44 -0
  81. package/dist/server/auth/providers/descope.js +44 -0
  82. package/dist/server/auth/providers/descope.js.map +1 -0
  83. package/dist/server/auth/providers/descope.test.d.ts +1 -0
  84. package/dist/server/auth/providers/descope.test.js +62 -0
  85. package/dist/server/auth/providers/descope.test.js.map +1 -0
  86. package/dist/server/auth/providers/shared.d.ts +2 -0
  87. package/dist/server/auth/providers/shared.js +6 -0
  88. package/dist/server/auth/providers/shared.js.map +1 -0
  89. package/dist/server/auth/providers/shared.test.d.ts +1 -0
  90. package/dist/server/auth/providers/shared.test.js +10 -0
  91. package/dist/server/auth/providers/shared.test.js.map +1 -0
  92. package/dist/server/auth/providers/stytch.d.ts +25 -0
  93. package/dist/server/auth/providers/stytch.js +16 -0
  94. package/dist/server/auth/providers/stytch.js.map +1 -0
  95. package/dist/server/auth/providers/verify-spy.d.ts +12 -0
  96. package/dist/server/auth/providers/verify-spy.js +21 -0
  97. package/dist/server/auth/providers/verify-spy.js.map +1 -0
  98. package/dist/server/auth/providers/workos.d.ts +33 -0
  99. package/dist/server/auth/providers/workos.js +15 -0
  100. package/dist/server/auth/providers/workos.js.map +1 -0
  101. package/dist/server/auth/security-schemes.d.ts +23 -0
  102. package/dist/server/auth/security-schemes.js +64 -0
  103. package/dist/server/auth/security-schemes.js.map +1 -0
  104. package/dist/server/auth/security-schemes.test.d.ts +1 -0
  105. package/dist/server/auth/security-schemes.test.js +99 -0
  106. package/dist/server/auth/security-schemes.test.js.map +1 -0
  107. package/dist/server/auth/setup.d.ts +6 -0
  108. package/dist/server/auth/setup.js +91 -0
  109. package/dist/server/auth/setup.js.map +1 -0
  110. package/dist/server/auth/setup.test.d.ts +1 -0
  111. package/dist/server/auth/setup.test.js +514 -0
  112. package/dist/server/auth/setup.test.js.map +1 -0
  113. package/dist/server/auth/verify.d.ts +46 -0
  114. package/dist/server/auth/verify.js +62 -0
  115. package/dist/server/auth/verify.js.map +1 -0
  116. package/dist/server/auth/verify.test.d.ts +1 -0
  117. package/dist/server/auth/verify.test.js +149 -0
  118. package/dist/server/auth/verify.test.js.map +1 -0
  119. package/dist/server/auth-extra.test-d.js +130 -0
  120. package/dist/server/auth-extra.test-d.js.map +1 -0
  121. package/dist/server/auth.d.ts +43 -6
  122. package/dist/server/auth.js +4 -5
  123. package/dist/server/auth.js.map +1 -1
  124. package/dist/server/build-manifest.test.d.ts +1 -0
  125. package/dist/server/build-manifest.test.js +28 -0
  126. package/dist/server/build-manifest.test.js.map +1 -0
  127. package/dist/server/content-helpers.d.ts +1 -1
  128. package/dist/server/content-helpers.js.map +1 -1
  129. package/dist/server/express.d.ts +23 -3
  130. package/dist/server/express.js +38 -32
  131. package/dist/server/express.js.map +1 -1
  132. package/dist/server/express.test.js +268 -90
  133. package/dist/server/express.test.js.map +1 -1
  134. package/dist/server/file-ref.d.ts +1 -1
  135. package/dist/server/file-ref.js +1 -1
  136. package/dist/server/file-ref.js.map +1 -1
  137. package/dist/server/host.d.ts +2 -0
  138. package/dist/server/host.js +11 -0
  139. package/dist/server/host.js.map +1 -0
  140. package/dist/server/host.test.d.ts +1 -0
  141. package/dist/server/host.test.js +13 -0
  142. package/dist/server/host.test.js.map +1 -0
  143. package/dist/server/index.d.ts +17 -3
  144. package/dist/server/index.js +14 -2
  145. package/dist/server/index.js.map +1 -1
  146. package/dist/server/mcp-errors.test.d.ts +1 -0
  147. package/dist/server/mcp-errors.test.js +41 -0
  148. package/dist/server/mcp-errors.test.js.map +1 -0
  149. package/dist/server/middleware.d.ts +35 -10
  150. package/dist/server/middleware.js +33 -0
  151. package/dist/server/middleware.js.map +1 -1
  152. package/dist/server/middleware.test-d.js +1 -1
  153. package/dist/server/middleware.test-d.js.map +1 -1
  154. package/dist/server/middleware.test.js +242 -134
  155. package/dist/server/middleware.test.js.map +1 -1
  156. package/dist/server/register-tool.test.d.ts +1 -0
  157. package/dist/server/register-tool.test.js +27 -0
  158. package/dist/server/register-tool.test.js.map +1 -0
  159. package/dist/server/requestOrigin.d.ts +7 -0
  160. package/dist/server/requestOrigin.js +25 -0
  161. package/dist/server/requestOrigin.js.map +1 -0
  162. package/dist/server/server.d.ts +144 -122
  163. package/dist/server/server.js +313 -328
  164. package/dist/server/server.js.map +1 -1
  165. package/dist/server/skills-integration.test.d.ts +1 -0
  166. package/dist/server/skills-integration.test.js +86 -0
  167. package/dist/server/skills-integration.test.js.map +1 -0
  168. package/dist/server/skills.d.ts +27 -0
  169. package/dist/server/skills.js +188 -0
  170. package/dist/server/skills.js.map +1 -0
  171. package/dist/server/skills.test.d.ts +1 -0
  172. package/dist/server/skills.test.js +243 -0
  173. package/dist/server/skills.test.js.map +1 -0
  174. package/dist/server/templateHelper.d.ts +0 -3
  175. package/dist/server/templateHelper.js.map +1 -1
  176. package/dist/server/templates.generated.js +4 -8
  177. package/dist/server/templates.generated.js.map +1 -1
  178. package/dist/server/tool-extra.test.d.ts +1 -0
  179. package/dist/server/tool-extra.test.js +88 -0
  180. package/dist/server/tool-extra.test.js.map +1 -0
  181. package/dist/server/view-name.test-d.d.ts +1 -0
  182. package/dist/server/view-name.test-d.js +8 -0
  183. package/dist/server/view-name.test-d.js.map +1 -0
  184. package/dist/server/view-resource-resolution.test.d.ts +6 -0
  185. package/dist/server/view-resource-resolution.test.js +176 -0
  186. package/dist/server/view-resource-resolution.test.js.map +1 -0
  187. package/dist/server/viewsDevServer.js +4 -1
  188. package/dist/server/viewsDevServer.js.map +1 -1
  189. package/dist/test/utils.d.ts +9 -11
  190. package/dist/test/utils.js +220 -201
  191. package/dist/test/utils.js.map +1 -1
  192. package/dist/test/view.test.js +105 -133
  193. package/dist/test/view.test.js.map +1 -1
  194. package/dist/views/index.d.ts +10 -0
  195. package/dist/views/index.js +3 -0
  196. package/dist/views/index.js.map +1 -0
  197. package/dist/{web/plugin → views}/scan-views.js +1 -1
  198. package/dist/views/scan-views.js.map +1 -0
  199. package/dist/views/scan-views.test.d.ts +1 -0
  200. package/dist/views/scan-views.test.js.map +1 -0
  201. package/dist/views/validate-view.d.ts +1 -0
  202. package/dist/{web/plugin → views}/validate-view.js +2 -2
  203. package/dist/views/validate-view.js.map +1 -0
  204. package/dist/views/validate-view.test.d.ts +1 -0
  205. package/dist/views/validate-view.test.js.map +1 -0
  206. package/dist/web/bridges/adaptor.d.ts +51 -0
  207. package/dist/web/bridges/adaptor.js +327 -0
  208. package/dist/web/bridges/adaptor.js.map +1 -0
  209. package/dist/web/bridges/adaptor.test.d.ts +1 -0
  210. package/dist/web/bridges/adaptor.test.js +225 -0
  211. package/dist/web/bridges/adaptor.test.js.map +1 -0
  212. package/dist/web/bridges/apps-sdk/bridge.d.ts +6 -2
  213. package/dist/web/bridges/apps-sdk/bridge.js +15 -4
  214. package/dist/web/bridges/apps-sdk/bridge.js.map +1 -1
  215. package/dist/web/bridges/apps-sdk/index.d.ts +0 -1
  216. package/dist/web/bridges/apps-sdk/index.js +0 -1
  217. package/dist/web/bridges/apps-sdk/index.js.map +1 -1
  218. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.d.ts +1 -1
  219. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js +1 -1
  220. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js.map +1 -1
  221. package/dist/web/bridges/get-adaptor.d.ts +4 -4
  222. package/dist/web/bridges/get-adaptor.js +6 -11
  223. package/dist/web/bridges/get-adaptor.js.map +1 -1
  224. package/dist/web/bridges/get-adaptor.test.d.ts +1 -0
  225. package/dist/web/bridges/get-adaptor.test.js +32 -0
  226. package/dist/web/bridges/get-adaptor.test.js.map +1 -0
  227. package/dist/web/bridges/mcp-app/bridge.d.ts +15 -3
  228. package/dist/web/bridges/mcp-app/bridge.js +73 -8
  229. package/dist/web/bridges/mcp-app/bridge.js.map +1 -1
  230. package/dist/web/bridges/mcp-app/bridge.test.d.ts +1 -0
  231. package/dist/web/bridges/mcp-app/bridge.test.js +17 -0
  232. package/dist/web/bridges/mcp-app/bridge.test.js.map +1 -0
  233. package/dist/web/bridges/mcp-app/index.d.ts +0 -1
  234. package/dist/web/bridges/mcp-app/index.js +0 -1
  235. package/dist/web/bridges/mcp-app/index.js.map +1 -1
  236. package/dist/web/bridges/mcp-app/types.d.ts +2 -0
  237. package/dist/web/bridges/mcp-app/types.js.map +1 -1
  238. package/dist/web/bridges/mcp-app/use-mcp-app-context.d.ts +1 -1
  239. package/dist/web/bridges/mcp-app/use-mcp-app-context.js +1 -1
  240. package/dist/web/bridges/mcp-app/use-mcp-app-context.js.map +1 -1
  241. package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js +1 -1
  242. package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js.map +1 -1
  243. package/dist/web/bridges/mcp-app/view-tools.test.d.ts +1 -0
  244. package/dist/web/bridges/mcp-app/view-tools.test.js +143 -0
  245. package/dist/web/bridges/mcp-app/view-tools.test.js.map +1 -0
  246. package/dist/web/bridges/types.d.ts +55 -7
  247. package/dist/web/bridges/types.js +14 -1
  248. package/dist/web/bridges/types.js.map +1 -1
  249. package/dist/web/bridges/types.test.d.ts +1 -0
  250. package/dist/web/bridges/types.test.js +19 -0
  251. package/dist/web/bridges/types.test.js.map +1 -0
  252. package/dist/web/components/modal-provider.d.ts +1 -1
  253. package/dist/web/components/modal-provider.js +4 -3
  254. package/dist/web/components/modal-provider.js.map +1 -1
  255. package/dist/web/create-store.test.js +10 -7
  256. package/dist/web/create-store.test.js.map +1 -1
  257. package/dist/web/data-llm.d.ts +1 -1
  258. package/dist/web/data-llm.test.js +20 -7
  259. package/dist/web/data-llm.test.js.map +1 -1
  260. package/dist/web/generate-helpers.d.ts +22 -18
  261. package/dist/web/generate-helpers.js +19 -15
  262. package/dist/web/generate-helpers.js.map +1 -1
  263. package/dist/web/generate-helpers.test-d.js +7 -5
  264. package/dist/web/generate-helpers.test-d.js.map +1 -1
  265. package/dist/web/generate-helpers.test.js +2 -2
  266. package/dist/web/generate-helpers.test.js.map +1 -1
  267. package/dist/web/hooks/index.d.ts +3 -1
  268. package/dist/web/hooks/index.js +3 -1
  269. package/dist/web/hooks/index.js.map +1 -1
  270. package/dist/web/hooks/test/utils.d.ts +2 -1
  271. package/dist/web/hooks/test/utils.js +1 -1
  272. package/dist/web/hooks/test/utils.js.map +1 -1
  273. package/dist/web/hooks/use-call-tool.test.js +39 -25
  274. package/dist/web/hooks/use-call-tool.test.js.map +1 -1
  275. package/dist/web/hooks/use-display-mode.d.ts +1 -1
  276. package/dist/web/hooks/use-display-mode.js +1 -1
  277. package/dist/web/hooks/use-display-mode.js.map +1 -1
  278. package/dist/web/hooks/use-display-mode.test.js +57 -21
  279. package/dist/web/hooks/use-display-mode.test.js.map +1 -1
  280. package/dist/web/hooks/use-download.d.ts +1 -3
  281. package/dist/web/hooks/use-download.js +1 -2
  282. package/dist/web/hooks/use-download.js.map +1 -1
  283. package/dist/web/hooks/use-download.test.js +18 -10
  284. package/dist/web/hooks/use-download.test.js.map +1 -1
  285. package/dist/web/hooks/use-files.test.js +11 -3
  286. package/dist/web/hooks/use-files.test.js.map +1 -1
  287. package/dist/web/hooks/use-host.d.ts +22 -0
  288. package/dist/web/hooks/use-host.js +30 -0
  289. package/dist/web/hooks/use-host.js.map +1 -0
  290. package/dist/web/hooks/use-host.test.d.ts +1 -0
  291. package/dist/web/hooks/use-host.test.js +59 -0
  292. package/dist/web/hooks/use-host.test.js.map +1 -0
  293. package/dist/web/hooks/use-open-external.test.js +15 -5
  294. package/dist/web/hooks/use-open-external.test.js.map +1 -1
  295. package/dist/web/hooks/use-register-view-tool.d.ts +37 -0
  296. package/dist/web/hooks/use-register-view-tool.js +50 -0
  297. package/dist/web/hooks/use-register-view-tool.js.map +1 -0
  298. package/dist/web/hooks/use-request-close.test.js +35 -40
  299. package/dist/web/hooks/use-request-close.test.js.map +1 -1
  300. package/dist/web/hooks/use-request-modal.test.js +11 -1
  301. package/dist/web/hooks/use-request-modal.test.js.map +1 -1
  302. package/dist/web/hooks/use-request-size.d.ts +1 -1
  303. package/dist/web/hooks/use-request-size.js +1 -1
  304. package/dist/web/hooks/use-request-size.js.map +1 -1
  305. package/dist/web/hooks/use-request-size.test.js +35 -53
  306. package/dist/web/hooks/use-request-size.test.js.map +1 -1
  307. package/dist/web/hooks/use-set-open-in-app-url.test.js +26 -12
  308. package/dist/web/hooks/use-set-open-in-app-url.test.js.map +1 -1
  309. package/dist/web/hooks/use-tool-info.d.ts +18 -19
  310. package/dist/web/hooks/use-tool-info.js +4 -8
  311. package/dist/web/hooks/use-tool-info.js.map +1 -1
  312. package/dist/web/hooks/use-tool-info.test-d.js +11 -34
  313. package/dist/web/hooks/use-tool-info.test-d.js.map +1 -1
  314. package/dist/web/hooks/use-tool-info.test.js +42 -37
  315. package/dist/web/hooks/use-tool-info.test.js.map +1 -1
  316. package/dist/web/hooks/use-user.d.ts +3 -2
  317. package/dist/web/hooks/use-user.js +4 -3
  318. package/dist/web/hooks/use-user.js.map +1 -1
  319. package/dist/web/hooks/use-user.test.js +85 -37
  320. package/dist/web/hooks/use-user.test.js.map +1 -1
  321. package/dist/web/hooks/use-view-state.js +19 -9
  322. package/dist/web/hooks/use-view-state.js.map +1 -1
  323. package/dist/web/hooks/use-view-state.test.js +39 -4
  324. package/dist/web/hooks/use-view-state.test.js.map +1 -1
  325. package/dist/web/hooks/use-viewport.d.ts +20 -0
  326. package/dist/web/hooks/use-viewport.js +21 -0
  327. package/dist/web/hooks/use-viewport.js.map +1 -0
  328. package/dist/web/hooks/use-viewport.test.d.ts +1 -0
  329. package/dist/web/hooks/use-viewport.test.js +109 -0
  330. package/dist/web/hooks/use-viewport.test.js.map +1 -0
  331. package/dist/web/mount-view.d.ts +3 -2
  332. package/dist/web/mount-view.js +5 -8
  333. package/dist/web/mount-view.js.map +1 -1
  334. package/package.json +32 -26
  335. package/dist/web/bridges/apps-sdk/adaptor.d.ts +0 -28
  336. package/dist/web/bridges/apps-sdk/adaptor.js +0 -113
  337. package/dist/web/bridges/apps-sdk/adaptor.js.map +0 -1
  338. package/dist/web/bridges/mcp-app/adaptor.d.ts +0 -52
  339. package/dist/web/bridges/mcp-app/adaptor.js +0 -280
  340. package/dist/web/bridges/mcp-app/adaptor.js.map +0 -1
  341. package/dist/web/hooks/use-layout.d.ts +0 -24
  342. package/dist/web/hooks/use-layout.js +0 -25
  343. package/dist/web/hooks/use-layout.js.map +0 -1
  344. package/dist/web/hooks/use-layout.test.js +0 -96
  345. package/dist/web/hooks/use-layout.test.js.map +0 -1
  346. package/dist/web/plugin/data-llm.test.js +0 -81
  347. package/dist/web/plugin/data-llm.test.js.map +0 -1
  348. package/dist/web/plugin/plugin.d.ts +0 -33
  349. package/dist/web/plugin/plugin.js +0 -189
  350. package/dist/web/plugin/plugin.js.map +0 -1
  351. package/dist/web/plugin/scan-views.js.map +0 -1
  352. package/dist/web/plugin/scan-views.test.js.map +0 -1
  353. package/dist/web/plugin/transform-data-llm.d.ts +0 -12
  354. package/dist/web/plugin/transform-data-llm.js +0 -96
  355. package/dist/web/plugin/transform-data-llm.js.map +0 -1
  356. package/dist/web/plugin/transform-data-llm.test.js +0 -81
  357. package/dist/web/plugin/transform-data-llm.test.js.map +0 -1
  358. package/dist/web/plugin/validate-view.d.ts +0 -1
  359. package/dist/web/plugin/validate-view.js.map +0 -1
  360. package/dist/web/plugin/validate-view.test.js.map +0 -1
  361. /package/dist/{web/hooks/use-layout.test.d.ts → cli/build-helpers.test.d.ts} +0 -0
  362. /package/dist/{web/plugin/data-llm.test.d.ts → cli/build-steps.test.d.ts} +0 -0
  363. /package/dist/{web/plugin/scan-views.test.d.ts → context-warnings.test.d.ts} +0 -0
  364. /package/dist/{web/plugin/transform-data-llm.test.d.ts → server/app.test.d.ts} +0 -0
  365. /package/dist/{web/plugin/validate-view.test.d.ts → server/auth-extra.test-d.d.ts} +0 -0
  366. /package/dist/{web/plugin → views}/scan-views.d.ts +0 -0
  367. /package/dist/{web/plugin → views}/scan-views.test.js +0 -0
  368. /package/dist/{web/plugin → views}/validate-view.test.js +0 -0
@@ -1,64 +1,46 @@
1
1
  import { renderHook, waitFor } from "@testing-library/react";
2
2
  import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
3
- import { AppsSdkAdaptor } from "../bridges/apps-sdk/adaptor.js";
3
+ import { HostAdaptor } from "../bridges/adaptor.js";
4
4
  import { McpAppBridge } from "../bridges/mcp-app/bridge.js";
5
5
  import { getMcpAppHostPostMessageMock, MockResizeObserver, } from "./test/utils.js";
6
6
  import { useRequestSize } from "./use-request-size.js";
7
7
  describe("useRequestSize", () => {
8
- describe("apps-sdk host", () => {
9
- let consoleWarnSpy;
10
- beforeEach(() => {
11
- AppsSdkAdaptor.resetInstance();
12
- vi.stubGlobal("openai", {});
13
- vi.stubGlobal("skybridge", { hostType: "apps-sdk" });
14
- consoleWarnSpy = vi.spyOn(console, "warn").mockImplementation(() => { });
15
- });
16
- afterEach(() => {
17
- AppsSdkAdaptor.resetInstance();
18
- vi.unstubAllGlobals();
19
- vi.resetAllMocks();
20
- });
21
- it("warns that requestSize is not supported on Apps SDK", async () => {
22
- const { result } = renderHook(() => useRequestSize());
23
- await result.current({ height: 400 });
24
- expect(consoleWarnSpy).toHaveBeenCalledTimes(1);
25
- expect(consoleWarnSpy.mock.calls[0]?.[0]).toContain("not supported");
26
- });
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 });
27
17
  });
28
- describe("mcp-app host", () => {
29
- let postMessageMock;
30
- beforeEach(() => {
31
- vi.stubGlobal("skybridge", { hostType: "mcp-app" });
32
- vi.stubGlobal("ResizeObserver", MockResizeObserver);
33
- postMessageMock = getMcpAppHostPostMessageMock();
34
- vi.stubGlobal("parent", { postMessage: postMessageMock });
35
- });
36
- afterEach(async () => {
37
- vi.unstubAllGlobals();
38
- vi.resetAllMocks();
39
- McpAppBridge.resetInstance();
40
- });
41
- it("sends a ui/notifications/size-changed notification with width and height", async () => {
42
- const { result } = renderHook(() => useRequestSize());
43
- await result.current({ width: 800, height: 400 });
44
- await waitFor(() => {
45
- expect(postMessageMock).toHaveBeenCalledWith(expect.objectContaining({
46
- jsonrpc: "2.0",
47
- method: "ui/notifications/size-changed",
48
- params: { width: 800, height: 400 },
49
- }), "*");
50
- });
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
+ }), "*");
51
33
  });
52
- it("forwards height-only payloads as-is", async () => {
53
- const { result } = renderHook(() => useRequestSize());
54
- await result.current({ height: 400 });
55
- await waitFor(() => {
56
- expect(postMessageMock).toHaveBeenCalledWith(expect.objectContaining({
57
- jsonrpc: "2.0",
58
- method: "ui/notifications/size-changed",
59
- params: { height: 400 },
60
- }), "*");
61
- });
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
+ }), "*");
62
44
  });
63
45
  });
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AE;gBACjB,MAAM,CAAC,eAAe,CAAC,CAAC,oBAAoB,CAC1C,MAAM,CAAC,gBAAgB,CAAC;oBACtB,OAAO,EAAE,KAAK;oBACd,MAAM,EAAE,+BAA+B;oBACvC,MAAM,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE;iBACpC,CAAC,EACF,GAAG,CACJ,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,qCAAqC,EAAE,KAAK,IAAI,EAAE;YACnD,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,cAAc,EAAE,CAAC,CAAC;YAEtD,MAAM,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;YAEtC,MAAM,OAAO,CAAC,GAAG,EAAE;gBACjB,MAAM,CAAC,eAAe,CAAC,CAAC,oBAAoB,CAC1C,MAAM,CAAC,gBAAgB,CAAC;oBACtB,OAAO,EAAE,KAAK;oBACd,MAAM,EAAE,+BAA+B;oBACvC,MAAM,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE;iBACxB,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 { AppsSdkAdaptor } from \"../bridges/apps-sdk/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 describe(\"apps-sdk host\", () => {\n let consoleWarnSpy: ReturnType<typeof vi.spyOn>;\n\n beforeEach(() => {\n AppsSdkAdaptor.resetInstance();\n vi.stubGlobal(\"openai\", {});\n vi.stubGlobal(\"skybridge\", { hostType: \"apps-sdk\" });\n consoleWarnSpy = vi.spyOn(console, \"warn\").mockImplementation(() => {});\n });\n\n afterEach(() => {\n AppsSdkAdaptor.resetInstance();\n vi.unstubAllGlobals();\n vi.resetAllMocks();\n });\n\n it(\"warns that requestSize is not supported on Apps SDK\", async () => {\n const { result } = renderHook(() => useRequestSize());\n\n await result.current({ height: 400 });\n\n expect(consoleWarnSpy).toHaveBeenCalledTimes(1);\n expect(consoleWarnSpy.mock.calls[0]?.[0]).toContain(\"not supported\");\n });\n });\n\n describe(\"mcp-app host\", () => {\n let postMessageMock: ReturnType<typeof getMcpAppHostPostMessageMock>;\n\n beforeEach(() => {\n vi.stubGlobal(\"skybridge\", { hostType: \"mcp-app\" });\n vi.stubGlobal(\"ResizeObserver\", MockResizeObserver);\n postMessageMock = getMcpAppHostPostMessageMock();\n vi.stubGlobal(\"parent\", { postMessage: postMessageMock });\n });\n\n afterEach(async () => {\n vi.unstubAllGlobals();\n vi.resetAllMocks();\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});\n"]}
1
+ {"version":3,"file":"use-request-size.test.js","sourceRoot":"","sources":["../../../src/web/hooks/use-request-size.test.ts"],"names":[],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C,cAAc,EAAE,CAAC,CAAC;QAEtD,MAAM,MAAM,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;QAElD,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,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE;aACpC,CAAC,EACF,GAAG,CACJ,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qCAAqC,EAAE,KAAK,IAAI,EAAE;QACnD,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,cAAc,EAAE,CAAC,CAAC;QAEtD,MAAM,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;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,8 +1,18 @@
1
1
  import { renderHook } from "@testing-library/react";
2
2
  import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
3
- import { AppsSdkAdaptor } from "../bridges/apps-sdk/adaptor.js";
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";
6
+ import { NotSupportedError } from "../bridges/types.js";
4
7
  import { useSetOpenInAppUrl } from "./use-set-open-in-app-url.js";
5
8
  describe("useSetOpenInAppUrl", () => {
9
+ afterEach(() => {
10
+ vi.unstubAllGlobals();
11
+ vi.resetAllMocks();
12
+ HostAdaptor.resetInstance();
13
+ AppsSdkBridge.resetInstance();
14
+ McpAppBridge.resetInstance();
15
+ });
6
16
  describe("apps-sdk host", () => {
7
17
  let setOpenInAppUrlMock;
8
18
  beforeEach(() => {
@@ -10,15 +20,8 @@ describe("useSetOpenInAppUrl", () => {
10
20
  vi.stubGlobal("openai", {
11
21
  setOpenInAppUrl: setOpenInAppUrlMock,
12
22
  });
13
- vi.stubGlobal("skybridge", {
14
- hostType: "apps-sdk",
15
- serverUrl: "https://example.com",
16
- });
17
- });
18
- afterEach(() => {
19
- vi.unstubAllGlobals();
20
- vi.resetAllMocks();
21
- AppsSdkAdaptor.resetInstance();
23
+ vi.stubGlobal("skybridge", { serverUrl: "https://example.com" });
24
+ vi.stubGlobal("parent", { postMessage: vi.fn() });
22
25
  });
23
26
  it("should return a function that calls window.openai.setOpenInAppUrl with the href", async () => {
24
27
  const { result } = renderHook(() => useSetOpenInAppUrl());
@@ -27,9 +30,9 @@ describe("useSetOpenInAppUrl", () => {
27
30
  expect(setOpenInAppUrlMock).toHaveBeenCalledTimes(1);
28
31
  expect(setOpenInAppUrlMock).toHaveBeenCalledWith({ href });
29
32
  });
30
- it("should throw an error when href is empty", () => {
33
+ it("should reject when href is empty", async () => {
31
34
  const { result } = renderHook(() => useSetOpenInAppUrl());
32
- expect(() => result.current("")).toThrow("The href parameter is required.");
35
+ await expect(result.current("")).rejects.toThrow("The href parameter is required.");
33
36
  });
34
37
  it("should call setOpenInAppUrl when href origin differs from serverUrl origin", async () => {
35
38
  const { result } = renderHook(() => useSetOpenInAppUrl());
@@ -39,5 +42,16 @@ describe("useSetOpenInAppUrl", () => {
39
42
  expect(setOpenInAppUrlMock).toHaveBeenCalledWith({ href });
40
43
  });
41
44
  });
45
+ describe("mcp-app host", () => {
46
+ beforeEach(() => {
47
+ vi.stubGlobal("openai", undefined);
48
+ vi.stubGlobal("skybridge", { serverUrl: "https://example.com" });
49
+ vi.stubGlobal("parent", { postMessage: vi.fn() });
50
+ });
51
+ it("should throw NotSupportedError when called from an MCP App runtime", async () => {
52
+ const { result } = renderHook(() => useSetOpenInAppUrl());
53
+ await expect(result.current("https://example.com/path")).rejects.toBeInstanceOf(NotSupportedError);
54
+ });
55
+ });
42
56
  });
43
57
  //# sourceMappingURL=use-set-open-in-app-url.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-set-open-in-app-url.test.js","sourceRoot":"","sources":["../../../src/web/hooks/use-set-open-in-app-url.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,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAElE,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;QAC7B,IAAI,mBAA6C,CAAC;QAElD,UAAU,CAAC,GAAG,EAAE;YACd,mBAAmB,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;YAC3D,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE;gBACtB,eAAe,EAAE,mBAAmB;aACrC,CAAC,CAAC;YACH,EAAE,CAAC,UAAU,CAAC,WAAW,EAAE;gBACzB,QAAQ,EAAE,UAAU;gBACpB,SAAS,EAAE,qBAAqB;aACjC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,SAAS,CAAC,GAAG,EAAE;YACb,EAAE,CAAC,gBAAgB,EAAE,CAAC;YACtB,EAAE,CAAC,aAAa,EAAE,CAAC;YACnB,cAAc,CAAC,aAAa,EAAE,CAAC;QACjC,CAAC,CAAC,CAAC;QAEH,E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import { AppsSdkAdaptor } from \"../bridges/apps-sdk/adaptor.js\";\nimport { useSetOpenInAppUrl } from \"./use-set-open-in-app-url.js\";\n\ndescribe(\"useSetOpenInAppUrl\", () => {\n describe(\"apps-sdk host\", () => {\n let setOpenInAppUrlMock: ReturnType<typeof vi.fn>;\n\n beforeEach(() => {\n setOpenInAppUrlMock = vi.fn().mockResolvedValue(undefined);\n vi.stubGlobal(\"openai\", {\n setOpenInAppUrl: setOpenInAppUrlMock,\n });\n vi.stubGlobal(\"skybridge\", {\n hostType: \"apps-sdk\",\n serverUrl: \"https://example.com\",\n });\n });\n\n afterEach(() => {\n vi.unstubAllGlobals();\n vi.resetAllMocks();\n AppsSdkAdaptor.resetInstance();\n });\n\n it(\"should return a function that calls window.openai.setOpenInAppUrl with the href\", async () => {\n const { result } = renderHook(() => useSetOpenInAppUrl());\n\n const href = \"https://example.com/path\";\n await result.current(href);\n\n expect(setOpenInAppUrlMock).toHaveBeenCalledTimes(1);\n expect(setOpenInAppUrlMock).toHaveBeenCalledWith({ href });\n });\n\n it(\"should throw an error when href is empty\", () => {\n const { result } = renderHook(() => useSetOpenInAppUrl());\n\n expect(() => result.current(\"\")).toThrow(\n \"The href parameter is required.\",\n );\n });\n\n it(\"should call setOpenInAppUrl when href origin differs from serverUrl origin\", async () => {\n const { result } = renderHook(() => useSetOpenInAppUrl());\n\n const href = \"https://different-domain.com/path\";\n await result.current(href);\n\n expect(setOpenInAppUrlMock).toHaveBeenCalledTimes(1);\n expect(setOpenInAppUrlMock).toHaveBeenCalledWith({ href });\n });\n });\n});\n"]}
1
+ {"version":3,"file":"use-set-open-in-app-url.test.js","sourceRoot":"","sources":["../../../src/web/hooks/use-set-open-in-app-url.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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AE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,oEAAoE,EAAE,KAAK,IAAI,EAAE;YAClF,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,kBAAkB,EAAE,CAAC,CAAC;YAE1D,MAAM,MAAM,CACV,MAAM,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAC3C,CAAC,OAAO,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC;QAC9C,CAAC,CAAC,CAAC;IACL,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 { NotSupportedError } from \"../bridges/types.js\";\nimport { useSetOpenInAppUrl } from \"./use-set-open-in-app-url.js\";\n\ndescribe(\"useSetOpenInAppUrl\", () => {\n afterEach(() => {\n vi.unstubAllGlobals();\n vi.resetAllMocks();\n HostAdaptor.resetInstance();\n AppsSdkBridge.resetInstance();\n McpAppBridge.resetInstance();\n });\n\n describe(\"apps-sdk host\", () => {\n let setOpenInAppUrlMock: ReturnType<typeof vi.fn>;\n\n beforeEach(() => {\n setOpenInAppUrlMock = vi.fn().mockResolvedValue(undefined);\n vi.stubGlobal(\"openai\", {\n setOpenInAppUrl: setOpenInAppUrlMock,\n });\n vi.stubGlobal(\"skybridge\", { serverUrl: \"https://example.com\" });\n vi.stubGlobal(\"parent\", { postMessage: vi.fn() });\n });\n\n it(\"should return a function that calls window.openai.setOpenInAppUrl with the href\", async () => {\n const { result } = renderHook(() => useSetOpenInAppUrl());\n\n const href = \"https://example.com/path\";\n await result.current(href);\n\n expect(setOpenInAppUrlMock).toHaveBeenCalledTimes(1);\n expect(setOpenInAppUrlMock).toHaveBeenCalledWith({ href });\n });\n\n it(\"should reject when href is empty\", async () => {\n const { result } = renderHook(() => useSetOpenInAppUrl());\n\n await expect(result.current(\"\")).rejects.toThrow(\n \"The href parameter is required.\",\n );\n });\n\n it(\"should call setOpenInAppUrl when href origin differs from serverUrl origin\", async () => {\n const { result } = renderHook(() => useSetOpenInAppUrl());\n\n const href = \"https://different-domain.com/path\";\n await result.current(href);\n\n expect(setOpenInAppUrlMock).toHaveBeenCalledTimes(1);\n expect(setOpenInAppUrlMock).toHaveBeenCalledWith({ href });\n });\n });\n\n describe(\"mcp-app host\", () => {\n beforeEach(() => {\n vi.stubGlobal(\"openai\", undefined);\n vi.stubGlobal(\"skybridge\", { serverUrl: \"https://example.com\" });\n vi.stubGlobal(\"parent\", { postMessage: vi.fn() });\n });\n\n it(\"should throw NotSupportedError when called from an MCP App runtime\", async () => {\n const { result } = renderHook(() => useSetOpenInAppUrl());\n\n await expect(\n result.current(\"https://example.com/path\"),\n ).rejects.toBeInstanceOf(NotSupportedError);\n });\n });\n});\n"]}
@@ -1,39 +1,38 @@
1
1
  import type { UnknownObject } from "../types.js";
2
- /** {@link useToolInfo} state before the tool has been invoked. */
3
- export type ToolIdleState = {
4
- status: "idle";
5
- isIdle: true;
6
- isPending: false;
7
- isSuccess: false;
8
- input: undefined;
9
- output: undefined;
10
- responseMetadata: undefined;
11
- };
12
- /** {@link useToolInfo} state while the tool is executing — `input` is available, output is not yet. */
2
+ /**
3
+ * {@link useToolInfo} state while the tool is executing — `output` is not yet
4
+ * available.
5
+ *
6
+ * `input` is optional: the host may render the view before delivering the
7
+ * tool arguments.
8
+ */
13
9
  export type ToolPendingState<ToolInput extends UnknownObject> = {
14
10
  status: "pending";
15
- isIdle: false;
16
11
  isPending: true;
17
12
  isSuccess: false;
18
- input: ToolInput;
13
+ input: ToolInput | undefined;
19
14
  output: undefined;
20
15
  responseMetadata: undefined;
21
16
  };
22
- /** {@link useToolInfo} state once the tool returned — `input`, `output`, and `responseMetadata` are all available. */
17
+ /**
18
+ * {@link useToolInfo} state once the tool returned — `output` is available.
19
+ *
20
+ * `input` is optional: the host may not have surfaced the tool arguments by
21
+ * the time `output` arrives.
22
+ */
23
23
  export type ToolSuccessState<ToolInput extends UnknownObject, ToolOutput extends UnknownObject, ToolResponseMetadata extends UnknownObject> = {
24
24
  status: "success";
25
- isIdle: false;
26
25
  isPending: false;
27
26
  isSuccess: true;
28
- input: ToolInput;
27
+ input: ToolInput | undefined;
29
28
  output: ToolOutput;
30
29
  responseMetadata: ToolResponseMetadata;
31
30
  };
32
31
  /**
33
32
  * Discriminated union describing the tool invocation that triggered the
34
- * current view render. Use `isIdle` / `isPending` / `isSuccess` to narrow.
33
+ * current view render. Use `isPending` / `isSuccess` to narrow.
35
34
  */
36
- export type ToolState<ToolInput extends UnknownObject, ToolOutput extends UnknownObject, ToolResponseMetadata extends UnknownObject> = ToolIdleState | ToolPendingState<ToolInput> | ToolSuccessState<ToolInput, ToolOutput, ToolResponseMetadata>;
35
+ export type ToolState<ToolInput extends UnknownObject, ToolOutput extends UnknownObject, ToolResponseMetadata extends UnknownObject> = ToolPendingState<ToolInput> | ToolSuccessState<ToolInput, ToolOutput, ToolResponseMetadata>;
37
36
  type ToolSignature = {
38
37
  input: UnknownObject;
39
38
  output: UnknownObject;
@@ -42,7 +41,7 @@ type ToolSignature = {
42
41
  /**
43
42
  * Access the tool invocation that produced the current view: its `input`,
44
43
  * resulting `output`, and `responseMetadata`. The shape evolves as the tool
45
- * runs (idle → pending → success), exposed through {@link ToolState}.
44
+ * runs (pending → success), exposed through {@link ToolState}.
46
45
  *
47
46
  * For full input/output typing per tool name, prefer the typed `useToolInfo`
48
47
  * returned by {@link generateHelpers} over the generic form.
@@ -1,8 +1,5 @@
1
1
  import { useHostContext } from "../bridges/index.js";
2
- function deriveStatus(input, output, responseMetadata) {
3
- if (input === null) {
4
- return "idle";
5
- }
2
+ function deriveStatus(output, responseMetadata) {
6
3
  if (output === null && responseMetadata === null) {
7
4
  return "pending";
8
5
  }
@@ -11,7 +8,7 @@ function deriveStatus(input, output, responseMetadata) {
11
8
  /**
12
9
  * Access the tool invocation that produced the current view: its `input`,
13
10
  * resulting `output`, and `responseMetadata`. The shape evolves as the tool
14
- * runs (idle → pending → success), exposed through {@link ToolState}.
11
+ * runs (pending → success), exposed through {@link ToolState}.
15
12
  *
16
13
  * For full input/output typing per tool name, prefer the typed `useToolInfo`
17
14
  * returned by {@link generateHelpers} over the generic form.
@@ -38,11 +35,10 @@ export function useToolInfo() {
38
35
  const input = useHostContext("toolInput");
39
36
  const output = useHostContext("toolOutput");
40
37
  const responseMetadata = useHostContext("toolResponseMetadata");
41
- const status = deriveStatus(input, output, responseMetadata);
38
+ const status = deriveStatus(output, responseMetadata);
42
39
  return {
43
- input,
40
+ input: input ?? undefined,
44
41
  status,
45
- isIdle: status === "idle",
46
42
  isPending: status === "pending",
47
43
  isSuccess: status === "success",
48
44
  output,
@@ -1 +1 @@
1
- {"version":3,"file":"use-tool-info.js","sourceRoot":"","sources":["../../../src/web/hooks/use-tool-info.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AA2DrD,SAAS,YAAY,CACnB,KAAqC,EACrC,MAAsC,EACtC,gBAAgD;IAEhD,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACnB,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,IAAI,MAAM,KAAK,IAAI,IAAI,gBAAgB,KAAK,IAAI,EAAE,CAAC;QACjD,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,WAAW;IAGzB,MAAM,KAAK,GAAG,cAAc,CAAC,WAAW,CAAC,CAAC;IAC1C,MAAM,MAAM,GAAG,cAAc,CAAC,YAAY,CAAC,CAAC;IAC5C,MAAM,gBAAgB,GAAG,cAAc,CAAC,sBAAsB,CAAC,CAAC;IAEhE,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAM7D,OAAO;QACL,KAAK;QACL,MAAM;QACN,MAAM,EAAE,MAAM,KAAK,MAAM;QACzB,SAAS,EAAE,MAAM,KAAK,SAAS;QAC/B,SAAS,EAAE,MAAM,KAAK,SAAS;QAC/B,MAAM;QACN,gBAAgB;KACqB,CAAC;AAC1C,CAAC","sourcesContent":["import { useHostContext } from \"../bridges/index.js\";\nimport type { UnknownObject } from \"../types.js\";\n\n/** {@link useToolInfo} state before the tool has been invoked. */\nexport type ToolIdleState = {\n status: \"idle\";\n isIdle: true;\n isPending: false;\n isSuccess: false;\n input: undefined;\n output: undefined;\n responseMetadata: undefined;\n};\n\n/** {@link useToolInfo} state while the tool is executing — `input` is available, output is not yet. */\nexport type ToolPendingState<ToolInput extends UnknownObject> = {\n status: \"pending\";\n isIdle: false;\n isPending: true;\n isSuccess: false;\n input: ToolInput;\n output: undefined;\n responseMetadata: undefined;\n};\n\n/** {@link useToolInfo} state once the tool returned — `input`, `output`, and `responseMetadata` are all available. */\nexport type ToolSuccessState<\n ToolInput extends UnknownObject,\n ToolOutput extends UnknownObject,\n ToolResponseMetadata extends UnknownObject,\n> = {\n status: \"success\";\n isIdle: false;\n isPending: false;\n isSuccess: true;\n input: ToolInput;\n output: ToolOutput;\n responseMetadata: ToolResponseMetadata;\n};\n\n/**\n * Discriminated union describing the tool invocation that triggered the\n * current view render. Use `isIdle` / `isPending` / `isSuccess` to narrow.\n */\nexport type ToolState<\n ToolInput extends UnknownObject,\n ToolOutput extends UnknownObject,\n ToolResponseMetadata extends UnknownObject,\n> =\n | ToolIdleState\n | ToolPendingState<ToolInput>\n | ToolSuccessState<ToolInput, ToolOutput, ToolResponseMetadata>;\n\ntype ToolSignature = {\n input: UnknownObject;\n output: UnknownObject;\n responseMetadata: UnknownObject;\n};\n\nfunction deriveStatus(\n input: Record<string, unknown> | null,\n output: Record<string, unknown> | null,\n responseMetadata: Record<string, unknown> | null,\n): \"idle\" | \"pending\" | \"success\" {\n if (input === null) {\n return \"idle\";\n }\n if (output === null && responseMetadata === null) {\n return \"pending\";\n }\n return \"success\";\n}\n\n/**\n * Access the tool invocation that produced the current view: its `input`,\n * resulting `output`, and `responseMetadata`. The shape evolves as the tool\n * runs (idle → pending → success), exposed through {@link ToolState}.\n *\n * For full input/output typing per tool name, prefer the typed `useToolInfo`\n * returned by {@link generateHelpers} over the generic form.\n *\n * @typeParam TS - Optional partial shape `{ input, output, responseMetadata }`\n * to refine each field's type. When omitted, each typed field resolves to\n * `never` — pass an explicit shape or use the typed helper from\n * {@link generateHelpers} to get usable types.\n *\n * @example\n * ```tsx\n * const { isSuccess, input, output } = useToolInfo<{\n * input: { query: string };\n * output: { results: Result[] };\n * }>();\n *\n * if (!isSuccess || !output) return <Skeleton />;\n * return <Results items={output.results} />;\n * ```\n *\n * @see https://docs.skybridge.tech/api-reference/use-tool-info\n */\nexport function useToolInfo<\n TS extends Partial<ToolSignature> = Record<string, never>,\n>() {\n const input = useHostContext(\"toolInput\");\n const output = useHostContext(\"toolOutput\");\n const responseMetadata = useHostContext(\"toolResponseMetadata\");\n\n const status = deriveStatus(input, output, responseMetadata);\n\n type Input = UnknownObject & TS[\"input\"];\n type Output = UnknownObject & TS[\"output\"];\n type Metadata = UnknownObject & TS[\"responseMetadata\"];\n\n return {\n input,\n status,\n isIdle: status === \"idle\",\n isPending: status === \"pending\",\n isSuccess: status === \"success\",\n output,\n responseMetadata,\n } as ToolState<Input, Output, Metadata>;\n}\n"]}
1
+ {"version":3,"file":"use-tool-info.js","sourceRoot":"","sources":["../../../src/web/hooks/use-tool-info.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAwDrD,SAAS,YAAY,CACnB,MAAsC,EACtC,gBAAgD;IAEhD,IAAI,MAAM,KAAK,IAAI,IAAI,gBAAgB,KAAK,IAAI,EAAE,CAAC;QACjD,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,WAAW;IAGzB,MAAM,KAAK,GAAG,cAAc,CAAC,WAAW,CAAC,CAAC;IAC1C,MAAM,MAAM,GAAG,cAAc,CAAC,YAAY,CAAC,CAAC;IAC5C,MAAM,gBAAgB,GAAG,cAAc,CAAC,sBAAsB,CAAC,CAAC;IAEhE,MAAM,MAAM,GAAG,YAAY,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAMtD,OAAO;QACL,KAAK,EAAE,KAAK,IAAI,SAAS;QACzB,MAAM;QACN,SAAS,EAAE,MAAM,KAAK,SAAS;QAC/B,SAAS,EAAE,MAAM,KAAK,SAAS;QAC/B,MAAM;QACN,gBAAgB;KACqB,CAAC;AAC1C,CAAC","sourcesContent":["import { useHostContext } from \"../bridges/index.js\";\nimport type { UnknownObject } from \"../types.js\";\n\n/**\n * {@link useToolInfo} state while the tool is executing — `output` is not yet\n * available.\n *\n * `input` is optional: the host may render the view before delivering the\n * tool arguments.\n */\nexport type ToolPendingState<ToolInput extends UnknownObject> = {\n status: \"pending\";\n isPending: true;\n isSuccess: false;\n input: ToolInput | undefined;\n output: undefined;\n responseMetadata: undefined;\n};\n\n/**\n * {@link useToolInfo} state once the tool returned — `output` is available.\n *\n * `input` is optional: the host may not have surfaced the tool arguments by\n * the time `output` arrives.\n */\nexport type ToolSuccessState<\n ToolInput extends UnknownObject,\n ToolOutput extends UnknownObject,\n ToolResponseMetadata extends UnknownObject,\n> = {\n status: \"success\";\n isPending: false;\n isSuccess: true;\n input: ToolInput | undefined;\n output: ToolOutput;\n responseMetadata: ToolResponseMetadata;\n};\n\n/**\n * Discriminated union describing the tool invocation that triggered the\n * current view render. Use `isPending` / `isSuccess` to narrow.\n */\nexport type ToolState<\n ToolInput extends UnknownObject,\n ToolOutput extends UnknownObject,\n ToolResponseMetadata extends UnknownObject,\n> =\n | ToolPendingState<ToolInput>\n | ToolSuccessState<ToolInput, ToolOutput, ToolResponseMetadata>;\n\ntype ToolSignature = {\n input: UnknownObject;\n output: UnknownObject;\n responseMetadata: UnknownObject;\n};\n\nfunction deriveStatus(\n output: Record<string, unknown> | null,\n responseMetadata: Record<string, unknown> | null,\n): \"pending\" | \"success\" {\n if (output === null && responseMetadata === null) {\n return \"pending\";\n }\n return \"success\";\n}\n\n/**\n * Access the tool invocation that produced the current view: its `input`,\n * resulting `output`, and `responseMetadata`. The shape evolves as the tool\n * runs (pending → success), exposed through {@link ToolState}.\n *\n * For full input/output typing per tool name, prefer the typed `useToolInfo`\n * returned by {@link generateHelpers} over the generic form.\n *\n * @typeParam TS - Optional partial shape `{ input, output, responseMetadata }`\n * to refine each field's type. When omitted, each typed field resolves to\n * `never` — pass an explicit shape or use the typed helper from\n * {@link generateHelpers} to get usable types.\n *\n * @example\n * ```tsx\n * const { isSuccess, input, output } = useToolInfo<{\n * input: { query: string };\n * output: { results: Result[] };\n * }>();\n *\n * if (!isSuccess || !output) return <Skeleton />;\n * return <Results items={output.results} />;\n * ```\n *\n * @see https://docs.skybridge.tech/api-reference/use-tool-info\n */\nexport function useToolInfo<\n TS extends Partial<ToolSignature> = Record<string, never>,\n>() {\n const input = useHostContext(\"toolInput\");\n const output = useHostContext(\"toolOutput\");\n const responseMetadata = useHostContext(\"toolResponseMetadata\");\n\n const status = deriveStatus(output, responseMetadata);\n\n type Input = UnknownObject & TS[\"input\"];\n type Output = UnknownObject & TS[\"output\"];\n type Metadata = UnknownObject & TS[\"responseMetadata\"];\n\n return {\n input: input ?? undefined,\n status,\n isPending: status === \"pending\",\n isSuccess: status === \"success\",\n output,\n responseMetadata,\n } as ToolState<Input, Output, Metadata>;\n}\n"]}
@@ -6,24 +6,19 @@ test("useToolInfo - TypeScript typing", () => {
6
6
  expectTypeOf(result.status);
7
7
  expectTypeOf(result.isPending);
8
8
  expectTypeOf(result.isSuccess);
9
- expectTypeOf(result.isIdle);
10
9
  expectTypeOf(result.input);
11
10
  });
12
11
  test("should correctly type input, output, and responseMetadata with explicit ToolSignature", () => {
13
12
  const result = useToolInfo();
14
- // When idle, input should be undefined
15
- if (result.status === "idle") {
16
- expectTypeOf(result.input);
17
- expectTypeOf(result.output);
18
- expectTypeOf(result.responseMetadata);
19
- }
20
- // When pending, output and responseMetadata should be undefined
13
+ // When pending, input may be undefined (host hasn't delivered args yet,
14
+ // or the tool has no input schema)
21
15
  if (result.status === "pending") {
22
16
  expectTypeOf(result.input);
23
17
  expectTypeOf(result.output);
24
18
  expectTypeOf(result.responseMetadata);
25
19
  }
26
- // When success, output and responseMetadata should be defined
20
+ // When success, output and responseMetadata are defined; input may still
21
+ // be undefined if the host hasn't surfaced the tool arguments
27
22
  if (result.status === "success") {
28
23
  expectTypeOf(result.input);
29
24
  expectTypeOf(result.output);
@@ -32,35 +27,17 @@ test("useToolInfo - TypeScript typing", () => {
32
27
  });
33
28
  test("should correctly narrow types based on status discriminated union", () => {
34
29
  const result = useToolInfo();
35
- // Test type narrowing for idle
36
- if (result.isIdle) {
37
- expectTypeOf(result.status);
38
- expectTypeOf(result.isIdle);
39
- expectTypeOf(result.isPending);
40
- expectTypeOf(result.isSuccess);
41
- expectTypeOf(result.input);
42
- expectTypeOf(result.output);
43
- expectTypeOf(result.responseMetadata);
44
- }
45
30
  // Test type narrowing for pending
46
31
  if (result.isPending) {
47
32
  expectTypeOf(result.status);
48
- expectTypeOf(result.isIdle);
49
33
  expectTypeOf(result.isPending);
50
34
  expectTypeOf(result.isSuccess);
35
+ expectTypeOf(result.input);
51
36
  expectTypeOf(result.output);
52
37
  expectTypeOf(result.responseMetadata);
53
38
  }
54
39
  if (result.isSuccess) {
55
40
  expectTypeOf(result.status);
56
- expectTypeOf(result.isIdle);
57
- expectTypeOf(result.isPending);
58
- expectTypeOf(result.isSuccess);
59
- expectTypeOf(result.output);
60
- expectTypeOf(result.responseMetadata);
61
- }
62
- if (result.status === "idle") {
63
- expectTypeOf(result.isIdle);
64
41
  expectTypeOf(result.isPending);
65
42
  expectTypeOf(result.isSuccess);
66
43
  expectTypeOf(result.input);
@@ -69,7 +46,6 @@ test("useToolInfo - TypeScript typing", () => {
69
46
  }
70
47
  if (result.status === "pending") {
71
48
  expectTypeOf(result.input);
72
- expectTypeOf(result.isIdle);
73
49
  expectTypeOf(result.isPending);
74
50
  expectTypeOf(result.isSuccess);
75
51
  expectTypeOf(result.output);
@@ -77,7 +53,6 @@ test("useToolInfo - TypeScript typing", () => {
77
53
  }
78
54
  if (result.status === "success") {
79
55
  expectTypeOf(result.input);
80
- expectTypeOf(result.isIdle);
81
56
  expectTypeOf(result.isPending);
82
57
  expectTypeOf(result.isSuccess);
83
58
  expectTypeOf(result.output);
@@ -86,22 +61,24 @@ test("useToolInfo - TypeScript typing", () => {
86
61
  });
87
62
  test("should handle partial ToolSignature with only input specified", () => {
88
63
  const result = useToolInfo();
89
- // Input can be TestInput or undefined (when idle)
90
- if (result.status === "pending" || result.status === "success") {
64
+ // Input is optional in both states — undefined while args haven't arrived
65
+ // (pending) and for no-input tools (success).
66
+ if (result.status === "pending") {
91
67
  expectTypeOf(result.input);
92
68
  }
93
69
  if (result.status === "success") {
70
+ expectTypeOf(result.input);
94
71
  expectTypeOf(result.output);
95
72
  expectTypeOf(result.responseMetadata);
96
73
  }
97
74
  });
98
75
  test("should handle ToolSignature with only output specified", () => {
99
76
  const result = useToolInfo();
100
- // Input can be Record<string, unknown> or undefined (when idle)
101
- if (result.status === "pending" || result.status === "success") {
77
+ if (result.status === "pending") {
102
78
  expectTypeOf(result.input);
103
79
  }
104
80
  if (result.status === "success") {
81
+ expectTypeOf(result.input);
105
82
  expectTypeOf(result.output);
106
83
  }
107
84
  });
@@ -1 +1 @@
1
- {"version":3,"file":"use-tool-info.test-d.js","sourceRoot":"","sources":["../../../src/web/hooks/use-tool-info.test-d.ts"],"names":[],"mappings":"AAA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CAAC;QAEL,kDAAkD;QAClD,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAC/D,YAAY,CAAY,MAAM,CAAC,KAAK,CAAC,CAAC;QACxC,CAAC;QAED,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAChC,YAAY,CAA0B,MAAM,CAAC,MAAM,CAAC,CAAC;YACrD,YAAY,CAA0B,MAAM,CAAC,gBAAgB,CAAC,CAAC;QACjE,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,wDAAwD,EAAE,GAAG,EAAE;QAGlE,MAAM,MAAM,GAAG,WAAW,EAEtB,CAAC;QAEL,gEAAgE;QAChE,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAC/D,YAAY,CAA0B,MAAM,CAAC,KAAK,CAAC,CAAC;QACtD,CAAC;QAED,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAChC,YAAY,CAAa,MAAM,CAAC,MAAM,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expectTypeOf, test } from \"vitest\";\nimport { useToolInfo } from \"./use-tool-info.js\";\n\ntest(\"useToolInfo - TypeScript typing\", () => {\n test(\"should have correct types when no generic parameter is provided\", () => {\n const result = useToolInfo();\n\n expectTypeOf<\"idle\" | \"pending\" | \"success\">(result.status);\n expectTypeOf<boolean>(result.isPending);\n expectTypeOf<boolean>(result.isSuccess);\n expectTypeOf<boolean>(result.isIdle);\n expectTypeOf<Record<string, unknown> | undefined>(result.input);\n });\n\n test(\"should correctly type input, output, and responseMetadata with explicit ToolSignature\", () => {\n type TestInput = { name: string; args: { name: string } };\n type TestOutput = { name: string; color: string };\n type TestMetadata = { id: number };\n\n const result = useToolInfo<{\n input: TestInput;\n output: TestOutput;\n responseMetadata: TestMetadata;\n }>();\n\n // When idle, input should be undefined\n if (result.status === \"idle\") {\n expectTypeOf<undefined>(result.input);\n expectTypeOf<undefined>(result.output);\n expectTypeOf<undefined>(result.responseMetadata);\n }\n\n // When pending, output and responseMetadata should be undefined\n if (result.status === \"pending\") {\n expectTypeOf<TestInput>(result.input);\n expectTypeOf<undefined>(result.output);\n expectTypeOf<undefined>(result.responseMetadata);\n }\n\n // When success, output and responseMetadata should be defined\n if (result.status === \"success\") {\n expectTypeOf<TestInput>(result.input);\n expectTypeOf<TestOutput>(result.output);\n expectTypeOf<TestMetadata>(result.responseMetadata);\n }\n });\n\n test(\"should correctly narrow types based on status discriminated union\", () => {\n type TestInput = { query: string };\n type TestOutput = { result: string };\n type TestMetadata = { timestamp: number };\n\n const result = useToolInfo<{\n input: TestInput;\n output: TestOutput;\n responseMetadata: TestMetadata;\n }>();\n\n // Test type narrowing for idle\n if (result.isIdle) {\n expectTypeOf<\"idle\">(result.status);\n expectTypeOf<true>(result.isIdle);\n expectTypeOf<false>(result.isPending);\n expectTypeOf<false>(result.isSuccess);\n expectTypeOf<undefined>(result.input);\n expectTypeOf<undefined>(result.output);\n expectTypeOf<undefined>(result.responseMetadata);\n }\n\n // Test type narrowing for pending\n if (result.isPending) {\n expectTypeOf<\"pending\">(result.status);\n expectTypeOf<false>(result.isIdle);\n expectTypeOf<true>(result.isPending);\n expectTypeOf<false>(result.isSuccess);\n expectTypeOf<undefined>(result.output);\n expectTypeOf<undefined>(result.responseMetadata);\n }\n\n if (result.isSuccess) {\n expectTypeOf<\"success\">(result.status);\n expectTypeOf<false>(result.isIdle);\n expectTypeOf<false>(result.isPending);\n expectTypeOf<true>(result.isSuccess);\n expectTypeOf<TestOutput>(result.output);\n expectTypeOf<TestMetadata>(result.responseMetadata);\n }\n\n if (result.status === \"idle\") {\n expectTypeOf<true>(result.isIdle);\n expectTypeOf<false>(result.isPending);\n expectTypeOf<false>(result.isSuccess);\n expectTypeOf<undefined>(result.input);\n expectTypeOf<undefined>(result.output);\n expectTypeOf<undefined>(result.responseMetadata);\n }\n\n if (result.status === \"pending\") {\n expectTypeOf<TestInput>(result.input);\n expectTypeOf<false>(result.isIdle);\n expectTypeOf<true>(result.isPending);\n expectTypeOf<false>(result.isSuccess);\n expectTypeOf<undefined>(result.output);\n expectTypeOf<undefined>(result.responseMetadata);\n }\n\n if (result.status === \"success\") {\n expectTypeOf<TestInput>(result.input);\n expectTypeOf<false>(result.isIdle);\n expectTypeOf<false>(result.isPending);\n expectTypeOf<true>(result.isSuccess);\n expectTypeOf<TestOutput>(result.output);\n expectTypeOf<TestMetadata>(result.responseMetadata);\n }\n });\n\n test(\"should handle partial ToolSignature with only input specified\", () => {\n type TestInput = { id: number };\n\n const result = useToolInfo<{\n input: TestInput;\n }>();\n\n // Input can be TestInput or undefined (when idle)\n if (result.status === \"pending\" || result.status === \"success\") {\n expectTypeOf<TestInput>(result.input);\n }\n\n if (result.status === \"success\") {\n expectTypeOf<Record<string, unknown>>(result.output);\n expectTypeOf<Record<string, unknown>>(result.responseMetadata);\n }\n });\n\n test(\"should handle ToolSignature with only output specified\", () => {\n type TestOutput = { data: string[] };\n\n const result = useToolInfo<{\n output: TestOutput;\n }>();\n\n // Input can be Record<string, unknown> or undefined (when idle)\n if (result.status === \"pending\" || result.status === \"success\") {\n expectTypeOf<Record<string, unknown>>(result.input);\n }\n\n if (result.status === \"success\") {\n expectTypeOf<TestOutput>(result.output);\n }\n });\n});\n"]}
1
+ {"version":3,"file":"use-tool-info.test-d.js","sourceRoot":"","sources":["../../../src/web/hooks/use-tool-info.test-d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,IAAI,CAAC,iCAAiC,EAAE,GAAG,EAAE;IAC3C,IAAI,CAAC,iEAAiE,EAAE,GAAG,EAAE;QAC3E,MAAM,M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C,YAAY,CAAwB,MAAM,CAAC,KAAK,CAAC,CAAC;QACpD,CAAC;QAED,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAChC,YAAY,CAAwB,MAAM,CAAC,KAAK,CAAC,CAAC;YAClD,YAAY,CAA0B,MAAM,CAAC,MAAM,CAAC,CAAC;YACrD,YAAY,CAA0B,MAAM,CAAC,gBAAgB,CAAC,CAAC;QACjE,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,wDAAwD,EAAE,GAAG,EAAE;QAGlE,MAAM,MAAM,GAAG,WAAW,EAEtB,CAAC;QAEL,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAChC,YAAY,CAAsC,MAAM,CAAC,KAAK,CAAC,CAAC;QAClE,CAAC;QAED,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAChC,YAAY,CAAsC,MAAM,CAAC,KAAK,CAAC,CAAC;YAChE,YAAY,CAAa,MAAM,CAAC,MAAM,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expectTypeOf, test } from \"vitest\";\nimport { useToolInfo } from \"./use-tool-info.js\";\n\ntest(\"useToolInfo - TypeScript typing\", () => {\n test(\"should have correct types when no generic parameter is provided\", () => {\n const result = useToolInfo();\n\n expectTypeOf<\"pending\" | \"success\">(result.status);\n expectTypeOf<boolean>(result.isPending);\n expectTypeOf<boolean>(result.isSuccess);\n expectTypeOf<Record<string, unknown> | undefined>(result.input);\n });\n\n test(\"should correctly type input, output, and responseMetadata with explicit ToolSignature\", () => {\n type TestInput = { name: string; args: { name: string } };\n type TestOutput = { name: string; color: string };\n type TestMetadata = { id: number };\n\n const result = useToolInfo<{\n input: TestInput;\n output: TestOutput;\n responseMetadata: TestMetadata;\n }>();\n\n // When pending, input may be undefined (host hasn't delivered args yet,\n // or the tool has no input schema)\n if (result.status === \"pending\") {\n expectTypeOf<TestInput | undefined>(result.input);\n expectTypeOf<undefined>(result.output);\n expectTypeOf<undefined>(result.responseMetadata);\n }\n\n // When success, output and responseMetadata are defined; input may still\n // be undefined if the host hasn't surfaced the tool arguments\n if (result.status === \"success\") {\n expectTypeOf<TestInput | undefined>(result.input);\n expectTypeOf<TestOutput>(result.output);\n expectTypeOf<TestMetadata>(result.responseMetadata);\n }\n });\n\n test(\"should correctly narrow types based on status discriminated union\", () => {\n type TestInput = { query: string };\n type TestOutput = { result: string };\n type TestMetadata = { timestamp: number };\n\n const result = useToolInfo<{\n input: TestInput;\n output: TestOutput;\n responseMetadata: TestMetadata;\n }>();\n\n // Test type narrowing for pending\n if (result.isPending) {\n expectTypeOf<\"pending\">(result.status);\n expectTypeOf<true>(result.isPending);\n expectTypeOf<false>(result.isSuccess);\n expectTypeOf<TestInput | undefined>(result.input);\n expectTypeOf<undefined>(result.output);\n expectTypeOf<undefined>(result.responseMetadata);\n }\n\n if (result.isSuccess) {\n expectTypeOf<\"success\">(result.status);\n expectTypeOf<false>(result.isPending);\n expectTypeOf<true>(result.isSuccess);\n expectTypeOf<TestInput | undefined>(result.input);\n expectTypeOf<TestOutput>(result.output);\n expectTypeOf<TestMetadata>(result.responseMetadata);\n }\n\n if (result.status === \"pending\") {\n expectTypeOf<TestInput | undefined>(result.input);\n expectTypeOf<true>(result.isPending);\n expectTypeOf<false>(result.isSuccess);\n expectTypeOf<undefined>(result.output);\n expectTypeOf<undefined>(result.responseMetadata);\n }\n\n if (result.status === \"success\") {\n expectTypeOf<TestInput | undefined>(result.input);\n expectTypeOf<false>(result.isPending);\n expectTypeOf<true>(result.isSuccess);\n expectTypeOf<TestOutput>(result.output);\n expectTypeOf<TestMetadata>(result.responseMetadata);\n }\n });\n\n test(\"should handle partial ToolSignature with only input specified\", () => {\n type TestInput = { id: number };\n\n const result = useToolInfo<{\n input: TestInput;\n }>();\n\n // Input is optional in both states — undefined while args haven't arrived\n // (pending) and for no-input tools (success).\n if (result.status === \"pending\") {\n expectTypeOf<TestInput | undefined>(result.input);\n }\n\n if (result.status === \"success\") {\n expectTypeOf<TestInput | undefined>(result.input);\n expectTypeOf<Record<string, unknown>>(result.output);\n expectTypeOf<Record<string, unknown>>(result.responseMetadata);\n }\n });\n\n test(\"should handle ToolSignature with only output specified\", () => {\n type TestOutput = { data: string[] };\n\n const result = useToolInfo<{\n output: TestOutput;\n }>();\n\n if (result.status === \"pending\") {\n expectTypeOf<Record<string, unknown> | undefined>(result.input);\n }\n\n if (result.status === \"success\") {\n expectTypeOf<Record<string, unknown> | undefined>(result.input);\n expectTypeOf<TestOutput>(result.output);\n }\n });\n});\n"]}