@copilotkit/shared 2.0.0-rc.5 → 2.0.0-rc.51

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 (569) hide show
  1. package/README.md +4 -15
  2. package/dist/a2ui-envelope.cjs +3 -3
  3. package/dist/a2ui-envelope.cjs.map +1 -1
  4. package/dist/a2ui-envelope.d.cts +1 -1
  5. package/dist/a2ui-envelope.d.cts.map +1 -1
  6. package/dist/a2ui-envelope.d.mts +1 -1
  7. package/dist/a2ui-envelope.d.mts.map +1 -1
  8. package/dist/a2ui-envelope.mjs +3 -3
  9. package/dist/a2ui-envelope.mjs.map +1 -1
  10. package/dist/a2ui-prompts.cjs +21 -62
  11. package/dist/a2ui-prompts.cjs.map +1 -1
  12. package/dist/a2ui-prompts.d.cts +8 -1
  13. package/dist/a2ui-prompts.d.cts.map +1 -1
  14. package/dist/a2ui-prompts.d.mts +8 -1
  15. package/dist/a2ui-prompts.d.mts.map +1 -1
  16. package/dist/a2ui-prompts.mjs +22 -62
  17. package/dist/a2ui-prompts.mjs.map +1 -1
  18. package/dist/attachments/types.d.cts +1 -3
  19. package/dist/attachments/types.d.cts.map +1 -1
  20. package/dist/attachments/types.d.mts +1 -3
  21. package/dist/attachments/types.d.mts.map +1 -1
  22. package/dist/attachments/utils.cjs +16 -5
  23. package/dist/attachments/utils.cjs.map +1 -1
  24. package/dist/attachments/utils.d.cts +3 -1
  25. package/dist/attachments/utils.d.cts.map +1 -1
  26. package/dist/attachments/utils.d.mts +3 -1
  27. package/dist/attachments/utils.d.mts.map +1 -1
  28. package/dist/attachments/utils.mjs +16 -5
  29. package/dist/attachments/utils.mjs.map +1 -1
  30. package/dist/finalize-events.cjs +16 -0
  31. package/dist/finalize-events.cjs.map +1 -1
  32. package/dist/finalize-events.d.cts.map +1 -1
  33. package/dist/finalize-events.d.mts.map +1 -1
  34. package/dist/finalize-events.mjs +16 -0
  35. package/dist/finalize-events.mjs.map +1 -1
  36. package/dist/generative-ui/basic-functions.cjs +1 -1
  37. package/dist/generative-ui/basic-functions.cjs.map +1 -1
  38. package/dist/generative-ui/basic-functions.mjs +1 -1
  39. package/dist/generative-ui/basic-functions.mjs.map +1 -1
  40. package/dist/generative-ui/catalog/catalog-export.cjs +329 -0
  41. package/dist/generative-ui/catalog/catalog-export.cjs.map +1 -0
  42. package/dist/generative-ui/catalog/catalog-export.d.cts +92 -0
  43. package/dist/generative-ui/catalog/catalog-export.d.cts.map +1 -0
  44. package/dist/generative-ui/catalog/catalog-export.d.mts +92 -0
  45. package/dist/generative-ui/catalog/catalog-export.d.mts.map +1 -0
  46. package/dist/generative-ui/catalog/catalog-export.mjs +328 -0
  47. package/dist/generative-ui/catalog/catalog-export.mjs.map +1 -0
  48. package/dist/generative-ui/catalog/catalog.cjs +315 -0
  49. package/dist/generative-ui/catalog/catalog.cjs.map +1 -0
  50. package/dist/generative-ui/catalog/catalog.d.cts +407 -0
  51. package/dist/generative-ui/catalog/catalog.d.cts.map +1 -0
  52. package/dist/generative-ui/catalog/catalog.d.mts +407 -0
  53. package/dist/generative-ui/catalog/catalog.d.mts.map +1 -0
  54. package/dist/generative-ui/catalog/catalog.mjs +312 -0
  55. package/dist/generative-ui/catalog/catalog.mjs.map +1 -0
  56. package/dist/generative-ui/catalog/errors.cjs +13 -0
  57. package/dist/generative-ui/catalog/errors.cjs.map +1 -0
  58. package/dist/generative-ui/catalog/errors.d.cts +46 -0
  59. package/dist/generative-ui/catalog/errors.d.cts.map +1 -0
  60. package/dist/generative-ui/catalog/errors.d.mts +46 -0
  61. package/dist/generative-ui/catalog/errors.d.mts.map +1 -0
  62. package/dist/generative-ui/catalog/errors.mjs +12 -0
  63. package/dist/generative-ui/catalog/errors.mjs.map +1 -0
  64. package/dist/generative-ui/catalog/index.d.mts +6 -0
  65. package/dist/generative-ui/catalog/json-schema.cjs +16 -0
  66. package/dist/generative-ui/catalog/json-schema.cjs.map +1 -0
  67. package/dist/generative-ui/catalog/json-schema.d.cts +12 -0
  68. package/dist/generative-ui/catalog/json-schema.d.cts.map +1 -0
  69. package/dist/generative-ui/catalog/json-schema.d.mts +12 -0
  70. package/dist/generative-ui/catalog/json-schema.d.mts.map +1 -0
  71. package/dist/generative-ui/catalog/json-schema.mjs +16 -0
  72. package/dist/generative-ui/catalog/json-schema.mjs.map +1 -0
  73. package/dist/generative-ui/catalog/refs.cjs +21 -0
  74. package/dist/generative-ui/catalog/refs.cjs.map +1 -0
  75. package/dist/generative-ui/catalog/refs.d.cts +55 -0
  76. package/dist/generative-ui/catalog/refs.d.cts.map +1 -0
  77. package/dist/generative-ui/catalog/refs.d.mts +55 -0
  78. package/dist/generative-ui/catalog/refs.d.mts.map +1 -0
  79. package/dist/generative-ui/catalog/refs.mjs +18 -0
  80. package/dist/generative-ui/catalog/refs.mjs.map +1 -0
  81. package/dist/generative-ui/catalog/schema.cjs +74 -0
  82. package/dist/generative-ui/catalog/schema.cjs.map +1 -0
  83. package/dist/generative-ui/catalog/schema.d.cts +43 -0
  84. package/dist/generative-ui/catalog/schema.d.cts.map +1 -0
  85. package/dist/generative-ui/catalog/schema.d.mts +43 -0
  86. package/dist/generative-ui/catalog/schema.d.mts.map +1 -0
  87. package/dist/generative-ui/catalog/schema.mjs +68 -0
  88. package/dist/generative-ui/catalog/schema.mjs.map +1 -0
  89. package/dist/generative-ui/child-refs.cjs +3 -3
  90. package/dist/generative-ui/child-refs.cjs.map +1 -1
  91. package/dist/generative-ui/child-refs.d.cts.map +1 -1
  92. package/dist/generative-ui/child-refs.d.mts.map +1 -1
  93. package/dist/generative-ui/child-refs.mjs +3 -3
  94. package/dist/generative-ui/child-refs.mjs.map +1 -1
  95. package/dist/generative-ui/clone-value.cjs +364 -0
  96. package/dist/generative-ui/clone-value.cjs.map +1 -0
  97. package/dist/generative-ui/clone-value.d.cts +51 -0
  98. package/dist/generative-ui/clone-value.d.cts.map +1 -0
  99. package/dist/generative-ui/clone-value.d.mts +51 -0
  100. package/dist/generative-ui/clone-value.d.mts.map +1 -0
  101. package/dist/generative-ui/clone-value.mjs +363 -0
  102. package/dist/generative-ui/clone-value.mjs.map +1 -0
  103. package/dist/generative-ui/compact-schema.cjs +187 -0
  104. package/dist/generative-ui/compact-schema.cjs.map +1 -0
  105. package/dist/generative-ui/compact-schema.d.cts +55 -0
  106. package/dist/generative-ui/compact-schema.d.cts.map +1 -0
  107. package/dist/generative-ui/compact-schema.d.mts +55 -0
  108. package/dist/generative-ui/compact-schema.d.mts.map +1 -0
  109. package/dist/generative-ui/compact-schema.mjs +185 -0
  110. package/dist/generative-ui/compact-schema.mjs.map +1 -0
  111. package/dist/generative-ui/index.cjs +286 -0
  112. package/dist/generative-ui/index.d.cts +39 -0
  113. package/dist/generative-ui/index.d.mts +41 -0
  114. package/dist/generative-ui/index.mjs +40 -0
  115. package/dist/generative-ui/is-record.cjs +6 -1
  116. package/dist/generative-ui/is-record.cjs.map +1 -1
  117. package/dist/generative-ui/is-record.d.cts +8 -0
  118. package/dist/generative-ui/is-record.d.cts.map +1 -0
  119. package/dist/generative-ui/is-record.d.mts +8 -0
  120. package/dist/generative-ui/is-record.d.mts.map +1 -0
  121. package/dist/generative-ui/is-record.mjs +6 -2
  122. package/dist/generative-ui/is-record.mjs.map +1 -1
  123. package/dist/generative-ui/prompt-spec.cjs +225 -0
  124. package/dist/generative-ui/prompt-spec.cjs.map +1 -0
  125. package/dist/generative-ui/prompt-spec.d.cts +94 -0
  126. package/dist/generative-ui/prompt-spec.d.cts.map +1 -0
  127. package/dist/generative-ui/prompt-spec.d.mts +94 -0
  128. package/dist/generative-ui/prompt-spec.d.mts.map +1 -0
  129. package/dist/generative-ui/prompt-spec.mjs +220 -0
  130. package/dist/generative-ui/prompt-spec.mjs.map +1 -0
  131. package/dist/generative-ui/prompt.cjs +10 -36
  132. package/dist/generative-ui/prompt.cjs.map +1 -1
  133. package/dist/generative-ui/prompt.d.cts +2 -1
  134. package/dist/generative-ui/prompt.d.cts.map +1 -1
  135. package/dist/generative-ui/prompt.d.mts +2 -1
  136. package/dist/generative-ui/prompt.d.mts.map +1 -1
  137. package/dist/generative-ui/prompt.mjs +12 -38
  138. package/dist/generative-ui/prompt.mjs.map +1 -1
  139. package/dist/generative-ui/render-ui-args.cjs +1 -0
  140. package/dist/generative-ui/render-ui-args.cjs.map +1 -1
  141. package/dist/generative-ui/render-ui-args.d.cts.map +1 -1
  142. package/dist/generative-ui/render-ui-args.d.mts.map +1 -1
  143. package/dist/generative-ui/render-ui-args.mjs +1 -0
  144. package/dist/generative-ui/render-ui-args.mjs.map +1 -1
  145. package/dist/generative-ui/schema-render.cjs +243 -0
  146. package/dist/generative-ui/schema-render.cjs.map +1 -0
  147. package/dist/generative-ui/schema-render.d.cts +44 -0
  148. package/dist/generative-ui/schema-render.d.cts.map +1 -0
  149. package/dist/generative-ui/schema-render.d.mts +44 -0
  150. package/dist/generative-ui/schema-render.d.mts.map +1 -0
  151. package/dist/generative-ui/schema-render.mjs +240 -0
  152. package/dist/generative-ui/schema-render.mjs.map +1 -0
  153. package/dist/generative-ui/standard/chart-config.cjs +347 -0
  154. package/dist/generative-ui/standard/chart-config.cjs.map +1 -0
  155. package/dist/generative-ui/standard/chart-config.d.cts +97 -0
  156. package/dist/generative-ui/standard/chart-config.d.cts.map +1 -0
  157. package/dist/generative-ui/standard/chart-config.d.mts +97 -0
  158. package/dist/generative-ui/standard/chart-config.d.mts.map +1 -0
  159. package/dist/generative-ui/standard/chart-config.mjs +342 -0
  160. package/dist/generative-ui/standard/chart-config.mjs.map +1 -0
  161. package/dist/generative-ui/standard/chart.cjs +56 -0
  162. package/dist/generative-ui/standard/chart.cjs.map +1 -0
  163. package/dist/generative-ui/standard/chart.d.cts +62 -0
  164. package/dist/generative-ui/standard/chart.d.cts.map +1 -0
  165. package/dist/generative-ui/standard/chart.d.mts +62 -0
  166. package/dist/generative-ui/standard/chart.d.mts.map +1 -0
  167. package/dist/generative-ui/standard/chart.mjs +54 -0
  168. package/dist/generative-ui/standard/chart.mjs.map +1 -0
  169. package/dist/generative-ui/standard/checks.cjs +74 -0
  170. package/dist/generative-ui/standard/checks.cjs.map +1 -0
  171. package/dist/generative-ui/standard/checks.d.cts +56 -0
  172. package/dist/generative-ui/standard/checks.d.cts.map +1 -0
  173. package/dist/generative-ui/standard/checks.d.mts +56 -0
  174. package/dist/generative-ui/standard/checks.d.mts.map +1 -0
  175. package/dist/generative-ui/standard/checks.mjs +71 -0
  176. package/dist/generative-ui/standard/checks.mjs.map +1 -0
  177. package/dist/generative-ui/standard/components.cjs +23 -0
  178. package/dist/generative-ui/standard/components.cjs.map +1 -0
  179. package/dist/generative-ui/standard/components.d.cts +24 -0
  180. package/dist/generative-ui/standard/components.d.cts.map +1 -0
  181. package/dist/generative-ui/standard/components.d.mts +24 -0
  182. package/dist/generative-ui/standard/components.d.mts.map +1 -0
  183. package/dist/generative-ui/standard/components.mjs +22 -0
  184. package/dist/generative-ui/standard/components.mjs.map +1 -0
  185. package/dist/generative-ui/standard/composites.cjs +143 -0
  186. package/dist/generative-ui/standard/composites.cjs.map +1 -0
  187. package/dist/generative-ui/standard/composites.d.cts +233 -0
  188. package/dist/generative-ui/standard/composites.d.cts.map +1 -0
  189. package/dist/generative-ui/standard/composites.d.mts +233 -0
  190. package/dist/generative-ui/standard/composites.d.mts.map +1 -0
  191. package/dist/generative-ui/standard/composites.mjs +132 -0
  192. package/dist/generative-ui/standard/composites.mjs.map +1 -0
  193. package/dist/generative-ui/standard/data.cjs +176 -0
  194. package/dist/generative-ui/standard/data.cjs.map +1 -0
  195. package/dist/generative-ui/standard/data.d.cts +365 -0
  196. package/dist/generative-ui/standard/data.d.cts.map +1 -0
  197. package/dist/generative-ui/standard/data.d.mts +365 -0
  198. package/dist/generative-ui/standard/data.d.mts.map +1 -0
  199. package/dist/generative-ui/standard/data.mjs +167 -0
  200. package/dist/generative-ui/standard/data.mjs.map +1 -0
  201. package/dist/generative-ui/standard/declarations.cjs +40 -0
  202. package/dist/generative-ui/standard/declarations.cjs.map +1 -0
  203. package/dist/generative-ui/standard/declarations.d.cts +2570 -0
  204. package/dist/generative-ui/standard/declarations.d.cts.map +1 -0
  205. package/dist/generative-ui/standard/declarations.d.mts +2571 -0
  206. package/dist/generative-ui/standard/declarations.d.mts.map +1 -0
  207. package/dist/generative-ui/standard/declarations.mjs +39 -0
  208. package/dist/generative-ui/standard/declarations.mjs.map +1 -0
  209. package/dist/generative-ui/standard/feedback.cjs +97 -0
  210. package/dist/generative-ui/standard/feedback.cjs.map +1 -0
  211. package/dist/generative-ui/standard/feedback.d.cts +133 -0
  212. package/dist/generative-ui/standard/feedback.d.cts.map +1 -0
  213. package/dist/generative-ui/standard/feedback.d.mts +133 -0
  214. package/dist/generative-ui/standard/feedback.d.mts.map +1 -0
  215. package/dist/generative-ui/standard/feedback.mjs +90 -0
  216. package/dist/generative-ui/standard/feedback.mjs.map +1 -0
  217. package/dist/generative-ui/standard/index.d.mts +20 -0
  218. package/dist/generative-ui/standard/inputs.cjs +333 -0
  219. package/dist/generative-ui/standard/inputs.cjs.map +1 -0
  220. package/dist/generative-ui/standard/inputs.d.cts +1128 -0
  221. package/dist/generative-ui/standard/inputs.d.cts.map +1 -0
  222. package/dist/generative-ui/standard/inputs.d.mts +1128 -0
  223. package/dist/generative-ui/standard/inputs.d.mts.map +1 -0
  224. package/dist/generative-ui/standard/inputs.mjs +318 -0
  225. package/dist/generative-ui/standard/inputs.mjs.map +1 -0
  226. package/dist/generative-ui/standard/layout.cjs +289 -0
  227. package/dist/generative-ui/standard/layout.cjs.map +1 -0
  228. package/dist/generative-ui/standard/layout.d.cts +1974 -0
  229. package/dist/generative-ui/standard/layout.d.cts.map +1 -0
  230. package/dist/generative-ui/standard/layout.d.mts +1975 -0
  231. package/dist/generative-ui/standard/layout.d.mts.map +1 -0
  232. package/dist/generative-ui/standard/layout.mjs +269 -0
  233. package/dist/generative-ui/standard/layout.mjs.map +1 -0
  234. package/dist/generative-ui/standard/map-helpers.cjs +104 -0
  235. package/dist/generative-ui/standard/map-helpers.cjs.map +1 -0
  236. package/dist/generative-ui/standard/map-helpers.d.cts +88 -0
  237. package/dist/generative-ui/standard/map-helpers.d.cts.map +1 -0
  238. package/dist/generative-ui/standard/map-helpers.d.mts +88 -0
  239. package/dist/generative-ui/standard/map-helpers.d.mts.map +1 -0
  240. package/dist/generative-ui/standard/map-helpers.mjs +95 -0
  241. package/dist/generative-ui/standard/map-helpers.mjs.map +1 -0
  242. package/dist/generative-ui/standard/map.cjs +27 -0
  243. package/dist/generative-ui/standard/map.cjs.map +1 -0
  244. package/dist/generative-ui/standard/map.d.cts +31 -0
  245. package/dist/generative-ui/standard/map.d.cts.map +1 -0
  246. package/dist/generative-ui/standard/map.d.mts +31 -0
  247. package/dist/generative-ui/standard/map.d.mts.map +1 -0
  248. package/dist/generative-ui/standard/map.mjs +25 -0
  249. package/dist/generative-ui/standard/map.mjs.map +1 -0
  250. package/dist/generative-ui/standard/media.cjs +215 -0
  251. package/dist/generative-ui/standard/media.cjs.map +1 -0
  252. package/dist/generative-ui/standard/media.d.cts +396 -0
  253. package/dist/generative-ui/standard/media.d.cts.map +1 -0
  254. package/dist/generative-ui/standard/media.d.mts +396 -0
  255. package/dist/generative-ui/standard/media.d.mts.map +1 -0
  256. package/dist/generative-ui/standard/media.mjs +205 -0
  257. package/dist/generative-ui/standard/media.mjs.map +1 -0
  258. package/dist/generative-ui/standard/parameter-order.cjs +231 -0
  259. package/dist/generative-ui/standard/parameter-order.cjs.map +1 -0
  260. package/dist/generative-ui/standard/parameter-order.d.cts +84 -0
  261. package/dist/generative-ui/standard/parameter-order.d.cts.map +1 -0
  262. package/dist/generative-ui/standard/parameter-order.d.mts +84 -0
  263. package/dist/generative-ui/standard/parameter-order.d.mts.map +1 -0
  264. package/dist/generative-ui/standard/parameter-order.mjs +230 -0
  265. package/dist/generative-ui/standard/parameter-order.mjs.map +1 -0
  266. package/dist/generative-ui/standard/style-helpers.cjs +151 -0
  267. package/dist/generative-ui/standard/style-helpers.cjs.map +1 -0
  268. package/dist/generative-ui/standard/style-helpers.d.cts +56 -0
  269. package/dist/generative-ui/standard/style-helpers.d.cts.map +1 -0
  270. package/dist/generative-ui/standard/style-helpers.d.mts +56 -0
  271. package/dist/generative-ui/standard/style-helpers.d.mts.map +1 -0
  272. package/dist/generative-ui/standard/style-helpers.mjs +142 -0
  273. package/dist/generative-ui/standard/style-helpers.mjs.map +1 -0
  274. package/dist/generative-ui/standard/styles.cjs +62 -0
  275. package/dist/generative-ui/standard/styles.cjs.map +1 -0
  276. package/dist/generative-ui/standard/styles.d.cts +17 -0
  277. package/dist/generative-ui/standard/styles.d.cts.map +1 -0
  278. package/dist/generative-ui/standard/styles.d.mts +17 -0
  279. package/dist/generative-ui/standard/styles.d.mts.map +1 -0
  280. package/dist/generative-ui/standard/styles.mjs +60 -0
  281. package/dist/generative-ui/standard/styles.mjs.map +1 -0
  282. package/dist/generative-ui/standard/text.cjs +226 -0
  283. package/dist/generative-ui/standard/text.cjs.map +1 -0
  284. package/dist/generative-ui/standard/text.d.cts +522 -0
  285. package/dist/generative-ui/standard/text.d.cts.map +1 -0
  286. package/dist/generative-ui/standard/text.d.mts +522 -0
  287. package/dist/generative-ui/standard/text.d.mts.map +1 -0
  288. package/dist/generative-ui/standard/text.mjs +209 -0
  289. package/dist/generative-ui/standard/text.mjs.map +1 -0
  290. package/dist/generative-ui/standard/theme.cjs +115 -0
  291. package/dist/generative-ui/standard/theme.cjs.map +1 -0
  292. package/dist/generative-ui/standard/theme.d.cts +60 -0
  293. package/dist/generative-ui/standard/theme.d.cts.map +1 -0
  294. package/dist/generative-ui/standard/theme.d.mts +60 -0
  295. package/dist/generative-ui/standard/theme.d.mts.map +1 -0
  296. package/dist/generative-ui/standard/theme.mjs +112 -0
  297. package/dist/generative-ui/standard/theme.mjs.map +1 -0
  298. package/dist/generative-ui/standard/tokens.cjs +336 -0
  299. package/dist/generative-ui/standard/tokens.cjs.map +1 -0
  300. package/dist/generative-ui/standard/tokens.d.cts +76 -0
  301. package/dist/generative-ui/standard/tokens.d.cts.map +1 -0
  302. package/dist/generative-ui/standard/tokens.d.mts +76 -0
  303. package/dist/generative-ui/standard/tokens.d.mts.map +1 -0
  304. package/dist/generative-ui/standard/tokens.mjs +305 -0
  305. package/dist/generative-ui/standard/tokens.mjs.map +1 -0
  306. package/dist/generative-ui/standard/url.cjs +54 -0
  307. package/dist/generative-ui/standard/url.cjs.map +1 -0
  308. package/dist/generative-ui/standard/url.d.cts +32 -0
  309. package/dist/generative-ui/standard/url.d.cts.map +1 -0
  310. package/dist/generative-ui/standard/url.d.mts +32 -0
  311. package/dist/generative-ui/standard/url.d.mts.map +1 -0
  312. package/dist/generative-ui/standard/url.mjs +50 -0
  313. package/dist/generative-ui/standard/url.mjs.map +1 -0
  314. package/dist/generative-ui/thrown.cjs +69 -0
  315. package/dist/generative-ui/thrown.cjs.map +1 -0
  316. package/dist/generative-ui/thrown.d.cts +21 -0
  317. package/dist/generative-ui/thrown.d.cts.map +1 -0
  318. package/dist/generative-ui/thrown.d.mts +21 -0
  319. package/dist/generative-ui/thrown.d.mts.map +1 -0
  320. package/dist/generative-ui/thrown.mjs +67 -0
  321. package/dist/generative-ui/thrown.mjs.map +1 -0
  322. package/dist/generative-ui/types.cjs +2 -2
  323. package/dist/generative-ui/types.cjs.map +1 -1
  324. package/dist/generative-ui/types.d.cts +20 -7
  325. package/dist/generative-ui/types.d.cts.map +1 -1
  326. package/dist/generative-ui/types.d.mts +20 -7
  327. package/dist/generative-ui/types.d.mts.map +1 -1
  328. package/dist/generative-ui/types.mjs +2 -2
  329. package/dist/generative-ui/types.mjs.map +1 -1
  330. package/dist/generative-ui/validate-operation.cjs +2 -2
  331. package/dist/generative-ui/validate-operation.cjs.map +1 -1
  332. package/dist/generative-ui/validate-operation.mjs +2 -2
  333. package/dist/generative-ui/validate-operation.mjs.map +1 -1
  334. package/dist/index.cjs +18 -15
  335. package/dist/index.cjs.map +1 -1
  336. package/dist/index.d.cts +18 -17
  337. package/dist/index.d.cts.map +1 -1
  338. package/dist/index.d.mts +18 -17
  339. package/dist/index.d.mts.map +1 -1
  340. package/dist/index.mjs +10 -8
  341. package/dist/index.mjs.map +1 -1
  342. package/dist/index.umd.js +1233 -456
  343. package/dist/index.umd.js.map +1 -1
  344. package/dist/package.cjs +1 -1
  345. package/dist/package.mjs +1 -1
  346. package/dist/standard-schema.cjs +20 -7
  347. package/dist/standard-schema.cjs.map +1 -1
  348. package/dist/standard-schema.d.cts +15 -16
  349. package/dist/standard-schema.d.cts.map +1 -1
  350. package/dist/standard-schema.d.mts +15 -16
  351. package/dist/standard-schema.d.mts.map +1 -1
  352. package/dist/standard-schema.mjs +20 -8
  353. package/dist/standard-schema.mjs.map +1 -1
  354. package/dist/telemetry/lambda-client.cjs +1 -1
  355. package/dist/telemetry/lambda-client.cjs.map +1 -1
  356. package/dist/telemetry/lambda-client.d.cts.map +1 -1
  357. package/dist/telemetry/lambda-client.d.mts.map +1 -1
  358. package/dist/telemetry/lambda-client.mjs +1 -1
  359. package/dist/telemetry/lambda-client.mjs.map +1 -1
  360. package/dist/telemetry/telemetry-disabled.cjs +0 -5
  361. package/dist/telemetry/telemetry-disabled.cjs.map +1 -1
  362. package/dist/telemetry/telemetry-disabled.d.cts +0 -5
  363. package/dist/telemetry/telemetry-disabled.d.cts.map +1 -1
  364. package/dist/telemetry/telemetry-disabled.d.mts +0 -5
  365. package/dist/telemetry/telemetry-disabled.d.mts.map +1 -1
  366. package/dist/telemetry/telemetry-disabled.mjs +0 -5
  367. package/dist/telemetry/telemetry-disabled.mjs.map +1 -1
  368. package/dist/types/message.d.cts +1 -18
  369. package/dist/types/message.d.cts.map +1 -1
  370. package/dist/types/message.d.mts +1 -18
  371. package/dist/types/message.d.mts.map +1 -1
  372. package/dist/utils/errors.cjs +5 -42
  373. package/dist/utils/errors.cjs.map +1 -1
  374. package/dist/utils/errors.d.cts +16 -34
  375. package/dist/utils/errors.d.cts.map +1 -1
  376. package/dist/utils/errors.d.mts +16 -34
  377. package/dist/utils/errors.d.mts.map +1 -1
  378. package/dist/utils/errors.mjs +6 -41
  379. package/dist/utils/errors.mjs.map +1 -1
  380. package/dist/utils/index.cjs +0 -2
  381. package/dist/utils/index.cjs.map +1 -1
  382. package/dist/utils/index.d.cts +5 -7
  383. package/dist/utils/index.d.cts.map +1 -1
  384. package/dist/utils/index.d.mts +5 -7
  385. package/dist/utils/index.d.mts.map +1 -1
  386. package/dist/utils/index.mjs +4 -6
  387. package/dist/utils/index.mjs.map +1 -1
  388. package/dist/utils/inspector-visibility.cjs +25 -3
  389. package/dist/utils/inspector-visibility.cjs.map +1 -1
  390. package/dist/utils/inspector-visibility.d.cts +26 -3
  391. package/dist/utils/inspector-visibility.d.cts.map +1 -1
  392. package/dist/utils/inspector-visibility.d.mts +26 -3
  393. package/dist/utils/inspector-visibility.d.mts.map +1 -1
  394. package/dist/utils/inspector-visibility.mjs +25 -4
  395. package/dist/utils/inspector-visibility.mjs.map +1 -1
  396. package/dist/utils/json-schema.cjs +4 -79
  397. package/dist/utils/json-schema.cjs.map +1 -1
  398. package/dist/utils/json-schema.d.cts +1 -4
  399. package/dist/utils/json-schema.d.cts.map +1 -1
  400. package/dist/utils/json-schema.d.mts +1 -4
  401. package/dist/utils/json-schema.d.mts.map +1 -1
  402. package/dist/utils/json-schema.mjs +5 -78
  403. package/dist/utils/json-schema.mjs.map +1 -1
  404. package/dist/utils/random-id.cjs +13 -26
  405. package/dist/utils/random-id.cjs.map +1 -1
  406. package/dist/utils/random-id.d.cts +6 -3
  407. package/dist/utils/random-id.d.cts.map +1 -1
  408. package/dist/utils/random-id.d.mts +6 -3
  409. package/dist/utils/random-id.d.mts.map +1 -1
  410. package/dist/utils/random-id.mjs +14 -25
  411. package/dist/utils/random-id.mjs.map +1 -1
  412. package/dist/utils/types.cjs.map +1 -1
  413. package/dist/utils/types.d.cts +5 -12
  414. package/dist/utils/types.d.cts.map +1 -1
  415. package/dist/utils/types.d.mts +5 -12
  416. package/dist/utils/types.d.mts.map +1 -1
  417. package/dist/utils/types.mjs.map +1 -1
  418. package/package.json +19 -32
  419. package/scripts/verify-cjs-exports.cjs +1 -1
  420. package/src/__tests__/a2ui-envelope.test.ts +38 -13
  421. package/src/__tests__/a2ui-prompts.test.ts +47 -14
  422. package/src/__tests__/fixtures/prompt-goldens.json +354 -0
  423. package/src/__tests__/prompt-spec.test.ts +191 -0
  424. package/src/__tests__/root-entry-browser-safety.test.ts +5 -7
  425. package/src/__tests__/schema-render.test.ts +323 -0
  426. package/src/__tests__/standard-schema.test.ts +61 -101
  427. package/src/a2ui-envelope.ts +9 -7
  428. package/src/a2ui-prompts.ts +47 -96
  429. package/src/attachments/__tests__/utils.test.ts +22 -0
  430. package/src/attachments/types.ts +1 -3
  431. package/src/attachments/utils.ts +23 -5
  432. package/src/finalize-events.ts +16 -0
  433. package/src/generative-ui/__tests__/clone-value-differential.test.ts +480 -0
  434. package/src/generative-ui/__tests__/clone-value.test.ts +226 -0
  435. package/src/generative-ui/__tests__/render-ui-args.test.ts +7 -7
  436. package/src/generative-ui/__tests__/validate-operation.test.ts +19 -13
  437. package/src/generative-ui/base.ts +9 -0
  438. package/src/generative-ui/basic-functions.ts +1 -1
  439. package/src/generative-ui/catalog/catalog-export.ts +478 -0
  440. package/src/generative-ui/catalog/catalog.ts +1167 -0
  441. package/src/generative-ui/catalog/errors.ts +102 -0
  442. package/src/generative-ui/catalog/index.ts +6 -0
  443. package/src/generative-ui/catalog/json-schema.ts +14 -0
  444. package/src/generative-ui/catalog/refs.ts +87 -0
  445. package/src/generative-ui/catalog/schema.ts +107 -0
  446. package/src/generative-ui/child-refs.ts +5 -4
  447. package/src/generative-ui/clone-value.ts +511 -0
  448. package/src/generative-ui/compact-schema.ts +277 -0
  449. package/src/generative-ui/index.ts +14 -0
  450. package/src/generative-ui/is-record.ts +6 -1
  451. package/src/generative-ui/prompt-spec.ts +335 -0
  452. package/src/generative-ui/prompt.ts +25 -75
  453. package/src/generative-ui/render-ui-args.ts +3 -0
  454. package/src/generative-ui/schema-render.ts +378 -0
  455. package/src/generative-ui/standard/__tests__/standard-helpers.test.ts +407 -0
  456. package/src/generative-ui/standard/__tests__/theme.test.ts +61 -0
  457. package/src/generative-ui/standard/__tests__/tokens.test.ts +139 -0
  458. package/src/generative-ui/standard/chart-config.ts +434 -0
  459. package/src/generative-ui/standard/chart.ts +79 -0
  460. package/src/generative-ui/standard/checks.ts +98 -0
  461. package/src/generative-ui/standard/components.ts +35 -0
  462. package/src/generative-ui/standard/composites.ts +158 -0
  463. package/src/generative-ui/standard/data.ts +213 -0
  464. package/src/generative-ui/standard/declarations.ts +57 -0
  465. package/src/generative-ui/standard/feedback.ts +105 -0
  466. package/src/generative-ui/standard/index.ts +55 -0
  467. package/src/generative-ui/standard/inputs.ts +423 -0
  468. package/src/generative-ui/standard/layout.ts +312 -0
  469. package/src/generative-ui/standard/map-helpers.ts +155 -0
  470. package/src/generative-ui/standard/map.ts +32 -0
  471. package/src/generative-ui/standard/media.ts +265 -0
  472. package/src/generative-ui/standard/parameter-order.ts +155 -0
  473. package/src/generative-ui/standard/style-helpers.ts +170 -0
  474. package/src/generative-ui/standard/styles.ts +79 -0
  475. package/src/generative-ui/standard/text.ts +210 -0
  476. package/src/generative-ui/standard/theme.ts +198 -0
  477. package/src/generative-ui/standard/tokens.ts +317 -0
  478. package/src/generative-ui/standard/url.ts +51 -0
  479. package/src/generative-ui/thrown.ts +90 -0
  480. package/src/generative-ui/types.ts +23 -7
  481. package/src/generative-ui/validate-operation.ts +2 -2
  482. package/src/index.ts +9 -17
  483. package/src/standard-schema.ts +24 -27
  484. package/src/telemetry/lambda-client.ts +8 -3
  485. package/src/telemetry/model-host.test.ts +2 -5
  486. package/src/telemetry/telemetry-disabled.ts +0 -5
  487. package/src/types/message.ts +1 -19
  488. package/src/utils/__tests__/errors.test.ts +44 -0
  489. package/src/utils/__tests__/json-schema.test.ts +3 -479
  490. package/src/utils/__tests__/random-id.test.ts +37 -0
  491. package/src/utils/errors.ts +28 -85
  492. package/src/utils/index.ts +0 -2
  493. package/src/utils/inspector-visibility.test.ts +26 -0
  494. package/src/utils/inspector-visibility.ts +35 -3
  495. package/src/utils/json-schema.ts +5 -152
  496. package/src/utils/random-id.ts +17 -37
  497. package/src/utils/types.ts +4 -11
  498. package/tsconfig.json +3 -1
  499. package/tsdown.config.ts +2 -19
  500. package/dist/event-transforms/index.cjs +0 -15
  501. package/dist/event-transforms/index.d.cts +0 -4
  502. package/dist/event-transforms/index.d.mts +0 -4
  503. package/dist/event-transforms/index.mjs +0 -5
  504. package/dist/event-transforms/open-generative-ui-middleware.cjs +0 -286
  505. package/dist/event-transforms/open-generative-ui-middleware.cjs.map +0 -1
  506. package/dist/event-transforms/open-generative-ui-middleware.d.cts +0 -60
  507. package/dist/event-transforms/open-generative-ui-middleware.d.cts.map +0 -1
  508. package/dist/event-transforms/open-generative-ui-middleware.d.mts +0 -60
  509. package/dist/event-transforms/open-generative-ui-middleware.d.mts.map +0 -1
  510. package/dist/event-transforms/open-generative-ui-middleware.mjs +0 -283
  511. package/dist/event-transforms/open-generative-ui-middleware.mjs.map +0 -1
  512. package/dist/event-transforms/recorded-events.cjs +0 -59
  513. package/dist/event-transforms/recorded-events.cjs.map +0 -1
  514. package/dist/event-transforms/recorded-events.d.cts +0 -23
  515. package/dist/event-transforms/recorded-events.d.cts.map +0 -1
  516. package/dist/event-transforms/recorded-events.d.mts +0 -23
  517. package/dist/event-transforms/recorded-events.d.mts.map +0 -1
  518. package/dist/event-transforms/recorded-events.mjs +0 -58
  519. package/dist/event-transforms/recorded-events.mjs.map +0 -1
  520. package/dist/telemetry/events.d.cts +0 -72
  521. package/dist/telemetry/events.d.cts.map +0 -1
  522. package/dist/telemetry/events.d.mts +0 -72
  523. package/dist/telemetry/events.d.mts.map +0 -1
  524. package/dist/telemetry/index.cjs +0 -18
  525. package/dist/telemetry/index.d.cts +0 -5
  526. package/dist/telemetry/index.d.mts +0 -5
  527. package/dist/telemetry/index.mjs +0 -6
  528. package/dist/telemetry/telemetry-client.cjs +0 -165
  529. package/dist/telemetry/telemetry-client.cjs.map +0 -1
  530. package/dist/telemetry/telemetry-client.d.cts +0 -87
  531. package/dist/telemetry/telemetry-client.d.cts.map +0 -1
  532. package/dist/telemetry/telemetry-client.d.mts +0 -87
  533. package/dist/telemetry/telemetry-client.d.mts.map +0 -1
  534. package/dist/telemetry/telemetry-client.mjs +0 -164
  535. package/dist/telemetry/telemetry-client.mjs.map +0 -1
  536. package/dist/telemetry/utils.cjs +0 -14
  537. package/dist/telemetry/utils.cjs.map +0 -1
  538. package/dist/telemetry/utils.mjs +0 -13
  539. package/dist/telemetry/utils.mjs.map +0 -1
  540. package/dist/utils/conditions.cjs +0 -32
  541. package/dist/utils/conditions.cjs.map +0 -1
  542. package/dist/utils/conditions.d.cts +0 -31
  543. package/dist/utils/conditions.d.cts.map +0 -1
  544. package/dist/utils/conditions.d.mts +0 -31
  545. package/dist/utils/conditions.d.mts.map +0 -1
  546. package/dist/utils/conditions.mjs +0 -31
  547. package/dist/utils/conditions.mjs.map +0 -1
  548. package/dist/utils/console-styling.cjs +0 -91
  549. package/dist/utils/console-styling.cjs.map +0 -1
  550. package/dist/utils/console-styling.d.cts +0 -65
  551. package/dist/utils/console-styling.d.cts.map +0 -1
  552. package/dist/utils/console-styling.d.mts +0 -65
  553. package/dist/utils/console-styling.d.mts.map +0 -1
  554. package/dist/utils/console-styling.mjs +0 -85
  555. package/dist/utils/console-styling.mjs.map +0 -1
  556. package/src/__tests__/zod-regression.test.ts +0 -319
  557. package/src/event-transforms/index.ts +0 -5
  558. package/src/event-transforms/open-generative-ui-middleware.ts +0 -392
  559. package/src/event-transforms/recorded-events.test.ts +0 -166
  560. package/src/event-transforms/recorded-events.ts +0 -74
  561. package/src/telemetry/events.ts +0 -68
  562. package/src/telemetry/index.ts +0 -9
  563. package/src/telemetry/telemetry-blank-license-identity.test.ts +0 -128
  564. package/src/telemetry/telemetry-client.test.ts +0 -798
  565. package/src/telemetry/telemetry-client.ts +0 -328
  566. package/src/telemetry/utils.ts +0 -15
  567. package/src/utils/__tests__/conditions.test.ts +0 -161
  568. package/src/utils/conditions.ts +0 -116
  569. package/src/utils/console-styling.ts +0 -126
