@copilotkit/react-core 1.10.6 → 1.50.0-beta.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 (333) hide show
  1. package/dist/chunk-24SCZAB4.mjs +143 -0
  2. package/dist/chunk-24SCZAB4.mjs.map +1 -0
  3. package/dist/chunk-36KQV2NA.mjs +1 -0
  4. package/dist/{chunk-U7QULEVO.mjs → chunk-3GURHDG7.mjs} +3 -3
  5. package/dist/{chunk-4BHIQMN6.mjs → chunk-3R423LZT.mjs} +6 -5
  6. package/dist/{chunk-4BHIQMN6.mjs.map → chunk-3R423LZT.mjs.map} +1 -1
  7. package/dist/chunk-5X5DJRQQ.mjs +71 -0
  8. package/dist/chunk-5X5DJRQQ.mjs.map +1 -0
  9. package/dist/{chunk-N4WEHORG.mjs → chunk-6PUNP7CD.mjs} +4 -4
  10. package/dist/chunk-6PUNP7CD.mjs.map +1 -0
  11. package/dist/chunk-7BYHZLPL.mjs +32 -0
  12. package/dist/chunk-7BYHZLPL.mjs.map +1 -0
  13. package/dist/chunk-7DTB7S5V.mjs +83 -0
  14. package/dist/chunk-7DTB7S5V.mjs.map +1 -0
  15. package/dist/chunk-A6NKSGH3.mjs +1 -0
  16. package/dist/{chunk-GT5WI3AF.mjs → chunk-BR5YEYZJ.mjs} +7 -9
  17. package/dist/chunk-BR5YEYZJ.mjs.map +1 -0
  18. package/dist/chunk-CB7CRBDG.mjs +48 -0
  19. package/dist/chunk-CB7CRBDG.mjs.map +1 -0
  20. package/dist/chunk-CYDWEPFL.mjs +1 -0
  21. package/dist/{chunk-BBUQMG45.mjs → chunk-D3QSYDJR.mjs} +3 -3
  22. package/dist/{chunk-BBUQMG45.mjs.map → chunk-D3QSYDJR.mjs.map} +1 -1
  23. package/dist/chunk-DCHSCK62.mjs +549 -0
  24. package/dist/chunk-DCHSCK62.mjs.map +1 -0
  25. package/dist/{chunk-ZLQVRPDS.mjs → chunk-DMLQZG75.mjs} +1 -1
  26. package/dist/chunk-DMLQZG75.mjs.map +1 -0
  27. package/dist/chunk-F555TVE4.mjs +33 -0
  28. package/dist/chunk-F555TVE4.mjs.map +1 -0
  29. package/dist/{chunk-C6IANC2R.mjs → chunk-FBD24VEH.mjs} +7 -43
  30. package/dist/chunk-FBD24VEH.mjs.map +1 -0
  31. package/dist/chunk-FD6FGKYY.mjs +1 -0
  32. package/dist/chunk-FDOMAPJY.mjs +59 -0
  33. package/dist/chunk-FDOMAPJY.mjs.map +1 -0
  34. package/dist/{chunk-X7MJWPI7.mjs → chunk-GMI4KO4X.mjs} +8 -6
  35. package/dist/{chunk-X7MJWPI7.mjs.map → chunk-GMI4KO4X.mjs.map} +1 -1
  36. package/dist/chunk-IUSKVYUI.mjs +13 -0
  37. package/dist/chunk-IUSKVYUI.mjs.map +1 -0
  38. package/dist/chunk-JD7BAH7U.mjs +1 -0
  39. package/dist/{chunk-N5HOP3PG.mjs → chunk-JRT5BJF3.mjs} +2 -2
  40. package/dist/{chunk-N4VN2B5S.mjs → chunk-LHERIF3L.mjs} +2 -2
  41. package/dist/{chunk-DXEQPN43.mjs → chunk-LHKZJ2ND.mjs} +3 -3
  42. package/dist/chunk-NB2FKV2V.mjs +1 -0
  43. package/dist/chunk-NBK4KBLX.mjs +54 -0
  44. package/dist/chunk-NBK4KBLX.mjs.map +1 -0
  45. package/dist/chunk-NG26QEGF.mjs +46 -0
  46. package/dist/chunk-NG26QEGF.mjs.map +1 -0
  47. package/dist/chunk-NROJOTQP.mjs +163 -0
  48. package/dist/chunk-NROJOTQP.mjs.map +1 -0
  49. package/dist/{chunk-MGWRDFBE.mjs → chunk-OVYFRPSN.mjs} +2 -2
  50. package/dist/{chunk-MQYWH4E6.mjs → chunk-QU6NONOD.mjs} +2 -2
  51. package/dist/chunk-R4MR43UQ.mjs +101 -0
  52. package/dist/chunk-R4MR43UQ.mjs.map +1 -0
  53. package/dist/chunk-SPCZTZCY.mjs +1 -0
  54. package/dist/chunk-SPCZTZCY.mjs.map +1 -0
  55. package/dist/chunk-TXI72QHK.mjs +80 -0
  56. package/dist/chunk-TXI72QHK.mjs.map +1 -0
  57. package/dist/chunk-UJBV5GAG.mjs +767 -0
  58. package/dist/chunk-UJBV5GAG.mjs.map +1 -0
  59. package/dist/{chunk-OKCYPO4I.mjs → chunk-WMJVBMUX.mjs} +3 -3
  60. package/dist/{chunk-EUX2P2E7.mjs → chunk-WVLHXIFP.mjs} +11 -9
  61. package/dist/chunk-WVLHXIFP.mjs.map +1 -0
  62. package/dist/{chunk-5FHSUKQL.mjs → chunk-YYN33GSG.mjs} +5 -2
  63. package/dist/chunk-YYN33GSG.mjs.map +1 -0
  64. package/dist/chunk-ZVF5Q6IH.mjs +29 -0
  65. package/dist/chunk-ZVF5Q6IH.mjs.map +1 -0
  66. package/dist/components/CopilotListeners.d.ts +3 -0
  67. package/dist/components/CopilotListeners.js +234 -0
  68. package/dist/components/CopilotListeners.js.map +1 -0
  69. package/dist/components/CopilotListeners.mjs +14 -0
  70. package/dist/components/CopilotListeners.mjs.map +1 -0
  71. package/dist/components/copilot-provider/copilot-messages.js +14 -48
  72. package/dist/components/copilot-provider/copilot-messages.js.map +1 -1
  73. package/dist/components/copilot-provider/copilot-messages.mjs +3 -3
  74. package/dist/components/copilot-provider/copilotkit-props.d.ts +9 -2
  75. package/dist/components/copilot-provider/copilotkit-props.js.map +1 -1
  76. package/dist/components/copilot-provider/copilotkit.d.ts +2 -1
  77. package/dist/components/copilot-provider/copilotkit.js +528 -370
  78. package/dist/components/copilot-provider/copilotkit.js.map +1 -1
  79. package/dist/components/copilot-provider/copilotkit.mjs +17 -12
  80. package/dist/components/copilot-provider/index.d.ts +2 -1
  81. package/dist/components/copilot-provider/index.js +528 -370
  82. package/dist/components/copilot-provider/index.js.map +1 -1
  83. package/dist/components/copilot-provider/index.mjs +18 -12
  84. package/dist/components/dev-console/console-trigger.js +10 -8
  85. package/dist/components/dev-console/console-trigger.js.map +1 -1
  86. package/dist/components/dev-console/console-trigger.mjs +4 -4
  87. package/dist/components/dev-console/developer-console-modal.js +10 -8
  88. package/dist/components/dev-console/developer-console-modal.js.map +1 -1
  89. package/dist/components/dev-console/developer-console-modal.mjs +3 -3
  90. package/dist/components/error-boundary/error-boundary.d.ts +7 -7
  91. package/dist/components/error-boundary/error-boundary.js +3 -3
  92. package/dist/components/error-boundary/error-boundary.js.map +1 -1
  93. package/dist/components/error-boundary/error-boundary.mjs +2 -2
  94. package/dist/components/error-boundary/error-utils.d.ts +1 -1
  95. package/dist/components/error-boundary/error-utils.js +3 -3
  96. package/dist/components/error-boundary/error-utils.js.map +1 -1
  97. package/dist/components/error-boundary/error-utils.mjs +1 -1
  98. package/dist/components/index.d.ts +2 -1
  99. package/dist/components/index.js +528 -370
  100. package/dist/components/index.js.map +1 -1
  101. package/dist/components/index.mjs +19 -12
  102. package/dist/components/toast/exclamation-mark-icon.d.ts +2 -2
  103. package/dist/components/toast/toast-provider.d.ts +3 -3
  104. package/dist/components/usage-banner.d.ts +2 -2
  105. package/dist/context/coagent-state-renders-context.d.ts +24 -0
  106. package/dist/context/coagent-state-renders-context.js +91 -0
  107. package/dist/context/coagent-state-renders-context.js.map +1 -0
  108. package/dist/context/coagent-state-renders-context.mjs +12 -0
  109. package/dist/context/coagent-state-renders-context.mjs.map +1 -0
  110. package/dist/context/copilot-context.d.ts +1 -1
  111. package/dist/context/copilot-context.js +10 -8
  112. package/dist/context/copilot-context.js.map +1 -1
  113. package/dist/context/copilot-context.mjs +1 -1
  114. package/dist/context/copilot-messages-context.d.ts +18 -11
  115. package/dist/context/copilot-messages-context.js.map +1 -1
  116. package/dist/context/copilot-messages-context.mjs +1 -1
  117. package/dist/context/index.d.ts +6 -2
  118. package/dist/context/index.js +110 -10
  119. package/dist/context/index.js.map +1 -1
  120. package/dist/context/index.mjs +20 -4
  121. package/dist/context/threads-context.d.ts +16 -0
  122. package/dist/context/threads-context.js +59 -0
  123. package/dist/context/threads-context.js.map +1 -0
  124. package/dist/context/threads-context.mjs +12 -0
  125. package/dist/context/threads-context.mjs.map +1 -0
  126. package/dist/{copilot-context-cf9de848.d.ts → copilot-context-1cd70a3f.d.ts} +36 -32
  127. package/dist/hooks/index.d.ts +9 -6
  128. package/dist/hooks/index.js +1445 -1839
  129. package/dist/hooks/index.js.map +1 -1
  130. package/dist/hooks/index.mjs +47 -56
  131. package/dist/hooks/use-coagent-state-render-bridge.d.ts +100 -0
  132. package/dist/hooks/use-coagent-state-render-bridge.js +211 -0
  133. package/dist/hooks/use-coagent-state-render-bridge.js.map +1 -0
  134. package/dist/hooks/use-coagent-state-render-bridge.mjs +15 -0
  135. package/dist/hooks/use-coagent-state-render-bridge.mjs.map +1 -0
  136. package/dist/hooks/use-coagent-state-render.js +31 -20
  137. package/dist/hooks/use-coagent-state-render.js.map +1 -1
  138. package/dist/hooks/use-coagent-state-render.mjs +3 -2
  139. package/dist/hooks/use-coagent.d.ts +2 -14
  140. package/dist/hooks/use-coagent.js +109 -1906
  141. package/dist/hooks/use-coagent.js.map +1 -1
  142. package/dist/hooks/use-coagent.mjs +1 -30
  143. package/dist/hooks/use-configure-chat-suggestions.d.ts +36 -0
  144. package/dist/hooks/use-configure-chat-suggestions.js +210 -0
  145. package/dist/hooks/use-configure-chat-suggestions.js.map +1 -0
  146. package/dist/hooks/use-configure-chat-suggestions.mjs +13 -0
  147. package/dist/hooks/use-configure-chat-suggestions.mjs.map +1 -0
  148. package/dist/hooks/use-copilot-action.d.ts +8 -45
  149. package/dist/hooks/use-copilot-action.js +207 -349
  150. package/dist/hooks/use-copilot-action.js.map +1 -1
  151. package/dist/hooks/use-copilot-action.mjs +4 -5
  152. package/dist/hooks/use-copilot-additional-instructions.js +10 -8
  153. package/dist/hooks/use-copilot-additional-instructions.js.map +1 -1
  154. package/dist/hooks/use-copilot-additional-instructions.mjs +2 -2
  155. package/dist/hooks/use-copilot-authenticated-action.js +224 -248
  156. package/dist/hooks/use-copilot-authenticated-action.js.map +1 -1
  157. package/dist/hooks/use-copilot-authenticated-action.mjs +6 -6
  158. package/dist/hooks/use-copilot-chat-headless_c.d.ts +2 -10
  159. package/dist/hooks/use-copilot-chat-headless_c.js +973 -1369
  160. package/dist/hooks/use-copilot-chat-headless_c.js.map +1 -1
  161. package/dist/hooks/use-copilot-chat-headless_c.mjs +12 -22
  162. package/dist/hooks/use-copilot-chat.d.ts +2 -10
  163. package/dist/hooks/use-copilot-chat.js +967 -1388
  164. package/dist/hooks/use-copilot-chat.js.map +1 -1
  165. package/dist/hooks/use-copilot-chat.mjs +12 -22
  166. package/dist/hooks/use-copilot-chat_internal.d.ts +38 -14
  167. package/dist/hooks/use-copilot-chat_internal.js +965 -1362
  168. package/dist/hooks/use-copilot-chat_internal.js.map +1 -1
  169. package/dist/hooks/use-copilot-chat_internal.mjs +13 -23
  170. package/dist/hooks/use-copilot-readable.d.ts +1 -1
  171. package/dist/hooks/use-copilot-readable.js +6 -157
  172. package/dist/hooks/use-copilot-readable.js.map +1 -1
  173. package/dist/hooks/use-copilot-readable.mjs +1 -2
  174. package/dist/hooks/use-default-tool.js +204 -349
  175. package/dist/hooks/use-default-tool.js.map +1 -1
  176. package/dist/hooks/use-default-tool.mjs +5 -6
  177. package/dist/hooks/use-flat-category-store.js +4 -1
  178. package/dist/hooks/use-flat-category-store.js.map +1 -1
  179. package/dist/hooks/use-flat-category-store.mjs +1 -1
  180. package/dist/hooks/use-frontend-tool.d.ts +3 -3
  181. package/dist/hooks/use-frontend-tool.js +30 -370
  182. package/dist/hooks/use-frontend-tool.js.map +1 -1
  183. package/dist/hooks/use-frontend-tool.mjs +1 -6
  184. package/dist/hooks/use-human-in-the-loop.d.ts +4 -3
  185. package/dist/hooks/use-human-in-the-loop.js +61 -393
  186. package/dist/hooks/use-human-in-the-loop.js.map +1 -1
  187. package/dist/hooks/use-human-in-the-loop.mjs +1 -6
  188. package/dist/hooks/use-langgraph-interrupt-render.d.ts +3 -2
  189. package/dist/hooks/use-langgraph-interrupt-render.js +92 -36
  190. package/dist/hooks/use-langgraph-interrupt-render.js.map +1 -1
  191. package/dist/hooks/use-langgraph-interrupt-render.mjs +6 -4
  192. package/dist/hooks/use-langgraph-interrupt.d.ts +1 -1
  193. package/dist/hooks/use-langgraph-interrupt.js +24 -1642
  194. package/dist/hooks/use-langgraph-interrupt.js.map +1 -1
  195. package/dist/hooks/use-langgraph-interrupt.mjs +2 -23
  196. package/dist/hooks/use-lazy-tool-renderer.d.ts +6 -0
  197. package/dist/hooks/use-lazy-tool-renderer.js +53 -0
  198. package/dist/hooks/use-lazy-tool-renderer.js.map +1 -0
  199. package/dist/hooks/use-lazy-tool-renderer.mjs +8 -0
  200. package/dist/hooks/use-lazy-tool-renderer.mjs.map +1 -0
  201. package/dist/hooks/use-make-copilot-document-readable.js +11 -9
  202. package/dist/hooks/use-make-copilot-document-readable.js.map +1 -1
  203. package/dist/hooks/use-make-copilot-document-readable.mjs +2 -2
  204. package/dist/hooks/use-render-tool-call.d.ts +7 -6
  205. package/dist/hooks/use-render-tool-call.js +36 -386
  206. package/dist/hooks/use-render-tool-call.js.map +1 -1
  207. package/dist/hooks/use-render-tool-call.mjs +1 -6
  208. package/dist/index.d.ts +11 -6
  209. package/dist/index.js +1841 -2056
  210. package/dist/index.js.map +1 -1
  211. package/dist/index.mjs +82 -63
  212. package/dist/lib/copilot-task.d.ts +1 -1
  213. package/dist/lib/copilot-task.js +1 -0
  214. package/dist/lib/copilot-task.js.map +1 -1
  215. package/dist/lib/copilot-task.mjs +20 -13
  216. package/dist/lib/index.d.ts +1 -1
  217. package/dist/lib/index.js +1 -0
  218. package/dist/lib/index.js.map +1 -1
  219. package/dist/lib/index.mjs +20 -13
  220. package/dist/setupTests.d.ts +2 -2
  221. package/dist/types/frontend-action.d.ts +5 -5
  222. package/dist/types/index.d.ts +4 -0
  223. package/dist/types/index.js.map +1 -1
  224. package/dist/types/index.mjs +2 -1
  225. package/dist/types/interrupt-action.d.ts +1 -1
  226. package/dist/types/interrupt-action.js.map +1 -1
  227. package/dist/types/interrupt-action.mjs +1 -0
  228. package/dist/utils/index.d.ts +0 -12
  229. package/dist/utils/index.js +6 -325
  230. package/dist/utils/index.js.map +1 -1
  231. package/dist/utils/index.mjs +3 -23
  232. package/dist/utils/utils.js.map +1 -1
  233. package/dist/v2/index.d.ts +2 -0
  234. package/dist/v2/index.js +27 -0
  235. package/dist/v2/index.js.map +1 -0
  236. package/dist/v2/index.mjs +4 -0
  237. package/dist/v2/index.mjs.map +1 -0
  238. package/package.json +34 -23
  239. package/src/components/CopilotListeners.tsx +82 -0
  240. package/src/components/copilot-provider/copilot-messages.tsx +46 -47
  241. package/src/components/copilot-provider/copilotkit-props.tsx +8 -1
  242. package/src/components/copilot-provider/copilotkit.tsx +177 -144
  243. package/src/components/error-boundary/error-utils.tsx +3 -3
  244. package/src/context/coagent-state-renders-context.tsx +76 -0
  245. package/src/context/copilot-context.tsx +21 -21
  246. package/src/context/copilot-messages-context.tsx +3 -3
  247. package/src/context/index.ts +8 -0
  248. package/src/context/threads-context.tsx +41 -0
  249. package/src/hooks/index.ts +7 -3
  250. package/src/hooks/use-coagent-state-render-bridge.tsx +293 -0
  251. package/src/hooks/use-coagent-state-render.ts +4 -7
  252. package/src/hooks/use-coagent.ts +129 -249
  253. package/src/hooks/use-configure-chat-suggestions.tsx +85 -0
  254. package/src/hooks/use-copilot-action.ts +88 -199
  255. package/src/hooks/use-copilot-chat-headless_c.ts +2 -1
  256. package/src/hooks/use-copilot-chat.ts +4 -1
  257. package/src/hooks/use-copilot-chat_internal.ts +349 -258
  258. package/src/hooks/use-copilot-readable.ts +6 -26
  259. package/src/hooks/use-flat-category-store.ts +4 -3
  260. package/src/hooks/use-frontend-tool.ts +67 -8
  261. package/src/hooks/use-human-in-the-loop.ts +111 -13
  262. package/src/hooks/use-langgraph-interrupt-render.ts +90 -40
  263. package/src/hooks/use-langgraph-interrupt.ts +18 -47
  264. package/src/hooks/use-lazy-tool-renderer.tsx +30 -0
  265. package/src/hooks/use-make-copilot-document-readable.ts +1 -1
  266. package/src/hooks/use-render-tool-call.ts +73 -13
  267. package/src/types/index.ts +1 -0
  268. package/src/types/interrupt-action.ts +8 -4
  269. package/src/utils/index.ts +0 -3
  270. package/src/utils/utils.ts +7 -0
  271. package/src/v2/index.ts +2 -0
  272. package/src/v2/styles.css +1 -0
  273. package/tsup.config.ts +1 -1
  274. package/dist/chunk-5FHSUKQL.mjs.map +0 -1
  275. package/dist/chunk-6GPVUMBU.mjs +0 -13
  276. package/dist/chunk-6GPVUMBU.mjs.map +0 -1
  277. package/dist/chunk-AKR2SSUJ.mjs +0 -22
  278. package/dist/chunk-AKR2SSUJ.mjs.map +0 -1
  279. package/dist/chunk-C6IANC2R.mjs.map +0 -1
  280. package/dist/chunk-CI4KD357.mjs +0 -804
  281. package/dist/chunk-CI4KD357.mjs.map +0 -1
  282. package/dist/chunk-DZTU6PGS.mjs +0 -1
  283. package/dist/chunk-EUX2P2E7.mjs.map +0 -1
  284. package/dist/chunk-EVVO67QO.mjs +0 -25
  285. package/dist/chunk-EVVO67QO.mjs.map +0 -1
  286. package/dist/chunk-GT5WI3AF.mjs.map +0 -1
  287. package/dist/chunk-HDOG2RTM.mjs +0 -37
  288. package/dist/chunk-HDOG2RTM.mjs.map +0 -1
  289. package/dist/chunk-N4WEHORG.mjs.map +0 -1
  290. package/dist/chunk-OT5NHMEC.mjs +0 -723
  291. package/dist/chunk-OT5NHMEC.mjs.map +0 -1
  292. package/dist/chunk-QHCLJODF.mjs +0 -332
  293. package/dist/chunk-QHCLJODF.mjs.map +0 -1
  294. package/dist/chunk-QV5SBF2S.mjs +0 -239
  295. package/dist/chunk-QV5SBF2S.mjs.map +0 -1
  296. package/dist/chunk-T3376SZS.mjs +0 -142
  297. package/dist/chunk-T3376SZS.mjs.map +0 -1
  298. package/dist/chunk-U3DQY67T.mjs +0 -71
  299. package/dist/chunk-U3DQY67T.mjs.map +0 -1
  300. package/dist/chunk-YPBKY4KY.mjs +0 -1
  301. package/dist/chunk-YPSGKPDA.mjs +0 -1
  302. package/dist/chunk-ZLQVRPDS.mjs.map +0 -1
  303. package/dist/chunk-ZVOLWJCY.mjs +0 -47
  304. package/dist/chunk-ZVOLWJCY.mjs.map +0 -1
  305. package/dist/hooks/use-chat.d.ts +0 -145
  306. package/dist/hooks/use-chat.js +0 -1129
  307. package/dist/hooks/use-chat.js.map +0 -1
  308. package/dist/hooks/use-chat.mjs +0 -14
  309. package/dist/index-1f5b66ac.d.ts +0 -36
  310. package/dist/utils/extract.d.ts +0 -43
  311. package/dist/utils/extract.js +0 -208
  312. package/dist/utils/extract.js.map +0 -1
  313. package/dist/utils/extract.mjs +0 -25
  314. package/dist/utils/suggestions.d.ts +0 -11
  315. package/dist/utils/suggestions.js +0 -343
  316. package/dist/utils/suggestions.js.map +0 -1
  317. package/dist/utils/suggestions.mjs +0 -25
  318. package/src/hooks/use-chat.ts +0 -1142
  319. package/src/utils/extract.ts +0 -215
  320. package/src/utils/suggestions.ts +0 -208
  321. /package/dist/{chunk-DZTU6PGS.mjs.map → chunk-36KQV2NA.mjs.map} +0 -0
  322. /package/dist/{chunk-U7QULEVO.mjs.map → chunk-3GURHDG7.mjs.map} +0 -0
  323. /package/dist/{chunk-YPBKY4KY.mjs.map → chunk-A6NKSGH3.mjs.map} +0 -0
  324. /package/dist/{chunk-YPSGKPDA.mjs.map → chunk-CYDWEPFL.mjs.map} +0 -0
  325. /package/dist/{hooks/use-chat.mjs.map → chunk-FD6FGKYY.mjs.map} +0 -0
  326. /package/dist/{utils/extract.mjs.map → chunk-JD7BAH7U.mjs.map} +0 -0
  327. /package/dist/{chunk-N5HOP3PG.mjs.map → chunk-JRT5BJF3.mjs.map} +0 -0
  328. /package/dist/{chunk-N4VN2B5S.mjs.map → chunk-LHERIF3L.mjs.map} +0 -0
  329. /package/dist/{chunk-DXEQPN43.mjs.map → chunk-LHKZJ2ND.mjs.map} +0 -0
  330. /package/dist/{utils/suggestions.mjs.map → chunk-NB2FKV2V.mjs.map} +0 -0
  331. /package/dist/{chunk-MGWRDFBE.mjs.map → chunk-OVYFRPSN.mjs.map} +0 -0
  332. /package/dist/{chunk-MQYWH4E6.mjs.map → chunk-QU6NONOD.mjs.map} +0 -0
  333. /package/dist/{chunk-OKCYPO4I.mjs.map → chunk-WMJVBMUX.mjs.map} +0 -0
