skybridge 0.0.0-dev.d8b52a9 → 0.0.0-dev.d8ce026

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 (366) hide show
  1. package/LICENSE +21 -674
  2. package/README.md +90 -264
  3. package/bin/run.js +5 -0
  4. package/dist/cli/detect-port.d.ts +18 -0
  5. package/dist/cli/detect-port.js +61 -0
  6. package/dist/cli/detect-port.js.map +1 -0
  7. package/dist/cli/header.d.ts +4 -0
  8. package/dist/cli/header.js +6 -0
  9. package/dist/cli/header.js.map +1 -0
  10. package/dist/cli/run-command.d.ts +2 -0
  11. package/dist/cli/run-command.js +43 -0
  12. package/dist/cli/run-command.js.map +1 -0
  13. package/dist/cli/telemetry.d.ts +7 -0
  14. package/dist/cli/telemetry.js +123 -0
  15. package/dist/cli/telemetry.js.map +1 -0
  16. package/dist/cli/types.d.ts +5 -0
  17. package/dist/cli/types.js +2 -0
  18. package/dist/cli/types.js.map +1 -0
  19. package/dist/cli/use-execute-steps.d.ts +11 -0
  20. package/dist/cli/use-execute-steps.js +36 -0
  21. package/dist/cli/use-execute-steps.js.map +1 -0
  22. package/dist/cli/use-nodemon.d.ts +2 -0
  23. package/dist/cli/use-nodemon.js +80 -0
  24. package/dist/cli/use-nodemon.js.map +1 -0
  25. package/dist/cli/use-tunnel.d.ts +8 -0
  26. package/dist/cli/use-tunnel.js +101 -0
  27. package/dist/cli/use-tunnel.js.map +1 -0
  28. package/dist/cli/use-typescript-check.d.ts +8 -0
  29. package/dist/cli/use-typescript-check.js +59 -0
  30. package/dist/cli/use-typescript-check.js.map +1 -0
  31. package/dist/commands/build.d.ts +9 -0
  32. package/dist/commands/build.js +46 -0
  33. package/dist/commands/build.js.map +1 -0
  34. package/dist/commands/dev.d.ts +10 -0
  35. package/dist/commands/dev.js +44 -0
  36. package/dist/commands/dev.js.map +1 -0
  37. package/dist/commands/start.d.ts +9 -0
  38. package/dist/commands/start.js +52 -0
  39. package/dist/commands/start.js.map +1 -0
  40. package/dist/commands/telemetry/disable.d.ts +5 -0
  41. package/dist/commands/telemetry/disable.js +14 -0
  42. package/dist/commands/telemetry/disable.js.map +1 -0
  43. package/dist/commands/telemetry/enable.d.ts +5 -0
  44. package/dist/commands/telemetry/enable.js +14 -0
  45. package/dist/commands/telemetry/enable.js.map +1 -0
  46. package/dist/commands/telemetry/status.d.ts +5 -0
  47. package/dist/commands/telemetry/status.js +14 -0
  48. package/dist/commands/telemetry/status.js.map +1 -0
  49. package/dist/server/asset-base-url-transform-plugin.d.ts +11 -0
  50. package/dist/server/asset-base-url-transform-plugin.js +34 -0
  51. package/dist/server/asset-base-url-transform-plugin.js.map +1 -0
  52. package/dist/server/asset-base-url-transform-plugin.test.js +56 -0
  53. package/dist/server/asset-base-url-transform-plugin.test.js.map +1 -0
  54. package/dist/server/express.d.ts +15 -0
  55. package/dist/server/express.js +77 -0
  56. package/dist/server/express.js.map +1 -0
  57. package/dist/server/express.test.js +252 -0
  58. package/dist/server/express.test.js.map +1 -0
  59. package/dist/server/index.d.ts +5 -0
  60. package/dist/server/index.js.map +1 -0
  61. package/dist/server/inferUtilityTypes.d.ts +64 -0
  62. package/dist/server/inferUtilityTypes.js.map +1 -0
  63. package/dist/server/middleware.d.ts +124 -0
  64. package/dist/server/middleware.js +93 -0
  65. package/dist/server/middleware.js.map +1 -0
  66. package/dist/server/middleware.test-d.js +75 -0
  67. package/dist/server/middleware.test-d.js.map +1 -0
  68. package/dist/server/middleware.test.js +490 -0
  69. package/dist/server/middleware.test.js.map +1 -0
  70. package/dist/server/server.d.ts +150 -0
  71. package/dist/server/server.js +288 -0
  72. package/dist/server/server.js.map +1 -0
  73. package/dist/{src/server → server}/templateHelper.d.ts +3 -0
  74. package/dist/{src/server → server}/templateHelper.js +5 -4
  75. package/dist/server/templateHelper.js.map +1 -0
  76. package/dist/server/templates/development.hbs +12 -0
  77. package/dist/{src/server → server}/templates/production.hbs +1 -1
  78. package/dist/{src/server → server}/widgetsDevServer.d.ts +3 -2
  79. package/dist/server/widgetsDevServer.js +57 -0
  80. package/dist/server/widgetsDevServer.js.map +1 -0
  81. package/dist/test/utils.d.ts +135 -0
  82. package/dist/test/utils.js +242 -0
  83. package/dist/test/utils.js.map +1 -0
  84. package/dist/test/widget.test.js +263 -0
  85. package/dist/test/widget.test.js.map +1 -0
  86. package/dist/web/bridges/apps-sdk/adaptor.d.ts +22 -0
  87. package/dist/web/bridges/apps-sdk/adaptor.js +75 -0
  88. package/dist/web/bridges/apps-sdk/adaptor.js.map +1 -0
  89. package/dist/web/bridges/apps-sdk/bridge.d.ts +10 -0
  90. package/dist/web/bridges/apps-sdk/bridge.js +46 -0
  91. package/dist/web/bridges/apps-sdk/bridge.js.map +1 -0
  92. package/dist/web/bridges/apps-sdk/index.d.ts +5 -0
  93. package/dist/web/bridges/apps-sdk/index.js +5 -0
  94. package/dist/web/bridges/apps-sdk/index.js.map +1 -0
  95. package/dist/{src/web → web/bridges/apps-sdk}/types.d.ts +37 -35
  96. package/dist/web/bridges/apps-sdk/types.js.map +1 -0
  97. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.d.ts +2 -0
  98. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js +7 -0
  99. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js.map +1 -0
  100. package/dist/web/bridges/get-adaptor.d.ts +2 -0
  101. package/dist/web/bridges/get-adaptor.js +8 -0
  102. package/dist/web/bridges/get-adaptor.js.map +1 -0
  103. package/dist/web/bridges/index.d.ts +5 -0
  104. package/dist/web/bridges/index.js +6 -0
  105. package/dist/web/bridges/index.js.map +1 -0
  106. package/dist/web/bridges/mcp-app/adaptor.d.ts +38 -0
  107. package/dist/web/bridges/mcp-app/adaptor.js +184 -0
  108. package/dist/web/bridges/mcp-app/adaptor.js.map +1 -0
  109. package/dist/web/bridges/mcp-app/bridge.d.ts +26 -0
  110. package/dist/web/bridges/mcp-app/bridge.js +102 -0
  111. package/dist/web/bridges/mcp-app/bridge.js.map +1 -0
  112. package/dist/web/bridges/mcp-app/index.d.ts +4 -0
  113. package/dist/web/bridges/mcp-app/index.js +4 -0
  114. package/dist/web/bridges/mcp-app/index.js.map +1 -0
  115. package/dist/web/bridges/mcp-app/types.d.ts +8 -0
  116. package/dist/web/bridges/mcp-app/types.js +2 -0
  117. package/dist/web/bridges/mcp-app/types.js.map +1 -0
  118. package/dist/web/bridges/mcp-app/use-mcp-app-context.d.ts +7 -0
  119. package/dist/web/bridges/mcp-app/use-mcp-app-context.js +7 -0
  120. package/dist/web/bridges/mcp-app/use-mcp-app-context.js.map +1 -0
  121. package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js +26 -0
  122. package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js.map +1 -0
  123. package/dist/web/bridges/types.d.ts +103 -0
  124. package/dist/web/bridges/types.js +2 -0
  125. package/dist/web/bridges/types.js.map +1 -0
  126. package/dist/web/bridges/use-host-context.d.ts +2 -0
  127. package/dist/web/bridges/use-host-context.js +8 -0
  128. package/dist/web/bridges/use-host-context.js.map +1 -0
  129. package/dist/web/components/modal-provider.d.ts +4 -0
  130. package/dist/web/components/modal-provider.js +45 -0
  131. package/dist/web/components/modal-provider.js.map +1 -0
  132. package/dist/web/create-store.d.ts +3 -0
  133. package/dist/web/create-store.js +24 -0
  134. package/dist/web/create-store.js.map +1 -0
  135. package/dist/web/create-store.test.js +131 -0
  136. package/dist/web/create-store.test.js.map +1 -0
  137. package/dist/web/data-llm.d.ts +14 -0
  138. package/dist/web/data-llm.js +72 -0
  139. package/dist/web/data-llm.js.map +1 -0
  140. package/dist/web/data-llm.test.js +142 -0
  141. package/dist/web/data-llm.test.js.map +1 -0
  142. package/dist/{src/web/typed-hooks.d.ts → web/generate-helpers.d.ts} +28 -19
  143. package/dist/{src/web/typed-hooks.js → web/generate-helpers.js} +15 -15
  144. package/dist/web/generate-helpers.js.map +1 -0
  145. package/dist/web/generate-helpers.test-d.js +209 -0
  146. package/dist/web/generate-helpers.test-d.js.map +1 -0
  147. package/dist/web/generate-helpers.test.js +17 -0
  148. package/dist/web/generate-helpers.test.js.map +1 -0
  149. package/dist/web/helpers/state.d.ts +7 -0
  150. package/dist/web/helpers/state.js +45 -0
  151. package/dist/web/helpers/state.js.map +1 -0
  152. package/dist/web/helpers/state.test.js +53 -0
  153. package/dist/web/helpers/state.test.js.map +1 -0
  154. package/dist/web/hooks/index.d.ts +11 -0
  155. package/dist/{src/web/hooks/index.d.ts → web/hooks/index.js} +5 -7
  156. package/dist/web/hooks/index.js.map +1 -0
  157. package/dist/web/hooks/test/utils.d.ts +16 -0
  158. package/dist/web/hooks/test/utils.js +64 -0
  159. package/dist/web/hooks/test/utils.js.map +1 -0
  160. package/dist/web/hooks/use-call-tool.d.ts +101 -0
  161. package/dist/{src/web → web}/hooks/use-call-tool.js +19 -19
  162. package/dist/web/hooks/use-call-tool.js.map +1 -0
  163. package/dist/web/hooks/use-call-tool.test-d.js +104 -0
  164. package/dist/web/hooks/use-call-tool.test-d.js.map +1 -0
  165. package/dist/{src/web → web}/hooks/use-call-tool.test.js +40 -13
  166. package/dist/web/hooks/use-call-tool.test.js.map +1 -0
  167. package/dist/web/hooks/use-display-mode.d.ts +4 -0
  168. package/dist/web/hooks/use-display-mode.js +9 -0
  169. package/dist/web/hooks/use-display-mode.js.map +1 -0
  170. package/dist/web/hooks/use-display-mode.test-d.js +8 -0
  171. package/dist/web/hooks/use-display-mode.test-d.js.map +1 -0
  172. package/dist/web/hooks/use-display-mode.test.d.ts +1 -0
  173. package/dist/{src/web → web}/hooks/use-display-mode.test.js +3 -2
  174. package/dist/web/hooks/use-display-mode.test.js.map +1 -0
  175. package/dist/web/hooks/use-files.d.ts +6 -0
  176. package/dist/web/hooks/use-files.js +9 -0
  177. package/dist/web/hooks/use-files.js.map +1 -0
  178. package/dist/web/hooks/use-files.test.d.ts +1 -0
  179. package/dist/{src/web → web}/hooks/use-files.test.js +11 -6
  180. package/dist/web/hooks/use-files.test.js.map +1 -0
  181. package/dist/web/hooks/use-layout.d.ts +22 -0
  182. package/dist/web/hooks/use-layout.js +23 -0
  183. package/dist/web/hooks/use-layout.js.map +1 -0
  184. package/dist/web/hooks/use-layout.test.d.ts +1 -0
  185. package/dist/web/hooks/use-layout.test.js +96 -0
  186. package/dist/web/hooks/use-layout.test.js.map +1 -0
  187. package/dist/web/hooks/use-open-external.d.ts +3 -0
  188. package/dist/web/hooks/use-open-external.js +8 -0
  189. package/dist/web/hooks/use-open-external.js.map +1 -0
  190. package/dist/web/hooks/use-open-external.test.d.ts +1 -0
  191. package/dist/web/hooks/use-open-external.test.js +65 -0
  192. package/dist/web/hooks/use-open-external.test.js.map +1 -0
  193. package/dist/web/hooks/use-request-modal.d.ts +9 -0
  194. package/dist/web/hooks/use-request-modal.js +16 -0
  195. package/dist/web/hooks/use-request-modal.js.map +1 -0
  196. package/dist/web/hooks/use-request-modal.test.d.ts +1 -0
  197. package/dist/web/hooks/use-request-modal.test.js +61 -0
  198. package/dist/web/hooks/use-request-modal.test.js.map +1 -0
  199. package/dist/web/hooks/use-send-follow-up-message.js +8 -0
  200. package/dist/web/hooks/use-send-follow-up-message.js.map +1 -0
  201. package/dist/web/hooks/use-set-open-in-app-url.d.ts +1 -0
  202. package/dist/web/hooks/use-set-open-in-app-url.js +8 -0
  203. package/dist/web/hooks/use-set-open-in-app-url.js.map +1 -0
  204. package/dist/web/hooks/use-set-open-in-app-url.test.d.ts +1 -0
  205. package/dist/web/hooks/use-set-open-in-app-url.test.js +43 -0
  206. package/dist/web/hooks/use-set-open-in-app-url.test.js.map +1 -0
  207. package/dist/{src/web → web}/hooks/use-tool-info.d.ts +13 -2
  208. package/dist/web/hooks/use-tool-info.js +26 -0
  209. package/dist/web/hooks/use-tool-info.js.map +1 -0
  210. package/dist/web/hooks/use-tool-info.test-d.d.ts +1 -0
  211. package/dist/{src/web → web}/hooks/use-tool-info.test-d.js +40 -5
  212. package/dist/web/hooks/use-tool-info.test-d.js.map +1 -0
  213. package/dist/web/hooks/use-tool-info.test.d.ts +1 -0
  214. package/dist/web/hooks/use-tool-info.test.js +130 -0
  215. package/dist/web/hooks/use-tool-info.test.js.map +1 -0
  216. package/dist/web/hooks/use-user.d.ts +18 -0
  217. package/dist/web/hooks/use-user.js +35 -0
  218. package/dist/web/hooks/use-user.js.map +1 -0
  219. package/dist/web/hooks/use-user.test.d.ts +1 -0
  220. package/dist/web/hooks/use-user.test.js +122 -0
  221. package/dist/web/hooks/use-user.test.js.map +1 -0
  222. package/dist/web/hooks/use-widget-state.js +32 -0
  223. package/dist/web/hooks/use-widget-state.js.map +1 -0
  224. package/dist/web/hooks/use-widget-state.test.d.ts +1 -0
  225. package/dist/{src/web → web}/hooks/use-widget-state.test.js +12 -8
  226. package/dist/web/hooks/use-widget-state.test.js.map +1 -0
  227. package/dist/web/index.d.ts +8 -0
  228. package/dist/web/index.js +9 -0
  229. package/dist/web/index.js.map +1 -0
  230. package/dist/{src/web → web}/mount-widget.js +9 -1
  231. package/dist/web/mount-widget.js.map +1 -0
  232. package/dist/web/plugin/data-llm.test.d.ts +1 -0
  233. package/dist/web/plugin/data-llm.test.js +81 -0
  234. package/dist/web/plugin/data-llm.test.js.map +1 -0
  235. package/dist/web/plugin/plugin.js +54 -0
  236. package/dist/web/plugin/plugin.js.map +1 -0
  237. package/dist/web/plugin/transform-data-llm.d.ts +12 -0
  238. package/dist/web/plugin/transform-data-llm.js +96 -0
  239. package/dist/web/plugin/transform-data-llm.js.map +1 -0
  240. package/dist/web/plugin/transform-data-llm.test.d.ts +1 -0
  241. package/dist/web/plugin/transform-data-llm.test.js +81 -0
  242. package/dist/web/plugin/transform-data-llm.test.js.map +1 -0
  243. package/dist/web/plugin/validate-widget.d.ts +5 -0
  244. package/dist/web/plugin/validate-widget.js +27 -0
  245. package/dist/web/plugin/validate-widget.js.map +1 -0
  246. package/dist/web/plugin/validate-widget.test.d.ts +1 -0
  247. package/dist/web/plugin/validate-widget.test.js +42 -0
  248. package/dist/web/plugin/validate-widget.test.js.map +1 -0
  249. package/dist/{src/web → web}/proxy.js +6 -2
  250. package/dist/web/proxy.js.map +1 -0
  251. package/dist/web/types.d.ts +16 -0
  252. package/dist/web/types.js +2 -0
  253. package/dist/web/types.js.map +1 -0
  254. package/package.json +70 -35
  255. package/tsconfig.base.json +31 -0
  256. package/dist/src/server/index.d.ts +0 -4
  257. package/dist/src/server/index.js.map +0 -1
  258. package/dist/src/server/inferUtilityTypes.d.ts +0 -44
  259. package/dist/src/server/inferUtilityTypes.js.map +0 -1
  260. package/dist/src/server/server.d.ts +0 -19
  261. package/dist/src/server/server.js +0 -58
  262. package/dist/src/server/server.js.map +0 -1
  263. package/dist/src/server/templateHelper.js.map +0 -1
  264. package/dist/src/server/templates/development.hbs +0 -12
  265. package/dist/src/server/widgetsDevServer.js +0 -39
  266. package/dist/src/server/widgetsDevServer.js.map +0 -1
  267. package/dist/src/test/utils.d.ts +0 -28
  268. package/dist/src/test/utils.js +0 -43
  269. package/dist/src/test/utils.js.map +0 -1
  270. package/dist/src/test/widget.test.js +0 -90
  271. package/dist/src/test/widget.test.js.map +0 -1
  272. package/dist/src/web/hooks/index.js +0 -15
  273. package/dist/src/web/hooks/index.js.map +0 -1
  274. package/dist/src/web/hooks/use-call-tool.d.ts +0 -62
  275. package/dist/src/web/hooks/use-call-tool.js.map +0 -1
  276. package/dist/src/web/hooks/use-call-tool.test.js.map +0 -1
  277. package/dist/src/web/hooks/use-display-mode.d.ts +0 -4
  278. package/dist/src/web/hooks/use-display-mode.js +0 -7
  279. package/dist/src/web/hooks/use-display-mode.js.map +0 -1
  280. package/dist/src/web/hooks/use-display-mode.test.js.map +0 -1
  281. package/dist/src/web/hooks/use-files.d.ts +0 -10
  282. package/dist/src/web/hooks/use-files.js +0 -7
  283. package/dist/src/web/hooks/use-files.js.map +0 -1
  284. package/dist/src/web/hooks/use-files.test.js.map +0 -1
  285. package/dist/src/web/hooks/use-locale.d.ts +0 -1
  286. package/dist/src/web/hooks/use-locale.js +0 -5
  287. package/dist/src/web/hooks/use-locale.js.map +0 -1
  288. package/dist/src/web/hooks/use-locale.test.js +0 -21
  289. package/dist/src/web/hooks/use-locale.test.js.map +0 -1
  290. package/dist/src/web/hooks/use-open-external.d.ts +0 -1
  291. package/dist/src/web/hooks/use-open-external.js +0 -6
  292. package/dist/src/web/hooks/use-open-external.js.map +0 -1
  293. package/dist/src/web/hooks/use-open-external.test.js +0 -24
  294. package/dist/src/web/hooks/use-open-external.test.js.map +0 -1
  295. package/dist/src/web/hooks/use-openai-global.d.ts +0 -2
  296. package/dist/src/web/hooks/use-openai-global.js +0 -23
  297. package/dist/src/web/hooks/use-openai-global.js.map +0 -1
  298. package/dist/src/web/hooks/use-request-modal.d.ts +0 -6
  299. package/dist/src/web/hooks/use-request-modal.js +0 -9
  300. package/dist/src/web/hooks/use-request-modal.js.map +0 -1
  301. package/dist/src/web/hooks/use-request-modal.test.js +0 -24
  302. package/dist/src/web/hooks/use-request-modal.test.js.map +0 -1
  303. package/dist/src/web/hooks/use-send-follow-up-message.js +0 -11
  304. package/dist/src/web/hooks/use-send-follow-up-message.js.map +0 -1
  305. package/dist/src/web/hooks/use-theme.d.ts +0 -1
  306. package/dist/src/web/hooks/use-theme.js +0 -5
  307. package/dist/src/web/hooks/use-theme.js.map +0 -1
  308. package/dist/src/web/hooks/use-theme.test.js +0 -26
  309. package/dist/src/web/hooks/use-theme.test.js.map +0 -1
  310. package/dist/src/web/hooks/use-tool-info.js +0 -22
  311. package/dist/src/web/hooks/use-tool-info.js.map +0 -1
  312. package/dist/src/web/hooks/use-tool-info.test-d.js.map +0 -1
  313. package/dist/src/web/hooks/use-tool-info.test.js +0 -59
  314. package/dist/src/web/hooks/use-tool-info.test.js.map +0 -1
  315. package/dist/src/web/hooks/use-tool-output.d.ts +0 -4
  316. package/dist/src/web/hooks/use-tool-output.js +0 -9
  317. package/dist/src/web/hooks/use-tool-output.js.map +0 -1
  318. package/dist/src/web/hooks/use-tool-response-metadata.d.ts +0 -4
  319. package/dist/src/web/hooks/use-tool-response-metadata.js +0 -8
  320. package/dist/src/web/hooks/use-tool-response-metadata.js.map +0 -1
  321. package/dist/src/web/hooks/use-user-agent.d.ts +0 -1
  322. package/dist/src/web/hooks/use-user-agent.js +0 -5
  323. package/dist/src/web/hooks/use-user-agent.js.map +0 -1
  324. package/dist/src/web/hooks/use-user-agent.test.js +0 -31
  325. package/dist/src/web/hooks/use-user-agent.test.js.map +0 -1
  326. package/dist/src/web/hooks/use-widget-state.js +0 -30
  327. package/dist/src/web/hooks/use-widget-state.js.map +0 -1
  328. package/dist/src/web/hooks/use-widget-state.test.js.map +0 -1
  329. package/dist/src/web/index.d.ts +0 -5
  330. package/dist/src/web/index.js +0 -6
  331. package/dist/src/web/index.js.map +0 -1
  332. package/dist/src/web/mount-widget.js.map +0 -1
  333. package/dist/src/web/plugin.js +0 -28
  334. package/dist/src/web/plugin.js.map +0 -1
  335. package/dist/src/web/proxy.js.map +0 -1
  336. package/dist/src/web/typed-hooks.js.map +0 -1
  337. package/dist/src/web/typed-hooks.test-d.js +0 -72
  338. package/dist/src/web/typed-hooks.test-d.js.map +0 -1
  339. package/dist/src/web/typed-hooks.test.js +0 -10
  340. package/dist/src/web/typed-hooks.test.js.map +0 -1
  341. package/dist/src/web/types.js.map +0 -1
  342. package/dist/vitest.config.d.ts +0 -2
  343. package/dist/vitest.config.js +0 -8
  344. package/dist/vitest.config.js.map +0 -1
  345. /package/dist/{src/test/widget.test.d.ts → server/asset-base-url-transform-plugin.test.d.ts} +0 -0
  346. /package/dist/{src/web/hooks/use-call-tool.test.d.ts → server/express.test.d.ts} +0 -0
  347. /package/dist/{src/server → server}/index.js +0 -0
  348. /package/dist/{src/server → server}/inferUtilityTypes.js +0 -0
  349. /package/dist/{src/web/hooks/use-display-mode.test.d.ts → server/middleware.test-d.d.ts} +0 -0
  350. /package/dist/{src/web/hooks/use-files.test.d.ts → server/middleware.test.d.ts} +0 -0
  351. /package/dist/{src/web/hooks/use-locale.test.d.ts → test/widget.test.d.ts} +0 -0
  352. /package/dist/{src/web → web/bridges/apps-sdk}/types.js +0 -0
  353. /package/dist/{src/web/hooks/use-open-external.test.d.ts → web/bridges/mcp-app/use-mcp-app-context.test.d.ts} +0 -0
  354. /package/dist/{src/web/hooks/use-request-modal.test.d.ts → web/create-store.test.d.ts} +0 -0
  355. /package/dist/{src/web/hooks/use-theme.test.d.ts → web/data-llm.test.d.ts} +0 -0
  356. /package/dist/{src/web/hooks/use-tool-info.test-d.d.ts → web/generate-helpers.test-d.d.ts} +0 -0
  357. /package/dist/{src/web/hooks/use-tool-info.test.d.ts → web/generate-helpers.test.d.ts} +0 -0
  358. /package/dist/{src/web/hooks/use-user-agent.test.d.ts → web/helpers/state.test.d.ts} +0 -0
  359. /package/dist/{src/web/hooks/use-widget-state.test.d.ts → web/hooks/use-call-tool.test-d.d.ts} +0 -0
  360. /package/dist/{src/web/typed-hooks.test-d.d.ts → web/hooks/use-call-tool.test.d.ts} +0 -0
  361. /package/dist/{src/web/typed-hooks.test.d.ts → web/hooks/use-display-mode.test-d.d.ts} +0 -0
  362. /package/dist/{src/web → web}/hooks/use-send-follow-up-message.d.ts +0 -0
  363. /package/dist/{src/web → web}/hooks/use-widget-state.d.ts +0 -0
  364. /package/dist/{src/web → web}/mount-widget.d.ts +0 -0
  365. /package/dist/{src/web → web/plugin}/plugin.d.ts +0 -0
  366. /package/dist/{src/web → web}/proxy.d.ts +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-llm.js","sourceRoot":"","sources":["../../src/web/data-llm.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,aAAa,EAEb,UAAU,EACV,SAAS,EACT,KAAK,GACN,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAUhD,MAAM,CAAC,MAAM,kBAAkB,GAAG,kBAA2B,CAAC;AAE9D,MAAM,KAAK,GAAG,IAAI,GAAG,EAAuB,CAAC;AAE7C,SAAS,OAAO,C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YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAEtB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,142 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { cleanup, render } from "@testing-library/react";
