@copilotkit/shared 2.0.0-next.1 → 2.0.0-rc.0

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
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) Atai Barkai
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md CHANGED
@@ -48,9 +48,9 @@
48
48
  const { visibleMessages, appendMessage, setMessages, ... } = useCopilotChat();
49
49
 
50
50
  // Pre-built components with deep customization options (CSS + pass custom sub-components)
51
- <CopilotPopup
52
- instructions={"You are assisting the user as best as you can. Answer in the best way possible given the data you have."}
53
- labels={{ title: "Popup Assistant", initial: "Need any help?" }}
51
+ <CopilotPopup
52
+ instructions={"You are assisting the user as best as you can. Answer in the best way possible given the data you have."}
53
+ labels={{ title: "Popup Assistant", initial: "Need any help?" }}
54
54
  />
55
55
  ```
56
56
 
@@ -71,9 +71,9 @@ useCopilotAction({
71
71
 
72
72
  ```ts
73
73
  // Share state between app and agent
74
- const { agentState } = useCoAgent({
75
- name: "basic_agent",
76
- initialState: { input: "NYC" }
74
+ const { agentState } = useCoAgent({
75
+ name: "basic_agent",
76
+ initialState: { input: "NYC" }
77
77
  });
78
78
 
79
79
  // agentic generative UI
@@ -114,14 +114,20 @@ useCopilotAction({
114
114
  ```ts
115
115
  // intermediate agent state streaming (supports both LangGraph.js + LangGraph python)
116
116
  const modifiedConfig = copilotKitCustomizeConfig(config, {
117
- emitIntermediateState: [{
118
- stateKey: "outline",
119
- tool: "set_outline",
120
- toolArgument: "outline"
121
- }],
117
+ emitIntermediateState: [
118
+ {
119
+ stateKey: "outline",
120
+ tool: "set_outline",
121
+ toolArgument: "outline",
122
+ },
123
+ ],
122
124
  });
123
- const response = await ChatOpenAI({ model: "gpt-4o" }).invoke(messages, modifiedConfig);
125
+ const response = await ChatOpenAI({ model: "gpt-4o" }).invoke(
126
+ messages,
127
+ modifiedConfig,
128
+ );
124
129
  ```
130
+
125
131
  ## 🏆 Featured Examples
126
132
 
127
133
  <p align="center">
@@ -136,6 +142,81 @@ const response = await ChatOpenAI({ model: "gpt-4o" }).invoke(messages, modified
136
142
  </a>
137
143
  </p>
138
144
 
145
+ ## Trusted Inspector metadata
146
+
147
+ `@copilotkit/shared` exports the versioned `InspectorMetadataV1` contract and
148
+ `parseInspectorMetadataV1()` parser. A Copilot Runtime can use this contract to
149
+ send project and license context to the Inspector:
150
+
151
+ ```ts
152
+ interface InspectorMetadataV1 {
153
+ readonly schemaVersion: 1;
154
+ readonly identity?: {
155
+ readonly organizationName: string;
156
+ readonly projectName: string;
157
+ };
158
+ readonly plan?: { readonly code: string; readonly label: string };
159
+ readonly license?: {
160
+ readonly state: "valid" | "none" | "expired" | "unknown";
161
+ };
162
+ readonly action?:
163
+ | { readonly kind: "manage_plan"; readonly url: string }
164
+ | { readonly kind: "renew"; readonly url: string }
165
+ | { readonly kind: "enable_intelligence"; readonly url: string };
166
+ readonly usage?: {
167
+ readonly used: number;
168
+ readonly limit:
169
+ | { readonly kind: "finite"; readonly value: number }
170
+ | { readonly kind: "unlimited" }
171
+ | { readonly kind: "unknown" };
172
+ readonly expiringSoonCount?: number;
173
+ };
174
+ }
175
+ ```
176
+
177
+ Every optional module is independent. The parser drops an invalid `identity`,
178
+ `plan`, `license`, `action`, or `usage` module without hiding valid sibling
179
+ modules. It returns `undefined` when the top-level value is not a plain object
180
+ with `schemaVersion: 1`.
181
+
182
+ Action URLs are treated as trusted navigation only after parsing. They must use
183
+ HTTPS, or HTTP on `localhost`, `127.0.0.1`, or `[::1]`; URLs with credentials, a
184
+ query string, or a fragment are rejected. Consumers use the accepted URL as
185
+ supplied and must not derive a destination from identity or plan values.
186
+
187
+ The optional `usage.expiringSoonCount` field lets V1 producers report a known
188
+ count. Older producers may omit it; absence remains valid V1 usage, while `0`
189
+ is a known count and stays distinct from absence. The parser drops a malformed,
190
+ inherited, or accessor-backed expiry leaf without removing `used`, `limit`, or
191
+ valid sibling modules. Older V1 consumers ignore the additive field, so
192
+ producers and consumers do not need a V2 schema or lock-step deployment.
193
+
194
+ `RuntimeInfo.inspectorMetadata?: boolean` is the capability signal. Clients only
195
+ request the optional metadata route when a runtime reports
196
+ `inspectorMetadata: true` in its runtime-info response.
197
+
139
198
  # Documentation
140
199
 
141
200
  To get started with CopilotKit, please check out the [documentation](https://docs.copilotkit.ai).
201
+
202
+ ## Event and attachment conversion
203
+
204
+ `createAttachmentContent` from `@copilotkit/shared` builds the same AG-UI
205
+ attachment content part used by the React, Angular, and Vue chat components.
206
+ It preserves the source and merges the filename into metadata, with explicit
207
+ metadata taking precedence.
208
+
209
+ The Node-only `@copilotkit/shared/event-transforms` entry exports
210
+ `OpenGenerativeUIMiddleware`, the existing upstream `A2UIMiddleware`, and
211
+ `transformRecordedEvents(input, events, options)`. The latter applies the same
212
+ converters to one recorded, pre-middleware AG-UI run without executing tools or
213
+ contacting an agent. Enable converters explicitly with `openGenerativeUI: true`
214
+ and/or `a2ui: { ...originalRuntimeOptions }`. Pass the recorded input, including
215
+ prior messages and catalog context, to preserve live conversion behavior.
216
+
217
+ The result includes the original events and generated activities in runtime
218
+ order. The caller owns persistence IDs, historical timestamps, and provenance.
219
+ A2UI can generate random message IDs for synthetic tool results; an importer
220
+ that needs deterministic IDs must assign them before saving. Do not process
221
+ already transformed histories a second time. This entry does not include MCP
222
+ execution or recreate runtime configuration absent from the recording.
@@ -0,0 +1,29 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) {
13
+ __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ }
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
25
+ }) : target, mod));
26
+
27
+ //#endregion
28
+
29
+ exports.__toESM = __toESM;
@@ -0,0 +1,154 @@
1
+ const require_is_record = require('./generative-ui/is-record.cjs');
2
+ const require_types = require('./generative-ui/types.cjs');
3
+
4
+ //#region src/a2ui-envelope.ts
5
+ /**
6
+ * The generative UI envelope that the client sends on every run as
7
+ * `forwardedProps.copilotkit.ui`. It has the A2UI v1.0 renderer capabilities
8
+ * shape, so a backend that speaks A2UI v1.0 can read the catalog as it is.
9
+ * CopilotKit data goes in `metadata.extensions`, under `copilotkit_` keys.
10
+ * The runtime reads it to pick the transport and to build the guide.
11
+ */
12
+ /** Top-level `forwardedProps` key that holds the CopilotKit run properties. */
13
+ const COPILOTKIT_FORWARDED_PROPS_KEY = "copilotkit";
14
+ /** Version of the envelope shape (not of the UI protocol that it carries). */
15
+ const COPILOTKIT_UI_ENVELOPE_FORMAT = 3;
16
+ function isOptionalString(value) {
17
+ return value === void 0 || typeof value === "string";
18
+ }
19
+ function isNonEmptyString(value) {
20
+ return typeof value === "string" && value !== "";
21
+ }
22
+ function isRecordOf(value, isEntry) {
23
+ return require_is_record.isRecord(value) && Object.values(value).every(isEntry);
24
+ }
25
+ /** A function, or an event of a component: a description and a parameter schema. */
26
+ function isSchemaEntry(value) {
27
+ return require_is_record.isRecord(value) && require_is_record.isRecord(value.parameters) && isOptionalString(value.description);
28
+ }
29
+ function isSlotKind(value) {
30
+ return value === "single" || value === "multiple";
31
+ }
32
+ /**
33
+ * `validateOperation` reads `properties` and `required` of a props schema,
34
+ * so those two must have the right shape when they are there.
35
+ */
36
+ function isPropsSchema(value) {
37
+ return require_is_record.isRecord(value) && (value.properties === void 0 || require_is_record.isRecord(value.properties)) && (value.required === void 0 || Array.isArray(value.required) && value.required.every((name) => typeof name === "string"));
38
+ }
39
+ function isComponentManifest(value) {
40
+ if (!require_is_record.isRecord(value) || !isPropsSchema(value.props) || !isOptionalString(value.description) || value.events !== void 0 && !isRecordOf(value.events, isSchemaEntry) || value.slots !== void 0 && !isRecordOf(value.slots, isSlotKind)) return false;
41
+ const order = value.parameterOrder;
42
+ if (order === void 0) return true;
43
+ const keys = new Set([
44
+ ...Object.keys(value.props.properties ?? {}),
45
+ ...Object.keys(value.slots ?? {}),
46
+ ...Object.keys(value.events ?? {})
47
+ ]);
48
+ return Array.isArray(order) && new Set(order).size === order.length && order.every((key) => typeof key === "string" && keys.has(key));
49
+ }
50
+ function isInlineCatalog(value) {
51
+ return require_is_record.isRecord(value) && isNonEmptyString(value.catalogId) && value.protocolVersion === "1.0" && (value.components === void 0 || isRecordOf(value.components, isComponentManifest)) && isRecordOf(value.functions, isSchemaEntry) && isOptionalString(value.instructions);
52
+ }
53
+ function isCapabilities(value) {
54
+ return require_is_record.isRecord(value) && Array.isArray(value.supportedCatalogIds) && value.supportedCatalogIds.length > 0 && value.supportedCatalogIds.every(isNonEmptyString) && (value.inlineCatalogs === void 0 || Array.isArray(value.inlineCatalogs) && value.inlineCatalogs.every(isInlineCatalog));
55
+ }
56
+ /** A short list of component names. */
57
+ function isComponentNameList(value) {
58
+ return Array.isArray(value) && value.length <= require_types.GENERATIVE_UI_MAX_TARGET_COMPONENTS && value.every(isNonEmptyString);
59
+ }
60
+ function isTarget(value) {
61
+ return require_is_record.isRecord(value) && isNonEmptyString(value.id) && (value.kind === "chat" || value.kind === "inline") && isOptionalString(value.description) && (value.components === void 0 || isComponentNameList(value.components));
62
+ }
63
+ /** A short list of short strings. The summary limits keep the guide small. */
64
+ function isRejectionList(value) {
65
+ return Array.isArray(value) && value.length <= require_types.GENERATIVE_UI_MAX_SUMMARY_REJECTIONS && value.every((entry) => typeof entry === "string" && entry.length <= require_types.GENERATIVE_UI_MAX_REJECTION_LENGTH);
66
+ }
67
+ function isSurfaceEntry(value) {
68
+ return require_is_record.isRecord(value) && isNonEmptyString(value.target) && (value.dataModel === void 0 || require_is_record.isRecord(value.dataModel)) && (value.rejected === void 0 || isRejectionList(value.rejected)) && (value.status === void 0 || value.status === "deleted" || value.status === "failed");
69
+ }
70
+ /** Checks the `copilotkit_` keys only. Other extensions can be there too. */
71
+ function isExtensions(value) {
72
+ return require_is_record.isRecord(value) && value.copilotkit_format === COPILOTKIT_UI_ENVELOPE_FORMAT && (value.copilotkit_transport === "tool" || value.copilotkit_transport === "markdown") && Array.isArray(value.copilotkit_targets) && value.copilotkit_targets.every(isTarget) && isRecordOf(value.copilotkit_surfaces, isSurfaceEntry) && typeof value.copilotkit_contextSent === "boolean";
73
+ }
74
+ function isEnvelope(value) {
75
+ return require_is_record.isRecord(value) && isCapabilities(value["v1.0"]) && require_is_record.isRecord(value.metadata) && isExtensions(value.metadata.extensions);
76
+ }
77
+ /**
78
+ * Reads the generative UI envelope from the `forwardedProps` of a run.
79
+ *
80
+ * The envelope comes from the client, so it is not trusted: every field is
81
+ * checked. Returns `undefined` when the envelope is not there, or when it is
82
+ * malformed (for example a wrong `copilotkit_format` or
83
+ * `copilotkit_transport`, or no catalog id).
84
+ *
85
+ * @param forwardedProps - The `forwardedProps` of the run input.
86
+ *
87
+ * @example
88
+ * ```ts
89
+ * const envelope = readCopilotKitUIEnvelope(input.forwardedProps);
90
+ * if (envelope?.metadata.extensions.copilotkit_transport === "markdown") {
91
+ * // The model writes ```a2ui fences. Add no render tool.
92
+ * }
93
+ * ```
94
+ */
95
+ function readCopilotKitUIEnvelope(forwardedProps) {
96
+ if (!require_is_record.isRecord(forwardedProps)) return void 0;
97
+ const namespace = forwardedProps[COPILOTKIT_FORWARDED_PROPS_KEY];
98
+ if (!require_is_record.isRecord(namespace)) return void 0;
99
+ const envelope = namespace.ui;
100
+ return isEnvelope(envelope) ? envelope : void 0;
101
+ }
102
+ /**
103
+ * Turns an envelope into the manifest that the runtime and the prompts use.
104
+ *
105
+ * The catalog is the first of `supportedCatalogIds`, and `catalogIds` lists
106
+ * all of them. The components, functions, and instructions come from the
107
+ * inline catalog of the first id.
108
+ * With no such inline catalog, there are no components and no functions.
109
+ *
110
+ * The result also has:
111
+ * - `transport` and `contextSent`, from the extensions.
112
+ * - `instructions`, when the inline catalog has them.
113
+ * - `hasComponents`: false when the client left the component schemas out.
114
+ * The runtime cannot check operations without them.
115
+ * - `action`: the A2UI action message of the user event that started the
116
+ * run, when one did.
117
+ *
118
+ * @param envelope - An envelope from `readCopilotKitUIEnvelope`.
119
+ *
120
+ * @example
121
+ * ```ts
122
+ * const envelope = readCopilotKitUIEnvelope(input.forwardedProps);
123
+ * const manifest = envelope && envelopeToManifest(envelope);
124
+ * if (manifest?.transport === "tool" && manifest.hasComponents) {
125
+ * // Add the render tool and validate operations against manifest.components.
126
+ * }
127
+ * ```
128
+ */
129
+ function envelopeToManifest(envelope) {
130
+ const { supportedCatalogIds, inlineCatalogs } = envelope["v1.0"];
131
+ const catalogId = supportedCatalogIds[0];
132
+ const catalog = inlineCatalogs?.find((entry) => entry.catalogId === catalogId);
133
+ const extensions = envelope.metadata.extensions;
134
+ return {
135
+ catalogId,
136
+ catalogIds: supportedCatalogIds,
137
+ components: catalog?.components ?? {},
138
+ functions: catalog?.functions ?? {},
139
+ targets: extensions.copilotkit_targets,
140
+ surfaces: extensions.copilotkit_surfaces,
141
+ transport: extensions.copilotkit_transport,
142
+ contextSent: extensions.copilotkit_contextSent,
143
+ instructions: catalog?.instructions,
144
+ hasComponents: catalog?.components !== void 0,
145
+ ...extensions.copilotkit_action === void 0 ? {} : { action: extensions.copilotkit_action }
146
+ };
147
+ }
148
+
149
+ //#endregion
150
+ exports.COPILOTKIT_FORWARDED_PROPS_KEY = COPILOTKIT_FORWARDED_PROPS_KEY;
151
+ exports.COPILOTKIT_UI_ENVELOPE_FORMAT = COPILOTKIT_UI_ENVELOPE_FORMAT;
152
+ exports.envelopeToManifest = envelopeToManifest;
153
+ exports.readCopilotKitUIEnvelope = readCopilotKitUIEnvelope;
154
+ //# sourceMappingURL=a2ui-envelope.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"a2ui-envelope.cjs","names":["isRecord","GENERATIVE_UI_MAX_TARGET_COMPONENTS","GENERATIVE_UI_MAX_SUMMARY_REJECTIONS","GENERATIVE_UI_MAX_REJECTION_LENGTH"],"sources":["../src/a2ui-envelope.ts"],"sourcesContent":["/**\n * The generative UI envelope that the client sends on every run as\n * `forwardedProps.copilotkit.ui`. It has the A2UI v1.0 renderer capabilities\n * shape, so a backend that speaks A2UI v1.0 can read the catalog as it is.\n * CopilotKit data goes in `metadata.extensions`, under `copilotkit_` keys.\n * The runtime reads it to pick the transport and to build the guide.\n */\nimport {\n GENERATIVE_UI_MAX_REJECTION_LENGTH,\n GENERATIVE_UI_MAX_SUMMARY_REJECTIONS,\n GENERATIVE_UI_MAX_TARGET_COMPONENTS,\n} from \"./generative-ui/types\";\nimport type {\n A2UIActionMessage,\n GenerativeUIComponentManifest,\n GenerativeUIFunctionManifest,\n GenerativeUIManifest,\n GenerativeUISurfaceSummary,\n GenerativeUITarget,\n} from \"./generative-ui/types\";\nimport { isRecord } from \"./generative-ui/is-record\";\n\n/** Top-level `forwardedProps` key that holds the CopilotKit run properties. */\nexport const COPILOTKIT_FORWARDED_PROPS_KEY = \"copilotkit\";\n\n/** Version of the envelope shape (not of the UI protocol that it carries). */\nexport const COPILOTKIT_UI_ENVELOPE_FORMAT = 3;\n\n/** What the client renders and calls, and how the model must write UI. */\nexport interface CopilotKitUIEnvelope {\n /** The A2UI v1.0 renderer capabilities. */\n \"v1.0\": {\n /**\n * The catalog that the client renders comes first, then the catalogs of\n * its `extends`. An operation can name any of them.\n */\n supportedCatalogIds: string[];\n inlineCatalogs?: Array<{\n catalogId: string;\n protocolVersion: \"1.0\";\n /** Not there when the client is set up with `includeCatalog: false`. */\n components?: Record<string, GenerativeUIComponentManifest>;\n /** The app functions that are mounted now. */\n functions: Record<string, GenerativeUIFunctionManifest>;\n /** The markdown guideline. Only the markdown transport sends it. */\n instructions?: string;\n }>;\n };\n metadata: {\n extensions: {\n /** Envelope shape version. */\n copilotkit_format: typeof COPILOTKIT_UI_ENVELOPE_FORMAT;\n /** \"tool\": the model calls the render tool. \"markdown\": the model writes ```a2ui fences. */\n copilotkit_transport: \"tool\" | \"markdown\";\n copilotkit_targets: GenerativeUIManifest[\"targets\"];\n copilotkit_surfaces: GenerativeUIManifest[\"surfaces\"];\n /** True when the client also sent the guide as context entries on this run. */\n copilotkit_contextSent: boolean;\n /**\n * The A2UI action that started this run, when a user event did: the\n * structured form of the user message that the event added.\n */\n copilotkit_action?: A2UIActionMessage;\n };\n };\n}\n\ntype InlineCatalog = NonNullable<\n CopilotKitUIEnvelope[\"v1.0\"][\"inlineCatalogs\"]\n>[number];\ntype Extensions = CopilotKitUIEnvelope[\"metadata\"][\"extensions\"];\n\nfunction isOptionalString(value: unknown) {\n return value === undefined || typeof value === \"string\";\n}\n\nfunction isNonEmptyString(value: unknown): value is string {\n return typeof value === \"string\" && value !== \"\";\n}\n\nfunction isRecordOf<T>(\n value: unknown,\n isEntry: (entry: unknown) => entry is T,\n): value is Record<string, T> {\n return isRecord(value) && Object.values(value).every(isEntry);\n}\n\n/** A function, or an event of a component: a description and a parameter schema. */\nfunction isSchemaEntry(value: unknown): value is GenerativeUIFunctionManifest {\n return (\n isRecord(value) &&\n isRecord(value.parameters) &&\n isOptionalString(value.description)\n );\n}\n\nfunction isSlotKind(value: unknown): value is \"single\" | \"multiple\" {\n return value === \"single\" || value === \"multiple\";\n}\n\n/**\n * `validateOperation` reads `properties` and `required` of a props schema,\n * so those two must have the right shape when they are there.\n */\nfunction isPropsSchema(value: unknown): value is Record<string, unknown> {\n return (\n isRecord(value) &&\n (value.properties === undefined || isRecord(value.properties)) &&\n (value.required === undefined ||\n (Array.isArray(value.required) &&\n value.required.every((name) => typeof name === \"string\")))\n );\n}\n\nfunction isComponentManifest(\n value: unknown,\n): value is GenerativeUIComponentManifest {\n if (\n !isRecord(value) ||\n !isPropsSchema(value.props) ||\n !isOptionalString(value.description) ||\n (value.events !== undefined && !isRecordOf(value.events, isSchemaEntry)) ||\n (value.slots !== undefined && !isRecordOf(value.slots, isSlotKind))\n )\n return false;\n const order = value.parameterOrder;\n if (order === undefined) return true;\n const keys = new Set([\n ...Object.keys(value.props.properties ?? {}),\n ...Object.keys(value.slots ?? {}),\n ...Object.keys(value.events ?? {}),\n ]);\n return (\n Array.isArray(order) &&\n new Set(order).size === order.length &&\n order.every((key) => typeof key === \"string\" && keys.has(key))\n );\n}\n\nfunction isInlineCatalog(value: unknown): value is InlineCatalog {\n return (\n isRecord(value) &&\n isNonEmptyString(value.catalogId) &&\n value.protocolVersion === \"1.0\" &&\n (value.components === undefined ||\n isRecordOf(value.components, isComponentManifest)) &&\n isRecordOf(value.functions, isSchemaEntry) &&\n isOptionalString(value.instructions)\n );\n}\n\nfunction isCapabilities(value: unknown): value is CopilotKitUIEnvelope[\"v1.0\"] {\n return (\n isRecord(value) &&\n Array.isArray(value.supportedCatalogIds) &&\n value.supportedCatalogIds.length > 0 &&\n value.supportedCatalogIds.every(isNonEmptyString) &&\n (value.inlineCatalogs === undefined ||\n (Array.isArray(value.inlineCatalogs) &&\n value.inlineCatalogs.every(isInlineCatalog)))\n );\n}\n\n/** A short list of component names. */\nfunction isComponentNameList(value: unknown): value is string[] {\n return (\n Array.isArray(value) &&\n value.length <= GENERATIVE_UI_MAX_TARGET_COMPONENTS &&\n value.every(isNonEmptyString)\n );\n}\n\nfunction isTarget(value: unknown): value is GenerativeUITarget {\n return (\n isRecord(value) &&\n isNonEmptyString(value.id) &&\n (value.kind === \"chat\" || value.kind === \"inline\") &&\n isOptionalString(value.description) &&\n (value.components === undefined || isComponentNameList(value.components))\n );\n}\n\n/** A short list of short strings. The summary limits keep the guide small. */\nfunction isRejectionList(value: unknown): value is string[] {\n return (\n Array.isArray(value) &&\n value.length <= GENERATIVE_UI_MAX_SUMMARY_REJECTIONS &&\n value.every(\n (entry) =>\n typeof entry === \"string\" &&\n entry.length <= GENERATIVE_UI_MAX_REJECTION_LENGTH,\n )\n );\n}\n\nfunction isSurfaceEntry(value: unknown): value is GenerativeUISurfaceSummary {\n return (\n isRecord(value) &&\n isNonEmptyString(value.target) &&\n (value.dataModel === undefined || isRecord(value.dataModel)) &&\n (value.rejected === undefined || isRejectionList(value.rejected)) &&\n (value.status === undefined ||\n value.status === \"deleted\" ||\n value.status === \"failed\")\n );\n}\n\n/** Checks the `copilotkit_` keys only. Other extensions can be there too. */\nfunction isExtensions(value: unknown): value is Extensions {\n return (\n isRecord(value) &&\n value.copilotkit_format === COPILOTKIT_UI_ENVELOPE_FORMAT &&\n (value.copilotkit_transport === \"tool\" ||\n value.copilotkit_transport === \"markdown\") &&\n Array.isArray(value.copilotkit_targets) &&\n value.copilotkit_targets.every(isTarget) &&\n isRecordOf(value.copilotkit_surfaces, isSurfaceEntry) &&\n typeof value.copilotkit_contextSent === \"boolean\"\n );\n}\n\nfunction isEnvelope(value: unknown): value is CopilotKitUIEnvelope {\n return (\n isRecord(value) &&\n isCapabilities(value[\"v1.0\"]) &&\n isRecord(value.metadata) &&\n isExtensions(value.metadata.extensions)\n );\n}\n\n/**\n * Reads the generative UI envelope from the `forwardedProps` of a run.\n *\n * The envelope comes from the client, so it is not trusted: every field is\n * checked. Returns `undefined` when the envelope is not there, or when it is\n * malformed (for example a wrong `copilotkit_format` or\n * `copilotkit_transport`, or no catalog id).\n *\n * @param forwardedProps - The `forwardedProps` of the run input.\n *\n * @example\n * ```ts\n * const envelope = readCopilotKitUIEnvelope(input.forwardedProps);\n * if (envelope?.metadata.extensions.copilotkit_transport === \"markdown\") {\n * // The model writes ```a2ui fences. Add no render tool.\n * }\n * ```\n */\nexport function readCopilotKitUIEnvelope(forwardedProps: unknown) {\n if (!isRecord(forwardedProps)) return undefined;\n const namespace = forwardedProps[COPILOTKIT_FORWARDED_PROPS_KEY];\n if (!isRecord(namespace)) return undefined;\n const envelope = namespace.ui;\n return isEnvelope(envelope) ? envelope : undefined;\n}\n\n/**\n * Turns an envelope into the manifest that the runtime and the prompts use.\n *\n * The catalog is the first of `supportedCatalogIds`, and `catalogIds` lists\n * all of them. The components, functions, and instructions come from the\n * inline catalog of the first id.\n * With no such inline catalog, there are no components and no functions.\n *\n * The result also has:\n * - `transport` and `contextSent`, from the extensions.\n * - `instructions`, when the inline catalog has them.\n * - `hasComponents`: false when the client left the component schemas out.\n * The runtime cannot check operations without them.\n * - `action`: the A2UI action message of the user event that started the\n * run, when one did.\n *\n * @param envelope - An envelope from `readCopilotKitUIEnvelope`.\n *\n * @example\n * ```ts\n * const envelope = readCopilotKitUIEnvelope(input.forwardedProps);\n * const manifest = envelope && envelopeToManifest(envelope);\n * if (manifest?.transport === \"tool\" && manifest.hasComponents) {\n * // Add the render tool and validate operations against manifest.components.\n * }\n * ```\n */\nexport function envelopeToManifest(envelope: CopilotKitUIEnvelope) {\n const { supportedCatalogIds, inlineCatalogs } = envelope[\"v1.0\"];\n const catalogId = supportedCatalogIds[0];\n const catalog = inlineCatalogs?.find(\n (entry) => entry.catalogId === catalogId,\n );\n const extensions = envelope.metadata.extensions;\n const manifest: GenerativeUIManifest = {\n catalogId,\n catalogIds: supportedCatalogIds,\n components: catalog?.components ?? {},\n functions: catalog?.functions ?? {},\n targets: extensions.copilotkit_targets,\n surfaces: extensions.copilotkit_surfaces,\n };\n return {\n ...manifest,\n transport: extensions.copilotkit_transport,\n contextSent: extensions.copilotkit_contextSent,\n instructions: catalog?.instructions,\n hasComponents: catalog?.components !== undefined,\n ...(extensions.copilotkit_action === undefined\n ? {}\n : { action: extensions.copilotkit_action }),\n };\n}\n"],"mappings":"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"}
@@ -0,0 +1,101 @@
1
+ import { A2UIActionMessage, GenerativeUIComponentManifest, GenerativeUIFunctionManifest, GenerativeUIManifest, GenerativeUISurfaceSummary, GenerativeUITarget } from "./generative-ui/types.cjs";
2
+
3
+ //#region src/a2ui-envelope.d.ts
4
+ /** Top-level `forwardedProps` key that holds the CopilotKit run properties. */
5
+ declare const COPILOTKIT_FORWARDED_PROPS_KEY = "copilotkit";
6
+ /** Version of the envelope shape (not of the UI protocol that it carries). */
7
+ declare const COPILOTKIT_UI_ENVELOPE_FORMAT = 3;
8
+ /** What the client renders and calls, and how the model must write UI. */
9
+ interface CopilotKitUIEnvelope {
10
+ /** The A2UI v1.0 renderer capabilities. */
11
+ "v1.0": {
12
+ /**
13
+ * The catalog that the client renders comes first, then the catalogs of
14
+ * its `extends`. An operation can name any of them.
15
+ */
16
+ supportedCatalogIds: string[];
17
+ inlineCatalogs?: Array<{
18
+ catalogId: string;
19
+ protocolVersion: "1.0"; /** Not there when the client is set up with `includeCatalog: false`. */
20
+ components?: Record<string, GenerativeUIComponentManifest>; /** The app functions that are mounted now. */
21
+ functions: Record<string, GenerativeUIFunctionManifest>; /** The markdown guideline. Only the markdown transport sends it. */
22
+ instructions?: string;
23
+ }>;
24
+ };
25
+ metadata: {
26
+ extensions: {
27
+ /** Envelope shape version. */copilotkit_format: typeof COPILOTKIT_UI_ENVELOPE_FORMAT; /** "tool": the model calls the render tool. "markdown": the model writes ```a2ui fences. */
28
+ copilotkit_transport: "tool" | "markdown";
29
+ copilotkit_targets: GenerativeUIManifest["targets"];
30
+ copilotkit_surfaces: GenerativeUIManifest["surfaces"]; /** True when the client also sent the guide as context entries on this run. */
31
+ copilotkit_contextSent: boolean;
32
+ /**
33
+ * The A2UI action that started this run, when a user event did: the
34
+ * structured form of the user message that the event added.
35
+ */
36
+ copilotkit_action?: A2UIActionMessage;
37
+ };
38
+ };
39
+ }
40
+ /**
41
+ * Reads the generative UI envelope from the `forwardedProps` of a run.
42
+ *
43
+ * The envelope comes from the client, so it is not trusted: every field is
44
+ * checked. Returns `undefined` when the envelope is not there, or when it is
45
+ * malformed (for example a wrong `copilotkit_format` or
46
+ * `copilotkit_transport`, or no catalog id).
47
+ *
48
+ * @param forwardedProps - The `forwardedProps` of the run input.
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * const envelope = readCopilotKitUIEnvelope(input.forwardedProps);
53
+ * if (envelope?.metadata.extensions.copilotkit_transport === "markdown") {
54
+ * // The model writes ```a2ui fences. Add no render tool.
55
+ * }
56
+ * ```
57
+ */
58
+ declare function readCopilotKitUIEnvelope(forwardedProps: unknown): CopilotKitUIEnvelope | undefined;
59
+ /**
60
+ * Turns an envelope into the manifest that the runtime and the prompts use.
61
+ *
62
+ * The catalog is the first of `supportedCatalogIds`, and `catalogIds` lists
63
+ * all of them. The components, functions, and instructions come from the
64
+ * inline catalog of the first id.
65
+ * With no such inline catalog, there are no components and no functions.
66
+ *
67
+ * The result also has:
68
+ * - `transport` and `contextSent`, from the extensions.
69
+ * - `instructions`, when the inline catalog has them.
70
+ * - `hasComponents`: false when the client left the component schemas out.
71
+ * The runtime cannot check operations without them.
72
+ * - `action`: the A2UI action message of the user event that started the
73
+ * run, when one did.
74
+ *
75
+ * @param envelope - An envelope from `readCopilotKitUIEnvelope`.
76
+ *
77
+ * @example
78
+ * ```ts
79
+ * const envelope = readCopilotKitUIEnvelope(input.forwardedProps);
80
+ * const manifest = envelope && envelopeToManifest(envelope);
81
+ * if (manifest?.transport === "tool" && manifest.hasComponents) {
82
+ * // Add the render tool and validate operations against manifest.components.
83
+ * }
84
+ * ```
85
+ */
86
+ declare function envelopeToManifest(envelope: CopilotKitUIEnvelope): {
87
+ action?: A2UIActionMessage | undefined;
88
+ transport: "tool" | "markdown";
89
+ contextSent: boolean;
90
+ instructions: string | undefined;
91
+ hasComponents: boolean;
92
+ catalogId: string;
93
+ catalogIds?: string[];
94
+ components: Record<string, GenerativeUIComponentManifest>;
95
+ functions: Record<string, GenerativeUIFunctionManifest>;
96
+ targets: GenerativeUITarget[];
97
+ surfaces: Record<string, GenerativeUISurfaceSummary>;
98
+ };
99
+ //#endregion
100
+ export { COPILOTKIT_FORWARDED_PROPS_KEY, COPILOTKIT_UI_ENVELOPE_FORMAT, CopilotKitUIEnvelope, envelopeToManifest, readCopilotKitUIEnvelope };
101
+ //# sourceMappingURL=a2ui-envelope.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"a2ui-envelope.d.cts","names":[],"sources":["../src/a2ui-envelope.ts"],"mappings":";;;;cAuBa,8BAAA;AAAb;AAAA,cAGa,6BAAA;;UAGI,oBAAA;EAN0B;EAQzC,MAAA;IALwC;;;;IAUtC,mBAAA;IACA,cAAA,GAAiB,KAAA;MACf,SAAA;MACA,eAAA,SAEa;MAAb,UAAA,GAAa,MAAA,SAAe,6BAAA,GAEjB;MAAX,SAAA,EAAW,MAAA,SAAe,4BAAA,GAQA;MAN1B,YAAA;IAAA;EAAA;EAGJ,QAAA;IACE,UAAA;MAlBF,8BAoBI,iBAAA,SAA0B,6BAAA,EAd5B;MAgBE,oBAAA;MACA,kBAAA,EAAoB,oBAAA;MACpB,mBAAA,EAAqB,oBAAA,cAdrB;MAgBA,sBAAA;MAhB4B;;;;MAqB5B,iBAAA,GAAoB,iBAAA;IAAA;EAAA;AAAA;;;;;;;;;;;;AA0L1B;;;;;AAmCA;;iBAnCgB,wBAAA,CAAyB,cAAA,YAAuB,oBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAmChD,kBAAA,CAAmB,QAAA,EAAU,oBAAA"}
@@ -0,0 +1,101 @@
1
+ import { A2UIActionMessage, GenerativeUIComponentManifest, GenerativeUIFunctionManifest, GenerativeUIManifest, GenerativeUISurfaceSummary, GenerativeUITarget } from "./generative-ui/types.mjs";
2
+
3
+ //#region src/a2ui-envelope.d.ts
4
+ /** Top-level `forwardedProps` key that holds the CopilotKit run properties. */
5
+ declare const COPILOTKIT_FORWARDED_PROPS_KEY = "copilotkit";
6
+ /** Version of the envelope shape (not of the UI protocol that it carries). */
7
+ declare const COPILOTKIT_UI_ENVELOPE_FORMAT = 3;
8
+ /** What the client renders and calls, and how the model must write UI. */
9
+ interface CopilotKitUIEnvelope {
10
+ /** The A2UI v1.0 renderer capabilities. */
11
+ "v1.0": {
12
+ /**
13
+ * The catalog that the client renders comes first, then the catalogs of
14
+ * its `extends`. An operation can name any of them.
15
+ */
16
+ supportedCatalogIds: string[];
17
+ inlineCatalogs?: Array<{
18
+ catalogId: string;
19
+ protocolVersion: "1.0"; /** Not there when the client is set up with `includeCatalog: false`. */
20
+ components?: Record<string, GenerativeUIComponentManifest>; /** The app functions that are mounted now. */
21
+ functions: Record<string, GenerativeUIFunctionManifest>; /** The markdown guideline. Only the markdown transport sends it. */
22
+ instructions?: string;
23
+ }>;
24
+ };
25
+ metadata: {
26
+ extensions: {
27
+ /** Envelope shape version. */copilotkit_format: typeof COPILOTKIT_UI_ENVELOPE_FORMAT; /** "tool": the model calls the render tool. "markdown": the model writes ```a2ui fences. */
28
+ copilotkit_transport: "tool" | "markdown";
29
+ copilotkit_targets: GenerativeUIManifest["targets"];
30
+ copilotkit_surfaces: GenerativeUIManifest["surfaces"]; /** True when the client also sent the guide as context entries on this run. */
31
+ copilotkit_contextSent: boolean;
32
+ /**
33
+ * The A2UI action that started this run, when a user event did: the
34
+ * structured form of the user message that the event added.
35
+ */
36
+ copilotkit_action?: A2UIActionMessage;
37
+ };
38
+ };
39
+ }
40
+ /**
41
+ * Reads the generative UI envelope from the `forwardedProps` of a run.
42
+ *
43
+ * The envelope comes from the client, so it is not trusted: every field is
44
+ * checked. Returns `undefined` when the envelope is not there, or when it is
45
+ * malformed (for example a wrong `copilotkit_format` or
46
+ * `copilotkit_transport`, or no catalog id).
47
+ *
48
+ * @param forwardedProps - The `forwardedProps` of the run input.
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * const envelope = readCopilotKitUIEnvelope(input.forwardedProps);
53
+ * if (envelope?.metadata.extensions.copilotkit_transport === "markdown") {
54
+ * // The model writes ```a2ui fences. Add no render tool.
55
+ * }
56
+ * ```
57
+ */
58
+ declare function readCopilotKitUIEnvelope(forwardedProps: unknown): CopilotKitUIEnvelope | undefined;
59
+ /**
60
+ * Turns an envelope into the manifest that the runtime and the prompts use.
61
+ *
62
+ * The catalog is the first of `supportedCatalogIds`, and `catalogIds` lists
63
+ * all of them. The components, functions, and instructions come from the
64
+ * inline catalog of the first id.
65
+ * With no such inline catalog, there are no components and no functions.
66
+ *
67
+ * The result also has:
68
+ * - `transport` and `contextSent`, from the extensions.
69
+ * - `instructions`, when the inline catalog has them.
70
+ * - `hasComponents`: false when the client left the component schemas out.
71
+ * The runtime cannot check operations without them.
72
+ * - `action`: the A2UI action message of the user event that started the
73
+ * run, when one did.
74
+ *
75
+ * @param envelope - An envelope from `readCopilotKitUIEnvelope`.
76
+ *
77
+ * @example
78
+ * ```ts
79
+ * const envelope = readCopilotKitUIEnvelope(input.forwardedProps);
80
+ * const manifest = envelope && envelopeToManifest(envelope);
81
+ * if (manifest?.transport === "tool" && manifest.hasComponents) {
82
+ * // Add the render tool and validate operations against manifest.components.
83
+ * }
84
+ * ```
85
+ */
86
+ declare function envelopeToManifest(envelope: CopilotKitUIEnvelope): {
87
+ action?: A2UIActionMessage | undefined;
88
+ transport: "tool" | "markdown";
89
+ contextSent: boolean;
90
+ instructions: string | undefined;
91
+ hasComponents: boolean;
92
+ catalogId: string;
93
+ catalogIds?: string[];
94
+ components: Record<string, GenerativeUIComponentManifest>;
95
+ functions: Record<string, GenerativeUIFunctionManifest>;
96
+ targets: GenerativeUITarget[];
97
+ surfaces: Record<string, GenerativeUISurfaceSummary>;
98
+ };
99
+ //#endregion
100
+ export { COPILOTKIT_FORWARDED_PROPS_KEY, COPILOTKIT_UI_ENVELOPE_FORMAT, CopilotKitUIEnvelope, envelopeToManifest, readCopilotKitUIEnvelope };
101
+ //# sourceMappingURL=a2ui-envelope.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"a2ui-envelope.d.mts","names":[],"sources":["../src/a2ui-envelope.ts"],"mappings":";;;;cAuBa,8BAAA;AAAb;AAAA,cAGa,6BAAA;;UAGI,oBAAA;EAN0B;EAQzC,MAAA;IALwC;;;;IAUtC,mBAAA;IACA,cAAA,GAAiB,KAAA;MACf,SAAA;MACA,eAAA,SAEa;MAAb,UAAA,GAAa,MAAA,SAAe,6BAAA,GAEjB;MAAX,SAAA,EAAW,MAAA,SAAe,4BAAA,GAQA;MAN1B,YAAA;IAAA;EAAA;EAGJ,QAAA;IACE,UAAA;MAlBF,8BAoBI,iBAAA,SAA0B,6BAAA,EAd5B;MAgBE,oBAAA;MACA,kBAAA,EAAoB,oBAAA;MACpB,mBAAA,EAAqB,oBAAA,cAdrB;MAgBA,sBAAA;MAhB4B;;;;MAqB5B,iBAAA,GAAoB,iBAAA;IAAA;EAAA;AAAA;;;;;;;;;;;;AA0L1B;;;;;AAmCA;;iBAnCgB,wBAAA,CAAyB,cAAA,YAAuB,oBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAmChD,kBAAA,CAAmB,QAAA,EAAU,oBAAA"}