@copilotkit/shared 2.0.0-next.1 → 2.0.0-rc.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 (592) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +93 -12
  3. package/dist/_virtual/_rolldown/runtime.cjs +29 -0
  4. package/dist/a2ui-envelope.cjs +154 -0
  5. package/dist/a2ui-envelope.cjs.map +1 -0
  6. package/dist/a2ui-envelope.d.cts +101 -0
  7. package/dist/a2ui-envelope.d.cts.map +1 -0
  8. package/dist/a2ui-envelope.d.mts +101 -0
  9. package/dist/a2ui-envelope.d.mts.map +1 -0
  10. package/dist/a2ui-envelope.mjs +151 -0
  11. package/dist/a2ui-envelope.mjs.map +1 -0
  12. package/dist/a2ui-prompts.cjs +259 -0
  13. package/dist/a2ui-prompts.cjs.map +1 -0
  14. package/dist/a2ui-prompts.d.cts +79 -0
  15. package/dist/a2ui-prompts.d.cts.map +1 -0
  16. package/dist/a2ui-prompts.d.mts +79 -0
  17. package/dist/a2ui-prompts.d.mts.map +1 -0
  18. package/dist/a2ui-prompts.mjs +251 -0
  19. package/dist/a2ui-prompts.mjs.map +1 -0
  20. package/dist/attachments/content.cjs +17 -0
  21. package/dist/attachments/content.cjs.map +1 -0
  22. package/dist/attachments/content.d.cts +9 -0
  23. package/dist/attachments/content.d.cts.map +1 -0
  24. package/dist/attachments/content.d.mts +9 -0
  25. package/dist/attachments/content.d.mts.map +1 -0
  26. package/dist/attachments/content.mjs +16 -0
  27. package/dist/attachments/content.mjs.map +1 -0
  28. package/dist/attachments/types.d.cts +64 -0
  29. package/dist/attachments/types.d.cts.map +1 -0
  30. package/dist/attachments/types.d.mts +64 -0
  31. package/dist/attachments/types.d.mts.map +1 -0
  32. package/dist/attachments/utils.cjs +137 -0
  33. package/dist/attachments/utils.cjs.map +1 -0
  34. package/dist/attachments/utils.d.cts +44 -0
  35. package/dist/attachments/utils.d.cts.map +1 -0
  36. package/dist/attachments/utils.d.mts +44 -0
  37. package/dist/attachments/utils.d.mts.map +1 -0
  38. package/dist/attachments/utils.mjs +129 -0
  39. package/dist/attachments/utils.mjs.map +1 -0
  40. package/dist/constants/index.cjs +25 -0
  41. package/dist/constants/index.cjs.map +1 -0
  42. package/dist/constants/index.d.cts +17 -0
  43. package/dist/constants/index.d.cts.map +1 -0
  44. package/dist/constants/index.d.mts +17 -0
  45. package/dist/constants/index.d.mts.map +1 -0
  46. package/dist/constants/index.mjs +17 -12
  47. package/dist/constants/index.mjs.map +1 -1
  48. package/dist/debug-event-envelope.d.cts +13 -0
  49. package/dist/debug-event-envelope.d.cts.map +1 -0
  50. package/dist/debug-event-envelope.d.mts +13 -0
  51. package/dist/debug-event-envelope.d.mts.map +1 -0
  52. package/dist/debug.cjs +38 -0
  53. package/dist/debug.cjs.map +1 -0
  54. package/dist/debug.d.cts +29 -0
  55. package/dist/debug.d.cts.map +1 -0
  56. package/dist/debug.d.mts +29 -0
  57. package/dist/debug.d.mts.map +1 -0
  58. package/dist/debug.mjs +37 -0
  59. package/dist/debug.mjs.map +1 -0
  60. package/dist/event-transforms/index.cjs +15 -0
  61. package/dist/event-transforms/index.d.cts +4 -0
  62. package/dist/event-transforms/index.d.mts +4 -0
  63. package/dist/event-transforms/index.mjs +5 -0
  64. package/dist/event-transforms/open-generative-ui-middleware.cjs +286 -0
  65. package/dist/event-transforms/open-generative-ui-middleware.cjs.map +1 -0
  66. package/dist/event-transforms/open-generative-ui-middleware.d.cts +60 -0
  67. package/dist/event-transforms/open-generative-ui-middleware.d.cts.map +1 -0
  68. package/dist/event-transforms/open-generative-ui-middleware.d.mts +60 -0
  69. package/dist/event-transforms/open-generative-ui-middleware.d.mts.map +1 -0
  70. package/dist/event-transforms/open-generative-ui-middleware.mjs +283 -0
  71. package/dist/event-transforms/open-generative-ui-middleware.mjs.map +1 -0
  72. package/dist/event-transforms/recorded-events.cjs +59 -0
  73. package/dist/event-transforms/recorded-events.cjs.map +1 -0
  74. package/dist/event-transforms/recorded-events.d.cts +23 -0
  75. package/dist/event-transforms/recorded-events.d.cts.map +1 -0
  76. package/dist/event-transforms/recorded-events.d.mts +23 -0
  77. package/dist/event-transforms/recorded-events.d.mts.map +1 -0
  78. package/dist/event-transforms/recorded-events.mjs +58 -0
  79. package/dist/event-transforms/recorded-events.mjs.map +1 -0
  80. package/dist/finalize-events.cjs +186 -0
  81. package/dist/finalize-events.cjs.map +1 -0
  82. package/dist/finalize-events.d.cts +40 -0
  83. package/dist/finalize-events.d.cts.map +1 -0
  84. package/dist/finalize-events.d.mts +40 -0
  85. package/dist/finalize-events.d.mts.map +1 -0
  86. package/dist/finalize-events.mjs +184 -0
  87. package/dist/finalize-events.mjs.map +1 -0
  88. package/dist/generative-ui/basic-functions.cjs +177 -0
  89. package/dist/generative-ui/basic-functions.cjs.map +1 -0
  90. package/dist/generative-ui/basic-functions.d.cts +108 -0
  91. package/dist/generative-ui/basic-functions.d.cts.map +1 -0
  92. package/dist/generative-ui/basic-functions.d.mts +108 -0
  93. package/dist/generative-ui/basic-functions.d.mts.map +1 -0
  94. package/dist/generative-ui/basic-functions.mjs +167 -0
  95. package/dist/generative-ui/basic-functions.mjs.map +1 -0
  96. package/dist/generative-ui/child-refs.cjs +161 -0
  97. package/dist/generative-ui/child-refs.cjs.map +1 -0
  98. package/dist/generative-ui/child-refs.d.cts +68 -0
  99. package/dist/generative-ui/child-refs.d.cts.map +1 -0
  100. package/dist/generative-ui/child-refs.d.mts +68 -0
  101. package/dist/generative-ui/child-refs.d.mts.map +1 -0
  102. package/dist/generative-ui/child-refs.mjs +152 -0
  103. package/dist/generative-ui/child-refs.mjs.map +1 -0
  104. package/dist/generative-ui/is-record.cjs +10 -0
  105. package/dist/generative-ui/is-record.cjs.map +1 -0
  106. package/dist/generative-ui/is-record.mjs +9 -0
  107. package/dist/generative-ui/is-record.mjs.map +1 -0
  108. package/dist/generative-ui/prompt.cjs +91 -0
  109. package/dist/generative-ui/prompt.cjs.map +1 -0
  110. package/dist/generative-ui/prompt.d.cts +13 -0
  111. package/dist/generative-ui/prompt.d.cts.map +1 -0
  112. package/dist/generative-ui/prompt.d.mts +13 -0
  113. package/dist/generative-ui/prompt.d.mts.map +1 -0
  114. package/dist/generative-ui/prompt.mjs +90 -0
  115. package/dist/generative-ui/prompt.mjs.map +1 -0
  116. package/dist/generative-ui/render-ui-args.cjs +160 -0
  117. package/dist/generative-ui/render-ui-args.cjs.map +1 -0
  118. package/dist/generative-ui/render-ui-args.d.cts +40 -0
  119. package/dist/generative-ui/render-ui-args.d.cts.map +1 -0
  120. package/dist/generative-ui/render-ui-args.d.mts +40 -0
  121. package/dist/generative-ui/render-ui-args.d.mts.map +1 -0
  122. package/dist/generative-ui/render-ui-args.mjs +159 -0
  123. package/dist/generative-ui/render-ui-args.mjs.map +1 -0
  124. package/dist/generative-ui/types.cjs +101 -0
  125. package/dist/generative-ui/types.cjs.map +1 -0
  126. package/dist/generative-ui/types.d.cts +270 -0
  127. package/dist/generative-ui/types.d.cts.map +1 -0
  128. package/dist/generative-ui/types.d.mts +270 -0
  129. package/dist/generative-ui/types.d.mts.map +1 -0
  130. package/dist/generative-ui/types.mjs +86 -0
  131. package/dist/generative-ui/types.mjs.map +1 -0
  132. package/dist/generative-ui/validate-operation.cjs +405 -0
  133. package/dist/generative-ui/validate-operation.cjs.map +1 -0
  134. package/dist/generative-ui/validate-operation.d.cts +86 -0
  135. package/dist/generative-ui/validate-operation.d.cts.map +1 -0
  136. package/dist/generative-ui/validate-operation.d.mts +86 -0
  137. package/dist/generative-ui/validate-operation.d.mts.map +1 -0
  138. package/dist/generative-ui/validate-operation.mjs +399 -0
  139. package/dist/generative-ui/validate-operation.mjs.map +1 -0
  140. package/dist/index.cjs +233 -0
  141. package/dist/index.cjs.map +1 -0
  142. package/dist/index.d.cts +80 -0
  143. package/dist/index.d.cts.map +1 -0
  144. package/dist/index.d.mts +80 -0
  145. package/dist/index.d.mts.map +1 -0
  146. package/dist/index.mjs +78 -123
  147. package/dist/index.mjs.map +1 -1
  148. package/dist/index.umd.js +3979 -0
  149. package/dist/index.umd.js.map +1 -0
  150. package/dist/intelligence-routing-fields.cjs +35 -0
  151. package/dist/intelligence-routing-fields.cjs.map +1 -0
  152. package/dist/intelligence-routing-fields.d.cts +18 -0
  153. package/dist/intelligence-routing-fields.d.cts.map +1 -0
  154. package/dist/intelligence-routing-fields.d.mts +18 -0
  155. package/dist/intelligence-routing-fields.d.mts.map +1 -0
  156. package/dist/intelligence-routing-fields.mjs +34 -0
  157. package/dist/intelligence-routing-fields.mjs.map +1 -0
  158. package/dist/logger.cjs +7 -0
  159. package/dist/logger.cjs.map +1 -0
  160. package/dist/logger.d.cts +5 -0
  161. package/dist/logger.d.cts.map +1 -0
  162. package/dist/logger.d.mts +5 -0
  163. package/dist/logger.d.mts.map +1 -0
  164. package/dist/logger.mjs +6 -0
  165. package/dist/logger.mjs.map +1 -0
  166. package/dist/open-generative-ui-prompts.cjs +8 -0
  167. package/dist/open-generative-ui-prompts.cjs.map +1 -0
  168. package/dist/open-generative-ui-prompts.d.cts +6 -0
  169. package/dist/open-generative-ui-prompts.d.cts.map +1 -0
  170. package/dist/open-generative-ui-prompts.d.mts +6 -0
  171. package/dist/open-generative-ui-prompts.d.mts.map +1 -0
  172. package/dist/open-generative-ui-prompts.mjs +7 -0
  173. package/dist/open-generative-ui-prompts.mjs.map +1 -0
  174. package/dist/package.cjs +12 -0
  175. package/dist/package.cjs.map +1 -0
  176. package/dist/package.mjs +6 -0
  177. package/dist/package.mjs.map +1 -0
  178. package/dist/standard-schema.cjs +31 -0
  179. package/dist/standard-schema.cjs.map +1 -0
  180. package/dist/standard-schema.d.cts +33 -0
  181. package/dist/standard-schema.d.cts.map +1 -0
  182. package/dist/standard-schema.d.mts +33 -0
  183. package/dist/standard-schema.d.mts.map +1 -0
  184. package/dist/standard-schema.mjs +30 -0
  185. package/dist/standard-schema.mjs.map +1 -0
  186. package/dist/telemetry/events.d.cts +72 -0
  187. package/dist/telemetry/events.d.cts.map +1 -0
  188. package/dist/telemetry/events.d.mts +72 -0
  189. package/dist/telemetry/events.d.mts.map +1 -0
  190. package/dist/telemetry/index.cjs +18 -0
  191. package/dist/telemetry/index.d.cts +5 -0
  192. package/dist/telemetry/index.d.mts +5 -0
  193. package/dist/telemetry/index.mjs +6 -12
  194. package/dist/telemetry/lambda-client.cjs +91 -0
  195. package/dist/telemetry/lambda-client.cjs.map +1 -0
  196. package/dist/telemetry/lambda-client.d.cts +31 -0
  197. package/dist/telemetry/lambda-client.d.cts.map +1 -0
  198. package/dist/telemetry/lambda-client.d.mts +31 -0
  199. package/dist/telemetry/lambda-client.d.mts.map +1 -0
  200. package/dist/telemetry/lambda-client.mjs +87 -0
  201. package/dist/telemetry/lambda-client.mjs.map +1 -0
  202. package/dist/telemetry/model-host.cjs +104 -0
  203. package/dist/telemetry/model-host.cjs.map +1 -0
  204. package/dist/telemetry/model-host.d.cts +26 -0
  205. package/dist/telemetry/model-host.d.cts.map +1 -0
  206. package/dist/telemetry/model-host.d.mts +26 -0
  207. package/dist/telemetry/model-host.d.mts.map +1 -0
  208. package/dist/telemetry/model-host.mjs +102 -0
  209. package/dist/telemetry/model-host.mjs.map +1 -0
  210. package/dist/telemetry/sampling.cjs +50 -0
  211. package/dist/telemetry/sampling.cjs.map +1 -0
  212. package/dist/telemetry/sampling.d.cts +57 -0
  213. package/dist/telemetry/sampling.d.cts.map +1 -0
  214. package/dist/telemetry/sampling.d.mts +57 -0
  215. package/dist/telemetry/sampling.d.mts.map +1 -0
  216. package/dist/telemetry/sampling.mjs +44 -0
  217. package/dist/telemetry/sampling.mjs.map +1 -0
  218. package/dist/telemetry/telemetry-client.cjs +165 -0
  219. package/dist/telemetry/telemetry-client.cjs.map +1 -0
  220. package/dist/telemetry/telemetry-client.d.cts +87 -0
  221. package/dist/telemetry/telemetry-client.d.cts.map +1 -0
  222. package/dist/telemetry/telemetry-client.d.mts +87 -0
  223. package/dist/telemetry/telemetry-client.d.mts.map +1 -0
  224. package/dist/telemetry/telemetry-client.mjs +162 -9
  225. package/dist/telemetry/telemetry-client.mjs.map +1 -1
  226. package/dist/telemetry/telemetry-disabled.cjs +20 -0
  227. package/dist/telemetry/telemetry-disabled.cjs.map +1 -0
  228. package/dist/telemetry/telemetry-disabled.d.cts +16 -0
  229. package/dist/telemetry/telemetry-disabled.d.cts.map +1 -0
  230. package/dist/telemetry/telemetry-disabled.d.mts +16 -0
  231. package/dist/telemetry/telemetry-disabled.d.mts.map +1 -0
  232. package/dist/telemetry/telemetry-disabled.mjs +19 -0
  233. package/dist/telemetry/telemetry-disabled.mjs.map +1 -0
  234. package/dist/telemetry/utils.cjs +14 -0
  235. package/dist/telemetry/utils.cjs.map +1 -0
  236. package/dist/telemetry/utils.mjs +12 -8
  237. package/dist/telemetry/utils.mjs.map +1 -1
  238. package/dist/transcription-errors.cjs +84 -0
  239. package/dist/transcription-errors.cjs.map +1 -0
  240. package/dist/transcription-errors.d.cts +52 -0
  241. package/dist/transcription-errors.d.cts.map +1 -0
  242. package/dist/transcription-errors.d.mts +52 -0
  243. package/dist/transcription-errors.d.mts.map +1 -0
  244. package/dist/transcription-errors.mjs +82 -0
  245. package/dist/transcription-errors.mjs.map +1 -0
  246. package/dist/types/{action.d.ts → action.d.cts} +32 -32
  247. package/dist/types/action.d.cts.map +1 -0
  248. package/dist/types/action.d.mts +59 -0
  249. package/dist/types/action.d.mts.map +1 -0
  250. package/dist/types/copilot-cloud-config.d.cts +15 -0
  251. package/dist/types/copilot-cloud-config.d.cts.map +1 -0
  252. package/dist/types/copilot-cloud-config.d.mts +15 -0
  253. package/dist/types/copilot-cloud-config.d.mts.map +1 -0
  254. package/dist/types/error.d.cts +57 -0
  255. package/dist/types/error.d.cts.map +1 -0
  256. package/dist/types/error.d.mts +57 -0
  257. package/dist/types/error.d.mts.map +1 -0
  258. package/dist/types/message.d.cts +42 -0
  259. package/dist/types/message.d.cts.map +1 -0
  260. package/dist/types/message.d.mts +42 -0
  261. package/dist/types/message.d.mts.map +1 -0
  262. package/dist/types/openai-assistant.d.cts +55 -0
  263. package/dist/types/openai-assistant.d.cts.map +1 -0
  264. package/dist/types/openai-assistant.d.mts +55 -0
  265. package/dist/types/openai-assistant.d.mts.map +1 -0
  266. package/dist/types/utility.d.cts +6 -0
  267. package/dist/types/utility.d.cts.map +1 -0
  268. package/dist/types/utility.d.mts +6 -0
  269. package/dist/types/utility.d.mts.map +1 -0
  270. package/dist/utils/clipboard.cjs +28 -0
  271. package/dist/utils/clipboard.cjs.map +1 -0
  272. package/dist/utils/clipboard.d.cts +14 -0
  273. package/dist/utils/clipboard.d.cts.map +1 -0
  274. package/dist/utils/clipboard.d.mts +14 -0
  275. package/dist/utils/clipboard.d.mts.map +1 -0
  276. package/dist/utils/clipboard.mjs +27 -0
  277. package/dist/utils/clipboard.mjs.map +1 -0
  278. package/dist/utils/conditions.cjs +32 -0
  279. package/dist/utils/conditions.cjs.map +1 -0
  280. package/dist/utils/{conditions.d.ts → conditions.d.cts} +16 -11
  281. package/dist/utils/conditions.d.cts.map +1 -0
  282. package/dist/utils/conditions.d.mts +31 -0
  283. package/dist/utils/conditions.d.mts.map +1 -0
  284. package/dist/utils/conditions.mjs +30 -6
  285. package/dist/utils/conditions.mjs.map +1 -1
  286. package/dist/utils/console-styling.cjs +91 -0
  287. package/dist/utils/console-styling.cjs.map +1 -0
  288. package/dist/utils/console-styling.d.cts +65 -0
  289. package/dist/utils/console-styling.d.cts.map +1 -0
  290. package/dist/utils/console-styling.d.mts +65 -0
  291. package/dist/utils/console-styling.d.mts.map +1 -0
  292. package/dist/utils/console-styling.mjs +83 -15
  293. package/dist/utils/console-styling.mjs.map +1 -1
  294. package/dist/utils/dashboard-url.cjs +19 -0
  295. package/dist/utils/dashboard-url.cjs.map +1 -0
  296. package/dist/utils/dashboard-url.mjs +18 -0
  297. package/dist/utils/dashboard-url.mjs.map +1 -0
  298. package/dist/utils/errors.cjs +439 -0
  299. package/dist/utils/errors.cjs.map +1 -0
  300. package/dist/utils/{errors.d.ts → errors.d.cts} +188 -156
  301. package/dist/utils/errors.d.cts.map +1 -0
  302. package/dist/utils/errors.d.mts +312 -0
  303. package/dist/utils/errors.d.mts.map +1 -0
  304. package/dist/utils/errors.mjs +416 -63
  305. package/dist/utils/errors.mjs.map +1 -1
  306. package/dist/utils/index.cjs +105 -0
  307. package/dist/utils/index.cjs.map +1 -0
  308. package/dist/utils/index.d.cts +58 -0
  309. package/dist/utils/index.d.cts.map +1 -0
  310. package/dist/utils/index.d.mts +58 -0
  311. package/dist/utils/index.d.mts.map +1 -0
  312. package/dist/utils/index.mjs +97 -107
  313. package/dist/utils/index.mjs.map +1 -1
  314. package/dist/utils/inspector-learning.cjs +217 -0
  315. package/dist/utils/inspector-learning.cjs.map +1 -0
  316. package/dist/utils/inspector-learning.d.cts +104 -0
  317. package/dist/utils/inspector-learning.d.cts.map +1 -0
  318. package/dist/utils/inspector-learning.d.mts +104 -0
  319. package/dist/utils/inspector-learning.d.mts.map +1 -0
  320. package/dist/utils/inspector-learning.mjs +215 -0
  321. package/dist/utils/inspector-learning.mjs.map +1 -0
  322. package/dist/utils/inspector-metadata.cjs +146 -0
  323. package/dist/utils/inspector-metadata.cjs.map +1 -0
  324. package/dist/utils/inspector-metadata.d.cts +55 -0
  325. package/dist/utils/inspector-metadata.d.cts.map +1 -0
  326. package/dist/utils/inspector-metadata.d.mts +55 -0
  327. package/dist/utils/inspector-metadata.d.mts.map +1 -0
  328. package/dist/utils/inspector-metadata.mjs +146 -0
  329. package/dist/utils/inspector-metadata.mjs.map +1 -0
  330. package/dist/utils/inspector-visibility.cjs +13 -0
  331. package/dist/utils/inspector-visibility.cjs.map +1 -0
  332. package/dist/utils/inspector-visibility.d.cts +18 -0
  333. package/dist/utils/inspector-visibility.d.cts.map +1 -0
  334. package/dist/utils/inspector-visibility.d.mts +18 -0
  335. package/dist/utils/inspector-visibility.d.mts.map +1 -0
  336. package/dist/utils/inspector-visibility.mjs +12 -0
  337. package/dist/utils/inspector-visibility.mjs.map +1 -0
  338. package/dist/utils/json-schema.cjs +215 -0
  339. package/dist/utils/json-schema.cjs.map +1 -0
  340. package/dist/utils/{json-schema.d.ts → json-schema.d.cts} +20 -18
  341. package/dist/utils/json-schema.d.cts.map +1 -0
  342. package/dist/utils/json-schema.d.mts +36 -0
  343. package/dist/utils/json-schema.d.mts.map +1 -0
  344. package/dist/utils/json-schema.mjs +210 -12
  345. package/dist/utils/json-schema.mjs.map +1 -1
  346. package/dist/utils/random-id.cjs +38 -0
  347. package/dist/utils/random-id.cjs.map +1 -0
  348. package/dist/utils/{random-id.d.ts → random-id.d.cts} +3 -1
  349. package/dist/utils/random-id.d.cts.map +1 -0
  350. package/dist/utils/random-id.d.mts +8 -0
  351. package/dist/utils/random-id.d.mts.map +1 -0
  352. package/dist/utils/random-id.mjs +33 -12
  353. package/dist/utils/random-id.mjs.map +1 -1
  354. package/dist/utils/requests.cjs +58 -0
  355. package/dist/utils/requests.cjs.map +1 -0
  356. package/dist/utils/{requests.d.ts → requests.d.cts} +3 -1
  357. package/dist/utils/requests.d.cts.map +1 -0
  358. package/dist/utils/requests.d.mts +12 -0
  359. package/dist/utils/requests.d.mts.map +1 -0
  360. package/dist/utils/requests.mjs +56 -6
  361. package/dist/utils/requests.mjs.map +1 -1
  362. package/dist/utils/row-render-keys.cjs +206 -0
  363. package/dist/utils/row-render-keys.cjs.map +1 -0
  364. package/dist/utils/row-render-keys.d.cts +65 -0
  365. package/dist/utils/row-render-keys.d.cts.map +1 -0
  366. package/dist/utils/row-render-keys.d.mts +65 -0
  367. package/dist/utils/row-render-keys.d.mts.map +1 -0
  368. package/dist/utils/row-render-keys.mjs +201 -0
  369. package/dist/utils/row-render-keys.mjs.map +1 -0
  370. package/dist/utils/types.cjs +9 -0
  371. package/dist/utils/types.cjs.map +1 -0
  372. package/dist/utils/types.d.cts +122 -0
  373. package/dist/utils/types.d.cts.map +1 -0
  374. package/dist/utils/types.d.mts +122 -0
  375. package/dist/utils/types.d.mts.map +1 -0
  376. package/dist/utils/types.mjs +6 -1
  377. package/dist/utils/types.mjs.map +1 -1
  378. package/package.json +74 -40
  379. package/scripts/verify-cjs-exports.cjs +16 -0
  380. package/src/__tests__/a2ui-envelope.test.ts +434 -0
  381. package/src/__tests__/a2ui-prompts.test.ts +362 -0
  382. package/src/__tests__/debug.test.ts +116 -0
  383. package/src/__tests__/license-context.test.ts +253 -0
  384. package/src/__tests__/root-entry-browser-safety.test.ts +91 -0
  385. package/src/__tests__/standard-schema-types.test.ts +144 -0
  386. package/src/__tests__/standard-schema.test.ts +359 -0
  387. package/src/__tests__/zod-regression.test.ts +319 -0
  388. package/src/a2ui-envelope.ts +309 -0
  389. package/src/a2ui-prompts.ts +322 -0
  390. package/src/attachments/__tests__/utils.test.ts +214 -0
  391. package/src/attachments/content.test.ts +48 -0
  392. package/src/attachments/content.ts +16 -0
  393. package/src/attachments/index.ts +21 -0
  394. package/src/attachments/types.ts +77 -0
  395. package/src/attachments/utils.ts +169 -0
  396. package/src/constants/index.ts +14 -1
  397. package/src/debug-event-envelope.ts +9 -0
  398. package/src/debug.ts +55 -0
  399. package/src/event-transforms/index.ts +5 -0
  400. package/src/event-transforms/open-generative-ui-middleware.ts +392 -0
  401. package/src/event-transforms/recorded-events.test.ts +166 -0
  402. package/src/event-transforms/recorded-events.ts +74 -0
  403. package/src/finalize-events.test.ts +284 -0
  404. package/src/finalize-events.ts +260 -0
  405. package/src/generative-ui/__tests__/render-ui-args.test.ts +175 -0
  406. package/src/generative-ui/__tests__/validate-operation.test.ts +977 -0
  407. package/src/generative-ui/basic-functions.ts +282 -0
  408. package/src/generative-ui/child-refs.ts +210 -0
  409. package/src/generative-ui/index.ts +6 -0
  410. package/src/generative-ui/is-record.ts +4 -0
  411. package/src/generative-ui/prompt.ts +174 -0
  412. package/src/generative-ui/render-ui-args.ts +199 -0
  413. package/src/generative-ui/types.ts +314 -0
  414. package/src/generative-ui/validate-operation.ts +723 -0
  415. package/src/index.ts +190 -1
  416. package/src/intelligence-routing-fields.test.ts +51 -0
  417. package/src/intelligence-routing-fields.ts +40 -0
  418. package/src/logger.ts +1 -0
  419. package/src/open-generative-ui-prompts.ts +20 -0
  420. package/src/standard-schema.ts +82 -0
  421. package/src/telemetry/events.ts +37 -10
  422. package/src/telemetry/index.ts +8 -0
  423. package/src/telemetry/lambda-client.test.ts +446 -0
  424. package/src/telemetry/lambda-client.ts +194 -0
  425. package/src/telemetry/model-host.test.ts +145 -0
  426. package/src/telemetry/model-host.ts +156 -0
  427. package/src/telemetry/sampling.test.ts +65 -0
  428. package/src/telemetry/sampling.ts +103 -0
  429. package/src/telemetry/telemetry-blank-license-identity.test.ts +128 -0
  430. package/src/telemetry/telemetry-client.test.ts +798 -0
  431. package/src/telemetry/telemetry-client.ts +223 -37
  432. package/src/telemetry/telemetry-disabled.ts +22 -0
  433. package/src/telemetry/utils.ts +0 -24
  434. package/src/transcription-errors.ts +99 -0
  435. package/src/types/__tests__/message.test.ts +62 -0
  436. package/src/types/action.ts +9 -5
  437. package/src/types/error.ts +11 -2
  438. package/src/types/message.ts +33 -5
  439. package/src/types/openai-assistant.ts +6 -2
  440. package/src/utils/__tests__/clipboard.test.ts +87 -0
  441. package/src/utils/__tests__/conditions.test.ts +161 -0
  442. package/src/utils/__tests__/json-schema.test.ts +812 -0
  443. package/src/utils/__tests__/row-render-keys.test.ts +388 -0
  444. package/src/utils/clipboard.ts +23 -0
  445. package/src/utils/conditions.ts +27 -9
  446. package/src/utils/console-styling.ts +10 -8
  447. package/src/utils/dashboard-url.ts +17 -0
  448. package/src/utils/errors.ts +55 -22
  449. package/src/utils/index.ts +70 -1
  450. package/src/utils/inspector-learning.test.ts +423 -0
  451. package/src/utils/inspector-learning.ts +523 -0
  452. package/src/utils/inspector-metadata.test.ts +743 -0
  453. package/src/utils/inspector-metadata.ts +263 -0
  454. package/src/utils/inspector-visibility.test.ts +43 -0
  455. package/src/utils/inspector-visibility.ts +17 -0
  456. package/src/utils/json-schema.ts +156 -12
  457. package/src/utils/random-id.ts +5 -2
  458. package/src/utils/requests.ts +3 -1
  459. package/src/utils/row-render-keys.ts +263 -0
  460. package/src/utils/types.ts +128 -1
  461. package/src/utils.test.ts +137 -0
  462. package/tsconfig.json +10 -2
  463. package/tsdown.config.ts +49 -0
  464. package/vitest.config.mjs +11 -0
  465. package/CHANGELOG.md +0 -1817
  466. package/dist/chunk-2OJ5OJ2D.mjs +0 -1
  467. package/dist/chunk-2OJ5OJ2D.mjs.map +0 -1
  468. package/dist/chunk-64DYJ27R.mjs +0 -201
  469. package/dist/chunk-64DYJ27R.mjs.map +0 -1
  470. package/dist/chunk-6QGXWNS5.mjs +0 -34
  471. package/dist/chunk-6QGXWNS5.mjs.map +0 -1
  472. package/dist/chunk-6W2UEO2M.mjs +0 -94
  473. package/dist/chunk-6W2UEO2M.mjs.map +0 -1
  474. package/dist/chunk-7DJDTRNX.mjs +0 -426
  475. package/dist/chunk-7DJDTRNX.mjs.map +0 -1
  476. package/dist/chunk-A66772CV.mjs +0 -107
  477. package/dist/chunk-A66772CV.mjs.map +0 -1
  478. package/dist/chunk-BOKE4OKY.mjs +0 -41
  479. package/dist/chunk-BOKE4OKY.mjs.map +0 -1
  480. package/dist/chunk-FCCOSO5L.mjs +0 -1
  481. package/dist/chunk-FCCOSO5L.mjs.map +0 -1
  482. package/dist/chunk-GYZIHHE6.mjs +0 -13
  483. package/dist/chunk-GYZIHHE6.mjs.map +0 -1
  484. package/dist/chunk-IAFBVORQ.mjs +0 -1
  485. package/dist/chunk-IAFBVORQ.mjs.map +0 -1
  486. package/dist/chunk-JAAUCDUR.mjs +0 -38
  487. package/dist/chunk-JAAUCDUR.mjs.map +0 -1
  488. package/dist/chunk-MSUB6DGR.mjs +0 -1
  489. package/dist/chunk-MSUB6DGR.mjs.map +0 -1
  490. package/dist/chunk-N5EP5OD5.mjs +0 -1
  491. package/dist/chunk-N5EP5OD5.mjs.map +0 -1
  492. package/dist/chunk-NAFEBKSO.mjs +0 -1
  493. package/dist/chunk-NAFEBKSO.mjs.map +0 -1
  494. package/dist/chunk-P7STFMPO.mjs +0 -1
  495. package/dist/chunk-P7STFMPO.mjs.map +0 -1
  496. package/dist/chunk-PL5WNHFZ.mjs +0 -50
  497. package/dist/chunk-PL5WNHFZ.mjs.map +0 -1
  498. package/dist/chunk-UYARLQNA.mjs +0 -1
  499. package/dist/chunk-UYARLQNA.mjs.map +0 -1
  500. package/dist/chunk-XEMZTHQZ.mjs +0 -67
  501. package/dist/chunk-XEMZTHQZ.mjs.map +0 -1
  502. package/dist/chunk-XTHC46M2.mjs +0 -1
  503. package/dist/chunk-XTHC46M2.mjs.map +0 -1
  504. package/dist/constants/index.d.ts +0 -6
  505. package/dist/constants/index.js +0 -40
  506. package/dist/constants/index.js.map +0 -1
  507. package/dist/index.d.ts +0 -25
  508. package/dist/index.js +0 -1098
  509. package/dist/index.js.map +0 -1
  510. package/dist/telemetry/events.d.ts +0 -45
  511. package/dist/telemetry/events.js +0 -19
  512. package/dist/telemetry/events.js.map +0 -1
  513. package/dist/telemetry/events.mjs +0 -1
  514. package/dist/telemetry/events.mjs.map +0 -1
  515. package/dist/telemetry/index.d.ts +0 -3
  516. package/dist/telemetry/index.js +0 -188
  517. package/dist/telemetry/index.js.map +0 -1
  518. package/dist/telemetry/index.mjs.map +0 -1
  519. package/dist/telemetry/scarf-client.d.ts +0 -7
  520. package/dist/telemetry/scarf-client.js +0 -59
  521. package/dist/telemetry/scarf-client.js.map +0 -1
  522. package/dist/telemetry/scarf-client.mjs +0 -7
  523. package/dist/telemetry/scarf-client.mjs.map +0 -1
  524. package/dist/telemetry/security-check.d.ts +0 -2
  525. package/dist/telemetry/security-check.js +0 -2
  526. package/dist/telemetry/security-check.js.map +0 -1
  527. package/dist/telemetry/security-check.mjs +0 -1
  528. package/dist/telemetry/security-check.mjs.map +0 -1
  529. package/dist/telemetry/telemetry-client.d.ts +0 -40
  530. package/dist/telemetry/telemetry-client.js +0 -186
  531. package/dist/telemetry/telemetry-client.js.map +0 -1
  532. package/dist/telemetry/utils.d.ts +0 -8
  533. package/dist/telemetry/utils.js +0 -69
  534. package/dist/telemetry/utils.js.map +0 -1
  535. package/dist/types/action.js +0 -19
  536. package/dist/types/action.js.map +0 -1
  537. package/dist/types/action.mjs +0 -2
  538. package/dist/types/action.mjs.map +0 -1
  539. package/dist/types/copilot-cloud-config.d.ts +0 -13
  540. package/dist/types/copilot-cloud-config.js +0 -19
  541. package/dist/types/copilot-cloud-config.js.map +0 -1
  542. package/dist/types/copilot-cloud-config.mjs +0 -2
  543. package/dist/types/copilot-cloud-config.mjs.map +0 -1
  544. package/dist/types/error.d.ts +0 -55
  545. package/dist/types/error.js +0 -19
  546. package/dist/types/error.js.map +0 -1
  547. package/dist/types/error.mjs +0 -2
  548. package/dist/types/error.mjs.map +0 -1
  549. package/dist/types/index.d.ts +0 -7
  550. package/dist/types/index.js +0 -19
  551. package/dist/types/index.js.map +0 -1
  552. package/dist/types/index.mjs +0 -8
  553. package/dist/types/index.mjs.map +0 -1
  554. package/dist/types/message.d.ts +0 -26
  555. package/dist/types/message.js +0 -19
  556. package/dist/types/message.js.map +0 -1
  557. package/dist/types/message.mjs +0 -2
  558. package/dist/types/message.mjs.map +0 -1
  559. package/dist/types/openai-assistant.d.ts +0 -53
  560. package/dist/types/openai-assistant.js +0 -19
  561. package/dist/types/openai-assistant.js.map +0 -1
  562. package/dist/types/openai-assistant.mjs +0 -2
  563. package/dist/types/openai-assistant.mjs.map +0 -1
  564. package/dist/types/utility.d.ts +0 -6
  565. package/dist/types/utility.js +0 -19
  566. package/dist/types/utility.js.map +0 -1
  567. package/dist/types/utility.mjs +0 -2
  568. package/dist/types/utility.mjs.map +0 -1
  569. package/dist/utils/conditions.js +0 -74
  570. package/dist/utils/conditions.js.map +0 -1
  571. package/dist/utils/console-styling.d.ts +0 -84
  572. package/dist/utils/console-styling.js +0 -123
  573. package/dist/utils/console-styling.js.map +0 -1
  574. package/dist/utils/errors.js +0 -443
  575. package/dist/utils/errors.js.map +0 -1
  576. package/dist/utils/index.d.ts +0 -32
  577. package/dist/utils/index.js +0 -927
  578. package/dist/utils/index.js.map +0 -1
  579. package/dist/utils/json-schema.js +0 -228
  580. package/dist/utils/json-schema.js.map +0 -1
  581. package/dist/utils/random-id.js +0 -68
  582. package/dist/utils/random-id.js.map +0 -1
  583. package/dist/utils/requests.js +0 -91
  584. package/dist/utils/requests.js.map +0 -1
  585. package/dist/utils/types.d.ts +0 -20
  586. package/dist/utils/types.js +0 -19
  587. package/dist/utils/types.js.map +0 -1
  588. package/jest.config.js +0 -5
  589. package/src/telemetry/scarf-client.ts +0 -39
  590. package/src/telemetry/security-check.ts +0 -0
  591. package/src/utils/json-schema.test.ts +0 -383
  592. package/tsup.config.ts +0 -11
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-ui-args.mjs","names":[],"sources":["../../src/generative-ui/render-ui-args.ts"],"sourcesContent":["import { isRecord } from \"./is-record\";\nexport interface ExtractedRenderUIArgs {\n target?: string;\n /**\n * Complete elements of the `operations` array, in order. A balanced element\n * that is not a valid JSON object is returned as `null`.\n */\n operations: Array<Record<string, unknown> | null>;\n /**\n * Set when an `operations[]` element was opened but its closing brace never\n * arrived: the text ends mid-operation (still streaming, or truncated).\n */\n incompleteOperation?: boolean;\n}\n\n/**\n * Reads `target` and every complete `operations[]` element from a possibly\n * truncated `render_ui` argument string.\n */\nexport function extractRenderUIArgs(text: string) {\n return new RenderUIArgsScanner().scan(text);\n}\n\n/**\n * The parser of {@link extractRenderUIArgs}, with its state kept between\n * calls. Each call scans only the text after the text it scanned before, so\n * a streamed argument string is scanned once in total.\n */\nclass RenderUIArgsScanner {\n private readonly result: ExtractedRenderUIArgs = { operations: [] };\n private readonly stack: Array<\"{\" | \"[\"> = [];\n private inString = false;\n private escaped = false;\n private stringStart = -1;\n private pendingKey: string | null = null;\n private currentKey: string | null = null;\n private expectingValue = false;\n private inOperations = false;\n private elementStart = -1;\n private scanned = 0;\n\n /**\n * Scans `text` from where the last call stopped.\n *\n * @param text - The whole text so far. It starts with the text of the\n * last call.\n * @returns The result so far. It is the same object on each call.\n */\n scan(text: string) {\n const { result, stack } = this;\n let {\n inString,\n escaped,\n stringStart,\n pendingKey,\n currentKey,\n expectingValue,\n inOperations,\n elementStart,\n } = this;\n for (let i = this.scanned; i < text.length; i++) {\n const ch = text[i];\n if (inString) {\n if (escaped) {\n escaped = false;\n } else if (ch === \"\\\\\") {\n escaped = true;\n } else if (ch === '\"') {\n inString = false;\n if (stack.length === 1) {\n const literal = text.slice(stringStart, i + 1);\n if (expectingValue) {\n if (currentKey === \"target\") {\n try {\n result.target = JSON.parse(literal);\n } catch {\n // Unreachable for a closed literal; keep scanning.\n }\n }\n expectingValue = false;\n } else {\n pendingKey = literal;\n }\n }\n }\n continue;\n }\n switch (ch) {\n case '\"':\n inString = true;\n stringStart = i;\n break;\n case \":\":\n if (stack.length === 1 && pendingKey !== null) {\n try {\n currentKey = JSON.parse(pendingKey);\n } catch {\n currentKey = null;\n }\n pendingKey = null;\n expectingValue = true;\n }\n break;\n case \",\":\n if (stack.length === 1) {\n expectingValue = false;\n currentKey = null;\n }\n break;\n case \"{\":\n if (inOperations && stack.length === 2) elementStart = i;\n stack.push(\"{\");\n break;\n case \"[\":\n if (\n stack.length === 1 &&\n expectingValue &&\n currentKey === \"operations\"\n ) {\n inOperations = true;\n }\n stack.push(\"[\");\n break;\n case \"}\":\n case \"]\":\n stack.pop();\n if (\n ch === \"}\" &&\n inOperations &&\n stack.length === 2 &&\n elementStart >= 0\n ) {\n result.operations.push(\n parseObject(text.slice(elementStart, i + 1)),\n );\n elementStart = -1;\n }\n if (ch === \"]\" && inOperations && stack.length === 1) {\n inOperations = false;\n expectingValue = false;\n }\n break;\n }\n }\n this.inString = inString;\n this.escaped = escaped;\n this.stringStart = stringStart;\n this.pendingKey = pendingKey;\n this.currentKey = currentKey;\n this.expectingValue = expectingValue;\n this.inOperations = inOperations;\n this.elementStart = elementStart;\n this.scanned = text.length;\n if (elementStart >= 0) result.incompleteOperation = true;\n else delete result.incompleteOperation;\n return result;\n }\n}\n\nfunction parseObject(raw: string) {\n try {\n const value: unknown = JSON.parse(raw);\n return isRecord(value) ? value : null;\n } catch {\n return null;\n }\n}\n\n/** Feeds streamed argument deltas and reports operations not yet seen. */\nexport class RenderUIArgsStream {\n private buffer = \"\";\n private emitted = 0;\n private incomplete = false;\n private readonly scanner = new RenderUIArgsScanner();\n\n push(delta: string) {\n this.buffer += delta;\n const { target, operations, incompleteOperation } = this.scanner.scan(\n this.buffer,\n );\n const newOperations = operations.slice(this.emitted);\n this.emitted = operations.length;\n this.incomplete = incompleteOperation === true;\n return { target, newOperations };\n }\n\n /** Every argument delta received so far, concatenated. */\n get text() {\n return this.buffer;\n }\n\n /**\n * True when the text received so far ends inside an `operations[]` element.\n * Once the tool call has ended, that element was truncated.\n */\n get hasIncompleteOperation() {\n return this.incomplete;\n }\n}\n"],"mappings":";;;;;;;AAmBA,SAAgB,oBAAoB,MAAc;AAChD,QAAO,IAAI,qBAAqB,CAAC,KAAK,KAAK;;;;;;;AAQ7C,IAAM,sBAAN,MAA0B;;gBACyB,EAAE,YAAY,EAAE,EAAE;eACxB,EAAE;kBAC1B;iBACD;qBACI;oBACc;oBACA;wBACX;sBACF;sBACA;iBACL;;;;;;;;;CASlB,KAAK,MAAc;EACjB,MAAM,EAAE,QAAQ,UAAU;EAC1B,IAAI,EACF,UACA,SACA,aACA,YACA,YACA,gBACA,cACA,iBACE;AACJ,OAAK,IAAI,IAAI,KAAK,SAAS,IAAI,KAAK,QAAQ,KAAK;GAC/C,MAAM,KAAK,KAAK;AAChB,OAAI,UAAU;AACZ,QAAI,QACF,WAAU;aACD,OAAO,KAChB,WAAU;aACD,OAAO,MAAK;AACrB,gBAAW;AACX,SAAI,MAAM,WAAW,GAAG;MACtB,MAAM,UAAU,KAAK,MAAM,aAAa,IAAI,EAAE;AAC9C,UAAI,gBAAgB;AAClB,WAAI,eAAe,SACjB,KAAI;AACF,eAAO,SAAS,KAAK,MAAM,QAAQ;eAC7B;AAIV,wBAAiB;YAEjB,cAAa;;;AAInB;;AAEF,WAAQ,IAAR;IACE,KAAK;AACH,gBAAW;AACX,mBAAc;AACd;IACF,KAAK;AACH,SAAI,MAAM,WAAW,KAAK,eAAe,MAAM;AAC7C,UAAI;AACF,oBAAa,KAAK,MAAM,WAAW;cAC7B;AACN,oBAAa;;AAEf,mBAAa;AACb,uBAAiB;;AAEnB;IACF,KAAK;AACH,SAAI,MAAM,WAAW,GAAG;AACtB,uBAAiB;AACjB,mBAAa;;AAEf;IACF,KAAK;AACH,SAAI,gBAAgB,MAAM,WAAW,EAAG,gBAAe;AACvD,WAAM,KAAK,IAAI;AACf;IACF,KAAK;AACH,SACE,MAAM,WAAW,KACjB,kBACA,eAAe,aAEf,gBAAe;AAEjB,WAAM,KAAK,IAAI;AACf;IACF,KAAK;IACL,KAAK;AACH,WAAM,KAAK;AACX,SACE,OAAO,OACP,gBACA,MAAM,WAAW,KACjB,gBAAgB,GAChB;AACA,aAAO,WAAW,KAChB,YAAY,KAAK,MAAM,cAAc,IAAI,EAAE,CAAC,CAC7C;AACD,qBAAe;;AAEjB,SAAI,OAAO,OAAO,gBAAgB,MAAM,WAAW,GAAG;AACpD,qBAAe;AACf,uBAAiB;;AAEnB;;;AAGN,OAAK,WAAW;AAChB,OAAK,UAAU;AACf,OAAK,cAAc;AACnB,OAAK,aAAa;AAClB,OAAK,aAAa;AAClB,OAAK,iBAAiB;AACtB,OAAK,eAAe;AACpB,OAAK,eAAe;AACpB,OAAK,UAAU,KAAK;AACpB,MAAI,gBAAgB,EAAG,QAAO,sBAAsB;MAC/C,QAAO,OAAO;AACnB,SAAO;;;AAIX,SAAS,YAAY,KAAa;AAChC,KAAI;EACF,MAAM,QAAiB,KAAK,MAAM,IAAI;AACtC,SAAO,SAAS,MAAM,GAAG,QAAQ;SAC3B;AACN,SAAO;;;;AAKX,IAAa,qBAAb,MAAgC;;gBACb;iBACC;oBACG;iBACM,IAAI,qBAAqB;;CAEpD,KAAK,OAAe;AAClB,OAAK,UAAU;EACf,MAAM,EAAE,QAAQ,YAAY,wBAAwB,KAAK,QAAQ,KAC/D,KAAK,OACN;EACD,MAAM,gBAAgB,WAAW,MAAM,KAAK,QAAQ;AACpD,OAAK,UAAU,WAAW;AAC1B,OAAK,aAAa,wBAAwB;AAC1C,SAAO;GAAE;GAAQ;GAAe;;;CAIlC,IAAI,OAAO;AACT,SAAO,KAAK;;;;;;CAOd,IAAI,yBAAyB;AAC3B,SAAO,KAAK"}
@@ -0,0 +1,101 @@
1
+
2
+ //#region src/generative-ui/types.ts
3
+ /** A2UI protocol version used on the wire. */
4
+ const A2UI_VERSION = "v1.0";
5
+ /** Activity type of a generated surface message. */
6
+ const GENERATIVE_UI_ACTIVITY_TYPE = "generative-ui-surface";
7
+ /** Activity type of a function call that the agent asks the client to run. */
8
+ const GENERATIVE_UI_FUNCTION_CALL_ACTIVITY_TYPE = "generative-ui-function-call";
9
+ /** Tool the model calls to render or update surfaces. */
10
+ const GENERATIVE_UI_RENDER_TOOL = "render_ui";
11
+ /** Target id of the chat transcript. */
12
+ const GENERATIVE_UI_CHAT_TARGET = "chat";
13
+ /** Component id every surface renders from. */
14
+ const GENERATIVE_UI_ROOT_ID = "root";
15
+ /**
16
+ * Whether the agent may call renderer functions with `callRendererFunction`.
17
+ * Off for now: the result goes back as a developer message, and not every
18
+ * backend keeps that message where the model reads it in order. While off,
19
+ * the prompts do not mention the operation, the validator rejects it, and
20
+ * the dispatcher refuses the agent, whatever a declaration's
21
+ * `allowedCallers` says. The code and its tests stay for when it is on.
22
+ */
23
+ const GENERATIVE_UI_AGENT_FUNCTION_CALLS = false;
24
+ /** The reason an agent function call is rejected while they are off. */
25
+ const GENERATIVE_UI_AGENT_FUNCTION_CALLS_OFF_REASON = "callRendererFunction is not supported in this version: the agent cannot call renderer functions until their results can be sent back to it reliably";
26
+ /** Activity message id of a surface. One message per surface. */
27
+ function generativeUISurfaceMessageId(surfaceId) {
28
+ return `genui:${surfaceId}`;
29
+ }
30
+ /**
31
+ * Activity message id of an agent-called function. One message per
32
+ * `functionCallId`.
33
+ *
34
+ * @param functionCallId - The `functionCallId` of the `callRendererFunction` operation.
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * generativeUIFunctionCallMessageId("f1"); // "genui-fn:f1"
39
+ * ```
40
+ */
41
+ function generativeUIFunctionCallMessageId(functionCallId) {
42
+ return `genui-fn:${functionCallId}`;
43
+ }
44
+ /**
45
+ * The keys of the A2UI 1.0 component envelope next to `id` and
46
+ * `component`: `catalogId`, `accessibility` and `metadata`. They are not
47
+ * props of the component. The renderer reads `accessibility` and ignores
48
+ * the other two.
49
+ */
50
+ const A2UI_COMPONENT_ENVELOPE_KEYS = new Set([
51
+ "catalogId",
52
+ "accessibility",
53
+ "metadata"
54
+ ]);
55
+ /** Most component names that one target can list. */
56
+ const GENERATIVE_UI_MAX_TARGET_COMPONENTS = 100;
57
+ /** Most rejections that a surface summary lists. */
58
+ const GENERATIVE_UI_MAX_SUMMARY_REJECTIONS = 20;
59
+ /** Most characters of one rejection in a surface summary. */
60
+ const GENERATIVE_UI_MAX_REJECTION_LENGTH = 500;
61
+ /**
62
+ * The action message of a user event, with the A2UI field names. Takes the
63
+ * time of the call when the event has no timestamp.
64
+ *
65
+ * @example
66
+ * ```ts
67
+ * toA2UIActionMessage({ name: "buy", surfaceId: "s1", componentId: "b", context: { sku: "a" } });
68
+ * // { version: "v1.0", action: { name: "buy", surfaceId: "s1", sourceComponentId: "b", timestamp: "2026-…", context: { sku: "a" } } }
69
+ * ```
70
+ */
71
+ function toA2UIActionMessage(event) {
72
+ return {
73
+ version: A2UI_VERSION,
74
+ action: {
75
+ name: event.name,
76
+ surfaceId: event.surfaceId,
77
+ sourceComponentId: event.componentId,
78
+ timestamp: event.timestamp ?? (/* @__PURE__ */ new Date()).toISOString(),
79
+ ...event.userMessage === void 0 ? {} : { userMessage: event.userMessage },
80
+ context: event.context
81
+ }
82
+ };
83
+ }
84
+
85
+ //#endregion
86
+ exports.A2UI_COMPONENT_ENVELOPE_KEYS = A2UI_COMPONENT_ENVELOPE_KEYS;
87
+ exports.A2UI_VERSION = A2UI_VERSION;
88
+ exports.GENERATIVE_UI_ACTIVITY_TYPE = GENERATIVE_UI_ACTIVITY_TYPE;
89
+ exports.GENERATIVE_UI_AGENT_FUNCTION_CALLS = GENERATIVE_UI_AGENT_FUNCTION_CALLS;
90
+ exports.GENERATIVE_UI_AGENT_FUNCTION_CALLS_OFF_REASON = GENERATIVE_UI_AGENT_FUNCTION_CALLS_OFF_REASON;
91
+ exports.GENERATIVE_UI_CHAT_TARGET = GENERATIVE_UI_CHAT_TARGET;
92
+ exports.GENERATIVE_UI_FUNCTION_CALL_ACTIVITY_TYPE = GENERATIVE_UI_FUNCTION_CALL_ACTIVITY_TYPE;
93
+ exports.GENERATIVE_UI_MAX_REJECTION_LENGTH = GENERATIVE_UI_MAX_REJECTION_LENGTH;
94
+ exports.GENERATIVE_UI_MAX_SUMMARY_REJECTIONS = GENERATIVE_UI_MAX_SUMMARY_REJECTIONS;
95
+ exports.GENERATIVE_UI_MAX_TARGET_COMPONENTS = GENERATIVE_UI_MAX_TARGET_COMPONENTS;
96
+ exports.GENERATIVE_UI_RENDER_TOOL = GENERATIVE_UI_RENDER_TOOL;
97
+ exports.GENERATIVE_UI_ROOT_ID = GENERATIVE_UI_ROOT_ID;
98
+ exports.generativeUIFunctionCallMessageId = generativeUIFunctionCallMessageId;
99
+ exports.generativeUISurfaceMessageId = generativeUISurfaceMessageId;
100
+ exports.toA2UIActionMessage = toA2UIActionMessage;
101
+ //# sourceMappingURL=types.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.cjs","names":[],"sources":["../../src/generative-ui/types.ts"],"sourcesContent":["/** A2UI protocol version used on the wire. */\nexport const A2UI_VERSION = \"v1.0\";\n/** Activity type of a generated surface message. */\nexport const GENERATIVE_UI_ACTIVITY_TYPE = \"generative-ui-surface\";\n/** Activity type of a function call that the agent asks the client to run. */\nexport const GENERATIVE_UI_FUNCTION_CALL_ACTIVITY_TYPE =\n \"generative-ui-function-call\";\n/** Tool the model calls to render or update surfaces. */\nexport const GENERATIVE_UI_RENDER_TOOL = \"render_ui\";\n/** Target id of the chat transcript. */\nexport const GENERATIVE_UI_CHAT_TARGET = \"chat\";\n/** Component id every surface renders from. */\nexport const GENERATIVE_UI_ROOT_ID = \"root\";\n/**\n * Whether the agent may call renderer functions with `callRendererFunction`.\n * Off for now: the result goes back as a developer message, and not every\n * backend keeps that message where the model reads it in order. While off,\n * the prompts do not mention the operation, the validator rejects it, and\n * the dispatcher refuses the agent, whatever a declaration's\n * `allowedCallers` says. The code and its tests stay for when it is on.\n */\nexport const GENERATIVE_UI_AGENT_FUNCTION_CALLS = false;\n/** The reason an agent function call is rejected while they are off. */\nexport const GENERATIVE_UI_AGENT_FUNCTION_CALLS_OFF_REASON =\n \"callRendererFunction is not supported in this version: the agent cannot call renderer functions until their results can be sent back to it reliably\";\n\n/** Activity message id of a surface. One message per surface. */\nexport function generativeUISurfaceMessageId(surfaceId: string) {\n return `genui:${surfaceId}`;\n}\n\n/**\n * Activity message id of an agent-called function. One message per\n * `functionCallId`.\n *\n * @param functionCallId - The `functionCallId` of the `callRendererFunction` operation.\n *\n * @example\n * ```ts\n * generativeUIFunctionCallMessageId(\"f1\"); // \"genui-fn:f1\"\n * ```\n */\nexport function generativeUIFunctionCallMessageId(functionCallId: string) {\n return `genui-fn:${functionCallId}`;\n}\n\nimport type {\n A2UIFunctionPermissions,\n A2UIFunctionReturnType,\n} from \"./basic-functions\";\n\n// Named `GenerativeUIJSONSchema` because the package root already exports a\n// `JSONSchema` (utils/json-schema.ts); the bare name would collide.\nexport type GenerativeUIJSONSchema = Record<string, unknown>;\n\nexport type A2UIComponentNode = {\n id: string;\n component: string;\n [prop: string]: unknown;\n};\n\n/**\n * The keys of the A2UI 1.0 component envelope next to `id` and\n * `component`: `catalogId`, `accessibility` and `metadata`. They are not\n * props of the component. The renderer reads `accessibility` and ignores\n * the other two.\n */\nexport const A2UI_COMPONENT_ENVELOPE_KEYS: ReadonlySet<string> = new Set([\n \"catalogId\",\n \"accessibility\",\n \"metadata\",\n]);\n\n/**\n * A call of a named function: `{ \"@call\": \"addToCart\", \"args\": { ... } }`.\n * Without `catalogId`, the function comes from the catalog of the run.\n */\nexport type A2UIFunctionCall = {\n \"@call\": string;\n args?: Record<string, unknown>;\n catalogId?: string;\n};\n\nexport type A2UIOperation =\n | {\n version: \"v1.0\";\n createSurface: {\n surfaceId: string;\n /** Left out by the model. The run's catalog id is filled in. */\n catalogId?: string;\n /** Components to add at once, checked like `updateComponents`. */\n components?: A2UIComponentNode[];\n /** The initial root data model. */\n dataModel?: Record<string, unknown>;\n sendDataModel?: boolean;\n metadata?: { extensions?: Record<string, unknown> };\n };\n }\n | {\n version: \"v1.0\";\n updateComponents: { surfaceId: string; components: A2UIComponentNode[] };\n }\n | {\n version: \"v1.0\";\n /**\n * Sets `value` at `path`. A `null` value deletes the key at `path`.\n * With no `path`, or `\"/\"`, it sets the whole data model.\n */\n updateDataModel: { surfaceId: string; path?: string; value: unknown };\n }\n | { version: \"v1.0\"; deleteSurface: { surfaceId: string } }\n | {\n version: \"v1.0\";\n /** Runs an app function in the browser, with no user interaction. */\n callRendererFunction: {\n functionCallId: string;\n callFunction: A2UIFunctionCall;\n };\n };\n\n/** Value of an event prop: run a host function, or report the event to the agent. */\nexport type GenerativeUIActionBinding =\n | {\n event: {\n name: string;\n /**\n * First line of the user message that the event becomes: text, a\n * data binding, or a function value such as formatString.\n */\n userMessage?: string | { \"@path\": string } | A2UIFunctionCall;\n context?: Record<string, unknown>;\n };\n }\n | { functionCall: A2UIFunctionCall };\n\nexport type GenerativeUISurfaceStatus = \"streaming\" | \"ready\" | \"error\";\n\nexport interface GenerativeUIRejectedOperation {\n /** Position of the operation in the render_ui call, or in the content list. */\n index: number;\n reason: string;\n}\n\n/** Content of a `generative-ui-surface` activity message. */\nexport interface GenerativeUISurfaceContent {\n surfaceId: string;\n target: string;\n catalogId: string;\n /** Committed (validated) operations, cumulative. */\n operations: A2UIOperation[];\n status: GenerativeUISurfaceStatus;\n rejected: GenerativeUIRejectedOperation[];\n}\n\n/** Content of a `generative-ui-function-call` activity message. */\nexport interface GenerativeUIFunctionCallContent {\n functionCallId: string;\n callFunction: A2UIFunctionCall;\n}\n\n/**\n * Value of a \"multiple\" slot that repeats one component for each item of the\n * list at `path`. Paths inside the repeated component are relative to the item.\n */\nexport type GenerativeUITemplateChildren = {\n componentId: string;\n path: string;\n};\n\nexport interface GenerativeUIComponentManifest {\n /** CopilotKit positional order across model-visible props, slots and events.\n * Exporters encode this as JSON Schema property order; it is not an A2UI keyword. */\n parameterOrder?: readonly string[];\n description?: string;\n props: GenerativeUIJSONSchema;\n events?: Record<\n string,\n { description?: string; parameters: GenerativeUIJSONSchema }\n >;\n /**\n * Props that hold child components. A \"single\" slot takes one component id.\n * A \"multiple\" slot takes a `string[]` of component ids, or a\n * {@link GenerativeUITemplateChildren} template.\n */\n slots?: Record<string, \"single\" | \"multiple\">;\n}\n\nexport interface GenerativeUIFunctionManifest extends A2UIFunctionPermissions {\n description?: string;\n parameters: GenerativeUIJSONSchema;\n /** What the function gives back, as A2UI 1.0 names it. */\n returnType?: A2UIFunctionReturnType;\n}\n\n/** Serializable description of what the browser can render and call. */\nexport interface GenerativeUIManifest {\n /** The catalog of the run. A surface with no `catalogId` gets this one. */\n catalogId: string;\n /**\n * Every catalog that a `catalogId` can name: `catalogId` first, then the\n * catalogs of `extends`. Left out, only `catalogId`.\n */\n catalogIds?: string[];\n components: Record<string, GenerativeUIComponentManifest>;\n functions: Record<string, GenerativeUIFunctionManifest>;\n /**\n * Places where the model can render surfaces. Only mounted targets are\n * listed. `description` tells the model where the target is on the page\n * and what to put in it.\n */\n targets: GenerativeUITarget[];\n /** Surfaces the client already holds for the current thread. */\n surfaces: Record<string, GenerativeUISurfaceSummary>;\n}\n\n/** A place where the model can render surfaces. */\nexport interface GenerativeUITarget {\n id: string;\n kind: \"chat\" | \"inline\";\n description?: string;\n /**\n * The only components that the surfaces of this target can use, at most\n * {@link GENERATIVE_UI_MAX_TARGET_COMPONENTS} names. Left out, the target\n * takes every component of the catalog.\n */\n components?: string[];\n}\n\n/** Most component names that one target can list. */\nexport const GENERATIVE_UI_MAX_TARGET_COMPONENTS = 100;\n\n/** Most rejections that a surface summary lists. */\nexport const GENERATIVE_UI_MAX_SUMMARY_REJECTIONS = 20;\n/** Most characters of one rejection in a surface summary. */\nexport const GENERATIVE_UI_MAX_REJECTION_LENGTH = 500;\n\n/** One surface that the client holds, as the model sees it. */\nexport interface GenerativeUISurfaceSummary {\n target: string;\n /** The values that the user set, by path. Left out when there are none. */\n dataModel?: Record<string, unknown>;\n /**\n * Operations that the client dropped, as `\"operation <index>: <reason>\"`.\n * At most {@link GENERATIVE_UI_MAX_SUMMARY_REJECTIONS} entries of at most\n * {@link GENERATIVE_UI_MAX_REJECTION_LENGTH} characters. Left out when\n * there are none.\n */\n rejected?: string[];\n /**\n * Left out while the surface exists. `\"deleted\"`: a deleteSurface removed\n * it, and its id cannot be used again. `\"failed\"`: its createSurface was\n * rejected, so it does not exist; a corrected createSurface can use the id.\n */\n status?: \"deleted\" | \"failed\";\n}\n\n/** A user interaction bound to `{ event }`, sent to the agent. */\nexport interface GenerativeUIUserEvent {\n name: string;\n surfaceId: string;\n componentId: string;\n context: Record<string, unknown>;\n /** The resolved `event.userMessage`: the first line of the user message. */\n userMessage?: string;\n /** When the user acted, as an ISO 8601 string. Filled in when left out. */\n timestamp?: string;\n}\n\n/**\n * The A2UI 1.0 action message of a user event: what a renderer sends to the\n * agent when the user triggers an `{ event }` action. The run that the\n * event starts carries it in the envelope (`copilotkit_action`), next to\n * the visible user message.\n */\nexport interface A2UIActionMessage {\n version: typeof A2UI_VERSION;\n action: {\n name: string;\n surfaceId: string;\n sourceComponentId: string;\n /** ISO 8601. */\n timestamp: string;\n userMessage?: string;\n context: Record<string, unknown>;\n };\n}\n\n/**\n * The action message of a user event, with the A2UI field names. Takes the\n * time of the call when the event has no timestamp.\n *\n * @example\n * ```ts\n * toA2UIActionMessage({ name: \"buy\", surfaceId: \"s1\", componentId: \"b\", context: { sku: \"a\" } });\n * // { version: \"v1.0\", action: { name: \"buy\", surfaceId: \"s1\", sourceComponentId: \"b\", timestamp: \"2026-…\", context: { sku: \"a\" } } }\n * ```\n */\nexport function toA2UIActionMessage(\n event: GenerativeUIUserEvent,\n): A2UIActionMessage {\n return {\n version: A2UI_VERSION,\n action: {\n name: event.name,\n surfaceId: event.surfaceId,\n sourceComponentId: event.componentId,\n timestamp: event.timestamp ?? new Date().toISOString(),\n ...(event.userMessage === undefined\n ? {}\n : { userMessage: event.userMessage }),\n context: event.context,\n },\n };\n}\n"],"mappings":";;;AACA,MAAa,eAAe;;AAE5B,MAAa,8BAA8B;;AAE3C,MAAa,4CACX;;AAEF,MAAa,4BAA4B;;AAEzC,MAAa,4BAA4B;;AAEzC,MAAa,wBAAwB;;;;;;;;;AASrC,MAAa,qCAAqC;;AAElD,MAAa,gDACX;;AAGF,SAAgB,6BAA6B,WAAmB;AAC9D,QAAO,SAAS;;;;;;;;;;;;;AAclB,SAAgB,kCAAkC,gBAAwB;AACxE,QAAO,YAAY;;;;;;;;AAwBrB,MAAa,+BAAoD,IAAI,IAAI;CACvE;CACA;CACA;CACD,CAAC;;AA8JF,MAAa,sCAAsC;;AAGnD,MAAa,uCAAuC;;AAEpD,MAAa,qCAAqC;;;;;;;;;;;AA+DlD,SAAgB,oBACd,OACmB;AACnB,QAAO;EACL,SAAS;EACT,QAAQ;GACN,MAAM,MAAM;GACZ,WAAW,MAAM;GACjB,mBAAmB,MAAM;GACzB,WAAW,MAAM,8BAAa,IAAI,MAAM,EAAC,aAAa;GACtD,GAAI,MAAM,gBAAgB,SACtB,EAAE,GACF,EAAE,aAAa,MAAM,aAAa;GACtC,SAAS,MAAM;GAChB;EACF"}
@@ -0,0 +1,270 @@
1
+ import { A2UIFunctionPermissions, A2UIFunctionReturnType } from "./basic-functions.cjs";
2
+
3
+ //#region src/generative-ui/types.d.ts
4
+ /** A2UI protocol version used on the wire. */
5
+ declare const A2UI_VERSION = "v1.0";
6
+ /** Activity type of a generated surface message. */
7
+ declare const GENERATIVE_UI_ACTIVITY_TYPE = "generative-ui-surface";
8
+ /** Activity type of a function call that the agent asks the client to run. */
9
+ declare const GENERATIVE_UI_FUNCTION_CALL_ACTIVITY_TYPE = "generative-ui-function-call";
10
+ /** Tool the model calls to render or update surfaces. */
11
+ declare const GENERATIVE_UI_RENDER_TOOL = "render_ui";
12
+ /** Target id of the chat transcript. */
13
+ declare const GENERATIVE_UI_CHAT_TARGET = "chat";
14
+ /** Component id every surface renders from. */
15
+ declare const GENERATIVE_UI_ROOT_ID = "root";
16
+ /**
17
+ * Whether the agent may call renderer functions with `callRendererFunction`.
18
+ * Off for now: the result goes back as a developer message, and not every
19
+ * backend keeps that message where the model reads it in order. While off,
20
+ * the prompts do not mention the operation, the validator rejects it, and
21
+ * the dispatcher refuses the agent, whatever a declaration's
22
+ * `allowedCallers` says. The code and its tests stay for when it is on.
23
+ */
24
+ declare const GENERATIVE_UI_AGENT_FUNCTION_CALLS = false;
25
+ /** The reason an agent function call is rejected while they are off. */
26
+ declare const GENERATIVE_UI_AGENT_FUNCTION_CALLS_OFF_REASON = "callRendererFunction is not supported in this version: the agent cannot call renderer functions until their results can be sent back to it reliably";
27
+ /** Activity message id of a surface. One message per surface. */
28
+ declare function generativeUISurfaceMessageId(surfaceId: string): string;
29
+ /**
30
+ * Activity message id of an agent-called function. One message per
31
+ * `functionCallId`.
32
+ *
33
+ * @param functionCallId - The `functionCallId` of the `callRendererFunction` operation.
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * generativeUIFunctionCallMessageId("f1"); // "genui-fn:f1"
38
+ * ```
39
+ */
40
+ declare function generativeUIFunctionCallMessageId(functionCallId: string): string;
41
+ type GenerativeUIJSONSchema = Record<string, unknown>;
42
+ type A2UIComponentNode = {
43
+ id: string;
44
+ component: string;
45
+ [prop: string]: unknown;
46
+ };
47
+ /**
48
+ * The keys of the A2UI 1.0 component envelope next to `id` and
49
+ * `component`: `catalogId`, `accessibility` and `metadata`. They are not
50
+ * props of the component. The renderer reads `accessibility` and ignores
51
+ * the other two.
52
+ */
53
+ declare const A2UI_COMPONENT_ENVELOPE_KEYS: ReadonlySet<string>;
54
+ /**
55
+ * A call of a named function: `{ "@call": "addToCart", "args": { ... } }`.
56
+ * Without `catalogId`, the function comes from the catalog of the run.
57
+ */
58
+ type A2UIFunctionCall = {
59
+ "@call": string;
60
+ args?: Record<string, unknown>;
61
+ catalogId?: string;
62
+ };
63
+ type A2UIOperation = {
64
+ version: "v1.0";
65
+ createSurface: {
66
+ surfaceId: string; /** Left out by the model. The run's catalog id is filled in. */
67
+ catalogId?: string; /** Components to add at once, checked like `updateComponents`. */
68
+ components?: A2UIComponentNode[]; /** The initial root data model. */
69
+ dataModel?: Record<string, unknown>;
70
+ sendDataModel?: boolean;
71
+ metadata?: {
72
+ extensions?: Record<string, unknown>;
73
+ };
74
+ };
75
+ } | {
76
+ version: "v1.0";
77
+ updateComponents: {
78
+ surfaceId: string;
79
+ components: A2UIComponentNode[];
80
+ };
81
+ } | {
82
+ version: "v1.0";
83
+ /**
84
+ * Sets `value` at `path`. A `null` value deletes the key at `path`.
85
+ * With no `path`, or `"/"`, it sets the whole data model.
86
+ */
87
+ updateDataModel: {
88
+ surfaceId: string;
89
+ path?: string;
90
+ value: unknown;
91
+ };
92
+ } | {
93
+ version: "v1.0";
94
+ deleteSurface: {
95
+ surfaceId: string;
96
+ };
97
+ } | {
98
+ version: "v1.0"; /** Runs an app function in the browser, with no user interaction. */
99
+ callRendererFunction: {
100
+ functionCallId: string;
101
+ callFunction: A2UIFunctionCall;
102
+ };
103
+ };
104
+ /** Value of an event prop: run a host function, or report the event to the agent. */
105
+ type GenerativeUIActionBinding = {
106
+ event: {
107
+ name: string;
108
+ /**
109
+ * First line of the user message that the event becomes: text, a
110
+ * data binding, or a function value such as formatString.
111
+ */
112
+ userMessage?: string | {
113
+ "@path": string;
114
+ } | A2UIFunctionCall;
115
+ context?: Record<string, unknown>;
116
+ };
117
+ } | {
118
+ functionCall: A2UIFunctionCall;
119
+ };
120
+ type GenerativeUISurfaceStatus = "streaming" | "ready" | "error";
121
+ interface GenerativeUIRejectedOperation {
122
+ /** Position of the operation in the render_ui call, or in the content list. */
123
+ index: number;
124
+ reason: string;
125
+ }
126
+ /** Content of a `generative-ui-surface` activity message. */
127
+ interface GenerativeUISurfaceContent {
128
+ surfaceId: string;
129
+ target: string;
130
+ catalogId: string;
131
+ /** Committed (validated) operations, cumulative. */
132
+ operations: A2UIOperation[];
133
+ status: GenerativeUISurfaceStatus;
134
+ rejected: GenerativeUIRejectedOperation[];
135
+ }
136
+ /** Content of a `generative-ui-function-call` activity message. */
137
+ interface GenerativeUIFunctionCallContent {
138
+ functionCallId: string;
139
+ callFunction: A2UIFunctionCall;
140
+ }
141
+ /**
142
+ * Value of a "multiple" slot that repeats one component for each item of the
143
+ * list at `path`. Paths inside the repeated component are relative to the item.
144
+ */
145
+ type GenerativeUITemplateChildren = {
146
+ componentId: string;
147
+ path: string;
148
+ };
149
+ interface GenerativeUIComponentManifest {
150
+ /** CopilotKit positional order across model-visible props, slots and events.
151
+ * Exporters encode this as JSON Schema property order; it is not an A2UI keyword. */
152
+ parameterOrder?: readonly string[];
153
+ description?: string;
154
+ props: GenerativeUIJSONSchema;
155
+ events?: Record<string, {
156
+ description?: string;
157
+ parameters: GenerativeUIJSONSchema;
158
+ }>;
159
+ /**
160
+ * Props that hold child components. A "single" slot takes one component id.
161
+ * A "multiple" slot takes a `string[]` of component ids, or a
162
+ * {@link GenerativeUITemplateChildren} template.
163
+ */
164
+ slots?: Record<string, "single" | "multiple">;
165
+ }
166
+ interface GenerativeUIFunctionManifest extends A2UIFunctionPermissions {
167
+ description?: string;
168
+ parameters: GenerativeUIJSONSchema;
169
+ /** What the function gives back, as A2UI 1.0 names it. */
170
+ returnType?: A2UIFunctionReturnType;
171
+ }
172
+ /** Serializable description of what the browser can render and call. */
173
+ interface GenerativeUIManifest {
174
+ /** The catalog of the run. A surface with no `catalogId` gets this one. */
175
+ catalogId: string;
176
+ /**
177
+ * Every catalog that a `catalogId` can name: `catalogId` first, then the
178
+ * catalogs of `extends`. Left out, only `catalogId`.
179
+ */
180
+ catalogIds?: string[];
181
+ components: Record<string, GenerativeUIComponentManifest>;
182
+ functions: Record<string, GenerativeUIFunctionManifest>;
183
+ /**
184
+ * Places where the model can render surfaces. Only mounted targets are
185
+ * listed. `description` tells the model where the target is on the page
186
+ * and what to put in it.
187
+ */
188
+ targets: GenerativeUITarget[];
189
+ /** Surfaces the client already holds for the current thread. */
190
+ surfaces: Record<string, GenerativeUISurfaceSummary>;
191
+ }
192
+ /** A place where the model can render surfaces. */
193
+ interface GenerativeUITarget {
194
+ id: string;
195
+ kind: "chat" | "inline";
196
+ description?: string;
197
+ /**
198
+ * The only components that the surfaces of this target can use, at most
199
+ * {@link GENERATIVE_UI_MAX_TARGET_COMPONENTS} names. Left out, the target
200
+ * takes every component of the catalog.
201
+ */
202
+ components?: string[];
203
+ }
204
+ /** Most component names that one target can list. */
205
+ declare const GENERATIVE_UI_MAX_TARGET_COMPONENTS = 100;
206
+ /** Most rejections that a surface summary lists. */
207
+ declare const GENERATIVE_UI_MAX_SUMMARY_REJECTIONS = 20;
208
+ /** Most characters of one rejection in a surface summary. */
209
+ declare const GENERATIVE_UI_MAX_REJECTION_LENGTH = 500;
210
+ /** One surface that the client holds, as the model sees it. */
211
+ interface GenerativeUISurfaceSummary {
212
+ target: string;
213
+ /** The values that the user set, by path. Left out when there are none. */
214
+ dataModel?: Record<string, unknown>;
215
+ /**
216
+ * Operations that the client dropped, as `"operation <index>: <reason>"`.
217
+ * At most {@link GENERATIVE_UI_MAX_SUMMARY_REJECTIONS} entries of at most
218
+ * {@link GENERATIVE_UI_MAX_REJECTION_LENGTH} characters. Left out when
219
+ * there are none.
220
+ */
221
+ rejected?: string[];
222
+ /**
223
+ * Left out while the surface exists. `"deleted"`: a deleteSurface removed
224
+ * it, and its id cannot be used again. `"failed"`: its createSurface was
225
+ * rejected, so it does not exist; a corrected createSurface can use the id.
226
+ */
227
+ status?: "deleted" | "failed";
228
+ }
229
+ /** A user interaction bound to `{ event }`, sent to the agent. */
230
+ interface GenerativeUIUserEvent {
231
+ name: string;
232
+ surfaceId: string;
233
+ componentId: string;
234
+ context: Record<string, unknown>;
235
+ /** The resolved `event.userMessage`: the first line of the user message. */
236
+ userMessage?: string;
237
+ /** When the user acted, as an ISO 8601 string. Filled in when left out. */
238
+ timestamp?: string;
239
+ }
240
+ /**
241
+ * The A2UI 1.0 action message of a user event: what a renderer sends to the
242
+ * agent when the user triggers an `{ event }` action. The run that the
243
+ * event starts carries it in the envelope (`copilotkit_action`), next to
244
+ * the visible user message.
245
+ */
246
+ interface A2UIActionMessage {
247
+ version: typeof A2UI_VERSION;
248
+ action: {
249
+ name: string;
250
+ surfaceId: string;
251
+ sourceComponentId: string; /** ISO 8601. */
252
+ timestamp: string;
253
+ userMessage?: string;
254
+ context: Record<string, unknown>;
255
+ };
256
+ }
257
+ /**
258
+ * The action message of a user event, with the A2UI field names. Takes the
259
+ * time of the call when the event has no timestamp.
260
+ *
261
+ * @example
262
+ * ```ts
263
+ * toA2UIActionMessage({ name: "buy", surfaceId: "s1", componentId: "b", context: { sku: "a" } });
264
+ * // { version: "v1.0", action: { name: "buy", surfaceId: "s1", sourceComponentId: "b", timestamp: "2026-…", context: { sku: "a" } } }
265
+ * ```
266
+ */
267
+ declare function toA2UIActionMessage(event: GenerativeUIUserEvent): A2UIActionMessage;
268
+ //#endregion
269
+ export { A2UIActionMessage, A2UIComponentNode, A2UIFunctionCall, A2UIOperation, A2UI_COMPONENT_ENVELOPE_KEYS, A2UI_VERSION, GENERATIVE_UI_ACTIVITY_TYPE, GENERATIVE_UI_AGENT_FUNCTION_CALLS, GENERATIVE_UI_AGENT_FUNCTION_CALLS_OFF_REASON, GENERATIVE_UI_CHAT_TARGET, GENERATIVE_UI_FUNCTION_CALL_ACTIVITY_TYPE, GENERATIVE_UI_MAX_REJECTION_LENGTH, GENERATIVE_UI_MAX_SUMMARY_REJECTIONS, GENERATIVE_UI_MAX_TARGET_COMPONENTS, GENERATIVE_UI_RENDER_TOOL, GENERATIVE_UI_ROOT_ID, GenerativeUIActionBinding, GenerativeUIComponentManifest, GenerativeUIFunctionCallContent, GenerativeUIFunctionManifest, GenerativeUIJSONSchema, GenerativeUIManifest, GenerativeUIRejectedOperation, GenerativeUISurfaceContent, GenerativeUISurfaceStatus, GenerativeUISurfaceSummary, GenerativeUITarget, GenerativeUITemplateChildren, GenerativeUIUserEvent, generativeUIFunctionCallMessageId, generativeUISurfaceMessageId, toA2UIActionMessage };
270
+ //# sourceMappingURL=types.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.cts","names":[],"sources":["../../src/generative-ui/types.ts"],"mappings":";;;;cACa,YAAA;;cAEA,2BAAA;;cAEA,yCAAA;;cAGA,yBAAA;AALb;AAAA,cAOa,yBAAA;;cAEA,qBAAA;;AAPb;;;;;AAGA;;cAaa,kCAAA;;cAEA,6CAAA;AAbb;AAAA,iBAiBgB,4BAAA,CAA6B,SAAA;;;;AAf7C;;;;;AASA;;;iBAqBgB,iCAAA,CAAkC,cAAA;AAAA,KAWtC,sBAAA,GAAyB,MAAA;AAAA,KAEzB,iBAAA;EACV,EAAA;EACA,SAAA;EAAA,CACC,IAAA;AAAA;;;;;AAhBH;;cAyBa,4BAAA,EAA8B,WAAA;;;AAd3C;;KAwBY,gBAAA;EACV,OAAA;EACA,IAAA,GAAO,MAAA;EACP,SAAA;AAAA;AAAA,KAGU,aAAA;EAEN,OAAA;EACA,aAAA;IACE,SAAA,UA7BL;IA+BK,SAAA,WA/BO;IAiCP,UAAA,GAAa,iBAAA,IApBnB;IAsBM,SAAA,GAAY,MAAA;IACZ,aAAA;IACA,QAAA;MAAa,UAAA,GAAa,MAAA;IAAA;EAAA;AAAA;EAI5B,OAAA;EACA,gBAAA;IAAoB,SAAA;IAAmB,UAAA,EAAY,iBAAA;EAAA;AAAA;EAGnD,OAAA;EApBmB;;;;EAyBnB,eAAA;IAAmB,SAAA;IAAmB,IAAA;IAAe,KAAA;EAAA;AAAA;EAErD,OAAA;EAAiB,aAAA;IAAiB,SAAA;EAAA;AAAA;EAElC,OAAA,UAnBc;EAqBd,oBAAA;IACE,cAAA;IACA,YAAA,EAAc,gBAAA;EAAA;AAAA;;KAKV,yBAAA;EAEN,KAAA;IACE,IAAA;IArBF;;;;IA0BE,WAAA;MAAyB,OAAA;IAAA,IAAoB,gBAAA;IAC7C,OAAA,GAAU,MAAA;EAAA;AAAA;EAGZ,YAAA,EAAc,gBAAA;AAAA;AAAA,KAER,yBAAA;AAAA,UAEK,6BAAA;EArBqB;EAuBpC,KAAA;EACA,MAAA;AAAA;;UAIe,0BAAA;EACf,SAAA;EACA,MAAA;EACA,SAAA;EAxBI;EA0BJ,UAAA,EAAY,aAAA;EACZ,MAAA,EAAQ,yBAAA;EACR,QAAA,EAAU,6BAAA;AAAA;;UAIK,+BAAA;EACf,cAAA;EACA,YAAA,EAAc,gBAAA;AAAA;;AAtBhB;;;KA6BY,4BAAA;EACV,WAAA;EACA,IAAA;AAAA;AAAA,UAGe,6BAAA;EA9Bf;;EAiCA,cAAA;EACA,WAAA;EACA,KAAA,EAAO,sBAAA;EACP,MAAA,GAAS,MAAA;IAEL,WAAA;IAAsB,UAAA,EAAY,sBAAA;EAAA;EA1BC;;;;;EAiCvC,KAAA,GAAQ,MAAA;AAAA;AAAA,UAGO,4BAAA,SAAqC,uBAAA;EACpD,WAAA;EACA,UAAA,EAAY,sBAAA;EAtC2B;EAwCvC,UAAA,GAAa,sBAAA;AAAA;;UAIE,oBAAA;EAtCe;EAwC9B,SAAA;EAxCA;;;;EA6CA,UAAA;EACA,UAAA,EAAY,MAAA,SAAe,6BAAA;EAC3B,SAAA,EAAW,MAAA,SAAe,4BAAA;EAvC1B;;AAIF;;;EAyCE,OAAA,EAAS,kBAAA;EAjC6B;EAmCtC,QAAA,EAAU,MAAA,SAAe,0BAAA;AAAA;;UAIV,kBAAA;EACf,EAAA;EACA,IAAA;EACA,WAAA;EA7CO;;;;;EAmDP,UAAA;AAAA;;cAIW,mCAAA;;cAGA,oCAAA;;cAEA,kCAAA;;UAGI,0BAAA;EACf,MAAA;EAnD2E;EAqD3E,SAAA,GAAY,MAAA;EArDwC;;;;;;EA4DpD,QAAA;EAxDmC;AAIrC;;;;EA0DE,MAAA;AAAA;;UAIe,qBAAA;EACf,IAAA;EACA,SAAA;EACA,WAAA;EACA,OAAA,EAAS,MAAA;EAhET;EAkEA,WAAA;EA5DA;EA8DA,SAAA;AAAA;;;;;;;UASe,iBAAA;EACf,OAAA,SAAgB,YAAA;EAChB,MAAA;IACE,IAAA;IACA,SAAA;IACA,iBAAA,UA/D+B;IAiE/B,SAAA;IACA,WAAA;IACA,OAAA,EAAS,MAAA;EAAA;AAAA;;;AAtDb;;;;;AAGA;;;iBAiEgB,mBAAA,CACd,KAAA,EAAO,qBAAA,GACN,iBAAA"}