@@ -109,7 +109,11 @@ export function parseTelemetryIdFromLicense(token?: string): string | null {
109
109
  if (parts.length !== 3) return null;
110
110
  try {
111
111
  const payload = parts[1];
112
- if (!/^[A-Za-z0-9_-]+$/.test(payload) || payload.length % 4 === 1) {
112
+ if (
113
+ payload === undefined ||
114
+ !/^[A-Za-z0-9_-]+$/.test(payload) ||
115
+ payload.length % 4 === 1
116
+ ) {
113
117
  return null;
114
118
  }
115
119
 
@@ -136,8 +140,9 @@ export function parseTelemetryIdFromLicense(token?: string): string | null {
136
140
  // Parse the telemetry_id from a license token AND emit the rollout smoke
137
141
  // signal if the parse returned null. Returning the parsed id lets callers
138
142
  // cache it in one step (avoiding a second parseTelemetryIdFromLicense
139
- // pass) while keeping the warn text in lockstep between v1 (shared) and
140
- // v2 (runtime) TelemetryClient.setLicenseToken.
143
+ // pass) while keeping the warn text in lockstep between the v1 (shared)
144
+ // TelemetryClient.setLicenseToken and the v2 (runtime)
145
+ // TelemetryClient.setTelemetryIdentity.
141
146
  export function parseAndWarnTelemetryId(licenseToken: string): string | null {
142
147
  const telemetryId = parseTelemetryIdFromLicense(licenseToken);
143
148
  if (!telemetryId) {
@@ -1,9 +1,6 @@
1
1
  import { describe, it, expect } from "vitest";
2
- import {
3
- classifyModelHost,
4
- MODEL_HOST_CLASSES,
5
- type ModelHostClass,
6
- } from "./model-host";
2
+ import { classifyModelHost, MODEL_HOST_CLASSES } from "./model-host";
3
+ import type { ModelHostClass } from "./model-host";
7
4
 
8
5
  describe("classifyModelHost", () => {
9
6
  describe("the case this exists for: an OpenAI-shaped client aimed elsewhere", () => {
@@ -5,11 +5,6 @@ import { processEnv } from "../utils/process-env";
5
5
  * Users can opt out by setting:
6
6
  * - COPILOTKIT_TELEMETRY_DISABLED=true or COPILOTKIT_TELEMETRY_DISABLED=1
7
7
  * - DO_NOT_TRACK=true or DO_NOT_TRACK=1
8
- *
9
- * Lives in its own module so that the browser-facing root entry can
10
- * re-export it without pulling in `telemetry-client.ts`, whose
11
- * `@segment/analytics-node` import drags Node built-ins into browser
12
- * bundler module graphs. See the note in `../index.ts`.
13
8
  */
14
9
  export function isTelemetryDisabled(): boolean {
15
10
  const env = processEnv();
@@ -1,4 +1,4 @@
1
- import * as agui from "@ag-ui/core";
1
+ import type * as agui from "@ag-ui/core";
2
2
 
3
3
  // Re-export AG-UI multimodal input types.
4
4
  // Note: AG-UI names the text variant TextInputContent; we export it as TextInputPart for consistency.
@@ -14,18 +14,6 @@ export type {
14
14
  DocumentInputPart,
15
15
  } from "@ag-ui/core";
16
16
 
17
- /**
18
- * @deprecated Use `InputContentSource` from `@ag-ui/core` (re-exported from `@copilotkit/shared`) instead.
19
- * `ImageData` only described base64 image payloads. `InputContentSource` supports
20
- * data and URL sources for images, audio, video, and documents.
21
- * See https://docs.copilotkit.ai/migration-guides/migrate-attachments
22
- * @since 1.56.0
23
- */
24
- export interface ImageData {
25
- format: string;
26
- bytes: string;
27
- }
28
-
29
17
  // Pass through types
30
18
  export type Role = agui.Role;
31
19
  export type SystemMessage = agui.SystemMessage;
@@ -44,12 +32,6 @@ export type AIMessage = agui.AssistantMessage & {
44
32
  generativeUIPosition?: "before" | "after";
45
33
  agentName?: string;
46
34
  state?: any;
47
- /**
48
- * @deprecated Use multimodal `content` array with `InputContent` parts instead.
49
- * See https://docs.copilotkit.ai/migration-guides/migrate-attachments
50
- * @since 1.56.0
51
- */
52
- image?: ImageData;
53
35
  runId?: string;
54
36
  };
55
37
 
@@ -0,0 +1,44 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import {
3
+ CopilotKitError,
4
+ CopilotKitErrorCode,
5
+ ConfigurationError,
6
+ ErrorVisibility,
7
+ Severity,
8
+ } from "../errors";
9
+
10
+ describe("CopilotKitError", () => {
11
+ it("is a plain Error that keeps the structured extensions", () => {
12
+ const error = new CopilotKitError({
13
+ message: "boom",
14
+ code: CopilotKitErrorCode.NOT_FOUND,
15
+ });
16
+
17
+ expect(error).toBeInstanceOf(Error);
18
+ expect(error.message).toBe("boom");
19
+ expect(error.name).toBe("CopilotError");
20
+ expect(error.extensions).toMatchObject({
21
+ name: "CopilotError",
22
+ code: CopilotKitErrorCode.NOT_FOUND,
23
+ statusCode: 404,
24
+ visibility: ErrorVisibility.BANNER,
25
+ severity: Severity.CRITICAL,
26
+ originalError: { message: "boom" },
27
+ });
28
+ expect(error.extensions.troubleshootingUrl).toContain(
29
+ "network-errors-api-not-found",
30
+ );
31
+ });
32
+
33
+ it("sets troubleshootingUrl to null when the code has none", () => {
34
+ const error = new CopilotKitError({ code: CopilotKitErrorCode.UNKNOWN });
35
+ expect(error.extensions.troubleshootingUrl).toBeNull();
36
+ });
37
+
38
+ it("keeps subclasses instanceof both the subclass and CopilotKitError", () => {
39
+ const error = new ConfigurationError("bad config");
40
+ expect(error).toBeInstanceOf(ConfigurationError);
41
+ expect(error).toBeInstanceOf(CopilotKitError);
42
+ expect(error.extensions.code).toBe(CopilotKitErrorCode.CONFIGURATION_ERROR);
43
+ });
44
+ });
@@ -1,486 +1,10 @@
1
- import { describe, it, expect, vi } from "vitest";
2
- import { z } from "zod";
1
+ import { describe, it, expect } from "vitest";
2
+ import type { JSONSchema } from "../json-schema";
3
3
  import {
4
- convertJsonSchemaToZodSchema,
5
4
  actionParametersToJsonSchema,
6
5
  jsonSchemaToActionParameters,
7
- JSONSchema,
8
6
  } from "../json-schema";
9
- import { zodToJsonSchema } from "zod-to-json-schema";
10
- import { Parameter } from "../../types";
11
-
12
- describe("convertJsonSchemaToZodSchema", () => {
13
- it("should convert a simple JSON schema to a Zod schema", () => {
14
- const jsonSchema = {
15
- type: "object",
16
- properties: {
17
- name: { type: "string" },
18
- age: { type: "number" },
19
- },
20
- required: ["name", "age"],
21
- };
22
-
23
- const expectedSchema = z.object({
24
- name: z.string(),
25
- age: z.number(),
26
- });
27
-
28
- const result = convertJsonSchemaToZodSchema(jsonSchema, true);
29
- const resultSchemaJson = zodToJsonSchema(result);
30
- const expectedSchemaJson = zodToJsonSchema(expectedSchema);
31
-
32
- expect(resultSchemaJson).toStrictEqual(expectedSchemaJson);
33
- });
34
-
35
- it("should convert a JSON schema with nested objects to a Zod schema", () => {
36
- const jsonSchema = {
37
- type: "object",
38
- properties: {
39
- name: { type: "string" },
40
- address: {
41
- type: "object",
42
- properties: {
43
- street: { type: "string" },
44
- city: { type: "string" },
45
- },
46
- required: ["street", "city"],
47
- },
48
- },
49
- required: ["name", "address"],
50
- };
51
-
52
- const expectedSchema = z.object({
53
- name: z.string(),
54
- address: z.object({
55
- street: z.string(),
56
- city: z.string(),
57
- }),
58
- });
59
-
60
- const result = convertJsonSchemaToZodSchema(jsonSchema, true);
61
- const resultSchemaJson = zodToJsonSchema(result);
62
- const expectedSchemaJson = zodToJsonSchema(expectedSchema);
63
-
64
- expect(resultSchemaJson).toStrictEqual(expectedSchemaJson);
65
- });
66
-
67
- it("should convert a JSON schema with arrays to a Zod schema", () => {
68
- const jsonSchema = {
69
- type: "object",
70
- properties: {
71
- names: {
72
- type: "array",
73
- items: { type: "string" },
74
- },
75
- },
76
- required: ["names"],
77
- };
78
-
79
- const expectedSchema = z.object({
80
- names: z.array(z.string()),
81
- });
82
-
83
- const result = convertJsonSchemaToZodSchema(jsonSchema, true);
84
- const resultSchemaJson = zodToJsonSchema(result);
85
- const expectedSchemaJson = zodToJsonSchema(expectedSchema);
86
-
87
- expect(resultSchemaJson).toStrictEqual(expectedSchemaJson);
88
- });
89
-
90
- it("should convert a JSON schema with optional properties to a Zod schema", () => {
91
- const jsonSchema = {
92
- type: "object",
93
- properties: {
94
- name: { type: "string" },
95
- age: { type: "number", required: false },
96
- },
97
- };
98
-
99
- const expectedSchema = z
100
- .object({
101
- name: z.string().optional(),
102
- age: z.number().optional(),
103
- })
104
- .optional();
105
-
106
- const result = convertJsonSchemaToZodSchema(jsonSchema, false);
107
-
108
- console.log(convertJsonSchemaToZodSchema(jsonSchema, false));
109
-
110
- const resultSchemaJson = zodToJsonSchema(result);
111
- const expectedSchemaJson = zodToJsonSchema(expectedSchema);
112
-
113
- expect(resultSchemaJson).toStrictEqual(expectedSchemaJson);
114
- });
115
-
116
- it("should convert a JSON schema with different types to a Zod schema", () => {
117
- const jsonSchema = {
118
- type: "object",
119
- properties: {
120
- name: { type: "string" },
121
- age: { type: "number" },
122
- isAdmin: { type: "boolean" },
123
- },
124
- required: ["name", "age", "isAdmin"],
125
- };
126
-
127
- const expectedSchema = z.object({
128
- name: z.string(),
129
- age: z.number(),
130
- isAdmin: z.boolean(),
131
- });
132
-
133
- const result = convertJsonSchemaToZodSchema(jsonSchema, true);
134
- const resultSchemaJson = zodToJsonSchema(result);
135
- const expectedSchemaJson = zodToJsonSchema(expectedSchema);
136
-
137
- expect(resultSchemaJson).toStrictEqual(expectedSchemaJson);
138
- });
139
-
140
- it("should handle edge case where JSON schema has no properties", () => {
141
- const jsonSchema = {
142
- type: "object",
143
- };
144
-
145
- const expectedSchema = z.object({});
146
-
147
- const result = convertJsonSchemaToZodSchema(jsonSchema, true);
148
- const resultSchemaJson = zodToJsonSchema(result);
149
- const expectedSchemaJson = zodToJsonSchema(expectedSchema);
150
-
151
- expect(resultSchemaJson).toStrictEqual(expectedSchemaJson);
152
- });
153
-
154
- it("should preserve string enum constraints", () => {
155
- const jsonSchema = {
156
- type: "object",
157
- properties: {
158
- status: {
159
- type: "string",
160
- description: "The status",
161
- enum: ["todo", "done"],
162
- },
163
- },
164
- required: ["status"],
165
- };
166
- const result = convertJsonSchemaToZodSchema(jsonSchema, true);
167
- const statusSchema = (result as z.ZodObject<any>).shape.status;
168
- expect(statusSchema._def.typeName).toBe("ZodEnum");
169
- expect(statusSchema._def.values).toEqual(["todo", "done"]);
170
- });
171
-
172
- it("should handle null-union type ['string', 'null'] as nullable", () => {
173
- const jsonSchema = {
174
- type: "object",
175
- properties: {
176
- nickname: {
177
- type: ["string", "null"],
178
- description: "Optional nickname",
179
- },
180
- },
181
- required: ["nickname"],
182
- };
183
-
184
- const result = convertJsonSchemaToZodSchema(jsonSchema, true);
185
- const shape = (result as z.ZodObject<any>).shape;
186
-
187
- // The nickname field should accept both string and null
188
- expect(shape.nickname.safeParse("hello").success).toBe(true);
189
- expect(shape.nickname.safeParse(null).success).toBe(true);
190
- expect(shape.nickname.safeParse(42).success).toBe(false);
191
- });
192
-
193
- it("should handle null-union type ['number', 'null'] as nullable number", () => {
194
- const jsonSchema = {
195
- type: "object",
196
- properties: {
197
- score: {
198
- type: ["number", "null"],
199
- },
200
- },
201
- required: ["score"],
202
- };
203
-
204
- const result = convertJsonSchemaToZodSchema(jsonSchema, true);
205
- const shape = (result as z.ZodObject<any>).shape;
206
-
207
- expect(shape.score.safeParse(42).success).toBe(true);
208
- expect(shape.score.safeParse(null).success).toBe(true);
209
- expect(shape.score.safeParse("hello").success).toBe(false);
210
- });
211
-
212
- it("should handle edge case where JSON schema has no required properties", () => {
213
- const jsonSchema = {
214
- type: "object",
215
- properties: {
216
- name: { type: "string" },
217
- age: { type: "number" },
218
- },
219
- };
220
-
221
- const expectedSchema = z
222
- .object({
223
- name: z.string().optional(),
224
- age: z.number().optional(),
225
- })
226
- .optional();
227
-
228
- const result = convertJsonSchemaToZodSchema(jsonSchema, false);
229
- const resultSchemaJson = zodToJsonSchema(result);
230
- const expectedSchemaJson = zodToJsonSchema(expectedSchema);
231
-
232
- expect(resultSchemaJson).toStrictEqual(expectedSchemaJson);
233
- });
234
-
235
- it("should resolve non-circular $ref definitions correctly", () => {
236
- const jsonSchema = {
237
- type: "object",
238
- properties: {
239
- address: { $ref: "#/$defs/Address" },
240
- },
241
- required: ["address"],
242
- $defs: {
243
- Address: {
244
- type: "object",
245
- properties: {
246
- street: { type: "string", description: "Street name" },
247
- city: { type: "string", description: "City name" },
248
- },
249
- required: ["street", "city"],
250
- description: "A postal address",
251
- },
252
- },
253
- };
254
-
255
- const result = convertJsonSchemaToZodSchema(jsonSchema, true);
256
- const resultJson = zodToJsonSchema(result);
257
-
258
- const expectedSchema = z.object({
259
- address: z
260
- .object({
261
- street: z.string().describe("Street name"),
262
- city: z.string().describe("City name"),
263
- })
264
- .describe("A postal address"),
265
- });
266
- const expectedJson = zodToJsonSchema(expectedSchema);
267
-
268
- expect(resultJson).toStrictEqual(expectedJson);
269
- });
270
-
271
- it("should handle circular $ref without crashing and return z.any()", () => {
272
- // A schema where Node references itself — this would cause infinite
273
- // recursion without cycle detection.
274
- const jsonSchema = {
275
- type: "object",
276
- properties: {
277
- root: { $ref: "#/$defs/Node" },
278
- },
279
- required: ["root"],
280
- $defs: {
281
- Node: {
282
- type: "object",
283
- properties: {
284
- value: { type: "string", description: "Node value" },
285
- child: { $ref: "#/$defs/Node" },
286
- },
287
- required: ["value"],
288
- description: "A tree node",
289
- },
290
- },
291
- };
292
-
293
- const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
294
-
295
- // Must not throw or hang
296
- const result = convertJsonSchemaToZodSchema(jsonSchema, true);
297
- expect(result).toBeDefined();
298
-
299
- // The circular ref should have produced a console.warn
300
- expect(warnSpy).toHaveBeenCalledWith(
301
- expect.stringContaining("Circular $ref detected"),
302
- );
303
-
304
- // The top-level shape should still have a "root" key that is an object
305
- const shape = (result as z.ZodObject<any>).shape;
306
- expect(shape.root).toBeDefined();
307
-
308
- // Inside root, "value" should be a string and "child" should be z.any()
309
- // (child is optional since it's not in required[], so unwrap ZodOptional)
310
- const rootShape = (shape.root as z.ZodObject<any>).shape;
311
- expect(rootShape.value._def.typeName).toBe("ZodString");
312
- const childDef = rootShape.child._def;
313
- if (childDef.typeName === "ZodOptional") {
314
- expect(childDef.innerType._def.typeName).toBe("ZodAny");
315
- } else {
316
- expect(childDef.typeName).toBe("ZodAny");
317
- }
318
-
319
- warnSpy.mockRestore();
320
- });
321
-
322
- it("should resolve the same $ref used by multiple sibling properties", () => {
323
- // Two properties reference the same $def — the visited set must NOT
324
- // mark the second usage as circular.
325
- const jsonSchema = {
326
- type: "object",
327
- properties: {
328
- billing: { $ref: "#/$defs/Address" },
329
- shipping: { $ref: "#/$defs/Address" },
330
- },
331
- required: ["billing", "shipping"],
332
- $defs: {
333
- Address: {
334
- type: "object",
335
- properties: {
336
- street: { type: "string", description: "Street" },
337
- city: { type: "string", description: "City" },
338
- },
339
- required: ["street", "city"],
340
- description: "An address",
341
- },
342
- },
343
- };
344
-
345
- const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
346
-
347
- const result = convertJsonSchemaToZodSchema(jsonSchema, true);
348
- const shape = (result as z.ZodObject<any>).shape;
349
-
350
- // Both should be fully resolved objects, NOT z.any()
351
- expect(shape.billing._def.typeName).toBe("ZodObject");
352
- expect(shape.shipping._def.typeName).toBe("ZodObject");
353
-
354
- // No circular-ref warning should have been emitted
355
- expect(warnSpy).not.toHaveBeenCalled();
356
-
357
- warnSpy.mockRestore();
358
- });
359
-
360
- it("should resolve a shared $ref used in different branches of a $ref chain", () => {
361
- // Wrapper -> Container (via $ref) which has two children both using $ref to Leaf.
362
- // Without set cloning, the second Leaf ref in Container would be wrongly flagged
363
- // as circular because the first Leaf resolution already added it to the set.
364
- const jsonSchema = {
365
- type: "object",
366
- properties: {
367
- wrapper: { $ref: "#/$defs/Container" },
368
- },
369
- required: ["wrapper"],
370
- $defs: {
371
- Container: {
372
- type: "object",
373
- properties: {
374
- first: { $ref: "#/$defs/Leaf" },
375
- second: { $ref: "#/$defs/Leaf" },
376
- },
377
- required: ["first", "second"],
378
- description: "A container with two leaves",
379
- },
380
- Leaf: {
381
- type: "object",
382
- properties: {
383
- label: { type: "string", description: "Leaf label" },
384
- },
385
- required: ["label"],
386
- description: "A leaf node",
387
- },
388
- },
389
- };
390
-
391
- const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
392
-
393
- const result = convertJsonSchemaToZodSchema(jsonSchema, true);
394
- const wrapperShape = (
395
- (result as z.ZodObject<any>).shape.wrapper as z.ZodObject<any>
396
- ).shape;
397
-
398
- // Both first and second should be fully resolved Leaf objects
399
- expect(wrapperShape.first._def.typeName).toBe("ZodObject");
400
- expect(wrapperShape.second._def.typeName).toBe("ZodObject");
401
-
402
- // No circular-ref warning should have been emitted
403
- expect(warnSpy).not.toHaveBeenCalled();
404
-
405
- warnSpy.mockRestore();
406
- });
407
-
408
- it("should handle anyOf with $ref variants", () => {
409
- const jsonSchema = {
410
- type: "object",
411
- properties: {
412
- pet: {
413
- anyOf: [{ $ref: "#/$defs/Cat" }, { $ref: "#/$defs/Dog" }],
414
- description: "A pet",
415
- },
416
- },
417
- required: ["pet"],
418
- $defs: {
419
- Cat: {
420
- type: "object",
421
- properties: { meow: { type: "boolean" } },
422
- required: ["meow"],
423
- },
424
- Dog: {
425
- type: "object",
426
- properties: { bark: { type: "boolean" } },
427
- required: ["bark"],
428
- },
429
- },
430
- };
431
-
432
- const result = convertJsonSchemaToZodSchema(jsonSchema, true);
433
- expect(result).toBeDefined();
434
-
435
- // Should produce a union inside the "pet" property
436
- const petSchema = (result as z.ZodObject<any>).shape.pet;
437
- expect(petSchema._def.typeName).toBe("ZodUnion");
438
- });
439
-
440
- it("should handle integer type as z.number()", () => {
441
- const jsonSchema = {
442
- type: "object",
443
- properties: {
444
- count: { type: "integer", description: "A count" },
445
- },
446
- required: ["count"],
447
- };
448
-
449
- const result = convertJsonSchemaToZodSchema(jsonSchema, true);
450
- const shape = (result as z.ZodObject<any>).shape;
451
- expect(shape.count._def.typeName).toBe("ZodNumber");
452
- });
453
-
454
- it("should handle null type", () => {
455
- const jsonSchema = {
456
- type: "object",
457
- properties: {
458
- empty: { type: "null", description: "Always null" },
459
- },
460
- required: ["empty"],
461
- };
462
-
463
- const result = convertJsonSchemaToZodSchema(jsonSchema, true);
464
- const shape = (result as z.ZodObject<any>).shape;
465
- expect(shape.empty._def.typeName).toBe("ZodNull");
466
- });
467
-
468
- it("should warn and return z.any() for unsupported schema types", () => {
469
- const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
470
-
471
- const jsonSchema = { type: "custom_unsupported" };
472
- const result = convertJsonSchemaToZodSchema(jsonSchema, true);
473
-
474
- expect(result._def.typeName).toBe("ZodAny");
475
- expect(warnSpy).toHaveBeenCalledWith(
476
- expect.stringContaining(
477
- 'Unsupported JSON schema type "custom_unsupported"',
478
- ),
479
- );
480
-
481
- warnSpy.mockRestore();
482
- });
483
- });
7
+ import type { Parameter } from "../../types";
484
8
 
485
9
  describe("jsonSchemaToActionParameters", () => {
486
10
  it("should convert a simple JSONSchema to Parameter array", () => {
@@ -0,0 +1,37 @@
1
+ import { afterEach, describe, expect, it, vi } from "vitest";
2
+ import { randomId, randomUUID } from "../random-id";
3
+
4
+ const UUID_V4 =
5
+ /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
6
+
7
+ describe("randomUUID", () => {
8
+ afterEach(() => {
9
+ vi.unstubAllGlobals();
10
+ });
11
+
12
+ it("returns crypto.randomUUID() when it exists", () => {
13
+ vi.stubGlobal("crypto", {
14
+ randomUUID: () => "11111111-2222-4333-8444-555555555555",
15
+ });
16
+ expect(randomUUID()).toBe("11111111-2222-4333-8444-555555555555");
17
+ });
18
+
19
+ it("builds a v4 UUID from getRandomValues when randomUUID is missing", () => {
20
+ vi.stubGlobal("crypto", {
21
+ getRandomValues: (bytes: Uint8Array) => bytes.fill(0xff),
22
+ });
23
+ const id = randomUUID();
24
+ expect(id).toBe("ffffffff-ffff-4fff-bfff-ffffffffffff");
25
+ expect(id).toMatch(UUID_V4);
26
+ });
27
+
28
+ it("throws a clear error when the runtime has no crypto", () => {
29
+ vi.stubGlobal("crypto", undefined);
30
+ expect(() => randomUUID()).toThrow(/getRandomValues/);
31
+ });
32
+
33
+ it("prefixes randomId with ck-", () => {
34
+ expect(randomId()).toMatch(/^ck-/);
35
+ expect(randomId().slice(3)).toMatch(UUID_V4);
36
+ });
37
+ });