3
+ import { afterEach, beforeEach, describe, expect, it, vi, } from "vitest";
4
+ import { McpAppAdaptor, McpAppBridge } from "./bridges/mcp-app/index.js";
5
+ import { DataLLM } from "./data-llm.js";
6
+ import { getMcpAppHostPostMessageMock, MockResizeObserver, } from "./hooks/test/utils.js";
7
+ describe("DataLLM", () => {
8
+ afterEach(() => {
9
+ // Clean up React components BEFORE unstubbing globals
10
+ cleanup();
11
+ vi.unstubAllGlobals();
12
+ vi.resetAllMocks();
13
+ });
14
+ describe("apps-sdk mode", () => {
15
+ let OpenaiMock;
16
+ beforeEach(() => {
17
+ OpenaiMock = {
18
+ widgetState: { modelContent: {} },
19
+ setWidgetState: vi.fn(),
20
+ };
21
+ // Use Object.defineProperty to ensure it persists
22
+ Object.defineProperty(globalThis, "openai", {
23
+ value: OpenaiMock,
24
+ writable: true,
25
+ configurable: true,
26
+ });
27
+ // Also set on window for browser-like environment
28
+ if (typeof window !== "undefined") {
29
+ Object.defineProperty(window, "openai", {
30
+ value: OpenaiMock,
31
+ writable: true,
32
+ configurable: true,
33
+ });
34
+ }
35
+ vi.stubGlobal("openai", OpenaiMock);
36
+ vi.stubGlobal("skybridge", { hostType: "apps-sdk" });
37
+ });
38
+ afterEach(() => {
39
+ // Keep the mock available for React cleanup, but reset it
40
+ if (typeof window !== "undefined" && window.openai) {
41
+ window.openai.setWidgetState = vi.fn();
42
+ window.openai.widgetState = { modelContent: {}, privateContent: {} };
43
+ }
44
+ });
45
+ it("should register a node with content and call setWidgetState", () => {
46
+ render(_jsx(DataLLM, { content: "Test content", children: _jsx("div", { children: "Child" }) }));
47
+ expect(OpenaiMock.setWidgetState).toHaveBeenCalled();
48
+ const callArgs = OpenaiMock.setWidgetState.mock.calls[0]?.[0]?.modelContent;
49
+ expect(callArgs).toHaveProperty("__widget_context");
50
+ expect(callArgs?.__widget_context).toContain("- Test content");
51
+ });
52
+ it("should preserve existing widgetState when updating context", () => {
53
+ OpenaiMock.widgetState = {
54
+ modelContent: { existingKey: "existingValue" },
55
+ };
56
+ render(_jsx(DataLLM, { content: "Test content", children: _jsx("div", { children: "Child" }) }));
57
+ const callArgs = OpenaiMock.setWidgetState.mock.calls[0]?.[0]?.modelContent;
58
+ expect(callArgs).toHaveProperty("existingKey", "existingValue");
59
+ expect(callArgs).toHaveProperty("__widget_context");
60
+ });
61
+ it("should handle deeply nested DataLLM components", () => {
62
+ render(_jsxs(DataLLM, { content: "Level 1", children: [_jsx(DataLLM, { content: "Level 2A" }), _jsx(DataLLM, { content: "Level 2B", children: _jsx(DataLLM, { content: "Level 3", children: _jsx("div", { children: "Content" }) }) })] }));
63
+ const callArgs = OpenaiMock.setWidgetState.mock.calls[OpenaiMock.setWidgetState.mock.calls.length - 1]?.[0]?.modelContent;
64
+ const context = callArgs?.__widget_context;
65
+ expect(context).toContain("- Level 1");
66
+ expect(context).toContain(" - Level 2A");
67
+ expect(context).toContain(" - Level 2B");
68
+ expect(context).toContain(" - Level 3");
69
+ });
70
+ it("should update context when content changes", () => {
71
+ const { rerender } = render(_jsx(DataLLM, { content: "Initial content", children: _jsx("div", { children: "Child" }) }));
72
+ const initialCalls = OpenaiMock.setWidgetState.mock.calls.length;
73
+ rerender(_jsx(DataLLM, { content: "Updated content", children: _jsx("div", { children: "Child" }) }));
74
+ expect(OpenaiMock.setWidgetState.mock.calls.length).toBeGreaterThan(initialCalls);
75
+ const lastCallArgs = OpenaiMock.setWidgetState.mock.calls[OpenaiMock.setWidgetState.mock.calls.length - 1]?.[0]?.modelContent;
76
+ expect(lastCallArgs?.__widget_context).toContain("- Updated content");
77
+ });
78
+ it("should remove node and update context when component unmounts", () => {
79
+ const { unmount } = render(_jsx(DataLLM, { content: "Content to remove", children: _jsx("div", { children: "Child" }) }));
80
+ const callsBeforeUnmount = OpenaiMock.setWidgetState.mock.calls.length;
81
+ unmount();
82
+ expect(OpenaiMock.setWidgetState.mock.calls.length).toBeGreaterThan(callsBeforeUnmount);
83
+ const lastCallArgs = OpenaiMock.setWidgetState.mock.calls[OpenaiMock.setWidgetState.mock.calls.length - 1]?.[0]?.modelContent;
84
+ expect(lastCallArgs?.__widget_context).not.toContain("Content to remove");
85
+ });
86
+ });
87
+ describe("mcp-app mode", () => {
88
+ let postMessageMock;
89
+ beforeEach(() => {
90
+ vi.stubGlobal("skybridge", { hostType: "mcp-app" });
91
+ vi.stubGlobal("ResizeObserver", MockResizeObserver);
92
+ postMessageMock = getMcpAppHostPostMessageMock();
93
+ vi.stubGlobal("parent", { postMessage: postMessageMock });
94
+ });
95
+ afterEach(() => {
96
+ cleanup();
97
+ McpAppBridge.resetInstance();
98
+ McpAppAdaptor.resetInstance();
99
+ });
100
+ it("should register a node and update widget state via adaptor", async () => {
101
+ const adaptor = McpAppAdaptor.getInstance();
102
+ render(_jsx(DataLLM, { content: "Test content", children: _jsx("div", { children: "Child" }) }));
103
+ await vi.waitFor(() => {
104
+ const widgetState = adaptor
105
+ .getHostContextStore("widgetState")
106
+ .getSnapshot();
107
+ expect(widgetState?.__widget_context).toContain("- Test content");
108
+ });
109
+ });
110
+ it("should preserve existing widget state when updating context", async () => {
111
+ const adaptor = McpAppAdaptor.getInstance();
112
+ await adaptor.setWidgetState({ existingKey: "existingValue" });
113
+ render(_jsx(DataLLM, { content: "Test content", children: _jsx("div", { children: "Child" }) }));
114
+ await vi.waitFor(() => {
115
+ const widgetState = adaptor
116
+ .getHostContextStore("widgetState")
117
+ .getSnapshot();
118
+ expect(widgetState?.existingKey).toBe("existingValue");
119
+ expect(widgetState?.__widget_context).toContain("- Test content");
120
+ });
121
+ });
122
+ it("should handle multiple DataLLM components sharing state through adaptor", async () => {
123
+ const adaptor = McpAppAdaptor.getInstance();
124
+ render(_jsxs(_Fragment, { children: [_jsx(DataLLM, { content: "First component", children: _jsx("div", { children: "First" }) }), _jsx(DataLLM, { content: "Second component", children: _jsx("div", { children: "Second" }) })] }));
125
+ await vi.waitFor(() => {
126
+ const widgetState = adaptor
127
+ .getHostContextStore("widgetState")
128
+ .getSnapshot();
129
+ const context = widgetState?.__widget_context;
130
+ expect(context).toContain("- First component");
131
+ expect(context).toContain("- Second component");
132
+ });
133
+ });
134
+ it("should call ui/update-model-context when widget state changes", async () => {
135
+ render(_jsx(DataLLM, { content: "Test content", children: _jsx("div", { children: "Child" }) }));
136
+ await vi.waitFor(() => {
137
+ expect(postMessageMock).toHaveBeenCalledWith(expect.objectContaining({ method: "ui/update-model-context" }), "*");
138
+ });
139
+ });
140
+ });
141
+ });
142
+ //# sourceMappingURL=data-llm.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-llm.test.js","sourceRoot":"","sources":["../../src/web/data-llm.test.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EACL,SAAS,EACT,UAAU,EACV,QAAQ,EACR,MAAM,EACN,EAAE,EAEF,EAAE,GACH,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EACL,4BAA4B,EAC5B,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAE/B,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;IACvB,SAAS,CAAC,GAAG,EAAE;QACb,sDAAsD;QACtD,OAAO,EAAE,CAAC;QACV,EAAE,CAAC,gBAAgB,EAAE,CAAC;QACtB,EAAE,CAAC,aAAa,EAAE,CAAC;IACrB,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;QAC7B,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GACR,EACV,KAAC,OAAO,IAAC,OAAO,EAAC,kBAAkB,YACjC,mCAAiB,GACT,IACT,CACJ,CAAC;YAEF,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE;gBACpB,MAAM,WAAW,GAAG,OAAO;qBACxB,mBAAmB,CAAC,aAAa,CAAC;qBAClC,WAAW,EAAE,CAAC;gBACjB,MAAM,OAAO,GAAG,WAAW,EAAE,gBAA0B,CAAC;gBACxD,MAAM,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC;gBAC/C,MAAM,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAAC;YAClD,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,+DAA+D,EAAE,KAAK,IAAI,EAAE;YAC7E,MAAM,CACJ,KAAC,OAAO,IAAC,OAAO,EAAC,cAAc,YAC7B,kCAAgB,GACR,CACX,CAAC;YAEF,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE;gBACpB,MAAM,CAAC,eAAe,CAAC,CAAC,oBAAoB,CAC1C,MAAM,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,yBAAyB,EAAE,CAAC,EAC9D,GAAG,CACJ,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,11 +1,16 @@
1
- import { useCallTool } from "./hooks/use-call-tool.js";
2
- import type { ToolPendingState, ToolSuccessState } from "./hooks/use-tool-info.js";
3
- import type { McpServer, InferWidgets, AnyWidgetRegistry, WidgetInput, WidgetOutput } from "../server/index.js";
4
- import type { CallToolArgs, UnknownObject } from "./types.js";
5
- type TypedCallToolReturn<TInput, TOutput> = ReturnType<typeof useCallTool<TInput & CallToolArgs, {
6
- structuredContent: TOutput & UnknownObject;
7
- }>>;
8
- type TypedToolInfoReturn<TInput extends UnknownObject, TOutput extends UnknownObject, TResponseMetadata extends UnknownObject> = ToolPendingState<TInput> | ToolSuccessState<TInput, TOutput, TResponseMetadata>;
1
+ import type { InferTools, ToolInput, ToolOutput, ToolResponseMetadata } from "../server/index.js";
2
+ import type { CallToolResponse } from "./bridges/types.js";
3
+ import { type CallToolAsyncFn, type CallToolFn, type CallToolState } from "./hooks/use-call-tool.js";
4
+ import { type ToolState } from "./hooks/use-tool-info.js";
5
+ import type { Objectify, Prettify } from "./types.js";
6
+ type TypedCallToolResponse<TOutput> = CallToolResponse & {
7
+ structuredContent: TOutput;
8
+ };
9
+ type TypedCallToolReturn<TInput, TOutput> = Prettify<CallToolState<TypedCallToolResponse<TOutput>> & {
10
+ callTool: CallToolFn<TInput, TypedCallToolResponse<TOutput>>;
11
+ callToolAsync: CallToolAsyncFn<TInput, TypedCallToolResponse<TOutput>>;
12
+ }>;
13
+ type TypedToolInfoReturn<TInput, TOutput, TResponseMetadata> = ToolState<Objectify<TInput>, Objectify<TOutput>, Objectify<TResponseMetadata>>;
9
14
  /**
10
15
  * Creates typed versions of skybridge hooks with full type inference
11
16
  * for tool names, inputs, and outputs.
@@ -13,7 +18,9 @@ type TypedToolInfoReturn<TInput extends UnknownObject, TOutput extends UnknownOb
13
18
  * This is the recommended way to use skybridge hooks in your widgets.
14
19
  * Set this up once in a dedicated file and export the typed hooks for use across your app.
15
20
  *
16
- * @typeParam T - The type of your McpServer instance. Use `typeof server`.
21
+ * @typeParam ServerType - The type of your McpServer instance (use `typeof server`).
22
+ * Must be a server instance created with method chaining.
23
+ * TypeScript will validate that tools can be inferred from this type.
17
24
  *
18
25
  * @example
19
26
  * ```typescript
@@ -31,11 +38,11 @@ type TypedToolInfoReturn<TInput extends UnknownObject, TOutput extends UnknownOb
31
38
  *
32
39
  * @example
33
40
  * ```typescript
34
- * // web/src/skybridge.ts (one-time setup)
41
+ * // web/src/helpers.ts (one-time setup)
35
42
  * import type { AppType } from "../server";
36
- * import { createTypedHooks } from "skybridge/web";
43
+ * import { generateHelpers } from "skybridge/web";
37
44
  *
38
- * export const { useCallTool, useToolInfo } = createTypedHooks<AppType>();
45
+ * export const { useCallTool, useToolInfo } = generateHelpers<AppType>();
39
46
  * ```
40
47
  *
41
48
  * @example
@@ -52,11 +59,11 @@ type TypedToolInfoReturn<TInput extends UnknownObject, TOutput extends UnknownOb
52
59
  * const toolInfo = useToolInfo<"search-voyage">();
53
60
  * // ^ autocomplete for widget names
54
61
  * // toolInfo.input is typed based on widget input schema
55
- * // toolInfo.output is typed based on widget output schema
62
+ * // toolInfo.output.structuredContent is typed based on widget output schema
56
63
  * }
57
64
  * ```
58
65
  */
