mcp-use 2.0.0-beta.2 → 2.0.0-beta.21

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 (1081) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/bin/args.d.ts +10 -0
  3. package/dist/bin/args.d.ts.map +1 -1
  4. package/dist/bin/main.d.ts +8 -0
  5. package/dist/bin/main.d.ts.map +1 -1
  6. package/dist/bin/start.d.ts.map +1 -1
  7. package/dist/bin.js +22 -6
  8. package/dist/bin.js.map +1 -1
  9. package/dist/branding.d.ts +82 -0
  10. package/dist/branding.d.ts.map +1 -0
  11. package/dist/chunk-22Y3WIJP.js +62 -0
  12. package/dist/chunk-22Y3WIJP.js.map +1 -0
  13. package/dist/chunk-EAPJUSK7.js +98 -0
  14. package/dist/chunk-EAPJUSK7.js.map +1 -0
  15. package/dist/chunk-FC2Z2VFO.js +99 -0
  16. package/dist/chunk-FC2Z2VFO.js.map +1 -0
  17. package/dist/{public-route-7IK5D7V7.js → chunk-G62AMJHS.js} +17 -12
  18. package/dist/chunk-G62AMJHS.js.map +1 -0
  19. package/dist/{chunk-UDLRVMML.js → chunk-IGVT7UV6.js} +94 -23
  20. package/dist/chunk-IGVT7UV6.js.map +1 -0
  21. package/dist/chunk-KIZ72TIK.js +38 -0
  22. package/dist/chunk-KIZ72TIK.js.map +1 -0
  23. package/dist/{chunk-Q4PUTBMV.js → chunk-QBAJXPRQ.js} +21 -1
  24. package/dist/chunk-QBAJXPRQ.js.map +1 -0
  25. package/dist/{chunk-SFI2T6TE.js → chunk-QUUANIE4.js} +34 -80
  26. package/dist/chunk-QUUANIE4.js.map +1 -0
  27. package/dist/{chunk-RQRT27Q3.js → chunk-RHITI5QM.js} +190 -16
  28. package/dist/chunk-RHITI5QM.js.map +1 -0
  29. package/dist/chunk-Z326HADF.js +82 -0
  30. package/dist/chunk-Z326HADF.js.map +1 -0
  31. package/dist/chunk-ZJJD33SF.js +741 -0
  32. package/dist/chunk-ZJJD33SF.js.map +1 -0
  33. package/dist/cli/build.d.ts +21 -15
  34. package/dist/cli/build.d.ts.map +1 -1
  35. package/dist/cli/dev.d.ts +4 -0
  36. package/dist/cli/dev.d.ts.map +1 -1
  37. package/dist/cli/entry.d.ts +1 -1
  38. package/dist/cli/entry.d.ts.map +1 -1
  39. package/dist/cli/mcp-env-declaration.d.ts +20 -0
  40. package/dist/cli/mcp-env-declaration.d.ts.map +1 -0
  41. package/dist/cli/next-compat.d.ts +21 -0
  42. package/dist/cli/next-compat.d.ts.map +1 -0
  43. package/dist/cli/next-server-shims.d.ts +52 -0
  44. package/dist/cli/next-server-shims.d.ts.map +1 -0
  45. package/dist/cli/port.d.ts.map +1 -1
  46. package/dist/cli/tunnel.d.ts.map +1 -1
  47. package/dist/cli/views-bindings.d.ts +9 -0
  48. package/dist/cli/views-bindings.d.ts.map +1 -1
  49. package/dist/cli/views-plugin.d.ts.map +1 -1
  50. package/dist/cli/views.d.ts +23 -8
  51. package/dist/cli/views.d.ts.map +1 -1
  52. package/dist/cli/workspace.d.ts +4 -9
  53. package/dist/cli/workspace.d.ts.map +1 -1
  54. package/dist/commands/build.js +171 -34
  55. package/dist/commands/build.js.map +1 -1
  56. package/dist/commands/client.d.ts.map +1 -1
  57. package/dist/commands/client.js +1 -1
  58. package/dist/commands/dev.js +145 -40
  59. package/dist/commands/dev.js.map +1 -1
  60. package/dist/commands/load-client.d.ts +9 -2
  61. package/dist/commands/load-client.d.ts.map +1 -1
  62. package/dist/commands/screenshot.js +1 -1
  63. package/dist/commands/start.js +5 -1
  64. package/dist/commands/start.js.map +1 -1
  65. package/dist/completable.d.ts +9 -0
  66. package/dist/completable.d.ts.map +1 -1
  67. package/dist/config.d.ts +125 -4
  68. package/dist/config.d.ts.map +1 -1
  69. package/dist/fetch-app.d.ts +43 -0
  70. package/dist/fetch-app.d.ts.map +1 -1
  71. package/dist/index.d.ts +20 -5
  72. package/dist/index.d.ts.map +1 -1
  73. package/dist/index.js +1318 -251
  74. package/dist/index.js.map +1 -1
  75. package/dist/inspector-shell.d.ts +19 -6
  76. package/dist/inspector-shell.d.ts.map +1 -1
  77. package/dist/internal/resource-completion.js +7 -0
  78. package/dist/internal/resource-completion.js.map +1 -0
  79. package/dist/landing-handler-WE66NIGB.js +37 -0
  80. package/dist/landing-handler-WE66NIGB.js.map +1 -0
  81. package/dist/landing-handler.d.ts +24 -0
  82. package/dist/landing-handler.d.ts.map +1 -0
  83. package/dist/landing.d.ts +67 -0
  84. package/dist/landing.d.ts.map +1 -0
  85. package/dist/landing.js +7 -0
  86. package/dist/landing.js.map +1 -0
  87. package/dist/mcp-proxy-5YQJJ4RT.js +282 -0
  88. package/dist/mcp-proxy-5YQJJ4RT.js.map +1 -0
  89. package/dist/mcp-proxy.d.ts +153 -0
  90. package/dist/mcp-proxy.d.ts.map +1 -0
  91. package/dist/middleware/cors.d.ts +11 -0
  92. package/dist/middleware/cors.d.ts.map +1 -0
  93. package/dist/middleware/mcp-middleware.d.ts +179 -0
  94. package/dist/middleware/mcp-middleware.d.ts.map +1 -0
  95. package/dist/mount-mcp.d.ts +0 -4
  96. package/dist/mount-mcp.d.ts.map +1 -1
  97. package/dist/next/config.d.ts +39 -0
  98. package/dist/next/config.d.ts.map +1 -0
  99. package/dist/next/handler.d.ts +17 -0
  100. package/dist/next/handler.d.ts.map +1 -0
  101. package/dist/next/index.d.ts +5 -0
  102. package/dist/next/index.d.ts.map +1 -0
  103. package/dist/next/index.js +172 -0
  104. package/dist/next/index.js.map +1 -0
  105. package/dist/next-server-shims.js +108 -0
  106. package/dist/next-server-shims.js.map +1 -0
  107. package/dist/oauth/better-auth.d.ts +29 -0
  108. package/dist/oauth/better-auth.d.ts.map +1 -0
  109. package/dist/oauth/better-auth.js +76 -0
  110. package/dist/oauth/better-auth.js.map +1 -0
  111. package/dist/oauth/index.js +2 -1
  112. package/dist/public-route-RWJVJQTX.js +9 -0
  113. package/dist/public-route-RWJVJQTX.js.map +1 -0
  114. package/dist/react/components/theme-provider.d.ts +3 -0
  115. package/dist/react/components/theme-provider.d.ts.map +1 -1
  116. package/dist/react/hooks/use-files.d.ts +25 -0
  117. package/dist/react/hooks/use-files.d.ts.map +1 -0
  118. package/dist/react/hooks/use-host-context.d.ts +5 -0
  119. package/dist/react/hooks/use-host-context.d.ts.map +1 -1
  120. package/dist/react/index.d.ts +2 -0
  121. package/dist/react/index.d.ts.map +1 -1
  122. package/dist/react/index.js +124 -3
  123. package/dist/react/index.js.map +1 -1
  124. package/dist/react/runtime/view-runtime.d.ts +23 -0
  125. package/dist/react/runtime/view-runtime.d.ts.map +1 -1
  126. package/dist/react/types/file-types.d.ts +16 -0
  127. package/dist/react/types/file-types.d.ts.map +1 -0
  128. package/dist/react/types/register.d.ts +1 -1
  129. package/dist/react/types/register.d.ts.map +1 -1
  130. package/dist/resource-completion.d.ts +12 -0
  131. package/dist/resource-completion.d.ts.map +1 -0
  132. package/dist/resources.d.ts +59 -4
  133. package/dist/resources.d.ts.map +1 -1
  134. package/dist/server.d.ts +120 -7
  135. package/dist/server.d.ts.map +1 -1
  136. package/dist/tools.d.ts +21 -10
  137. package/dist/tools.d.ts.map +1 -1
  138. package/dist/views/constants.d.ts +1 -1
  139. package/dist/views/csp-env.d.ts +37 -0
  140. package/dist/views/csp-env.d.ts.map +1 -0
  141. package/dist/views/document.d.ts +30 -13
  142. package/dist/views/document.d.ts.map +1 -1
  143. package/dist/views/index.d.ts +4 -3
  144. package/dist/views/index.d.ts.map +1 -1
  145. package/dist/views/origin.d.ts +37 -9
  146. package/dist/views/origin.d.ts.map +1 -1
  147. package/dist/views/public-route.d.ts +10 -4
  148. package/dist/views/public-route.d.ts.map +1 -1
  149. package/dist/views/register.d.ts +1 -1
  150. package/dist/views/routes.d.ts +20 -1
  151. package/dist/views/routes.d.ts.map +1 -1
  152. package/dist/views/types.d.ts +23 -14
  153. package/dist/views/types.d.ts.map +1 -1
  154. package/dist/views/wire.d.ts +26 -36
  155. package/dist/views/wire.d.ts.map +1 -1
  156. package/node_modules/@modelcontextprotocol/client/LICENSE +216 -0
  157. package/node_modules/@modelcontextprotocol/client/README.md +26 -0
  158. package/node_modules/@modelcontextprotocol/client/dist/ajvProvider-Asx17_Co.mjs +7069 -0
  159. package/node_modules/@modelcontextprotocol/client/dist/ajvProvider-Asx17_Co.mjs.map +1 -0
  160. package/node_modules/@modelcontextprotocol/client/dist/ajvProvider-B7GnTXYx.d.mts +1054 -0
  161. package/node_modules/@modelcontextprotocol/client/dist/ajvProvider-B7GnTXYx.d.mts.map +1 -0
  162. package/node_modules/@modelcontextprotocol/client/dist/ajvProvider-B_4czhCS.d.cts +1054 -0
  163. package/node_modules/@modelcontextprotocol/client/dist/ajvProvider-B_4czhCS.d.cts.map +1 -0
  164. package/node_modules/@modelcontextprotocol/client/dist/ajvProvider-DNzBrkxq.cjs +7086 -0
  165. package/node_modules/@modelcontextprotocol/client/dist/ajvProvider-DNzBrkxq.cjs.map +1 -0
  166. package/node_modules/@modelcontextprotocol/client/dist/cfWorkerProvider-D9GAttn8.d.cts +59 -0
  167. package/node_modules/@modelcontextprotocol/client/dist/cfWorkerProvider-D9GAttn8.d.cts.map +1 -0
  168. package/node_modules/@modelcontextprotocol/client/dist/cfWorkerProvider-DbU8BxXO.mjs +970 -0
  169. package/node_modules/@modelcontextprotocol/client/dist/cfWorkerProvider-DbU8BxXO.mjs.map +1 -0
  170. package/node_modules/@modelcontextprotocol/client/dist/cfWorkerProvider-Djgwc46-.cjs +976 -0
  171. package/node_modules/@modelcontextprotocol/client/dist/cfWorkerProvider-Djgwc46-.cjs.map +1 -0
  172. package/node_modules/@modelcontextprotocol/client/dist/cfWorkerProvider-Xtj52JOa.d.mts +59 -0
  173. package/node_modules/@modelcontextprotocol/client/dist/cfWorkerProvider-Xtj52JOa.d.mts.map +1 -0
  174. package/node_modules/@modelcontextprotocol/client/dist/chunk-Bnu9O96Y.cjs +60 -0
  175. package/node_modules/@modelcontextprotocol/client/dist/chunk-Br0eD_fh.mjs +42 -0
  176. package/node_modules/@modelcontextprotocol/client/dist/index-ZagFkUbt.d.mts +2675 -0
  177. package/node_modules/@modelcontextprotocol/client/dist/index-ZagFkUbt.d.mts.map +1 -0
  178. package/node_modules/@modelcontextprotocol/client/dist/index-gN3EXmil.d.cts +2678 -0
  179. package/node_modules/@modelcontextprotocol/client/dist/index-gN3EXmil.d.cts.map +1 -0
  180. package/node_modules/@modelcontextprotocol/client/dist/index.cjs +5427 -0
  181. package/node_modules/@modelcontextprotocol/client/dist/index.cjs.map +1 -0
  182. package/node_modules/@modelcontextprotocol/client/dist/index.d.cts +3196 -0
  183. package/node_modules/@modelcontextprotocol/client/dist/index.d.cts.map +1 -0
  184. package/node_modules/@modelcontextprotocol/client/dist/index.d.mts +3196 -0
  185. package/node_modules/@modelcontextprotocol/client/dist/index.d.mts.map +1 -0
  186. package/node_modules/@modelcontextprotocol/client/dist/index.mjs +5224 -0
  187. package/node_modules/@modelcontextprotocol/client/dist/index.mjs.map +1 -0
  188. package/node_modules/@modelcontextprotocol/client/dist/shimsBrowser.cjs +14 -0
  189. package/node_modules/@modelcontextprotocol/client/dist/shimsBrowser.cjs.map +1 -0
  190. package/node_modules/@modelcontextprotocol/client/dist/shimsBrowser.d.cts +13 -0
  191. package/node_modules/@modelcontextprotocol/client/dist/shimsBrowser.d.cts.map +1 -0
  192. package/node_modules/@modelcontextprotocol/client/dist/shimsBrowser.d.mts +13 -0
  193. package/node_modules/@modelcontextprotocol/client/dist/shimsBrowser.d.mts.map +1 -0
  194. package/node_modules/@modelcontextprotocol/client/dist/shimsBrowser.mjs +13 -0
  195. package/node_modules/@modelcontextprotocol/client/dist/shimsBrowser.mjs.map +1 -0
  196. package/node_modules/@modelcontextprotocol/client/dist/shimsNode.cjs +14 -0
  197. package/node_modules/@modelcontextprotocol/client/dist/shimsNode.cjs.map +1 -0
  198. package/node_modules/@modelcontextprotocol/client/dist/shimsNode.d.cts +13 -0
  199. package/node_modules/@modelcontextprotocol/client/dist/shimsNode.d.cts.map +1 -0
  200. package/node_modules/@modelcontextprotocol/client/dist/shimsNode.d.mts +13 -0
  201. package/node_modules/@modelcontextprotocol/client/dist/shimsNode.d.mts.map +1 -0
  202. package/node_modules/@modelcontextprotocol/client/dist/shimsNode.mjs +13 -0
  203. package/node_modules/@modelcontextprotocol/client/dist/shimsNode.mjs.map +1 -0
  204. package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.cjs +21 -0
  205. package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.cjs.map +1 -0
  206. package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.d.cts +13 -0
  207. package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.d.cts.map +1 -0
  208. package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.d.mts +13 -0
  209. package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.d.mts.map +1 -0
  210. package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.mjs +20 -0
  211. package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.mjs.map +1 -0
  212. package/node_modules/@modelcontextprotocol/client/dist/src-BzzZSQyL.cjs +7331 -0
  213. package/node_modules/@modelcontextprotocol/client/dist/src-BzzZSQyL.cjs.map +1 -0
  214. package/node_modules/@modelcontextprotocol/client/dist/src-DGeA9On3.mjs +6963 -0
  215. package/node_modules/@modelcontextprotocol/client/dist/src-DGeA9On3.mjs.map +1 -0
  216. package/node_modules/@modelcontextprotocol/client/dist/stdio.cjs +181 -0
  217. package/node_modules/@modelcontextprotocol/client/dist/stdio.cjs.map +1 -0
  218. package/node_modules/@modelcontextprotocol/client/dist/stdio.d.cts +87 -0
  219. package/node_modules/@modelcontextprotocol/client/dist/stdio.d.cts.map +1 -0
  220. package/node_modules/@modelcontextprotocol/client/dist/stdio.d.mts +87 -0
  221. package/node_modules/@modelcontextprotocol/client/dist/stdio.d.mts.map +1 -0
  222. package/node_modules/@modelcontextprotocol/client/dist/stdio.mjs +176 -0
  223. package/node_modules/@modelcontextprotocol/client/dist/stdio.mjs.map +1 -0
  224. package/node_modules/@modelcontextprotocol/client/dist/types-BDNQEPSs.d.mts +1099 -0
  225. package/node_modules/@modelcontextprotocol/client/dist/types-BDNQEPSs.d.mts.map +1 -0
  226. package/node_modules/@modelcontextprotocol/client/dist/types-DsbMXNFL.d.cts +1099 -0
  227. package/node_modules/@modelcontextprotocol/client/dist/types-DsbMXNFL.d.cts.map +1 -0
  228. package/node_modules/@modelcontextprotocol/client/dist/validators/ajv.cjs +5 -0
  229. package/node_modules/@modelcontextprotocol/client/dist/validators/ajv.d.cts +2 -0
  230. package/node_modules/@modelcontextprotocol/client/dist/validators/ajv.d.mts +2 -0
  231. package/node_modules/@modelcontextprotocol/client/dist/validators/ajv.mjs +3 -0
  232. package/node_modules/@modelcontextprotocol/client/dist/validators/cfWorker.cjs +3 -0
  233. package/node_modules/@modelcontextprotocol/client/dist/validators/cfWorker.d.cts +2 -0
  234. package/node_modules/@modelcontextprotocol/client/dist/validators/cfWorker.d.mts +2 -0
  235. package/node_modules/@modelcontextprotocol/client/dist/validators/cfWorker.mjs +3 -0
  236. package/node_modules/@modelcontextprotocol/client/package.json +166 -0
  237. package/node_modules/@modelcontextprotocol/core/LICENSE +216 -0
  238. package/node_modules/@modelcontextprotocol/core/README.md +40 -0
  239. package/node_modules/@modelcontextprotocol/core/dist/auth-BUWfrB3C.d.cts +8198 -0
  240. package/node_modules/@modelcontextprotocol/core/dist/auth-BUWfrB3C.d.cts.map +1 -0
  241. package/node_modules/@modelcontextprotocol/core/dist/auth-CEFpHq32.cjs +2862 -0
  242. package/node_modules/@modelcontextprotocol/core/dist/auth-CEFpHq32.cjs.map +1 -0
  243. package/node_modules/@modelcontextprotocol/core/dist/auth-CNbu4K4a.d.mts +8198 -0
  244. package/node_modules/@modelcontextprotocol/core/dist/auth-CNbu4K4a.d.mts.map +1 -0
  245. package/node_modules/@modelcontextprotocol/core/dist/auth-DFgbUATV.mjs +1653 -0
  246. package/node_modules/@modelcontextprotocol/core/dist/auth-DFgbUATV.mjs.map +1 -0
  247. package/node_modules/@modelcontextprotocol/core/dist/index.cjs +174 -0
  248. package/node_modules/@modelcontextprotocol/core/dist/index.d.cts +2 -0
  249. package/node_modules/@modelcontextprotocol/core/dist/index.d.mts +2 -0
  250. package/node_modules/@modelcontextprotocol/core/dist/index.mjs +3 -0
  251. package/node_modules/@modelcontextprotocol/core/dist/internal.cjs +199 -0
  252. package/node_modules/@modelcontextprotocol/core/dist/internal.d.cts +87 -0
  253. package/node_modules/@modelcontextprotocol/core/dist/internal.d.cts.map +1 -0
  254. package/node_modules/@modelcontextprotocol/core/dist/internal.d.mts +87 -0
  255. package/node_modules/@modelcontextprotocol/core/dist/internal.d.mts.map +1 -0
  256. package/node_modules/@modelcontextprotocol/core/dist/internal.mjs +3 -0
  257. package/node_modules/@modelcontextprotocol/core/package.json +85 -0
  258. package/node_modules/jose/LICENSE.md +21 -0
  259. package/node_modules/jose/README.md +153 -0
  260. package/node_modules/jose/dist/types/index.d.ts +55 -0
  261. package/node_modules/jose/dist/types/jwe/compact/decrypt.d.ts +31 -0
  262. package/node_modules/jose/dist/types/jwe/compact/encrypt.d.ts +65 -0
  263. package/node_modules/jose/dist/types/jwe/flattened/decrypt.d.ts +31 -0
  264. package/node_modules/jose/dist/types/jwe/flattened/encrypt.d.ts +83 -0
  265. package/node_modules/jose/dist/types/jwe/general/decrypt.d.ts +31 -0
  266. package/node_modules/jose/dist/types/jwe/general/encrypt.d.ts +74 -0
  267. package/node_modules/jose/dist/types/jwk/embedded.d.ts +17 -0
  268. package/node_modules/jose/dist/types/jwk/thumbprint.d.ts +32 -0
  269. package/node_modules/jose/dist/types/jwks/local.d.ts +29 -0
  270. package/node_modules/jose/dist/types/jwks/remote.d.ts +237 -0
  271. package/node_modules/jose/dist/types/jws/compact/sign.d.ts +36 -0
  272. package/node_modules/jose/dist/types/jws/compact/verify.d.ts +33 -0
  273. package/node_modules/jose/dist/types/jws/flattened/sign.d.ts +42 -0
  274. package/node_modules/jose/dist/types/jws/flattened/verify.d.ts +33 -0
  275. package/node_modules/jose/dist/types/jws/general/sign.d.ts +53 -0
  276. package/node_modules/jose/dist/types/jws/general/verify.d.ts +33 -0
  277. package/node_modules/jose/dist/types/jwt/decrypt.d.ts +35 -0
  278. package/node_modules/jose/dist/types/jwt/encrypt.d.ts +91 -0
  279. package/node_modules/jose/dist/types/jwt/sign.d.ts +43 -0
  280. package/node_modules/jose/dist/types/jwt/unsecured.d.ts +43 -0
  281. package/node_modules/jose/dist/types/jwt/verify.d.ts +37 -0
  282. package/node_modules/jose/dist/types/key/export.d.ts +33 -0
  283. package/node_modules/jose/dist/types/key/generate_key_pair.d.ts +47 -0
  284. package/node_modules/jose/dist/types/key/generate_secret.d.ts +35 -0
  285. package/node_modules/jose/dist/types/key/import.d.ts +83 -0
  286. package/node_modules/jose/dist/types/types.d.ts +841 -0
  287. package/node_modules/jose/dist/types/util/base64url.d.ts +9 -0
  288. package/node_modules/jose/dist/types/util/decode_jwt.d.ts +18 -0
  289. package/node_modules/jose/dist/types/util/decode_protected_header.d.ts +17 -0
  290. package/node_modules/jose/dist/types/util/errors.d.ts +213 -0
  291. package/node_modules/jose/dist/webapi/index.js +32 -0
  292. package/node_modules/jose/dist/webapi/jwe/compact/decrypt.js +27 -0
  293. package/node_modules/jose/dist/webapi/jwe/compact/encrypt.js +27 -0
  294. package/node_modules/jose/dist/webapi/jwe/flattened/decrypt.js +165 -0
  295. package/node_modules/jose/dist/webapi/jwe/flattened/encrypt.js +169 -0
  296. package/node_modules/jose/dist/webapi/jwe/general/decrypt.js +31 -0
  297. package/node_modules/jose/dist/webapi/jwe/general/encrypt.js +187 -0
  298. package/node_modules/jose/dist/webapi/jwk/embedded.js +17 -0
  299. package/node_modules/jose/dist/webapi/jwk/thumbprint.js +68 -0
  300. package/node_modules/jose/dist/webapi/jwks/local.js +119 -0
  301. package/node_modules/jose/dist/webapi/jwks/remote.js +179 -0
  302. package/node_modules/jose/dist/webapi/jws/compact/sign.js +18 -0
  303. package/node_modules/jose/dist/webapi/jws/compact/verify.js +21 -0
  304. package/node_modules/jose/dist/webapi/jws/flattened/sign.js +92 -0
  305. package/node_modules/jose/dist/webapi/jws/flattened/verify.js +120 -0
  306. package/node_modules/jose/dist/webapi/jws/general/sign.js +73 -0
  307. package/node_modules/jose/dist/webapi/jws/general/verify.js +24 -0
  308. package/node_modules/jose/dist/webapi/jwt/decrypt.js +23 -0
  309. package/node_modules/jose/dist/webapi/jwt/encrypt.js +108 -0
  310. package/node_modules/jose/dist/webapi/jwt/sign.js +52 -0
  311. package/node_modules/jose/dist/webapi/jwt/unsecured.js +63 -0
  312. package/node_modules/jose/dist/webapi/jwt/verify.js +15 -0
  313. package/node_modules/jose/dist/webapi/key/export.js +11 -0
  314. package/node_modules/jose/dist/webapi/key/generate_key_pair.js +97 -0
  315. package/node_modules/jose/dist/webapi/key/generate_secret.js +40 -0
  316. package/node_modules/jose/dist/webapi/key/import.js +57 -0
  317. package/node_modules/jose/dist/webapi/lib/aesgcmkw.js +16 -0
  318. package/node_modules/jose/dist/webapi/lib/aeskw.js +25 -0
  319. package/node_modules/jose/dist/webapi/lib/asn1.js +243 -0
  320. package/node_modules/jose/dist/webapi/lib/base64.js +22 -0
  321. package/node_modules/jose/dist/webapi/lib/buffer_utils.js +43 -0
  322. package/node_modules/jose/dist/webapi/lib/cek.js +19 -0
  323. package/node_modules/jose/dist/webapi/lib/check_cek_length.js +7 -0
  324. package/node_modules/jose/dist/webapi/lib/check_iv_length.js +7 -0
  325. package/node_modules/jose/dist/webapi/lib/check_key_length.js +8 -0
  326. package/node_modules/jose/dist/webapi/lib/check_key_type.js +122 -0
  327. package/node_modules/jose/dist/webapi/lib/crypto_key.js +143 -0
  328. package/node_modules/jose/dist/webapi/lib/decrypt.js +106 -0
  329. package/node_modules/jose/dist/webapi/lib/decrypt_key_management.js +127 -0
  330. package/node_modules/jose/dist/webapi/lib/digest.js +4 -0
  331. package/node_modules/jose/dist/webapi/lib/ecdhes.js +52 -0
  332. package/node_modules/jose/dist/webapi/lib/encrypt.js +74 -0
  333. package/node_modules/jose/dist/webapi/lib/encrypt_key_management.js +92 -0
  334. package/node_modules/jose/dist/webapi/lib/get_sign_verify_key.js +12 -0
  335. package/node_modules/jose/dist/webapi/lib/invalid_key_input.js +27 -0
  336. package/node_modules/jose/dist/webapi/lib/is_disjoint.js +21 -0
  337. package/node_modules/jose/dist/webapi/lib/is_jwk.js +6 -0
  338. package/node_modules/jose/dist/webapi/lib/is_key_like.js +17 -0
  339. package/node_modules/jose/dist/webapi/lib/is_object.js +14 -0
  340. package/node_modules/jose/dist/webapi/lib/iv.js +19 -0
  341. package/node_modules/jose/dist/webapi/lib/jwk_to_key.js +109 -0
  342. package/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +238 -0
  343. package/node_modules/jose/dist/webapi/lib/key_to_jwk.js +31 -0
  344. package/node_modules/jose/dist/webapi/lib/normalize_key.js +176 -0
  345. package/node_modules/jose/dist/webapi/lib/pbes2kw.js +39 -0
  346. package/node_modules/jose/dist/webapi/lib/private_symbols.js +1 -0
  347. package/node_modules/jose/dist/webapi/lib/rsaes.js +24 -0
  348. package/node_modules/jose/dist/webapi/lib/sign.js +9 -0
  349. package/node_modules/jose/dist/webapi/lib/subtle_dsa.js +31 -0
  350. package/node_modules/jose/dist/webapi/lib/validate_algorithms.js +10 -0
  351. package/node_modules/jose/dist/webapi/lib/validate_crit.js +33 -0
  352. package/node_modules/jose/dist/webapi/lib/verify.js +14 -0
  353. package/node_modules/jose/dist/webapi/util/base64url.js +30 -0
  354. package/node_modules/jose/dist/webapi/util/decode_jwt.js +32 -0
  355. package/node_modules/jose/dist/webapi/util/decode_protected_header.js +34 -0
  356. package/node_modules/jose/dist/webapi/util/errors.js +99 -0
  357. package/node_modules/jose/package.json +200 -0
  358. package/node_modules/zod/LICENSE +21 -0
  359. package/node_modules/zod/README.md +191 -0
  360. package/node_modules/zod/index.cjs +33 -0
  361. package/node_modules/zod/index.d.cts +4 -0
  362. package/node_modules/zod/index.d.ts +4 -0
  363. package/node_modules/zod/index.js +4 -0
  364. package/node_modules/zod/locales/index.cjs +17 -0
  365. package/node_modules/zod/locales/index.d.cts +1 -0
  366. package/node_modules/zod/locales/index.d.ts +1 -0
  367. package/node_modules/zod/locales/index.js +1 -0
  368. package/node_modules/zod/locales/package.json +7 -0
  369. package/node_modules/zod/mini/index.cjs +32 -0
  370. package/node_modules/zod/mini/index.d.cts +3 -0
  371. package/node_modules/zod/mini/index.d.ts +3 -0
  372. package/node_modules/zod/mini/index.js +3 -0
  373. package/node_modules/zod/mini/package.json +7 -0
  374. package/node_modules/zod/package.json +135 -0
  375. package/node_modules/zod/src/index.ts +4 -0
  376. package/node_modules/zod/src/locales/index.ts +1 -0
  377. package/node_modules/zod/src/mini/index.ts +3 -0
  378. package/node_modules/zod/src/v3/ZodError.ts +330 -0
  379. package/node_modules/zod/src/v3/benchmarks/datetime.ts +58 -0
  380. package/node_modules/zod/src/v3/benchmarks/discriminatedUnion.ts +80 -0
  381. package/node_modules/zod/src/v3/benchmarks/index.ts +59 -0
  382. package/node_modules/zod/src/v3/benchmarks/ipv4.ts +57 -0
  383. package/node_modules/zod/src/v3/benchmarks/object.ts +69 -0
  384. package/node_modules/zod/src/v3/benchmarks/primitives.ts +162 -0
  385. package/node_modules/zod/src/v3/benchmarks/realworld.ts +63 -0
  386. package/node_modules/zod/src/v3/benchmarks/string.ts +55 -0
  387. package/node_modules/zod/src/v3/benchmarks/union.ts +80 -0
  388. package/node_modules/zod/src/v3/errors.ts +13 -0
  389. package/node_modules/zod/src/v3/external.ts +6 -0
  390. package/node_modules/zod/src/v3/helpers/enumUtil.ts +17 -0
  391. package/node_modules/zod/src/v3/helpers/errorUtil.ts +8 -0
  392. package/node_modules/zod/src/v3/helpers/parseUtil.ts +176 -0
  393. package/node_modules/zod/src/v3/helpers/partialUtil.ts +34 -0
  394. package/node_modules/zod/src/v3/helpers/typeAliases.ts +2 -0
  395. package/node_modules/zod/src/v3/helpers/util.ts +224 -0
  396. package/node_modules/zod/src/v3/index.ts +4 -0
  397. package/node_modules/zod/src/v3/locales/en.ts +124 -0
  398. package/node_modules/zod/src/v3/standard-schema.ts +113 -0
  399. package/node_modules/zod/src/v3/tests/Mocker.ts +54 -0
  400. package/node_modules/zod/src/v3/tests/all-errors.test.ts +157 -0
  401. package/node_modules/zod/src/v3/tests/anyunknown.test.ts +28 -0
  402. package/node_modules/zod/src/v3/tests/array.test.ts +71 -0
  403. package/node_modules/zod/src/v3/tests/async-parsing.test.ts +388 -0
  404. package/node_modules/zod/src/v3/tests/async-refinements.test.ts +46 -0
  405. package/node_modules/zod/src/v3/tests/base.test.ts +29 -0
  406. package/node_modules/zod/src/v3/tests/bigint.test.ts +55 -0
  407. package/node_modules/zod/src/v3/tests/branded.test.ts +53 -0
  408. package/node_modules/zod/src/v3/tests/catch.test.ts +220 -0
  409. package/node_modules/zod/src/v3/tests/coerce.test.ts +133 -0
  410. package/node_modules/zod/src/v3/tests/complex.test.ts +70 -0
  411. package/node_modules/zod/src/v3/tests/custom.test.ts +31 -0
  412. package/node_modules/zod/src/v3/tests/date.test.ts +32 -0
  413. package/node_modules/zod/src/v3/tests/deepmasking.test.ts +186 -0
  414. package/node_modules/zod/src/v3/tests/default.test.ts +112 -0
  415. package/node_modules/zod/src/v3/tests/description.test.ts +33 -0
  416. package/node_modules/zod/src/v3/tests/discriminated-unions.test.ts +315 -0
  417. package/node_modules/zod/src/v3/tests/enum.test.ts +80 -0
  418. package/node_modules/zod/src/v3/tests/error.test.ts +551 -0
  419. package/node_modules/zod/src/v3/tests/firstparty.test.ts +87 -0
  420. package/node_modules/zod/src/v3/tests/firstpartyschematypes.test.ts +21 -0
  421. package/node_modules/zod/src/v3/tests/function.test.ts +261 -0
  422. package/node_modules/zod/src/v3/tests/generics.test.ts +48 -0
  423. package/node_modules/zod/src/v3/tests/instanceof.test.ts +37 -0
  424. package/node_modules/zod/src/v3/tests/intersection.test.ts +110 -0
  425. package/node_modules/zod/src/v3/tests/language-server.source.ts +76 -0
  426. package/node_modules/zod/src/v3/tests/language-server.test.ts +207 -0
  427. package/node_modules/zod/src/v3/tests/literal.test.ts +36 -0
  428. package/node_modules/zod/src/v3/tests/map.test.ts +110 -0
  429. package/node_modules/zod/src/v3/tests/masking.test.ts +4 -0
  430. package/node_modules/zod/src/v3/tests/mocker.test.ts +19 -0
  431. package/node_modules/zod/src/v3/tests/nan.test.ts +24 -0
  432. package/node_modules/zod/src/v3/tests/nativeEnum.test.ts +87 -0
  433. package/node_modules/zod/src/v3/tests/nullable.test.ts +42 -0
  434. package/node_modules/zod/src/v3/tests/number.test.ts +176 -0
  435. package/node_modules/zod/src/v3/tests/object-augmentation.test.ts +29 -0
  436. package/node_modules/zod/src/v3/tests/object-in-es5-env.test.ts +29 -0
  437. package/node_modules/zod/src/v3/tests/object.test.ts +434 -0
  438. package/node_modules/zod/src/v3/tests/optional.test.ts +42 -0
  439. package/node_modules/zod/src/v3/tests/parseUtil.test.ts +23 -0
  440. package/node_modules/zod/src/v3/tests/parser.test.ts +41 -0
  441. package/node_modules/zod/src/v3/tests/partials.test.ts +243 -0
  442. package/node_modules/zod/src/v3/tests/pickomit.test.ts +111 -0
  443. package/node_modules/zod/src/v3/tests/pipeline.test.ts +29 -0
  444. package/node_modules/zod/src/v3/tests/preprocess.test.ts +186 -0
  445. package/node_modules/zod/src/v3/tests/primitive.test.ts +440 -0
  446. package/node_modules/zod/src/v3/tests/promise.test.ts +90 -0
  447. package/node_modules/zod/src/v3/tests/readonly.test.ts +194 -0
  448. package/node_modules/zod/src/v3/tests/record.test.ts +171 -0
  449. package/node_modules/zod/src/v3/tests/recursive.test.ts +197 -0
  450. package/node_modules/zod/src/v3/tests/refine.test.ts +313 -0
  451. package/node_modules/zod/src/v3/tests/safeparse.test.ts +27 -0
  452. package/node_modules/zod/src/v3/tests/set.test.ts +142 -0
  453. package/node_modules/zod/src/v3/tests/standard-schema.test.ts +83 -0
  454. package/node_modules/zod/src/v3/tests/string.test.ts +916 -0
  455. package/node_modules/zod/src/v3/tests/transformer.test.ts +233 -0
  456. package/node_modules/zod/src/v3/tests/tuple.test.ts +90 -0
  457. package/node_modules/zod/src/v3/tests/unions.test.ts +57 -0
  458. package/node_modules/zod/src/v3/tests/validations.test.ts +133 -0
  459. package/node_modules/zod/src/v3/tests/void.test.ts +15 -0
  460. package/node_modules/zod/src/v3/types.ts +5138 -0
  461. package/node_modules/zod/src/v4/classic/checks.ts +32 -0
  462. package/node_modules/zod/src/v4/classic/coerce.ts +27 -0
  463. package/node_modules/zod/src/v4/classic/compat.ts +70 -0
  464. package/node_modules/zod/src/v4/classic/errors.ts +82 -0
  465. package/node_modules/zod/src/v4/classic/external.ts +52 -0
  466. package/node_modules/zod/src/v4/classic/from-json-schema.ts +659 -0
  467. package/node_modules/zod/src/v4/classic/index.ts +5 -0
  468. package/node_modules/zod/src/v4/classic/iso.ts +90 -0
  469. package/node_modules/zod/src/v4/classic/parse.ts +82 -0
  470. package/node_modules/zod/src/v4/classic/schemas.ts +2672 -0
  471. package/node_modules/zod/src/v4/classic/tests/anyunknown.test.ts +26 -0
  472. package/node_modules/zod/src/v4/classic/tests/apply.test.ts +59 -0
  473. package/node_modules/zod/src/v4/classic/tests/array.test.ts +264 -0
  474. package/node_modules/zod/src/v4/classic/tests/assignability.test.ts +216 -0
  475. package/node_modules/zod/src/v4/classic/tests/async-parsing.test.ts +381 -0
  476. package/node_modules/zod/src/v4/classic/tests/async-refinements.test.ts +68 -0
  477. package/node_modules/zod/src/v4/classic/tests/base.test.ts +7 -0
  478. package/node_modules/zod/src/v4/classic/tests/bigint.test.ts +54 -0
  479. package/node_modules/zod/src/v4/classic/tests/brand.test.ts +106 -0
  480. package/node_modules/zod/src/v4/classic/tests/catch.test.ts +326 -0
  481. package/node_modules/zod/src/v4/classic/tests/coalesce.test.ts +20 -0
  482. package/node_modules/zod/src/v4/classic/tests/codec-examples.test.ts +573 -0
  483. package/node_modules/zod/src/v4/classic/tests/codec.test.ts +703 -0
  484. package/node_modules/zod/src/v4/classic/tests/coerce.test.ts +160 -0
  485. package/node_modules/zod/src/v4/classic/tests/continuability.test.ts +374 -0
  486. package/node_modules/zod/src/v4/classic/tests/custom.test.ts +40 -0
  487. package/node_modules/zod/src/v4/classic/tests/date.test.ts +62 -0
  488. package/node_modules/zod/src/v4/classic/tests/datetime.test.ts +302 -0
  489. package/node_modules/zod/src/v4/classic/tests/default.test.ts +409 -0
  490. package/node_modules/zod/src/v4/classic/tests/describe-meta-checks.test.ts +27 -0
  491. package/node_modules/zod/src/v4/classic/tests/description.test.ts +32 -0
  492. package/node_modules/zod/src/v4/classic/tests/detached-methods.test.ts +197 -0
  493. package/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +694 -0
  494. package/node_modules/zod/src/v4/classic/tests/enum.test.ts +285 -0
  495. package/node_modules/zod/src/v4/classic/tests/error-utils.test.ts +807 -0
  496. package/node_modules/zod/src/v4/classic/tests/error.test.ts +711 -0
  497. package/node_modules/zod/src/v4/classic/tests/file.test.ts +96 -0
  498. package/node_modules/zod/src/v4/classic/tests/firstparty.test.ts +179 -0
  499. package/node_modules/zod/src/v4/classic/tests/fix-json-issue.test.ts +26 -0
  500. package/node_modules/zod/src/v4/classic/tests/from-json-schema.test.ts +895 -0
  501. package/node_modules/zod/src/v4/classic/tests/function.test.ts +360 -0
  502. package/node_modules/zod/src/v4/classic/tests/generics.test.ts +72 -0
  503. package/node_modules/zod/src/v4/classic/tests/global-config.test.ts +39 -0
  504. package/node_modules/zod/src/v4/classic/tests/hash.test.ts +68 -0
  505. package/node_modules/zod/src/v4/classic/tests/index.test.ts +939 -0
  506. package/node_modules/zod/src/v4/classic/tests/instanceof.test.ts +60 -0
  507. package/node_modules/zod/src/v4/classic/tests/intersection.test.ts +198 -0
  508. package/node_modules/zod/src/v4/classic/tests/jitless-allows-eval.test.ts +46 -0
  509. package/node_modules/zod/src/v4/classic/tests/json.test.ts +109 -0
  510. package/node_modules/zod/src/v4/classic/tests/lazy.test.ts +227 -0
  511. package/node_modules/zod/src/v4/classic/tests/literal.test.ts +117 -0
  512. package/node_modules/zod/src/v4/classic/tests/locales_ka.test.ts +29 -0
  513. package/node_modules/zod/src/v4/classic/tests/locales_ro.test.ts +24 -0
  514. package/node_modules/zod/src/v4/classic/tests/map.test.ts +330 -0
  515. package/node_modules/zod/src/v4/classic/tests/nan.test.ts +21 -0
  516. package/node_modules/zod/src/v4/classic/tests/nested-refine.test.ts +168 -0
  517. package/node_modules/zod/src/v4/classic/tests/nonoptional.test.ts +101 -0
  518. package/node_modules/zod/src/v4/classic/tests/nullable.test.ts +22 -0
  519. package/node_modules/zod/src/v4/classic/tests/number.test.ts +325 -0
  520. package/node_modules/zod/src/v4/classic/tests/object.test.ts +717 -0
  521. package/node_modules/zod/src/v4/classic/tests/optional.test.ts +333 -0
  522. package/node_modules/zod/src/v4/classic/tests/partial.test.ts +450 -0
  523. package/node_modules/zod/src/v4/classic/tests/pickomit.test.ts +211 -0
  524. package/node_modules/zod/src/v4/classic/tests/pipe.test.ts +101 -0
  525. package/node_modules/zod/src/v4/classic/tests/prefault.test.ts +74 -0
  526. package/node_modules/zod/src/v4/classic/tests/preprocess-types.test.ts +26 -0
  527. package/node_modules/zod/src/v4/classic/tests/preprocess.test.ts +351 -0
  528. package/node_modules/zod/src/v4/classic/tests/primitive.test.ts +175 -0
  529. package/node_modules/zod/src/v4/classic/tests/promise.test.ts +81 -0
  530. package/node_modules/zod/src/v4/classic/tests/prototypes.test.ts +23 -0
  531. package/node_modules/zod/src/v4/classic/tests/readonly.test.ts +252 -0
  532. package/node_modules/zod/src/v4/classic/tests/record.test.ts +717 -0
  533. package/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +631 -0
  534. package/node_modules/zod/src/v4/classic/tests/refine.test.ts +633 -0
  535. package/node_modules/zod/src/v4/classic/tests/registries.test.ts +243 -0
  536. package/node_modules/zod/src/v4/classic/tests/set.test.ts +181 -0
  537. package/node_modules/zod/src/v4/classic/tests/standard-schema.test.ts +134 -0
  538. package/node_modules/zod/src/v4/classic/tests/string-formats.test.ts +125 -0
  539. package/node_modules/zod/src/v4/classic/tests/string.test.ts +1224 -0
  540. package/node_modules/zod/src/v4/classic/tests/stringbool.test.ts +106 -0
  541. package/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +771 -0
  542. package/node_modules/zod/src/v4/classic/tests/to-json-schema-methods.test.ts +438 -0
  543. package/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +3125 -0
  544. package/node_modules/zod/src/v4/classic/tests/transform.test.ts +378 -0
  545. package/node_modules/zod/src/v4/classic/tests/tuple.test.ts +496 -0
  546. package/node_modules/zod/src/v4/classic/tests/union.test.ts +273 -0
  547. package/node_modules/zod/src/v4/classic/tests/url.test.ts +13 -0
  548. package/node_modules/zod/src/v4/classic/tests/validations.test.ts +283 -0
  549. package/node_modules/zod/src/v4/classic/tests/void.test.ts +12 -0
  550. package/node_modules/zod/src/v4/core/api.ts +1823 -0
  551. package/node_modules/zod/src/v4/core/checks.ts +1293 -0
  552. package/node_modules/zod/src/v4/core/config.ts +15 -0
  553. package/node_modules/zod/src/v4/core/core.ts +153 -0
  554. package/node_modules/zod/src/v4/core/doc.ts +44 -0
  555. package/node_modules/zod/src/v4/core/errors.ts +455 -0
  556. package/node_modules/zod/src/v4/core/index.ts +16 -0
  557. package/node_modules/zod/src/v4/core/json-schema-generator.ts +126 -0
  558. package/node_modules/zod/src/v4/core/json-schema-processors.ts +666 -0
  559. package/node_modules/zod/src/v4/core/json-schema.ts +147 -0
  560. package/node_modules/zod/src/v4/core/parse.ts +195 -0
  561. package/node_modules/zod/src/v4/core/regexes.ts +190 -0
  562. package/node_modules/zod/src/v4/core/registries.ts +105 -0
  563. package/node_modules/zod/src/v4/core/schemas.ts +4730 -0
  564. package/node_modules/zod/src/v4/core/standard-schema.ts +159 -0
  565. package/node_modules/zod/src/v4/core/tests/extend.test.ts +59 -0
  566. package/node_modules/zod/src/v4/core/tests/index.test.ts +46 -0
  567. package/node_modules/zod/src/v4/core/tests/locales/be.test.ts +124 -0
  568. package/node_modules/zod/src/v4/core/tests/locales/el.test.ts +215 -0
  569. package/node_modules/zod/src/v4/core/tests/locales/en.test.ts +22 -0
  570. package/node_modules/zod/src/v4/core/tests/locales/es.test.ts +181 -0
  571. package/node_modules/zod/src/v4/core/tests/locales/fr.test.ts +72 -0
  572. package/node_modules/zod/src/v4/core/tests/locales/he.test.ts +379 -0
  573. package/node_modules/zod/src/v4/core/tests/locales/hr.test.ts +163 -0
  574. package/node_modules/zod/src/v4/core/tests/locales/nl.test.ts +46 -0
  575. package/node_modules/zod/src/v4/core/tests/locales/ru.test.ts +128 -0
  576. package/node_modules/zod/src/v4/core/tests/locales/tr.test.ts +69 -0
  577. package/node_modules/zod/src/v4/core/tests/locales/uz.test.ts +105 -0
  578. package/node_modules/zod/src/v4/core/tests/record-constructor.test.ts +125 -0
  579. package/node_modules/zod/src/v4/core/tests/recursive-tuples.test.ts +45 -0
  580. package/node_modules/zod/src/v4/core/to-json-schema.ts +622 -0
  581. package/node_modules/zod/src/v4/core/util.ts +983 -0
  582. package/node_modules/zod/src/v4/core/versions.ts +5 -0
  583. package/node_modules/zod/src/v4/core/zsf.ts +323 -0
  584. package/node_modules/zod/src/v4/index.ts +4 -0
  585. package/node_modules/zod/src/v4/locales/ar.ts +115 -0
  586. package/node_modules/zod/src/v4/locales/az.ts +111 -0
  587. package/node_modules/zod/src/v4/locales/be.ts +176 -0
  588. package/node_modules/zod/src/v4/locales/bg.ts +128 -0
  589. package/node_modules/zod/src/v4/locales/ca.ts +116 -0
  590. package/node_modules/zod/src/v4/locales/cs.ts +118 -0
  591. package/node_modules/zod/src/v4/locales/da.ts +123 -0
  592. package/node_modules/zod/src/v4/locales/de.ts +116 -0
  593. package/node_modules/zod/src/v4/locales/el.ts +121 -0
  594. package/node_modules/zod/src/v4/locales/en.ts +123 -0
  595. package/node_modules/zod/src/v4/locales/eo.ts +118 -0
  596. package/node_modules/zod/src/v4/locales/es.ts +141 -0
  597. package/node_modules/zod/src/v4/locales/fa.ts +126 -0
  598. package/node_modules/zod/src/v4/locales/fi.ts +121 -0
  599. package/node_modules/zod/src/v4/locales/fr-CA.ts +116 -0
  600. package/node_modules/zod/src/v4/locales/fr.ts +132 -0
  601. package/node_modules/zod/src/v4/locales/he.ts +246 -0
  602. package/node_modules/zod/src/v4/locales/hr.ts +131 -0
  603. package/node_modules/zod/src/v4/locales/hu.ts +117 -0
  604. package/node_modules/zod/src/v4/locales/hy.ts +164 -0
  605. package/node_modules/zod/src/v4/locales/id.ts +115 -0
  606. package/node_modules/zod/src/v4/locales/index.ts +52 -0
  607. package/node_modules/zod/src/v4/locales/is.ts +119 -0
  608. package/node_modules/zod/src/v4/locales/it.ts +116 -0
  609. package/node_modules/zod/src/v4/locales/ja.ts +114 -0
  610. package/node_modules/zod/src/v4/locales/ka.ts +123 -0
  611. package/node_modules/zod/src/v4/locales/kh.ts +7 -0
  612. package/node_modules/zod/src/v4/locales/km.ts +119 -0
  613. package/node_modules/zod/src/v4/locales/ko.ts +121 -0
  614. package/node_modules/zod/src/v4/locales/lt.ts +239 -0
  615. package/node_modules/zod/src/v4/locales/mk.ts +118 -0
  616. package/node_modules/zod/src/v4/locales/ms.ts +115 -0
  617. package/node_modules/zod/src/v4/locales/nl.ts +121 -0
  618. package/node_modules/zod/src/v4/locales/no.ts +116 -0
  619. package/node_modules/zod/src/v4/locales/ota.ts +117 -0
  620. package/node_modules/zod/src/v4/locales/pl.ts +118 -0
  621. package/node_modules/zod/src/v4/locales/ps.ts +126 -0
  622. package/node_modules/zod/src/v4/locales/pt.ts +116 -0
  623. package/node_modules/zod/src/v4/locales/ro.ts +129 -0
  624. package/node_modules/zod/src/v4/locales/ru.ts +176 -0
  625. package/node_modules/zod/src/v4/locales/sl.ts +118 -0
  626. package/node_modules/zod/src/v4/locales/sv.ts +119 -0
  627. package/node_modules/zod/src/v4/locales/ta.ts +118 -0
  628. package/node_modules/zod/src/v4/locales/th.ts +119 -0
  629. package/node_modules/zod/src/v4/locales/tr.ts +111 -0
  630. package/node_modules/zod/src/v4/locales/ua.ts +7 -0
  631. package/node_modules/zod/src/v4/locales/uk.ts +117 -0
  632. package/node_modules/zod/src/v4/locales/ur.ts +119 -0
  633. package/node_modules/zod/src/v4/locales/uz.ts +117 -0
  634. package/node_modules/zod/src/v4/locales/vi.ts +117 -0
  635. package/node_modules/zod/src/v4/locales/yo.ts +124 -0
  636. package/node_modules/zod/src/v4/locales/zh-CN.ts +116 -0
  637. package/node_modules/zod/src/v4/locales/zh-TW.ts +115 -0
  638. package/node_modules/zod/src/v4/mini/checks.ts +32 -0
  639. package/node_modules/zod/src/v4/mini/coerce.ts +27 -0
  640. package/node_modules/zod/src/v4/mini/external.ts +41 -0
  641. package/node_modules/zod/src/v4/mini/index.ts +3 -0
  642. package/node_modules/zod/src/v4/mini/iso.ts +66 -0
  643. package/node_modules/zod/src/v4/mini/parse.ts +14 -0
  644. package/node_modules/zod/src/v4/mini/schemas.ts +1947 -0
  645. package/node_modules/zod/src/v4/mini/tests/apply.test.ts +24 -0
  646. package/node_modules/zod/src/v4/mini/tests/assignability.test.ts +129 -0
  647. package/node_modules/zod/src/v4/mini/tests/brand.test.ts +94 -0
  648. package/node_modules/zod/src/v4/mini/tests/checks.test.ts +144 -0
  649. package/node_modules/zod/src/v4/mini/tests/codec.test.ts +548 -0
  650. package/node_modules/zod/src/v4/mini/tests/computed.test.ts +36 -0
  651. package/node_modules/zod/src/v4/mini/tests/error.test.ts +22 -0
  652. package/node_modules/zod/src/v4/mini/tests/functions.test.ts +5 -0
  653. package/node_modules/zod/src/v4/mini/tests/index.test.ts +993 -0
  654. package/node_modules/zod/src/v4/mini/tests/number.test.ts +95 -0
  655. package/node_modules/zod/src/v4/mini/tests/object.test.ts +227 -0
  656. package/node_modules/zod/src/v4/mini/tests/prototypes.test.ts +43 -0
  657. package/node_modules/zod/src/v4/mini/tests/recursive-types.test.ts +325 -0
  658. package/node_modules/zod/src/v4/mini/tests/standard-schema.test.ts +50 -0
  659. package/node_modules/zod/src/v4/mini/tests/string.test.ts +352 -0
  660. package/node_modules/zod/src/v4-mini/index.ts +3 -0
  661. package/node_modules/zod/v3/ZodError.cjs +138 -0
  662. package/node_modules/zod/v3/ZodError.d.cts +164 -0
  663. package/node_modules/zod/v3/ZodError.d.ts +164 -0
  664. package/node_modules/zod/v3/ZodError.js +133 -0
  665. package/node_modules/zod/v3/errors.cjs +17 -0
  666. package/node_modules/zod/v3/errors.d.cts +5 -0
  667. package/node_modules/zod/v3/errors.d.ts +5 -0
  668. package/node_modules/zod/v3/errors.js +9 -0
  669. package/node_modules/zod/v3/external.cjs +22 -0
  670. package/node_modules/zod/v3/external.d.cts +6 -0
  671. package/node_modules/zod/v3/external.d.ts +6 -0
  672. package/node_modules/zod/v3/external.js +6 -0
  673. package/node_modules/zod/v3/helpers/enumUtil.cjs +2 -0
  674. package/node_modules/zod/v3/helpers/enumUtil.d.cts +8 -0
  675. package/node_modules/zod/v3/helpers/enumUtil.d.ts +8 -0
  676. package/node_modules/zod/v3/helpers/enumUtil.js +1 -0
  677. package/node_modules/zod/v3/helpers/errorUtil.cjs +9 -0
  678. package/node_modules/zod/v3/helpers/errorUtil.d.cts +9 -0
  679. package/node_modules/zod/v3/helpers/errorUtil.d.ts +9 -0
  680. package/node_modules/zod/v3/helpers/errorUtil.js +6 -0
  681. package/node_modules/zod/v3/helpers/parseUtil.cjs +124 -0
  682. package/node_modules/zod/v3/helpers/parseUtil.d.cts +78 -0
  683. package/node_modules/zod/v3/helpers/parseUtil.d.ts +78 -0
  684. package/node_modules/zod/v3/helpers/parseUtil.js +109 -0
  685. package/node_modules/zod/v3/helpers/partialUtil.cjs +2 -0
  686. package/node_modules/zod/v3/helpers/partialUtil.d.cts +8 -0
  687. package/node_modules/zod/v3/helpers/partialUtil.d.ts +8 -0
  688. package/node_modules/zod/v3/helpers/partialUtil.js +1 -0
  689. package/node_modules/zod/v3/helpers/typeAliases.cjs +2 -0
  690. package/node_modules/zod/v3/helpers/typeAliases.d.cts +2 -0
  691. package/node_modules/zod/v3/helpers/typeAliases.d.ts +2 -0
  692. package/node_modules/zod/v3/helpers/typeAliases.js +1 -0
  693. package/node_modules/zod/v3/helpers/util.cjs +137 -0
  694. package/node_modules/zod/v3/helpers/util.d.cts +85 -0
  695. package/node_modules/zod/v3/helpers/util.d.ts +85 -0
  696. package/node_modules/zod/v3/helpers/util.js +133 -0
  697. package/node_modules/zod/v3/index.cjs +33 -0
  698. package/node_modules/zod/v3/index.d.cts +4 -0
  699. package/node_modules/zod/v3/index.d.ts +4 -0
  700. package/node_modules/zod/v3/index.js +4 -0
  701. package/node_modules/zod/v3/locales/en.cjs +112 -0
  702. package/node_modules/zod/v3/locales/en.d.cts +3 -0
  703. package/node_modules/zod/v3/locales/en.d.ts +3 -0
  704. package/node_modules/zod/v3/locales/en.js +109 -0
  705. package/node_modules/zod/v3/package.json +7 -0
  706. package/node_modules/zod/v3/standard-schema.cjs +2 -0
  707. package/node_modules/zod/v3/standard-schema.d.cts +102 -0
  708. package/node_modules/zod/v3/standard-schema.d.ts +102 -0
  709. package/node_modules/zod/v3/standard-schema.js +1 -0
  710. package/node_modules/zod/v3/types.cjs +3777 -0
  711. package/node_modules/zod/v3/types.d.cts +1034 -0
  712. package/node_modules/zod/v3/types.d.ts +1034 -0
  713. package/node_modules/zod/v3/types.js +3695 -0
  714. package/node_modules/zod/v4/classic/checks.cjs +33 -0
  715. package/node_modules/zod/v4/classic/checks.d.cts +1 -0
  716. package/node_modules/zod/v4/classic/checks.d.ts +1 -0
  717. package/node_modules/zod/v4/classic/checks.js +1 -0
  718. package/node_modules/zod/v4/classic/coerce.cjs +47 -0
  719. package/node_modules/zod/v4/classic/coerce.d.cts +17 -0
  720. package/node_modules/zod/v4/classic/coerce.d.ts +17 -0
  721. package/node_modules/zod/v4/classic/coerce.js +17 -0
  722. package/node_modules/zod/v4/classic/compat.cjs +61 -0
  723. package/node_modules/zod/v4/classic/compat.d.cts +50 -0
  724. package/node_modules/zod/v4/classic/compat.d.ts +50 -0
  725. package/node_modules/zod/v4/classic/compat.js +31 -0
  726. package/node_modules/zod/v4/classic/errors.cjs +74 -0
  727. package/node_modules/zod/v4/classic/errors.d.cts +30 -0
  728. package/node_modules/zod/v4/classic/errors.d.ts +30 -0
  729. package/node_modules/zod/v4/classic/errors.js +48 -0
  730. package/node_modules/zod/v4/classic/external.cjs +73 -0
  731. package/node_modules/zod/v4/classic/external.d.cts +16 -0
  732. package/node_modules/zod/v4/classic/external.d.ts +16 -0
  733. package/node_modules/zod/v4/classic/external.js +20 -0
  734. package/node_modules/zod/v4/classic/from-json-schema.cjs +625 -0
  735. package/node_modules/zod/v4/classic/from-json-schema.d.cts +12 -0
  736. package/node_modules/zod/v4/classic/from-json-schema.d.ts +12 -0
  737. package/node_modules/zod/v4/classic/from-json-schema.js +599 -0
  738. package/node_modules/zod/v4/classic/index.cjs +33 -0
  739. package/node_modules/zod/v4/classic/index.d.cts +4 -0
  740. package/node_modules/zod/v4/classic/index.d.ts +4 -0
  741. package/node_modules/zod/v4/classic/index.js +4 -0
  742. package/node_modules/zod/v4/classic/iso.cjs +60 -0
  743. package/node_modules/zod/v4/classic/iso.d.cts +22 -0
  744. package/node_modules/zod/v4/classic/iso.d.ts +22 -0
  745. package/node_modules/zod/v4/classic/iso.js +30 -0
  746. package/node_modules/zod/v4/classic/package.json +7 -0
  747. package/node_modules/zod/v4/classic/parse.cjs +41 -0
  748. package/node_modules/zod/v4/classic/parse.d.cts +31 -0
  749. package/node_modules/zod/v4/classic/parse.d.ts +31 -0
  750. package/node_modules/zod/v4/classic/parse.js +15 -0
  751. package/node_modules/zod/v4/classic/schemas.cjs +1511 -0
  752. package/node_modules/zod/v4/classic/schemas.d.cts +767 -0
  753. package/node_modules/zod/v4/classic/schemas.d.ts +767 -0
  754. package/node_modules/zod/v4/classic/schemas.js +1395 -0
  755. package/node_modules/zod/v4/core/api.cjs +1227 -0
  756. package/node_modules/zod/v4/core/api.d.cts +325 -0
  757. package/node_modules/zod/v4/core/api.d.ts +325 -0
  758. package/node_modules/zod/v4/core/api.js +1087 -0
  759. package/node_modules/zod/v4/core/checks.cjs +601 -0
  760. package/node_modules/zod/v4/core/checks.d.cts +278 -0
  761. package/node_modules/zod/v4/core/checks.d.ts +278 -0
  762. package/node_modules/zod/v4/core/checks.js +575 -0
  763. package/node_modules/zod/v4/core/core.cjs +85 -0
  764. package/node_modules/zod/v4/core/core.d.cts +70 -0
  765. package/node_modules/zod/v4/core/core.d.ts +70 -0
  766. package/node_modules/zod/v4/core/core.js +78 -0
  767. package/node_modules/zod/v4/core/doc.cjs +39 -0
  768. package/node_modules/zod/v4/core/doc.d.cts +14 -0
  769. package/node_modules/zod/v4/core/doc.d.ts +14 -0
  770. package/node_modules/zod/v4/core/doc.js +35 -0
  771. package/node_modules/zod/v4/core/errors.cjs +216 -0
  772. package/node_modules/zod/v4/core/errors.d.cts +221 -0
  773. package/node_modules/zod/v4/core/errors.d.ts +221 -0
  774. package/node_modules/zod/v4/core/errors.js +185 -0
  775. package/node_modules/zod/v4/core/index.cjs +47 -0
  776. package/node_modules/zod/v4/core/index.d.cts +16 -0
  777. package/node_modules/zod/v4/core/index.d.ts +16 -0
  778. package/node_modules/zod/v4/core/index.js +16 -0
  779. package/node_modules/zod/v4/core/json-schema-generator.cjs +99 -0
  780. package/node_modules/zod/v4/core/json-schema-generator.d.cts +65 -0
  781. package/node_modules/zod/v4/core/json-schema-generator.d.ts +65 -0
  782. package/node_modules/zod/v4/core/json-schema-generator.js +95 -0
  783. package/node_modules/zod/v4/core/json-schema-processors.cjs +644 -0
  784. package/node_modules/zod/v4/core/json-schema-processors.d.cts +49 -0
  785. package/node_modules/zod/v4/core/json-schema-processors.d.ts +49 -0
  786. package/node_modules/zod/v4/core/json-schema-processors.js +601 -0
  787. package/node_modules/zod/v4/core/json-schema.cjs +2 -0
  788. package/node_modules/zod/v4/core/json-schema.d.cts +88 -0
  789. package/node_modules/zod/v4/core/json-schema.d.ts +88 -0
  790. package/node_modules/zod/v4/core/json-schema.js +1 -0
  791. package/node_modules/zod/v4/core/package.json +7 -0
  792. package/node_modules/zod/v4/core/parse.cjs +131 -0
  793. package/node_modules/zod/v4/core/parse.d.cts +49 -0
  794. package/node_modules/zod/v4/core/parse.d.ts +49 -0
  795. package/node_modules/zod/v4/core/parse.js +93 -0
  796. package/node_modules/zod/v4/core/regexes.cjs +172 -0
  797. package/node_modules/zod/v4/core/regexes.d.cts +85 -0
  798. package/node_modules/zod/v4/core/regexes.d.ts +85 -0
  799. package/node_modules/zod/v4/core/regexes.js +139 -0
  800. package/node_modules/zod/v4/core/registries.cjs +56 -0
  801. package/node_modules/zod/v4/core/registries.d.cts +35 -0
  802. package/node_modules/zod/v4/core/registries.d.ts +35 -0
  803. package/node_modules/zod/v4/core/registries.js +51 -0
  804. package/node_modules/zod/v4/core/schemas.cjs +2270 -0
  805. package/node_modules/zod/v4/core/schemas.d.cts +1184 -0
  806. package/node_modules/zod/v4/core/schemas.d.ts +1184 -0
  807. package/node_modules/zod/v4/core/schemas.js +2239 -0
  808. package/node_modules/zod/v4/core/standard-schema.cjs +2 -0
  809. package/node_modules/zod/v4/core/standard-schema.d.cts +126 -0
  810. package/node_modules/zod/v4/core/standard-schema.d.ts +126 -0
  811. package/node_modules/zod/v4/core/standard-schema.js +1 -0
  812. package/node_modules/zod/v4/core/to-json-schema.cjs +457 -0
  813. package/node_modules/zod/v4/core/to-json-schema.d.cts +114 -0
  814. package/node_modules/zod/v4/core/to-json-schema.d.ts +114 -0
  815. package/node_modules/zod/v4/core/to-json-schema.js +448 -0
  816. package/node_modules/zod/v4/core/util.cjs +734 -0
  817. package/node_modules/zod/v4/core/util.d.cts +200 -0
  818. package/node_modules/zod/v4/core/util.d.ts +200 -0
  819. package/node_modules/zod/v4/core/util.js +674 -0
  820. package/node_modules/zod/v4/core/versions.cjs +8 -0
  821. package/node_modules/zod/v4/core/versions.d.cts +5 -0
  822. package/node_modules/zod/v4/core/versions.d.ts +5 -0
  823. package/node_modules/zod/v4/core/versions.js +5 -0
  824. package/node_modules/zod/v4/index.cjs +22 -0
  825. package/node_modules/zod/v4/index.d.cts +3 -0
  826. package/node_modules/zod/v4/index.d.ts +3 -0
  827. package/node_modules/zod/v4/index.js +3 -0
  828. package/node_modules/zod/v4/locales/ar.cjs +133 -0
  829. package/node_modules/zod/v4/locales/ar.d.cts +5 -0
  830. package/node_modules/zod/v4/locales/ar.d.ts +4 -0
  831. package/node_modules/zod/v4/locales/ar.js +106 -0
  832. package/node_modules/zod/v4/locales/az.cjs +132 -0
  833. package/node_modules/zod/v4/locales/az.d.cts +5 -0
  834. package/node_modules/zod/v4/locales/az.d.ts +4 -0
  835. package/node_modules/zod/v4/locales/az.js +105 -0
  836. package/node_modules/zod/v4/locales/be.cjs +183 -0
  837. package/node_modules/zod/v4/locales/be.d.cts +5 -0
  838. package/node_modules/zod/v4/locales/be.d.ts +4 -0
  839. package/node_modules/zod/v4/locales/be.js +156 -0
  840. package/node_modules/zod/v4/locales/bg.cjs +147 -0
  841. package/node_modules/zod/v4/locales/bg.d.cts +5 -0
  842. package/node_modules/zod/v4/locales/bg.d.ts +4 -0
  843. package/node_modules/zod/v4/locales/bg.js +120 -0
  844. package/node_modules/zod/v4/locales/ca.cjs +134 -0
  845. package/node_modules/zod/v4/locales/ca.d.cts +5 -0
  846. package/node_modules/zod/v4/locales/ca.d.ts +4 -0
  847. package/node_modules/zod/v4/locales/ca.js +107 -0
  848. package/node_modules/zod/v4/locales/cs.cjs +138 -0
  849. package/node_modules/zod/v4/locales/cs.d.cts +5 -0
  850. package/node_modules/zod/v4/locales/cs.d.ts +4 -0
  851. package/node_modules/zod/v4/locales/cs.js +111 -0
  852. package/node_modules/zod/v4/locales/da.cjs +142 -0
  853. package/node_modules/zod/v4/locales/da.d.cts +5 -0
  854. package/node_modules/zod/v4/locales/da.d.ts +4 -0
  855. package/node_modules/zod/v4/locales/da.js +115 -0
  856. package/node_modules/zod/v4/locales/de.cjs +135 -0
  857. package/node_modules/zod/v4/locales/de.d.cts +5 -0
  858. package/node_modules/zod/v4/locales/de.d.ts +4 -0
  859. package/node_modules/zod/v4/locales/de.js +108 -0
  860. package/node_modules/zod/v4/locales/el.cjs +136 -0
  861. package/node_modules/zod/v4/locales/el.d.cts +5 -0
  862. package/node_modules/zod/v4/locales/el.d.ts +4 -0
  863. package/node_modules/zod/v4/locales/el.js +109 -0
  864. package/node_modules/zod/v4/locales/en.cjs +140 -0
  865. package/node_modules/zod/v4/locales/en.d.cts +5 -0
  866. package/node_modules/zod/v4/locales/en.d.ts +4 -0
  867. package/node_modules/zod/v4/locales/en.js +113 -0
  868. package/node_modules/zod/v4/locales/eo.cjs +136 -0
  869. package/node_modules/zod/v4/locales/eo.d.cts +5 -0
  870. package/node_modules/zod/v4/locales/eo.d.ts +4 -0
  871. package/node_modules/zod/v4/locales/eo.js +109 -0
  872. package/node_modules/zod/v4/locales/es.cjs +159 -0
  873. package/node_modules/zod/v4/locales/es.d.cts +5 -0
  874. package/node_modules/zod/v4/locales/es.d.ts +4 -0
  875. package/node_modules/zod/v4/locales/es.js +132 -0
  876. package/node_modules/zod/v4/locales/fa.cjs +141 -0
  877. package/node_modules/zod/v4/locales/fa.d.cts +5 -0
  878. package/node_modules/zod/v4/locales/fa.d.ts +4 -0
  879. package/node_modules/zod/v4/locales/fa.js +114 -0
  880. package/node_modules/zod/v4/locales/fi.cjs +139 -0
  881. package/node_modules/zod/v4/locales/fi.d.cts +5 -0
  882. package/node_modules/zod/v4/locales/fi.d.ts +4 -0
  883. package/node_modules/zod/v4/locales/fi.js +112 -0
  884. package/node_modules/zod/v4/locales/fr-CA.cjs +134 -0
  885. package/node_modules/zod/v4/locales/fr-CA.d.cts +5 -0
  886. package/node_modules/zod/v4/locales/fr-CA.d.ts +4 -0
  887. package/node_modules/zod/v4/locales/fr-CA.js +107 -0
  888. package/node_modules/zod/v4/locales/fr.cjs +152 -0
  889. package/node_modules/zod/v4/locales/fr.d.cts +5 -0
  890. package/node_modules/zod/v4/locales/fr.d.ts +4 -0
  891. package/node_modules/zod/v4/locales/fr.js +125 -0
  892. package/node_modules/zod/v4/locales/he.cjs +241 -0
  893. package/node_modules/zod/v4/locales/he.d.cts +5 -0
  894. package/node_modules/zod/v4/locales/he.d.ts +4 -0
  895. package/node_modules/zod/v4/locales/he.js +214 -0
  896. package/node_modules/zod/v4/locales/hr.cjs +149 -0
  897. package/node_modules/zod/v4/locales/hr.d.cts +5 -0
  898. package/node_modules/zod/v4/locales/hr.d.ts +4 -0
  899. package/node_modules/zod/v4/locales/hr.js +122 -0
  900. package/node_modules/zod/v4/locales/hu.cjs +135 -0
  901. package/node_modules/zod/v4/locales/hu.d.cts +5 -0
  902. package/node_modules/zod/v4/locales/hu.d.ts +4 -0
  903. package/node_modules/zod/v4/locales/hu.js +108 -0
  904. package/node_modules/zod/v4/locales/hy.cjs +174 -0
  905. package/node_modules/zod/v4/locales/hy.d.cts +5 -0
  906. package/node_modules/zod/v4/locales/hy.d.ts +4 -0
  907. package/node_modules/zod/v4/locales/hy.js +147 -0
  908. package/node_modules/zod/v4/locales/id.cjs +133 -0
  909. package/node_modules/zod/v4/locales/id.d.cts +5 -0
  910. package/node_modules/zod/v4/locales/id.d.ts +4 -0
  911. package/node_modules/zod/v4/locales/id.js +106 -0
  912. package/node_modules/zod/v4/locales/index.cjs +111 -0
  913. package/node_modules/zod/v4/locales/index.d.cts +52 -0
  914. package/node_modules/zod/v4/locales/index.d.ts +52 -0
  915. package/node_modules/zod/v4/locales/index.js +52 -0
  916. package/node_modules/zod/v4/locales/is.cjs +136 -0
  917. package/node_modules/zod/v4/locales/is.d.cts +5 -0
  918. package/node_modules/zod/v4/locales/is.d.ts +4 -0
  919. package/node_modules/zod/v4/locales/is.js +109 -0
  920. package/node_modules/zod/v4/locales/it.cjs +135 -0
  921. package/node_modules/zod/v4/locales/it.d.cts +5 -0
  922. package/node_modules/zod/v4/locales/it.d.ts +4 -0
  923. package/node_modules/zod/v4/locales/it.js +108 -0
  924. package/node_modules/zod/v4/locales/ja.cjs +134 -0
  925. package/node_modules/zod/v4/locales/ja.d.cts +5 -0
  926. package/node_modules/zod/v4/locales/ja.d.ts +4 -0
  927. package/node_modules/zod/v4/locales/ja.js +107 -0
  928. package/node_modules/zod/v4/locales/ka.cjs +139 -0
  929. package/node_modules/zod/v4/locales/ka.d.cts +5 -0
  930. package/node_modules/zod/v4/locales/ka.d.ts +4 -0
  931. package/node_modules/zod/v4/locales/ka.js +112 -0
  932. package/node_modules/zod/v4/locales/kh.cjs +12 -0
  933. package/node_modules/zod/v4/locales/kh.d.cts +5 -0
  934. package/node_modules/zod/v4/locales/kh.d.ts +5 -0
  935. package/node_modules/zod/v4/locales/kh.js +5 -0
  936. package/node_modules/zod/v4/locales/km.cjs +137 -0
  937. package/node_modules/zod/v4/locales/km.d.cts +5 -0
  938. package/node_modules/zod/v4/locales/km.d.ts +4 -0
  939. package/node_modules/zod/v4/locales/km.js +110 -0
  940. package/node_modules/zod/v4/locales/ko.cjs +138 -0
  941. package/node_modules/zod/v4/locales/ko.d.cts +5 -0
  942. package/node_modules/zod/v4/locales/ko.d.ts +4 -0
  943. package/node_modules/zod/v4/locales/ko.js +111 -0
  944. package/node_modules/zod/v4/locales/lt.cjs +230 -0
  945. package/node_modules/zod/v4/locales/lt.d.cts +5 -0
  946. package/node_modules/zod/v4/locales/lt.d.ts +4 -0
  947. package/node_modules/zod/v4/locales/lt.js +203 -0
  948. package/node_modules/zod/v4/locales/mk.cjs +136 -0
  949. package/node_modules/zod/v4/locales/mk.d.cts +5 -0
  950. package/node_modules/zod/v4/locales/mk.d.ts +4 -0
  951. package/node_modules/zod/v4/locales/mk.js +109 -0
  952. package/node_modules/zod/v4/locales/ms.cjs +134 -0
  953. package/node_modules/zod/v4/locales/ms.d.cts +5 -0
  954. package/node_modules/zod/v4/locales/ms.d.ts +4 -0
  955. package/node_modules/zod/v4/locales/ms.js +107 -0
  956. package/node_modules/zod/v4/locales/nl.cjs +137 -0
  957. package/node_modules/zod/v4/locales/nl.d.cts +5 -0
  958. package/node_modules/zod/v4/locales/nl.d.ts +4 -0
  959. package/node_modules/zod/v4/locales/nl.js +110 -0
  960. package/node_modules/zod/v4/locales/no.cjs +135 -0
  961. package/node_modules/zod/v4/locales/no.d.cts +5 -0
  962. package/node_modules/zod/v4/locales/no.d.ts +4 -0
  963. package/node_modules/zod/v4/locales/no.js +108 -0
  964. package/node_modules/zod/v4/locales/ota.cjs +136 -0
  965. package/node_modules/zod/v4/locales/ota.d.cts +5 -0
  966. package/node_modules/zod/v4/locales/ota.d.ts +4 -0
  967. package/node_modules/zod/v4/locales/ota.js +109 -0
  968. package/node_modules/zod/v4/locales/package.json +7 -0
  969. package/node_modules/zod/v4/locales/pl.cjs +136 -0
  970. package/node_modules/zod/v4/locales/pl.d.cts +5 -0
  971. package/node_modules/zod/v4/locales/pl.d.ts +4 -0
  972. package/node_modules/zod/v4/locales/pl.js +109 -0
  973. package/node_modules/zod/v4/locales/ps.cjs +141 -0
  974. package/node_modules/zod/v4/locales/ps.d.cts +5 -0
  975. package/node_modules/zod/v4/locales/ps.d.ts +4 -0
  976. package/node_modules/zod/v4/locales/ps.js +114 -0
  977. package/node_modules/zod/v4/locales/pt.cjs +135 -0
  978. package/node_modules/zod/v4/locales/pt.d.cts +5 -0
  979. package/node_modules/zod/v4/locales/pt.d.ts +4 -0
  980. package/node_modules/zod/v4/locales/pt.js +108 -0
  981. package/node_modules/zod/v4/locales/ro.cjs +146 -0
  982. package/node_modules/zod/v4/locales/ro.d.cts +5 -0
  983. package/node_modules/zod/v4/locales/ro.d.ts +4 -0
  984. package/node_modules/zod/v4/locales/ro.js +119 -0
  985. package/node_modules/zod/v4/locales/ru.cjs +183 -0
  986. package/node_modules/zod/v4/locales/ru.d.cts +5 -0
  987. package/node_modules/zod/v4/locales/ru.d.ts +4 -0
  988. package/node_modules/zod/v4/locales/ru.js +156 -0
  989. package/node_modules/zod/v4/locales/sl.cjs +136 -0
  990. package/node_modules/zod/v4/locales/sl.d.cts +5 -0
  991. package/node_modules/zod/v4/locales/sl.d.ts +4 -0
  992. package/node_modules/zod/v4/locales/sl.js +109 -0
  993. package/node_modules/zod/v4/locales/sv.cjs +137 -0
  994. package/node_modules/zod/v4/locales/sv.d.cts +5 -0
  995. package/node_modules/zod/v4/locales/sv.d.ts +4 -0
  996. package/node_modules/zod/v4/locales/sv.js +110 -0
  997. package/node_modules/zod/v4/locales/ta.cjs +137 -0
  998. package/node_modules/zod/v4/locales/ta.d.cts +5 -0
  999. package/node_modules/zod/v4/locales/ta.d.ts +4 -0
  1000. package/node_modules/zod/v4/locales/ta.js +110 -0
  1001. package/node_modules/zod/v4/locales/th.cjs +137 -0
  1002. package/node_modules/zod/v4/locales/th.d.cts +5 -0
  1003. package/node_modules/zod/v4/locales/th.d.ts +4 -0
  1004. package/node_modules/zod/v4/locales/th.js +110 -0
  1005. package/node_modules/zod/v4/locales/tr.cjs +132 -0
  1006. package/node_modules/zod/v4/locales/tr.d.cts +5 -0
  1007. package/node_modules/zod/v4/locales/tr.d.ts +4 -0
  1008. package/node_modules/zod/v4/locales/tr.js +105 -0
  1009. package/node_modules/zod/v4/locales/ua.cjs +12 -0
  1010. package/node_modules/zod/v4/locales/ua.d.cts +5 -0
  1011. package/node_modules/zod/v4/locales/ua.d.ts +5 -0
  1012. package/node_modules/zod/v4/locales/ua.js +5 -0
  1013. package/node_modules/zod/v4/locales/uk.cjs +135 -0
  1014. package/node_modules/zod/v4/locales/uk.d.cts +5 -0
  1015. package/node_modules/zod/v4/locales/uk.d.ts +4 -0
  1016. package/node_modules/zod/v4/locales/uk.js +108 -0
  1017. package/node_modules/zod/v4/locales/ur.cjs +137 -0
  1018. package/node_modules/zod/v4/locales/ur.d.cts +5 -0
  1019. package/node_modules/zod/v4/locales/ur.d.ts +4 -0
  1020. package/node_modules/zod/v4/locales/ur.js +110 -0
  1021. package/node_modules/zod/v4/locales/uz.cjs +137 -0
  1022. package/node_modules/zod/v4/locales/uz.d.cts +5 -0
  1023. package/node_modules/zod/v4/locales/uz.d.ts +4 -0
  1024. package/node_modules/zod/v4/locales/uz.js +110 -0
  1025. package/node_modules/zod/v4/locales/vi.cjs +135 -0
  1026. package/node_modules/zod/v4/locales/vi.d.cts +5 -0
  1027. package/node_modules/zod/v4/locales/vi.d.ts +4 -0
  1028. package/node_modules/zod/v4/locales/vi.js +108 -0
  1029. package/node_modules/zod/v4/locales/yo.cjs +134 -0
  1030. package/node_modules/zod/v4/locales/yo.d.cts +5 -0
  1031. package/node_modules/zod/v4/locales/yo.d.ts +4 -0
  1032. package/node_modules/zod/v4/locales/yo.js +107 -0
  1033. package/node_modules/zod/v4/locales/zh-CN.cjs +136 -0
  1034. package/node_modules/zod/v4/locales/zh-CN.d.cts +5 -0
  1035. package/node_modules/zod/v4/locales/zh-CN.d.ts +4 -0
  1036. package/node_modules/zod/v4/locales/zh-CN.js +109 -0
  1037. package/node_modules/zod/v4/locales/zh-TW.cjs +134 -0
  1038. package/node_modules/zod/v4/locales/zh-TW.d.cts +5 -0
  1039. package/node_modules/zod/v4/locales/zh-TW.d.ts +4 -0
  1040. package/node_modules/zod/v4/locales/zh-TW.js +107 -0
  1041. package/node_modules/zod/v4/mini/checks.cjs +34 -0
  1042. package/node_modules/zod/v4/mini/checks.d.cts +1 -0
  1043. package/node_modules/zod/v4/mini/checks.d.ts +1 -0
  1044. package/node_modules/zod/v4/mini/checks.js +1 -0
  1045. package/node_modules/zod/v4/mini/coerce.cjs +52 -0
  1046. package/node_modules/zod/v4/mini/coerce.d.cts +7 -0
  1047. package/node_modules/zod/v4/mini/coerce.d.ts +7 -0
  1048. package/node_modules/zod/v4/mini/coerce.js +22 -0
  1049. package/node_modules/zod/v4/mini/external.cjs +63 -0
  1050. package/node_modules/zod/v4/mini/external.d.cts +13 -0
  1051. package/node_modules/zod/v4/mini/external.d.ts +13 -0
  1052. package/node_modules/zod/v4/mini/external.js +14 -0
  1053. package/node_modules/zod/v4/mini/index.cjs +32 -0
  1054. package/node_modules/zod/v4/mini/index.d.cts +3 -0
  1055. package/node_modules/zod/v4/mini/index.d.ts +3 -0
  1056. package/node_modules/zod/v4/mini/index.js +3 -0
  1057. package/node_modules/zod/v4/mini/iso.cjs +64 -0
  1058. package/node_modules/zod/v4/mini/iso.d.cts +22 -0
  1059. package/node_modules/zod/v4/mini/iso.d.ts +22 -0
  1060. package/node_modules/zod/v4/mini/iso.js +34 -0
  1061. package/node_modules/zod/v4/mini/package.json +7 -0
  1062. package/node_modules/zod/v4/mini/parse.cjs +16 -0
  1063. package/node_modules/zod/v4/mini/parse.d.cts +1 -0
  1064. package/node_modules/zod/v4/mini/parse.d.ts +1 -0
  1065. package/node_modules/zod/v4/mini/parse.js +1 -0
  1066. package/node_modules/zod/v4/mini/schemas.cjs +1083 -0
  1067. package/node_modules/zod/v4/mini/schemas.d.cts +445 -0
  1068. package/node_modules/zod/v4/mini/schemas.d.ts +445 -0
  1069. package/node_modules/zod/v4/mini/schemas.js +961 -0
  1070. package/node_modules/zod/v4/package.json +7 -0
  1071. package/node_modules/zod/v4-mini/index.cjs +32 -0
  1072. package/node_modules/zod/v4-mini/index.d.cts +3 -0
  1073. package/node_modules/zod/v4-mini/index.d.ts +3 -0
  1074. package/node_modules/zod/v4-mini/index.js +3 -0
  1075. package/node_modules/zod/v4-mini/package.json +7 -0
  1076. package/package.json +26 -10
  1077. package/dist/chunk-Q4PUTBMV.js.map +0 -1
  1078. package/dist/chunk-RQRT27Q3.js.map +0 -1
  1079. package/dist/chunk-SFI2T6TE.js.map +0 -1
  1080. package/dist/chunk-UDLRVMML.js.map +0 -1
  1081. package/dist/public-route-7IK5D7V7.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/react/runtime/bootstrap-view.tsx","../../src/react/components/error-boundary.tsx","../../src/react/runtime/view-config.ts","../../src/react/runtime/view-runtime-context.tsx","../../src/react/runtime/view-runtime.ts","../../src/react/types/result-types.ts","../../src/react/runtime/model-context-store.ts","../../src/react/public-assets.ts","../../src/react/components/image.tsx","../../src/react/components/model-context.tsx","../../src/react/components/theme-provider.tsx","../../src/react/components/view-controls.tsx","../../src/react/hooks/use-display-mode.ts","../../src/react/hooks/use-host-context.ts","../../src/react/hooks/use-tool-context.ts","../../src/react/hooks/use-call-tool.ts","../../src/react/hooks/use-open-external.ts","../../src/react/hooks/use-send-follow-up.ts","../../src/react/hooks/use-send-size-changed.ts","../../src/react/hooks/use-view-theme.ts","../../src/react/hooks/use-view-tool.ts","../../src/tools.ts"],"sourcesContent":["import { createRoot, type Root } from \"react-dom/client\";\nimport type { ComponentType } from \"react\";\n\nimport { ErrorBoundary } from \"../components/error-boundary.js\";\nimport {\n normalizeViewConfig,\n type NormalizedViewConfig,\n type ViewConfig,\n} from \"./view-config.js\";\nimport { ViewRuntimeProvider } from \"./view-runtime-context.js\";\nimport {\n createMcpAppRuntime,\n setActiveRuntime,\n takePendingTestTransport,\n _registerDisposeViewForTesting,\n type McpAppRuntime,\n type ViewRuntimeTransport,\n} from \"./view-runtime.js\";\n\n/**\n * One mounted MCP App view per iframe document.\n *\n * Attached to `document` via a module-private symbol so HMR of the view\n * module reuses the same record without a module-level `Map` keyed by root id.\n */\ninterface MountedView {\n /** DOM id of the React mount container. */\n rootId: string;\n /** React root created for this mount. */\n root: Root;\n /** Document-owned {@link McpAppRuntime}. */\n runtime: McpAppRuntime;\n /** Normalized config fixed at first mount (HMR must not change it). */\n config: NormalizedViewConfig;\n}\n\n/**\n * Module-private symbol property key for the document mount record.\n *\n * A plain `Symbol` (not `Symbol.for`) keeps the key unforgeable from other\n * modules: only this bootstrap module can read or write the mount record.\n * View-module HMR re-enters {@link bootstrapView} without reloading this\n * module, so the symbol identity is stable for the iframe lifetime.\n */\nconst MOUNTED_VIEW: unique symbol = Symbol(\"mcp-use.mountedView\");\n\ntype DocumentWithMount = Document & {\n [MOUNTED_VIEW]?: MountedView;\n};\n\nfunction readMountedView(): MountedView | undefined {\n return (document as DocumentWithMount)[MOUNTED_VIEW];\n}\n\nfunction writeMountedView(mounted: MountedView): void {\n (document as DocumentWithMount)[MOUNTED_VIEW] = mounted;\n}\n\nfunction clearMountedView(): void {\n delete (document as DocumentWithMount)[MOUNTED_VIEW];\n}\n\nfunction configsEqual(\n a: NormalizedViewConfig,\n b: NormalizedViewConfig\n): boolean {\n if (a.autoResize !== b.autoResize) return false;\n if (a.displayModes.length !== b.displayModes.length) return false;\n return a.displayModes.every((mode, index) => mode === b.displayModes[index]);\n}\n\nfunction renderView(mounted: MountedView, View: ComponentType): void {\n mounted.root.render(\n <ErrorBoundary>\n <ViewRuntimeProvider runtime={mounted.runtime}>\n <View />\n </ViewRuntimeProvider>\n </ErrorBoundary>\n );\n}\n\n/** @internal Module shape of a `view.tsx` file. */\nexport interface ViewModule {\n /** Default view component — reads data via hooks. */\n default: ComponentType;\n /**\n * Optional immutable pre-render runtime configuration.\n *\n * Normalized before the guest `App` is constructed. See {@link ViewConfig}.\n */\n viewConfig?: ViewConfig;\n}\n\n/**\n * Mount options for {@link bootstrapView}.\n *\n * @internal\n */\nexport interface BootstrapViewOptions {\n /** DOM id of the mount container; created if missing. @defaultValue `\"root\"` */\n rootId?: string;\n /**\n * Guest transport injected for tests. When omitted, consumes any transport\n * queued by `_setTransportForTesting`, otherwise uses postMessage.\n *\n * @internal\n */\n transport?: ViewRuntimeTransport;\n}\n\n/**\n * Mount a view module into the iframe document: normalizes\n * {@link ViewModule.viewConfig}, creates a {@link McpAppRuntime}, starts\n * `connect()` (declaring `tools: { listChanged: true }` and normalized\n * `availableDisplayModes`), renders the default export immediately (the\n * component reads data via hooks while the handshake is in progress), and\n * wraps everything in an error boundary.\n *\n * Auto-resize is on by default. Opt out with\n * `viewConfig.autoResize: false` and report size via\n * {@link useSendSizeChanged}.\n *\n * Repeated bootstrap for the same `rootId` reuses the mounted root and\n * runtime (HMR) without reconnecting. A second `rootId` while one view is\n * mounted throws. Call {@link disposeView} to unmount and allow a fresh\n * bootstrap.\n *\n * @param module - The view module (`default` component and optional\n * `viewConfig`).\n * @param options - Mount options.\n * @throws When `viewConfig.displayModes` is empty, duplicated, missing\n * `\"inline\"`, or contains an unknown mode.\n * @throws When a view is already mounted on a different `rootId` in this\n * document.\n *\n * @internal\n */\nexport function bootstrapView(\n module: ViewModule,\n options?: BootstrapViewOptions\n): void {\n if (typeof document === \"undefined\") {\n throw new Error(\"bootstrapView requires a browser document\");\n }\n\n const normalized = normalizeViewConfig(module.viewConfig);\n const rootId = options?.rootId ?? \"root\";\n const existing = readMountedView();\n\n if (existing) {\n if (existing.rootId !== rootId) {\n throw new Error(\n `bootstrapView: a view is already mounted on \"#${existing.rootId}\"; cannot mount a second root \"#${rootId}\" in the same document`\n );\n }\n\n if (!configsEqual(existing.config, normalized)) {\n console.warn(\n \"[mcp-use] viewConfig changed during HMR (autoResize / displayModes). \" +\n \"A full iframe reload is required for configuration changes to take effect; \" +\n \"the mounted runtime keeps the original configuration.\"\n );\n }\n\n renderView(existing, module.default);\n return;\n }\n\n let container = document.getElementById(rootId);\n if (!container) {\n container = document.createElement(\"div\");\n container.id = rootId;\n document.body.appendChild(container);\n }\n\n const transport = options?.transport ?? takePendingTestTransport();\n const runtime = createMcpAppRuntime(normalized, {\n ...(transport !== undefined && { transport }),\n });\n setActiveRuntime(runtime);\n // Start connect before React mounts; attach rejection handling immediately\n // so a failed handshake is logged and does not become an unhandled rejection.\n void runtime.connect().catch((error: unknown) => {\n console.error(\"[mcp-use] Failed to connect view runtime:\", error);\n });\n\n const root = createRoot(container);\n const mounted: MountedView = {\n rootId,\n root,\n runtime,\n config: normalized,\n };\n writeMountedView(mounted);\n renderView(mounted, module.default);\n}\n\n/**\n * Unmount the document's view and dispose its {@link McpAppRuntime}.\n *\n * React unmounts first so hook cleanup (e.g. {@link useViewTool} removal) can\n * run while the App connection still exists; then the runtime closes the App\n * and transport. After this resolves, {@link bootstrapView} may create a\n * fresh runtime.\n *\n * No-ops when nothing is mounted.\n *\n * @example\n * ```ts\n * await disposeView();\n * ```\n */\nexport async function disposeView(): Promise<void> {\n if (typeof document === \"undefined\") {\n return;\n }\n\n const mounted = readMountedView();\n if (!mounted) return;\n\n // Unmount React before closing the App so hook cleanup (view-tool remove)\n // runs while the connection still exists.\n try {\n mounted.root.unmount();\n } catch {\n // Container may already be detached by test teardown.\n }\n\n // Drop the mount record before awaiting App close so a subsequent\n // bootstrapView (or sync test reset) does not reuse a half-disposed runtime.\n clearMountedView();\n await mounted.runtime.dispose();\n}\n\n/**\n * @internal Clear the document mount via {@link disposeView} between tests.\n */\nexport function _resetBootstrapRootsForTesting(): void {\n void disposeView();\n}\n\n// Wire the real disposal path into the view-runtime test seam without a\n// circular static import from view-runtime → bootstrap-view.\n_registerDisposeViewForTesting(disposeView);\n","import React from \"react\";\n\ninterface ErrorBoundaryProps {\n children: React.ReactNode;\n /** Custom fallback when an error is caught. */\n fallback?: React.ReactNode | ((error: Error) => React.ReactNode);\n /** Invoked when an error is caught. */\n onError?: (error: Error, errorInfo: React.ErrorInfo) => void;\n}\n\n/**\n * Catches React errors in the view tree and renders a fallback instead of\n * crashing the iframe.\n */\nexport class ErrorBoundary extends React.Component<\n ErrorBoundaryProps,\n { hasError: boolean; error: Error | null }\n> {\n constructor(props: ErrorBoundaryProps) {\n super(props);\n this.state = { hasError: false, error: null };\n }\n\n static getDerivedStateFromError(error: Error) {\n return { hasError: true, error };\n }\n\n override componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {\n console.error(\"[mcp-use] View error:\", error, errorInfo);\n this.props.onError?.(error, errorInfo);\n }\n\n override render() {\n if (this.state.hasError && this.state.error) {\n if (this.props.fallback !== undefined) {\n return typeof this.props.fallback === \"function\"\n ? this.props.fallback(this.state.error)\n : this.props.fallback;\n }\n\n return (\n <div\n style={{\n padding: \"1rem\",\n border: \"1px solid #ef4444\",\n borderRadius: \"0.375rem\",\n background: \"#fef2f2\",\n color: \"#7f1d1d\",\n }}\n >\n <strong>View error</strong>\n <pre style={{ marginTop: \"0.5rem\", whiteSpace: \"pre-wrap\" }}>\n {this.state.error.message}\n </pre>\n </div>\n );\n }\n\n return this.props.children;\n }\n}\n","import type { DisplayMode } from \"../types/host-types.js\";\n\n/**\n * Immutable pre-render runtime configuration for a view module.\n *\n * Export as a named `viewConfig` alongside the default component. Values are\n * normalized and validated by `bootstrapView` before the guest `App` is\n * constructed. React presentation settings do not belong here — compose\n * {@link ThemeProvider} / {@link ViewControls} in the component tree instead.\n *\n * @example\n * ```tsx\n * import type { ViewConfig } from \"mcp-use/react\";\n *\n * export const viewConfig = {\n * autoResize: false,\n * displayModes: [\"inline\", \"fullscreen\"],\n * } satisfies ViewConfig;\n *\n * export default function CanvasView() {\n * return <Canvas />;\n * }\n * ```\n */\nexport interface ViewConfig {\n /**\n * Let ext-apps observe the document and report size changes.\n *\n * @defaultValue true\n */\n autoResize?: boolean;\n\n /**\n * Display modes this view can render correctly.\n *\n * Must contain \"inline\".\n *\n * @defaultValue [\"inline\", \"fullscreen\", \"pip\"]\n */\n displayModes?: readonly DisplayMode[];\n}\n\n/**\n * Fully-resolved {@link ViewConfig} with every field required.\n *\n * @internal\n */\nexport interface NormalizedViewConfig {\n /** Whether the guest `App` auto-measures and reports size changes. */\n autoResize: boolean;\n /** Display modes advertised to the host via App capabilities. */\n displayModes: readonly DisplayMode[];\n}\n\nconst DEFAULT_DISPLAY_MODES: readonly DisplayMode[] = [\n \"inline\",\n \"fullscreen\",\n \"pip\",\n];\n\nconst VALID_DISPLAY_MODES: ReadonlySet<string> = new Set<DisplayMode>([\n \"inline\",\n \"fullscreen\",\n \"pip\",\n]);\n\n/**\n * Normalize and validate an optional {@link ViewConfig}.\n *\n * @param config - Optional named export from a view module.\n * @returns A fully-resolved config with defaults applied.\n * @throws When `displayModes` is empty, contains duplicates, omits `\"inline\"`,\n * or includes a value that is not a known {@link DisplayMode}.\n *\n * @internal\n */\nexport function normalizeViewConfig(config?: ViewConfig): NormalizedViewConfig {\n const autoResize = config?.autoResize ?? true;\n\n if (config?.displayModes === undefined) {\n return { autoResize, displayModes: DEFAULT_DISPLAY_MODES };\n }\n\n const modes = config.displayModes;\n if (!Array.isArray(modes) || modes.length === 0) {\n throw new Error(\n 'viewConfig.displayModes must be a non-empty array that includes \"inline\"'\n );\n }\n\n const seen = new Set<string>();\n const normalizedModes: DisplayMode[] = [];\n for (const mode of modes) {\n if (typeof mode !== \"string\" || !VALID_DISPLAY_MODES.has(mode)) {\n throw new Error(\n `viewConfig.displayModes contains invalid mode ${JSON.stringify(mode)}; expected \"inline\", \"fullscreen\", or \"pip\"`\n );\n }\n if (seen.has(mode)) {\n throw new Error(\n `viewConfig.displayModes contains duplicate mode \"${mode}\"`\n );\n }\n seen.add(mode);\n // Validated against VALID_DISPLAY_MODES above.\n normalizedModes.push(mode as DisplayMode);\n }\n\n if (!seen.has(\"inline\")) {\n throw new Error('viewConfig.displayModes must include \"inline\"');\n }\n\n return {\n autoResize,\n displayModes: normalizedModes,\n };\n}\n","import type { McpUiHostContext } from \"@modelcontextprotocol/ext-apps\";\nimport {\n createContext,\n useContext,\n useSyncExternalStore,\n type ReactNode,\n} from \"react\";\n\nimport type { McpAppRuntime } from \"./view-runtime.js\";\n\n/**\n * React context holding the document's {@link McpAppRuntime}.\n *\n * `null` outside bootstrap — hooks throw via {@link useViewRuntime}.\n *\n * @internal\n */\nexport const ViewRuntimeContext = createContext<McpAppRuntime | null>(null);\n\n/**\n * Provide a {@link McpAppRuntime} to the view tree.\n *\n * Connection is started by {@link bootstrapView} before render. Model-context\n * delivery is owned by the runtime's {@link McpAppRuntime.modelContextStore};\n * this provider only exposes the runtime through context.\n *\n * @param props - Provider props.\n * @param props.runtime - Runtime created by bootstrap for this mount.\n * @param props.children - View tree.\n *\n * @internal\n */\nexport function ViewRuntimeProvider({\n runtime,\n children,\n}: {\n runtime: McpAppRuntime;\n children: ReactNode;\n}) {\n return (\n <ViewRuntimeContext.Provider value={runtime}>\n {children}\n </ViewRuntimeContext.Provider>\n );\n}\n\n/**\n * Read the current {@link McpAppRuntime} from context.\n *\n * @throws When called outside a {@link bootstrapView}-mounted tree.\n *\n * @internal\n */\nexport function useViewRuntime(): McpAppRuntime {\n const runtime = useContext(ViewRuntimeContext);\n if (!runtime) {\n throw new Error(\n \"mcp-use/react hooks require a browser view mounted by bootstrapView\"\n );\n }\n return runtime;\n}\n\n/**\n * Subscribe to host context only — re-renders when `hostContext` identity\n * changes (connection-only updates that keep the same context object do not).\n *\n * Used by {@link ThemeProvider} for theme, style variables, and fonts.\n *\n * @internal\n */\nexport function useHostContextSubscription(): McpUiHostContext | undefined {\n const runtime = useViewRuntime();\n return useSyncExternalStore(\n runtime.subscribeHost,\n () => runtime.getHostSnapshot().hostContext\n );\n}\n","import {\n App,\n PostMessageTransport,\n type McpUiHostContext,\n type RegisteredAppTool,\n} from \"@modelcontextprotocol/ext-apps\";\nimport type {\n CallToolResult,\n ContentBlock,\n} from \"@modelcontextprotocol/server\";\n\nimport type { DisplayMode } from \"../types/host-types.js\";\nimport { ToolError, type ToolContextError } from \"../types/result-types.js\";\nimport { ModelContextStore } from \"./model-context-store.js\";\nimport type { NormalizedViewConfig } from \"./view-config.js\";\n\n/** Transport accepted by {@link App.connect}. */\nexport type ViewRuntimeTransport = NonNullable<Parameters<App[\"connect\"]>[0]>;\n\ntype Listener = () => void;\n\n/**\n * Tool-channel snapshot for the invocation that rendered this View.\n *\n * Input notifications replace `toolInput` while the invocation is pending.\n * The first structured result or tool error latches a terminal state; all\n * later ambient lifecycle notifications are ignored.\n *\n * @internal\n */\nexport interface ToolSnapshot {\n /** Pending until the first structured result or tool error, then terminal. */\n status: \"pending\" | \"ready\" | \"error\";\n /** Model-visible tool output from the last ready result's `structuredContent`. */\n toolOutput: unknown;\n /** Model-visible content blocks from the last tool result (ready or error). */\n content: ContentBlock[] | undefined;\n /**\n * Latest progressive tool arguments from the host. Partial and complete\n * notifications replace the same snapshot; last write wins.\n */\n toolInput: Record<string, unknown> | undefined;\n /** View-only result `_meta` channel. */\n meta: Record<string, unknown> | undefined;\n /**\n * Tool error for the rendering invocation.\n */\n error: ToolContextError | undefined;\n}\n\n/**\n * Host-channel snapshot: negotiated host context and connection status.\n *\n * @internal\n */\nexport interface HostSnapshot {\n /** Current host context (updated on `host-context-changed`). */\n hostContext: McpUiHostContext | undefined;\n /** Whether the App handshake completed. */\n isConnected: boolean;\n /** Terminal connection failure for this mount, if any. */\n connectionError: Error | undefined;\n}\n\n/**\n * Display-channel snapshot: current mode and negotiated available modes.\n *\n * @internal\n */\nexport interface DisplaySnapshot {\n /** How the host is currently displaying the view. */\n displayMode: DisplayMode;\n /**\n * Negotiated modes: intersection of normalized\n * {@link NormalizedViewConfig.displayModes} and\n * `hostContext.availableDisplayModes`. When the host omits available modes,\n * only `\"inline\"`.\n */\n availableDisplayModes: readonly DisplayMode[];\n}\n\n/**\n * Parameters for {@link McpAppRuntime.callServerTool}.\n *\n * @internal\n */\nexport type CallToolParams = Parameters<App[\"callServerTool\"]>[0];\n\n/**\n * Parameters for {@link McpAppRuntime.sendMessage}.\n *\n * @internal\n */\nexport type SendMessageParams = Parameters<App[\"sendMessage\"]>[0];\n\n/**\n * Parameters for {@link McpAppRuntime.openLink}.\n *\n * @internal\n */\nexport type OpenLinkParams = Parameters<App[\"openLink\"]>[0];\n\n/**\n * Parameters for {@link McpAppRuntime.requestDisplayMode}.\n *\n * @internal\n */\nexport type RequestDisplayModeParams = Parameters<App[\"requestDisplayMode\"]>[0];\n\n/**\n * Parameters for {@link McpAppRuntime.sendSizeChanged}.\n *\n * @internal\n */\nexport type SizeChangedParams = Parameters<App[\"sendSizeChanged\"]>[0];\n\n/**\n * Config passed to {@link McpAppRuntime.registerViewTool} (ext-apps shape).\n *\n * @internal\n */\nexport type ViewToolConfig = Parameters<App[\"registerTool\"]>[1];\n\n/**\n * Callback passed to {@link McpAppRuntime.registerViewTool}.\n *\n * @internal\n */\nexport type ViewToolCallback = Parameters<App[\"registerTool\"]>[2];\n\n/**\n * Per-document MCP Apps runtime: owns one guest {@link App}, one cached\n * connection attempt, tool-handler handoff, narrow external-store channels,\n * one {@link ModelContextStore}, and disposal.\n *\n * Created by {@link createMcpAppRuntime} / {@link bootstrapView}. Hooks obtain\n * the instance from {@link ViewRuntimeContext}.\n *\n * @internal\n */\nexport interface McpAppRuntime {\n /** Normalized immutable view configuration fixed at construction. */\n readonly config: NormalizedViewConfig;\n\n /**\n * Per-runtime model-context node tree and async flush pump.\n *\n * Constructed with this runtime and disposed with it. React components obtain\n * it via {@link useViewRuntime}; the imperative `modelContext` API delegates\n * to the active document runtime's store.\n */\n readonly modelContextStore: ModelContextStore;\n\n /** Connect once, or return the cached in-flight / settled connection promise. */\n connect(): Promise<App>;\n /**\n * Dispose the model-context store (so late in-flight completions are\n * ignored), prevent late event delivery, clear listeners and snapshots, and\n * close the App/transport.\n *\n * Callers should unmount the view tree first (see `disposeView`) so hook\n * cleanup can run while the App connection still exists.\n */\n dispose(): Promise<void>;\n\n /** Subscribe to tool-channel changes. */\n subscribeTool(listener: Listener): () => void;\n /** Current tool-channel snapshot (stable until a tool field changes). */\n getToolSnapshot(): ToolSnapshot;\n\n /** Subscribe to host-channel changes. */\n subscribeHost(listener: Listener): () => void;\n /** Current host-channel snapshot (stable until host/connection fields change). */\n getHostSnapshot(): HostSnapshot;\n\n /** Subscribe to theme-channel changes. */\n subscribeTheme(listener: Listener): () => void;\n /** Current theme (`\"light\"` until the host reports otherwise). Primitive; stable until theme changes. */\n getThemeSnapshot(): \"light\" | \"dark\";\n\n /** Subscribe to display-channel changes. */\n subscribeDisplay(listener: Listener): () => void;\n /**\n * Current display-channel snapshot (stable until `displayMode` or\n * negotiated `availableDisplayModes` change).\n */\n getDisplaySnapshot(): DisplaySnapshot;\n\n /** Runtime-owned guest {@link App}, or `null` after disposal. */\n getApp(): App | null;\n\n /** Call a server tool through the host. */\n callServerTool(params: CallToolParams): Promise<CallToolResult>;\n /** Send a follow-up message through the host. */\n sendMessage(params: SendMessageParams): Promise<void>;\n /** Ask the host to open an external link. */\n openLink(params: OpenLinkParams): Promise<void>;\n /** Request a display-mode change from the host. */\n requestDisplayMode(params: RequestDisplayModeParams): Promise<void>;\n /** Notify the host of a size change. */\n sendSizeChanged(params: SizeChangedParams): Promise<void>;\n\n /**\n * Register a view tool, performing the empty-handler → registry handoff on\n * the first call. Must remain synchronous relative to the handoff.\n */\n registerViewTool(\n name: string,\n config: ViewToolConfig,\n callback: ViewToolCallback\n ): RegisteredAppTool;\n}\n\nconst APP_VERSION = \"2.0.0-alpha.0\";\n\nconst defaultToolSnapshot: ToolSnapshot = {\n status: \"pending\",\n toolOutput: undefined,\n content: undefined,\n toolInput: undefined,\n meta: undefined,\n error: undefined,\n};\n\nconst defaultHostSnapshot: HostSnapshot = {\n hostContext: undefined,\n isConnected: false,\n connectionError: undefined,\n};\n\nfunction resolveDisplayMode(\n hostContext: McpUiHostContext | undefined\n): DisplayMode {\n return hostContext?.displayMode === \"fullscreen\" ||\n hostContext?.displayMode === \"pip\"\n ? hostContext.displayMode\n : \"inline\";\n}\n\nfunction resolveTheme(\n hostContext: McpUiHostContext | undefined\n): \"light\" | \"dark\" {\n return hostContext?.theme === \"dark\" ? \"dark\" : \"light\";\n}\n\nfunction sameDisplayModes(\n a: readonly DisplayMode[],\n b: readonly DisplayMode[]\n): boolean {\n return a.length === b.length && a.every((mode, index) => mode === b[index]);\n}\n\n/**\n * Negotiated display modes: view modes ∩ host modes.\n *\n * When the host omits `availableDisplayModes`, only `\"inline\"` is requestable.\n */\nfunction resolveAvailableDisplayModes(\n viewModes: readonly DisplayMode[],\n hostContext: McpUiHostContext | undefined\n): readonly DisplayMode[] {\n const hostModes = hostContext?.availableDisplayModes;\n if (hostModes === undefined) {\n return [\"inline\"];\n }\n return viewModes.filter((mode) => hostModes.includes(mode));\n}\n\nfunction installEmptyToolHandlers(app: App): void {\n app.onlisttools = async () => ({ tools: [] });\n app.oncalltool = async ({ name }) => {\n throw new Error(`View tool \"${name}\" is not registered`);\n };\n}\n\nfunction createChannelStore(): {\n subscribe: (listener: Listener) => () => void;\n emit: () => void;\n clear: () => void;\n} {\n const listeners = new Set<Listener>();\n return {\n subscribe(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n emit() {\n for (const listener of listeners) {\n listener();\n }\n },\n clear() {\n listeners.clear();\n },\n };\n}\n\nfunction toolSnapshotChanged(\n prev: ToolSnapshot,\n patch: Partial<ToolSnapshot>\n): boolean {\n for (const key of Object.keys(patch) as (keyof ToolSnapshot)[]) {\n if (prev[key] !== patch[key]) {\n return true;\n }\n }\n return false;\n}\n\nfunction hostSnapshotChanged(\n prev: HostSnapshot,\n patch: Partial<HostSnapshot>\n): boolean {\n for (const key of Object.keys(patch) as (keyof HostSnapshot)[]) {\n if (prev[key] !== patch[key]) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Options for {@link createMcpAppRuntime}.\n *\n * @internal\n */\nexport interface CreateMcpAppRuntimeOptions {\n /**\n * Transport used by the runtime's single {@link McpAppRuntime.connect}\n * attempt (tests).\n * Defaults to {@link PostMessageTransport} against `window.parent`.\n */\n transport?: ViewRuntimeTransport;\n}\n\n/**\n * Create a fresh {@link McpAppRuntime} for one iframe document / view mount.\n *\n * Constructs and configures the guest {@link App} eagerly so event handlers\n * and view tools can be registered before or during initialization. The App is\n * connected at most once and remains owned by the runtime until disposal.\n *\n * @param config - Normalized {@link NormalizedViewConfig} from bootstrap.\n * @param options - Optional transport injection for tests.\n * @returns A runtime owning connection, snapshots, and view-tool registration.\n *\n * @internal\n */\nexport function createMcpAppRuntime(\n config: NormalizedViewConfig,\n options?: CreateMcpAppRuntimeOptions\n): McpAppRuntime {\n let disposed = false;\n let connectPromise: Promise<App> | null = null;\n let toolRegistryActivated = false;\n const configuredTransport = options?.transport;\n\n let toolSnapshot: ToolSnapshot = { ...defaultToolSnapshot };\n let hostSnapshot: HostSnapshot = { ...defaultHostSnapshot };\n let themeSnapshot: \"light\" | \"dark\" = \"light\";\n // Host has not reported modes yet → treat as omitted → only \"inline\".\n let displaySnapshot: DisplaySnapshot = {\n displayMode: \"inline\",\n availableDisplayModes: [\"inline\"],\n };\n\n const toolChannel = createChannelStore();\n const hostChannel = createChannelStore();\n const themeChannel = createChannelStore();\n const displayChannel = createChannelStore();\n\n function patchTool(patch: Partial<ToolSnapshot>): void {\n if (!toolSnapshotChanged(toolSnapshot, patch)) {\n return;\n }\n toolSnapshot = { ...toolSnapshot, ...patch };\n toolChannel.emit();\n }\n\n function patchHost(patch: Partial<HostSnapshot>): void {\n if (!hostSnapshotChanged(hostSnapshot, patch)) {\n return;\n }\n hostSnapshot = { ...hostSnapshot, ...patch };\n hostChannel.emit();\n }\n\n function syncThemeFromHost(hostContext: McpUiHostContext | undefined): void {\n const next = resolveTheme(hostContext);\n if (next === themeSnapshot) {\n return;\n }\n themeSnapshot = next;\n themeChannel.emit();\n }\n\n function syncDisplayFromHost(\n hostContext: McpUiHostContext | undefined\n ): void {\n const nextMode = resolveDisplayMode(hostContext);\n const nextAvailable = resolveAvailableDisplayModes(\n config.displayModes,\n hostContext\n );\n if (\n nextMode === displaySnapshot.displayMode &&\n sameDisplayModes(nextAvailable, displaySnapshot.availableDisplayModes)\n ) {\n return;\n }\n displaySnapshot = {\n displayMode: nextMode,\n availableDisplayModes: nextAvailable,\n };\n displayChannel.emit();\n }\n\n /**\n * Apply a host-context update and fan out to host / theme / display\n * channels that actually changed.\n */\n function applyHostContext(nextHostContext: McpUiHostContext): void {\n patchHost({ hostContext: nextHostContext });\n syncThemeFromHost(nextHostContext);\n syncDisplayFromHost(nextHostContext);\n }\n\n function installRuntimeEventHandlers(app: App): void {\n // The draft notification shape has no tool name or request id. While the\n // rendering invocation is pending, both complete and partial input replace\n // the same progressive snapshot. Once a result is latched, later ambient\n // lifecycle notifications must not mutate the View context.\n app.ontoolinput = (params) => {\n if (disposed || toolSnapshot.status !== \"pending\") return;\n patchTool({ toolInput: params.arguments ?? {} });\n };\n\n app.ontoolinputpartial = (params) => {\n if (disposed || toolSnapshot.status !== \"pending\") return;\n patchTool({ toolInput: params.arguments ?? {} });\n };\n\n app.ontoolresult = (params) => {\n if (disposed || toolSnapshot.status !== \"pending\") return;\n\n // Content-only successes are valid CallToolResults from ambient server\n // or View tools. Without correlation metadata they cannot be classified\n // as malformed rendering results, so leave the pending context alone.\n if (params.isError !== true && params.structuredContent === undefined) {\n return;\n }\n\n const content = Array.isArray(params.content)\n ? (params.content as ContentBlock[])\n : undefined;\n const meta =\n params._meta !== undefined &&\n typeof params._meta === \"object\" &&\n params._meta !== null\n ? (params._meta as Record<string, unknown>)\n : undefined;\n\n if (params.isError === true) {\n const result = params as CallToolResult & { isError: true };\n patchTool({\n status: \"error\",\n error: new ToolError(result),\n toolOutput: undefined,\n content,\n meta,\n });\n return;\n }\n\n patchTool({\n status: \"ready\",\n error: undefined,\n toolOutput: params.structuredContent,\n content,\n meta,\n });\n };\n\n // Cancellation cannot be correlated either and has no public bound-state\n // branch. A cancelled rendering invocation therefore remains pending.\n app.ontoolcancelled = () => {};\n\n app.onhostcontextchanged = (params) => {\n if (disposed) return;\n applyHostContext({\n ...(hostSnapshot.hostContext ?? {}),\n ...params,\n });\n };\n }\n\n function createApp(): App {\n const app = new App(\n { name: \"mcp-use-view\", version: APP_VERSION },\n {\n tools: { listChanged: true },\n availableDisplayModes: [...config.displayModes],\n },\n { autoResize: config.autoResize }\n );\n installEmptyToolHandlers(app);\n installRuntimeEventHandlers(app);\n return app;\n }\n\n const app = createApp();\n\n async function closeAppQuietly(app: App): Promise<void> {\n try {\n await app.close();\n } catch {\n // Best-effort deterministic cleanup.\n }\n }\n\n async function connectApp(): Promise<App> {\n try {\n if (typeof window === \"undefined\" && configuredTransport === undefined) {\n throw new Error(\n \"View runtime can only connect in a browser environment\"\n );\n }\n const transport =\n configuredTransport ??\n new PostMessageTransport(window.parent, window.parent);\n await app.connect(transport);\n if (disposed) {\n await closeAppQuietly(app);\n throw new Error(\"View runtime was disposed during connection\");\n }\n const hostContext = app.getHostContext();\n patchHost({\n isConnected: true,\n connectionError: undefined,\n ...(hostContext !== undefined && { hostContext }),\n });\n // Always re-derive display (host omitting modes → [\"inline\"]).\n syncThemeFromHost(hostContext);\n syncDisplayFromHost(hostContext);\n return app;\n } catch (error) {\n const failure = error instanceof Error ? error : new Error(String(error));\n if (!disposed) {\n patchHost({\n isConnected: false,\n connectionError: failure,\n });\n }\n throw failure;\n }\n }\n\n function connect(): Promise<App> {\n if (disposed) {\n return Promise.reject(new Error(\"View runtime has been disposed\"));\n }\n connectPromise ??= connectApp();\n return connectPromise;\n }\n\n const modelContextStore = new ModelContextStore({ connect });\n\n function registerViewTool(\n name: string,\n toolConfig: ViewToolConfig,\n callback: ViewToolCallback\n ): RegisteredAppTool {\n if (disposed) {\n throw new Error(\"View runtime has been disposed\");\n }\n if (toolRegistryActivated) {\n return app.registerTool(name, toolConfig, callback);\n }\n\n // Clear temporary handlers first so ensureToolHandlersInitialized does not\n // warn about replacing them. Clear + register must stay in one turn.\n app.onlisttools = undefined;\n app.oncalltool = undefined;\n\n try {\n const registration = app.registerTool(name, toolConfig, callback);\n toolRegistryActivated = true;\n return registration;\n } catch (error) {\n installEmptyToolHandlers(app);\n throw error;\n }\n }\n\n async function dispose(): Promise<void> {\n if (disposed) return;\n disposed = true;\n modelContextStore.dispose();\n toolRegistryActivated = false;\n toolChannel.clear();\n hostChannel.clear();\n themeChannel.clear();\n displayChannel.clear();\n toolSnapshot = { ...defaultToolSnapshot };\n hostSnapshot = { ...defaultHostSnapshot };\n themeSnapshot = \"light\";\n displaySnapshot = {\n displayMode: \"inline\",\n availableDisplayModes: [\"inline\"],\n };\n if (activeRuntime === runtime) {\n activeRuntime = null;\n }\n await closeAppQuietly(app);\n }\n\n async function callServerTool(\n params: CallToolParams\n ): Promise<CallToolResult> {\n const app = await connect();\n if (app.getHostCapabilities()?.serverTools === undefined) {\n throw new Error(\n \"Host does not advertise the serverTools capability required to call server tools\"\n );\n }\n return app.callServerTool(params);\n }\n\n async function sendMessage(params: SendMessageParams): Promise<void> {\n const app = await connect();\n if (app.getHostCapabilities()?.message === undefined) {\n throw new Error(\n \"Host does not advertise the message capability required to send follow-up messages\"\n );\n }\n await app.sendMessage(params);\n }\n\n async function openLink(params: OpenLinkParams): Promise<void> {\n const app = await connect();\n if (app.getHostCapabilities()?.openLinks === undefined) {\n throw new Error(\n \"Host does not advertise the openLinks capability required to open external links\"\n );\n }\n await app.openLink(params);\n }\n\n async function requestDisplayMode(\n params: RequestDisplayModeParams\n ): Promise<void> {\n const app = await connect();\n // Re-derive from the latest host context so a race with host-context\n // updates cannot approve a mode the snapshot has not yet published.\n const negotiated = resolveAvailableDisplayModes(\n config.displayModes,\n app.getHostContext() ?? hostSnapshot.hostContext\n );\n if (!negotiated.includes(params.mode as DisplayMode)) {\n throw new Error(\n `Display mode \"${params.mode}\" is not in the negotiated available modes [${negotiated.join(\", \")}]`\n );\n }\n await app.requestDisplayMode(params);\n }\n\n async function sendSizeChanged(params: SizeChangedParams): Promise<void> {\n const app = await connect();\n await app.sendSizeChanged(params);\n }\n\n const runtime: McpAppRuntime = {\n config,\n modelContextStore,\n connect,\n dispose,\n subscribeTool: toolChannel.subscribe,\n getToolSnapshot: () => toolSnapshot,\n subscribeHost: hostChannel.subscribe,\n getHostSnapshot: () => hostSnapshot,\n subscribeTheme: themeChannel.subscribe,\n getThemeSnapshot: () => themeSnapshot,\n subscribeDisplay: displayChannel.subscribe,\n getDisplaySnapshot: () => displaySnapshot,\n getApp: () => (disposed ? null : app),\n callServerTool,\n sendMessage,\n openLink,\n requestDisplayMode,\n sendSizeChanged,\n registerViewTool,\n };\n\n return runtime;\n}\n\n/**\n * Document-level active runtime used by the imperative {@link modelContext}\n * API and test seams.\n *\n * Set by {@link bootstrapView}; cleared on {@link McpAppRuntime.dispose}.\n */\nlet activeRuntime: McpAppRuntime | null = null;\n\n/** Transport queued for the next bootstrap when set before the runtime exists. */\nlet pendingTestTransport: ViewRuntimeTransport | null = null;\n\n/**\n * Register `runtime` as the document-active instance for imperative APIs.\n *\n * @param runtime - Runtime to activate, or `null` to clear.\n *\n * @internal\n */\nexport function setActiveRuntime(runtime: McpAppRuntime | null): void {\n activeRuntime = runtime;\n}\n\n/**\n * Return the document-active runtime, if any.\n *\n * @internal\n */\nexport function getActiveRuntime(): McpAppRuntime | null {\n return activeRuntime;\n}\n\n/**\n * Inject a transport before the next bootstrap-created runtime.\n *\n * A mounted runtime has already started its sole connection attempt, so its\n * transport cannot be replaced.\n *\n * @param transport - Guest-side paired transport, or `null` to clear.\n *\n * @internal\n */\nexport function _setTransportForTesting(\n transport: ViewRuntimeTransport | null\n): void {\n if (activeRuntime) {\n throw new Error(\n \"Cannot replace the transport after a view runtime has been mounted\"\n );\n }\n pendingTestTransport = transport;\n}\n\n/**\n * Consume and clear any transport queued by {@link _setTransportForTesting}.\n *\n * @internal\n */\nexport function takePendingTestTransport(): ViewRuntimeTransport | undefined {\n const transport = pendingTestTransport ?? undefined;\n pendingTestTransport = null;\n return transport;\n}\n\n/**\n * Optional disposer registered by bootstrap-view so test reset can run the\n * real unmount-then-close path without a circular static import.\n */\nlet registeredDisposeView: (() => Promise<void>) | null = null;\n\n/**\n * Register {@link disposeView} for {@link _resetViewBridgeForTesting}.\n *\n * @param disposer - The document dispose function from bootstrap-view.\n *\n * @internal\n */\nexport function _registerDisposeViewForTesting(\n disposer: () => Promise<void>\n): void {\n registeredDisposeView = disposer;\n}\n\n/**\n * @internal Reset runtime module seams between tests.\n *\n * Uses the real {@link disposeView} path when bootstrap has registered it\n * (unmount React, then close the App). Falls back to disposing an orphaned\n * active runtime when nothing is mounted through bootstrap.\n */\nexport function _resetViewBridgeForTesting(): void {\n pendingTestTransport = null;\n if (registeredDisposeView) {\n void registeredDisposeView();\n return;\n }\n const runtime = activeRuntime;\n activeRuntime = null;\n if (runtime) {\n void runtime.dispose();\n }\n}\n\n/** @internal Guest `App` for the active runtime (bridge tests only). */\nexport function _getAppForTesting(): App | null {\n return activeRuntime?.getApp() ?? null;\n}\n\n/** @internal Active runtime instance (Phase 5 runtime tests). */\nexport function _getRuntimeForTesting(): McpAppRuntime | null {\n return activeRuntime;\n}\n","import type { CallToolResult } from \"@modelcontextprotocol/server\";\n\nexport type { CallToolResult };\n\n/**\n * Concatenated text content of a tool result, or `undefined` when it has none.\n *\n * Joins the `text` of every `content` block with `type === \"text\"` using\n * `\"\\n\"`, then trims. Returns `undefined` when there are no text blocks or\n * the joined result is empty/whitespace — callers choose their own fallback.\n *\n * Useful when reading human-readable text from a {@link CallToolResult}\n * (success or error) without inspecting the full `content` array.\n *\n * @param result - Tool result (or any object with a `content` array).\n * @returns Joined trimmed text, or `undefined` when there is none.\n *\n * @example\n * ```ts\n * const text = toolResultText(result) ?? \"No message.\";\n * ```\n */\nexport function toolResultText(\n result: Pick<CallToolResult, \"content\">\n): string | undefined {\n const blocks = result.content;\n if (!Array.isArray(blocks) || blocks.length === 0) {\n return undefined;\n }\n\n const parts: string[] = [];\n for (const block of blocks) {\n if (\n block !== null &&\n typeof block === \"object\" &&\n \"type\" in block &&\n block.type === \"text\" &&\n \"text\" in block &&\n typeof block.text === \"string\"\n ) {\n parts.push(block.text);\n }\n }\n\n if (parts.length === 0) {\n return undefined;\n }\n\n const joined = parts.join(\"\\n\").trim();\n return joined.length > 0 ? joined : undefined;\n}\n\n/**\n * The bound or called tool ran and answered with `isError: true` — a domain\n * error, not a transport or protocol failure.\n *\n * `message` is derived from the error result's text content blocks (via\n * {@link toolResultText}), or `\"Tool returned an error.\"` when there are none.\n */\nexport class ToolError extends Error {\n /** The error result as delivered (`isError: true`). */\n readonly result: CallToolResult & { isError: true };\n\n /**\n * @param result - The tool result with `isError: true`.\n */\n constructor(result: CallToolResult & { isError: true }) {\n super(toolResultText(result) ?? \"Tool returned an error.\");\n this.name = \"ToolError\";\n this.result = result;\n }\n}\n\n/**\n * Error that can appear in the `\"error\"` branch of {@link ToolContextHandle}.\n */\nexport type ToolContextError = ToolError;\n\n/**\n * Successful non-error tool result returned by {@link useCallTool}.\n *\n * `structuredContent` is guaranteed and typed exactly when the tool declares\n * an `outputSchema` (`Result` is not `never`) — the server rejects non-error\n * results from schema-backed tools that lack it, so a resolved result always\n * carries it. Tools without an `outputSchema` (`Result = never`) legitimately\n * return content-only results, so no `structuredContent` guarantee is added\n * beyond the base {@link CallToolResult} (optional, `unknown`).\n *\n * Tool errors and transport failures reject instead — they never appear here.\n *\n * @typeParam Result - Inferred `structuredContent` type from the tool's\n * `outputSchema`; `never` when the tool declares none.\n */\nexport type CallToolSuccess<Result> = CallToolResult & {\n isError?: false;\n} & ([Result] extends [never] ? unknown : { structuredContent: Result });\n","import type { App } from \"@modelcontextprotocol/ext-apps\";\nimport type { ContentBlock } from \"@modelcontextprotocol/server\";\n\ninterface ModelContextNode {\n id: string;\n parentId: string | null;\n content: string;\n}\n\ninterface StoredModelContextNode extends ModelContextNode {\n /** Insertion sequence — preserves registration order across flushes. */\n order: number;\n}\n\n/**\n * Complete `ui/update-model-context` params built from the store — the wire\n * shape of the MCP Apps spec's `content` blocks. Each push carries the full\n * current state (the spec's overwrite semantics).\n *\n * @internal\n */\nexport interface ModelContextParams {\n /**\n * Content blocks: empty, or a single text block with the serialized\n * description tree.\n */\n content: ContentBlock[];\n}\n\n/**\n * Narrow runtime surface the flush pump needs to connect and send.\n *\n * @internal\n */\nexport interface ModelContextStoreHost {\n /** Connect once, or return the cached in-flight / settled connection promise. */\n connect(): Promise<App>;\n}\n\nconst EMPTY_SERIALIZED = JSON.stringify({ content: [] });\n\n/**\n * Warn-once flag for hosts that omit the `updateModelContext` capability.\n * Document-scoped so HMR / rebootstrap do not spam the console.\n */\nlet warnedModelContextUnsupported = false;\n\n/**\n * Mark that the missing-`updateModelContext` warning has been emitted.\n *\n * @returns `true` if this call should emit the warning (first time only).\n *\n * @internal\n */\nexport function markModelContextUnsupportedWarned(): boolean {\n if (warnedModelContextUnsupported) {\n return false;\n }\n warnedModelContextUnsupported = true;\n return true;\n}\n\n/**\n * @internal Reset the missing-capability warn-once flag between tests.\n *\n * Prefer {@link _resetModelContextForTesting} from `model-context.tsx` when the\n * active runtime's store must also be cleared; this seam only resets the\n * document-level warn flag (dispose already drops the store).\n */\nexport function _resetModelContextForTesting(): void {\n warnedModelContextUnsupported = false;\n}\n\n/**\n * @internal Reset the missing-capability warn-once flag between tests.\n */\nexport function _resetModelContextUnsupportedWarnedForTesting(): void {\n warnedModelContextUnsupported = false;\n}\n\n/**\n * Per-runtime model-context node tree and async flush pump.\n *\n * Owned by one {@link McpAppRuntime}: constructed with it, disposed with it.\n * Mutations update desired state and schedule a microtask-batched pump that\n * acknowledges a payload only after a successful `updateModelContext` send.\n *\n * @internal\n */\nexport class ModelContextStore {\n readonly #host: ModelContextStoreHost;\n readonly #nodes = new Map<string, StoredModelContextNode>();\n #nextOrder = 0;\n #flushScheduled = false;\n #disposed = false;\n /** Bumped on {@link dispose} so late in-flight completions are ignored. */\n #epoch = 0;\n /**\n * Serialized form of the latest tree. Starts empty so views that never\n * register context are not dirty.\n */\n #desiredSerialized = EMPTY_SERIALIZED;\n /**\n * Last successfully delivered payload. Starts empty so an empty push is\n * sent only as a clear after non-empty context existed.\n */\n #acknowledgedSerialized = EMPTY_SERIALIZED;\n #inFlight: Promise<void> | null = null;\n\n /**\n * @param host - Runtime bridge used to `connect` and send updates.\n */\n constructor(host: ModelContextStoreHost) {\n this.#host = host;\n }\n\n /**\n * Register or replace a node and schedule a flush.\n *\n * @param node - Node identity, parent link, and text content.\n */\n setNode(node: ModelContextNode): void {\n if (this.#disposed) return;\n const order = this.#nodes.get(node.id)?.order ?? this.#nextOrder++;\n this.#nodes.set(node.id, { ...node, order });\n this.#updateDesiredAndSchedule();\n }\n\n /**\n * Remove a node by id and schedule a flush.\n *\n * @param id - Node id previously passed to {@link setNode}.\n */\n removeNode(id: string): void {\n if (this.#disposed) return;\n if (!this.#nodes.delete(id)) return;\n this.#updateDesiredAndSchedule();\n }\n\n /** Remove every node and schedule a flush (empty clear when previously non-empty). */\n clear(): void {\n if (this.#disposed) return;\n if (this.#nodes.size === 0) return;\n this.#nodes.clear();\n this.#updateDesiredAndSchedule();\n }\n\n /**\n * Invalidate the store: ignore late in-flight completions and reject further\n * mutations. Does not send a final clear — the runtime is going away.\n */\n dispose(): void {\n if (this.#disposed) return;\n this.#disposed = true;\n this.#epoch += 1;\n this.#flushScheduled = false;\n this.#inFlight = null;\n this.#nodes.clear();\n this.#nextOrder = 0;\n this.#desiredSerialized = EMPTY_SERIALIZED;\n this.#acknowledgedSerialized = EMPTY_SERIALIZED;\n }\n\n /**\n * Serialize the registered tree into an indented markdown-like string.\n *\n * @returns Description text, or `\"\"` when nothing is registered.\n */\n buildDescriptionString(): string {\n const byParent = new Map<string | null, StoredModelContextNode[]>();\n\n for (const node of this.#nodes.values()) {\n const key = node.parentId ?? null;\n const list = byParent.get(key);\n if (list) {\n list.push(node);\n } else {\n byParent.set(key, [node]);\n }\n }\n\n // Sibling order = registration order. React runs effects in document order\n // for siblings, so this tracks on-screen order; sorting by `useId` strings\n // would not (`:r10:` sorts before `:r2:`).\n for (const list of byParent.values()) {\n list.sort((a, b) => a.order - b.order);\n }\n\n const lines: string[] = [];\n\n const traverseTree = (parentId: string | null, depth: number): void => {\n const children = byParent.get(parentId);\n if (!children) return;\n for (const child of children) {\n if (child.content.trim()) {\n lines.push(`${\" \".repeat(depth)}- ${child.content.trim()}`);\n }\n traverseTree(child.id, depth + 1);\n }\n };\n\n traverseTree(null, 0);\n return lines.join(\"\\n\");\n }\n\n /**\n * Build the `ui/update-model-context` params from the current tree.\n *\n * @returns Empty `content` when nothing is registered; otherwise one text block.\n */\n buildModelContextParams(): ModelContextParams {\n const description = this.buildDescriptionString();\n if (description.length === 0) {\n return { content: [] };\n }\n return { content: [{ type: \"text\", text: description }] };\n }\n\n /**\n * @internal Clear nodes and pump state between tests without disposing the\n * owning runtime (warn-once flag is reset separately).\n */\n resetForTesting(): void {\n this.#nodes.clear();\n this.#nextOrder = 0;\n this.#flushScheduled = false;\n this.#inFlight = null;\n this.#desiredSerialized = EMPTY_SERIALIZED;\n this.#acknowledgedSerialized = EMPTY_SERIALIZED;\n // Keep #disposed / #epoch — a disposed store stays disposed.\n }\n\n /** @internal Serialized tree for tests. */\n getDescriptionForTesting(): string {\n return this.buildDescriptionString();\n }\n\n #updateDesiredAndSchedule(): void {\n this.#desiredSerialized = JSON.stringify(this.buildModelContextParams());\n this.#schedulePump();\n }\n\n #schedulePump(): void {\n if (this.#disposed) return;\n if (this.#flushScheduled) return;\n this.#flushScheduled = true;\n queueMicrotask(() => {\n this.#flushScheduled = false;\n this.#pump();\n });\n }\n\n #pump(): void {\n if (this.#disposed) return;\n if (this.#inFlight) return;\n if (this.#desiredSerialized === this.#acknowledgedSerialized) return;\n\n const params = this.buildModelContextParams();\n // Re-serialize from the live tree and track that exact form for ack.\n const serialized = JSON.stringify(params);\n this.#desiredSerialized = serialized;\n if (serialized === this.#acknowledgedSerialized) return;\n\n const sendEpoch = this.#epoch;\n let sendSucceeded = false;\n\n this.#inFlight = (async () => {\n try {\n const app = await this.#host.connect();\n if (this.#disposed || sendEpoch !== this.#epoch) return;\n\n if (app.getHostCapabilities()?.updateModelContext === undefined) {\n if (markModelContextUnsupportedWarned()) {\n console.warn(\n \"[ModelContext] Host does not declare the updateModelContext capability; model-context updates are not sent.\"\n );\n }\n // Stay dirty — a later host/capability may accept updates.\n return;\n }\n\n await app.updateModelContext(\n params as Parameters<App[\"updateModelContext\"]>[0]\n );\n if (this.#disposed || sendEpoch !== this.#epoch) return;\n\n // Acknowledge the exact payload that was sent. If desired moved on\n // mid-flight, the store stays dirty and the finally-block re-pumps.\n this.#acknowledgedSerialized = serialized;\n sendSucceeded = true;\n } catch (error: unknown) {\n if (this.#disposed || sendEpoch !== this.#epoch) return;\n console.warn(\"[ModelContext] Failed to update model context:\", error);\n } finally {\n this.#inFlight = null;\n if (\n !this.#disposed &&\n sendEpoch === this.#epoch &&\n sendSucceeded &&\n this.#desiredSerialized !== this.#acknowledgedSerialized\n ) {\n // Coalesced mutations during the in-flight send — push the latest.\n this.#pump();\n }\n }\n })();\n }\n}\n","/**\n * Client-side resolution for root-relative public asset paths.\n *\n * The synthesized view document injects {@link McpUseViewConfig} before any\n * module scripts so iframe code can resolve `/…` paths to absolute URLs.\n */\n\n/**\n * Request-scoped view configuration injected into the synthesized document.\n *\n * @remarks\n * Set per request by {@link synthesizeViewDocument} — not at build or boot\n * time — so public asset URLs stay correct behind proxies and tunnels.\n */\nexport interface McpUseViewConfig {\n /**\n * Absolute URL prefix for the project's `public/` directory, including a\n * trailing slash (e.g. `http://127.0.0.1:3000/mcp/_mcp-use/public/`).\n */\n publicBase: string;\n}\n\ndeclare global {\n var __mcpUseViewConfig: McpUseViewConfig | undefined;\n}\n\n/**\n * Read the injected public asset base URL, if present.\n *\n * @returns The request-resolved `publicBase`, or an empty string outside a\n * synthesized view document.\n *\n * @internal\n */\nexport function getPublicBase(): string {\n if (typeof globalThis === \"undefined\") {\n return \"\";\n }\n return globalThis.__mcpUseViewConfig?.publicBase ?? \"\";\n}\n\n/**\n * Resolve a root-relative path from the project's `public/` folder to an\n * absolute URL for the current view iframe.\n *\n * Root-relative paths (starting with `/`) are resolved against the injected\n * {@link McpUseViewConfig.publicBase}. Absolute `http(s):` and `data:` URLs\n * pass through unchanged. Fully-relative paths (no leading slash) are returned\n * as-is. Not part of the public API — public assets are consumed through the\n * {@link Image} component.\n *\n * @param path - Author path, typically root-relative from the `public/` folder\n * (e.g. `/fruits/apple.png`).\n * @returns The resolved absolute URL, or the original path when no base is set.\n *\n * @internal\n */\nexport function publicAsset(path: string): string {\n if (path === \"\") {\n return path;\n }\n if (\n path.startsWith(\"http://\") ||\n path.startsWith(\"https://\") ||\n path.startsWith(\"data:\")\n ) {\n return path;\n }\n if (path.startsWith(\"/\")) {\n const publicBase = getPublicBase();\n if (publicBase === \"\") {\n return path;\n }\n return `${publicBase}${path.slice(1)}`;\n }\n return path;\n}\n","import React from \"react\";\n\nimport { publicAsset } from \"../public-assets.js\";\n\n/**\n * Image element that resolves root-relative `src` paths against the project's\n * `public/` directory via the request-scoped config injected into the\n * synthesized view document.\n *\n * Root-relative paths (starting with `/`) resolve to absolute URLs under\n * `${basePath}/_mcp-use/public/`. Absolute `http(s):` and `data:` URLs pass\n * through unchanged. Fully-relative paths are left as-is.\n */\nexport const Image: React.FC<React.ImgHTMLAttributes<HTMLImageElement>> = ({\n src,\n ...props\n}) => {\n const finalSrc = typeof src === \"string\" ? publicAsset(src) : src;\n\n return <img src={finalSrc} {...props} />;\n};\n","/**\n * ModelContext: React component and module-level API for annotating view UI\n * with contextual information the model can see.\n */\n\nimport {\n createContext,\n type ReactNode,\n useContext,\n useEffect,\n useId,\n} from \"react\";\n\nimport type { ModelContextStore } from \"../runtime/model-context-store.js\";\nimport {\n _resetModelContextUnsupportedWarnedForTesting,\n type ModelContextParams,\n} from \"../runtime/model-context-store.js\";\nimport { useViewRuntime } from \"../runtime/view-runtime-context.js\";\nimport { getActiveRuntime } from \"../runtime/view-runtime.js\";\n\nconst ParentIdContext = createContext<string | null>(null);\n\ninterface ModelContextProps {\n /** Text describing what the user is currently seeing. */\n content: string;\n /** Optional children — acts as a scope boundary for nested context nodes. */\n children?: ReactNode;\n}\n\n/**\n * Resolve the active runtime's {@link ModelContextStore}.\n *\n * @throws When no view runtime is mounted.\n */\nfunction requireActiveModelContextStore(): ModelContextStore {\n const runtime = getActiveRuntime();\n if (!runtime) {\n throw new Error(\n \"modelContext requires a browser view mounted by bootstrapView\"\n );\n }\n return runtime.modelContextStore;\n}\n\n/**\n * Annotate a portion of the view UI with a description the model can see.\n *\n * Registers `content` in a hierarchical tree that serializes into an indented\n * markdown list and is pushed to the host via `ui/update-model-context`\n * (ext-apps `App.updateModelContext`). Updates batch per microtask. An async\n * flush pump acknowledges a payload only after a successful send; failed\n * update requests and missing host capability stay dirty and retry on the next\n * mutation. Each push carries the complete current context — the spec's\n * overwrite semantics (the host may defer delivery until the next model turn).\n *\n * An empty `content` (trimmed) does not register a node and does not orphan\n * children — nested {@link ModelContext} nodes re-parent to the nearest\n * registered ancestor (or root).\n *\n * When the host does not declare the `updateModelContext` capability, pushes\n * are skipped (payload stays dirty) and a one-time `console.warn` names the\n * gap.\n *\n * @param props - Component props.\n * @param props.content - Text describing what the user is currently seeing.\n * @param props.children - Optional nested UI; nested {@link ModelContext}\n * nodes serialize as indented children of this node when this node has\n * non-empty content.\n *\n * @example\n * ```tsx\n * <ModelContext content={`Selected: ${item.name}`} />\n *\n * <ModelContext content=\"Dashboard\">\n * <ModelContext content=\"Revenue section\" />\n * </ModelContext>\n * ```\n */\nexport function ModelContext({ content, children }: ModelContextProps) {\n const runtime = useViewRuntime();\n const store = runtime.modelContextStore;\n const parentId = useContext(ParentIdContext);\n const id = useId();\n const hasContent = content.trim().length > 0;\n const childParentId = hasContent ? id : parentId;\n\n useEffect(() => {\n if (hasContent) {\n store.setNode({ id, parentId, content });\n }\n return () => {\n store.removeNode(id);\n };\n }, [store, id, parentId, content, hasContent]);\n\n if (children === undefined || children === null) {\n return null;\n }\n\n return (\n <ParentIdContext.Provider value={childParentId}>\n {children}\n </ParentIdContext.Provider>\n );\n}\n\n/**\n * Imperative model-context API for non-React call sites (event handlers,\n * stores).\n *\n * Delegates to the active document runtime's {@link ModelContextStore}.\n * Strings register as root-level nodes in the same tree {@link ModelContext}\n * builds; each push overwrites the previous context on the host (the host may\n * defer delivery until the next model turn). Updates batch per microtask and\n * use the same async flush pump (ack only on success). When the host lacks the\n * `updateModelContext` capability, pushes stay dirty with a one-time\n * `console.warn`.\n *\n * @throws When no view runtime is mounted (`bootstrapView` has not activated a\n * runtime, or it has been disposed).\n *\n * @example\n * ```ts\n * modelContext.set(\"active-item\", `Viewing ${item.name}`);\n * modelContext.remove(\"active-item\");\n * modelContext.clear();\n * ```\n */\nexport const modelContext = {\n /**\n * Register or update a named root-level text context entry.\n *\n * @param key - Stable key for this entry (replaces any prior value under the same key).\n * @param content - Text describing what the user is seeing.\n * @throws When no view runtime is mounted.\n */\n set(key: string, content: string): void {\n requireActiveModelContextStore().setNode({\n id: key,\n parentId: null,\n content,\n });\n },\n\n /**\n * Remove the entry registered under `key`.\n *\n * @param key - Key previously passed to {@link modelContext.set}.\n * @throws When no view runtime is mounted.\n */\n remove(key: string): void {\n requireActiveModelContextStore().removeNode(key);\n },\n\n /**\n * Remove all context entries.\n *\n * @throws When no view runtime is mounted.\n */\n clear(): void {\n requireActiveModelContextStore().clear();\n },\n} as const;\n\n/**\n * @internal Reset model-context warn-once flag and the active runtime's store\n * between tests.\n */\nexport function _resetModelContextForTesting(): void {\n _resetModelContextUnsupportedWarnedForTesting();\n const runtime = getActiveRuntime();\n if (runtime) {\n runtime.modelContextStore.resetForTesting();\n }\n}\n\n/** @internal Serialized tree for the active runtime's store (tests). */\nexport function _getDescriptionForTesting(): string {\n return getActiveRuntime()?.modelContextStore.getDescriptionForTesting() ?? \"\";\n}\n\n/**\n * @internal Serialize the active runtime's model-context tree.\n *\n * @returns Description string, or `\"\"` when no runtime is mounted.\n */\nexport function buildDescriptionString(): string {\n return getActiveRuntime()?.modelContextStore.buildDescriptionString() ?? \"\";\n}\n\n/**\n * @internal Build `ui/update-model-context` params from the active store.\n *\n * @returns Empty content when no runtime is mounted or nothing is registered.\n */\nexport function buildModelContextParams(): ModelContextParams {\n return (\n getActiveRuntime()?.modelContextStore.buildModelContextParams() ?? {\n content: [],\n }\n );\n}\n","import {\n applyDocumentTheme,\n applyHostFonts,\n applyHostStyleVariables,\n} from \"@modelcontextprotocol/ext-apps\";\nimport React, { useLayoutEffect, useState } from \"react\";\n\nimport { useHostContextSubscription } from \"../runtime/view-runtime-context.js\";\n\n/**\n * Applies host theme, style variables, and fonts to the document root.\n *\n * Subscribes to the host channel (theme, `styles.variables`, `styles.css.fonts`)\n * via {@link useHostContextSubscription}. Theme-only consumers should use\n * {@link useViewTheme} instead so locale/dimension updates do not rerender them.\n */\nexport const ThemeProvider: React.FC<{\n children: React.ReactNode;\n /** Set `color-scheme` on the document root to match the active theme. */\n colorScheme?: boolean;\n}> = ({ children, colorScheme = true }) => {\n const hostContext = useHostContextSubscription();\n const [systemPreference, setSystemPreference] = useState<\"light\" | \"dark\">(\n () => {\n if (typeof window === \"undefined\") return \"light\";\n return window.matchMedia(\"(prefers-color-scheme: dark)\").matches\n ? \"dark\"\n : \"light\";\n }\n );\n\n React.useEffect(() => {\n if (typeof window === \"undefined\") return;\n const mediaQuery = window.matchMedia(\"(prefers-color-scheme: dark)\");\n const handleChange = (event: MediaQueryListEvent) => {\n setSystemPreference(event.matches ? \"dark\" : \"light\");\n };\n mediaQuery.addEventListener(\"change\", handleChange);\n return () => mediaQuery.removeEventListener(\"change\", handleChange);\n }, []);\n\n const hostTheme =\n hostContext?.theme === \"dark\" || hostContext?.theme === \"light\"\n ? hostContext.theme\n : undefined;\n const effectiveTheme = hostTheme ?? systemPreference;\n\n useLayoutEffect(() => {\n if (typeof document === \"undefined\") return;\n applyDocumentTheme(effectiveTheme);\n if (colorScheme) {\n document.documentElement.style.colorScheme =\n effectiveTheme === \"dark\" ? \"dark\" : \"light\";\n } else {\n document.documentElement.style.colorScheme = \"\";\n }\n }, [effectiveTheme, colorScheme]);\n\n useLayoutEffect(() => {\n const variables = hostContext?.styles?.variables;\n if (variables) {\n applyHostStyleVariables(variables);\n }\n const fonts = hostContext?.styles?.css?.fonts;\n if (typeof fonts === \"string\") {\n applyHostFonts(fonts);\n }\n }, [hostContext]);\n\n return <>{children}</>;\n};\n","import React, { useRef, useState } from \"react\";\n\nimport { useDisplayMode } from \"../hooks/use-display-mode.js\";\nimport { useHostContext } from \"../hooks/use-host-context.js\";\nimport { useToolContext } from \"../hooks/use-tool-context.js\";\n\n/**\n * Static styles for the debug overlay. Hoisted to module scope so the objects\n * keep stable identities across renders (this runtime ships no stylesheet, so\n * CSS classes are not an option here).\n */\nconst debugOverlayStyle: React.CSSProperties = {\n position: \"fixed\",\n inset: 0,\n zIndex: 10000,\n boxSizing: \"border-box\",\n padding: \"56px 16px 16px\",\n background: \"#111\",\n color: \"#eee\",\n overflow: \"auto\",\n};\n\nconst debugContentStyle: React.CSSProperties = {\n margin: 0,\n fontSize: 12,\n whiteSpace: \"pre-wrap\",\n overflowWrap: \"anywhere\",\n};\n\nconst debugCloseButtonStyle: React.CSSProperties = {\n position: \"fixed\",\n top: 16,\n right: 16,\n zIndex: 10001,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n width: 36,\n height: 36,\n padding: 0,\n border: \"2px solid #111\",\n borderRadius: 9999,\n background: \"#fff\",\n color: \"#111\",\n boxShadow: \"0 2px 12px rgba(0, 0, 0, 0.45)\",\n cursor: \"pointer\",\n fontSize: 26,\n fontWeight: 600,\n lineHeight: 1,\n};\n\ninterface ViewControlsProps {\n children: React.ReactNode;\n /** Show a debug overlay with view state and action testers. */\n debugger?: boolean;\n /** Show fullscreen / PiP display-mode buttons. */\n viewControls?: boolean | \"pip\" | \"fullscreen\";\n}\n\n/**\n * Dev-only overlay with debug info and bridge action testers.\n */\nexport function ViewControls({\n children,\n debugger: enableDebugger = false,\n viewControls = false,\n}: ViewControlsProps) {\n const context = useToolContext();\n const host = useHostContext();\n const { displayMode, availableDisplayModes, requestDisplayMode } =\n useDisplayMode();\n const [open, setOpen] = useState(false);\n const [hovered, setHovered] = useState(false);\n const displayModeBeforeDebugRef = useRef(displayMode);\n const restoreDisplayModeOnCloseRef = useRef(false);\n\n const showControls = enableDebugger || viewControls;\n\n const openDebugger = () => {\n displayModeBeforeDebugRef.current = displayMode;\n setOpen(true);\n\n const canExpand =\n displayMode !== \"fullscreen\" &&\n availableDisplayModes.includes(\"fullscreen\");\n restoreDisplayModeOnCloseRef.current = canExpand;\n\n if (canExpand) {\n void requestDisplayMode({ mode: \"fullscreen\" }).catch(() => {\n // The overlay remains usable inline when the host denies expansion.\n restoreDisplayModeOnCloseRef.current = false;\n });\n }\n };\n\n const closeDebugger = () => {\n setOpen(false);\n\n if (!restoreDisplayModeOnCloseRef.current) return;\n restoreDisplayModeOnCloseRef.current = false;\n void requestDisplayMode({\n mode: displayModeBeforeDebugRef.current,\n }).catch(() => {\n // The host owns display mode; closing the overlay must never be blocked.\n });\n };\n\n return (\n <div\n style={{ position: \"relative\" }}\n onMouseEnter={() => setHovered(true)}\n onMouseLeave={() => setHovered(false)}\n >\n {showControls && (\n <div\n style={{\n position: \"absolute\",\n top: 8,\n right: 8,\n zIndex: 1000,\n display: \"flex\",\n gap: 8,\n opacity: hovered ? 1 : 0,\n transition: \"opacity 0.2s\",\n }}\n >\n {viewControls && host.displayMode === \"inline\" && (\n <>\n {(viewControls === true || viewControls === \"fullscreen\") && (\n <button\n type=\"button\"\n aria-label=\"Fullscreen\"\n onClick={() =>\n void requestDisplayMode({ mode: \"fullscreen\" })\n }\n >\n FS\n </button>\n )}\n {(viewControls === true || viewControls === \"pip\") && (\n <button\n type=\"button\"\n aria-label=\"Picture in picture\"\n onClick={() => void requestDisplayMode({ mode: \"pip\" })}\n >\n PiP\n </button>\n )}\n </>\n )}\n {enableDebugger && (\n <button type=\"button\" aria-label=\"Debug\" onClick={openDebugger}>\n Debug\n </button>\n )}\n </div>\n )}\n {children}\n {enableDebugger && open && (\n <div\n style={debugOverlayStyle}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label=\"Debug info\"\n >\n <button\n type=\"button\"\n style={debugCloseButtonStyle}\n aria-label=\"Close debug\"\n title=\"Close debug\"\n onClick={closeDebugger}\n >\n ×\n </button>\n <pre style={debugContentStyle}>\n {JSON.stringify(\n {\n status: context.status,\n toolOutput:\n context.status === \"ready\" ? context.toolOutput : undefined,\n content:\n context.status === \"ready\" || context.status === \"error\"\n ? context.content\n : undefined,\n toolInput: context.toolInput,\n meta:\n context.status === \"ready\" || context.status === \"error\"\n ? context.meta\n : undefined,\n error: context.status === \"error\" ? context.error : undefined,\n theme: host.theme,\n displayMode: host.displayMode,\n isAvailable: host.isAvailable,\n },\n null,\n 2\n )}\n </pre>\n </div>\n )}\n </div>\n );\n}\n","import { useSyncExternalStore } from \"react\";\n\nimport { useViewRuntime } from \"../runtime/view-runtime-context.js\";\nimport type { DisplayMode } from \"../types/host-types.js\";\n\n/**\n * Read the current display mode and request changes from the host.\n *\n * @remarks\n * `requestDisplayMode` is advisory: the host decides whether to honor it and\n * may grant a different mode or none at all. The returned promise resolves\n * once the host has processed the request — resolution does **not** mean the\n * mode changed. The single source of truth for the outcome is `displayMode`,\n * which updates reactively when the host applies a change; a denied request\n * simply leaves it unchanged. Do not store the requested mode in local state —\n * render from `displayMode` so the view also tracks mode changes the host\n * makes on its own (for example, the user exiting fullscreen).\n *\n * `displayMode` is `\"inline\"` until the host reports otherwise.\n * `availableDisplayModes` is the negotiated intersection of\n * `viewConfig.displayModes` and `hostContext.availableDisplayModes`. When the\n * host omits available modes, only `\"inline\"` is requestable.\n * `requestDisplayMode` rejects modes outside that intersection before sending;\n * the method itself is runtime-owned and referentially stable.\n *\n * @example\n * ```tsx\n * function ExpandButton() {\n * const { displayMode, availableDisplayModes, requestDisplayMode } =\n * useDisplayMode();\n * if (!availableDisplayModes.includes(\"fullscreen\")) return null;\n * if (displayMode === \"fullscreen\") return null;\n * return (\n * <button\n * type=\"button\"\n * onClick={() => {\n * void requestDisplayMode({ mode: \"fullscreen\" });\n * }}\n * >\n * Expand\n * </button>\n * );\n * }\n * ```\n */\nexport function useDisplayMode(): {\n /** How the host is currently displaying the view; `\"inline\"` until the host reports otherwise. */\n displayMode: DisplayMode;\n /**\n * Negotiated modes: intersection of `viewConfig.displayModes` and host\n * `availableDisplayModes` (host omits → only `\"inline\"`).\n */\n availableDisplayModes: readonly DisplayMode[];\n /**\n * Ask the host to switch display mode. Rejects when the mode is outside the\n * negotiated intersection. Resolves when the host has processed the request;\n * observe `displayMode` for the outcome.\n */\n requestDisplayMode: (args: { mode: DisplayMode }) => Promise<void>;\n} {\n const runtime = useViewRuntime();\n const { displayMode, availableDisplayModes } = useSyncExternalStore(\n runtime.subscribeDisplay,\n runtime.getDisplaySnapshot\n );\n return {\n displayMode,\n availableDisplayModes,\n requestDisplayMode: runtime.requestDisplayMode,\n };\n}\n","import { useSyncExternalStore } from \"react\";\n\nimport { useViewRuntime } from \"../runtime/view-runtime-context.js\";\nimport type {\n DisplayMode,\n HostCapabilities,\n HostContext,\n HostInfo,\n SafeAreaInsets,\n} from \"../types/host-types.js\";\n\nconst DEFAULT_SAFE_AREA: SafeAreaInsets = {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0,\n};\n\nfunction readMaxHeight(\n hostContext: HostContext | undefined\n): number | undefined {\n const dims = hostContext?.containerDimensions;\n if (!dims) return undefined;\n if (\"height\" in dims && typeof dims.height === \"number\") return dims.height;\n if (\"maxHeight\" in dims && typeof dims.maxHeight === \"number\") {\n return dims.maxHeight;\n }\n return undefined;\n}\n\nfunction readMaxWidth(\n hostContext: HostContext | undefined\n): number | undefined {\n const dims = hostContext?.containerDimensions;\n if (!dims) return undefined;\n if (\"width\" in dims && typeof dims.width === \"number\") return dims.width;\n if (\"maxWidth\" in dims && typeof dims.maxWidth === \"number\") {\n return dims.maxWidth;\n }\n return undefined;\n}\n\nfunction resolveDisplayMode(hostContext: HostContext | undefined): DisplayMode {\n return hostContext?.displayMode === \"fullscreen\" ||\n hostContext?.displayMode === \"pip\"\n ? hostContext.displayMode\n : \"inline\";\n}\n\n/**\n * Host environment and bridge availability for the current view.\n */\nexport interface HostContextHandle {\n /** Host color theme. `\"light\"` until the host reports a theme. */\n theme: \"light\" | \"dark\";\n /** User locale (BCP 47). Falls back to `\"en-US\"` when the host does not report one. */\n locale: string;\n /** User timezone (IANA). Falls back to the browser's timezone, then `\"UTC\"`. */\n timeZone: string;\n /** Host application user-agent string. Falls back to the browser's own user agent. */\n userAgent: string;\n /** How the host is currently displaying the view. `\"inline\"` until the host reports otherwise. */\n displayMode: DisplayMode;\n /** Mobile safe area insets in pixels. All zeros when the host reports none. */\n safeArea: SafeAreaInsets;\n /**\n * Vertical layout budget in pixels: the most height the view can occupy.\n *\n * Derived from the host's container dimensions. When the host fixes the\n * container to an exact height, that height is reported; otherwise the\n * host's stated maximum is. `undefined` when the host reports no layout\n * constraint — treat that as unbounded. The raw dimensions remain available\n * on `hostContext.containerDimensions`.\n */\n maxHeight: number | undefined;\n /**\n * Horizontal layout budget in pixels: the most width the view can occupy.\n *\n * Same derivation as `maxHeight`: an exact container width when the host\n * fixes one, otherwise the host's stated maximum, otherwise `undefined`\n * (unbounded).\n */\n maxWidth: number | undefined;\n /** Host identity (name and version). `undefined` until the bridge has connected. */\n hostInfo: HostInfo | undefined;\n /** Host capabilities negotiated at initialization. `undefined` until the bridge has connected. */\n hostCapabilities: HostCapabilities | undefined;\n /**\n * The host context object exactly as the host reported it, with none of the\n * fallbacks the fields above apply. Use it to read host-specific fields this\n * handle does not surface. `undefined` until the host first reports context.\n */\n hostContext: HostContext | undefined;\n /** Whether the MCP Apps bridge is connected. While `false`, every field holds its documented fallback. */\n isAvailable: boolean;\n}\n\n/**\n * Subscribe to host environment context (theme, locale, display mode, layout).\n *\n * Re-renders only when host context or bridge connection status changes — not\n * on tool-input / result / cancel snapshot updates.\n *\n * @example\n * ```tsx\n * function Layout() {\n * const { theme, locale, maxHeight } = useHostContext();\n * return (\n * <div data-theme={theme} lang={locale} style={{ maxHeight }}>\n * …\n * </div>\n * );\n * }\n * ```\n */\nexport function useHostContext(): HostContextHandle {\n const runtime = useViewRuntime();\n const { hostContext, isConnected } = useSyncExternalStore(\n runtime.subscribeHost,\n runtime.getHostSnapshot\n );\n const app = runtime.getApp();\n\n return {\n theme: hostContext?.theme === \"dark\" ? \"dark\" : \"light\",\n locale:\n typeof hostContext?.locale === \"string\" ? hostContext.locale : \"en-US\",\n timeZone:\n typeof hostContext?.timeZone === \"string\"\n ? hostContext.timeZone\n : typeof Intl !== \"undefined\"\n ? Intl.DateTimeFormat().resolvedOptions().timeZone\n : \"UTC\",\n userAgent:\n typeof hostContext?.userAgent === \"string\"\n ? hostContext.userAgent\n : typeof navigator !== \"undefined\"\n ? navigator.userAgent\n : \"\",\n displayMode: resolveDisplayMode(hostContext),\n safeArea: hostContext?.safeAreaInsets ?? DEFAULT_SAFE_AREA,\n maxHeight: readMaxHeight(hostContext),\n maxWidth: readMaxWidth(hostContext),\n hostInfo: app?.getHostVersion(),\n hostCapabilities: app?.getHostCapabilities(),\n hostContext,\n isAvailable: isConnected,\n };\n}\n","import type { ContentBlock } from \"@modelcontextprotocol/server\";\nimport { useSyncExternalStore } from \"react\";\n\nimport { useViewRuntime } from \"../runtime/view-runtime-context.js\";\nimport type { DeepPartial, RegisteredTools } from \"../types/register.js\";\nimport type { ToolContextError } from \"../types/result-types.js\";\n\nexport type { ToolContextError } from \"../types/result-types.js\";\n\ntype ToolOutput<Name extends keyof RegisteredTools> =\n Name extends keyof RegisteredTools\n ? RegisteredTools[Name][\"output\"]\n : unknown;\n\ntype ToolInput<Name extends keyof RegisteredTools> =\n Name extends keyof RegisteredTools ? RegisteredTools[Name][\"input\"] : unknown;\n\n/** No structured result has been latched yet. */\ninterface PendingToolContext<Name extends keyof RegisteredTools> {\n status: \"pending\";\n /** Latest complete or partial arguments; each notification replaces it. */\n toolInput: DeepPartial<ToolInput<Name>> | undefined;\n toolOutput: undefined;\n content: undefined;\n meta: undefined;\n error?: undefined;\n}\n\n/** First non-error result carrying `structuredContent`. */\ninterface ReadyToolContext<Name extends keyof RegisteredTools> {\n status: \"ready\";\n /** Latest arguments delivered before the result, when available. */\n toolInput: ToolInput<Name> | undefined;\n /** Typed `structuredContent` from the latched rendering result. */\n toolOutput: ToolOutput<Name>;\n content: ContentBlock[] | undefined;\n /** View-only result `_meta`, when present. */\n meta: Record<string, unknown> | undefined;\n error?: undefined;\n}\n\n/** First tool result carrying `isError: true`. */\ninterface ErrorToolContext<Name extends keyof RegisteredTools> {\n status: \"error\";\n /** Latest arguments delivered before the error, when available. */\n toolInput: ToolInput<Name> | undefined;\n toolOutput: undefined;\n content: ContentBlock[] | undefined;\n meta: Record<string, unknown> | undefined;\n error: ToolContextError;\n}\n\n/**\n * The rendering invocation's latched lifecycle.\n *\n * Partial and complete input notifications replace the same `toolInput`\n * snapshot while pending. Because the MCP Apps notification has no tool name\n * or request id, the first structured result or tool error is assumed to\n * belong to the rendering invocation and becomes terminal. Content-only\n * successes are valid ambient activity and are ignored.\n */\nexport type ToolContextHandle<Name extends keyof RegisteredTools = never> =\n | PendingToolContext<Name>\n | ReadyToolContext<Name>\n | ErrorToolContext<Name>;\n\n/**\n * Read the tool invocation that rendered this View.\n *\n * The hook starts pending with an optional progressive `toolInput`, then\n * latches the first structured success or tool error for the View's lifetime.\n * Later lifecycle notifications cannot overwrite that terminal context.\n *\n * @example\n * ```tsx\n * function ProductSearchResult() {\n * const view = useToolContext<\"search-fruits\">();\n *\n * if (view.status === \"error\") {\n * return <ToolErrorBanner message={view.error.message} />;\n * }\n * if (view.status === \"pending\") {\n * return <SearchSkeleton query={view.toolInput?.query} />;\n * }\n * return <Results items={view.toolOutput.items} />;\n * }\n * ```\n */\nexport function useToolContext<\n Name extends keyof RegisteredTools = never,\n>(): ToolContextHandle<Name> {\n const runtime = useViewRuntime();\n const snap = useSyncExternalStore(\n runtime.subscribeTool,\n runtime.getToolSnapshot\n );\n\n if (snap.status === \"error\") {\n return {\n status: \"error\",\n toolInput: snap.toolInput as ToolInput<Name> | undefined,\n toolOutput: undefined,\n content: snap.content,\n meta: snap.meta,\n error: snap.error as ToolContextError,\n };\n }\n\n if (snap.status === \"ready\") {\n return {\n status: \"ready\",\n toolInput: snap.toolInput as ToolInput<Name> | undefined,\n toolOutput: snap.toolOutput as ToolOutput<Name>,\n content: snap.content,\n meta: snap.meta,\n };\n }\n\n return {\n status: \"pending\",\n toolInput: snap.toolInput as DeepPartial<ToolInput<Name>> | undefined,\n toolOutput: undefined,\n content: undefined,\n meta: undefined,\n };\n}\n","import { useCallback, useRef, useState } from \"react\";\n\nimport type { ToolRef } from \"../../tools.js\";\nimport { useViewRuntime } from \"../runtime/view-runtime-context.js\";\nimport type { RegisteredTools } from \"../types/register.js\";\nimport {\n ToolError,\n type CallToolResult,\n type CallToolSuccess,\n} from \"../types/result-types.js\";\n\nexport type { CallToolSuccess } from \"../types/result-types.js\";\nexport { ToolError } from \"../types/result-types.js\";\n\n/**\n * Typed server-tool call handle returned by {@link useCallTool}.\n *\n * @typeParam Args - Tool argument object type.\n * @typeParam Result - Expected `structuredContent` type for a successful result.\n */\nexport interface CallToolHandle<Args, Result> {\n /**\n * Invoke the server tool over the bridge.\n *\n * Every non-error result resolves. `structuredContent` is guaranteed and\n * typed exactly when the tool declares an `outputSchema` — the server\n * rejects non-error results from schema-backed tools that lack it, so a\n * resolved result from a schema'd tool always carries it. Tools without an\n * `outputSchema` legitimately return content-only results.\n *\n * @param args - Tool arguments matching the registered input schema.\n * @returns Successful result ({@link CallToolSuccess}).\n * @throws {@link ToolError} when the tool answers with `isError: true`.\n * Transport, RPC, and missing-`serverTools` failures also reject with an\n * `Error`.\n */\n callTool: (args: Args) => Promise<CallToolSuccess<Result>>;\n /**\n * Last successful result only. Preserved while a later request is pending\n * or fails (tool error / transport).\n */\n data: CallToolSuccess<Result> | undefined;\n /**\n * Last failure ({@link ToolError} or transport/RPC/capability `Error`).\n * Cleared on the next call.\n */\n error: Error | undefined;\n /** Whether a call is in flight. */\n isPending: boolean;\n}\n\n/**\n * Call a registered server tool from the view with inferred types.\n *\n * Successful results populate `data` and clear `error`. Tool errors and\n * transport failures reject and populate `error` while preserving previous\n * `data`. Prefer reading `data` / `error` from the handle for React UI; use\n * try/catch for imperative flows.\n *\n * @example\n * ```tsx\n * const details = useCallTool(\"get-fruit-details\");\n *\n * // State-driven (typical in React):\n * // {details.error && <ErrorBanner message={details.error.message} />}\n * // {details.data && <DetailsCard data={details.data.structuredContent} />}\n *\n * // Imperative:\n * try {\n * const result = await details.callTool({ fruit: \"apple\" });\n * showDetails(result.structuredContent);\n * } catch (err) {\n * if (err instanceof ToolError) {\n * showToolError(err.message);\n * }\n * }\n * ```\n */\nexport function useCallTool<Name extends keyof RegisteredTools>(\n name: Name\n): CallToolHandle<\n RegisteredTools[Name][\"input\"],\n RegisteredTools[Name][\"output\"]\n>;\n\n/**\n * Call a server tool using a {@link ToolRef} value (inline-JSX stretch path).\n *\n * @typeParam R - Tool ref carrying name, input, and output types.\n */\n// eslint-disable-next-line no-redeclare -- overload set\nexport function useCallTool<R extends ToolRef<string, unknown, unknown>>(\n ref: R\n): CallToolHandle<\n R extends ToolRef<string, infer I, unknown> ? I : never,\n R extends ToolRef<string, unknown, infer O> ? O : never\n>;\n\n/**\n * Call a server tool with explicit argument/result types (escape hatch).\n *\n * @typeParam Args - Explicit argument object type.\n * @typeParam Result - Explicit `structuredContent` type.\n */\n// eslint-disable-next-line no-redeclare -- overload set\nexport function useCallTool<\n Args extends Record<string, unknown>,\n Result = unknown,\n>(name: string): CallToolHandle<Args, Result>;\n\n// eslint-disable-next-line no-redeclare -- implementation signature\nexport function useCallTool(\n nameOrRef: string | ToolRef<string, unknown, unknown>\n) {\n const toolName = typeof nameOrRef === \"string\" ? nameOrRef : nameOrRef.name;\n const runtime = useViewRuntime();\n const [data, setData] = useState<CallToolSuccess<unknown> | undefined>(\n undefined\n );\n const [error, setError] = useState<Error | undefined>(undefined);\n const [isPending, setIsPending] = useState(false);\n const callIdRef = useRef(0);\n\n const callTool = useCallback(\n async (\n args: Record<string, unknown>\n ): Promise<CallToolSuccess<unknown>> => {\n const callId = ++callIdRef.current;\n setIsPending(true);\n setError(undefined);\n\n try {\n const result = await runtime.callServerTool({\n name: toolName,\n arguments: args,\n });\n\n if (result.isError === true) {\n throw new ToolError(result as CallToolResult & { isError: true });\n }\n\n const typed = result as CallToolSuccess<unknown>;\n if (callId === callIdRef.current) {\n setData(typed);\n setIsPending(false);\n }\n return typed;\n } catch (err) {\n const failure = err instanceof Error ? err : new Error(String(err));\n if (callId === callIdRef.current) {\n setError(failure);\n setIsPending(false);\n }\n throw failure;\n }\n },\n [runtime, toolName]\n );\n\n return { callTool, data, error, isPending };\n}\n","import { useCallback } from \"react\";\n\nimport { useViewRuntime } from \"../runtime/view-runtime-context.js\";\n\n/**\n * Returns a callback that asks the host to open a URL outside the view.\n *\n * @remarks\n * Requires the host `openLinks` capability; otherwise the returned promise\n * rejects before any wire traffic. The host decides how (and whether) to open\n * the link — typically in the user's browser, often behind a confirmation\n * prompt — so treat it as a request, not a guaranteed navigation. Views run\n * sandboxed and cannot navigate the user themselves; this is the supported\n * way to link out.\n *\n * The returned callback is referentially stable for the lifetime of the\n * mounted runtime.\n *\n * @example\n * ```tsx\n * function DocsLink() {\n * const openExternal = useOpenExternal();\n * return (\n * <button\n * type=\"button\"\n * onClick={() => {\n * void openExternal({ url: \"https://example.com/docs\" });\n * }}\n * >\n * Open docs\n * </button>\n * );\n * }\n * ```\n */\nexport function useOpenExternal(): (args: { url: string }) => Promise<void> {\n const runtime = useViewRuntime();\n return useCallback(\n async (args: { url: string }) => {\n await runtime.openLink({ url: args.url });\n },\n [runtime]\n );\n}\n","import { useCallback } from \"react\";\n\nimport { useViewRuntime } from \"../runtime/view-runtime-context.js\";\n\n/**\n * Returns a callback that sends a follow-up message to the conversation,\n * triggering a model turn.\n *\n * @remarks\n * Requires the host `message` capability; otherwise the returned promise\n * rejects before any wire traffic. The prompt is delivered to the host as a\n * user-authored chat message, as if the user had typed it. The returned\n * promise resolves when the host accepts the message — not when the model\n * responds; any response arrives through the normal conversation flow (and, if\n * the model calls this view's tool again, through {@link useToolContext}).\n * Hosts may require user confirmation or decline the message entirely.\n *\n * The returned callback is referentially stable for the lifetime of the\n * mounted runtime.\n *\n * @example\n * ```tsx\n * function AskAgain() {\n * const sendFollowUp = useSendFollowUp();\n * return (\n * <button\n * type=\"button\"\n * onClick={() => sendFollowUp({ prompt: \"Show more results\" })}\n * >\n * Refine search\n * </button>\n * );\n * }\n * ```\n */\nexport function useSendFollowUp(): (args: { prompt: string }) => Promise<void> {\n const runtime = useViewRuntime();\n return useCallback(\n async (args: { prompt: string }) => {\n await runtime.sendMessage({\n role: \"user\",\n content: [{ type: \"text\", text: args.prompt }],\n });\n },\n [runtime]\n );\n}\n","import { useViewRuntime } from \"../runtime/view-runtime-context.js\";\n\n/**\n * Returns a callback that notifies the host of the view's size via\n * `ui/notifications/size-changed`.\n *\n * Pair with `viewConfig.autoResize: false` when the view's height derives from\n * its width (for example a fixed aspect-ratio container). Ext-apps auto-resize\n * measures the document under `height: max-content`, which collapses those\n * layouts; disable it and report `{ width, height }` from a `ResizeObserver`\n * (or equivalent) instead.\n *\n * Returns the runtime-owned `sendSizeChanged` method — referentially stable\n * for the lifetime of the mounted runtime.\n *\n * @example\n * ```tsx\n * import {\n * ThemeProvider,\n * useSendSizeChanged,\n * type ViewConfig,\n * } from \"mcp-use/react\";\n * import { useEffect, useRef } from \"react\";\n *\n * export const viewConfig = {\n * autoResize: false,\n * displayModes: [\"inline\", \"fullscreen\"],\n * } satisfies ViewConfig;\n *\n * export default function AspectRatioView() {\n * return (\n * <ThemeProvider>\n * <AspectRatioContent />\n * </ThemeProvider>\n * );\n * }\n *\n * function AspectRatioContent() {\n * const ref = useRef<HTMLDivElement>(null);\n * const sendSizeChanged = useSendSizeChanged();\n *\n * useEffect(() => {\n * const element = ref.current;\n * if (!element) return;\n *\n * const observer = new ResizeObserver(([entry]) => {\n * if (!entry) return;\n * const { width, height } = entry.contentRect;\n * void sendSizeChanged({ width, height });\n * });\n *\n * observer.observe(element);\n * return () => observer.disconnect();\n * }, [sendSizeChanged]);\n *\n * return <div ref={ref} style={{ width: \"100%\", aspectRatio: \"4 / 3\" }} />;\n * }\n * ```\n */\nexport function useSendSizeChanged(): (size: {\n width?: number;\n height?: number;\n}) => Promise<void> {\n const runtime = useViewRuntime();\n return runtime.sendSizeChanged;\n}\n","import { useSyncExternalStore } from \"react\";\n\nimport { useViewRuntime } from \"../runtime/view-runtime-context.js\";\n\n/**\n * Subscribe to the host color theme only.\n *\n * @remarks\n * Returns the same value as {@link useHostContext}'s `theme` and updates live\n * when the user or host switches themes. Prefer this hook when theme is all a\n * component needs: it re-renders only when the resolved theme string changes,\n * never on locale, dimensions, display mode, or tool updates. Returns\n * `\"light\"` until the host reports a theme.\n *\n * @example\n * ```tsx\n * const theme = useViewTheme();\n * ```\n */\nexport function useViewTheme(): \"light\" | \"dark\" {\n const runtime = useViewRuntime();\n return useSyncExternalStore(runtime.subscribeTheme, runtime.getThemeSnapshot);\n}\n","import type {\n InputRequiredResult,\n ToolAnnotations,\n} from \"@modelcontextprotocol/server\";\nimport { useEffect, useRef } from \"react\";\n\nimport type {\n InferToolInput,\n InferToolOutput,\n ToolDefinition,\n ToolResult,\n} from \"../../tools.js\";\nimport { resolveToolInputSchema } from \"../../tools.js\";\nimport { useViewRuntime } from \"../runtime/view-runtime-context.js\";\nimport type { McpAppRuntime } from \"../runtime/view-runtime.js\";\n\n/** View-tool definition — mirrors {@link ToolDefinition} plus `enabled`. */\nexport type ViewToolDefinition = Pick<\n ToolDefinition,\n | \"name\"\n | \"title\"\n | \"description\"\n | \"inputSchema\"\n | \"schema\"\n | \"outputSchema\"\n | \"annotations\"\n> & {\n /** When `false`, the tool stays registered but is not listed or callable. */\n enabled?: boolean;\n};\n\n/** Handle returned by {@link McpAppRuntime.registerViewTool}. */\ntype RegisteredViewTool = ReturnType<McpAppRuntime[\"registerViewTool\"]>;\n\n/**\n * Register an ephemeral tool the host/model can call while this component is mounted.\n *\n * Registration is synchronous against the runtime-owned App and independent\n * of connection completion. It is keyed by `name` only (`[runtime, name]`):\n * the tool registers once per mounted name and is removed on unmount. Changing\n * `inputSchema` / `outputSchema` without changing `name` does **not**\n * re-register — schemas are captured at registration time (ext-apps fixes\n * handler arity at registration); to change a tool's schema, register it under\n * a new name. `schema` is accepted as an alias for `inputSchema`.\n *\n * `title`, `description`, and `annotations` changes are applied in place via\n * the ext-apps handle's `update()`, passing explicit `undefined` so omitted\n * fields are cleared. Toggling `enabled` calls `enable()` / `disable()`\n * without re-registering. The handler is kept in a ref so calls always see\n * current React state. Registration goes through\n * {@link McpAppRuntime.registerViewTool} (never `app.registerTool` directly)\n * so the runtime can perform the empty-handler handoff on first registration.\n *\n * Cleanup captures the registration handle inside the effect so an older\n * cleanup cannot remove a newer registration (e.g. after a rapid `name`\n * change). Registration failures are reported with `console.error` and do not\n * leave half-registered state.\n *\n * @example\n * ```tsx\n * useViewTool(\n * { name: \"highlight-fruit\", inputSchema: z.object({ id: z.string() }) },\n * async ({ id }) => {\n * setSelected(id);\n * return { content: [{ type: \"text\", text: `Highlighted ${id}` }] };\n * }\n * );\n * ```\n */\nexport function useViewTool<\n const TDef extends ViewToolDefinition,\n TInput = InferToolInput<TDef>,\n TOutput = InferToolOutput<TDef>,\n>(\n definition: TDef,\n handler: (\n args: TInput\n ) =>\n | Exclude<ToolResult<TOutput>, InputRequiredResult>\n | Promise<Exclude<ToolResult<TOutput>, InputRequiredResult>>\n): void {\n const runtime = useViewRuntime();\n const handlerRef = useRef(handler);\n handlerRef.current = handler;\n const definitionRef = useRef<ViewToolDefinition>(definition);\n definitionRef.current = definition;\n // Shared only for post-registration metadata / enabled updates. Cleanup\n // never removes through this ref alone — each registering effect removes\n // only the handle it captured locally.\n const registeredRef = useRef<RegisteredViewTool | null>(null);\n const registeredMetadataRef = useRef<{\n registration: RegisteredViewTool;\n title: string | undefined;\n description: string | undefined;\n annotationsJson: string | undefined;\n } | null>(null);\n\n const { name, title, description, enabled = true } = definition;\n // Annotations are plain JSON data (MCP wire shape); serialize for change\n // detection so inline literals don't retrigger effects by identity.\n const annotationsJson =\n definition.annotations === undefined\n ? undefined\n : JSON.stringify(definition.annotations);\n\n useEffect(() => {\n const def = definitionRef.current;\n const config: {\n title?: string;\n description?: string;\n inputSchema?: NonNullable<ViewToolDefinition[\"inputSchema\"]>;\n outputSchema?: NonNullable<ViewToolDefinition[\"outputSchema\"]>;\n annotations?: ToolAnnotations;\n } = {};\n\n if (def.title !== undefined) config.title = def.title;\n if (def.description !== undefined) config.description = def.description;\n const inputSchema = resolveToolInputSchema(def);\n if (inputSchema !== undefined) config.inputSchema = inputSchema;\n if (def.outputSchema !== undefined) {\n config.outputSchema = def.outputSchema;\n }\n if (def.annotations !== undefined) {\n config.annotations = def.annotations;\n }\n\n // ext-apps fixes callback arity at registration: schema-backed tools call\n // `(parsedArgs, extra)`, while schema-less tools call `(extra)`. Adapt the\n // latter so the public handler receives an empty input object rather than\n // RequestHandlerExtra. Validation remains entirely owned by ext-apps.\n const callback =\n inputSchema !== undefined\n ? async (args: unknown) => handlerRef.current(args as TInput)\n : async (_extra: unknown) => handlerRef.current({} as TInput);\n\n let registration: RegisteredViewTool;\n try {\n registration = runtime.registerViewTool(name, config, callback);\n } catch (error: unknown) {\n console.error(\n `[mcp-use] useViewTool failed to register tool \"${name}\":`,\n error\n );\n return;\n }\n\n registeredRef.current = registration;\n registeredMetadataRef.current = {\n registration,\n title: def.title,\n description: def.description,\n annotationsJson:\n def.annotations === undefined\n ? undefined\n : JSON.stringify(def.annotations),\n };\n\n if (def.enabled === false) {\n registration.disable();\n }\n\n return () => {\n if (registeredRef.current === registration) {\n registeredRef.current = null;\n }\n if (registeredMetadataRef.current?.registration === registration) {\n registeredMetadataRef.current = null;\n }\n try {\n registration.remove();\n } catch {\n // App may already be closing during disposal. Swallow quietly.\n }\n };\n }, [runtime, name]);\n\n useEffect(() => {\n const registered = registeredRef.current;\n // Pre-registration changes are picked up from definitionRef at\n // registration time; this effect only applies post-registration edits.\n if (!registered) return;\n const applied = registeredMetadataRef.current;\n if (\n applied?.registration === registered &&\n applied.title === title &&\n applied.description === description &&\n applied.annotationsJson === annotationsJson\n ) {\n return;\n }\n const def = definitionRef.current;\n // Pass explicit undefined so Object.assign clears previously set fields.\n // Cast: exactOptionalPropertyTypes rejects `string | undefined` on\n // Partial<{ title?: string }>, but ext-apps' update uses Object.assign\n // and listing omits falsy/undefined metadata — explicit undefined is\n // required to clear.\n registered.update({\n title: def.title,\n description: def.description,\n annotations: def.annotations,\n } as Parameters<RegisteredViewTool[\"update\"]>[0]);\n registeredMetadataRef.current = {\n registration: registered,\n title: def.title,\n description: def.description,\n annotationsJson:\n def.annotations === undefined\n ? undefined\n : JSON.stringify(def.annotations),\n };\n }, [title, description, annotationsJson]);\n\n useEffect(() => {\n const registered = registeredRef.current;\n if (!registered || registered.enabled === enabled) return;\n if (enabled) {\n registered.enable();\n } else {\n registered.disable();\n }\n }, [enabled]);\n}\n","import type {\n CallToolResult,\n InputRequiredResult,\n StandardSchemaWithJSON,\n ToolAnnotations,\n} from \"@modelcontextprotocol/server\";\n\nimport type { McpUiResourceCsp } from \"@modelcontextprotocol/ext-apps\";\n\nimport type { RequestContext } from \"./context.js\";\nimport type { UiPermissions } from \"./views/types.js\";\n\n/**\n * Binds a tool to a view directory for MCP Apps rendering.\n *\n * Any number of tools may share the same `name`. Resource facts\n * (`description`, `csp`, `permissions`, `domain`, `prefersBorder`) have one\n * authoring point — at most one binder may declare them; others pass only\n * `{ name }`. The view file exports only the component; the framework reads\n * these fields at registration and emits them on the bound view's MCP\n * resource (hosts read resource `_meta.ui`, not tool-level copies).\n */\nexport interface ToolViewConfig {\n /** View directory / manifest name, e.g. `\"product-search-result\"`. */\n name: string;\n /**\n * Human-readable description of the view resource → the resource's\n * `description` on `resources/list` and `resources/read`.\n */\n description?: string;\n /**\n * CSP domains the host must allow → resource `_meta.ui.csp`. The framework\n * auto-appends its serving origin to `resourceDomains` at emission time;\n * other author-set fields (`frameDomains`, `baseUriDomains`, …) pass through.\n */\n csp?: McpUiResourceCsp;\n /** Sandbox permissions the view needs → resource `_meta.ui.permissions`. */\n permissions?: UiPermissions;\n /**\n * Dedicated origin hint for hosts that render views on a separate domain →\n * resource `_meta.ui.domain`.\n */\n domain?: string;\n /**\n * Ask the host to draw a border around the view → resource\n * `_meta.ui.prefersBorder`.\n */\n prefersBorder?: boolean;\n}\n\n/** Declares a tool's identity, LLM-facing description, and schemas. First argument to {@link MCPServer.tool}. */\nexport interface ToolDefinition {\n /** Unique tool identifier, e.g. `\"fetch-weather\"`. */\n name: string;\n /** Human-readable title shown in UIs (falls back to `name`). */\n title?: string;\n /** LLM-facing description of what the tool does. */\n description?: string;\n /**\n * Object schema for input validation — any Standard Schema library with\n * JSON Schema conversion ({@link StandardSchemaWithJSON}): zod v4, ArkType,\n * Valibot, …. Field descriptions become LLM hints. Input is validated by\n * the SDK before the callback runs. Emitted on the wire as `inputSchema`.\n */\n inputSchema?: StandardSchemaWithJSON;\n /**\n * Alias for {@link ToolDefinition.inputSchema}. Prefer `inputSchema` in new\n * code — it matches the MCP wire field name.\n */\n schema?: StandardSchemaWithJSON;\n /**\n * Schema for structured output ({@link StandardSchemaWithJSON}). Any JSON\n * root is allowed — object, array, or primitive (2026-07-28 protocol).\n * When set, the callback must return a result carrying matching\n * `structuredContent` or an explicit `isError` result — enforced at\n * compile time and validated by the SDK at runtime.\n */\n outputSchema?: StandardSchemaWithJSON;\n /** Behavioral hints for clients (readOnlyHint, destructiveHint, …). */\n annotations?: ToolAnnotations;\n /**\n * Declares who may call or see the tool. Emitted as `_meta.ui.visibility`\n * on `tools/list`. Omitted = host default (callable by the model, visible\n * to the app). The server always lists every registered tool — hosts\n * filter by this declaration; the server never omits tools from\n * `tools/list`. `\"app\"` marks app-private helper tools callable from\n * views via `useCallTool` while the host hides them from the model.\n */\n visibility?: \"model\" | \"app\";\n /**\n * Bind this tool to a view for MCP Apps rendering. Requires\n * {@link ToolDefinition.outputSchema} — the view reads the result's\n * `structuredContent` typed by this schema.\n */\n view?: ToolViewConfig;\n}\n\n/**\n * Handle returned by {@link MCPServer.tool} — carries the tool name at runtime\n * and phantom input/output types for inference (e.g. `Register` / `useCallTool`).\n */\nexport interface ToolRef<\n Name extends string = string,\n Input = Record<string, unknown>,\n Output = never,\n> {\n /** The tool's registered name. */\n readonly name: Name;\n /**\n * Phantom carrier for the tool's inferred input/output types. Never set at\n * runtime.\n *\n * @internal\n */\n readonly \"~types\"?: { input: Input; output: Output };\n}\n\n/**\n * Result a tool callback may return, keyed by the tool's inferred output\n * type. Completed calls use the SDK's raw {@link CallToolResult}; interactive\n * calls may return an {@link InputRequiredResult}. There is no\n * framework-specific result layer.\n *\n * Without an `outputSchema` (`TOutput = never`) any `CallToolResult` is\n * accepted. With one, the result must carry `structuredContent` matching the\n * schema or set `isError: true` — mirroring the SDK's runtime rule, which\n * rejects results from schema'd tools that carry no structured content\n * unless `isError` is set.\n *\n * The SDK auto-appends a JSON text block when `structuredContent` is a\n * non-object value and no `type: \"text\"` block is present; for object-shaped\n * payloads include the text serialization yourself:\n *\n * ```ts\n * return {\n * content: [{ type: \"text\", text: JSON.stringify(data) }],\n * structuredContent: data,\n * };\n * ```\n */\nexport type ToolResult<TOutput = never> =\n | InputRequiredResult\n | ([TOutput] extends [never]\n ? CallToolResult\n :\n | (CallToolResult & { structuredContent: TOutput })\n | (CallToolResult & { isError: true }));\n\n/** Infer the callback params type from a tool definition's input schema. */\nexport type InferToolInput<T> = T extends {\n inputSchema: infer S extends StandardSchemaWithJSON;\n}\n ? StandardSchemaWithJSON.InferOutput<S> extends Record<string, unknown>\n ? StandardSchemaWithJSON.InferOutput<S>\n : Record<string, unknown>\n : T extends {\n schema: infer S extends StandardSchemaWithJSON;\n }\n ? StandardSchemaWithJSON.InferOutput<S> extends Record<string, unknown>\n ? StandardSchemaWithJSON.InferOutput<S>\n : Record<string, unknown>\n : Record<string, unknown>;\n\n/**\n * Resolve a tool definition's input schema. `inputSchema` wins when both are\n * set.\n *\n * @internal\n */\nexport function resolveToolInputSchema(\n definition: Pick<ToolDefinition, \"inputSchema\" | \"schema\">\n): StandardSchemaWithJSON | undefined {\n return definition.inputSchema ?? definition.schema;\n}\n\n/**\n * Infer the structured output type from a definition's `outputSchema` —\n * any JSON root, not just objects (2026-07-28 protocol); `never` when the\n * definition declares none (any {@link CallToolResult} is then accepted —\n * see {@link ToolResult}).\n */\nexport type InferToolOutput<T> = T extends {\n outputSchema: infer S extends StandardSchemaWithJSON;\n}\n ? StandardSchemaWithJSON.InferOutput<S>\n : never;\n\n/** Infer the literal tool name from a definition's `name` field. */\nexport type InferToolName<T> = T extends { name: infer N extends string }\n ? N\n : string;\n\n/**\n * Tool execution callback. The return type is {@link ToolResult}: tools with\n * an `outputSchema` must return matching `structuredContent` or an `isError`\n * result; tools without one accept any {@link CallToolResult}.\n */\nexport type ToolCallback<\n TInput = Record<string, unknown>,\n TOutput = never,\n TUser = never,\n HasOAuth extends boolean = false,\n> = (\n params: TInput,\n ctx: RequestContext<TUser, HasOAuth>\n) => ToolResult<TOutput> | Promise<ToolResult<TOutput>>;\n"],"mappings":";AAAA,SAAS,kBAA6B;;;ACAtC,OAAO,WAAW;AAyCV,SASE,KATF;AA3BD,IAAM,gBAAN,cAA4B,MAAM,UAGvC;AAAA,EACA,YAAY,OAA2B;AACrC,UAAM,KAAK;AACX,SAAK,QAAQ,EAAE,UAAU,OAAO,OAAO,KAAK;AAAA,EAC9C;AAAA,EAEA,OAAO,yBAAyB,OAAc;AAC5C,WAAO,EAAE,UAAU,MAAM,MAAM;AAAA,EACjC;AAAA,EAES,kBAAkB,OAAc,WAA4B;AACnE,YAAQ,MAAM,yBAAyB,OAAO,SAAS;AACvD,SAAK,MAAM,UAAU,OAAO,SAAS;AAAA,EACvC;AAAA,EAES,SAAS;AAChB,QAAI,KAAK,MAAM,YAAY,KAAK,MAAM,OAAO;AAC3C,UAAI,KAAK,MAAM,aAAa,QAAW;AACrC,eAAO,OAAO,KAAK,MAAM,aAAa,aAClC,KAAK,MAAM,SAAS,KAAK,MAAM,KAAK,IACpC,KAAK,MAAM;AAAA,MACjB;AAEA,aACE;AAAA,QAAC;AAAA;AAAA,UACC,OAAO;AAAA,YACL,SAAS;AAAA,YACT,QAAQ;AAAA,YACR,cAAc;AAAA,YACd,YAAY;AAAA,YACZ,OAAO;AAAA,UACT;AAAA,UAEA;AAAA,gCAAC,YAAO,wBAAU;AAAA,YAClB,oBAAC,SAAI,OAAO,E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GjC,QAAI,CAAC,WAAY;AACjB,UAAM,UAAU,sBAAsB;AACtC,QACE,SAAS,iBAAiB,cAC1B,QAAQ,UAAU,SAClB,QAAQ,gBAAgB,eACxB,QAAQ,oBAAoB,iBAC5B;AACA;AAAA,IACF;AACA,UAAM,MAAM,cAAc;AAM1B,eAAW,OAAO;AAAA,MAChB,OAAO,IAAI;AAAA,MACX,aAAa,IAAI;AAAA,MACjB,aAAa,IAAI;AAAA,IACnB,CAAgD;AAChD,0BAAsB,UAAU;AAAA,MAC9B,cAAc;AAAA,MACd,OAAO,IAAI;AAAA,MACX,aAAa,IAAI;AAAA,MACjB,iBACE,IAAI,gBAAgB,SAChB,SACA,KAAK,UAAU,IAAI,WAAW;AAAA,IACtC;AAAA,EACF,GAAG,CAAC,OAAO,aAAa,eAAe,CAAC;AAExC,EAAAA,WAAU,MAAM;AACd,UAAM,aAAa,cAAc;AACjC,QAAI,CAAC,cAAc,WAAW,YAAY,QAAS;AACnD,QAAI,SAAS;AACX,iBAAW,OAAO;AAAA,IACpB,OAAO;AACL,iBAAW,QAAQ;AAAA,IACrB;AAAA,EACF,GAAG,CAAC,OAAO,CAAC;AACd;","names":["jsx","app","jsx","jsx","createContext","useContext","jsx","createContext","useContext","React","jsx","React","useState","useSyncExternalStore","useSyncExternalStore","useSyncExternalStore","resolveDisplayMode","useSyncExternalStore","useSyncExternalStore","useSyncExternalStore","Fragment","jsx","jsxs","useState","useRef","useState","useState","useRef","useCallback","useCallback","useCallback","useCallback","useSyncExternalStore","useSyncExternalStore","useEffect","useRef","useRef","useEffect"]}