@@ -0,0 +1,76 @@
1
+ import React, {
2
+ createContext,
3
+ useContext,
4
+ useCallback,
5
+ useState,
6
+ useRef,
7
+ ReactNode,
8
+ RefObject,
9
+ } from "react";
10
+ import { CoAgentStateRender } from "../types/coagent-action";
11
+
12
+ interface StateRenderClaim {
13
+ stateRenderId: string;
14
+ stateSnapshot?: any;
15
+ runId?: string;
16
+ locked?: boolean;
17
+ }
18
+
19
+ type ClaimsRef = Record<string, StateRenderClaim>;
20
+
21
+ export interface CoAgentStateRendersContextValue {
22
+ coAgentStateRenders: Record<string, CoAgentStateRender<any>>;
23
+ setCoAgentStateRender: (id: string, stateRender: CoAgentStateRender<any>) => void;
24
+ removeCoAgentStateRender: (id: string) => void;
25
+ claimsRef: RefObject<ClaimsRef>;
26
+ }
27
+
28
+ const CoAgentStateRendersContext = createContext<CoAgentStateRendersContextValue | undefined>(
29
+ undefined,
30
+ );
31
+
32
+ export function CoAgentStateRendersProvider({ children }: { children: ReactNode }) {
33
+ const [coAgentStateRenders, setCoAgentStateRenders] = useState<
34
+ Record<string, CoAgentStateRender<any>>
35
+ >({});
36
+
37
+ const setCoAgentStateRender = useCallback((id: string, stateRender: CoAgentStateRender<any>) => {
38
+ setCoAgentStateRenders((prevPoints) => ({
39
+ ...prevPoints,
40
+ [id]: stateRender,
41
+ }));
42
+ }, []);
43
+
44
+ const removeCoAgentStateRender = useCallback((id: string) => {
45
+ setCoAgentStateRenders((prevPoints) => {
46
+ const newPoints = { ...prevPoints };
47
+ delete newPoints[id];
48
+ return newPoints;
49
+ });
50
+ }, []);
51
+
52
+ const claimsRef = useRef<ClaimsRef>({});
53
+
54
+ return (
55
+ <CoAgentStateRendersContext.Provider
56
+ value={{
57
+ coAgentStateRenders,
58
+ setCoAgentStateRender,
59
+ removeCoAgentStateRender,
60
+ claimsRef,
61
+ }}
62
+ >
63
+ {children}
64
+ </CoAgentStateRendersContext.Provider>
65
+ );
66
+ }
67
+
68
+ export function useCoAgentStateRenders() {
69
+ const context = useContext(CoAgentStateRendersContext);
70
+ if (!context) {
71
+ throw new Error("useCoAgentStateRenders must be used within CoAgentStateRendersProvider");
72
+ }
73
+ return context;
74
+ }
75
+
76
+ export { CoAgentStateRendersContext };
@@ -22,10 +22,10 @@ import {
22
22
  } from "@copilotkit/runtime-client-gql";