59
- export declare function createTypedHooks<T extends McpServer<AnyWidgetRegistry>>(): {
66
+ export declare function generateHelpers<ServerType = never>(): {
60
67
  /**
61
68
  * Typed version of `useCallTool` that provides autocomplete for tool names
62
69
  * and type inference for inputs and outputs.
@@ -76,7 +83,7 @@ export declare function createTypedHooks<T extends McpServer<AnyWidgetRegistry>>
76
83
  * }
77
84
  * ```
78
85
  */
79
- useCallTool: <K extends keyof InferWidgets<T> & string>(name: K) => TypedCallToolReturn<InferWidgets<T>[K]["input"], InferWidgets<T>[K]["output"]>;
86
+ useCallTool: <ToolName extends keyof InferTools<ServerType> & string>(name: ToolName) => TypedCallToolReturn<ToolInput<ServerType, ToolName>, ToolOutput<ServerType, ToolName>>;
80
87
  /**
81
88
  * Typed version of `useToolInfo` that provides autocomplete for widget names
82
89
  * and type inference for inputs, outputs, and responseMetadata.
@@ -88,20 +95,22 @@ export declare function createTypedHooks<T extends McpServer<AnyWidgetRegistry>>
88
95
  * ```typescript
89
96
  * const toolInfo = useToolInfo<"search-voyage">();
90
97
  * // toolInfo.input is typed as { destination: string; ... }
91
- * // toolInfo.output is typed as { results: Array<...>; ... } | undefined
98
+ * // toolInfo.output is typed as { results: Array<...>; ... }
99
+ * // toolInfo.responseMetadata is typed based on _meta in callback return
92
100
  * // toolInfo.status narrows correctly: "pending" | "success"
93
101
  *
94
102
  * if (toolInfo.isPending) {
95
- * // TypeScript knows output is undefined here
103
+ * // TypeScript knows output and responseMetadata are undefined here
96
104
  * console.log(toolInfo.input.destination);
97
105
  * }
98
106
  *
99
107
  * if (toolInfo.isSuccess) {
100
- * // TypeScript knows output is defined here
108
+ * // TypeScript knows output and responseMetadata are defined here
101
109
  * console.log(toolInfo.output.results);
110
+ * console.log(toolInfo.responseMetadata);
102
111
  * }
103
112
  * ```
104
113
  */
105
- useToolInfo: <K extends keyof InferWidgets<T> & string>() => TypedToolInfoReturn<WidgetInput<T, K> & UnknownObject, WidgetOutput<T, K> & UnknownObject, UnknownObject>;
114
+ useToolInfo: <ToolName extends keyof InferTools<ServerType> & string>() => TypedToolInfoReturn<ToolInput<ServerType, ToolName>, ToolOutput<ServerType, ToolName>, ToolResponseMetadata<ServerType, ToolName>>;
106
115
  };
107
116
  export {};
@@ -1,4 +1,4 @@
1
- import { useCallTool } from "./hooks/use-call-tool.js";
1
+ import { useCallTool, } from "./hooks/use-call-tool.js";
2
2
  import { useToolInfo } from "./hooks/use-tool-info.js";
3
3
  /**
4
4
  * Creates typed versions of skybridge hooks with full type inference
@@ -7,7 +7,9 @@ import { useToolInfo } from "./hooks/use-tool-info.js";
7
7
  * This is the recommended way to use skybridge hooks in your widgets.
8
8
  * Set this up once in a dedicated file and export the typed hooks for use across your app.
9
9
  *
10
- * @typeParam T - The type of your McpServer instance. Use `typeof server`.
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.
11
13
  *
12
14
  * @example
13
15
  * ```typescript
@@ -25,11 +27,11 @@ import { useToolInfo } from "./hooks/use-tool-info.js";
25
27
  *
26
28
  * @example
27
29
  * ```typescript
28
- * // web/src/skybridge.ts (one-time setup)
30
+ * // web/src/helpers.ts (one-time setup)
29
31
  * import type { AppType } from "../server";
30
- * import { createTypedHooks } from "skybridge/web";
32
+ * import { generateHelpers } from "skybridge/web";
31
33
  *
32
- * export const { useCallTool, useToolInfo } = createTypedHooks<AppType>();
34
+ * export const { useCallTool, useToolInfo } = generateHelpers<AppType>();
33
35
  * ```
34
36
  *
35
37
  * @example
@@ -46,11 +48,11 @@ import { useToolInfo } from "./hooks/use-tool-info.js";
46
48
  * const toolInfo = useToolInfo<"search-voyage">();
47
49
  * // ^ autocomplete for widget names
48
50
  * // toolInfo.input is typed based on widget input schema
49
- * // toolInfo.output is typed based on widget output schema
51
+ * // toolInfo.output.structuredContent is typed based on widget output schema
50
52
  * }
51
53
  * ```
52
54
  */
53
- export function createTypedHooks() {
55
+ export function generateHelpers() {
54
56
  return {
55
57
  /**
56
58
  * Typed version of `useCallTool` that provides autocomplete for tool names
@@ -72,8 +74,6 @@ export function createTypedHooks() {
72
74
  * ```
73
75
  */
74
76
  useCallTool: (name) => {
75
- // Type assertion is safe here because the runtime types are compatible.
76
- // The underlying hook accepts broader types, but we expose narrower, more specific types.
77
77
  return useCallTool(name);
78
78
  },
79
79
  /**
@@ -87,25 +87,25 @@ export function createTypedHooks() {
87
87
  * ```typescript
88
88
  * const toolInfo = useToolInfo<"search-voyage">();
89
89
  * // toolInfo.input is typed as { destination: string; ... }
90
- * // toolInfo.output is typed as { results: Array<...>; ... } | undefined
90
+ * // toolInfo.output is typed as { results: Array<...>; ... }
91
+ * // toolInfo.responseMetadata is typed based on _meta in callback return
91
92
  * // toolInfo.status narrows correctly: "pending" | "success"
92
93
  *
93
94
  * if (toolInfo.isPending) {
94
- * // TypeScript knows output is undefined here
95
+ * // TypeScript knows output and responseMetadata are undefined here
95
96
  * console.log(toolInfo.input.destination);
96
97
  * }
97
98
  *
98
99
  * if (toolInfo.isSuccess) {
99
- * // TypeScript knows output is defined here
100
+ * // TypeScript knows output and responseMetadata are defined here
100
101
  * console.log(toolInfo.output.results);
102
+ * console.log(toolInfo.responseMetadata);
101
103
  * }
102
104
  * ```
103
105
  */
104
106
  useToolInfo: () => {
105
- // Type assertion is safe here because the runtime types are compatible.
106
- // The underlying hook accepts broader types, but we expose narrower, more specific types.
107
107
  return useToolInfo();
108
108
  },
109
109
  };
110
110
  }
111
- //# sourceMappingURL=typed-hooks.js.map
111
+ //# sourceMappingURL=generate-helpers.js.map
@@ -0,0 +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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;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"}
@@ -0,0 +1,209 @@
1
+ import { expectTypeOf, test } from "vitest";
2
+ import { createInterfaceTestServer, createTestServer } from "../test/utils.js";
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)", () => {
7
+ expectTypeOf().toHaveProperty("search-voyage");
8
+ expectTypeOf().toHaveProperty("get-trip-details");
9
+ expectTypeOf().toHaveProperty("no-input-widget");
10
+ expectTypeOf().toHaveProperty("calculate-price");
11
+ expectTypeOf().toHaveProperty("inferred-output-widget");
12
+ expectTypeOf().toHaveProperty("inferred-tool");
13
+ expectTypeOf().toHaveProperty("widget-with-metadata");
14
+ expectTypeOf().toHaveProperty("tool-with-metadata");
15
+ expectTypeOf().toHaveProperty("widget-with-mixed-returns");
16
+ });
17
+ test("ToolNames returns a union of tool name literals (widgets + registerTool)", () => {
18
+ expectTypeOf().toEqualTypeOf();
19
+ });
20
+ test("ToolInput extracts the correct input type from Zod schema", () => {
21
+ expectTypeOf().toEqualTypeOf();
22
+ expectTypeOf().toEqualTypeOf();
23
+ expectTypeOf().toEqualTypeOf();
24
+ });
25
+ test("ToolOutput extracts the correct output type from callback's structuredContent", () => {
26
+ expectTypeOf().toEqualTypeOf();
27
+ expectTypeOf().toEqualTypeOf();
28
+ expectTypeOf().toEqualTypeOf();
29
+ expectTypeOf().toEqualTypeOf();
30
+ });
31
+ test("ToolOutput extracts the correct output type from callback (inferred)", () => {
32
+ expectTypeOf().toEqualTypeOf();
33
+ expectTypeOf().toEqualTypeOf();
34
+ });
35
+ test("generateHelpers provides autocomplete for tool names (widgets + registerTool)", () => {
36
+ const { useCallTool } = generateHelpers();
37
+ useCallTool("search-voyage");
38
+ useCallTool("get-trip-details");
39
+ useCallTool("no-input-widget");
40
+ useCallTool("calculate-price");
41
+ useCallTool("inferred-output-widget");
42
+ useCallTool("inferred-tool");
43
+ useCallTool("widget-with-metadata");
44
+ useCallTool("tool-with-metadata");
45
+ useCallTool("widget-with-mixed-returns");
46
+ // @ts-expect-error - "invalid-name" is not a valid tool name
47
+ useCallTool("invalid-name");
48
+ });
49
+ test("useCallTool returns correctly typed callTool function", () => {
50
+ const { useCallTool } = generateHelpers();
51
+ const { callTool } = useCallTool("search-voyage");
52
+ callTool({ destination: "Spain" });
53
+ callTool({ destination: "France", departureDate: "2024-06-01" });
54
+ callTool({ destination: "Italy", maxPrice: 1000 });
55
+ const { callTool: calculateTool } = useCallTool("calculate-price");
56
+ calculateTool({ tripId: "123", passengers: 2 });
57
+ });
58
+ test("callTool can be called without args for tools with no required inputs", () => {
59
+ const { useCallTool } = generateHelpers();
60
+ const { callTool, callToolAsync } = useCallTool("no-input-widget");
61
+ callTool();
62
+ callTool({});
63
+ callToolAsync();
64
+ callToolAsync({});
65
+ });
66
+ test("callTool requires args for tools with required inputs", () => {
67
+ const { useCallTool } = generateHelpers();
68
+ const { callTool } = useCallTool("search-voyage");
69
+ // @ts-expect-error - "destination" is required
70
+ callTool();
71
+ // @ts-expect-error - "destination" is required
72
+ callTool({});
73
+ // This should work
74
+ callTool({ destination: "Spain" });
75
+ });
76
+ test("callTool supports sideEffects for tools with required inputs", () => {
77
+ const { useCallTool } = generateHelpers();
78
+ const { callTool } = useCallTool("search-voyage");
79
+ callTool({ destination: "Spain" }, {
80
+ onSuccess: (response, args) => {
81
+ expectTypeOf(response.structuredContent.results).toBeArray();
82
+ expectTypeOf(args.destination).toBeString();
83
+ },
84
+ onError: (error, args) => {
85
+ expectTypeOf(error).toBeUnknown();
86
+ expectTypeOf(args.destination).toBeString();
87
+ },
88
+ onSettled: (response, error, args) => {
89
+ if (response) {
90
+ expectTypeOf(response.structuredContent.totalCount).toBeNumber();
91
+ }
92
+ expectTypeOf(error).toBeUnknown();
93
+ expectTypeOf(args.destination).toBeString();
94
+ },
95
+ });
96
+ });
97
+ test("callTool supports sideEffects for tools with no required inputs", () => {
98
+ const { useCallTool } = generateHelpers();
99
+ const { callTool } = useCallTool("no-input-widget");
100
+ callTool({
101
+ onSuccess: (response) => {
102
+ expectTypeOf(response).toHaveProperty("structuredContent");
103
+ },
104
+ });
105
+ callTool({}, {
106
+ onSuccess: (response) => {
107
+ expectTypeOf(response).toHaveProperty("structuredContent");
108
+ },
109
+ });
110
+ });
111
+ test("callToolAsync returns correctly typed promise", () => {
112
+ const { useCallTool } = generateHelpers();
113
+ const { callToolAsync: searchAsync } = useCallTool("search-voyage");
114
+ const searchPromise = searchAsync({ destination: "Spain" });
115
+ expectTypeOf(searchPromise).resolves.toHaveProperty("structuredContent");
116
+ const { callToolAsync: noInputAsync } = useCallTool("no-input-widget");
117
+ const noInputPromise = noInputAsync();
118
+ expectTypeOf(noInputPromise).resolves.toHaveProperty("structuredContent");
119
+ });
120
+ test("useCallTool returns correctly typed data", () => {
121
+ const { useCallTool } = generateHelpers();
122
+ const { data } = useCallTool("search-voyage");
123
+ if (data) {
124
+ expectTypeOf(data.structuredContent).toExtend();
125
+ expectTypeOf(data.structuredContent.results).toBeArray();
126
+ expectTypeOf(data.structuredContent.totalCount).toBeNumber();
127
+ }
128
+ });
129
+ test("useCallTool returns correctly typed data for callback-inferred outputs", () => {
130
+ const { useCallTool } = generateHelpers();
131
+ const { data: widgetData } = useCallTool("inferred-output-widget");
132
+ if (widgetData) {
133
+ expectTypeOf(widgetData.structuredContent).toExtend();
134
+ }
135
+ const { data: toolData } = useCallTool("inferred-tool");
136
+ if (toolData) {
137
+ expectTypeOf(toolData.structuredContent).toExtend();
138
+ }
139
+ });
140
+ test("generateHelpers provides autocomplete for tool names in useToolInfo (widgets + registerTool)", () => {
141
+ const { useToolInfo } = generateHelpers();
142
+ useToolInfo();
143
+ useToolInfo();
144
+ useToolInfo();
145
+ useToolInfo();
146
+ useToolInfo();
147
+ useToolInfo();
148
+ useToolInfo();
149
+ useToolInfo();
150
+ useToolInfo();
151
+ // @ts-expect-error - "invalid-name" is not a valid tool name
152
+ useToolInfo();
153
+ });
154
+ test("useToolInfo infers input and output types", () => {
155
+ const { useToolInfo } = generateHelpers();
156
+ const toolInfo = useToolInfo();
157
+ // Input is only available when not in idle state
158
+ if (!(toolInfo.status === "idle")) {
159
+ expectTypeOf(toolInfo.input).toExtend();
160
+ }
161
+ if (toolInfo.status === "success") {
162
+ expectTypeOf(toolInfo.output).toExtend();
163
+ expectTypeOf(toolInfo.output.results).toBeArray();
164
+ expectTypeOf(toolInfo.output.totalCount).toBeNumber();
165
+ }
166
+ });
167
+ test("ToolResponseMetadata extracts _meta type from callback", () => {
168
+ expectTypeOf().toEqualTypeOf();
169
+ expectTypeOf().toEqualTypeOf();
170
+ expectTypeOf().toBeUnknown();
171
+ });
172
+ test("useToolInfo infers responseMetadata type from generateHelpers", () => {
173
+ const { useToolInfo } = generateHelpers();
174
+ const toolInfo = useToolInfo();
175
+ if (toolInfo.isSuccess) {
176
+ expectTypeOf(toolInfo.responseMetadata.requestId).toBeString();
177
+ expectTypeOf(toolInfo.responseMetadata.timestamp).toBeNumber();
178
+ expectTypeOf(toolInfo.responseMetadata.cached).toBeBoolean();
179
+ }
180
+ });
181
+ test("ToolResponseMetadata extracts _meta from mixed return paths", () => {
182
+ expectTypeOf().toEqualTypeOf();
183
+ });
184
+ test("ToolOutput extracts correct type when using interface declaration", () => {
185
+ expectTypeOf().toHaveProperty("itemName");
186
+ expectTypeOf().toBeString();
187
+ expectTypeOf().toBeNumber();
188
+ });
189
+ test("ToolResponseMetadata extracts correct type when using interface declaration", () => {
190
+ expectTypeOf().toHaveProperty("processedBy");
191
+ expectTypeOf().toBeString();
192
+ expectTypeOf().toBeNumber();
193
+ });
194
+ test("generateHelpers works with interface-typed server", () => {
195
+ const { useCallTool, useToolInfo } = generateHelpers();
196
+ const { data } = useCallTool("interface-widget");
197
+ if (data) {
198
+ expectTypeOf(data.structuredContent.itemName).toBeString();
199
+ expectTypeOf(data.structuredContent.quantity).toBeNumber();
200
+ }
201
+ const toolInfo = useToolInfo();
202
+ if (toolInfo.isSuccess) {
203
+ expectTypeOf(toolInfo.output.itemName).toBeString();
204
+ expectTypeOf(toolInfo.output.quantity).toBeNumber();
205
+ expectTypeOf(toolInfo.responseMetadata.processedBy).toBeString();
206
+ expectTypeOf(toolInfo.responseMetadata.version).toBeNumber();
207
+ }
208
+ });
209
+ //# sourceMappingURL=generate-helpers.test-d.js.map
@@ -0,0 +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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jD,IAAI,IAAI,EAAE,CAAC;QACT,YAAY,CAAC,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,UAAU,EAAE,CAAC;QAC3D,YAAY,CAAC,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,UAAU,EAAE,CAAC;IAC7D,CAAC;IAED,MAAM,QAAQ,GAAG,WAAW,EAAsB,CAAC;IACnD,IAAI,QAAQ,CAAC,SAAS,EAAE,CAAC;QACvB,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,UAAU,EAAE,CAAC;QACpD,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,UAAU,EAAE,CAAC;QACpD,YAAY,CAAC,QAAQ,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC,UAAU,EAAE,CAAC;QACjE,YAAY,CAAC,QAAQ,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,CAAC;IAC/D,CAAC;AACH,CAAC,CAAC,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { createMinimalTestServer } from "../test/utils.js";
3
+ import { generateHelpers } from "./generate-helpers.js";
4
+ const server = createMinimalTestServer();
5
+ describe("generateHelpers", () => {
6
+ it("should return an object with useCallTool hook", () => {
7
+ const hooks = generateHelpers();
8
+ expect(hooks).toHaveProperty("useCallTool");
9
+ expect(typeof hooks.useCallTool).toBe("function");
10
+ });
11
+ it("should return an object with useToolInfo hook", () => {
12
+ const hooks = generateHelpers();
13
+ expect(hooks).toHaveProperty("useToolInfo");
14
+ expect(typeof hooks.useToolInfo).toBe("function");
15
+ });
16
+ });
17
+ //# sourceMappingURL=generate-helpers.test.js.map
@@ -0,0 +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"}
@@ -0,0 +1,7 @@
1
+ import { type SuperJSONResult } from "superjson";
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;
5
+ export declare function serializeState(value: UnknownObject): unknown;
6
+ export declare function deserializeState(value: SuperJSONResult): unknown;
7
+ export declare function getInitialState<State extends UnknownObject>(defaultState?: State | (() => State)): State | null;