@frontmcp/ui 0.6.0 → 0.6.1

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 (445) hide show
  1. package/README.md +140 -362
  2. package/bridge/runtime/index.d.ts +2 -1
  3. package/bridge/runtime/index.d.ts.map +1 -1
  4. package/bundler/file-cache/component-builder.d.ts +1 -1
  5. package/bundler/file-cache/component-builder.d.ts.map +1 -1
  6. package/bundler/file-cache/hash-calculator.d.ts +1 -1
  7. package/bundler/file-cache/hash-calculator.d.ts.map +1 -1
  8. package/bundler/file-cache/storage/filesystem.d.ts +1 -1
  9. package/bundler/file-cache/storage/filesystem.d.ts.map +1 -1
  10. package/bundler/file-cache/storage/interface.d.ts +1 -1
  11. package/bundler/file-cache/storage/interface.d.ts.map +1 -1
  12. package/bundler/file-cache/storage/redis.d.ts +1 -1
  13. package/bundler/file-cache/storage/redis.d.ts.map +1 -1
  14. package/bundler/index.js +10 -1057
  15. package/components/alert.schema.d.ts +6 -6
  16. package/components/avatar.schema.d.ts +9 -9
  17. package/components/badge.schema.d.ts +9 -9
  18. package/components/button.schema.d.ts +9 -9
  19. package/components/card.schema.d.ts +7 -7
  20. package/components/form.schema.d.ts +24 -24
  21. package/components/index.js +128 -198
  22. package/components/modal.schema.d.ts +8 -8
  23. package/components/table.schema.d.ts +6 -6
  24. package/esm/bridge/runtime/index.d.ts +2 -1
  25. package/esm/bridge/runtime/index.d.ts.map +1 -1
  26. package/esm/bundler/file-cache/component-builder.d.ts +1 -1
  27. package/esm/bundler/file-cache/component-builder.d.ts.map +1 -1
  28. package/esm/bundler/file-cache/hash-calculator.d.ts +1 -1
  29. package/esm/bundler/file-cache/hash-calculator.d.ts.map +1 -1
  30. package/esm/bundler/file-cache/storage/filesystem.d.ts +1 -1
  31. package/esm/bundler/file-cache/storage/filesystem.d.ts.map +1 -1
  32. package/esm/bundler/file-cache/storage/interface.d.ts +1 -1
  33. package/esm/bundler/file-cache/storage/interface.d.ts.map +1 -1
  34. package/esm/bundler/file-cache/storage/redis.d.ts +1 -1
  35. package/esm/bundler/file-cache/storage/redis.d.ts.map +1 -1
  36. package/esm/bundler/index.js +3 -1050
  37. package/esm/components/alert.schema.d.ts +6 -6
  38. package/esm/components/avatar.schema.d.ts +9 -9
  39. package/esm/components/badge.schema.d.ts +9 -9
  40. package/esm/components/button.schema.d.ts +9 -9
  41. package/esm/components/card.schema.d.ts +7 -7
  42. package/esm/components/form.schema.d.ts +24 -24
  43. package/esm/components/index.js +136 -196
  44. package/esm/components/modal.schema.d.ts +8 -8
  45. package/esm/components/table.schema.d.ts +6 -6
  46. package/esm/index.d.ts +23 -39
  47. package/esm/index.d.ts.map +1 -1
  48. package/esm/index.js +4256 -16441
  49. package/esm/layouts/base.d.ts +2 -2
  50. package/esm/layouts/base.d.ts.map +1 -1
  51. package/esm/layouts/index.js +33 -516
  52. package/esm/package.json +8 -26
  53. package/esm/pages/index.js +100 -627
  54. package/esm/react/Alert.d.ts +1 -2
  55. package/esm/react/Alert.d.ts.map +1 -1
  56. package/esm/react/Badge.d.ts +1 -2
  57. package/esm/react/Badge.d.ts.map +1 -1
  58. package/esm/react/Button.d.ts +1 -2
  59. package/esm/react/Button.d.ts.map +1 -1
  60. package/esm/react/Card.d.ts +1 -2
  61. package/esm/react/Card.d.ts.map +1 -1
  62. package/esm/react/hooks/context.d.ts +1 -1
  63. package/esm/react/hooks/context.d.ts.map +1 -1
  64. package/esm/react/index.d.ts +5 -6
  65. package/esm/react/index.d.ts.map +1 -1
  66. package/esm/react/index.js +2074 -322
  67. package/esm/react/types.d.ts +1 -2
  68. package/esm/react/types.d.ts.map +1 -1
  69. package/esm/renderers/index.d.ts +10 -25
  70. package/esm/renderers/index.d.ts.map +1 -1
  71. package/esm/renderers/index.js +171 -1617
  72. package/esm/{runtime/adapters → renderers}/react.adapter.d.ts +2 -2
  73. package/esm/renderers/react.adapter.d.ts.map +1 -0
  74. package/esm/renderers/react.renderer.d.ts +3 -3
  75. package/esm/renderers/react.renderer.d.ts.map +1 -1
  76. package/esm/universal/index.js +1755 -0
  77. package/esm/web-components/index.js +232 -287
  78. package/esm/widgets/index.js +89 -147
  79. package/index.d.ts +23 -39
  80. package/index.d.ts.map +1 -1
  81. package/index.js +6123 -18539
  82. package/layouts/base.d.ts +2 -2
  83. package/layouts/base.d.ts.map +1 -1
  84. package/layouts/index.js +43 -536
  85. package/package.json +8 -26
  86. package/pages/index.js +111 -648
  87. package/react/Alert.d.ts +1 -2
  88. package/react/Alert.d.ts.map +1 -1
  89. package/react/Badge.d.ts +1 -2
  90. package/react/Badge.d.ts.map +1 -1
  91. package/react/Button.d.ts +1 -2
  92. package/react/Button.d.ts.map +1 -1
  93. package/react/Card.d.ts +1 -2
  94. package/react/Card.d.ts.map +1 -1
  95. package/react/hooks/context.d.ts +1 -1
  96. package/react/hooks/context.d.ts.map +1 -1
  97. package/react/index.d.ts +5 -6
  98. package/react/index.d.ts.map +1 -1
  99. package/react/index.js +2065 -335
  100. package/react/types.d.ts +1 -2
  101. package/react/types.d.ts.map +1 -1
  102. package/renderers/index.d.ts +10 -25
  103. package/renderers/index.d.ts.map +1 -1
  104. package/renderers/index.js +175 -1641
  105. package/{runtime/adapters → renderers}/react.adapter.d.ts +2 -2
  106. package/renderers/react.adapter.d.ts.map +1 -0
  107. package/renderers/react.renderer.d.ts +3 -3
  108. package/renderers/react.renderer.d.ts.map +1 -1
  109. package/universal/index.js +1841 -0
  110. package/web-components/index.js +224 -289
  111. package/widgets/index.js +80 -148
  112. package/adapters/index.d.ts +0 -13
  113. package/adapters/index.d.ts.map +0 -1
  114. package/adapters/index.js +0 -462
  115. package/adapters/platform-meta.d.ts +0 -166
  116. package/adapters/platform-meta.d.ts.map +0 -1
  117. package/adapters/response-builder.d.ts +0 -108
  118. package/adapters/response-builder.d.ts.map +0 -1
  119. package/adapters/serving-mode.d.ts +0 -107
  120. package/adapters/serving-mode.d.ts.map +0 -1
  121. package/base-template/bridge.d.ts +0 -90
  122. package/base-template/bridge.d.ts.map +0 -1
  123. package/base-template/default-base-template.d.ts +0 -92
  124. package/base-template/default-base-template.d.ts.map +0 -1
  125. package/base-template/index.d.ts +0 -15
  126. package/base-template/index.d.ts.map +0 -1
  127. package/base-template/index.js +0 -1398
  128. package/base-template/polyfills.d.ts +0 -31
  129. package/base-template/polyfills.d.ts.map +0 -1
  130. package/base-template/theme-styles.d.ts +0 -74
  131. package/base-template/theme-styles.d.ts.map +0 -1
  132. package/build/cdn-resources.d.ts +0 -243
  133. package/build/cdn-resources.d.ts.map +0 -1
  134. package/build/index.d.ts +0 -295
  135. package/build/index.d.ts.map +0 -1
  136. package/build/index.js +0 -7096
  137. package/build/widget-manifest.d.ts +0 -362
  138. package/build/widget-manifest.d.ts.map +0 -1
  139. package/dependency/cdn-registry.d.ts +0 -98
  140. package/dependency/cdn-registry.d.ts.map +0 -1
  141. package/dependency/import-map.d.ts +0 -186
  142. package/dependency/import-map.d.ts.map +0 -1
  143. package/dependency/import-parser.d.ts +0 -82
  144. package/dependency/import-parser.d.ts.map +0 -1
  145. package/dependency/index.d.ts +0 -17
  146. package/dependency/index.d.ts.map +0 -1
  147. package/dependency/resolver.d.ts +0 -164
  148. package/dependency/resolver.d.ts.map +0 -1
  149. package/dependency/schemas.d.ts +0 -486
  150. package/dependency/schemas.d.ts.map +0 -1
  151. package/dependency/template-loader.d.ts +0 -204
  152. package/dependency/template-loader.d.ts.map +0 -1
  153. package/dependency/template-processor.d.ts +0 -118
  154. package/dependency/template-processor.d.ts.map +0 -1
  155. package/dependency/types.d.ts +0 -739
  156. package/dependency/types.d.ts.map +0 -1
  157. package/esm/adapters/index.d.ts +0 -13
  158. package/esm/adapters/index.d.ts.map +0 -1
  159. package/esm/adapters/index.js +0 -427
  160. package/esm/adapters/platform-meta.d.ts +0 -166
  161. package/esm/adapters/platform-meta.d.ts.map +0 -1
  162. package/esm/adapters/response-builder.d.ts +0 -108
  163. package/esm/adapters/response-builder.d.ts.map +0 -1
  164. package/esm/adapters/serving-mode.d.ts +0 -107
  165. package/esm/adapters/serving-mode.d.ts.map +0 -1
  166. package/esm/base-template/bridge.d.ts +0 -90
  167. package/esm/base-template/bridge.d.ts.map +0 -1
  168. package/esm/base-template/default-base-template.d.ts +0 -92
  169. package/esm/base-template/default-base-template.d.ts.map +0 -1
  170. package/esm/base-template/index.d.ts +0 -15
  171. package/esm/base-template/index.d.ts.map +0 -1
  172. package/esm/base-template/index.js +0 -1364
  173. package/esm/base-template/polyfills.d.ts +0 -31
  174. package/esm/base-template/polyfills.d.ts.map +0 -1
  175. package/esm/base-template/theme-styles.d.ts +0 -74
  176. package/esm/base-template/theme-styles.d.ts.map +0 -1
  177. package/esm/build/cdn-resources.d.ts +0 -243
  178. package/esm/build/cdn-resources.d.ts.map +0 -1
  179. package/esm/build/index.d.ts +0 -295
  180. package/esm/build/index.d.ts.map +0 -1
  181. package/esm/build/index.js +0 -7021
  182. package/esm/build/widget-manifest.d.ts +0 -362
  183. package/esm/build/widget-manifest.d.ts.map +0 -1
  184. package/esm/dependency/cdn-registry.d.ts +0 -98
  185. package/esm/dependency/cdn-registry.d.ts.map +0 -1
  186. package/esm/dependency/import-map.d.ts +0 -186
  187. package/esm/dependency/import-map.d.ts.map +0 -1
  188. package/esm/dependency/import-parser.d.ts +0 -82
  189. package/esm/dependency/import-parser.d.ts.map +0 -1
  190. package/esm/dependency/index.d.ts +0 -17
  191. package/esm/dependency/index.d.ts.map +0 -1
  192. package/esm/dependency/resolver.d.ts +0 -164
  193. package/esm/dependency/resolver.d.ts.map +0 -1
  194. package/esm/dependency/schemas.d.ts +0 -486
  195. package/esm/dependency/schemas.d.ts.map +0 -1
  196. package/esm/dependency/template-loader.d.ts +0 -204
  197. package/esm/dependency/template-loader.d.ts.map +0 -1
  198. package/esm/dependency/template-processor.d.ts +0 -118
  199. package/esm/dependency/template-processor.d.ts.map +0 -1
  200. package/esm/dependency/types.d.ts +0 -739
  201. package/esm/dependency/types.d.ts.map +0 -1
  202. package/esm/handlebars/expression-extractor.d.ts +0 -147
  203. package/esm/handlebars/expression-extractor.d.ts.map +0 -1
  204. package/esm/handlebars/helpers.d.ts +0 -339
  205. package/esm/handlebars/helpers.d.ts.map +0 -1
  206. package/esm/handlebars/index.d.ts +0 -195
  207. package/esm/handlebars/index.d.ts.map +0 -1
  208. package/esm/handlebars/index.js +0 -587
  209. package/esm/registry/index.d.ts +0 -46
  210. package/esm/registry/index.d.ts.map +0 -1
  211. package/esm/registry/index.js +0 -6422
  212. package/esm/registry/render-template.d.ts +0 -91
  213. package/esm/registry/render-template.d.ts.map +0 -1
  214. package/esm/registry/tool-ui.registry.d.ts +0 -294
  215. package/esm/registry/tool-ui.registry.d.ts.map +0 -1
  216. package/esm/registry/uri-utils.d.ts +0 -56
  217. package/esm/registry/uri-utils.d.ts.map +0 -1
  218. package/esm/renderers/cache.d.ts +0 -145
  219. package/esm/renderers/cache.d.ts.map +0 -1
  220. package/esm/renderers/html.renderer.d.ts +0 -123
  221. package/esm/renderers/html.renderer.d.ts.map +0 -1
  222. package/esm/renderers/mdx.renderer.d.ts +0 -120
  223. package/esm/renderers/mdx.renderer.d.ts.map +0 -1
  224. package/esm/renderers/registry.d.ts +0 -134
  225. package/esm/renderers/registry.d.ts.map +0 -1
  226. package/esm/renderers/types.d.ts +0 -342
  227. package/esm/renderers/types.d.ts.map +0 -1
  228. package/esm/renderers/utils/detect.d.ts +0 -107
  229. package/esm/renderers/utils/detect.d.ts.map +0 -1
  230. package/esm/renderers/utils/hash.d.ts +0 -40
  231. package/esm/renderers/utils/hash.d.ts.map +0 -1
  232. package/esm/renderers/utils/index.d.ts +0 -9
  233. package/esm/renderers/utils/index.d.ts.map +0 -1
  234. package/esm/renderers/utils/transpiler.d.ts +0 -89
  235. package/esm/renderers/utils/transpiler.d.ts.map +0 -1
  236. package/esm/runtime/adapters/html.adapter.d.ts +0 -59
  237. package/esm/runtime/adapters/html.adapter.d.ts.map +0 -1
  238. package/esm/runtime/adapters/index.d.ts +0 -26
  239. package/esm/runtime/adapters/index.d.ts.map +0 -1
  240. package/esm/runtime/adapters/mdx.adapter.d.ts +0 -73
  241. package/esm/runtime/adapters/mdx.adapter.d.ts.map +0 -1
  242. package/esm/runtime/adapters/react.adapter.d.ts.map +0 -1
  243. package/esm/runtime/adapters/types.d.ts +0 -95
  244. package/esm/runtime/adapters/types.d.ts.map +0 -1
  245. package/esm/runtime/csp.d.ts +0 -48
  246. package/esm/runtime/csp.d.ts.map +0 -1
  247. package/esm/runtime/index.d.ts +0 -17
  248. package/esm/runtime/index.d.ts.map +0 -1
  249. package/esm/runtime/index.js +0 -5186
  250. package/esm/runtime/mcp-bridge.d.ts +0 -101
  251. package/esm/runtime/mcp-bridge.d.ts.map +0 -1
  252. package/esm/runtime/renderer-runtime.d.ts +0 -133
  253. package/esm/runtime/renderer-runtime.d.ts.map +0 -1
  254. package/esm/runtime/sanitizer.d.ts +0 -172
  255. package/esm/runtime/sanitizer.d.ts.map +0 -1
  256. package/esm/runtime/types.d.ts +0 -415
  257. package/esm/runtime/types.d.ts.map +0 -1
  258. package/esm/runtime/wrapper.d.ts +0 -421
  259. package/esm/runtime/wrapper.d.ts.map +0 -1
  260. package/esm/styles/index.d.ts +0 -8
  261. package/esm/styles/index.d.ts.map +0 -1
  262. package/esm/styles/index.js +0 -171
  263. package/esm/styles/variants.d.ts +0 -51
  264. package/esm/styles/variants.d.ts.map +0 -1
  265. package/esm/theme/cdn.d.ts +0 -195
  266. package/esm/theme/cdn.d.ts.map +0 -1
  267. package/esm/theme/index.d.ts +0 -18
  268. package/esm/theme/index.d.ts.map +0 -1
  269. package/esm/theme/index.js +0 -700
  270. package/esm/theme/platforms.d.ts +0 -107
  271. package/esm/theme/platforms.d.ts.map +0 -1
  272. package/esm/theme/presets/github-openai.d.ts +0 -50
  273. package/esm/theme/presets/github-openai.d.ts.map +0 -1
  274. package/esm/theme/presets/index.d.ts +0 -11
  275. package/esm/theme/presets/index.d.ts.map +0 -1
  276. package/esm/theme/theme.d.ts +0 -396
  277. package/esm/theme/theme.d.ts.map +0 -1
  278. package/esm/tool-template/builder.d.ts +0 -213
  279. package/esm/tool-template/builder.d.ts.map +0 -1
  280. package/esm/tool-template/index.d.ts +0 -16
  281. package/esm/tool-template/index.d.ts.map +0 -1
  282. package/esm/tool-template/index.js +0 -3515
  283. package/esm/types/index.d.ts +0 -14
  284. package/esm/types/index.d.ts.map +0 -1
  285. package/esm/types/index.js +0 -75
  286. package/esm/types/ui-config.d.ts +0 -639
  287. package/esm/types/ui-config.d.ts.map +0 -1
  288. package/esm/types/ui-runtime.d.ts +0 -1007
  289. package/esm/types/ui-runtime.d.ts.map +0 -1
  290. package/esm/typings/cache/cache-adapter.d.ts +0 -125
  291. package/esm/typings/cache/cache-adapter.d.ts.map +0 -1
  292. package/esm/typings/cache/index.d.ts +0 -10
  293. package/esm/typings/cache/index.d.ts.map +0 -1
  294. package/esm/typings/cache/memory-cache.d.ts +0 -92
  295. package/esm/typings/cache/memory-cache.d.ts.map +0 -1
  296. package/esm/typings/dts-parser.d.ts +0 -90
  297. package/esm/typings/dts-parser.d.ts.map +0 -1
  298. package/esm/typings/index.d.ts +0 -48
  299. package/esm/typings/index.d.ts.map +0 -1
  300. package/esm/typings/schemas.d.ts +0 -232
  301. package/esm/typings/schemas.d.ts.map +0 -1
  302. package/esm/typings/type-fetcher.d.ts +0 -89
  303. package/esm/typings/type-fetcher.d.ts.map +0 -1
  304. package/esm/typings/types.d.ts +0 -320
  305. package/esm/typings/types.d.ts.map +0 -1
  306. package/esm/utils/escape-html.d.ts +0 -58
  307. package/esm/utils/escape-html.d.ts.map +0 -1
  308. package/esm/utils/index.d.ts +0 -10
  309. package/esm/utils/index.d.ts.map +0 -1
  310. package/esm/utils/index.js +0 -40
  311. package/esm/utils/safe-stringify.d.ts +0 -30
  312. package/esm/utils/safe-stringify.d.ts.map +0 -1
  313. package/esm/validation/error-box.d.ts +0 -56
  314. package/esm/validation/error-box.d.ts.map +0 -1
  315. package/esm/validation/index.d.ts +0 -13
  316. package/esm/validation/index.d.ts.map +0 -1
  317. package/esm/validation/index.js +0 -562
  318. package/esm/validation/schema-paths.d.ts +0 -118
  319. package/esm/validation/schema-paths.d.ts.map +0 -1
  320. package/esm/validation/template-validator.d.ts +0 -143
  321. package/esm/validation/template-validator.d.ts.map +0 -1
  322. package/esm/validation/wrapper.d.ts +0 -97
  323. package/esm/validation/wrapper.d.ts.map +0 -1
  324. package/handlebars/expression-extractor.d.ts +0 -147
  325. package/handlebars/expression-extractor.d.ts.map +0 -1
  326. package/handlebars/helpers.d.ts +0 -339
  327. package/handlebars/helpers.d.ts.map +0 -1
  328. package/handlebars/index.d.ts +0 -195
  329. package/handlebars/index.d.ts.map +0 -1
  330. package/handlebars/index.js +0 -666
  331. package/registry/index.d.ts +0 -46
  332. package/registry/index.d.ts.map +0 -1
  333. package/registry/index.js +0 -6465
  334. package/registry/render-template.d.ts +0 -91
  335. package/registry/render-template.d.ts.map +0 -1
  336. package/registry/tool-ui.registry.d.ts +0 -294
  337. package/registry/tool-ui.registry.d.ts.map +0 -1
  338. package/registry/uri-utils.d.ts +0 -56
  339. package/registry/uri-utils.d.ts.map +0 -1
  340. package/renderers/cache.d.ts +0 -145
  341. package/renderers/cache.d.ts.map +0 -1
  342. package/renderers/html.renderer.d.ts +0 -123
  343. package/renderers/html.renderer.d.ts.map +0 -1
  344. package/renderers/mdx.renderer.d.ts +0 -120
  345. package/renderers/mdx.renderer.d.ts.map +0 -1
  346. package/renderers/registry.d.ts +0 -134
  347. package/renderers/registry.d.ts.map +0 -1
  348. package/renderers/types.d.ts +0 -342
  349. package/renderers/types.d.ts.map +0 -1
  350. package/renderers/utils/detect.d.ts +0 -107
  351. package/renderers/utils/detect.d.ts.map +0 -1
  352. package/renderers/utils/hash.d.ts +0 -40
  353. package/renderers/utils/hash.d.ts.map +0 -1
  354. package/renderers/utils/index.d.ts +0 -9
  355. package/renderers/utils/index.d.ts.map +0 -1
  356. package/renderers/utils/transpiler.d.ts +0 -89
  357. package/renderers/utils/transpiler.d.ts.map +0 -1
  358. package/runtime/adapters/html.adapter.d.ts +0 -59
  359. package/runtime/adapters/html.adapter.d.ts.map +0 -1
  360. package/runtime/adapters/index.d.ts +0 -26
  361. package/runtime/adapters/index.d.ts.map +0 -1
  362. package/runtime/adapters/mdx.adapter.d.ts +0 -73
  363. package/runtime/adapters/mdx.adapter.d.ts.map +0 -1
  364. package/runtime/adapters/react.adapter.d.ts.map +0 -1
  365. package/runtime/adapters/types.d.ts +0 -95
  366. package/runtime/adapters/types.d.ts.map +0 -1
  367. package/runtime/csp.d.ts +0 -48
  368. package/runtime/csp.d.ts.map +0 -1
  369. package/runtime/index.d.ts +0 -17
  370. package/runtime/index.d.ts.map +0 -1
  371. package/runtime/index.js +0 -5264
  372. package/runtime/mcp-bridge.d.ts +0 -101
  373. package/runtime/mcp-bridge.d.ts.map +0 -1
  374. package/runtime/renderer-runtime.d.ts +0 -133
  375. package/runtime/renderer-runtime.d.ts.map +0 -1
  376. package/runtime/sanitizer.d.ts +0 -172
  377. package/runtime/sanitizer.d.ts.map +0 -1
  378. package/runtime/types.d.ts +0 -415
  379. package/runtime/types.d.ts.map +0 -1
  380. package/runtime/wrapper.d.ts +0 -421
  381. package/runtime/wrapper.d.ts.map +0 -1
  382. package/styles/index.d.ts +0 -8
  383. package/styles/index.d.ts.map +0 -1
  384. package/styles/index.js +0 -222
  385. package/styles/variants.d.ts +0 -51
  386. package/styles/variants.d.ts.map +0 -1
  387. package/theme/cdn.d.ts +0 -195
  388. package/theme/cdn.d.ts.map +0 -1
  389. package/theme/index.d.ts +0 -18
  390. package/theme/index.d.ts.map +0 -1
  391. package/theme/index.js +0 -757
  392. package/theme/platforms.d.ts +0 -107
  393. package/theme/platforms.d.ts.map +0 -1
  394. package/theme/presets/github-openai.d.ts +0 -50
  395. package/theme/presets/github-openai.d.ts.map +0 -1
  396. package/theme/presets/index.d.ts +0 -11
  397. package/theme/presets/index.d.ts.map +0 -1
  398. package/theme/theme.d.ts +0 -396
  399. package/theme/theme.d.ts.map +0 -1
  400. package/tool-template/builder.d.ts +0 -213
  401. package/tool-template/builder.d.ts.map +0 -1
  402. package/tool-template/index.d.ts +0 -16
  403. package/tool-template/index.d.ts.map +0 -1
  404. package/tool-template/index.js +0 -3559
  405. package/types/index.d.ts +0 -14
  406. package/types/index.d.ts.map +0 -1
  407. package/types/index.js +0 -108
  408. package/types/ui-config.d.ts +0 -639
  409. package/types/ui-config.d.ts.map +0 -1
  410. package/types/ui-runtime.d.ts +0 -1007
  411. package/types/ui-runtime.d.ts.map +0 -1
  412. package/typings/cache/cache-adapter.d.ts +0 -125
  413. package/typings/cache/cache-adapter.d.ts.map +0 -1
  414. package/typings/cache/index.d.ts +0 -10
  415. package/typings/cache/index.d.ts.map +0 -1
  416. package/typings/cache/memory-cache.d.ts +0 -92
  417. package/typings/cache/memory-cache.d.ts.map +0 -1
  418. package/typings/dts-parser.d.ts +0 -90
  419. package/typings/dts-parser.d.ts.map +0 -1
  420. package/typings/index.d.ts +0 -48
  421. package/typings/index.d.ts.map +0 -1
  422. package/typings/schemas.d.ts +0 -232
  423. package/typings/schemas.d.ts.map +0 -1
  424. package/typings/type-fetcher.d.ts +0 -89
  425. package/typings/type-fetcher.d.ts.map +0 -1
  426. package/typings/types.d.ts +0 -320
  427. package/typings/types.d.ts.map +0 -1
  428. package/utils/escape-html.d.ts +0 -58
  429. package/utils/escape-html.d.ts.map +0 -1
  430. package/utils/index.d.ts +0 -10
  431. package/utils/index.d.ts.map +0 -1
  432. package/utils/index.js +0 -70
  433. package/utils/safe-stringify.d.ts +0 -30
  434. package/utils/safe-stringify.d.ts.map +0 -1
  435. package/validation/error-box.d.ts +0 -56
  436. package/validation/error-box.d.ts.map +0 -1
  437. package/validation/index.d.ts +0 -13
  438. package/validation/index.d.ts.map +0 -1
  439. package/validation/index.js +0 -603
  440. package/validation/schema-paths.d.ts +0 -118
  441. package/validation/schema-paths.d.ts.map +0 -1
  442. package/validation/template-validator.d.ts +0 -143
  443. package/validation/template-validator.d.ts.map +0 -1
  444. package/validation/wrapper.d.ts +0 -97
  445. package/validation/wrapper.d.ts.map +0 -1