1
+ {"version":3,"sources":["../../src/react/runtime/bootstrap-view.tsx","../../src/react/components/error-boundary.tsx","../../src/react/runtime/view-config.ts","../../src/react/runtime/view-runtime-context.tsx","../../src/react/runtime/view-runtime.ts","../../src/react/types/result-types.ts","../../src/react/runtime/model-context-store.ts","../../src/react/public-assets.ts","../../src/react/components/image.tsx","../../src/react/components/model-context.tsx","../../src/react/components/theme-provider.tsx","../../src/react/components/view-controls.tsx","../../src/react/hooks/use-display-mode.ts","../../src/react/hooks/use-host-context.ts","../../src/react/hooks/use-tool-context.ts","../../src/react/hooks/use-call-tool.ts","../../src/react/hooks/use-files.ts","../../src/react/hooks/use-open-external.ts","../../src/react/hooks/use-send-follow-up.ts","../../src/react/hooks/use-send-size-changed.ts","../../src/react/hooks/use-view-theme.ts","../../src/react/hooks/use-view-tool.ts","../../src/tools.ts"],"sourcesContent":["import { createRoot, type Root } from \"react-dom/client\";\nimport type { ComponentType } from \"react\";\n\nimport { ErrorBoundary } from \"../components/error-boundary.js\";\nimport {\n normalizeViewConfig,\n type NormalizedViewConfig,\n type ViewConfig,\n} from \"./view-config.js\";\nimport { ViewRuntimeProvider } from \"./view-runtime-context.js\";\nimport {\n createMcpAppRuntime,\n setActiveRuntime,\n takePendingTestTransport,\n _registerDisposeViewForTesting,\n type McpAppRuntime,\n type ViewRuntimeTransport,\n} from \"./view-runtime.js\";\n\n/**\n * One mounted MCP App view per iframe document.\n *\n * Attached to `document` via a module-private symbol so HMR of the view\n * module reuses the same record without a module-level `Map` keyed by root id.\n */\ninterface MountedView {\n /** DOM id of the React mount container. */\n rootId: string;\n /** React root created for this mount. */\n root: Root;\n /** Document-owned {@link McpAppRuntime}. */\n runtime: McpAppRuntime;\n /** Normalized config fixed at first mount (HMR must not change it). */\n config: NormalizedViewConfig;\n}\n\n/**\n * Module-private symbol property key for the document mount record.\n *\n * A plain `Symbol` (not `Symbol.for`) keeps the key unforgeable from other\n * modules: only this bootstrap module can read or write the mount record.\n * View-module HMR re-enters {@link bootstrapView} without reloading this\n * module, so the symbol identity is stable for the iframe lifetime.\n */\nconst MOUNTED_VIEW: unique symbol = Symbol(\"mcp-use.mountedView\");\n\ntype DocumentWithMount = Document & {\n [MOUNTED_VIEW]?: MountedView;\n};\n\nfunction readMountedView(): MountedView | undefined {\n return (document as DocumentWithMount)[MOUNTED_VIEW];\n}\n\nfunction writeMountedView(mounted: MountedView): void {\n (document as DocumentWithMount)[MOUNTED_VIEW] = mounted;\n}\n\nfunction clearMountedView(): void {\n delete (document as DocumentWithMount)[MOUNTED_VIEW];\n}\n\nfunction configsEqual(\n a: NormalizedViewConfig,\n b: NormalizedViewConfig\n): boolean {\n if (a.autoResize !== b.autoResize) return false;\n if (a.displayModes.length !== b.displayModes.length) return false;\n return a.displayModes.every((mode, index) => mode === b.displayModes[index]);\n}\n\nfunction renderView(mounted: MountedView, View: ComponentType): void {\n mounted.root.render(\n <ErrorBoundary>\n <ViewRuntimeProvider runtime={mounted.runtime}>\n <View />\n </ViewRuntimeProvider>\n </ErrorBoundary>\n );\n}\n\n/** @internal Module shape of a `view.tsx` file. */\nexport interface ViewModule {\n /** Default view component — reads data via hooks. */\n default: ComponentType;\n /**\n * Optional immutable pre-render runtime configuration.\n *\n * Normalized before the guest `App` is constructed. See {@link ViewConfig}.\n */\n viewConfig?: ViewConfig;\n}\n\n/**\n * Mount options for {@link bootstrapView}.\n *\n * @internal\n */\nexport interface BootstrapViewOptions {\n /** DOM id of the mount container; created if missing. @defaultValue `\"root\"` */\n rootId?: string;\n /**\n * Guest transport injected for tests. When omitted, consumes any transport\n * queued by `_setTransportForTesting`, otherwise uses postMessage.\n *\n * @internal\n */\n transport?: ViewRuntimeTransport;\n}\n\n/**\n * Mount a view module into the iframe document: normalizes\n * {@link ViewModule.viewConfig}, creates a {@link McpAppRuntime}, starts\n * `connect()` (declaring `tools: { listChanged: true }` and normalized\n * `availableDisplayModes`), renders the default export immediately (the\n * component reads data via hooks while the handshake is in progress), and\n * wraps everything in an error boundary.\n *\n * Auto-resize is on by default. Opt out with\n * `viewConfig.autoResize: false` and report size via\n * {@link useSendSizeChanged}.\n *\n * Repeated bootstrap for the same `rootId` reuses the mounted root and\n * runtime (HMR) without reconnecting. A second `rootId` while one view is\n * mounted throws. Call {@link disposeView} to unmount and allow a fresh\n * bootstrap.\n *\n * @param module - The view module (`default` component and optional\n * `viewConfig`).\n * @param options - Mount options.\n * @throws When `viewConfig.displayModes` is empty, duplicated, missing\n * `\"inline\"`, or contains an unknown mode.\n * @throws When a view is already mounted on a different `rootId` in this\n * document.\n *\n * @internal\n */\nexport function bootstrapView(\n module: ViewModule,\n options?: BootstrapViewOptions\n): void {\n if (typeof document === \"undefined\") {\n throw new Error(\"bootstrapView requires a browser document\");\n }\n\n const normalized = normalizeViewConfig(module.viewConfig);\n const rootId = options?.rootId ?? \"root\";\n const existing = readMountedView();\n\n if (existing) {\n if (existing.rootId !== rootId) {\n throw new Error(\n `bootstrapView: a view is already mounted on \"#${existing.rootId}\"; cannot mount a second root \"#${rootId}\" in the same document`\n );\n }\n\n if (!configsEqual(existing.config, normalized)) {\n console.warn(\n \"[mcp-use] viewConfig changed during HMR (autoResize / displayModes). \" +\n \"A full iframe reload is required for configuration changes to take effect; \" +\n \"the mounted runtime keeps the original configuration.\"\n );\n }\n\n renderView(existing, module.default);\n return;\n }\n\n let container = document.getElementById(rootId);\n if (!container) {\n container = document.createElement(\"div\");\n container.id = rootId;\n document.body.appendChild(container);\n }\n\n const transport = options?.transport ?? takePendingTestTransport();\n const runtime = createMcpAppRuntime(normalized, {\n ...(transport !== undefined && { transport }),\n });\n setActiveRuntime(runtime);\n // Start connect before React mounts; attach rejection handling immediately\n // so a failed handshake is logged and does not become an unhandled rejection.\n void runtime.connect().catch((error: unknown) => {\n console.error(\"[mcp-use] Failed to connect view runtime:\", error);\n });\n\n const root = createRoot(container);\n const mounted: MountedView = {\n rootId,\n root,\n runtime,\n config: normalized,\n };\n writeMountedView(mounted);\n renderView(mounted, module.default);\n}\n\n/**\n * Unmount the document's view and dispose its {@link McpAppRuntime}.\n *\n * React unmounts first so hook cleanup (e.g. {@link useViewTool} removal) can\n * run while the App connection still exists; then the runtime closes the App\n * and transport. After this resolves, {@link bootstrapView} may create a\n * fresh runtime.\n *\n * No-ops when nothing is mounted.\n *\n * @example\n * ```ts\n * await disposeView();\n * ```\n */\nexport async function disposeView(): Promise<void> {\n if (typeof document === \"undefined\") {\n return;\n }\n\n const mounted = readMountedView();\n if (!mounted) return;\n\n // Unmount React before closing the App so hook cleanup (view-tool remove)\n // runs while the connection still exists.\n try {\n mounted.root.unmount();\n } catch {\n // Container may already be detached by test teardown.\n }\n\n // Drop the mount record before awaiting App close so a subsequent\n // bootstrapView (or sync test reset) does not reuse a half-disposed runtime.\n clearMountedView();\n await mounted.runtime.dispose();\n}\n\n/**\n * @internal Clear the document mount via {@link disposeView} between tests.\n */\nexport function _resetBootstrapRootsForTesting(): void {\n void disposeView();\n}\n\n// Wire the real disposal path into the view-runtime test seam without a\n// circular static import from view-runtime → bootstrap-view.\n_registerDisposeViewForTesting(disposeView);\n","import React from \"react\";\n\ninterface ErrorBoundaryProps {\n children: React.ReactNode;\n /** Custom fallback when an error is caught. */\n fallback?: React.ReactNode | ((error: Error) => React.ReactNode);\n /** Invoked when an error is caught. */\n onError?: (error: Error, errorInfo: React.ErrorInfo) => void;\n}\n\n/**\n * Catches React errors in the view tree and renders a fallback instead of\n * crashing the iframe.\n */\nexport class ErrorBoundary extends React.Component<\n ErrorBoundaryProps,\n { hasError: boolean; error: Error | null }\n> {\n constructor(props: ErrorBoundaryProps) {\n super(props);\n this.state = { hasError: false, error: null };\n }\n\n static getDerivedStateFromError(error: Error) {\n return { hasError: true, error };\n }\n\n override componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {\n console.error(\"[mcp-use] View error:\", error, errorInfo);\n this.props.onError?.(error, errorInfo);\n }\n\n override render() {\n if (this.state.hasError && this.state.error) {\n if (this.props.fallback !== undefined) {\n return typeof this.props.fallback === \"function\"\n ? this.props.fallback(this.state.error)\n : this.props.fallback;\n }\n\n return (\n <div\n style={{\n padding: \"1rem\",\n border: \"1px solid #ef4444\",\n borderRadius: \"0.375rem\",\n background: \"#fef2f2\",\n color: \"#7f1d1d\",\n }}\n >\n <strong>View error</strong>\n <pre style={{ marginTop: \"0.5rem\", whiteSpace: \"pre-wrap\" }}>\n {this.state.error.message}\n </pre>\n </div>\n );\n }\n\n return this.props.children;\n }\n}\n","import type { DisplayMode } from \"../types/host-types.js\";\n\n/**\n * Immutable pre-render runtime configuration for a view module.\n *\n * Export as a named `viewConfig` alongside the default component. Values are\n * normalized and validated by `bootstrapView` before the guest `App` is\n * constructed. React presentation settings do not belong here — compose\n * {@link ThemeProvider} / {@link ViewControls} in the component tree instead.\n *\n * @example\n * ```tsx\n * import type { ViewConfig } from \"mcp-use/react\";\n *\n * export const viewConfig = {\n * autoResize: false,\n * displayModes: [\"inline\", \"fullscreen\"],\n * } satisfies ViewConfig;\n *\n * export default function CanvasView() {\n * return <Canvas />;\n * }\n * ```\n */\nexport interface ViewConfig {\n /**\n * Let ext-apps observe the document and report size changes.\n *\n * @defaultValue true\n */\n autoResize?: boolean;\n\n /**\n * Display modes this view can render correctly.\n *\n * Must contain \"inline\".\n *\n * @defaultValue [\"inline\", \"fullscreen\", \"pip\"]\n */\n displayModes?: readonly DisplayMode[];\n}\n\n/**\n * Fully-resolved {@link ViewConfig} with every field required.\n *\n * @internal\n */\nexport interface NormalizedViewConfig {\n /** Whether the guest `App` auto-measures and reports size changes. */\n autoResize: boolean;\n /** Display modes advertised to the host via App capabilities. */\n displayModes: readonly DisplayMode[];\n}\n\nconst DEFAULT_DISPLAY_MODES: readonly DisplayMode[] = [\n \"inline\",\n \"fullscreen\",\n \"pip\",\n];\n\nconst VALID_DISPLAY_MODES: ReadonlySet<string> = new Set<DisplayMode>([\n \"inline\",\n \"fullscreen\",\n \"pip\",\n]);\n\n/**\n * Normalize and validate an optional {@link ViewConfig}.\n *\n * @param config - Optional named export from a view module.\n * @returns A fully-resolved config with defaults applied.\n * @throws When `displayModes` is empty, contains duplicates, omits `\"inline\"`,\n * or includes a value that is not a known {@link DisplayMode}.\n *\n * @internal\n */\nexport function normalizeViewConfig(config?: ViewConfig): NormalizedViewConfig {\n const autoResize = config?.autoResize ?? true;\n\n if (config?.displayModes === undefined) {\n return { autoResize, displayModes: DEFAULT_DISPLAY_MODES };\n }\n\n const modes = config.displayModes;\n if (!Array.isArray(modes) || modes.length === 0) {\n throw new Error(\n 'viewConfig.displayModes must be a non-empty array that includes \"inline\"'\n );\n }\n\n const seen = new Set<string>();\n const normalizedModes: DisplayMode[] = [];\n for (const mode of modes) {\n if (typeof mode !== \"string\" || !VALID_DISPLAY_MODES.has(mode)) {\n throw new Error(\n `viewConfig.displayModes contains invalid mode ${JSON.stringify(mode)}; expected \"inline\", \"fullscreen\", or \"pip\"`\n );\n }\n if (seen.has(mode)) {\n throw new Error(\n `viewConfig.displayModes contains duplicate mode \"${mode}\"`\n );\n }\n seen.add(mode);\n // Validated against VALID_DISPLAY_MODES above.\n normalizedModes.push(mode as DisplayMode);\n }\n\n if (!seen.has(\"inline\")) {\n throw new Error('viewConfig.displayModes must include \"inline\"');\n }\n\n return {\n autoResize,\n displayModes: normalizedModes,\n };\n}\n","import type { McpUiHostContext } from \"@modelcontextprotocol/ext-apps\";\nimport {\n createContext,\n useContext,\n useSyncExternalStore,\n type ReactNode,\n} from \"react\";\n\nimport type { McpAppRuntime } from \"./view-runtime.js\";\n\n/**\n * React context holding the document's {@link McpAppRuntime}.\n *\n * `null` outside bootstrap — hooks throw via {@link useViewRuntime}.\n *\n * @internal\n */\nexport const ViewRuntimeContext = createContext<McpAppRuntime | null>(null);\n\n/**\n * Provide a {@link McpAppRuntime} to the view tree.\n *\n * Connection is started by {@link bootstrapView} before render. Model-context\n * delivery is owned by the runtime's {@link McpAppRuntime.modelContextStore};\n * this provider only exposes the runtime through context.\n *\n * @param props - Provider props.\n * @param props.runtime - Runtime created by bootstrap for this mount.\n * @param props.children - View tree.\n *\n * @internal\n */\nexport function ViewRuntimeProvider({\n runtime,\n children,\n}: {\n runtime: McpAppRuntime;\n children: ReactNode;\n}) {\n return (\n <ViewRuntimeContext.Provider value={runtime}>\n {children}\n </ViewRuntimeContext.Provider>\n );\n}\n\n/**\n * Read the current {@link McpAppRuntime} from context.\n *\n * @throws When called outside a {@link bootstrapView}-mounted tree.\n *\n * @internal\n */\nexport function useViewRuntime(): McpAppRuntime {\n const runtime = useContext(ViewRuntimeContext);\n if (!runtime) {\n throw new Error(\n \"mcp-use/react hooks require a browser view mounted by bootstrapView\"\n );\n }\n return runtime;\n}\n\n/**\n * Subscribe to host context only — re-renders when `hostContext` identity\n * changes (connection-only updates that keep the same context object do not).\n *\n * Used by {@link ThemeProvider} for theme, style variables, and fonts.\n *\n * @internal\n */\nexport function useHostContextSubscription(): McpUiHostContext | undefined {\n const runtime = useViewRuntime();\n return useSyncExternalStore(\n runtime.subscribeHost,\n () => runtime.getHostSnapshot().hostContext\n );\n}\n","import {\n App,\n PostMessageTransport,\n type McpUiHostContext,\n type RegisteredAppTool,\n} from \"@modelcontextprotocol/ext-apps\";\nimport type {\n CallToolResult,\n ContentBlock,\n} from \"@modelcontextprotocol/server\";\n\nimport type { DisplayMode } from \"../types/host-types.js\";\nimport type { FileMetadata } from \"../types/file-types.js\";\nimport { ToolError, type ToolContextError } from \"../types/result-types.js\";\nimport { ModelContextStore } from \"./model-context-store.js\";\nimport type { NormalizedViewConfig } from \"./view-config.js\";\n\n/** Transport accepted by {@link App.connect}. */\nexport type ViewRuntimeTransport = NonNullable<Parameters<App[\"connect\"]>[0]>;\n\ntype Listener = () => void;\n\n/**\n * Tool-channel snapshot for the invocation that rendered this View.\n *\n * Input notifications replace `toolInput` while the invocation is pending.\n * The first structured result or tool error latches a terminal state; all\n * later ambient lifecycle notifications are ignored.\n *\n * @internal\n */\nexport interface ToolSnapshot {\n /** Pending until the first structured result or tool error, then terminal. */\n status: \"pending\" | \"ready\" | \"error\";\n /** Model-visible tool output from the last ready result's `structuredContent`. */\n toolOutput: unknown;\n /** Model-visible content blocks from the last tool result (ready or error). */\n content: ContentBlock[] | undefined;\n /**\n * Latest progressive tool arguments from the host. Partial and complete\n * notifications replace the same snapshot; last write wins.\n */\n toolInput: Record<string, unknown> | undefined;\n /** View-only result `_meta` channel. */\n meta: Record<string, unknown> | undefined;\n /**\n * Tool error for the rendering invocation.\n */\n error: ToolContextError | undefined;\n}\n\n/**\n * Host-channel snapshot: negotiated host context and connection status.\n *\n * @internal\n */\nexport interface HostSnapshot {\n /** Current host context (updated on `host-context-changed`). */\n hostContext: McpUiHostContext | undefined;\n /** Whether the App handshake completed. */\n isConnected: boolean;\n /** Terminal connection failure for this mount, if any. */\n connectionError: Error | undefined;\n}\n\n/**\n * Display-channel snapshot: current mode and negotiated available modes.\n *\n * @internal\n */\nexport interface DisplaySnapshot {\n /** How the host is currently displaying the view. */\n displayMode: DisplayMode;\n /**\n * Negotiated modes: intersection of normalized\n * {@link NormalizedViewConfig.displayModes} and\n * `hostContext.availableDisplayModes`. When the host omits available modes,\n * only `\"inline\"`.\n */\n availableDisplayModes: readonly DisplayMode[];\n}\n\n/**\n * ChatGPT file-extension channel snapshot.\n *\n * This channel deliberately represents only the optional file APIs used by\n * `useFiles`; the runtime does not mirror other `window.openai` globals.\n *\n * @internal\n */\nexport interface FilesSnapshot {\n /** Whether both upload and temporary-download-url helpers are available. */\n isSupported: boolean;\n}\n\ninterface ChatGptFilesApi {\n uploadFile?: (file: File) => Promise<FileMetadata>;\n getFileDownloadUrl?: (file: FileMetadata) => Promise<{ downloadUrl: string }>;\n}\n\n/**\n * Parameters for {@link McpAppRuntime.callServerTool}.\n *\n * @internal\n */\nexport type CallToolParams = Parameters<App[\"callServerTool\"]>[0];\n\n/**\n * Parameters for {@link McpAppRuntime.sendMessage}.\n *\n * @internal\n */\nexport type SendMessageParams = Parameters<App[\"sendMessage\"]>[0];\n\n/**\n * Parameters for {@link McpAppRuntime.openLink}.\n *\n * @internal\n */\nexport type OpenLinkParams = Parameters<App[\"openLink\"]>[0];\n\n/**\n * Parameters for {@link McpAppRuntime.requestDisplayMode}.\n *\n * @internal\n */\nexport type RequestDisplayModeParams = Parameters<App[\"requestDisplayMode\"]>[0];\n\n/**\n * Parameters for {@link McpAppRuntime.sendSizeChanged}.\n *\n * @internal\n */\nexport type SizeChangedParams = Parameters<App[\"sendSizeChanged\"]>[0];\n\n/**\n * Config passed to {@link McpAppRuntime.registerViewTool} (ext-apps shape).\n *\n * @internal\n */\nexport type ViewToolConfig = Parameters<App[\"registerTool\"]>[1];\n\n/**\n * Callback passed to {@link McpAppRuntime.registerViewTool}.\n *\n * @internal\n */\nexport type ViewToolCallback = Parameters<App[\"registerTool\"]>[2];\n\n/**\n * Per-document MCP Apps runtime: owns one guest {@link App}, one cached\n * connection attempt, tool-handler handoff, narrow external-store channels,\n * one {@link ModelContextStore}, and disposal.\n *\n * Created by {@link createMcpAppRuntime} / {@link bootstrapView}. Hooks obtain\n * the instance from {@link ViewRuntimeContext}.\n *\n * @internal\n */\nexport interface McpAppRuntime {\n /** Normalized immutable view configuration fixed at construction. */\n readonly config: NormalizedViewConfig;\n\n /**\n * Per-runtime model-context node tree and async flush pump.\n *\n * Constructed with this runtime and disposed with it. React components obtain\n * it via {@link useViewRuntime}; the imperative `modelContext` API delegates\n * to the active document runtime's store.\n */\n readonly modelContextStore: ModelContextStore;\n\n /** Connect once, or return the cached in-flight / settled connection promise. */\n connect(): Promise<App>;\n /**\n * Dispose the model-context store (so late in-flight completions are\n * ignored), prevent late event delivery, clear listeners and snapshots, and\n * close the App/transport.\n *\n * Callers should unmount the view tree first (see `disposeView`) so hook\n * cleanup can run while the App connection still exists.\n */\n dispose(): Promise<void>;\n\n /** Subscribe to tool-channel changes. */\n subscribeTool(listener: Listener): () => void;\n /** Current tool-channel snapshot (stable until a tool field changes). */\n getToolSnapshot(): ToolSnapshot;\n\n /** Subscribe to host-channel changes. */\n subscribeHost(listener: Listener): () => void;\n /** Current host-channel snapshot (stable until host/connection fields change). */\n getHostSnapshot(): HostSnapshot;\n\n /** Subscribe to theme-channel changes. */\n subscribeTheme(listener: Listener): () => void;\n /** Current theme (`\"light\"` until the host reports otherwise). Primitive; stable until theme changes. */\n getThemeSnapshot(): \"light\" | \"dark\";\n\n /** Subscribe to display-channel changes. */\n subscribeDisplay(listener: Listener): () => void;\n /**\n * Current display-channel snapshot (stable until `displayMode` or\n * negotiated `availableDisplayModes` change).\n */\n getDisplaySnapshot(): DisplaySnapshot;\n\n /** Subscribe to ChatGPT file-extension availability changes. */\n subscribeFiles(listener: Listener): () => void;\n /** Current ChatGPT file-extension snapshot. */\n getFilesSnapshot(): FilesSnapshot;\n\n /** Runtime-owned guest {@link App}, or `null` after disposal. */\n getApp(): App | null;\n\n /** Call a server tool through the host. */\n callServerTool(params: CallToolParams): Promise<CallToolResult>;\n /** Send a follow-up message through the host. */\n sendMessage(params: SendMessageParams): Promise<void>;\n /** Ask the host to open an external link. */\n openLink(params: OpenLinkParams): Promise<void>;\n /** Request a display-mode change from the host. */\n requestDisplayMode(params: RequestDisplayModeParams): Promise<void>;\n /** Notify the host of a size change. */\n sendSizeChanged(params: SizeChangedParams): Promise<void>;\n /** Upload a file through ChatGPT's optional file extension. */\n uploadFile(file: File): Promise<FileMetadata>;\n /** Request a temporary download URL through ChatGPT's file extension. */\n getFileDownloadUrl(file: FileMetadata): Promise<{ downloadUrl: string }>;\n\n /**\n * Register a view tool, performing the empty-handler → registry handoff on\n * the first call. Must remain synchronous relative to the handoff.\n */\n registerViewTool(\n name: string,\n config: ViewToolConfig,\n callback: ViewToolCallback\n ): RegisteredAppTool;\n}\n\nconst APP_VERSION = \"2.0.0-alpha.0\";\n\nconst defaultToolSnapshot: ToolSnapshot = {\n status: \"pending\",\n toolOutput: undefined,\n content: undefined,\n toolInput: undefined,\n meta: undefined,\n error: undefined,\n};\n\nconst defaultHostSnapshot: HostSnapshot = {\n hostContext: undefined,\n isConnected: false,\n connectionError: undefined,\n};\n\nconst defaultFilesSnapshot: FilesSnapshot = {\n isSupported: false,\n};\n\nfunction getChatGptFilesApi(): ChatGptFilesApi | undefined {\n if (typeof window === \"undefined\") return undefined;\n return (window as unknown as { openai?: ChatGptFilesApi }).openai;\n}\n\nfunction resolveFilesSnapshot(): FilesSnapshot {\n const api = getChatGptFilesApi();\n return {\n isSupported:\n typeof api?.uploadFile === \"function\" &&\n typeof api.getFileDownloadUrl === \"function\",\n };\n}\n\nfunction resolveDisplayMode(\n hostContext: McpUiHostContext | undefined\n): DisplayMode {\n return hostContext?.displayMode === \"fullscreen\" ||\n hostContext?.displayMode === \"pip\"\n ? hostContext.displayMode\n : \"inline\";\n}\n\nfunction resolveTheme(\n hostContext: McpUiHostContext | undefined\n): \"light\" | \"dark\" {\n return hostContext?.theme === \"dark\" ? \"dark\" : \"light\";\n}\n\nfunction sameDisplayModes(\n a: readonly DisplayMode[],\n b: readonly DisplayMode[]\n): boolean {\n return a.length === b.length && a.every((mode, index) => mode === b[index]);\n}\n\n/**\n * Negotiated display modes: view modes ∩ host modes.\n *\n * When the host omits `availableDisplayModes`, only `\"inline\"` is requestable.\n */\nfunction resolveAvailableDisplayModes(\n viewModes: readonly DisplayMode[],\n hostContext: McpUiHostContext | undefined\n): readonly DisplayMode[] {\n const hostModes = hostContext?.availableDisplayModes;\n if (hostModes === undefined) {\n return [\"inline\"];\n }\n return viewModes.filter((mode) => hostModes.includes(mode));\n}\n\nfunction installEmptyToolHandlers(app: App): void {\n app.onlisttools = async () => ({ tools: [] });\n app.oncalltool = async ({ name }) => {\n throw new Error(`View tool \"${name}\" is not registered`);\n };\n}\n\nfunction createChannelStore(): {\n subscribe: (listener: Listener) => () => void;\n emit: () => void;\n clear: () => void;\n} {\n const listeners = new Set<Listener>();\n return {\n subscribe(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n emit() {\n for (const listener of listeners) {\n listener();\n }\n },\n clear() {\n listeners.clear();\n },\n };\n}\n\nfunction toolSnapshotChanged(\n prev: ToolSnapshot,\n patch: Partial<ToolSnapshot>\n): boolean {\n for (const key of Object.keys(patch) as (keyof ToolSnapshot)[]) {\n if (prev[key] !== patch[key]) {\n return true;\n }\n }\n return false;\n}\n\nfunction hostSnapshotChanged(\n prev: HostSnapshot,\n patch: Partial<HostSnapshot>\n): boolean {\n for (const key of Object.keys(patch) as (keyof HostSnapshot)[]) {\n if (prev[key] !== patch[key]) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Options for {@link createMcpAppRuntime}.\n *\n * @internal\n */\nexport interface CreateMcpAppRuntimeOptions {\n /**\n * Transport used by the runtime's single {@link McpAppRuntime.connect}\n * attempt (tests).\n * Defaults to {@link PostMessageTransport} against `window.parent`.\n */\n transport?: ViewRuntimeTransport;\n}\n\n/**\n * Create a fresh {@link McpAppRuntime} for one iframe document / view mount.\n *\n * Constructs and configures the guest {@link App} eagerly so event handlers\n * and view tools can be registered before or during initialization. The App is\n * connected at most once and remains owned by the runtime until disposal.\n *\n * @param config - Normalized {@link NormalizedViewConfig} from bootstrap.\n * @param options - Optional transport injection for tests.\n * @returns A runtime owning connection, snapshots, and view-tool registration.\n *\n * @internal\n */\nexport function createMcpAppRuntime(\n config: NormalizedViewConfig,\n options?: CreateMcpAppRuntimeOptions\n): McpAppRuntime {\n let disposed = false;\n let connectPromise: Promise<App> | null = null;\n let toolRegistryActivated = false;\n const configuredTransport = options?.transport;\n\n let toolSnapshot: ToolSnapshot = { ...defaultToolSnapshot };\n let hostSnapshot: HostSnapshot = { ...defaultHostSnapshot };\n let themeSnapshot: \"light\" | \"dark\" = \"light\";\n // Host has not reported modes yet → treat as omitted → only \"inline\".\n let displaySnapshot: DisplaySnapshot = {\n displayMode: \"inline\",\n availableDisplayModes: [\"inline\"],\n };\n let filesSnapshot: FilesSnapshot = resolveFilesSnapshot();\n\n const toolChannel = createChannelStore();\n const hostChannel = createChannelStore();\n const themeChannel = createChannelStore();\n const displayChannel = createChannelStore();\n const filesChannel = createChannelStore();\n\n function patchTool(patch: Partial<ToolSnapshot>): void {\n if (!toolSnapshotChanged(toolSnapshot, patch)) {\n return;\n }\n toolSnapshot = { ...toolSnapshot, ...patch };\n toolChannel.emit();\n }\n\n function patchHost(patch: Partial<HostSnapshot>): void {\n if (!hostSnapshotChanged(hostSnapshot, patch)) {\n return;\n }\n hostSnapshot = { ...hostSnapshot, ...patch };\n hostChannel.emit();\n }\n\n function syncThemeFromHost(hostContext: McpUiHostContext | undefined): void {\n const next = resolveTheme(hostContext);\n if (next === themeSnapshot) {\n return;\n }\n themeSnapshot = next;\n themeChannel.emit();\n }\n\n function syncDisplayFromHost(\n hostContext: McpUiHostContext | undefined\n ): void {\n const nextMode = resolveDisplayMode(hostContext);\n const nextAvailable = resolveAvailableDisplayModes(\n config.displayModes,\n hostContext\n );\n if (\n nextMode === displaySnapshot.displayMode &&\n sameDisplayModes(nextAvailable, displaySnapshot.availableDisplayModes)\n ) {\n return;\n }\n displaySnapshot = {\n displayMode: nextMode,\n availableDisplayModes: nextAvailable,\n };\n displayChannel.emit();\n }\n\n /**\n * Apply a host-context update and fan out to host / theme / display\n * channels that actually changed.\n */\n function applyHostContext(nextHostContext: McpUiHostContext): void {\n patchHost({ hostContext: nextHostContext });\n syncThemeFromHost(nextHostContext);\n syncDisplayFromHost(nextHostContext);\n }\n\n function installRuntimeEventHandlers(app: App): void {\n // The draft notification shape has no tool name or request id. While the\n // rendering invocation is pending, both complete and partial input replace\n // the same progressive snapshot. Once a result is latched, later ambient\n // lifecycle notifications must not mutate the View context.\n app.ontoolinput = (params) => {\n if (disposed || toolSnapshot.status !== \"pending\") return;\n patchTool({ toolInput: params.arguments ?? {} });\n };\n\n app.ontoolinputpartial = (params) => {\n if (disposed || toolSnapshot.status !== \"pending\") return;\n patchTool({ toolInput: params.arguments ?? {} });\n };\n\n app.ontoolresult = (params) => {\n if (disposed || toolSnapshot.status !== \"pending\") return;\n\n // Content-only successes are valid CallToolResults from ambient server\n // or View tools. Without correlation metadata they cannot be classified\n // as malformed rendering results, so leave the pending context alone.\n if (params.isError !== true && params.structuredContent === undefined) {\n return;\n }\n\n const content = Array.isArray(params.content)\n ? (params.content as ContentBlock[])\n : undefined;\n const meta =\n params._meta !== undefined &&\n typeof params._meta === \"object\" &&\n params._meta !== null\n ? (params._meta as Record<string, unknown>)\n : undefined;\n\n if (params.isError === true) {\n const result = params as CallToolResult & { isError: true };\n patchTool({\n status: \"error\",\n error: new ToolError(result),\n toolOutput: undefined,\n content,\n meta,\n });\n return;\n }\n\n patchTool({\n status: \"ready\",\n error: undefined,\n toolOutput: params.structuredContent,\n content,\n meta,\n });\n };\n\n // Cancellation cannot be correlated either and has no public bound-state\n // branch. A cancelled rendering invocation therefore remains pending.\n app.ontoolcancelled = () => {};\n\n app.onhostcontextchanged = (params) => {\n if (disposed) return;\n applyHostContext({\n ...(hostSnapshot.hostContext ?? {}),\n ...params,\n });\n };\n }\n\n function createApp(): App {\n const app = new App(\n { name: \"mcp-use-view\", version: APP_VERSION },\n {\n tools: { listChanged: true },\n availableDisplayModes: [...config.displayModes],\n },\n { autoResize: config.autoResize }\n );\n installEmptyToolHandlers(app);\n installRuntimeEventHandlers(app);\n return app;\n }\n\n const app = createApp();\n\n async function closeAppQuietly(app: App): Promise<void> {\n try {\n await app.close();\n } catch {\n // Best-effort deterministic cleanup.\n }\n }\n\n async function connectApp(): Promise<App> {\n try {\n if (typeof window === \"undefined\" && configuredTransport === undefined) {\n throw new Error(\n \"View runtime can only connect in a browser environment\"\n );\n }\n const transport =\n configuredTransport ??\n new PostMessageTransport(window.parent, window.parent);\n await app.connect(transport);\n if (disposed) {\n await closeAppQuietly(app);\n throw new Error(\"View runtime was disposed during connection\");\n }\n const hostContext = app.getHostContext();\n patchHost({\n isConnected: true,\n connectionError: undefined,\n ...(hostContext !== undefined && { hostContext }),\n });\n // Always re-derive display (host omitting modes → [\"inline\"]).\n syncThemeFromHost(hostContext);\n syncDisplayFromHost(hostContext);\n return app;\n } catch (error) {\n const failure = error instanceof Error ? error : new Error(String(error));\n if (!disposed) {\n patchHost({\n isConnected: false,\n connectionError: failure,\n });\n }\n throw failure;\n }\n }\n\n function connect(): Promise<App> {\n if (disposed) {\n return Promise.reject(new Error(\"View runtime has been disposed\"));\n }\n connectPromise ??= connectApp();\n return connectPromise;\n }\n\n const modelContextStore = new ModelContextStore({ connect });\n\n function registerViewTool(\n name: string,\n toolConfig: ViewToolConfig,\n callback: ViewToolCallback\n ): RegisteredAppTool {\n if (disposed) {\n throw new Error(\"View runtime has been disposed\");\n }\n if (toolRegistryActivated) {\n return app.registerTool(name, toolConfig, callback);\n }\n\n // Clear temporary handlers first so ensureToolHandlersInitialized does not\n // warn about replacing them. Clear + register must stay in one turn.\n app.onlisttools = undefined;\n app.oncalltool = undefined;\n\n try {\n const registration = app.registerTool(name, toolConfig, callback);\n toolRegistryActivated = true;\n return registration;\n } catch (error) {\n installEmptyToolHandlers(app);\n throw error;\n }\n }\n\n async function dispose(): Promise<void> {\n if (disposed) return;\n disposed = true;\n modelContextStore.dispose();\n toolRegistryActivated = false;\n toolChannel.clear();\n hostChannel.clear();\n themeChannel.clear();\n displayChannel.clear();\n filesChannel.clear();\n toolSnapshot = { ...defaultToolSnapshot };\n hostSnapshot = { ...defaultHostSnapshot };\n themeSnapshot = \"light\";\n displaySnapshot = {\n displayMode: \"inline\",\n availableDisplayModes: [\"inline\"],\n };\n filesSnapshot = { ...defaultFilesSnapshot };\n if (activeRuntime === runtime) {\n activeRuntime = null;\n }\n await closeAppQuietly(app);\n }\n\n async function callServerTool(\n params: CallToolParams\n ): Promise<CallToolResult> {\n const app = await connect();\n if (app.getHostCapabilities()?.serverTools === undefined) {\n throw new Error(\n \"Host does not advertise the serverTools capability required to call server tools\"\n );\n }\n return app.callServerTool(params);\n }\n\n async function sendMessage(params: SendMessageParams): Promise<void> {\n const app = await connect();\n if (app.getHostCapabilities()?.message === undefined) {\n throw new Error(\n \"Host does not advertise the message capability required to send follow-up messages\"\n );\n }\n await app.sendMessage(params);\n }\n\n async function openLink(params: OpenLinkParams): Promise<void> {\n const app = await connect();\n if (app.getHostCapabilities()?.openLinks === undefined) {\n throw new Error(\n \"Host does not advertise the openLinks capability required to open external links\"\n );\n }\n await app.openLink(params);\n }\n\n async function requestDisplayMode(\n params: RequestDisplayModeParams\n ): Promise<void> {\n const app = await connect();\n // Re-derive from the latest host context so a race with host-context\n // updates cannot approve a mode the snapshot has not yet published.\n const negotiated = resolveAvailableDisplayModes(\n config.displayModes,\n app.getHostContext() ?? hostSnapshot.hostContext\n );\n if (!negotiated.includes(params.mode as DisplayMode)) {\n throw new Error(\n `Display mode \"${params.mode}\" is not in the negotiated available modes [${negotiated.join(\", \")}]`\n );\n }\n await app.requestDisplayMode(params);\n }\n\n async function sendSizeChanged(params: SizeChangedParams): Promise<void> {\n const app = await connect();\n await app.sendSizeChanged(params);\n }\n\n async function uploadFile(file: File): Promise<FileMetadata> {\n if (disposed) {\n throw new Error(\"View runtime has been disposed\");\n }\n\n const api = getChatGptFilesApi();\n if (!filesSnapshot.isSupported || typeof api?.uploadFile !== \"function\") {\n throw new Error(\n \"[useFiles] File upload is not supported in this host. \" +\n \"Check `isSupported` before calling `upload`. \" +\n \"File operations are only available in the ChatGPT Apps SDK environment.\"\n );\n }\n\n return api.uploadFile(file);\n }\n\n async function getFileDownloadUrl(\n file: FileMetadata\n ): Promise<{ downloadUrl: string }> {\n if (disposed) {\n throw new Error(\"View runtime has been disposed\");\n }\n\n const api = getChatGptFilesApi();\n if (\n !filesSnapshot.isSupported ||\n typeof api?.getFileDownloadUrl !== \"function\"\n ) {\n throw new Error(\n \"[useFiles] File download is not supported in this host. \" +\n \"Check `isSupported` before calling `getDownloadUrl`. \" +\n \"File operations are only available in the ChatGPT Apps SDK environment.\"\n );\n }\n return api.getFileDownloadUrl(file);\n }\n\n const runtime: McpAppRuntime = {\n config,\n modelContextStore,\n connect,\n dispose,\n subscribeTool: toolChannel.subscribe,\n getToolSnapshot: () => toolSnapshot,\n subscribeHost: hostChannel.subscribe,\n getHostSnapshot: () => hostSnapshot,\n subscribeTheme: themeChannel.subscribe,\n getThemeSnapshot: () => themeSnapshot,\n subscribeDisplay: displayChannel.subscribe,\n getDisplaySnapshot: () => displaySnapshot,\n subscribeFiles: filesChannel.subscribe,\n getFilesSnapshot: () => filesSnapshot,\n getApp: () => (disposed ? null : app),\n callServerTool,\n sendMessage,\n openLink,\n requestDisplayMode,\n sendSizeChanged,\n uploadFile,\n getFileDownloadUrl,\n registerViewTool,\n };\n\n return runtime;\n}\n\n/**\n * Document-level active runtime used by the imperative {@link modelContext}\n * API and test seams.\n *\n * Set by {@link bootstrapView}; cleared on {@link McpAppRuntime.dispose}.\n */\nlet activeRuntime: McpAppRuntime | null = null;\n\n/** Transport queued for the next bootstrap when set before the runtime exists. */\nlet pendingTestTransport: ViewRuntimeTransport | null = null;\n\n/**\n * Register `runtime` as the document-active instance for imperative APIs.\n *\n * @param runtime - Runtime to activate, or `null` to clear.\n *\n * @internal\n */\nexport function setActiveRuntime(runtime: McpAppRuntime | null): void {\n activeRuntime = runtime;\n}\n\n/**\n * Return the document-active runtime, if any.\n *\n * @internal\n */\nexport function getActiveRuntime(): McpAppRuntime | null {\n return activeRuntime;\n}\n\n/**\n * Inject a transport before the next bootstrap-created runtime.\n *\n * A mounted runtime has already started its sole connection attempt, so its\n * transport cannot be replaced.\n *\n * @param transport - Guest-side paired transport, or `null` to clear.\n *\n * @internal\n */\nexport function _setTransportForTesting(\n transport: ViewRuntimeTransport | null\n): void {\n if (activeRuntime) {\n throw new Error(\n \"Cannot replace the transport after a view runtime has been mounted\"\n );\n }\n pendingTestTransport = transport;\n}\n\n/**\n * Consume and clear any transport queued by {@link _setTransportForTesting}.\n *\n * @internal\n */\nexport function takePendingTestTransport(): ViewRuntimeTransport | undefined {\n const transport = pendingTestTransport ?? undefined;\n pendingTestTransport = null;\n return transport;\n}\n\n/**\n * Optional disposer registered by bootstrap-view so test reset can run the\n * real unmount-then-close path without a circular static import.\n */\nlet registeredDisposeView: (() => Promise<void>) | null = null;\n\n/**\n * Register {@link disposeView} for {@link _resetViewBridgeForTesting}.\n *\n * @param disposer - The document dispose function from bootstrap-view.\n *\n * @internal\n */\nexport function _registerDisposeViewForTesting(\n disposer: () => Promise<void>\n): void {\n registeredDisposeView = disposer;\n}\n\n/**\n * @internal Reset runtime module seams between tests.\n *\n * Uses the real {@link disposeView} path when bootstrap has registered it\n * (unmount React, then close the App). Falls back to disposing an orphaned\n * active runtime when nothing is mounted through bootstrap.\n */\nexport function _resetViewBridgeForTesting(): void {\n pendingTestTransport = null;\n if (registeredDisposeView) {\n void registeredDisposeView();\n return;\n }\n const runtime = activeRuntime;\n activeRuntime = null;\n if (runtime) {\n void runtime.dispose();\n }\n}\n\n/** @internal Guest `App` for the active runtime (bridge tests only). */\nexport function _getAppForTesting(): App | null {\n return activeRuntime?.getApp() ?? null;\n}\n\n/** @internal Active runtime instance (Phase 5 runtime tests). */\nexport function _getRuntimeForTesting(): McpAppRuntime | null {\n return activeRuntime;\n}\n","import type { CallToolResult } from \"@modelcontextprotocol/server\";\n\nexport type { CallToolResult };\n\n/**\n * Concatenated text content of a tool result, or `undefined` when it has none.\n *\n * Joins the `text` of every `content` block with `type === \"text\"` using\n * `\"\\n\"`, then trims. Returns `undefined` when there are no text blocks or\n * the joined result is empty/whitespace — callers choose their own fallback.\n *\n * Useful when reading human-readable text from a {@link CallToolResult}\n * (success or error) without inspecting the full `content` array.\n *\n * @param result - Tool result (or any object with a `content` array).\n * @returns Joined trimmed text, or `undefined` when there is none.\n *\n * @example\n * ```ts\n * const text = toolResultText(result) ?? \"No message.\";\n * ```\n */\nexport function toolResultText(\n result: Pick<CallToolResult, \"content\">\n): string | undefined {\n const blocks = result.content;\n if (!Array.isArray(blocks) || blocks.length === 0) {\n return undefined;\n }\n\n const parts: string[] = [];\n for (const block of blocks) {\n if (\n block !== null &&\n typeof block === \"object\" &&\n \"type\" in block &&\n block.type === \"text\" &&\n \"text\" in block &&\n typeof block.text === \"string\"\n ) {\n parts.push(block.text);\n }\n }\n\n if (parts.length === 0) {\n return undefined;\n }\n\n const joined = parts.join(\"\\n\").trim();\n return joined.length > 0 ? joined : undefined;\n}\n\n/**\n * The bound or called tool ran and answered with `isError: true` — a domain\n * error, not a transport or protocol failure.\n *\n * `message` is derived from the error result's text content blocks (via\n * {@link toolResultText}), or `\"Tool returned an error.\"` when there are none.\n */\nexport class ToolError extends Error {\n /** The error result as delivered (`isError: true`). */\n readonly result: CallToolResult & { isError: true };\n\n /**\n * @param result - The tool result with `isError: true`.\n */\n constructor(result: CallToolResult & { isError: true }) {\n super(toolResultText(result) ?? \"Tool returned an error.\");\n this.name = \"ToolError\";\n this.result = result;\n }\n}\n\n/**\n * Error that can appear in the `\"error\"` branch of {@link ToolContextHandle}.\n */\nexport type ToolContextError = ToolError;\n\n/**\n * Successful non-error tool result returned by {@link useCallTool}.\n *\n * `structuredContent` is guaranteed and typed exactly when the tool declares\n * an `outputSchema` (`Result` is not `never`) — the server rejects non-error\n * results from schema-backed tools that lack it, so a resolved result always\n * carries it. Tools without an `outputSchema` (`Result = never`) legitimately\n * return content-only results, so no `structuredContent` guarantee is added\n * beyond the base {@link CallToolResult} (optional, `unknown`).\n *\n * Tool errors and transport failures reject instead — they never appear here.\n *\n * @typeParam Result - Inferred `structuredContent` type from the tool's\n * `outputSchema`; `never` when the tool declares none.\n */\nexport type CallToolSuccess<Result> = CallToolResult & {\n isError?: false;\n} & ([Result] extends [never] ? unknown : { structuredContent: Result });\n","import type { App } from \"@modelcontextprotocol/ext-apps\";\nimport type { ContentBlock } from \"@modelcontextprotocol/server\";\n\ninterface ModelContextNode {\n id: string;\n parentId: string | null;\n content: string;\n}\n\ninterface StoredModelContextNode extends ModelContextNode {\n /** Insertion sequence — preserves registration order across flushes. */\n order: number;\n}\n\n/**\n * Complete `ui/update-model-context` params built from the store — the wire\n * shape of the MCP Apps spec's `content` blocks. Each push carries the full\n * current state (the spec's overwrite semantics).\n *\n * @internal\n */\nexport interface ModelContextParams {\n /**\n * Content blocks: empty, or a single text block with the serialized\n * description tree.\n */\n content: ContentBlock[];\n}\n\n/**\n * Narrow runtime surface the flush pump needs to connect and send.\n *\n * @internal\n */\nexport interface ModelContextStoreHost {\n /** Connect once, or return the cached in-flight / settled connection promise. */\n connect(): Promise<App>;\n}\n\nconst EMPTY_SERIALIZED = JSON.stringify({ content: [] });\n\n/**\n * Warn-once flag for hosts that omit the `updateModelContext` capability.\n * Document-scoped so HMR / rebootstrap do not spam the console.\n */\nlet warnedModelContextUnsupported = false;\n\n/**\n * Mark that the missing-`updateModelContext` warning has been emitted.\n *\n * @returns `true` if this call should emit the warning (first time only).\n *\n * @internal\n */\nexport function markModelContextUnsupportedWarned(): boolean {\n if (warnedModelContextUnsupported) {\n return false;\n }\n warnedModelContextUnsupported = true;\n return true;\n}\n\n/**\n * @internal Reset the missing-capability warn-once flag between tests.\n *\n * Prefer {@link _resetModelContextForTesting} from `model-context.tsx` when the\n * active runtime's store must also be cleared; this seam only resets the\n * document-level warn flag (dispose already drops the store).\n */\nexport function _resetModelContextForTesting(): void {\n warnedModelContextUnsupported = false;\n}\n\n/**\n * @internal Reset the missing-capability warn-once flag between tests.\n */\nexport function _resetModelContextUnsupportedWarnedForTesting(): void {\n warnedModelContextUnsupported = false;\n}\n\n/**\n * Per-runtime model-context node tree and async flush pump.\n *\n * Owned by one {@link McpAppRuntime}: constructed with it, disposed with it.\n * Mutations update desired state and schedule a microtask-batched pump that\n * acknowledges a payload only after a successful `updateModelContext` send.\n *\n * @internal\n */\nexport class ModelContextStore {\n readonly #host: ModelContextStoreHost;\n readonly #nodes = new Map<string, StoredModelContextNode>();\n #nextOrder = 0;\n #flushScheduled = false;\n #disposed = false;\n /** Bumped on {@link dispose} so late in-flight completions are ignored. */\n #epoch = 0;\n /**\n * Serialized form of the latest tree. Starts empty so views that never\n * register context are not dirty.\n */\n #desiredSerialized = EMPTY_SERIALIZED;\n /**\n * Last successfully delivered payload. Starts empty so an empty push is\n * sent only as a clear after non-empty context existed.\n */\n #acknowledgedSerialized = EMPTY_SERIALIZED;\n #inFlight: Promise<void> | null = null;\n\n /**\n * @param host - Runtime bridge used to `connect` and send updates.\n */\n constructor(host: ModelContextStoreHost) {\n this.#host = host;\n }\n\n /**\n * Register or replace a node and schedule a flush.\n *\n * @param node - Node identity, parent link, and text content.\n */\n setNode(node: ModelContextNode): void {\n if (this.#disposed) return;\n const order = this.#nodes.get(node.id)?.order ?? this.#nextOrder++;\n this.#nodes.set(node.id, { ...node, order });\n this.#updateDesiredAndSchedule();\n }\n\n /**\n * Remove a node by id and schedule a flush.\n *\n * @param id - Node id previously passed to {@link setNode}.\n */\n removeNode(id: string): void {\n if (this.#disposed) return;\n if (!this.#nodes.delete(id)) return;\n this.#updateDesiredAndSchedule();\n }\n\n /** Remove every node and schedule a flush (empty clear when previously non-empty). */\n clear(): void {\n if (this.#disposed) return;\n if (this.#nodes.size === 0) return;\n this.#nodes.clear();\n this.#updateDesiredAndSchedule();\n }\n\n /**\n * Invalidate the store: ignore late in-flight completions and reject further\n * mutations. Does not send a final clear — the runtime is going away.\n */\n dispose(): void {\n if (this.#disposed) return;\n this.#disposed = true;\n this.#epoch += 1;\n this.#flushScheduled = false;\n this.#inFlight = null;\n this.#nodes.clear();\n this.#nextOrder = 0;\n this.#desiredSerialized = EMPTY_SERIALIZED;\n this.#acknowledgedSerialized = EMPTY_SERIALIZED;\n }\n\n /**\n * Serialize the registered tree into an indented markdown-like string.\n *\n * @returns Description text, or `\"\"` when nothing is registered.\n */\n buildDescriptionString(): string {\n const byParent = new Map<string | null, StoredModelContextNode[]>();\n\n for (const node of this.#nodes.values()) {\n const key = node.parentId ?? null;\n const list = byParent.get(key);\n if (list) {\n list.push(node);\n } else {\n byParent.set(key, [node]);\n }\n }\n\n // Sibling order = registration order. React runs effects in document order\n // for siblings, so this tracks on-screen order; sorting by `useId` strings\n // would not (`:r10:` sorts before `:r2:`).\n for (const list of byParent.values()) {\n list.sort((a, b) => a.order - b.order);\n }\n\n const lines: string[] = [];\n\n const traverseTree = (parentId: string | null, depth: number): void => {\n const children = byParent.get(parentId);\n if (!children) return;\n for (const child of children) {\n if (child.content.trim()) {\n lines.push(`${\" \".repeat(depth)}- ${child.content.trim()}`);\n }\n traverseTree(child.id, depth + 1);\n }\n };\n\n traverseTree(null, 0);\n return lines.join(\"\\n\");\n }\n\n /**\n * Build the `ui/update-model-context` params from the current tree.\n *\n * @returns Empty `content` when nothing is registered; otherwise one text block.\n */\n buildModelContextParams(): ModelContextParams {\n const description = this.buildDescriptionString();\n if (description.length === 0) {\n return { content: [] };\n }\n return { content: [{ type: \"text\", text: description }] };\n }\n\n /**\n * @internal Clear nodes and pump state between tests without disposing the\n * owning runtime (warn-once flag is reset separately).\n */\n resetForTesting(): void {\n this.#nodes.clear();\n this.#nextOrder = 0;\n this.#flushScheduled = false;\n this.#inFlight = null;\n this.#desiredSerialized = EMPTY_SERIALIZED;\n this.#acknowledgedSerialized = EMPTY_SERIALIZED;\n // Keep #disposed / #epoch — a disposed store stays disposed.\n }\n\n /** @internal Serialized tree for tests. */\n getDescriptionForTesting(): string {\n return this.buildDescriptionString();\n }\n\n #updateDesiredAndSchedule(): void {\n this.#desiredSerialized = JSON.stringify(this.buildModelContextParams());\n this.#schedulePump();\n }\n\n #schedulePump(): void {\n if (this.#disposed) return;\n if (this.#flushScheduled) return;\n this.#flushScheduled = true;\n queueMicrotask(() => {\n this.#flushScheduled = false;\n this.#pump();\n });\n }\n\n #pump(): void {\n if (this.#disposed) return;\n if (this.#inFlight) return;\n if (this.#desiredSerialized === this.#acknowledgedSerialized) return;\n\n const params = this.buildModelContextParams();\n // Re-serialize from the live tree and track that exact form for ack.\n const serialized = JSON.stringify(params);\n this.#desiredSerialized = serialized;\n if (serialized === this.#acknowledgedSerialized) return;\n\n const sendEpoch = this.#epoch;\n let sendSucceeded = false;\n\n this.#inFlight = (async () => {\n try {\n const app = await this.#host.connect();\n if (this.#disposed || sendEpoch !== this.#epoch) return;\n\n if (app.getHostCapabilities()?.updateModelContext === undefined) {\n if (markModelContextUnsupportedWarned()) {\n console.warn(\n \"[ModelContext] Host does not declare the updateModelContext capability; model-context updates are not sent.\"\n );\n }\n // Stay dirty — a later host/capability may accept updates.\n return;\n }\n\n await app.updateModelContext(\n params as Parameters<App[\"updateModelContext\"]>[0]\n );\n if (this.#disposed || sendEpoch !== this.#epoch) return;\n\n // Acknowledge the exact payload that was sent. If desired moved on\n // mid-flight, the store stays dirty and the finally-block re-pumps.\n this.#acknowledgedSerialized = serialized;\n sendSucceeded = true;\n } catch (error: unknown) {\n if (this.#disposed || sendEpoch !== this.#epoch) return;\n console.warn(\"[ModelContext] Failed to update model context:\", error);\n } finally {\n this.#inFlight = null;\n if (\n !this.#disposed &&\n sendEpoch === this.#epoch &&\n sendSucceeded &&\n this.#desiredSerialized !== this.#acknowledgedSerialized\n ) {\n // Coalesced mutations during the in-flight send — push the latest.\n this.#pump();\n }\n }\n })();\n }\n}\n","/**\n * Client-side resolution for root-relative public asset paths.\n *\n * The synthesized view document injects {@link McpUseViewConfig} before any\n * module scripts so iframe code can resolve `/…` paths to absolute URLs.\n */\n\n/**\n * Request-scoped view configuration injected into the synthesized document.\n *\n * @remarks\n * Set per request by {@link synthesizeViewDocument} — not at build or boot\n * time — so public asset URLs stay correct behind proxies and tunnels.\n */\nexport interface McpUseViewConfig {\n /**\n * Absolute URL prefix for the project's `public/` directory, including a\n * trailing slash (e.g. `http://127.0.0.1:3000/mcp/_mcp-use/public/`).\n */\n publicBase: string;\n}\n\ndeclare global {\n var __mcpUseViewConfig: McpUseViewConfig | undefined;\n}\n\n/**\n * Read the injected public asset base URL, if present.\n *\n * @returns The request-resolved `publicBase`, or an empty string outside a\n * synthesized view document.\n *\n * @internal\n */\nexport function getPublicBase(): string {\n if (typeof globalThis === \"undefined\") {\n return \"\";\n }\n return globalThis.__mcpUseViewConfig?.publicBase ?? \"\";\n}\n\n/**\n * Resolve a root-relative path from the project's `public/` folder to an\n * absolute URL for the current view iframe.\n *\n * Root-relative paths (starting with `/`) are resolved against the injected\n * {@link McpUseViewConfig.publicBase}. Absolute `http(s):` and `data:` URLs\n * pass through unchanged. Fully-relative paths (no leading slash) are returned\n * as-is. Not part of the public API — public assets are consumed through the\n * {@link Image} component.\n *\n * @param path - Author path, typically root-relative from the `public/` folder\n * (e.g. `/fruits/apple.png`).\n * @returns The resolved absolute URL, or the original path when no base is set.\n *\n * @internal\n */\nexport function publicAsset(path: string): string {\n if (path === \"\") {\n return path;\n }\n if (\n path.startsWith(\"http://\") ||\n path.startsWith(\"https://\") ||\n path.startsWith(\"data:\")\n ) {\n return path;\n }\n if (path.startsWith(\"/\")) {\n const publicBase = getPublicBase();\n if (publicBase === \"\") {\n return path;\n }\n return `${publicBase}${path.slice(1)}`;\n }\n return path;\n}\n","import React from \"react\";\n\nimport { publicAsset } from \"../public-assets.js\";\n\n/**\n * Image element that resolves root-relative `src` paths against the project's\n * `public/` directory via the request-scoped config injected into the\n * synthesized view document.\n *\n * Root-relative paths (starting with `/`) resolve to absolute URLs under\n * `${basePath}/_mcp-use/public/`. Absolute `http(s):` and `data:` URLs pass\n * through unchanged. Fully-relative paths are left as-is.\n */\nexport const Image: React.FC<React.ImgHTMLAttributes<HTMLImageElement>> = ({\n src,\n ...props\n}) => {\n const finalSrc = typeof src === \"string\" ? publicAsset(src) : src;\n\n return <img src={finalSrc} {...props} />;\n};\n","/**\n * ModelContext: React component and module-level API for annotating view UI\n * with contextual information the model can see.\n */\n\nimport {\n createContext,\n type ReactNode,\n useContext,\n useEffect,\n useId,\n} from \"react\";\n\nimport type { ModelContextStore } from \"../runtime/model-context-store.js\";\nimport {\n _resetModelContextUnsupportedWarnedForTesting,\n type ModelContextParams,\n} from \"../runtime/model-context-store.js\";\nimport { useViewRuntime } from \"../runtime/view-runtime-context.js\";\nimport { getActiveRuntime } from \"../runtime/view-runtime.js\";\n\nconst ParentIdContext = createContext<string | null>(null);\n\ninterface ModelContextProps {\n /** Text describing what the user is currently seeing. */\n content: string;\n /** Optional children — acts as a scope boundary for nested context nodes. */\n children?: ReactNode;\n}\n\n/**\n * Resolve the active runtime's {@link ModelContextStore}.\n *\n * @throws When no view runtime is mounted.\n */\nfunction requireActiveModelContextStore(): ModelContextStore {\n const runtime = getActiveRuntime();\n if (!runtime) {\n throw new Error(\n \"modelContext requires a browser view mounted by bootstrapView\"\n );\n }\n return runtime.modelContextStore;\n}\n\n/**\n * Annotate a portion of the view UI with a description the model can see.\n *\n * Registers `content` in a hierarchical tree that serializes into an indented\n * markdown list and is pushed to the host via `ui/update-model-context`\n * (ext-apps `App.updateModelContext`). Updates batch per microtask. An async\n * flush pump acknowledges a payload only after a successful send; failed\n * update requests and missing host capability stay dirty and retry on the next\n * mutation. Each push carries the complete current context — the spec's\n * overwrite semantics (the host may defer delivery until the next model turn).\n *\n * An empty `content` (trimmed) does not register a node and does not orphan\n * children — nested {@link ModelContext} nodes re-parent to the nearest\n * registered ancestor (or root).\n *\n * When the host does not declare the `updateModelContext` capability, pushes\n * are skipped (payload stays dirty) and a one-time `console.warn` names the\n * gap.\n *\n * @param props - Component props.\n * @param props.content - Text describing what the user is currently seeing.\n * @param props.children - Optional nested UI; nested {@link ModelContext}\n * nodes serialize as indented children of this node when this node has\n * non-empty content.\n *\n * @example\n * ```tsx\n * <ModelContext content={`Selected: ${item.name}`} />\n *\n * <ModelContext content=\"Dashboard\">\n * <ModelContext content=\"Revenue section\" />\n * </ModelContext>\n * ```\n */\nexport function ModelContext({ content, children }: ModelContextProps) {\n const runtime = useViewRuntime();\n const store = runtime.modelContextStore;\n const parentId = useContext(ParentIdContext);\n const id = useId();\n const hasContent = content.trim().length > 0;\n const childParentId = hasContent ? id : parentId;\n\n useEffect(() => {\n if (hasContent) {\n store.setNode({ id, parentId, content });\n }\n return () => {\n store.removeNode(id);\n };\n }, [store, id, parentId, content, hasContent]);\n\n if (children === undefined || children === null) {\n return null;\n }\n\n return (\n <ParentIdContext.Provider value={childParentId}>\n {children}\n </ParentIdContext.Provider>\n );\n}\n\n/**\n * Imperative model-context API for non-React call sites (event handlers,\n * stores).\n *\n * Delegates to the active document runtime's {@link ModelContextStore}.\n * Strings register as root-level nodes in the same tree {@link ModelContext}\n * builds; each push overwrites the previous context on the host (the host may\n * defer delivery until the next model turn). Updates batch per microtask and\n * use the same async flush pump (ack only on success). When the host lacks the\n * `updateModelContext` capability, pushes stay dirty with a one-time\n * `console.warn`.\n *\n * @throws When no view runtime is mounted (`bootstrapView` has not activated a\n * runtime, or it has been disposed).\n *\n * @example\n * ```ts\n * modelContext.set(\"active-item\", `Viewing ${item.name}`);\n * modelContext.remove(\"active-item\");\n * modelContext.clear();\n * ```\n */\nexport const modelContext = {\n /**\n * Register or update a named root-level text context entry.\n *\n * @param key - Stable key for this entry (replaces any prior value under the same key).\n * @param content - Text describing what the user is seeing.\n * @throws When no view runtime is mounted.\n */\n set(key: string, content: string): void {\n requireActiveModelContextStore().setNode({\n id: key,\n parentId: null,\n content,\n });\n },\n\n /**\n * Remove the entry registered under `key`.\n *\n * @param key - Key previously passed to {@link modelContext.set}.\n * @throws When no view runtime is mounted.\n */\n remove(key: string): void {\n requireActiveModelContextStore().removeNode(key);\n },\n\n /**\n * Remove all context entries.\n *\n * @throws When no view runtime is mounted.\n */\n clear(): void {\n requireActiveModelContextStore().clear();\n },\n} as const;\n\n/**\n * @internal Reset model-context warn-once flag and the active runtime's store\n * between tests.\n */\nexport function _resetModelContextForTesting(): void {\n _resetModelContextUnsupportedWarnedForTesting();\n const runtime = getActiveRuntime();\n if (runtime) {\n runtime.modelContextStore.resetForTesting();\n }\n}\n\n/** @internal Serialized tree for the active runtime's store (tests). */\nexport function _getDescriptionForTesting(): string {\n return getActiveRuntime()?.modelContextStore.getDescriptionForTesting() ?? \"\";\n}\n\n/**\n * @internal Serialize the active runtime's model-context tree.\n *\n * @returns Description string, or `\"\"` when no runtime is mounted.\n */\nexport function buildDescriptionString(): string {\n return getActiveRuntime()?.modelContextStore.buildDescriptionString() ?? \"\";\n}\n\n/**\n * @internal Build `ui/update-model-context` params from the active store.\n *\n * @returns Empty content when no runtime is mounted or nothing is registered.\n */\nexport function buildModelContextParams(): ModelContextParams {\n return (\n getActiveRuntime()?.modelContextStore.buildModelContextParams() ?? {\n content: [],\n }\n );\n}\n","import {\n applyDocumentTheme,\n applyHostFonts,\n applyHostStyleVariables,\n} from \"@modelcontextprotocol/ext-apps\";\nimport React, { useLayoutEffect, useState } from \"react\";\n\nimport { useHostContextSubscription } from \"../runtime/view-runtime-context.js\";\n\n/** Keep iframe canvas transparent so host background shows through rounded views. */\nfunction applyTransparentIframeCanvas(): void {\n document.documentElement.style.background = \"transparent\";\n document.body.style.background = \"transparent\";\n const root = document.getElementById(\"root\");\n if (root) root.style.background = \"transparent\";\n}\n\nconst FILL_HOST_WRAPPER_STYLE: React.CSSProperties = {\n position: \"relative\",\n height: \"100%\",\n minHeight: \"100%\",\n display: \"flex\",\n flexDirection: \"column\",\n};\n\n/** ponytail: inline widgets size to content; fullscreen/pip need a height chain */\nfunction useFillHostDocument(fillHost: boolean): void {\n useLayoutEffect(() => {\n if (!fillHost || typeof document === \"undefined\") return;\n\n const html = document.documentElement;\n const body = document.body;\n const root = document.getElementById(\"root\");\n const prev = {\n htmlH: html.style.height,\n bodyH: body.style.height,\n htmlMin: html.style.minHeight,\n bodyMin: body.style.minHeight,\n rootH: root?.style.height ?? \"\",\n rootMin: root?.style.minHeight ?? \"\",\n };\n\n for (const el of [html, body]) {\n el.style.height = \"100%\";\n el.style.minHeight = \"100%\";\n }\n if (root) {\n root.style.height = \"100%\";\n root.style.minHeight = \"100%\";\n }\n\n return () => {\n html.style.height = prev.htmlH;\n body.style.height = prev.bodyH;\n html.style.minHeight = prev.htmlMin;\n body.style.minHeight = prev.bodyMin;\n if (root) {\n root.style.height = prev.rootH;\n root.style.minHeight = prev.rootMin;\n }\n };\n }, [fillHost]);\n}\n\n/**\n * Applies host theme, style variables, and fonts to the document root.\n *\n * Subscribes to the host channel (theme, `styles.variables`, `styles.css.fonts`)\n * via {@link useHostContextSubscription}. Theme-only consumers should use\n * {@link useViewTheme} instead so locale/dimension updates do not rerender them.\n *\n * MCP App views render in srcdoc iframes; the document canvas stays transparent\n * by default so rounded cards do not expose an opaque `color-scheme` backdrop.\n */\nexport const ThemeProvider: React.FC<{\n children: React.ReactNode;\n /** Set `color-scheme` on the document root to match the active theme. */\n colorScheme?: boolean;\n}> = ({ children, colorScheme = false }) => {\n const hostContext = useHostContextSubscription();\n const [systemPreference, setSystemPreference] = useState<\"light\" | \"dark\">(\n () => {\n if (typeof window === \"undefined\") return \"light\";\n return window.matchMedia(\"(prefers-color-scheme: dark)\").matches\n ? \"dark\"\n : \"light\";\n }\n );\n\n React.useEffect(() => {\n if (typeof window === \"undefined\") return;\n const mediaQuery = window.matchMedia(\"(prefers-color-scheme: dark)\");\n const handleChange = (event: MediaQueryListEvent) => {\n setSystemPreference(event.matches ? \"dark\" : \"light\");\n };\n mediaQuery.addEventListener(\"change\", handleChange);\n return () => mediaQuery.removeEventListener(\"change\", handleChange);\n }, []);\n\n const hostTheme =\n hostContext?.theme === \"dark\" || hostContext?.theme === \"light\"\n ? hostContext.theme\n : undefined;\n const effectiveTheme = hostTheme ?? systemPreference;\n const fillHost =\n hostContext?.displayMode === \"fullscreen\" ||\n hostContext?.displayMode === \"pip\";\n\n useFillHostDocument(fillHost);\n\n useLayoutEffect(() => {\n if (typeof document === \"undefined\") return;\n applyDocumentTheme(effectiveTheme);\n applyTransparentIframeCanvas();\n if (colorScheme) {\n document.documentElement.style.colorScheme =\n effectiveTheme === \"dark\" ? \"dark\" : \"light\";\n } else {\n document.documentElement.style.colorScheme = \"\";\n }\n }, [effectiveTheme, colorScheme]);\n\n useLayoutEffect(() => {\n const variables = hostContext?.styles?.variables;\n if (variables) {\n applyHostStyleVariables(variables);\n }\n const fonts = hostContext?.styles?.css?.fonts;\n if (typeof fonts === \"string\") {\n applyHostFonts(fonts);\n }\n }, [hostContext]);\n\n if (fillHost) {\n return <div style={FILL_HOST_WRAPPER_STYLE}>{children}</div>;\n }\n\n return <>{children}</>;\n};\n","import React, { useRef, useState } from \"react\";\n\nimport { useDisplayMode } from \"../hooks/use-display-mode.js\";\nimport { useHostContext } from \"../hooks/use-host-context.js\";\nimport { useToolContext } from \"../hooks/use-tool-context.js\";\n\n/**\n * Static styles for the debug overlay. Hoisted to module scope so the objects\n * keep stable identities across renders (this runtime ships no stylesheet, so\n * CSS classes are not an option here).\n */\nconst debugOverlayStyle: React.CSSProperties = {\n position: \"fixed\",\n inset: 0,\n zIndex: 10000,\n boxSizing: \"border-box\",\n padding: \"56px 16px 16px\",\n background: \"#111\",\n color: \"#eee\",\n overflow: \"auto\",\n};\n\nconst debugContentStyle: React.CSSProperties = {\n margin: 0,\n fontSize: 12,\n whiteSpace: \"pre-wrap\",\n overflowWrap: \"anywhere\",\n};\n\nconst debugCloseButtonStyle: React.CSSProperties = {\n position: \"fixed\",\n top: 16,\n right: 16,\n zIndex: 10001,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n width: 36,\n height: 36,\n padding: 0,\n border: \"2px solid #111\",\n borderRadius: 9999,\n background: \"#fff\",\n color: \"#111\",\n boxShadow: \"0 2px 12px rgba(0, 0, 0, 0.45)\",\n cursor: \"pointer\",\n fontSize: 26,\n fontWeight: 600,\n lineHeight: 1,\n};\n\ninterface ViewControlsProps {\n children: React.ReactNode;\n /** Show a debug overlay with view state and action testers. */\n debugger?: boolean;\n /** Show fullscreen / PiP display-mode buttons. */\n viewControls?: boolean | \"pip\" | \"fullscreen\";\n}\n\n/**\n * Dev-only overlay with debug info and bridge action testers.\n */\nexport function ViewControls({\n children,\n debugger: enableDebugger = false,\n viewControls = false,\n}: ViewControlsProps) {\n const context = useToolContext();\n const host = useHostContext();\n const { displayMode, availableDisplayModes, requestDisplayMode } =\n useDisplayMode();\n const [open, setOpen] = useState(false);\n const [hovered, setHovered] = useState(false);\n const displayModeBeforeDebugRef = useRef(displayMode);\n const restoreDisplayModeOnCloseRef = useRef(false);\n\n const showControls = enableDebugger || viewControls;\n\n const openDebugger = () => {\n displayModeBeforeDebugRef.current = displayMode;\n setOpen(true);\n\n const canExpand =\n displayMode !== \"fullscreen\" &&\n availableDisplayModes.includes(\"fullscreen\");\n restoreDisplayModeOnCloseRef.current = canExpand;\n\n if (canExpand) {\n void requestDisplayMode({ mode: \"fullscreen\" }).catch(() => {\n // The overlay remains usable inline when the host denies expansion.\n restoreDisplayModeOnCloseRef.current = false;\n });\n }\n };\n\n const closeDebugger = () => {\n setOpen(false);\n\n if (!restoreDisplayModeOnCloseRef.current) return;\n restoreDisplayModeOnCloseRef.current = false;\n void requestDisplayMode({\n mode: displayModeBeforeDebugRef.current,\n }).catch(() => {\n // The host owns display mode; closing the overlay must never be blocked.\n });\n };\n\n return (\n <div\n style={{ position: \"relative\" }}\n onMouseEnter={() => setHovered(true)}\n onMouseLeave={() => setHovered(false)}\n >\n {showControls && (\n <div\n style={{\n position: \"absolute\",\n top: 8,\n right: 8,\n zIndex: 1000,\n display: \"flex\",\n gap: 8,\n opacity: hovered ? 1 : 0,\n transition: \"opacity 0.2s\",\n }}\n >\n {viewControls && host.displayMode === \"inline\" && (\n <>\n {(viewControls === true || viewControls === \"fullscreen\") && (\n <button\n type=\"button\"\n aria-label=\"Fullscreen\"\n onClick={() =>\n void requestDisplayMode({ mode: \"fullscreen\" })\n }\n >\n FS\n </button>\n )}\n {(viewControls === true || viewControls === \"pip\") && (\n <button\n type=\"button\"\n aria-label=\"Picture in picture\"\n onClick={() => void requestDisplayMode({ mode: \"pip\" })}\n >\n PiP\n </button>\n )}\n </>\n )}\n {enableDebugger && (\n <button type=\"button\" aria-label=\"Debug\" onClick={openDebugger}>\n Debug\n </button>\n )}\n </div>\n )}\n {children}\n {enableDebugger && open && (\n <div\n style={debugOverlayStyle}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label=\"Debug info\"\n >\n <button\n type=\"button\"\n style={debugCloseButtonStyle}\n aria-label=\"Close debug\"\n title=\"Close debug\"\n onClick={closeDebugger}\n >\n ×\n </button>\n <pre style={debugContentStyle}>\n {JSON.stringify(\n {\n status: context.status,\n toolOutput:\n context.status === \"ready\" ? context.toolOutput : undefined,\n content:\n context.status === \"ready\" || context.status === \"error\"\n ? context.content\n : undefined,\n toolInput: context.toolInput,\n meta:\n context.status === \"ready\" || context.status === \"error\"\n ? context.meta\n : undefined,\n error: context.status === \"error\" ? context.error : undefined,\n theme: host.theme,\n displayMode: host.displayMode,\n isAvailable: host.isAvailable,\n },\n null,\n 2\n )}\n </pre>\n </div>\n )}\n </div>\n );\n}\n","import { useSyncExternalStore } from \"react\";\n\nimport { useViewRuntime } from \"../runtime/view-runtime-context.js\";\nimport type { DisplayMode } from \"../types/host-types.js\";\n\n/**\n * Read the current display mode and request changes from the host.\n *\n * @remarks\n * `requestDisplayMode` is advisory: the host decides whether to honor it and\n * may grant a different mode or none at all. The returned promise resolves\n * once the host has processed the request — resolution does **not** mean the\n * mode changed. The single source of truth for the outcome is `displayMode`,\n * which updates reactively when the host applies a change; a denied request\n * simply leaves it unchanged. Do not store the requested mode in local state —\n * render from `displayMode` so the view also tracks mode changes the host\n * makes on its own (for example, the user exiting fullscreen).\n *\n * `displayMode` is `\"inline\"` until the host reports otherwise.\n * `availableDisplayModes` is the negotiated intersection of\n * `viewConfig.displayModes` and `hostContext.availableDisplayModes`. When the\n * host omits available modes, only `\"inline\"` is requestable.\n * `requestDisplayMode` rejects modes outside that intersection before sending;\n * the method itself is runtime-owned and referentially stable.\n *\n * @example\n * ```tsx\n * function ExpandButton() {\n * const { displayMode, availableDisplayModes, requestDisplayMode } =\n * useDisplayMode();\n * if (!availableDisplayModes.includes(\"fullscreen\")) return null;\n * if (displayMode === \"fullscreen\") return null;\n * return (\n * <button\n * type=\"button\"\n * onClick={() => {\n * void requestDisplayMode({ mode: \"fullscreen\" });\n * }}\n * >\n * Expand\n * </button>\n * );\n * }\n * ```\n */\nexport function useDisplayMode(): {\n /** How the host is currently displaying the view; `\"inline\"` until the host reports otherwise. */\n displayMode: DisplayMode;\n /**\n * Negotiated modes: intersection of `viewConfig.displayModes` and host\n * `availableDisplayModes` (host omits → only `\"inline\"`).\n */\n availableDisplayModes: readonly DisplayMode[];\n /**\n * Ask the host to switch display mode. Rejects when the mode is outside the\n * negotiated intersection. Resolves when the host has processed the request;\n * observe `displayMode` for the outcome.\n */\n requestDisplayMode: (args: { mode: DisplayMode }) => Promise<void>;\n} {\n const runtime = useViewRuntime();\n const { displayMode, availableDisplayModes } = useSyncExternalStore(\n runtime.subscribeDisplay,\n runtime.getDisplaySnapshot\n );\n return {\n displayMode,\n availableDisplayModes,\n requestDisplayMode: runtime.requestDisplayMode,\n };\n}\n","import { useSyncExternalStore } from \"react\";\n\nimport { useViewRuntime } from \"../runtime/view-runtime-context.js\";\nimport type {\n DisplayMode,\n HostCapabilities,\n HostContext,\n HostInfo,\n SafeAreaInsets,\n} from \"../types/host-types.js\";\n\nconst DEFAULT_SAFE_AREA: SafeAreaInsets = {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0,\n};\n\nfunction readMaxHeight(\n hostContext: HostContext | undefined\n): number | undefined {\n const dims = hostContext?.containerDimensions;\n if (!dims) return undefined;\n if (\"height\" in dims && typeof dims.height === \"number\") return dims.height;\n if (\"maxHeight\" in dims && typeof dims.maxHeight === \"number\") {\n return dims.maxHeight;\n }\n return undefined;\n}\n\nfunction readMaxWidth(\n hostContext: HostContext | undefined\n): number | undefined {\n const dims = hostContext?.containerDimensions;\n if (!dims) return undefined;\n if (\"width\" in dims && typeof dims.width === \"number\") return dims.width;\n if (\"maxWidth\" in dims && typeof dims.maxWidth === \"number\") {\n return dims.maxWidth;\n }\n return undefined;\n}\n\nfunction resolveDisplayMode(hostContext: HostContext | undefined): DisplayMode {\n return hostContext?.displayMode === \"fullscreen\" ||\n hostContext?.displayMode === \"pip\"\n ? hostContext.displayMode\n : \"inline\";\n}\n\nfunction resolvePlatform(\n hostContext: HostContext | undefined\n): \"web\" | \"mobile\" {\n return hostContext?.platform === \"mobile\" ? \"mobile\" : \"web\";\n}\n\n/**\n * Host environment and bridge availability for the current view.\n */\nexport interface HostContextHandle {\n /** Host color theme. `\"light\"` until the host reports a theme. */\n theme: \"light\" | \"dark\";\n /** User locale (BCP 47). Falls back to `\"en-US\"` when the host does not report one. */\n locale: string;\n /** User timezone (IANA). Falls back to the browser's timezone, then `\"UTC\"`. */\n timeZone: string;\n /** Host application user-agent string. Falls back to the browser's own user agent. */\n userAgent: string;\n /**\n * Host-reported platform. `\"mobile\"` on mobile hosts; otherwise `\"web\"`.\n * Inspector maps Desktop → `\"web\"` and Mobile → `\"mobile\"`.\n */\n platform: \"web\" | \"mobile\";\n /** How the host is currently displaying the view. `\"inline\"` until the host reports otherwise. */\n displayMode: DisplayMode;\n /** Mobile safe area insets in pixels. All zeros when the host reports none. */\n safeArea: SafeAreaInsets;\n /**\n * Vertical layout budget in pixels: the most height the view can occupy.\n *\n * Derived from the host's container dimensions. When the host fixes the\n * container to an exact height, that height is reported; otherwise the\n * host's stated maximum is. `undefined` when the host reports no layout\n * constraint — treat that as unbounded. The raw dimensions remain available\n * on `hostContext.containerDimensions`.\n */\n maxHeight: number | undefined;\n /**\n * Horizontal layout budget in pixels: the most width the view can occupy.\n *\n * Same derivation as `maxHeight`: an exact container width when the host\n * fixes one, otherwise the host's stated maximum, otherwise `undefined`\n * (unbounded).\n */\n maxWidth: number | undefined;\n /** Host identity (name and version). `undefined` until the bridge has connected. */\n hostInfo: HostInfo | undefined;\n /** Host capabilities negotiated at initialization. `undefined` until the bridge has connected. */\n hostCapabilities: HostCapabilities | undefined;\n /**\n * The host context object exactly as the host reported it, with none of the\n * fallbacks the fields above apply. Use it to read host-specific fields this\n * handle does not surface. `undefined` until the host first reports context.\n */\n hostContext: HostContext | undefined;\n /** Whether the MCP Apps bridge is connected. While `false`, every field holds its documented fallback. */\n isAvailable: boolean;\n}\n\n/**\n * Subscribe to host environment context (theme, locale, display mode, layout).\n *\n * Re-renders only when host context or bridge connection status changes — not\n * on tool-input / result / cancel snapshot updates.\n *\n * @example\n * ```tsx\n * function Layout() {\n * const { theme, locale, maxHeight } = useHostContext();\n * return (\n * <div data-theme={theme} lang={locale} style={{ maxHeight }}>\n * …\n * </div>\n * );\n * }\n * ```\n */\nexport function useHostContext(): HostContextHandle {\n const runtime = useViewRuntime();\n const { hostContext, isConnected } = useSyncExternalStore(\n runtime.subscribeHost,\n runtime.getHostSnapshot\n );\n const app = runtime.getApp();\n\n return {\n theme: hostContext?.theme === \"dark\" ? \"dark\" : \"light\",\n locale:\n typeof hostContext?.locale === \"string\" ? hostContext.locale : \"en-US\",\n timeZone:\n typeof hostContext?.timeZone === \"string\"\n ? hostContext.timeZone\n : typeof Intl !== \"undefined\"\n ? Intl.DateTimeFormat().resolvedOptions().timeZone\n : \"UTC\",\n userAgent:\n typeof hostContext?.userAgent === \"string\"\n ? hostContext.userAgent\n : typeof navigator !== \"undefined\"\n ? navigator.userAgent\n : \"\",\n platform: resolvePlatform(hostContext),\n displayMode: resolveDisplayMode(hostContext),\n safeArea: hostContext?.safeAreaInsets ?? DEFAULT_SAFE_AREA,\n maxHeight: readMaxHeight(hostContext),\n maxWidth: readMaxWidth(hostContext),\n hostInfo: app?.getHostVersion(),\n hostCapabilities: app?.getHostCapabilities(),\n hostContext,\n isAvailable: isConnected,\n };\n}\n","import type { ContentBlock } from \"@modelcontextprotocol/server\";\nimport { useSyncExternalStore } from \"react\";\n\nimport { useViewRuntime } from \"../runtime/view-runtime-context.js\";\nimport type { DeepPartial, RegisteredTools } from \"../types/register.js\";\nimport type { ToolContextError } from \"../types/result-types.js\";\n\nexport type { ToolContextError } from \"../types/result-types.js\";\n\ntype ToolOutput<Name extends keyof RegisteredTools> =\n Name extends keyof RegisteredTools\n ? RegisteredTools[Name][\"output\"]\n : unknown;\n\ntype ToolInput<Name extends keyof RegisteredTools> =\n Name extends keyof RegisteredTools ? RegisteredTools[Name][\"input\"] : unknown;\n\n/** No structured result has been latched yet. */\ninterface PendingToolContext<Name extends keyof RegisteredTools> {\n status: \"pending\";\n /** Latest complete or partial arguments; each notification replaces it. */\n toolInput: DeepPartial<ToolInput<Name>> | undefined;\n toolOutput: undefined;\n content: undefined;\n meta: undefined;\n error?: undefined;\n}\n\n/** First non-error result carrying `structuredContent`. */\ninterface ReadyToolContext<Name extends keyof RegisteredTools> {\n status: \"ready\";\n /** Latest arguments delivered before the result, when available. */\n toolInput: ToolInput<Name> | undefined;\n /** Typed `structuredContent` from the latched rendering result. */\n toolOutput: ToolOutput<Name>;\n content: ContentBlock[] | undefined;\n /** View-only result `_meta`, when present. */\n meta: Record<string, unknown> | undefined;\n error?: undefined;\n}\n\n/** First tool result carrying `isError: true`. */\ninterface ErrorToolContext<Name extends keyof RegisteredTools> {\n status: \"error\";\n /** Latest arguments delivered before the error, when available. */\n toolInput: ToolInput<Name> | undefined;\n toolOutput: undefined;\n content: ContentBlock[] | undefined;\n meta: Record<string, unknown> | undefined;\n error: ToolContextError;\n}\n\n/**\n * The rendering invocation's latched lifecycle.\n *\n * Partial and complete input notifications replace the same `toolInput`\n * snapshot while pending. Because the MCP Apps notification has no tool name\n * or request id, the first structured result or tool error is assumed to\n * belong to the rendering invocation and becomes terminal. Content-only\n * successes are valid ambient activity and are ignored.\n */\nexport type ToolContextHandle<Name extends keyof RegisteredTools = never> =\n | PendingToolContext<Name>\n | ReadyToolContext<Name>\n | ErrorToolContext<Name>;\n\n/**\n * Read the tool invocation that rendered this View.\n *\n * The hook starts pending with an optional progressive `toolInput`, then\n * latches the first structured success or tool error for the View's lifetime.\n * Later lifecycle notifications cannot overwrite that terminal context.\n *\n * @example\n * ```tsx\n * function ProductSearchResult() {\n * const view = useToolContext<\"search-fruits\">();\n *\n * if (view.status === \"error\") {\n * return <ToolErrorBanner message={view.error.message} />;\n * }\n * if (view.status === \"pending\") {\n * return <SearchSkeleton query={view.toolInput?.query} />;\n * }\n * return <Results items={view.toolOutput.items} />;\n * }\n * ```\n */\nexport function useToolContext<\n Name extends keyof RegisteredTools = never,\n>(): ToolContextHandle<Name> {\n const runtime = useViewRuntime();\n const snap = useSyncExternalStore(\n runtime.subscribeTool,\n runtime.getToolSnapshot\n );\n\n if (snap.status === \"error\") {\n return {\n status: \"error\",\n toolInput: snap.toolInput as ToolInput<Name> | undefined,\n toolOutput: undefined,\n content: snap.content,\n meta: snap.meta,\n error: snap.error as ToolContextError,\n };\n }\n\n if (snap.status === \"ready\") {\n return {\n status: \"ready\",\n toolInput: snap.toolInput as ToolInput<Name> | undefined,\n toolOutput: snap.toolOutput as ToolOutput<Name>,\n content: snap.content,\n meta: snap.meta,\n };\n }\n\n return {\n status: \"pending\",\n toolInput: snap.toolInput as DeepPartial<ToolInput<Name>> | undefined,\n toolOutput: undefined,\n content: undefined,\n meta: undefined,\n };\n}\n","import { useCallback, useRef, useState } from \"react\";\n\nimport type { ToolRef } from \"../../tools.js\";\nimport { useViewRuntime } from \"../runtime/view-runtime-context.js\";\nimport type { RegisteredTools } from \"../types/register.js\";\nimport {\n ToolError,\n type CallToolResult,\n type CallToolSuccess,\n} from \"../types/result-types.js\";\n\nexport type { CallToolSuccess } from \"../types/result-types.js\";\nexport { ToolError } from \"../types/result-types.js\";\n\n/**\n * Typed server-tool call handle returned by {@link useCallTool}.\n *\n * @typeParam Args - Tool argument object type.\n * @typeParam Result - Expected `structuredContent` type for a successful result.\n */\nexport interface CallToolHandle<Args, Result> {\n /**\n * Invoke the server tool over the bridge.\n *\n * Every non-error result resolves. `structuredContent` is guaranteed and\n * typed exactly when the tool declares an `outputSchema` — the server\n * rejects non-error results from schema-backed tools that lack it, so a\n * resolved result from a schema'd tool always carries it. Tools without an\n * `outputSchema` legitimately return content-only results.\n *\n * @param args - Tool arguments matching the registered input schema.\n * @returns Successful result ({@link CallToolSuccess}).\n * @throws {@link ToolError} when the tool answers with `isError: true`.\n * Transport, RPC, and missing-`serverTools` failures also reject with an\n * `Error`.\n */\n callTool: (args: Args) => Promise<CallToolSuccess<Result>>;\n /**\n * Last successful result only. Preserved while a later request is pending\n * or fails (tool error / transport).\n */\n data: CallToolSuccess<Result> | undefined;\n /**\n * Last failure ({@link ToolError} or transport/RPC/capability `Error`).\n * Cleared on the next call.\n */\n error: Error | undefined;\n /** Whether a call is in flight. */\n isPending: boolean;\n}\n\n/**\n * Call a registered server tool from the view with inferred types.\n *\n * Successful results populate `data` and clear `error`. Tool errors and\n * transport failures reject and populate `error` while preserving previous\n * `data`. Prefer reading `data` / `error` from the handle for React UI; use\n * try/catch for imperative flows.\n *\n * @example\n * ```tsx\n * const details = useCallTool(\"get-fruit-details\");\n *\n * // State-driven (typical in React):\n * // {details.error && <ErrorBanner message={details.error.message} />}\n * // {details.data && <DetailsCard data={details.data.structuredContent} />}\n *\n * // Imperative:\n * try {\n * const result = await details.callTool({ fruit: \"apple\" });\n * showDetails(result.structuredContent);\n * } catch (err) {\n * if (err instanceof ToolError) {\n * showToolError(err.message);\n * }\n * }\n * ```\n */\nexport function useCallTool<Name extends keyof RegisteredTools>(\n name: Name\n): CallToolHandle<\n RegisteredTools[Name][\"input\"],\n RegisteredTools[Name][\"output\"]\n>;\n\n/**\n * Call a server tool using a {@link ToolRef} value (inline-JSX stretch path).\n *\n * @typeParam R - Tool ref carrying name, input, and output types.\n */\n// eslint-disable-next-line no-redeclare -- overload set\nexport function useCallTool<R extends ToolRef<string, unknown, unknown>>(\n ref: R\n): CallToolHandle<\n R extends ToolRef<string, infer I, unknown> ? I : never,\n R extends ToolRef<string, unknown, infer O> ? O : never\n>;\n\n/**\n * Call a server tool with explicit argument/result types (escape hatch).\n *\n * @typeParam Args - Explicit argument object type.\n * @typeParam Result - Explicit `structuredContent` type.\n */\n// eslint-disable-next-line no-redeclare -- overload set\nexport function useCallTool<\n Args extends Record<string, unknown>,\n Result = unknown,\n>(name: string): CallToolHandle<Args, Result>;\n\n// eslint-disable-next-line no-redeclare -- implementation signature\nexport function useCallTool(\n nameOrRef: string | ToolRef<string, unknown, unknown>\n) {\n const toolName = typeof nameOrRef === \"string\" ? nameOrRef : nameOrRef.name;\n const runtime = useViewRuntime();\n const [data, setData] = useState<CallToolSuccess<unknown> | undefined>(\n undefined\n );\n const [error, setError] = useState<Error | undefined>(undefined);\n const [isPending, setIsPending] = useState(false);\n const callIdRef = useRef(0);\n\n const callTool = useCallback(\n async (\n args: Record<string, unknown>\n ): Promise<CallToolSuccess<unknown>> => {\n const callId = ++callIdRef.current;\n setIsPending(true);\n setError(undefined);\n\n try {\n const result = await runtime.callServerTool({\n name: toolName,\n arguments: args,\n });\n\n if (result.isError === true) {\n throw new ToolError(result as CallToolResult & { isError: true });\n }\n\n const typed = result as CallToolSuccess<unknown>;\n if (callId === callIdRef.current) {\n setData(typed);\n setIsPending(false);\n }\n return typed;\n } catch (err) {\n const failure = err instanceof Error ? err : new Error(String(err));\n if (callId === callIdRef.current) {\n setError(failure);\n setIsPending(false);\n }\n throw failure;\n }\n },\n [runtime, toolName]\n );\n\n return { callTool, data, error, isPending };\n}\n","import { useMemo, useSyncExternalStore } from \"react\";\n\nimport { useViewRuntime } from \"../runtime/view-runtime-context.js\";\nimport type { UseFilesResult } from \"../types/file-types.js\";\n\n/**\n * Upload and download files through ChatGPT's optional `window.openai`\n * extension.\n *\n * File handling is not part of the MCP Apps bridge. Always check\n * `isSupported` before calling either action; unsupported calls reject with a\n * descriptive error. The hook does not read or update ChatGPT widget state and\n * does not make uploaded files model-visible as a side effect.\n *\n * The returned actions are referentially stable for the lifetime of the\n * mounted runtime.\n *\n * @example\n * ```tsx\n * const { isSupported, upload, getDownloadUrl } = useFiles();\n *\n * if (!isSupported) return <p>File handling requires ChatGPT.</p>;\n *\n * const { fileId } = await upload(file);\n * const { downloadUrl } = await getDownloadUrl({ fileId });\n * ```\n */\nexport function useFiles(): UseFilesResult {\n const runtime = useViewRuntime();\n const { isSupported } = useSyncExternalStore(\n runtime.subscribeFiles,\n runtime.getFilesSnapshot\n );\n\n return useMemo(\n () => ({\n isSupported,\n upload: runtime.uploadFile,\n getDownloadUrl: runtime.getFileDownloadUrl,\n }),\n [runtime, isSupported]\n );\n}\n","import { useCallback } from \"react\";\n\nimport { useViewRuntime } from \"../runtime/view-runtime-context.js\";\n\n/**\n * Returns a callback that asks the host to open a URL outside the view.\n *\n * @remarks\n * Requires the host `openLinks` capability; otherwise the returned promise\n * rejects before any wire traffic. The host decides how (and whether) to open\n * the link — typically in the user's browser, often behind a confirmation\n * prompt — so treat it as a request, not a guaranteed navigation. Views run\n * sandboxed and cannot navigate the user themselves; this is the supported\n * way to link out.\n *\n * The returned callback is referentially stable for the lifetime of the\n * mounted runtime.\n *\n * @example\n * ```tsx\n * function DocsLink() {\n * const openExternal = useOpenExternal();\n * return (\n * <button\n * type=\"button\"\n * onClick={() => {\n * void openExternal({ url: \"https://example.com/docs\" });\n * }}\n * >\n * Open docs\n * </button>\n * );\n * }\n * ```\n */\nexport function useOpenExternal(): (args: { url: string }) => Promise<void> {\n const runtime = useViewRuntime();\n return useCallback(\n async (args: { url: string }) => {\n await runtime.openLink({ url: args.url });\n },\n [runtime]\n );\n}\n","import { useCallback } from \"react\";\n\nimport { useViewRuntime } from \"../runtime/view-runtime-context.js\";\n\n/**\n * Returns a callback that sends a follow-up message to the conversation,\n * triggering a model turn.\n *\n * @remarks\n * Requires the host `message` capability; otherwise the returned promise\n * rejects before any wire traffic. The prompt is delivered to the host as a\n * user-authored chat message, as if the user had typed it. The returned\n * promise resolves when the host accepts the message — not when the model\n * responds; any response arrives through the normal conversation flow (and, if\n * the model calls this view's tool again, through {@link useToolContext}).\n * Hosts may require user confirmation or decline the message entirely.\n *\n * The returned callback is referentially stable for the lifetime of the\n * mounted runtime.\n *\n * @example\n * ```tsx\n * function AskAgain() {\n * const sendFollowUp = useSendFollowUp();\n * return (\n * <button\n * type=\"button\"\n * onClick={() => sendFollowUp({ prompt: \"Show more results\" })}\n * >\n * Refine search\n * </button>\n * );\n * }\n * ```\n */\nexport function useSendFollowUp(): (args: { prompt: string }) => Promise<void> {\n const runtime = useViewRuntime();\n return useCallback(\n async (args: { prompt: string }) => {\n await runtime.sendMessage({\n role: \"user\",\n content: [{ type: \"text\", text: args.prompt }],\n });\n },\n [runtime]\n );\n}\n","import { useViewRuntime } from \"../runtime/view-runtime-context.js\";\n\n/**\n * Returns a callback that notifies the host of the view's size via\n * `ui/notifications/size-changed`.\n *\n * Pair with `viewConfig.autoResize: false` when the view's height derives from\n * its width (for example a fixed aspect-ratio container). Ext-apps auto-resize\n * measures the document under `height: max-content`, which collapses those\n * layouts; disable it and report `{ width, height }` from a `ResizeObserver`\n * (or equivalent) instead.\n *\n * Returns the runtime-owned `sendSizeChanged` method — referentially stable\n * for the lifetime of the mounted runtime.\n *\n * @example\n * ```tsx\n * import {\n * ThemeProvider,\n * useSendSizeChanged,\n * type ViewConfig,\n * } from \"mcp-use/react\";\n * import { useEffect, useRef } from \"react\";\n *\n * export const viewConfig = {\n * autoResize: false,\n * displayModes: [\"inline\", \"fullscreen\"],\n * } satisfies ViewConfig;\n *\n * export default function AspectRatioView() {\n * return (\n * <ThemeProvider>\n * <AspectRatioContent />\n * </ThemeProvider>\n * );\n * }\n *\n * function AspectRatioContent() {\n * const ref = useRef<HTMLDivElement>(null);\n * const sendSizeChanged = useSendSizeChanged();\n *\n * useEffect(() => {\n * const element = ref.current;\n * if (!element) return;\n *\n * const observer = new ResizeObserver(([entry]) => {\n * if (!entry) return;\n * const { width, height } = entry.contentRect;\n * void sendSizeChanged({ width, height });\n * });\n *\n * observer.observe(element);\n * return () => observer.disconnect();\n * }, [sendSizeChanged]);\n *\n * return <div ref={ref} style={{ width: \"100%\", aspectRatio: \"4 / 3\" }} />;\n * }\n * ```\n */\nexport function useSendSizeChanged(): (size: {\n width?: number;\n height?: number;\n}) => Promise<void> {\n const runtime = useViewRuntime();\n return runtime.sendSizeChanged;\n}\n","import { useSyncExternalStore } from \"react\";\n\nimport { useViewRuntime } from \"../runtime/view-runtime-context.js\";\n\n/**\n * Subscribe to the host color theme only.\n *\n * @remarks\n * Returns the same value as {@link useHostContext}'s `theme` and updates live\n * when the user or host switches themes. Prefer this hook when theme is all a\n * component needs: it re-renders only when the resolved theme string changes,\n * never on locale, dimensions, display mode, or tool updates. Returns\n * `\"light\"` until the host reports a theme.\n *\n * @example\n * ```tsx\n * const theme = useViewTheme();\n * ```\n */\nexport function useViewTheme(): \"light\" | \"dark\" {\n const runtime = useViewRuntime();\n return useSyncExternalStore(runtime.subscribeTheme, runtime.getThemeSnapshot);\n}\n","import type {\n InputRequiredResult,\n ToolAnnotations,\n} from \"@modelcontextprotocol/server\";\nimport { useEffect, useRef } from \"react\";\n\nimport type {\n InferToolInput,\n InferToolOutput,\n ToolDefinition,\n ToolResult,\n} from \"../../tools.js\";\nimport { resolveToolInputSchema } from \"../../tools.js\";\nimport { useViewRuntime } from \"../runtime/view-runtime-context.js\";\nimport type { McpAppRuntime } from \"../runtime/view-runtime.js\";\n\n/** View-tool definition — mirrors {@link ToolDefinition} plus `enabled`. */\nexport type ViewToolDefinition = Pick<\n ToolDefinition,\n | \"name\"\n | \"title\"\n | \"description\"\n | \"inputSchema\"\n | \"schema\"\n | \"outputSchema\"\n | \"annotations\"\n> & {\n /** When `false`, the tool stays registered but is not listed or callable. */\n enabled?: boolean;\n};\n\n/** Handle returned by {@link McpAppRuntime.registerViewTool}. */\ntype RegisteredViewTool = ReturnType<McpAppRuntime[\"registerViewTool\"]>;\n\n/**\n * Register an ephemeral tool the host/model can call while this component is mounted.\n *\n * Registration is synchronous against the runtime-owned App and independent\n * of connection completion. It is keyed by `name` only (`[runtime, name]`):\n * the tool registers once per mounted name and is removed on unmount. Changing\n * `inputSchema` / `outputSchema` without changing `name` does **not**\n * re-register — schemas are captured at registration time (ext-apps fixes\n * handler arity at registration); to change a tool's schema, register it under\n * a new name. `schema` is accepted as an alias for `inputSchema`.\n *\n * `title`, `description`, and `annotations` changes are applied in place via\n * the ext-apps handle's `update()`, passing explicit `undefined` so omitted\n * fields are cleared. Toggling `enabled` calls `enable()` / `disable()`\n * without re-registering. The handler is kept in a ref so calls always see\n * current React state. Registration goes through\n * {@link McpAppRuntime.registerViewTool} (never `app.registerTool` directly)\n * so the runtime can perform the empty-handler handoff on first registration.\n *\n * Cleanup captures the registration handle inside the effect so an older\n * cleanup cannot remove a newer registration (e.g. after a rapid `name`\n * change). Registration failures are reported with `console.error` and do not\n * leave half-registered state.\n *\n * @example\n * ```tsx\n * useViewTool(\n * { name: \"highlight-fruit\", inputSchema: z.object({ id: z.string() }) },\n * async ({ id }) => {\n * setSelected(id);\n * return { content: [{ type: \"text\", text: `Highlighted ${id}` }] };\n * }\n * );\n * ```\n */\nexport function useViewTool<\n const TDef extends ViewToolDefinition,\n TInput = InferToolInput<TDef>,\n TOutput = InferToolOutput<TDef>,\n>(\n definition: TDef,\n handler: (\n args: TInput\n ) =>\n | Exclude<ToolResult<TOutput>, InputRequiredResult>\n | Promise<Exclude<ToolResult<TOutput>, InputRequiredResult>>\n): void {\n const runtime = useViewRuntime();\n const handlerRef = useRef(handler);\n handlerRef.current = handler;\n const definitionRef = useRef<ViewToolDefinition>(definition);\n definitionRef.current = definition;\n // Shared only for post-registration metadata / enabled updates. Cleanup\n // never removes through this ref alone — each registering effect removes\n // only the handle it captured locally.\n const registeredRef = useRef<RegisteredViewTool | null>(null);\n const registeredMetadataRef = useRef<{\n registration: RegisteredViewTool;\n title: string | undefined;\n description: string | undefined;\n annotationsJson: string | undefined;\n } | null>(null);\n\n const { name, title, description, enabled = true } = definition;\n // Annotations are plain JSON data (MCP wire shape); serialize for change\n // detection so inline literals don't retrigger effects by identity.\n const annotationsJson =\n definition.annotations === undefined\n ? undefined\n : JSON.stringify(definition.annotations);\n\n useEffect(() => {\n const def = definitionRef.current;\n const config: {\n title?: string;\n description?: string;\n inputSchema?: NonNullable<ViewToolDefinition[\"inputSchema\"]>;\n outputSchema?: NonNullable<ViewToolDefinition[\"outputSchema\"]>;\n annotations?: ToolAnnotations;\n } = {};\n\n if (def.title !== undefined) config.title = def.title;\n if (def.description !== undefined) config.description = def.description;\n const inputSchema = resolveToolInputSchema(def);\n if (inputSchema !== undefined) config.inputSchema = inputSchema;\n if (def.outputSchema !== undefined) {\n config.outputSchema = def.outputSchema;\n }\n if (def.annotations !== undefined) {\n config.annotations = def.annotations;\n }\n\n // ext-apps fixes callback arity at registration: schema-backed tools call\n // `(parsedArgs, extra)`, while schema-less tools call `(extra)`. Adapt the\n // latter so the public handler receives an empty input object rather than\n // RequestHandlerExtra. Validation remains entirely owned by ext-apps.\n const callback =\n inputSchema !== undefined\n ? async (args: unknown) => handlerRef.current(args as TInput)\n : async (_extra: unknown) => handlerRef.current({} as TInput);\n\n let registration: RegisteredViewTool;\n try {\n registration = runtime.registerViewTool(name, config, callback);\n } catch (error: unknown) {\n console.error(\n `[mcp-use] useViewTool failed to register tool \"${name}\":`,\n error\n );\n return;\n }\n\n registeredRef.current = registration;\n registeredMetadataRef.current = {\n registration,\n title: def.title,\n description: def.description,\n annotationsJson:\n def.annotations === undefined\n ? undefined\n : JSON.stringify(def.annotations),\n };\n\n if (def.enabled === false) {\n registration.disable();\n }\n\n return () => {\n if (registeredRef.current === registration) {\n registeredRef.current = null;\n }\n if (registeredMetadataRef.current?.registration === registration) {\n registeredMetadataRef.current = null;\n }\n try {\n registration.remove();\n } catch {\n // App may already be closing during disposal. Swallow quietly.\n }\n };\n }, [runtime, name]);\n\n useEffect(() => {\n const registered = registeredRef.current;\n // Pre-registration changes are picked up from definitionRef at\n // registration time; this effect only applies post-registration edits.\n if (!registered) return;\n const applied = registeredMetadataRef.current;\n if (\n applied?.registration === registered &&\n applied.title === title &&\n applied.description === description &&\n applied.annotationsJson === annotationsJson\n ) {\n return;\n }\n const def = definitionRef.current;\n // Pass explicit undefined so Object.assign clears previously set fields.\n // Cast: exactOptionalPropertyTypes rejects `string | undefined` on\n // Partial<{ title?: string }>, but ext-apps' update uses Object.assign\n // and listing omits falsy/undefined metadata — explicit undefined is\n // required to clear.\n registered.update({\n title: def.title,\n description: def.description,\n annotations: def.annotations,\n } as Parameters<RegisteredViewTool[\"update\"]>[0]);\n registeredMetadataRef.current = {\n registration: registered,\n title: def.title,\n description: def.description,\n annotationsJson:\n def.annotations === undefined\n ? undefined\n : JSON.stringify(def.annotations),\n };\n }, [title, description, annotationsJson]);\n\n useEffect(() => {\n const registered = registeredRef.current;\n if (!registered || registered.enabled === enabled) return;\n if (enabled) {\n registered.enable();\n } else {\n registered.disable();\n }\n }, [enabled]);\n}\n","import type {\n CallToolResult,\n InputRequiredResult,\n MetaObject,\n StandardSchemaWithJSON,\n ToolAnnotations,\n} from \"@modelcontextprotocol/server\";\n\nimport type { McpUiResourceCsp } from \"@modelcontextprotocol/ext-apps\";\n\nimport type { RequestContext } from \"./context.js\";\nimport type { UiPermissions } from \"./views/types.js\";\n\n/**\n * Binds a tool to a view directory for MCP Apps rendering.\n *\n * A view may have at most one bound tool. That tool owns the resource facts\n * (`description`, `csp`, `permissions`, `domain`, `prefersBorder`); a second\n * tool that names the same view is rejected. The view file exports the\n * component, while the framework emits these fields on the view's MCP\n * resource, where hosts read `_meta.ui`.\n */\nexport interface ToolViewConfig {\n /** View directory / registry name, e.g. `\"product-search-result\"`. */\n name: string;\n /**\n * Human-readable description of the view resource → the resource's\n * `description` on `resources/list` and `resources/read`.\n */\n description?: string;\n /**\n * CSP domains the host must allow → resource `_meta.ui.csp`. The framework\n * appends the server origin to `connectDomains` and the configured assets\n * origin (or server origin) to `resourceDomains` at emission time. Other\n * author-set fields (`frameDomains`, `baseUriDomains`, …) pass through.\n */\n csp?: McpUiResourceCsp;\n /** Sandbox permissions the view needs → resource `_meta.ui.permissions`. */\n permissions?: UiPermissions;\n /**\n * Dedicated origin hint for hosts that render views on a separate domain →\n * resource `_meta.ui.domain`.\n */\n domain?: string;\n /**\n * Ask the host to draw a border around the view → resource\n * `_meta.ui.prefersBorder`.\n */\n prefersBorder?: boolean;\n}\n\n/** Declares a tool's identity, LLM-facing description, and schemas. First argument to {@link MCPServer.tool}. */\nexport interface ToolDefinition {\n /** Unique tool identifier, e.g. `\"fetch-weather\"`. */\n name: string;\n /** Human-readable title shown in UIs (falls back to `name`). */\n title?: string;\n /** LLM-facing description of what the tool does. */\n description?: string;\n /**\n * Object schema for input validation — any Standard Schema library with\n * JSON Schema conversion ({@link StandardSchemaWithJSON}): zod v4, ArkType,\n * Valibot, …. Field descriptions become LLM hints. Input is validated by\n * the SDK before the callback runs. Emitted on the wire as `inputSchema`.\n */\n inputSchema?: StandardSchemaWithJSON;\n /**\n * Alias for {@link ToolDefinition.inputSchema}. Prefer `inputSchema` in new\n * code — it matches the MCP wire field name.\n */\n schema?: StandardSchemaWithJSON;\n /**\n * Schema for structured output ({@link StandardSchemaWithJSON}). Any JSON\n * root is allowed — object, array, or primitive (2026-07-28 protocol).\n * When set, the callback must return a result carrying matching\n * `structuredContent` or an explicit `isError` result — enforced at\n * compile time and validated by the SDK at runtime.\n */\n outputSchema?: StandardSchemaWithJSON;\n /** Behavioral hints for clients (readOnlyHint, destructiveHint, …). */\n annotations?: ToolAnnotations;\n /**\n * Extension metadata advertised on this tool's `tools/list` descriptor.\n *\n * Use vendor-namespaced keys for custom data. This definition metadata is\n * distinct from a tool callback result's `_meta`: it describes the tool,\n * while result `_meta` belongs to one invocation. For view-bound or\n * visibility-restricted tools, framework-owned MCP Apps keys are derived\n * from {@link ToolDefinition.view} and {@link ToolDefinition.visibility};\n * those derived values take precedence over colliding entries here.\n */\n _meta?: MetaObject;\n /**\n * Declares who may call or see the tool. Emitted as `_meta.ui.visibility`\n * on `tools/list`. Omitted = host default (callable by the model, visible\n * to the app). The server always lists every registered tool — hosts\n * filter by this declaration; the server never omits tools from\n * `tools/list`. `\"app\"` marks app-private helper tools callable from\n * views via `useCallTool` while the host hides them from the model.\n */\n visibility?: \"model\" | \"app\";\n /**\n * Bind this tool to a view for MCP Apps rendering. Requires\n * {@link ToolDefinition.outputSchema} — the view reads the result's\n * `structuredContent` typed by this schema.\n */\n view?: ToolViewConfig;\n}\n\n/**\n * Handle returned by {@link MCPServer.tool} — carries the tool name at runtime\n * and phantom input/output types for inference (e.g. `Register` / `useCallTool`).\n */\nexport interface ToolRef<\n Name extends string = string,\n Input = Record<string, unknown>,\n Output = never,\n> {\n /** The tool's registered name. */\n readonly name: Name;\n /**\n * Phantom carrier for the tool's inferred input/output types. Never set at\n * runtime.\n *\n * @internal\n */\n readonly \"~types\"?: { input: Input; output: Output };\n}\n\n/**\n * Result a tool callback may return, keyed by the tool's inferred output\n * type. Completed calls use the SDK's raw {@link CallToolResult}; interactive\n * calls may return an {@link InputRequiredResult}. There is no\n * framework-specific result layer.\n *\n * Without an `outputSchema` (`TOutput = never`) any `CallToolResult` is\n * accepted. With one, the result must carry `structuredContent` matching the\n * schema or set `isError: true` — mirroring the SDK's runtime rule, which\n * rejects results from schema'd tools that carry no structured content\n * unless `isError` is set.\n *\n * The SDK auto-appends a JSON text block when `structuredContent` is a\n * non-object value and no `type: \"text\"` block is present; for object-shaped\n * payloads include the text serialization yourself:\n *\n * ```ts\n * return {\n * content: [{ type: \"text\", text: JSON.stringify(data) }],\n * structuredContent: data,\n * };\n * ```\n */\nexport type ToolResult<TOutput = never> =\n | InputRequiredResult\n | ([TOutput] extends [never]\n ? CallToolResult\n :\n | (CallToolResult & { structuredContent: TOutput })\n | (CallToolResult & { isError: true }));\n\n/** Infer the callback params type from a tool definition's input schema. */\nexport type InferToolInput<T> = T extends {\n inputSchema: infer S extends StandardSchemaWithJSON;\n}\n ? StandardSchemaWithJSON.InferOutput<S> extends Record<string, unknown>\n ? StandardSchemaWithJSON.InferOutput<S>\n : Record<string, unknown>\n : T extends {\n schema: infer S extends StandardSchemaWithJSON;\n }\n ? StandardSchemaWithJSON.InferOutput<S> extends Record<string, unknown>\n ? StandardSchemaWithJSON.InferOutput<S>\n : Record<string, unknown>\n : Record<string, unknown>;\n\n/**\n * Resolve a tool definition's input schema. `inputSchema` wins when both are\n * set.\n *\n * @internal\n */\nexport function resolveToolInputSchema(\n definition: Pick<ToolDefinition, \"inputSchema\" | \"schema\">\n): StandardSchemaWithJSON | undefined {\n return definition.inputSchema ?? definition.schema;\n}\n\n/**\n * Infer the structured output type from a definition's `outputSchema` —\n * any JSON root, not just objects (2026-07-28 protocol); `never` when the\n * definition declares none (any {@link CallToolResult} is then accepted —\n * see {@link ToolResult}).\n */\nexport type InferToolOutput<T> = T extends {\n outputSchema: infer S extends StandardSchemaWithJSON;\n}\n ? StandardSchemaWithJSON.InferOutput<S>\n : never;\n\n/** Infer the literal tool name from a definition's `name` field. */\nexport type InferToolName<T> = T extends { name: infer N extends string }\n ? N\n : string;\n\n/**\n * Tool execution callback. The return type is {@link ToolResult}: tools with\n * an `outputSchema` must return matching `structuredContent` or an `isError`\n * result; tools without one accept any {@link CallToolResult}.\n */\nexport type ToolCallback<\n TInput = Record<string, unknown>,\n TOutput = never,\n TUser = never,\n HasOAuth extends boolean = false,\n> = (\n params: TInput,\n ctx: RequestContext<TUser, HasOAuth>\n) => ToolResult<TOutput> | Promise<ToolResult<TOutput>>;\n"],"mappings":";AAAA,SAAS,kBAA6B;;;ACAtC,OAAO,WAAW;AAyCV,SASE,KATF;AA3BD,IAAM,gBAAN,cAA4B,MAAM,UAGvC;AAAA,EACA,YAAY,OAA2B;AACrC,UAAM,KAAK;AACX,SAAK,QAAQ,EAAE,UAAU,OAAO,OAAO,KAAK;AAAA,EAC9C;AAAA,EAEA,OAAO,yBAAyB,OAAc;AAC5C,WAAO,EAAE,UAAU,MAAM,MAAM;AAAA,EACjC;AAAA,EAES,kBAAkB,OAAc,WAA4B;AACnE,YAAQ,MAAM,yBAAyB,OAAO,SAAS;AACvD,SAAK,MAAM,UAAU,OAAO,SAAS;AAAA,EACvC;AAAA,EAES,SAAS;AAChB,QAAI,KAAK,MAAM,YAAY,KAAK,MAAM,OAAO;AAC3C,UAAI,KAAK,MAAM,aAAa,QAAW;AACrC,eAAO,OAAO,KAAK,MAAM,aAAa,aAClC,KAAK,MAAM,SAAS,KAAK,MAAM,KAAK,IACpC,KAAK,MAAM;AAAA,MACjB;AAEA,aACE;AAAA,QAAC;AAAA;AAAA,UACC,OAAO;AAAA,YACL,SAAS;AAAA,YACT,QAAQ;AAAA,YACR,cAAc;AAAA,YACd,YAAY;AAAA,YACZ,OAAO;AAAA,UACT;AAAA,UAEA;AAAA,gCA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AEA,WAAO,MAAM;AACX,UAAI,cAAc,YAAY,cAAc;AAC1C,sBAAc,UAAU;AAAA,MAC1B;AACA,UAAI,sBAAsB,SAAS,iBAAiB,cAAc;AAChE,8BAAsB,UAAU;AAAA,MAClC;AACA,UAAI;AACF,qBAAa,OAAO;AAAA,MACtB,QAAQ;AAAA,MAER;AAAA,IACF;AAAA,EACF,GAAG,CAAC,SAAS,IAAI,CAAC;AAElB,EAAAA,WAAU,MAAM;AACd,UAAM,aAAa,cAAc;AAGjC,QAAI,CAAC,WAAY;AACjB,UAAM,UAAU,sBAAsB;AACtC,QACE,SAAS,iBAAiB,cAC1B,QAAQ,UAAU,SAClB,QAAQ,gBAAgB,eACxB,QAAQ,oBAAoB,iBAC5B;AACA;AAAA,IACF;AACA,UAAM,MAAM,cAAc;AAM1B,eAAW,OAAO;AAAA,MAChB,OAAO,IAAI;AAAA,MACX,aAAa,IAAI;AAAA,MACjB,aAAa,IAAI;AAAA,IACnB,CAAgD;AAChD,0BAAsB,UAAU;AAAA,MAC9B,cAAc;AAAA,MACd,OAAO,IAAI;AAAA,MACX,aAAa,IAAI;AAAA,MACjB,iBACE,IAAI,gBAAgB,SAChB,SACA,KAAK,UAAU,IAAI,WAAW;AAAA,IACtC;AAAA,EACF,GAAG,CAAC,OAAO,aAAa,eAAe,CAAC;AAExC,EAAAA,WAAU,MAAM;AACd,UAAM,aAAa,cAAc;AACjC,QAAI,CAAC,cAAc,WAAW,YAAY,QAAS;AACnD,QAAI,SAAS;AACX,iBAAW,OAAO;AAAA,IACpB,OAAO;AACL,iBAAW,QAAQ;AAAA,IACrB;AAAA,EACF,GAAG,CAAC,OAAO,CAAC;AACd;","names":["jsx","app","jsx","jsx","createContext","useContext","jsx","createContext","useContext","React","jsx","React","useState","useSyncExternalStore","useSyncExternalStore","useSyncExternalStore","resolveDisplayMode","useSyncExternalStore","useSyncExternalStore","useSyncExternalStore","Fragment","jsx","jsxs","useState","useRef","useState","useState","useRef","useSyncExternalStore","useSyncExternalStore","useCallback","useCallback","useCallback","useCallback","useSyncExternalStore","useSyncExternalStore","useEffect","useRef","useRef","useEffect"]}