@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,603 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // libs/ui/src/validation/index.ts
21
- var validation_exports = {};
22
- __export(validation_exports, {
23
- assertTemplateValid: () => assertTemplateValid,
24
- extractSchemaPaths: () => extractSchemaPaths,
25
- formatValidationWarnings: () => formatValidationWarnings,
26
- getMissingFields: () => getMissingFields,
27
- getPathInfo: () => getPathInfo,
28
- getRootFieldNames: () => getRootFieldNames,
29
- getSchemaPathStrings: () => getSchemaPathStrings,
30
- getTypeAtPath: () => getTypeAtPath,
31
- getTypeDescription: () => getTypeDescription,
32
- isTemplateValid: () => isTemplateValid,
33
- isValidSchemaPath: () => isValidSchemaPath,
34
- logValidationWarnings: () => logValidationWarnings,
35
- validateOptions: () => validateOptions,
36
- validateTemplate: () => validateTemplate,
37
- validationErrorBox: () => validationErrorBox
38
- });
39
- module.exports = __toCommonJS(validation_exports);
40
-
41
- // libs/ui/src/theme/platforms.ts
42
- var CLAUDE_PLATFORM = {
43
- id: "claude",
44
- name: "Claude (Artifacts)",
45
- supportsWidgets: true,
46
- supportsTailwind: true,
47
- supportsHtmx: false,
48
- // Network blocked, HTMX won't work for API calls
49
- networkMode: "blocked",
50
- scriptStrategy: "inline",
51
- maxInlineSize: 100 * 1024,
52
- // 100KB limit for artifacts
53
- cspRestrictions: ["script-src 'unsafe-inline'", "connect-src 'none'"],
54
- options: {
55
- mode: "artifacts",
56
- framework: "react"
57
- // Claude artifacts prefer React
58
- }
59
- };
60
-
61
- // libs/ui/src/utils/escape-html.ts
62
- function escapeHtml(str) {
63
- if (str === null || str === void 0) {
64
- return "";
65
- }
66
- const s = String(str);
67
- return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
68
- }
69
-
70
- // libs/ui/src/validation/error-box.ts
71
- var errorIcon = `<svg class="w-5 h-5 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true">
72
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"/>
73
- </svg>`;
74
- function validationErrorBox(options) {
75
- const { componentName, invalidParam } = options;
76
- return `<div
77
- class="validation-error flex items-start gap-3 p-4 bg-red-50 border border-red-200 text-red-800 rounded-lg"
78
- role="alert"
79
- data-testid="validation-error"
80
- data-component="${escapeHtml(componentName)}"
81
- data-param="${escapeHtml(invalidParam)}"
82
- >
83
- ${errorIcon}
84
- <div class="min-w-0">
85
- <p class="font-semibold text-sm">${escapeHtml(componentName)}: Invalid Configuration</p>
86
- <p class="text-sm opacity-90 mt-0.5">The "${escapeHtml(invalidParam)}" parameter is invalid.</p>
87
- </div>
88
- </div>`;
89
- }
90
-
91
- // libs/ui/src/validation/wrapper.ts
92
- function getFirstInvalidPath(error) {
93
- const firstError = error.issues[0];
94
- if (!firstError || firstError.path.length === 0) {
95
- return "options";
96
- }
97
- return firstError.path.map(String).join(".");
98
- }
99
- function validateOptions(options, config) {
100
- const result = config.schema.safeParse(options);
101
- if (result.success) {
102
- return { success: true, data: result.data };
103
- }
104
- const invalidParam = getFirstInvalidPath(result.error);
105
- return {
106
- success: false,
107
- error: validationErrorBox({
108
- componentName: config.componentName,
109
- invalidParam
110
- })
111
- };
112
- }
113
-
114
- // libs/ui/src/validation/schema-paths.ts
115
- var import_zod = require("zod");
116
- function extractSchemaPaths(schema, prefix = "output", options = {}) {
117
- const { maxDepth = 10, includeArrayItems = true } = options;
118
- const paths = [];
119
- const visited = /* @__PURE__ */ new Set();
120
- function recurse(currentSchema, currentPath, depth, isOptional, isNullable, isArrayItem) {
121
- if (depth > maxDepth) return;
122
- const pathKey = `${currentPath}:${depth}`;
123
- if (visited.has(pathKey)) return;
124
- visited.add(pathKey);
125
- const description = currentSchema.description;
126
- const innerType = unwrapType(currentSchema);
127
- paths.push({
128
- path: currentPath,
129
- zodType: currentSchema,
130
- optional: isOptional,
131
- nullable: isNullable,
132
- isArrayItem,
133
- description
134
- });
135
- if (innerType instanceof import_zod.z.ZodObject) {
136
- const shape = innerType.shape;
137
- for (const [key, value] of Object.entries(shape)) {
138
- const childSchema = value;
139
- const childOptional = isOptional || isOptionalType(childSchema);
140
- const childNullable = isNullable || isNullableType(childSchema);
141
- recurse(childSchema, `${currentPath}.${key}`, depth + 1, childOptional, childNullable, false);
142
- }
143
- } else if (innerType instanceof import_zod.z.ZodArray && includeArrayItems) {
144
- const itemSchema = innerType.element;
145
- recurse(itemSchema, `${currentPath}.[]`, depth + 1, isOptional, isNullable, true);
146
- } else if (innerType instanceof import_zod.z.ZodUnion || innerType instanceof import_zod.z.ZodDiscriminatedUnion) {
147
- const options2 = "options" in innerType ? innerType.options : [];
148
- for (const option of options2) {
149
- recurse(option, currentPath, depth, isOptional, isNullable, isArrayItem);
150
- }
151
- } else if (innerType instanceof import_zod.z.ZodIntersection) {
152
- recurse(innerType._def.left, currentPath, depth, isOptional, isNullable, isArrayItem);
153
- recurse(innerType._def.right, currentPath, depth, isOptional, isNullable, isArrayItem);
154
- } else if (innerType instanceof import_zod.z.ZodRecord) {
155
- const valueSchema = innerType._def.valueType;
156
- recurse(valueSchema, `${currentPath}.[]`, depth + 1, isOptional, isNullable, true);
157
- } else if (innerType instanceof import_zod.z.ZodTuple) {
158
- const items = innerType._def.items;
159
- items.forEach((item, index) => {
160
- recurse(item, `${currentPath}.${index}`, depth + 1, isOptional, isNullable, true);
161
- });
162
- }
163
- }
164
- recurse(schema, prefix, 0, false, false, false);
165
- const seen = /* @__PURE__ */ new Set();
166
- return paths.filter((p) => {
167
- if (seen.has(p.path)) return false;
168
- seen.add(p.path);
169
- return true;
170
- });
171
- }
172
- function unwrapType(schema) {
173
- if (schema instanceof import_zod.z.ZodOptional) {
174
- return unwrapType(schema.unwrap());
175
- }
176
- if (schema instanceof import_zod.z.ZodNullable) {
177
- return unwrapType(schema.unwrap());
178
- }
179
- if (schema instanceof import_zod.z.ZodDefault) {
180
- return unwrapType(schema._def.innerType);
181
- }
182
- if (schema instanceof import_zod.z.ZodCatch && "innerType" in schema._def) {
183
- return unwrapType(schema._def.innerType);
184
- }
185
- return schema;
186
- }
187
- function isOptionalType(schema) {
188
- if (schema instanceof import_zod.z.ZodOptional) return true;
189
- if (schema instanceof import_zod.z.ZodDefault) return true;
190
- if (schema instanceof import_zod.z.ZodNullable) return isOptionalType(schema.unwrap());
191
- return false;
192
- }
193
- function isNullableType(schema) {
194
- if (schema instanceof import_zod.z.ZodNullable) return true;
195
- if (schema instanceof import_zod.z.ZodOptional) return isNullableType(schema.unwrap());
196
- return false;
197
- }
198
- function getSchemaPathStrings(schema, prefix = "output") {
199
- const paths = extractSchemaPaths(schema, prefix);
200
- return new Set(paths.map((p) => p.path));
201
- }
202
- function isValidSchemaPath(schema, path) {
203
- const prefix = path.split(".")[0];
204
- const paths = getSchemaPathStrings(schema, prefix);
205
- if (paths.has(path)) return true;
206
- const normalizedPath = normalizePath(path);
207
- if (paths.has(normalizedPath)) return true;
208
- const pathParts = path.split(".");
209
- for (let i = pathParts.length - 1; i >= 0; i--) {
210
- const part = pathParts[i];
211
- if (/^\d+$/.test(part)) {
212
- const parentPath = pathParts.slice(0, i).join(".");
213
- const wildcardPath = `${parentPath}.[]`;
214
- if (paths.has(wildcardPath)) {
215
- const restPath = pathParts.slice(i + 1).join(".");
216
- if (restPath) {
217
- const fullWildcardPath = `${wildcardPath}.${restPath}`;
218
- const normalizedFullPath = normalizePath(fullWildcardPath);
219
- if (paths.has(normalizedFullPath)) return true;
220
- } else {
221
- return true;
222
- }
223
- }
224
- }
225
- }
226
- return false;
227
- }
228
- function normalizePath(path) {
229
- return path.replace(/\.\d+\./g, ".[].").replace(/\.\d+$/g, ".[]").replace(/\[\d+\]/g, ".[]");
230
- }
231
- function getTypeAtPath(schema, path) {
232
- const prefix = path.split(".")[0];
233
- const paths = extractSchemaPaths(schema, prefix);
234
- let schemaPath = paths.find((p) => p.path === path);
235
- if (!schemaPath) {
236
- const normalizedPath = normalizePath(path);
237
- schemaPath = paths.find((p) => p.path === normalizedPath);
238
- }
239
- return schemaPath?.zodType;
240
- }
241
- function getPathInfo(schema, path) {
242
- const prefix = path.split(".")[0];
243
- const paths = extractSchemaPaths(schema, prefix);
244
- let schemaPath = paths.find((p) => p.path === path);
245
- if (!schemaPath) {
246
- const normalizedPath = normalizePath(path);
247
- schemaPath = paths.find((p) => p.path === normalizedPath);
248
- }
249
- return schemaPath;
250
- }
251
- function getRootFieldNames(schema) {
252
- const unwrapped = unwrapType(schema);
253
- if (unwrapped instanceof import_zod.z.ZodObject) {
254
- return Object.keys(unwrapped.shape);
255
- }
256
- return [];
257
- }
258
- function getTypeDescription(schema, path) {
259
- const zodType = getTypeAtPath(schema, path);
260
- if (!zodType) return "unknown";
261
- return describeZodType(zodType);
262
- }
263
- function describeZodType(schema) {
264
- const inner = unwrapType(schema);
265
- if (inner instanceof import_zod.z.ZodString) return "string";
266
- if (inner instanceof import_zod.z.ZodNumber) return "number";
267
- if (inner instanceof import_zod.z.ZodBoolean) return "boolean";
268
- if (inner instanceof import_zod.z.ZodDate) return "Date";
269
- if (inner instanceof import_zod.z.ZodBigInt) return "bigint";
270
- if (inner instanceof import_zod.z.ZodSymbol) return "symbol";
271
- if (inner instanceof import_zod.z.ZodUndefined) return "undefined";
272
- if (inner instanceof import_zod.z.ZodNull) return "null";
273
- if (inner instanceof import_zod.z.ZodVoid) return "void";
274
- if (inner instanceof import_zod.z.ZodAny) return "any";
275
- if (inner instanceof import_zod.z.ZodUnknown) return "unknown";
276
- if (inner instanceof import_zod.z.ZodNever) return "never";
277
- if (inner instanceof import_zod.z.ZodLiteral) return `literal(${JSON.stringify(inner.value)})`;
278
- if (inner instanceof import_zod.z.ZodEnum) return `enum(${inner.options.join(" | ")})`;
279
- if (inner instanceof import_zod.z.ZodArray) return `${describeZodType(inner.element)}[]`;
280
- if (inner instanceof import_zod.z.ZodObject) return "object";
281
- if (inner instanceof import_zod.z.ZodUnion) return "union";
282
- if (inner instanceof import_zod.z.ZodDiscriminatedUnion) return "discriminatedUnion";
283
- if (inner instanceof import_zod.z.ZodIntersection) return "intersection";
284
- if (inner instanceof import_zod.z.ZodTuple) return "tuple";
285
- if (inner instanceof import_zod.z.ZodRecord) return `Record<string, ${describeZodType(inner._def.valueType)}>`;
286
- if (inner instanceof import_zod.z.ZodMap) return "Map";
287
- if (inner instanceof import_zod.z.ZodSet) return "Set";
288
- if (inner instanceof import_zod.z.ZodFunction) return "function";
289
- if (inner instanceof import_zod.z.ZodPromise) return "Promise";
290
- if (schema instanceof import_zod.z.ZodOptional) {
291
- return `${describeZodType(schema.unwrap())}?`;
292
- }
293
- if (schema instanceof import_zod.z.ZodNullable) {
294
- return `${describeZodType(schema.unwrap())} | null`;
295
- }
296
- return "unknown";
297
- }
298
-
299
- // libs/ui/src/handlebars/expression-extractor.ts
300
- var EXPRESSION_REGEX = /\{\{\{?(?!!)(#|\/)?([^}]+?)\}?\}\}/g;
301
- var PATH_REGEX = /\b(output|input|structuredContent)(\.[a-zA-Z_$][a-zA-Z0-9_$]*|\.\[[^\]]+\])+/g;
302
- var KEYWORDS = /* @__PURE__ */ new Set(["this", "else", "@index", "@key", "@first", "@last", "@root"]);
303
- function extractExpressions(template) {
304
- const expressions = [];
305
- const lines = template.split("\n");
306
- const positionMap = buildPositionMap(template);
307
- let match;
308
- EXPRESSION_REGEX.lastIndex = 0;
309
- while ((match = EXPRESSION_REGEX.exec(template)) !== null) {
310
- const fullExpression = match[0];
311
- const prefix = match[1];
312
- const content = match[2].trim();
313
- const position = positionMap.get(match.index) ?? { line: 1, column: 1 };
314
- let type = "variable";
315
- let helperName;
316
- if (prefix === "/") {
317
- type = "block-close";
318
- helperName = content;
319
- } else if (prefix === "#") {
320
- type = "block";
321
- const parts = content.split(/\s+/);
322
- helperName = parts[0];
323
- } else {
324
- const parts = content.split(/\s+/);
325
- if (parts.length > 1 && !content.startsWith("(")) {
326
- const firstToken = parts[0];
327
- if (!firstToken.includes(".") && !KEYWORDS.has(firstToken)) {
328
- type = "helper";
329
- helperName = firstToken;
330
- }
331
- }
332
- }
333
- const paths = extractPathsFromContent(content);
334
- for (const path of paths) {
335
- expressions.push({
336
- path,
337
- fullExpression,
338
- line: position.line,
339
- column: position.column,
340
- type,
341
- helperName
342
- });
343
- }
344
- if (paths.length === 0 && type === "variable") {
345
- const cleanContent = content.trim();
346
- if (!KEYWORDS.has(cleanContent) && !cleanContent.includes(" ") && !cleanContent.startsWith("(")) {
347
- }
348
- }
349
- }
350
- return expressions;
351
- }
352
- function extractPathsFromContent(content) {
353
- const paths = [];
354
- let match;
355
- const regex = new RegExp(PATH_REGEX.source, "g");
356
- while ((match = regex.exec(content)) !== null) {
357
- paths.push(match[0]);
358
- }
359
- return paths;
360
- }
361
- function buildPositionMap(template) {
362
- const map = /* @__PURE__ */ new Map();
363
- let line = 1;
364
- let column = 1;
365
- for (let i = 0; i < template.length; i++) {
366
- map.set(i, { line, column });
367
- if (template[i] === "\n") {
368
- line++;
369
- column = 1;
370
- } else {
371
- column++;
372
- }
373
- }
374
- return map;
375
- }
376
- function extractAll(template) {
377
- const expressions = extractExpressions(template);
378
- const paths = [...new Set(expressions.map((e) => e.path))];
379
- return {
380
- expressions,
381
- paths,
382
- outputPaths: paths.filter((p) => p.startsWith("output.")),
383
- inputPaths: paths.filter((p) => p.startsWith("input.")),
384
- structuredContentPaths: paths.filter((p) => p.startsWith("structuredContent."))
385
- };
386
- }
387
- function normalizePath2(path) {
388
- return path.replace(/\.\d+\./g, ".[].").replace(/\.\d+$/g, ".[]").replace(/\[\d+\]/g, ".[]");
389
- }
390
-
391
- // libs/ui/src/validation/template-validator.ts
392
- function validateTemplate(template, outputSchema, options = {}) {
393
- const { inputSchema, warnOnOptional = true, suggestSimilar = true, maxSuggestionDistance = 3 } = options;
394
- const errors = [];
395
- const warnings = [];
396
- const extraction = extractAll(template);
397
- const expressions = extractExpressions(template);
398
- const outputPaths = getSchemaPathStrings(outputSchema, "output");
399
- const inputPaths = inputSchema ? getSchemaPathStrings(inputSchema, "input") : /* @__PURE__ */ new Set();
400
- const outputPathInfos = extractSchemaPaths(outputSchema, "output");
401
- const inputPathInfos = inputSchema ? extractSchemaPaths(inputSchema, "input") : [];
402
- const pathInfoMap = /* @__PURE__ */ new Map();
403
- for (const info of [...outputPathInfos, ...inputPathInfos]) {
404
- pathInfoMap.set(info.path, info);
405
- }
406
- for (const expr of expressions) {
407
- const { path, fullExpression, line, column } = expr;
408
- let validPaths;
409
- let allPaths;
410
- if (path.startsWith("output.")) {
411
- validPaths = outputPaths;
412
- allPaths = Array.from(outputPaths);
413
- } else if (path.startsWith("input.")) {
414
- if (!inputSchema) {
415
- continue;
416
- }
417
- validPaths = inputPaths;
418
- allPaths = Array.from(inputPaths);
419
- } else if (path.startsWith("structuredContent.")) {
420
- continue;
421
- } else {
422
- continue;
423
- }
424
- const normalizedPath = normalizePath2(path);
425
- const isValid = validPaths.has(path) || validPaths.has(normalizedPath);
426
- if (!isValid) {
427
- const isArrayAccess = checkArrayAccess(path, validPaths);
428
- if (!isArrayAccess) {
429
- const suggestions = suggestSimilar ? findSimilarPaths(path, allPaths, maxSuggestionDistance) : [];
430
- errors.push({
431
- type: "missing_field",
432
- path,
433
- expression: fullExpression,
434
- line,
435
- column,
436
- message: `Field '${getFieldName(path)}' does not exist in ${getSchemaName(path)} schema`,
437
- suggestions
438
- });
439
- }
440
- } else {
441
- const pathInfo = pathInfoMap.get(path) ?? pathInfoMap.get(normalizedPath);
442
- if (pathInfo && warnOnOptional) {
443
- if (pathInfo.optional && expr.type === "variable") {
444
- const hasGuard = hasConditionalGuard(template, path);
445
- if (!hasGuard) {
446
- warnings.push({
447
- type: "optional_field",
448
- path,
449
- expression: fullExpression,
450
- line,
451
- message: `Accessing optional field '${getFieldName(path)}' without {{#if}} guard`
452
- });
453
- }
454
- }
455
- }
456
- }
457
- }
458
- return {
459
- valid: errors.length === 0,
460
- errors,
461
- warnings,
462
- templatePaths: extraction.paths,
463
- schemaPaths: [...outputPaths, ...inputPaths]
464
- };
465
- }
466
- function checkArrayAccess(path, validPaths) {
467
- const parts = path.split(".");
468
- for (let i = 0; i < parts.length; i++) {
469
- if (/^\d+$/.test(parts[i])) {
470
- const wildcardParts = [...parts];
471
- wildcardParts[i] = "[]";
472
- const wildcardPath = wildcardParts.join(".");
473
- if (validPaths.has(wildcardPath)) {
474
- return true;
475
- }
476
- }
477
- }
478
- return false;
479
- }
480
- function getFieldName(path) {
481
- const parts = path.split(".");
482
- return parts[parts.length - 1];
483
- }
484
- function getSchemaName(path) {
485
- if (path.startsWith("output.")) return "output";
486
- if (path.startsWith("input.")) return "input";
487
- if (path.startsWith("structuredContent.")) return "structuredContent";
488
- return "unknown";
489
- }
490
- function hasConditionalGuard(template, path) {
491
- const guardPattern = new RegExp(`\\{\\{#if\\s+${escapeRegex(path)}`, "i");
492
- return guardPattern.test(template);
493
- }
494
- function escapeRegex(str) {
495
- return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
496
- }
497
- function findSimilarPaths(path, validPaths, maxDistance) {
498
- const fieldName = getFieldName(path);
499
- const prefix = path.substring(0, path.lastIndexOf(".") + 1);
500
- const suggestions = [];
501
- for (const validPath of validPaths) {
502
- if (!validPath.startsWith(prefix)) continue;
503
- const validFieldName = getFieldName(validPath);
504
- const distance = levenshteinDistance(fieldName, validFieldName);
505
- if (distance <= maxDistance && distance > 0) {
506
- suggestions.push({ path: validPath, distance });
507
- }
508
- }
509
- return suggestions.sort((a, b) => a.distance - b.distance).slice(0, 3).map((s) => s.path);
510
- }
511
- function levenshteinDistance(a, b) {
512
- const matrix = [];
513
- for (let i = 0; i <= a.length; i++) {
514
- matrix[i] = [i];
515
- }
516
- for (let j = 0; j <= b.length; j++) {
517
- matrix[0][j] = j;
518
- }
519
- for (let i = 1; i <= a.length; i++) {
520
- for (let j = 1; j <= b.length; j++) {
521
- const cost = a[i - 1] === b[j - 1] ? 0 : 1;
522
- matrix[i][j] = Math.min(
523
- matrix[i - 1][j] + 1,
524
- // deletion
525
- matrix[i][j - 1] + 1,
526
- // insertion
527
- matrix[i - 1][j - 1] + cost
528
- // substitution
529
- );
530
- }
531
- }
532
- return matrix[a.length][b.length];
533
- }
534
- function formatValidationWarnings(result, toolName) {
535
- if (result.valid && result.warnings.length === 0) {
536
- return "";
537
- }
538
- const lines = [];
539
- if (result.errors.length > 0) {
540
- lines.push(`[FrontMCP] Template validation warnings for tool "${toolName}":`);
541
- lines.push("");
542
- for (const error of result.errors) {
543
- lines.push(` Line ${error.line}: ${error.expression}`);
544
- lines.push(` ${error.message}`);
545
- if (error.suggestions.length > 0) {
546
- lines.push(` Did you mean: ${error.suggestions.join(", ")}?`);
547
- }
548
- lines.push("");
549
- }
550
- const outputFields = result.schemaPaths.filter((p) => p.startsWith("output.") && p.split(".").length === 2).map((p) => p.replace("output.", ""));
551
- if (outputFields.length > 0) {
552
- lines.push(` Available output fields: ${outputFields.join(", ")}`);
553
- }
554
- }
555
- if (result.warnings.length > 0) {
556
- if (lines.length > 0) lines.push("");
557
- lines.push(` Warnings:`);
558
- for (const warning of result.warnings) {
559
- lines.push(` Line ${warning.line}: ${warning.message}`);
560
- }
561
- }
562
- return lines.join("\n");
563
- }
564
- function logValidationWarnings(result, toolName) {
565
- const formatted = formatValidationWarnings(result, toolName);
566
- if (formatted) {
567
- console.warn(formatted);
568
- }
569
- }
570
- function assertTemplateValid(template, outputSchema, toolName) {
571
- const result = validateTemplate(template, outputSchema);
572
- if (!result.valid) {
573
- const formatted = formatValidationWarnings(result, toolName);
574
- throw new Error(`Template validation failed for tool "${toolName}":
575
- ${formatted}`);
576
- }
577
- }
578
- function isTemplateValid(template, outputSchema) {
579
- const result = validateTemplate(template, outputSchema);
580
- return result.valid;
581
- }
582
- function getMissingFields(template, outputSchema) {
583
- const result = validateTemplate(template, outputSchema);
584
- return result.errors.map((e) => e.path);
585
- }
586
- // Annotate the CommonJS export names for ESM import in node:
587
- 0 && (module.exports = {
588
- assertTemplateValid,
589
- extractSchemaPaths,
590
- formatValidationWarnings,
591
- getMissingFields,
592
- getPathInfo,
593
- getRootFieldNames,
594
- getSchemaPathStrings,
595
- getTypeAtPath,
596
- getTypeDescription,
597
- isTemplateValid,
598
- isValidSchemaPath,
599
- logValidationWarnings,
600
- validateOptions,
601
- validateTemplate,
602
- validationErrorBox
603
- });