23
23
  import { Agent } from "@copilotkit/runtime-client-gql";
24
24
  import {
25
- LangGraphInterruptAction,
25
+ LangGraphInterruptRender,
26
26
  LangGraphInterruptActionSetter,
27
+ QueuedInterruptEvent,
27
28
  } from "../types/interrupt-action";
28
- import { SuggestionItem } from "../utils/suggestions";
29
29
 
30
30
  /**
31
31
  * Interface for the configuration of the Copilot API.
@@ -95,10 +95,10 @@ export interface CopilotApiConfig {
95
95
  }
96
96
 
97
97
  export type InChatRenderFunction<TProps = ActionRenderProps<any> | CatchAllActionRenderProps<any>> =
98
- (props: TProps) => string | JSX.Element;
98
+ (props: TProps) => string | React.JSX.Element;
99
99
  export type CoagentInChatRenderFunction = (
100
100
  props: CoAgentStateRenderProps<any>,
101
- ) => string | JSX.Element | undefined | null;
101
+ ) => string | React.JSX.Element | undefined | null;
102
102
 
103
103
  export interface ChatComponentsCache {
104
104
  actions: Record<string, InChatRenderFunction | string>;
@@ -127,10 +127,9 @@ export interface CopilotContextParams {
127
127
  setAction: (id: string, action: FrontendAction<any>) => void;
128
128
  removeAction: (id: string) => void;
129
129
 
130
- // coagent actions
131
- coAgentStateRenders: Record<string, CoAgentStateRender<any>>;
132
- setCoAgentStateRender: (id: string, stateRender: CoAgentStateRender<any>) => void;
133
- removeCoAgentStateRender: (id: string) => void;
130
+ // registered actions for component-based rendering
131
+ setRegisteredActions: (actionConfig: any) => string;
132
+ removeRegisteredAction: (actionKey: string) => void;
134
133
 
135
134
  chatComponentsCache: React.RefObject<ChatComponentsCache>;
136
135
 
@@ -195,9 +194,6 @@ export interface CopilotContextParams {
195
194
  // i.e. when using `stop()` from `useChat`
196
195
  chatAbortControllerRef: React.MutableRefObject<AbortController | null>;
197
196
 
198
- // runtime
199
- runtimeClient: CopilotRuntimeClient;
200
-
201
197
  /**
202
198
  * The forwarded parameters to use for the task.
203
199
  */