@@ -1,1007 +0,0 @@
1
- /**
2
- * Widget Runtime Types
3
- *
4
- * Core types for the Tool UI widget system. These types define:
5
- * - UI rendering modes (html, react, mdx, markdown, auto)
6
- * - Bundling strategies (static vs dynamic)
7
- * - Widget manifests for caching and discovery
8
- * - Runtime payloads for tool responses
9
- * - CSP directives for security
10
- *
11
- * This module is the canonical source for widget types.
12
- * Both `@frontmcp/sdk` and external consumers (like AgentLink)
13
- * should import types from here.
14
- *
15
- * @packageDocumentation
16
- */
17
- import type { WidgetServingMode as _WidgetServingMode } from './ui-config';
18
- import type { ZodTypeAny } from 'zod';
19
- export type { TemplateHelpers, TemplateContext, TemplateBuilderFn, UIContentSecurityPolicy, WidgetDisplayMode, WidgetServingMode, } from './ui-config';
20
- type WidgetServingMode = _WidgetServingMode;
21
- /**
22
- * UI renderer type for widget templates.
23
- *
24
- * - `'html'`: Plain HTML template (with optional Handlebars enhancement)
25
- * - `'react'`: React component (SSR + optional hydration)
26
- * - `'mdx'`: MDX template (Markdown + JSX components)
27
- * - `'markdown'`: Pure Markdown (rendered via markdown engine)
28
- * - `'auto'`: Auto-detect from template; loads all renderers at runtime
29
- *
30
- * @example
31
- * ```typescript
32
- * // Explicit HTML mode
33
- * ui: {
34
- * template: '<div>{{output.value}}</div>',
35
- * uiType: 'html'
36
- * }
37
- *
38
- * // Auto-detect (loads all renderers)
39
- * ui: {
40
- * template: MyReactComponent,
41
- * uiType: 'auto'
42
- * }
43
- * ```
44
- */
45
- export type UIType = 'html' | 'react' | 'mdx' | 'markdown' | 'auto';
46
- /**
47
- * Widget bundling strategy.
48
- *
49
- * - `'static'`: Widget shell is pre-compiled at startup and cached.
50
- * Tool responses reference the cached widget via `ui://widget/{toolName}`.
51
- * Data is injected at runtime via FrontMCP Bridge. **Default mode.**
52
- *
53
- * - `'dynamic'`: Fresh HTML is generated for each tool invocation.
54
- * Use for debugging or when template logic depends on invocation context.
55
- *
56
- * @example
57
- * ```typescript
58
- * // Static mode (default, recommended)
59
- * ui: {
60
- * template: WeatherWidget,
61
- * bundlingMode: 'static'
62
- * }
63
- *
64
- * // Dynamic mode (debugging, fresh per call)
65
- * ui: {
66
- * template: (ctx) => `<div>${ctx.output.debug}</div>`,
67
- * bundlingMode: 'dynamic'
68
- * }
69
- * ```
70
- */
71
- export type BundlingMode = 'static' | 'dynamic';
72
- /**
73
- * Resource loading mode for widget dependencies.
74
- *
75
- * - `'cdn'`: Load React/MDX/Handlebars from CDN URLs (light, fast).
76
- * Requires network access. Best for most platforms.
77
- *
78
- * - `'inline'`: Embed all scripts directly in the HTML (self-contained).
79
- * Works in network-blocked environments (e.g., Claude Artifacts).
80
- * Results in larger HTML payloads.
81
- *
82
- * @example
83
- * ```typescript
84
- * // CDN mode (default, lightweight)
85
- * ui: {
86
- * template: WeatherWidget,
87
- * resourceMode: 'cdn'
88
- * }
89
- *
90
- * // Inline mode (network-blocked environments)
91
- * ui: {
92
- * template: WeatherWidget,
93
- * resourceMode: 'inline'
94
- * }
95
- * ```
96
- */
97
- export type ResourceMode = 'cdn' | 'inline';
98
- /**
99
- * Widget output mode - determines what is returned in tool responses.
100
- *
101
- * - `'code-only'`: Return just the transpiled/rendered content.
102
- * The host platform (OpenAI, etc.) provides the runtime wrapper.
103
- * Best for capable platforms that handle their own rendering.
104
- *
105
- * - `'full-ssr'`: Return complete SSR'd HTML with embedded data.
106
- * Self-contained output for limited/unknown MCP clients.
107
- * Includes FrontMCP Bridge, scripts, and all necessary runtime.
108
- *
109
- * - `'dual-payload'`: Return TWO TextContent blocks for Claude Artifacts.
110
- * Block 0: Pure JSON stringified data (for programmatic parsing).
111
- * Block 1: Markdown-wrapped HTML (```html...```) for visual rendering.
112
- * Uses cloudflare CDN for all resources (Claude sandbox restriction).
113
- *
114
- * @example
115
- * ```typescript
116
- * // For OpenAI - just return the rendered content
117
- * const result = await buildWidgetOutput({
118
- * uiConfig,
119
- * toolName: 'weather',
120
- * outputMode: 'code-only',
121
- * output: { temperature: 72 },
122
- * });
123
- * // result.content = '<div class="weather">72°F</div>'
124
- *
125
- * // For unknown clients - return full HTML
126
- * const result = await buildWidgetOutput({
127
- * uiConfig,
128
- * toolName: 'weather',
129
- * outputMode: 'full-ssr',
130
- * output: { temperature: 72 },
131
- * });
132
- * // result.html = '<!DOCTYPE html>...'
133
- *
134
- * // For Claude - return dual-payload
135
- * const result = await buildWidgetOutput({
136
- * uiConfig,
137
- * toolName: 'weather',
138
- * outputMode: 'dual-payload',
139
- * output: { temperature: 72 },
140
- * });
141
- * // result.content = [
142
- * // { type: 'text', text: '{"temperature":72}' },
143
- * // { type: 'text', text: 'Here is the weather:\n\n```html\n<!DOCTYPE html>...\n```' }
144
- * // ]
145
- * ```
146
- */
147
- export type OutputMode = 'code-only' | 'full-ssr' | 'dual-payload';
148
- /**
149
- * Display mode for widget presentation.
150
- *
151
- * Note: This is an alias for `WidgetDisplayMode` from ui-config.ts.
152
- * Prefer using `WidgetDisplayMode` for new code.
153
- */
154
- export type DisplayMode = 'inline' | 'fullscreen' | 'pip';
155
- /**
156
- * Content Security Policy directives for widget sandboxes.
157
- *
158
- * More granular than `UIContentSecurityPolicy`, this type
159
- * maps directly to CSP header directives.
160
- *
161
- * @example
162
- * ```typescript
163
- * const csp: CSPDirectives = {
164
- * scriptSrc: ["'self'", "'unsafe-inline'", "https://unpkg.com"],
165
- * styleSrc: ["'self'", "'unsafe-inline'"],
166
- * connectSrc: ["https://api.example.com"],
167
- * };
168
- * ```
169
- */
170
- export interface CSPDirectives {
171
- /**
172
- * Script source directives (CSP script-src).
173
- * @example ["'self'", "'unsafe-inline'", "https://unpkg.com"]
174
- */
175
- scriptSrc: string[];
176
- /**
177
- * Style source directives (CSP style-src).
178
- * @example ["'self'", "'unsafe-inline'"]
179
- */
180
- styleSrc: string[];
181
- /**
182
- * Connection source directives (CSP connect-src).
183
- * Controls fetch/XHR/WebSocket destinations.
184
- * @example ["https://api.example.com"]
185
- */
186
- connectSrc: string[];
187
- /**
188
- * Image source directives (CSP img-src).
189
- * @example ["'self'", "data:", "https://images.example.com"]
190
- */
191
- imgSrc?: string[];
192
- /**
193
- * Font source directives (CSP font-src).
194
- * @example ["'self'", "https://fonts.gstatic.com"]
195
- */
196
- fontSrc?: string[];
197
- /**
198
- * Default source directive (CSP default-src).
199
- * @example ["'self'"]
200
- */
201
- defaultSrc?: string[];
202
- /**
203
- * Frame source directives (CSP frame-src).
204
- * @example ["'none'"]
205
- */
206
- frameSrc?: string[];
207
- /**
208
- * Object source directives (CSP object-src).
209
- * @example ["'none'"]
210
- */
211
- objectSrc?: string[];
212
- }
213
- /**
214
- * CDN configuration for a single script resource.
215
- */
216
- export interface CDNResource {
217
- /**
218
- * CDN URL for the script.
219
- */
220
- url: string;
221
- /**
222
- * Subresource integrity hash (SRI).
223
- * @example "sha384-..."
224
- */
225
- integrity?: string;
226
- /**
227
- * Crossorigin attribute.
228
- * @default "anonymous"
229
- */
230
- crossorigin?: 'anonymous' | 'use-credentials';
231
- }
232
- /**
233
- * External assets required by a renderer type.
234
- *
235
- * Supports two modes:
236
- * - CDN mode: Light payloads, scripts loaded from CDN URLs
237
- * - Inline mode: Self-contained, scripts embedded in HTML
238
- *
239
- * @example
240
- * ```typescript
241
- * // CDN mode (lightweight)
242
- * const assets: RendererAssets = {
243
- * mode: 'cdn',
244
- * react: { url: 'https://unpkg.com/react@18/umd/react.production.min.js' },
245
- * reactDom: { url: 'https://unpkg.com/react-dom@18/umd/react-dom.production.min.js' },
246
- * };
247
- *
248
- * // Inline mode (self-contained)
249
- * const assets: RendererAssets = {
250
- * mode: 'inline',
251
- * inlineReact: '/* minified react code *\/',
252
- * inlineReactDom: '/* minified react-dom code *\/',
253
- * };
254
- * ```
255
- */
256
- export interface RendererAssets {
257
- /**
258
- * Resource loading mode.
259
- * - 'cdn': Load scripts from CDN URLs (light, requires network)
260
- * - 'inline': Embed scripts in HTML (heavy, works offline)
261
- * @default 'cdn'
262
- */
263
- mode: ResourceMode;
264
- /**
265
- * React UMD runtime CDN (for 'react' UI type).
266
- */
267
- react?: CDNResource;
268
- /**
269
- * ReactDOM UMD runtime CDN (for 'react' UI type with hydration).
270
- */
271
- reactDom?: CDNResource;
272
- /**
273
- * Markdown rendering engine CDN (for 'markdown' or 'mdx' types).
274
- */
275
- markdown?: CDNResource;
276
- /**
277
- * MDX runtime CDN (for 'mdx' type).
278
- */
279
- mdxRuntime?: CDNResource;
280
- /**
281
- * Handlebars runtime CDN (for enhanced HTML templates).
282
- */
283
- handlebars?: CDNResource;
284
- /**
285
- * Tailwind CSS CDN.
286
- */
287
- tailwind?: CDNResource;
288
- /**
289
- * Inline React runtime (for inline mode).
290
- * Contains minified React UMD bundle.
291
- */
292
- inlineReact?: string;
293
- /**
294
- * Inline ReactDOM runtime (for inline mode).
295
- * Contains minified ReactDOM UMD bundle.
296
- */
297
- inlineReactDom?: string;
298
- /**
299
- * Inline Handlebars runtime (for inline mode).
300
- */
301
- inlineHandlebars?: string;
302
- /**
303
- * Inline Markdown engine (for inline mode).
304
- */
305
- inlineMarkdown?: string;
306
- /**
307
- * Inline bundle content (compiled widget template).
308
- * Contains the pre-bundled renderer + template code.
309
- */
310
- inlineBundle?: string;
311
- /**
312
- * Content hash of the bundled widget code.
313
- * Used for cache invalidation.
314
- */
315
- bundleHash?: string;
316
- /**
317
- * @deprecated Use `react.url` instead
318
- */
319
- reactRuntime?: string;
320
- /**
321
- * @deprecated Use `reactDom.url` instead
322
- */
323
- reactDomRuntime?: string;
324
- /**
325
- * @deprecated Use `markdown.url` instead
326
- */
327
- markdownEngine?: string;
328
- /**
329
- * @deprecated Use `handlebars.url` instead
330
- */
331
- handlebarsRuntime?: string;
332
- }
333
- /**
334
- * Widget manifest describing a pre-compiled static widget.
335
- *
336
- * The manifest is embedded in the widget HTML and also cached
337
- * separately for quick lookups. It contains all metadata needed
338
- * for the runtime to render the widget correctly.
339
- *
340
- * @example
341
- * ```json
342
- * {
343
- * "tool": "weather.get",
344
- * "uiType": "react",
345
- * "bundlingMode": "static",
346
- * "displayMode": "inline",
347
- * "widgetAccessible": true,
348
- * "schema": { "type": "object", "properties": {...} },
349
- * "csp": { "scriptSrc": ["'self'"], ... },
350
- * "rendererAssets": { "reactRuntime": "https://..." },
351
- * "hash": "sha256-abc123..."
352
- * }
353
- * ```
354
- */
355
- export interface WidgetManifest {
356
- /**
357
- * Tool name (unique identifier).
358
- * @example "weather.get"
359
- */
360
- tool: string;
361
- /**
362
- * UI renderer type.
363
- */
364
- uiType: UIType;
365
- /**
366
- * Bundling mode used to create this widget.
367
- */
368
- bundlingMode: BundlingMode;
369
- /**
370
- * Preferred display mode for the widget.
371
- */
372
- displayMode: DisplayMode;
373
- /**
374
- * Whether the widget can invoke tools via MCP bridge.
375
- * When true, widget has access to `window.mcpBridge.callTool()`.
376
- */
377
- widgetAccessible: boolean;
378
- /**
379
- * JSON Schema describing the tool's output structure.
380
- * Used for type hints and validation.
381
- */
382
- schema: object;
383
- /**
384
- * Content Security Policy directives.
385
- */
386
- csp: CSPDirectives;
387
- /**
388
- * External assets required by the renderer.
389
- */
390
- rendererAssets: RendererAssets;
391
- /**
392
- * SHA-256 hash of the manifest + HTML content.
393
- * Used for cache validation and ETag generation.
394
- */
395
- hash: string;
396
- /**
397
- * Timestamp when the manifest was created (ISO 8601).
398
- */
399
- createdAt?: string;
400
- /**
401
- * Human-readable description of the widget.
402
- */
403
- description?: string;
404
- /**
405
- * Widget URI in the MCP resource format.
406
- * @example "ui://widget/weather.get.html"
407
- */
408
- uri?: string;
409
- }
410
- /**
411
- * UI metadata fields emitted in tool response `_meta`.
412
- *
413
- * All UI-related data goes in `_meta`, NOT in the `content` array.
414
- * The MCP client reads these fields to render the widget.
415
- *
416
- * @example
417
- * ```typescript
418
- * // Tool response structure
419
- * {
420
- * content: [{ type: 'text', text: 'Weather data retrieved' }],
421
- * _meta: {
422
- * // UI type for renderer selection
423
- * 'ui/type': 'react',
424
- *
425
- * // Transpiled widget code (for capable clients like OpenAI)
426
- * 'ui/content': '<div class="weather">72°F Sunny</div>',
427
- *
428
- * // OR full HTML (for limited clients)
429
- * 'ui/html': '<!DOCTYPE html>...',
430
- *
431
- * // Content hash for caching
432
- * 'ui/hash': 'sha256-abc123...',
433
- *
434
- * // Display mode hint
435
- * 'ui/displayMode': 'inline',
436
- *
437
- * // Widget can call tools
438
- * 'ui/widgetAccessible': true,
439
- *
440
- * // OpenAI-specific CSP
441
- * 'openai/widgetCSP': { connect_domains: ['api.weather.com'] },
442
- * }
443
- * }
444
- * ```
445
- */
446
- export interface UIMetaFields {
447
- /**
448
- * UI renderer type.
449
- * Maps to `_meta['ui/type']`.
450
- */
451
- 'ui/type': UIType;
452
- /**
453
- * Transpiled widget content (code-only mode).
454
- * Just the rendered template without wrapper HTML.
455
- * Use for capable clients (OpenAI) that provide their own runtime.
456
- * Maps to `_meta['ui/content']`.
457
- */
458
- 'ui/content'?: string;
459
- /**
460
- * Full HTML document (full-ssr mode).
461
- * Complete self-contained HTML with scripts, bridge, etc.
462
- * Use for limited/unknown MCP clients.
463
- * Maps to `_meta['ui/html']`.
464
- */
465
- 'ui/html'?: string;
466
- /**
467
- * Content hash for cache validation.
468
- * Maps to `_meta['ui/hash']`.
469
- */
470
- 'ui/hash': string;
471
- /**
472
- * Display mode hint.
473
- * Maps to `_meta['ui/displayMode']`.
474
- */
475
- 'ui/displayMode'?: DisplayMode;
476
- /**
477
- * Whether widget can invoke tools via MCP bridge.
478
- * Maps to `_meta['ui/widgetAccessible']`.
479
- */
480
- 'ui/widgetAccessible'?: boolean;
481
- /**
482
- * Widget description for accessibility.
483
- * Maps to `_meta['ui/description']`.
484
- */
485
- 'ui/description'?: string;
486
- /**
487
- * Resource mode used (cdn or inline).
488
- * Maps to `_meta['ui/resourceMode']`.
489
- */
490
- 'ui/resourceMode'?: ResourceMode;
491
- }
492
- /**
493
- * OpenAI-specific meta fields.
494
- * These are in addition to the standard UI fields.
495
- */
496
- export interface OpenAIMetaFields {
497
- /**
498
- * OpenAI CSP configuration.
499
- * Maps to `_meta['openai/widgetCSP']`.
500
- */
501
- 'openai/widgetCSP'?: {
502
- connect_domains?: string[];
503
- resource_domains?: string[];
504
- };
505
- /**
506
- * OpenAI widget accessible flag.
507
- * Maps to `_meta['openai/widgetAccessible']`.
508
- */
509
- 'openai/widgetAccessible'?: boolean;
510
- /**
511
- * OpenAI widget description.
512
- * Maps to `_meta['openai/widgetDescription']`.
513
- */
514
- 'openai/widgetDescription'?: string;
515
- /**
516
- * OpenAI display mode.
517
- * Maps to `_meta['openai/displayMode']`.
518
- */
519
- 'openai/displayMode'?: 'inline' | 'fullscreen' | 'pip';
520
- }
521
- /**
522
- * Combined meta fields for tool responses.
523
- * Includes both standard UI fields and platform-specific fields.
524
- */
525
- export type ToolResponseMeta = Partial<UIMetaFields> & Partial<OpenAIMetaFields> & Record<string, unknown>;
526
- /**
527
- * @deprecated Use UIMetaFields instead. RuntimePayload is being replaced
528
- * with explicit _meta field types.
529
- */
530
- export interface RuntimePayload {
531
- /**
532
- * Resolved UI type for this invocation.
533
- * @deprecated Use UIMetaFields['ui/type']
534
- */
535
- type: UIType;
536
- /**
537
- * Rendered/compiled content.
538
- * @deprecated Use UIMetaFields['ui/content']
539
- */
540
- content: string;
541
- /**
542
- * Content hash for cache validation.
543
- * @deprecated Use UIMetaFields['ui/hash']
544
- */
545
- hash: string;
546
- /**
547
- * Hydration data for React components.
548
- */
549
- hydrationData?: unknown;
550
- /**
551
- * Structured tool output (JSON-serializable).
552
- */
553
- toolOutput?: unknown;
554
- /**
555
- * Additional metadata for the runtime.
556
- */
557
- metadata?: Record<string, unknown>;
558
- }
559
- /**
560
- * Widget template types supported by the system.
561
- *
562
- * - String: HTML/MDX/Markdown content
563
- * - Builder function: Receives context, returns HTML string
564
- * - React component: SSR'd with props from context
565
- */
566
- export type WidgetTemplate = string | ((ctx: WidgetTemplateContext) => string) | React.ComponentType<WidgetTemplateContext>;
567
- /**
568
- * Context passed to widget templates.
569
- *
570
- * This is a more specific version of `TemplateContext` with
571
- * explicit typing for widget rendering.
572
- */
573
- export interface WidgetTemplateContext<Input = Record<string, unknown>, Output = unknown> {
574
- /**
575
- * Tool input arguments.
576
- */
577
- input: Input;
578
- /**
579
- * Tool output/result.
580
- */
581
- output: Output;
582
- /**
583
- * Structured content parsed from output (if schema provided).
584
- */
585
- structuredContent?: unknown;
586
- /**
587
- * Template helper functions.
588
- */
589
- helpers: WidgetTemplateHelpers;
590
- }
591
- /**
592
- * Helper functions available in widget templates.
593
- */
594
- export interface WidgetTemplateHelpers {
595
- /**
596
- * Escape HTML special characters to prevent XSS.
597
- */
598
- escapeHtml(str: string): string;
599
- /**
600
- * Format a date for display.
601
- * @param date - Date object or ISO string
602
- * @param format - Optional format string
603
- */
604
- formatDate(date: Date | string, format?: string): string;
605
- /**
606
- * Format a number as currency.
607
- * @param amount - Numeric amount
608
- * @param currency - ISO 4217 currency code (default: 'USD')
609
- */
610
- formatCurrency(amount: number, currency?: string): string;
611
- /**
612
- * Generate a unique ID for DOM elements.
613
- * @param prefix - Optional prefix
614
- */
615
- uniqueId(prefix?: string): string;
616
- /**
617
- * Safely embed JSON data in HTML.
618
- * Escapes script-breaking characters.
619
- */
620
- jsonEmbed(data: unknown): string;
621
- /**
622
- * Conditionally join class names.
623
- * @param classes - Class names (falsy values are filtered)
624
- */
625
- classNames(...classes: (string | false | undefined | null)[]): string;
626
- /**
627
- * Format a number with locale-aware separators.
628
- */
629
- formatNumber(value: number, options?: Intl.NumberFormatOptions): string;
630
- }
631
- /**
632
- * Widget configuration for tool UI templates.
633
- *
634
- * This is the main configuration type used in tool decorators
635
- * and standalone widget compilation.
636
- *
637
- * @example
638
- * ```typescript
639
- * const config: WidgetConfig = {
640
- * template: WeatherWidget,
641
- * uiType: 'react',
642
- * bundlingMode: 'static',
643
- * displayMode: 'inline',
644
- * widgetAccessible: true,
645
- * csp: { connectSrc: ['https://api.weather.com'] },
646
- * };
647
- * ```
648
- */
649
- export interface WidgetConfig<Input = Record<string, unknown>, Output = unknown> {
650
- /**
651
- * Widget template.
652
- *
653
- * Supports:
654
- * - HTML string (with optional Handlebars syntax)
655
- * - MDX string
656
- * - Template builder function
657
- * - React component
658
- */
659
- template: WidgetTemplate | ((ctx: WidgetTemplateContext<Input, Output>) => string);
660
- /**
661
- * UI renderer type.
662
- *
663
- * - `'html'`: HTML with optional Handlebars
664
- * - `'react'`: React component (SSR)
665
- * - `'mdx'`: MDX template
666
- * - `'markdown'`: Pure Markdown
667
- * - `'auto'`: Auto-detect from template (default)
668
- *
669
- * @default 'auto'
670
- */
671
- uiType?: UIType;
672
- /**
673
- * Bundling mode.
674
- *
675
- * - `'static'`: Pre-compile widget shell, inject data at runtime (default)
676
- * - `'dynamic'`: Generate fresh HTML per tool invocation
677
- *
678
- * @default 'static'
679
- */
680
- bundlingMode?: BundlingMode;
681
- /**
682
- * Display mode preference.
683
- *
684
- * - `'inline'`: Render inline in conversation (default)
685
- * - `'fullscreen'`: Request fullscreen display
686
- * - `'pip'`: Picture-in-picture mode
687
- *
688
- * @default 'inline'
689
- */
690
- displayMode?: DisplayMode;
691
- /**
692
- * Resource loading mode.
693
- *
694
- * - `'cdn'`: Load React/MDX/Handlebars from CDN URLs (lightweight)
695
- * - `'inline'`: Embed all scripts in HTML (self-contained)
696
- *
697
- * Use 'cdn' for most platforms (OpenAI, ChatGPT, Cursor).
698
- * Use 'inline' for network-blocked environments (Claude Artifacts).
699
- *
700
- * @default 'cdn'
701
- */
702
- resourceMode?: ResourceMode;
703
- /**
704
- * Content Security Policy overrides.
705
- *
706
- * Merged with auto-generated CSP based on uiType.
707
- */
708
- csp?: Partial<CSPDirectives>;
709
- /**
710
- * Whether widget can invoke tools via MCP bridge.
711
- *
712
- * When true, widget gets access to `window.mcpBridge.callTool()`.
713
- *
714
- * @default false
715
- */
716
- widgetAccessible?: boolean;
717
- /**
718
- * Human-readable description shown to users.
719
- * Maps to OpenAI's `openai/widgetDescription`.
720
- */
721
- widgetDescription?: string;
722
- /**
723
- * Runtime options for specific renderers.
724
- */
725
- runtimeOptions?: WidgetRuntimeOptions;
726
- /**
727
- * Custom MDX components available in templates.
728
- */
729
- mdxComponents?: Record<string, any>;
730
- /**
731
- * Status messages during tool invocation (OpenAI-specific).
732
- */
733
- invocationStatus?: {
734
- /** Status text while tool is executing */
735
- invoking?: string;
736
- /** Status text after execution completes */
737
- invoked?: string;
738
- };
739
- /**
740
- * How the widget HTML should be served to the client.
741
- *
742
- * - `'inline'`: HTML embedded directly in tool response `_meta['ui/html']`
743
- * - `'static'`: Pre-compiled at startup, via `ui://` resource URI (MCP resources/read)
744
- * - `'hybrid'`: Shell pre-compiled at startup, component in response
745
- * - `'direct-url'`: HTTP endpoint on MCP server
746
- * - `'custom-url'`: Custom URL (CDN or external hosting)
747
- *
748
- * @default 'inline'
749
- */
750
- servingMode?: WidgetServingMode;
751
- /**
752
- * Custom URL for widget serving when `servingMode: 'custom-url'`.
753
- * The URL can include `{token}` placeholder which will be replaced
754
- * with the widget access token.
755
- *
756
- * @example 'https://cdn.example.com/widgets/weather.html?token={token}'
757
- */
758
- customWidgetUrl?: string;
759
- /**
760
- * Path for direct URL serving when `servingMode: 'direct-url'`.
761
- * This path is appended to the MCP server's base URL.
762
- *
763
- * @example '/widgets/weather'
764
- */
765
- directPath?: string;
766
- /**
767
- * Whether to show a border around the UI widget.
768
- * MCP Apps spec: `_meta.ui.prefersBorder`
769
- *
770
- * @default undefined (host decides)
771
- */
772
- prefersBorder?: boolean;
773
- /**
774
- * Dedicated sandbox domain for the widget.
775
- * MCP Apps spec: `_meta.ui.domain`
776
- *
777
- * @example 'sandbox.example.com'
778
- */
779
- sandboxDomain?: string;
780
- /**
781
- * Enable client-side React hydration after server-side rendering (SSR).
782
- *
783
- * **Default: `false`**
784
- *
785
- * When `false` (default):
786
- * - SSR output is static HTML
787
- * - No React runtime loaded on client
788
- * - Interactivity via FrontMCP Bridge
789
- *
790
- * When `true`:
791
- * - React/ReactDOM scripts included
792
- * - Client attempts hydration
793
- * - May cause hydration errors in MCP clients
794
- *
795
- * @default false
796
- */
797
- hydrate?: boolean;
798
- }
799
- /**
800
- * Runtime options for widget renderers.
801
- */
802
- export interface WidgetRuntimeOptions {
803
- /**
804
- * Enable React hydration after SSR.
805
- *
806
- * **Default: false**
807
- *
808
- * When false (recommended):
809
- * - SSR output is static HTML
810
- * - No React runtime loaded on client
811
- * - Interactivity via FrontMCP Bridge
812
- *
813
- * When true:
814
- * - React/ReactDOM scripts included
815
- * - Client attempts hydration
816
- * - May cause hydration errors in MCP clients
817
- */
818
- hydrate?: boolean;
819
- /**
820
- * Markdown rendering options.
821
- */
822
- markdown?: {
823
- /** Enable GitHub-flavored markdown */
824
- gfm?: boolean;
825
- /** Syntax highlighting theme */
826
- highlightTheme?: string;
827
- /** Custom renderer overrides */
828
- rendererOverrides?: Record<string, unknown>;
829
- };
830
- /**
831
- * Handlebars options (for HTML templates).
832
- */
833
- handlebars?: {
834
- /** Custom helpers to register */
835
- helpers?: Record<string, (...args: unknown[]) => string>;
836
- /** Custom partials */
837
- partials?: Record<string, string>;
838
- /** Strict mode (error on missing variables) */
839
- strict?: boolean;
840
- };
841
- }
842
- /**
843
- * Result of building a widget manifest.
844
- *
845
- * Returned by `buildToolWidgetManifest()` and used
846
- * by `ToolUIRegistry` for caching.
847
- *
848
- * The result contains both:
849
- * - `content`: Just the rendered template (for capable clients like OpenAI)
850
- * - `html`: Complete HTML document (for limited/unknown clients)
851
- *
852
- * Choose which to use based on the target client capabilities.
853
- */
854
- export interface BuildManifestResult {
855
- /**
856
- * Rendered template content (transpiled code).
857
- *
858
- * This is just the template output WITHOUT the wrapper HTML.
859
- * Use this for capable clients (OpenAI, etc.) that provide
860
- * their own runtime environment.
861
- *
862
- * @example
863
- * For a React component, this would be the SSR'd HTML:
864
- * `<div class="weather-card"><h1>72°F</h1><p>Sunny</p></div>`
865
- */
866
- content: string;
867
- /**
868
- * Complete HTML document string.
869
- *
870
- * Contains embedded manifest, FrontMCP Bridge, scripts, and template.
871
- * Use this for limited/unknown MCP clients that need a
872
- * self-contained HTML document.
873
- *
874
- * @example
875
- * `<!DOCTYPE html><html>...<body>{{content}}</body></html>`
876
- */
877
- html: string;
878
- /**
879
- * Widget manifest (also embedded in HTML).
880
- */
881
- manifest: WidgetManifest;
882
- /**
883
- * Content hash for cache validation.
884
- */
885
- hash: string;
886
- /**
887
- * Resolved renderer type.
888
- */
889
- rendererType: UIType;
890
- /**
891
- * Transpiled component code for client-side rendering.
892
- *
893
- * For React/MDX templates, this contains the transpiled component
894
- * that can be embedded in the widget HTML for client-side re-rendering
895
- * when tool output becomes available.
896
- *
897
- * This is used by `wrapStaticWidgetUniversal` for static mode.
898
- */
899
- componentCode?: string;
900
- /**
901
- * Size of content in bytes.
902
- */
903
- contentSize: number;
904
- /**
905
- * Size of full HTML in bytes.
906
- */
907
- htmlSize: number;
908
- /**
909
- * Estimated gzipped size of full HTML.
910
- */
911
- gzipSize: number;
912
- /**
913
- * @deprecated Use `htmlSize` instead
914
- */
915
- size: number;
916
- }
917
- /**
918
- * Options for building a widget manifest.
919
- */
920
- export interface BuildManifestOptions<Input = Record<string, unknown>, Output = unknown> {
921
- /**
922
- * Tool name (unique identifier).
923
- */
924
- toolName: string;
925
- /**
926
- * Widget configuration.
927
- */
928
- uiConfig: WidgetConfig<Input, Output>;
929
- /**
930
- * JSON Schema for tool output.
931
- * Used for validation and type hints.
932
- */
933
- schema?: object;
934
- /**
935
- * Theme configuration override.
936
- */
937
- theme?: any;
938
- /**
939
- * Sample input for SSR (static mode).
940
- * Used during pre-compilation.
941
- */
942
- sampleInput?: Input;
943
- /**
944
- * Sample output for SSR (static mode).
945
- * Used during pre-compilation.
946
- */
947
- sampleOutput?: Output;
948
- /**
949
- * Zod schema for output validation.
950
- *
951
- * When provided in development mode (NODE_ENV !== 'production'),
952
- * the template will be validated against this schema to catch
953
- * Handlebars expressions referencing non-existent fields.
954
- *
955
- * @example
956
- * ```typescript
957
- * outputSchema: z.object({
958
- * temperature: z.number(),
959
- * conditions: z.string(),
960
- * })
961
- * ```
962
- */
963
- outputSchema?: ZodTypeAny;
964
- /**
965
- * Zod schema for input validation.
966
- *
967
- * When provided in development mode (NODE_ENV !== 'production'),
968
- * the template will also validate {{input.*}} expressions.
969
- */
970
- inputSchema?: ZodTypeAny;
971
- }
972
- /**
973
- * Check if a value is a valid UIType.
974
- */
975
- export declare function isUIType(value: unknown): value is UIType;
976
- /**
977
- * Check if a value is a valid BundlingMode.
978
- */
979
- export declare function isBundlingMode(value: unknown): value is BundlingMode;
980
- /**
981
- * Check if a value is a valid ResourceMode.
982
- */
983
- export declare function isResourceMode(value: unknown): value is ResourceMode;
984
- /**
985
- * Check if a value is a valid DisplayMode.
986
- */
987
- export declare function isDisplayMode(value: unknown): value is DisplayMode;
988
- /**
989
- * Check if a value is a valid OutputMode.
990
- */
991
- export declare function isOutputMode(value: unknown): value is OutputMode;
992
- /**
993
- * Default CSP directives for different UI types.
994
- */
995
- export declare const DEFAULT_CSP_BY_TYPE: Record<UIType, CSPDirectives>;
996
- /**
997
- * Default renderer assets for different UI types.
998
- */
999
- export declare const DEFAULT_RENDERER_ASSETS: Record<UIType, Partial<RendererAssets>>;
1000
- /**
1001
- * React namespace declaration for type safety.
1002
- * This allows React.ComponentType to work without importing React.
1003
- */
1004
- declare namespace React {
1005
- type ComponentType<P = any> = (props: P) => any;
1006
- }
1007
- //# sourceMappingURL=ui-runtime.d.ts.map