@@ -221,9 +217,12 @@ export interface CopilotContextParams {
221
217
 
222
218
  extensions: ExtensionsInput;
223
219
  setExtensions: React.Dispatch<React.SetStateAction<ExtensionsInput>>;
224
- langGraphInterruptAction: LangGraphInterruptAction | null;
225
- setLangGraphInterruptAction: LangGraphInterruptActionSetter;
226
- removeLangGraphInterruptAction: (threadId: string) => void;
220
+ interruptActions: Record<string, LangGraphInterruptRender>;
221
+ setInterruptAction: LangGraphInterruptActionSetter;
222
+ removeInterruptAction: (actionId: string) => void;
223
+ interruptEventQueue: Record<string, QueuedInterruptEvent[]>;
224
+ addInterruptEvent: (queuedEvent: QueuedInterruptEvent) => void;
225
+ removeInterruptEvent: (threadId: string, eventId: string) => void;
227
226
 
228
227
  /**
229
228
  * Optional trace handler for comprehensive debugging and observability.
@@ -246,9 +245,8 @@ const emptyCopilotContext: CopilotContextParams = {
246
245
  setAction: () => {},
247
246
  removeAction: () => {},
248
247
 
249
- coAgentStateRenders: {},
250
- setCoAgentStateRender: () => {},
251
- removeCoAgentStateRender: () => {},
248
+ setRegisteredActions: () => "",
249
+ removeRegisteredAction: () => {},
252
250
 
253
251
  chatComponentsCache: { current: { actions: {}, coAgentStateRenders: {} } },
254
252
  getContextString: (documents: DocumentPointer[], categories: string[]) =>
@@ -271,7 +269,6 @@ const emptyCopilotContext: CopilotContextParams = {
271
269
  getDocumentsContext: (categories: string[]) => returnAndThrowInDebug([]),
272
270
  addDocumentContext: () => returnAndThrowInDebug(""),
273
271
  removeDocumentContext: () => {},
274
- runtimeClient: {} as any,
275
272
 
276
273
  copilotApiConfig: new (class implements CopilotApiConfig {
277
274
  get chatApiEndpoint(): string {
@@ -306,9 +303,12 @@ const emptyCopilotContext: CopilotContextParams = {
306
303
  availableAgents: [],
307
304
  extensions: {},
308
305
  setExtensions: () => {},
309
- langGraphInterruptAction: null,
310
- setLangGraphInterruptAction: () => {},
311
- removeLangGraphInterruptAction: () => {},
306
+ interruptActions: {},
307
+ setInterruptAction: () => {},
308
+ removeInterruptAction: () => {},
309
+ interruptEventQueue: {},
310
+ addInterruptEvent: () => {},
311
+ removeInterruptEvent: () => {},
312
312
  onError: () => {},
313
313
  bannerError: null,
314
314
  setBannerError: () => {},
@@ -4,13 +4,13 @@
4
4
 
5
5
  import { Message } from "@copilotkit/runtime-client-gql";
6
6
  import React from "react";
7
- import { SuggestionItem } from "../utils/suggestions";
7
+ import { Suggestion } from "@copilotkitnext/core";
8
8
 
9
9
  export interface CopilotMessagesContextParams {
10
10
  messages: Message[];
11
11
  setMessages: React.Dispatch<React.SetStateAction<Message[]>>; // suggestions state
12
- suggestions: SuggestionItem[];
13
- setSuggestions: React.Dispatch<React.SetStateAction<SuggestionItem[]>>;
12
+ suggestions: Suggestion[];
13
+ setSuggestions: React.Dispatch<React.SetStateAction<Suggestion[]>>;
14
14
  }
15
15
 
16
16
  const emptyCopilotContext: CopilotMessagesContextParams = {
@@ -1,8 +1,16 @@
1
1
  export { CopilotContext, useCopilotContext } from "./copilot-context";
2
2
  export { CopilotMessagesContext, useCopilotMessagesContext } from "./copilot-messages-context";
3
+ export {
4
+ CoAgentStateRendersContext,
5
+ CoAgentStateRendersProvider,
6
+ useCoAgentStateRenders,
7
+ } from "./coagent-state-renders-context";
8
+ export { ThreadsContext, ThreadsProvider, useThreads } from "./threads-context";
3
9
  export type {
4
10
  CopilotContextParams,
5
11
  CoagentInChatRenderFunction,
6
12
  CopilotApiConfig,
7
13
  } from "./copilot-context";
8
14
  export type { CopilotMessagesContextParams } from "./copilot-messages-context";
15
+ export type { CoAgentStateRendersContextValue } from "./coagent-state-renders-context";
16
+ export type { ThreadsContextValue, ThreadsProviderProps } from "./threads-context";
@@ -0,0 +1,41 @@
1
+ import React, { createContext, useContext, useState, ReactNode, SetStateAction } from "react";
2
+ import { randomUUID } from "@copilotkit/shared";
3
+
4
+ export interface ThreadsContextValue {
5
+ threadId: string;
6
+ setThreadId: (value: SetStateAction<string>) => void;
7
+ }
8
+
9
+ const ThreadsContext = createContext<ThreadsContextValue | undefined>(undefined);
10
+
11
+ export interface ThreadsProviderProps {
12
+ children: ReactNode;
13
+ threadId?: string;
14
+ }
15
+
16
+ export function ThreadsProvider({ children, threadId: explicitThreadId }: ThreadsProviderProps) {
17
+ const [internalThreadId, setThreadId] = useState<string>(explicitThreadId ?? randomUUID());
18
+
19
+ const threadId = internalThreadId;
20
+
21
+ return (
22
+ <ThreadsContext.Provider
23
+ value={{
24
+ threadId,
25
+ setThreadId,
26
+ }}
27
+ >
28
+ {children}
29
+ </ThreadsContext.Provider>
30
+ );
31
+ }
32
+
33
+ export function useThreads() {
34
+ const context = useContext(ThreadsContext);
35
+ if (!context) {
36
+ throw new Error("useThreads must be used within ThreadsProvider");
37
+ }
38
+ return context;
39
+ }
40
+
41
+ export { ThreadsContext };
@@ -6,13 +6,12 @@ export {
6
6
  type UseCopilotChatOptions_c,
7
7
  useCopilotChatHeadless_c,
8
8
  } from "./use-copilot-chat-headless_c";
9
- export { useCopilotChat as useCopilotChatInternal } from "./use-copilot-chat_internal";
9
+ export { useCopilotChatInternal, type ChatSuggestions } from "./use-copilot-chat_internal";
10
10
  export { useCopilotAction } from "./use-copilot-action";
11
11
  export { useCoAgentStateRender } from "./use-coagent-state-render";
12
12
  export { useMakeCopilotDocumentReadable } from "./use-make-copilot-document-readable";
13
- export { type UseChatHelpers } from "./use-chat";
14
13
  export { useCopilotReadable } from "./use-copilot-readable";
15
- export { useCoAgent, type HintFunction, runAgent, startAgent, stopAgent } from "./use-coagent";
14
+ export { useCoAgent, type HintFunction } from "./use-coagent";
16
15
  export { useCopilotRuntimeClient } from "./use-copilot-runtime-client";
17
16
  export { useCopilotAuthenticatedAction_c } from "./use-copilot-authenticated-action";
18
17
  export { useLangGraphInterrupt } from "./use-langgraph-interrupt";
@@ -23,3 +22,8 @@ export { useFrontendTool } from "./use-frontend-tool";
23
22
  export { useHumanInTheLoop } from "./use-human-in-the-loop";
24
23
  export { useRenderToolCall } from "./use-render-tool-call";
25
24
  export { useDefaultTool } from "./use-default-tool";
25
+ export { useLazyToolRenderer } from "./use-lazy-tool-renderer";
26
+ export {
27
+ useConfigureChatSuggestions,
28
+ type UseCopilotChatSuggestionsConfiguration,
29
+ } from "./use-configure-chat-suggestions";
@@ -0,0 +1,293 @@
1
+ import { ReactCustomMessageRendererPosition, useAgent } from "@copilotkitnext/react";
2
+ import { useCallback, useEffect, useMemo, useState } from "react";
3
+ import type { AgentSubscriber } from "@ag-ui/client";
4
+ import { useCoAgentStateRenders } from "../context";
5
+ import { dataToUUID, parseJson } from "@copilotkit/shared";
6
+
7
+ function getStateWithoutConstantKeys(state: any) {
8
+ const { messages, tools, copilotkit, ...stateWithoutConstantKeys } = state;
9
+ return stateWithoutConstantKeys;
10
+ }
11
+
12
+ // Function that compares states, without the constant keys
13
+ function areStatesEquals(a: any, b: any) {
14
+ if ((a && !b) || (!a && b)) return false;
15
+ const { messages, tools, copilotkit, ...aWithoutConstantKeys } = a;
16
+ const {
17
+ messages: bMessages,
18
+ tools: bTools,
19
+ copilotkit: bCopilotkit,
20
+ ...bWithoutConstantKeys
21
+ } = b;
22
+
23
+ return JSON.stringify(aWithoutConstantKeys) === JSON.stringify(bWithoutConstantKeys);
24
+ }
25
+
26
+ /**
27
+ * Bridge hook that connects agent state renders to chat messages.
28
+ *
29
+ * ## Purpose
30
+ * This hook finds matching state render configurations (registered via useCoAgentStateRender)
31
+ * and returns UI to render in chat.
32
+ * It ensures each state render appears bound to a specific message, preventing duplicates while
33
+ * allowing re-binding when the underlying state changes significantly.
34
+ *
35
+ * ## Message-ID-Based Claiming System
36
+ *
37
+ * ### The Problem
38
+ * Multiple bridge component instances render simultaneously (one per message). Without coordination,
39
+ * they would all try to render the same state render, causing duplicates.
40
+ *
41
+ * ### The Solution: Message-ID Claims with State Comparison
42
+ * Each state render is "claimed" by exactly one **message ID** (not runId):
43
+ *
44
+ * **Claim Structure**: `claimsRef.current[messageId] = { stateRenderId, runId, stateSnapshot, locked }`
45
+ *
46
+ * **Primary binding is by messageId because**:
47
+ * - runId is not always available immediately (starts as "pending")
48
+ * - messageId is the stable identifier throughout the message lifecycle
49
+ * - Claims persist across component remounts via context ref
50
+ *
51
+ * ### Claiming Logic Flow
52
+ *
53
+ * 1. **Message already has a claim**:
54
+ * - Check if the claim matches the current stateRenderId
55
+ * - If yes → render (this message owns this render)
56
+ * - Update runId if it was "pending" and now available
57
+ *
58
+ * 2. **State render claimed by another message**:
59
+ * - Compare state snapshots (ignoring constant keys: messages, tools, copilotkit)
60
+ * - If states are identical → block rendering (duplicate)
61
+ * - **If states are different → allow claiming** (new data, new message)
62
+ * - This handles cases where the same render type shows different states in different messages
63
+ *
64
+ * 3. **Unclaimed state render**:
65
+ * - Only allow claiming if runId is "pending" (initial render)
66
+ * - If runId is real but no claim exists → block (edge case protection)
67
+ * - Create new claim: `claimsRef.current[messageId] = { stateRenderId, runId }`
68
+ *
69
+ * ### State Snapshot Locking
70
+ *
71
+ * Once a state snapshot is captured and locked for a message:
72
+ * - The UI always renders with the locked snapshot (not live agent.state)
73
+ * - Prevents UI from appearing "wiped" during state transitions
74
+ * - Locked when: stateSnapshot prop is available (from message persistence)
75
+ * - Unlocked state: can still update from live agent.state
76
+ *
77
+ * ### Synchronous Claiming (Ref-based)
78
+ *
79
+ * Claims are stored in a context-level ref (not React state):
80
+ * - Multiple bridges render in the same tick
81
+ * - State updates are async - would allow duplicates before update completes
82
+ * - Ref provides immediate, synchronous claim checking
83
+ * - Survives component remounts (stored in context, not component)
84
+ *
85
+ * ## Flow Example
86
+ *
87
+ * ```
88
+ * Time 1: Message A renders, runId=undefined, state={progress: 50%}
89
+ * → effectiveRunId = "pending"
90
+ * → Claims: claimsRef["msgA"] = { stateRenderId: "tasks", runId: "pending", stateSnapshot: {progress: 50%} }
91
+ * → Renders UI with 50% progress
92
+ *
93
+ * Time 2: Message B renders, runId=undefined, same state
94
+ * → Checks: "tasks" already claimed by msgA with same state
95
+ * → Returns null (blocked - duplicate)
96
+ *
97
+ * Time 3: Real runId appears (e.g., "run-123")
98
+ * → Updates claim: claimsRef["msgA"].runId = "run-123"
99
+ * → Message A continues rendering
100
+ *
101
+ * Time 4: Agent processes more, state={progress: 100%}
102
+ * → Message A: locked to 50% (stateSnapshot locked)
103
+ * → Message C renders with state={progress: 100%}
104
+ * → Checks: "tasks" claimed by msgA but state is DIFFERENT (50% vs 100%)
105
+ * → Allows new claim: claimsRef["msgC"] = { stateRenderId: "tasks", runId: "run-123", stateSnapshot: {progress: 100%} }
106
+ * → Both messages render independently with their own snapshots
107
+ * ```
108
+ */
109
+ export interface CoAgentStateRenderBridgeProps {
110
+ message: any;
111
+ position: ReactCustomMessageRendererPosition;
112
+ runId: string;
113
+ messageIndex: number;
114
+ messageIndexInRun: number;
115
+ numberOfMessagesInRun: number;
116
+ agentId: string;
117
+ stateSnapshot: any;
118
+ }
119
+
120
+ export function useCoagentStateRenderBridge(agentId: string, props: CoAgentStateRenderBridgeProps) {
121
+ const { stateSnapshot, messageIndexInRun, message } = props;
122
+ const { coAgentStateRenders, claimsRef } = useCoAgentStateRenders();
123
+ const { agent } = useAgent({ agentId });
124
+ const [nodeName, setNodeName] = useState<string | undefined>(undefined);
125
+
126
+ const runId = props.runId ?? message.runId;
127
+ const effectiveRunId = runId || "pending";
128
+
129
+ useEffect(() => {
130
+ if (!agent) return;
131
+ const subscriber: AgentSubscriber = {
132
+ onStepStartedEvent: ({ event }) => {
133
+ if (event.stepName !== nodeName) {
134
+ setNodeName(event.stepName);
135
+ }
136
+ },
137
+ onStepFinishedEvent: ({ event }) => {
138
+ if (event.stepName === nodeName) {
139
+ setNodeName(undefined);
140
+ }
141
+ },
142
+ };
143
+
144
+ const { unsubscribe } = agent.subscribe(subscriber);
145
+ return () => {
146
+ unsubscribe();
147
+ };
148
+ // eslint-disable-next-line react-hooks/exhaustive-deps
149
+ }, [agentId, nodeName]);
150
+
151
+ if (messageIndexInRun !== 0) {
152
+ return null;
153
+ }
154
+
155
+ const getStateRender = useCallback(
156
+ (messageId: string) => {
157
+ return Object.entries(coAgentStateRenders).find(([stateRenderId, stateRender]) => {
158
+ if (claimsRef.current[messageId]) {
159
+ return stateRenderId === claimsRef.current[messageId].stateRenderId;
160
+ }
161
+ const matchingAgentName = stateRender.name === agentId;
162
+ const matchesNodeContext = stateRender.nodeName
163
+ ? stateRender.nodeName === nodeName
164
+ : true;
165
+ return matchingAgentName && matchesNodeContext;
166
+ });
167
+ },
168
+ [coAgentStateRenders, nodeName, agentId],
169
+ );
170
+
171
+ // Message ID-based claim system - A state render can only be claimed by one message ID
172
+ const handleRenderRequest = ({
173
+ stateRenderId,
174
+ messageId,
175
+ runId,
176
+ stateSnapshot: renderSnapshot,
177
+ }: {
178
+ stateRenderId: string;
179
+ messageId: string;
180
+ runId?: string;
181
+ stateSnapshot?: any;
182
+ }): boolean => {
183
+ // Check if this message has already claimed this state render
184
+ if (claimsRef.current[messageId]) {
185
+ const canRender = claimsRef.current[messageId].stateRenderId === stateRenderId;
186
+
187
+ // Update runId if it doesn't exist
188
+ if (
189
+ canRender &&
190
+ runId &&
191
+ (!claimsRef.current[messageId].runId || claimsRef.current[messageId].runId === "pending")
192
+ ) {
193
+ claimsRef.current[messageId].runId = runId;
194
+ }
195
+
196
+ return canRender;
197
+ }
198
+
199
+ // Do not allow render if any other message has claimed this state render
200
+ const renderClaimedByOtherMessage = Object.values(claimsRef.current).find(
201
+ (c) =>
202
+ c.stateRenderId === stateRenderId &&
203
+ dataToUUID(JSON.stringify(getStateWithoutConstantKeys(c.stateSnapshot))) ===
204
+ dataToUUID(JSON.stringify(getStateWithoutConstantKeys(renderSnapshot))),
205
+ );
206
+ if (renderClaimedByOtherMessage) {
207
+ // If:
208
+ // - state render already claimed
209
+ // - snapshot exists in the claiming object and is different from current,
210
+ if (
211
+ renderSnapshot &&
212
+ renderClaimedByOtherMessage.stateSnapshot &&
213
+ !areStatesEquals(renderClaimedByOtherMessage.stateSnapshot, renderSnapshot)
214
+ ) {
215
+ claimsRef.current[messageId] = { stateRenderId, runId };
216
+ return true;
217
+ }
218
+ return false;
219
+ }
220
+
221
+ // No existing claim anywhere yet – allow this message to claim even if we already know the runId.
222
+ if (!runId) {
223
+ return false;
224
+ }
225
+
226
+ claimsRef.current[messageId] = { stateRenderId, runId };
227
+ return true;
228
+ };
229
+
230
+ return useMemo(() => {
231
+ const [stateRenderId, stateRender] = getStateRender(message.id) ?? [];
232
+
233
+ if (!stateRender || !stateRenderId) {
234
+ return null;
235
+ }
236
+
237
+ // Is there any state we can use?
238
+ const snapshot = stateSnapshot ? parseJson(stateSnapshot, stateSnapshot) : agent?.state;
239
+
240
+ // Synchronously check/claim - returns true if this message can render
241
+ const canRender = handleRenderRequest({
242
+ stateRenderId,
243
+ messageId: message.id,
244
+ runId: effectiveRunId,
245
+ stateSnapshot: snapshot,
246
+ });
247
+ if (!canRender) {
248
+ return null;
249
+ }
250
+
251
+ // If we found state, and given that now there's a claim for the current message, let's save it in the claim
252
+ if (snapshot && !claimsRef.current[message.id].locked) {
253
+ if (stateSnapshot) {
254
+ claimsRef.current[message.id].stateSnapshot = snapshot;
255
+ claimsRef.current[message.id].locked = true;
256
+ } else {
257
+ claimsRef.current[message.id].stateSnapshot = snapshot;
258
+ }
259
+ }
260
+
261
+ if (stateRender.handler) {
262
+ stateRender.handler({
263
+ state: stateSnapshot ? parseJson(stateSnapshot, stateSnapshot) : (agent?.state ?? {}),
264
+ nodeName: nodeName ?? "",
265
+ });
266
+ }
267
+
268
+ if (stateRender.render) {
269
+ const status = agent?.isRunning ? "inProgress" : "complete";
270
+
271
+ if (typeof stateRender.render === "string") return stateRender.render;
272
+
273
+ return stateRender.render({
274
+ status,
275
+ // Always use state from claim, to make sure the state does not seem "wiped" for a fraction of a second
276
+ state: claimsRef.current[message.id].stateSnapshot ?? {},
277
+ nodeName: nodeName ?? "",
278
+ });
279
+ }
280
+ }, [
281
+ getStateRender,
282
+ stateSnapshot,
283
+ agent?.state,
284
+ agent?.isRunning,
285
+ nodeName,
286
+ effectiveRunId,
287
+ message.id,
288
+ ]);
289
+ }
290
+
291
+ export function CoAgentStateRenderBridge(props: CoAgentStateRenderBridgeProps) {
292
+ return useCoagentStateRenderBridge(props.agentId, props);
293
+ }
@@ -46,6 +46,7 @@ import { CopilotContext } from "../context/copilot-context";
46
46
  import { randomId, CopilotKitAgentDiscoveryError } from "@copilotkit/shared";
47
47
  import { CoAgentStateRender } from "../types/coagent-action";
48
48
  import { useToast } from "../components/toast/toast-provider";
49
+ import { useCoAgentStateRenders } from "../context/coagent-state-renders-context";
49
50
 
50
51
  /**
51
52
  * This hook is used to render agent state with custom UI components or text. This is particularly
@@ -62,13 +63,9 @@ export function useCoAgentStateRender<T = any>(
62
63
  action: CoAgentStateRender<T>,
63
64
  dependencies?: any[],
64
65
  ): void {
65
- const {
66
- setCoAgentStateRender,
67
- removeCoAgentStateRender,
68
- coAgentStateRenders,
69
- chatComponentsCache,
70
- availableAgents,
71
- } = useContext(CopilotContext);
66
+ const { chatComponentsCache, availableAgents } = useContext(CopilotContext);
67
+ const { setCoAgentStateRender, removeCoAgentStateRender, coAgentStateRenders } =
68
+ useCoAgentStateRenders();
72
69
  const idRef = useRef<string>(randomId());
73
70
  const { setBannerError, addToast } = useToast();
74
71