@copilotkit/react-core 1.10.7-next.0 → 1.50.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (334) hide show
  1. package/CHANGELOG.md +0 -7
  2. package/dist/chunk-24SCZAB4.mjs +143 -0
  3. package/dist/chunk-24SCZAB4.mjs.map +1 -0
  4. package/dist/chunk-36KQV2NA.mjs +1 -0
  5. package/dist/{chunk-U7QULEVO.mjs → chunk-3GURHDG7.mjs} +3 -3
  6. package/dist/{chunk-OAGAFMUM.mjs → chunk-3R423LZT.mjs} +6 -5
  7. package/dist/{chunk-OAGAFMUM.mjs.map → chunk-3R423LZT.mjs.map} +1 -1
  8. package/dist/chunk-5X5DJRQQ.mjs +71 -0
  9. package/dist/chunk-5X5DJRQQ.mjs.map +1 -0
  10. package/dist/{chunk-N4WEHORG.mjs → chunk-6PUNP7CD.mjs} +4 -4
  11. package/dist/chunk-6PUNP7CD.mjs.map +1 -0
  12. package/dist/chunk-7BYHZLPL.mjs +32 -0
  13. package/dist/chunk-7BYHZLPL.mjs.map +1 -0
  14. package/dist/chunk-7DTB7S5V.mjs +83 -0
  15. package/dist/chunk-7DTB7S5V.mjs.map +1 -0
  16. package/dist/chunk-A6NKSGH3.mjs +1 -0
  17. package/dist/{chunk-GT5WI3AF.mjs → chunk-BR5YEYZJ.mjs} +7 -9
  18. package/dist/chunk-BR5YEYZJ.mjs.map +1 -0
  19. package/dist/chunk-CB7CRBDG.mjs +48 -0
  20. package/dist/chunk-CB7CRBDG.mjs.map +1 -0
  21. package/dist/chunk-CYDWEPFL.mjs +1 -0
  22. package/dist/{chunk-BBUQMG45.mjs → chunk-D3QSYDJR.mjs} +3 -3
  23. package/dist/{chunk-BBUQMG45.mjs.map → chunk-D3QSYDJR.mjs.map} +1 -1
  24. package/dist/chunk-DCHSCK62.mjs +549 -0
  25. package/dist/chunk-DCHSCK62.mjs.map +1 -0
  26. package/dist/{chunk-ZLQVRPDS.mjs → chunk-DMLQZG75.mjs} +1 -1
  27. package/dist/chunk-DMLQZG75.mjs.map +1 -0
  28. package/dist/chunk-F555TVE4.mjs +33 -0
  29. package/dist/chunk-F555TVE4.mjs.map +1 -0
  30. package/dist/{chunk-C6IANC2R.mjs → chunk-FBD24VEH.mjs} +7 -43
  31. package/dist/chunk-FBD24VEH.mjs.map +1 -0
  32. package/dist/chunk-FD6FGKYY.mjs +1 -0
  33. package/dist/chunk-FDOMAPJY.mjs +59 -0
  34. package/dist/chunk-FDOMAPJY.mjs.map +1 -0
  35. package/dist/{chunk-E3624YDU.mjs → chunk-GMI4KO4X.mjs} +8 -6
  36. package/dist/{chunk-E3624YDU.mjs.map → chunk-GMI4KO4X.mjs.map} +1 -1
  37. package/dist/chunk-IUSKVYUI.mjs +13 -0
  38. package/dist/chunk-IUSKVYUI.mjs.map +1 -0
  39. package/dist/chunk-JD7BAH7U.mjs +1 -0
  40. package/dist/{chunk-EDBI5PCJ.mjs → chunk-JRT5BJF3.mjs} +2 -2
  41. package/dist/{chunk-N4VN2B5S.mjs → chunk-LHERIF3L.mjs} +2 -2
  42. package/dist/{chunk-DXEQPN43.mjs → chunk-LHKZJ2ND.mjs} +3 -3
  43. package/dist/chunk-NB2FKV2V.mjs +1 -0
  44. package/dist/chunk-NBK4KBLX.mjs +54 -0
  45. package/dist/chunk-NBK4KBLX.mjs.map +1 -0
  46. package/dist/chunk-NG26QEGF.mjs +46 -0
  47. package/dist/chunk-NG26QEGF.mjs.map +1 -0
  48. package/dist/chunk-NROJOTQP.mjs +163 -0
  49. package/dist/chunk-NROJOTQP.mjs.map +1 -0
  50. package/dist/{chunk-MGWRDFBE.mjs → chunk-OVYFRPSN.mjs} +2 -2
  51. package/dist/{chunk-MQYWH4E6.mjs → chunk-QU6NONOD.mjs} +2 -2
  52. package/dist/chunk-R4MR43UQ.mjs +101 -0
  53. package/dist/chunk-R4MR43UQ.mjs.map +1 -0
  54. package/dist/chunk-SPCZTZCY.mjs +1 -0
  55. package/dist/chunk-SPCZTZCY.mjs.map +1 -0
  56. package/dist/chunk-TXI72QHK.mjs +80 -0
  57. package/dist/chunk-TXI72QHK.mjs.map +1 -0
  58. package/dist/chunk-UJBV5GAG.mjs +767 -0
  59. package/dist/chunk-UJBV5GAG.mjs.map +1 -0
  60. package/dist/{chunk-OKCYPO4I.mjs → chunk-WMJVBMUX.mjs} +3 -3
  61. package/dist/{chunk-EUX2P2E7.mjs → chunk-WVLHXIFP.mjs} +11 -9
  62. package/dist/chunk-WVLHXIFP.mjs.map +1 -0
  63. package/dist/{chunk-5FHSUKQL.mjs → chunk-YYN33GSG.mjs} +5 -2
  64. package/dist/chunk-YYN33GSG.mjs.map +1 -0
  65. package/dist/chunk-ZVF5Q6IH.mjs +29 -0
  66. package/dist/chunk-ZVF5Q6IH.mjs.map +1 -0
  67. package/dist/components/CopilotListeners.d.ts +3 -0
  68. package/dist/components/CopilotListeners.js +234 -0
  69. package/dist/components/CopilotListeners.js.map +1 -0
  70. package/dist/components/CopilotListeners.mjs +14 -0
  71. package/dist/components/CopilotListeners.mjs.map +1 -0
  72. package/dist/components/copilot-provider/copilot-messages.js +14 -48
  73. package/dist/components/copilot-provider/copilot-messages.js.map +1 -1
  74. package/dist/components/copilot-provider/copilot-messages.mjs +3 -3
  75. package/dist/components/copilot-provider/copilotkit-props.d.ts +9 -2
  76. package/dist/components/copilot-provider/copilotkit-props.js.map +1 -1
  77. package/dist/components/copilot-provider/copilotkit.d.ts +2 -1
  78. package/dist/components/copilot-provider/copilotkit.js +528 -370
  79. package/dist/components/copilot-provider/copilotkit.js.map +1 -1
  80. package/dist/components/copilot-provider/copilotkit.mjs +15 -10
  81. package/dist/components/copilot-provider/index.d.ts +2 -1
  82. package/dist/components/copilot-provider/index.js +528 -370
  83. package/dist/components/copilot-provider/index.js.map +1 -1
  84. package/dist/components/copilot-provider/index.mjs +16 -10
  85. package/dist/components/dev-console/console-trigger.js +10 -8
  86. package/dist/components/dev-console/console-trigger.js.map +1 -1
  87. package/dist/components/dev-console/console-trigger.mjs +4 -4
  88. package/dist/components/dev-console/developer-console-modal.js +10 -8
  89. package/dist/components/dev-console/developer-console-modal.js.map +1 -1
  90. package/dist/components/dev-console/developer-console-modal.mjs +3 -3
  91. package/dist/components/error-boundary/error-boundary.d.ts +7 -7
  92. package/dist/components/error-boundary/error-boundary.js +3 -3
  93. package/dist/components/error-boundary/error-boundary.js.map +1 -1
  94. package/dist/components/error-boundary/error-boundary.mjs +2 -2
  95. package/dist/components/error-boundary/error-utils.d.ts +1 -1
  96. package/dist/components/error-boundary/error-utils.js +3 -3
  97. package/dist/components/error-boundary/error-utils.js.map +1 -1
  98. package/dist/components/error-boundary/error-utils.mjs +1 -1
  99. package/dist/components/index.d.ts +2 -1
  100. package/dist/components/index.js +528 -370
  101. package/dist/components/index.js.map +1 -1
  102. package/dist/components/index.mjs +17 -10
  103. package/dist/components/toast/exclamation-mark-icon.d.ts +2 -2
  104. package/dist/components/toast/toast-provider.d.ts +3 -3
  105. package/dist/components/usage-banner.d.ts +2 -2
  106. package/dist/context/coagent-state-renders-context.d.ts +24 -0
  107. package/dist/context/coagent-state-renders-context.js +91 -0
  108. package/dist/context/coagent-state-renders-context.js.map +1 -0
  109. package/dist/context/coagent-state-renders-context.mjs +12 -0
  110. package/dist/context/coagent-state-renders-context.mjs.map +1 -0
  111. package/dist/context/copilot-context.d.ts +1 -1
  112. package/dist/context/copilot-context.js +10 -8
  113. package/dist/context/copilot-context.js.map +1 -1
  114. package/dist/context/copilot-context.mjs +1 -1
  115. package/dist/context/copilot-messages-context.d.ts +18 -11
  116. package/dist/context/copilot-messages-context.js.map +1 -1
  117. package/dist/context/copilot-messages-context.mjs +1 -1
  118. package/dist/context/index.d.ts +6 -2
  119. package/dist/context/index.js +110 -10
  120. package/dist/context/index.js.map +1 -1
  121. package/dist/context/index.mjs +20 -4
  122. package/dist/context/threads-context.d.ts +16 -0
  123. package/dist/context/threads-context.js +59 -0
  124. package/dist/context/threads-context.js.map +1 -0
  125. package/dist/context/threads-context.mjs +12 -0
  126. package/dist/context/threads-context.mjs.map +1 -0
  127. package/dist/{copilot-context-cf9de848.d.ts → copilot-context-1cd70a3f.d.ts} +36 -32
  128. package/dist/hooks/index.d.ts +9 -6
  129. package/dist/hooks/index.js +1445 -1839
  130. package/dist/hooks/index.js.map +1 -1
  131. package/dist/hooks/index.mjs +47 -56
  132. package/dist/hooks/use-coagent-state-render-bridge.d.ts +100 -0
  133. package/dist/hooks/use-coagent-state-render-bridge.js +211 -0
  134. package/dist/hooks/use-coagent-state-render-bridge.js.map +1 -0
  135. package/dist/hooks/use-coagent-state-render-bridge.mjs +15 -0
  136. package/dist/hooks/use-coagent-state-render-bridge.mjs.map +1 -0
  137. package/dist/hooks/use-coagent-state-render.js +31 -20
  138. package/dist/hooks/use-coagent-state-render.js.map +1 -1
  139. package/dist/hooks/use-coagent-state-render.mjs +3 -2
  140. package/dist/hooks/use-coagent.d.ts +2 -14
  141. package/dist/hooks/use-coagent.js +109 -1906
  142. package/dist/hooks/use-coagent.js.map +1 -1
  143. package/dist/hooks/use-coagent.mjs +1 -30
  144. package/dist/hooks/use-configure-chat-suggestions.d.ts +36 -0
  145. package/dist/hooks/use-configure-chat-suggestions.js +210 -0
  146. package/dist/hooks/use-configure-chat-suggestions.js.map +1 -0
  147. package/dist/hooks/use-configure-chat-suggestions.mjs +13 -0
  148. package/dist/hooks/use-configure-chat-suggestions.mjs.map +1 -0
  149. package/dist/hooks/use-copilot-action.d.ts +8 -45
  150. package/dist/hooks/use-copilot-action.js +207 -349
  151. package/dist/hooks/use-copilot-action.js.map +1 -1
  152. package/dist/hooks/use-copilot-action.mjs +4 -5
  153. package/dist/hooks/use-copilot-additional-instructions.js +10 -8
  154. package/dist/hooks/use-copilot-additional-instructions.js.map +1 -1
  155. package/dist/hooks/use-copilot-additional-instructions.mjs +2 -2
  156. package/dist/hooks/use-copilot-authenticated-action.js +224 -248
  157. package/dist/hooks/use-copilot-authenticated-action.js.map +1 -1
  158. package/dist/hooks/use-copilot-authenticated-action.mjs +6 -6
  159. package/dist/hooks/use-copilot-chat-headless_c.d.ts +2 -10
  160. package/dist/hooks/use-copilot-chat-headless_c.js +973 -1369
  161. package/dist/hooks/use-copilot-chat-headless_c.js.map +1 -1
  162. package/dist/hooks/use-copilot-chat-headless_c.mjs +12 -22
  163. package/dist/hooks/use-copilot-chat.d.ts +2 -10
  164. package/dist/hooks/use-copilot-chat.js +967 -1388
  165. package/dist/hooks/use-copilot-chat.js.map +1 -1
  166. package/dist/hooks/use-copilot-chat.mjs +12 -22
  167. package/dist/hooks/use-copilot-chat_internal.d.ts +38 -14
  168. package/dist/hooks/use-copilot-chat_internal.js +965 -1362
  169. package/dist/hooks/use-copilot-chat_internal.js.map +1 -1
  170. package/dist/hooks/use-copilot-chat_internal.mjs +13 -23
  171. package/dist/hooks/use-copilot-readable.d.ts +1 -1
  172. package/dist/hooks/use-copilot-readable.js +6 -157
  173. package/dist/hooks/use-copilot-readable.js.map +1 -1
  174. package/dist/hooks/use-copilot-readable.mjs +1 -2
  175. package/dist/hooks/use-default-tool.js +204 -349
  176. package/dist/hooks/use-default-tool.js.map +1 -1
  177. package/dist/hooks/use-default-tool.mjs +5 -6
  178. package/dist/hooks/use-flat-category-store.js +4 -1
  179. package/dist/hooks/use-flat-category-store.js.map +1 -1
  180. package/dist/hooks/use-flat-category-store.mjs +1 -1
  181. package/dist/hooks/use-frontend-tool.d.ts +3 -3
  182. package/dist/hooks/use-frontend-tool.js +30 -370
  183. package/dist/hooks/use-frontend-tool.js.map +1 -1
  184. package/dist/hooks/use-frontend-tool.mjs +1 -6
  185. package/dist/hooks/use-human-in-the-loop.d.ts +4 -3
  186. package/dist/hooks/use-human-in-the-loop.js +61 -393
  187. package/dist/hooks/use-human-in-the-loop.js.map +1 -1
  188. package/dist/hooks/use-human-in-the-loop.mjs +1 -6
  189. package/dist/hooks/use-langgraph-interrupt-render.d.ts +3 -2
  190. package/dist/hooks/use-langgraph-interrupt-render.js +92 -36
  191. package/dist/hooks/use-langgraph-interrupt-render.js.map +1 -1
  192. package/dist/hooks/use-langgraph-interrupt-render.mjs +6 -4
  193. package/dist/hooks/use-langgraph-interrupt.d.ts +1 -1
  194. package/dist/hooks/use-langgraph-interrupt.js +24 -1642
  195. package/dist/hooks/use-langgraph-interrupt.js.map +1 -1
  196. package/dist/hooks/use-langgraph-interrupt.mjs +2 -23
  197. package/dist/hooks/use-lazy-tool-renderer.d.ts +6 -0
  198. package/dist/hooks/use-lazy-tool-renderer.js +53 -0
  199. package/dist/hooks/use-lazy-tool-renderer.js.map +1 -0
  200. package/dist/hooks/use-lazy-tool-renderer.mjs +8 -0
  201. package/dist/hooks/use-lazy-tool-renderer.mjs.map +1 -0
  202. package/dist/hooks/use-make-copilot-document-readable.js +11 -9
  203. package/dist/hooks/use-make-copilot-document-readable.js.map +1 -1
  204. package/dist/hooks/use-make-copilot-document-readable.mjs +2 -2
  205. package/dist/hooks/use-render-tool-call.d.ts +7 -6
  206. package/dist/hooks/use-render-tool-call.js +36 -386
  207. package/dist/hooks/use-render-tool-call.js.map +1 -1
  208. package/dist/hooks/use-render-tool-call.mjs +1 -6
  209. package/dist/index.d.ts +11 -6
  210. package/dist/index.js +1841 -2056
  211. package/dist/index.js.map +1 -1
  212. package/dist/index.mjs +78 -59
  213. package/dist/lib/copilot-task.d.ts +1 -1
  214. package/dist/lib/copilot-task.js +1 -0
  215. package/dist/lib/copilot-task.js.map +1 -1
  216. package/dist/lib/copilot-task.mjs +18 -11
  217. package/dist/lib/index.d.ts +1 -1
  218. package/dist/lib/index.js +1 -0
  219. package/dist/lib/index.js.map +1 -1
  220. package/dist/lib/index.mjs +18 -11
  221. package/dist/setupTests.d.ts +2 -2
  222. package/dist/types/frontend-action.d.ts +5 -5
  223. package/dist/types/index.d.ts +4 -0
  224. package/dist/types/index.js.map +1 -1
  225. package/dist/types/index.mjs +2 -1
  226. package/dist/types/interrupt-action.d.ts +1 -1
  227. package/dist/types/interrupt-action.js.map +1 -1
  228. package/dist/types/interrupt-action.mjs +1 -0
  229. package/dist/utils/index.d.ts +0 -12
  230. package/dist/utils/index.js +6 -325
  231. package/dist/utils/index.js.map +1 -1
  232. package/dist/utils/index.mjs +1 -21
  233. package/dist/utils/utils.js.map +1 -1
  234. package/dist/v2/index.d.ts +2 -0
  235. package/dist/v2/index.js +27 -0
  236. package/dist/v2/index.js.map +1 -0
  237. package/dist/v2/index.mjs +4 -0
  238. package/dist/v2/index.mjs.map +1 -0
  239. package/package.json +20 -9
  240. package/src/components/CopilotListeners.tsx +82 -0
  241. package/src/components/copilot-provider/copilot-messages.tsx +46 -47
  242. package/src/components/copilot-provider/copilotkit-props.tsx +8 -1
  243. package/src/components/copilot-provider/copilotkit.tsx +177 -144
  244. package/src/components/error-boundary/error-utils.tsx +3 -3
  245. package/src/context/coagent-state-renders-context.tsx +76 -0
  246. package/src/context/copilot-context.tsx +21 -21
  247. package/src/context/copilot-messages-context.tsx +3 -3
  248. package/src/context/index.ts +8 -0
  249. package/src/context/threads-context.tsx +41 -0
  250. package/src/hooks/index.ts +7 -3
  251. package/src/hooks/use-coagent-state-render-bridge.tsx +293 -0
  252. package/src/hooks/use-coagent-state-render.ts +4 -7
  253. package/src/hooks/use-coagent.ts +129 -249
  254. package/src/hooks/use-configure-chat-suggestions.tsx +85 -0
  255. package/src/hooks/use-copilot-action.ts +88 -199
  256. package/src/hooks/use-copilot-chat-headless_c.ts +2 -1
  257. package/src/hooks/use-copilot-chat.ts +4 -1
  258. package/src/hooks/use-copilot-chat_internal.ts +349 -258
  259. package/src/hooks/use-copilot-readable.ts +6 -26
  260. package/src/hooks/use-flat-category-store.ts +4 -3
  261. package/src/hooks/use-frontend-tool.ts +67 -8
  262. package/src/hooks/use-human-in-the-loop.ts +111 -13
  263. package/src/hooks/use-langgraph-interrupt-render.ts +90 -40
  264. package/src/hooks/use-langgraph-interrupt.ts +18 -47
  265. package/src/hooks/use-lazy-tool-renderer.tsx +30 -0
  266. package/src/hooks/use-make-copilot-document-readable.ts +1 -1
  267. package/src/hooks/use-render-tool-call.ts +73 -13
  268. package/src/types/index.ts +1 -0
  269. package/src/types/interrupt-action.ts +8 -4
  270. package/src/utils/index.ts +0 -3
  271. package/src/utils/utils.ts +7 -0
  272. package/src/v2/index.ts +2 -0
  273. package/src/v2/styles.css +1 -0
  274. package/tsup.config.ts +1 -1
  275. package/dist/chunk-5FHSUKQL.mjs.map +0 -1
  276. package/dist/chunk-6GPVUMBU.mjs +0 -13
  277. package/dist/chunk-6GPVUMBU.mjs.map +0 -1
  278. package/dist/chunk-AKR2SSUJ.mjs +0 -22
  279. package/dist/chunk-AKR2SSUJ.mjs.map +0 -1
  280. package/dist/chunk-BXXJQ2BL.mjs +0 -239
  281. package/dist/chunk-BXXJQ2BL.mjs.map +0 -1
  282. package/dist/chunk-C6IANC2R.mjs.map +0 -1
  283. package/dist/chunk-DZTU6PGS.mjs +0 -1
  284. package/dist/chunk-EUX2P2E7.mjs.map +0 -1
  285. package/dist/chunk-EVVO67QO.mjs +0 -25
  286. package/dist/chunk-EVVO67QO.mjs.map +0 -1
  287. package/dist/chunk-GGLAHG3I.mjs +0 -804
  288. package/dist/chunk-GGLAHG3I.mjs.map +0 -1
  289. package/dist/chunk-GT5WI3AF.mjs.map +0 -1
  290. package/dist/chunk-HDOG2RTM.mjs +0 -37
  291. package/dist/chunk-HDOG2RTM.mjs.map +0 -1
  292. package/dist/chunk-MIXSWZSB.mjs +0 -71
  293. package/dist/chunk-MIXSWZSB.mjs.map +0 -1
  294. package/dist/chunk-N4WEHORG.mjs.map +0 -1
  295. package/dist/chunk-NSBAWITG.mjs +0 -332
  296. package/dist/chunk-NSBAWITG.mjs.map +0 -1
  297. package/dist/chunk-OT5NHMEC.mjs +0 -723
  298. package/dist/chunk-OT5NHMEC.mjs.map +0 -1
  299. package/dist/chunk-T3376SZS.mjs +0 -142
  300. package/dist/chunk-T3376SZS.mjs.map +0 -1
  301. package/dist/chunk-YPBKY4KY.mjs +0 -1
  302. package/dist/chunk-YPSGKPDA.mjs +0 -1
  303. package/dist/chunk-ZLQVRPDS.mjs.map +0 -1
  304. package/dist/chunk-ZVOLWJCY.mjs +0 -47
  305. package/dist/chunk-ZVOLWJCY.mjs.map +0 -1
  306. package/dist/hooks/use-chat.d.ts +0 -145
  307. package/dist/hooks/use-chat.js +0 -1129
  308. package/dist/hooks/use-chat.js.map +0 -1
  309. package/dist/hooks/use-chat.mjs +0 -14
  310. package/dist/index-1f5b66ac.d.ts +0 -36
  311. package/dist/utils/extract.d.ts +0 -43
  312. package/dist/utils/extract.js +0 -208
  313. package/dist/utils/extract.js.map +0 -1
  314. package/dist/utils/extract.mjs +0 -25
  315. package/dist/utils/suggestions.d.ts +0 -11
  316. package/dist/utils/suggestions.js +0 -343
  317. package/dist/utils/suggestions.js.map +0 -1
  318. package/dist/utils/suggestions.mjs +0 -25
  319. package/src/hooks/use-chat.ts +0 -1142
  320. package/src/utils/extract.ts +0 -215
  321. package/src/utils/suggestions.ts +0 -208
  322. /package/dist/{chunk-DZTU6PGS.mjs.map → chunk-36KQV2NA.mjs.map} +0 -0
  323. /package/dist/{chunk-U7QULEVO.mjs.map → chunk-3GURHDG7.mjs.map} +0 -0
  324. /package/dist/{chunk-YPBKY4KY.mjs.map → chunk-A6NKSGH3.mjs.map} +0 -0
  325. /package/dist/{chunk-YPSGKPDA.mjs.map → chunk-CYDWEPFL.mjs.map} +0 -0
  326. /package/dist/{hooks/use-chat.mjs.map → chunk-FD6FGKYY.mjs.map} +0 -0
  327. /package/dist/{utils/extract.mjs.map → chunk-JD7BAH7U.mjs.map} +0 -0
  328. /package/dist/{chunk-EDBI5PCJ.mjs.map → chunk-JRT5BJF3.mjs.map} +0 -0
  329. /package/dist/{chunk-N4VN2B5S.mjs.map → chunk-LHERIF3L.mjs.map} +0 -0
  330. /package/dist/{chunk-DXEQPN43.mjs.map → chunk-LHKZJ2ND.mjs.map} +0 -0
  331. /package/dist/{utils/suggestions.mjs.map → chunk-NB2FKV2V.mjs.map} +0 -0
  332. /package/dist/{chunk-MGWRDFBE.mjs.map → chunk-OVYFRPSN.mjs.map} +0 -0
  333. /package/dist/{chunk-MQYWH4E6.mjs.map → chunk-QU6NONOD.mjs.map} +0 -0
  334. /package/dist/{chunk-OKCYPO4I.mjs.map → chunk-WMJVBMUX.mjs.map} +0 -0
@@ -63,6 +63,7 @@
63
63
  */
64
64
  import { useEffect, useRef } from "react";
65
65
  import { useCopilotContext } from "../context/copilot-context";
66
+ import { useAgentContext } from "@copilotkitnext/react";
66
67
 
67
68
  /**
68
69
  * Options for the useCopilotReadable hook.
@@ -106,32 +107,11 @@ function convertToJSON(description: string, value: any): string {
106
107
  * Adds the given information to the Copilot context to make it readable by Copilot.
107
108
  */
108
109
  export function useCopilotReadable(
109
- {
110
+ { description, value }: UseCopilotReadableOptions,
111
+ dependencies?: any[],
112
+ ): void {
113
+ useAgentContext({
110
114
  description,
111
115
  value,
112
- parentId,
113
- categories,
114
- convert,
115
- available = "enabled",
116
- }: UseCopilotReadableOptions,
117
- dependencies?: any[],
118
- ): string | undefined {
119
- const { addContext, removeContext } = useCopilotContext();
120
- const idRef = useRef<string>();
121
- convert = convert || convertToJSON;
122
-
123
- const information = convert(description, value);
124
-
125
- useEffect(() => {
126
- if (available === "disabled") return;
127
-
128
- const id = addContext(information, parentId, categories);
129
- idRef.current = id;
130
-
131
- return () => {
132
- removeContext(id);
133
- };
134
- }, [available, information, parentId, addContext, removeContext, ...(dependencies || [])]);
135
-
136
- return idRef.current;
116
+ });
137
117
  }
@@ -16,9 +16,10 @@ interface FlatCategoryStoreElement<T> {
16
16
  }
17
17
 
18
18
  const useFlatCategoryStore = <T>(): UseFlatCategoryStoreReturn<T> => {
19
- const [elements, dispatch] = useReducer<
20
- React.Reducer<Map<FlatCategoryStoreId, FlatCategoryStoreElement<T>>, Action<T>>
21
- >(flatCategoryStoreReducer, new Map<FlatCategoryStoreId, FlatCategoryStoreElement<T>>());
19
+ const [elements, dispatch] = useReducer(
20
+ flatCategoryStoreReducer<T>,
21
+ new Map<FlatCategoryStoreId, FlatCategoryStoreElement<T>>(),
22
+ );
22
23
 
23
24
  const addElement = useCallback((value: T, categories: string[]): FlatCategoryStoreId => {
24
25
  const newId = randomId();
@@ -1,18 +1,77 @@
1
- import { useCopilotAction } from "./use-copilot-action";
2
- import { FrontendAction } from "../types/frontend-action";
3
- import { Parameter } from "@copilotkit/shared";
1
+ import React from "react";
2
+ import { ActionRenderProps, FrontendAction } from "../types/frontend-action";
3
+ import { Parameter, getZodParameters, MappedParameterTypes } from "@copilotkit/shared";
4
+ import { parseJson } from "@copilotkit/shared";
5
+ import { ToolCallStatus } from "@copilotkitnext/core";
6
+ import { type ReactFrontendTool, useFrontendTool as useFrontendToolVNext } from "@copilotkitnext/react";
4
7
 
5
- type UseToolCallArgs<T extends Parameter[] | [] = []> = {
8
+ type FrontendToolOptions<T extends Parameter[] | []> = ReactFrontendTool<MappedParameterTypes<T>>;
9
+ type FrontendToolRenderArgs<T extends Parameter[] | []> =
10
+ | {
11
+ name: string;
12
+ args: Partial<MappedParameterTypes<T>>;
13
+ status: ToolCallStatus.InProgress;
14
+ result: undefined;
15
+ }
16
+ | {
17
+ name: string;
18
+ args: MappedParameterTypes<T>;
19
+ status: ToolCallStatus.Executing;
20
+ result: undefined;
21
+ }
22
+ | {
23
+ name: string;
24
+ args: MappedParameterTypes<T>;
25
+ status: ToolCallStatus.Complete;
26
+ result: string;
27
+ };
28
+
29
+ export type UseFrontendToolArgs<T extends Parameter[] | [] = []> = {
6
30
  available?: "disabled" | "enabled";
7
31
  } & Pick<
8
32
  FrontendAction<T>,
9
33
  "name" | "description" | "parameters" | "handler" | "followUp" | "render"
10
34
  >;
11
35
 
12
- export function useFrontendTool<const T extends Parameter[] | [] = []>(
13
- tool: UseToolCallArgs<T>,
36
+ export function useFrontendTool<const T extends Parameter[] = []>(
37
+ tool: UseFrontendToolArgs<T>,
14
38
  dependencies?: any[],
15
39
  ) {
16
- // Use the existing useCopilotAction hook
17
- useCopilotAction<T>(tool, dependencies);
40
+ const { name, description, parameters, render, followUp } = tool;
41
+ const zodParameters = getZodParameters(parameters);
42
+
43
+ const normalizedRender: FrontendToolOptions<T>["render"] | undefined = (() => {
44
+ if (typeof render === "undefined") {
45
+ return undefined;
46
+ }
47
+
48
+ if (typeof render === "string") {
49
+ const staticRender = render;
50
+ return (() => React.createElement(React.Fragment, null, staticRender)) as FrontendToolOptions<T>["render"];
51
+ }
52
+
53
+ return ((args: FrontendToolRenderArgs<T>) => {
54
+ const renderArgs = {
55
+ ...args,
56
+ result: typeof args.result === "string" ? parseJson(args.result, args.result) : args.result,
57
+ } as ActionRenderProps<T>;
58
+
59
+ const rendered = render(renderArgs);
60
+
61
+ if (typeof rendered === "string") {
62
+ return React.createElement(React.Fragment, null, rendered);
63
+ }
64
+
65
+ return rendered ?? null;
66
+ }) as FrontendToolOptions<T>["render"];
67
+ })();
68
+
69
+ useFrontendToolVNext<MappedParameterTypes<T>>({
70
+ name,
71
+ description,
72
+ parameters: zodParameters,
73
+ handler: tool.handler,
74
+ followUp,
75
+ render: normalizedRender,
76
+ });
18
77
  }
@@ -1,24 +1,122 @@
1
- import { useCopilotAction } from "./use-copilot-action";
2
- import { FrontendAction } from "../types";
3
- import { Parameter } from "@copilotkit/shared";
1
+ import { ActionRenderProps, ActionRenderPropsWait, FrontendAction } from "../types";
2
+ import {
3
+ CopilotKitError,
4
+ CopilotKitErrorCode,
5
+ MappedParameterTypes,
6
+ Parameter,
7
+ getZodParameters,
8
+ parseJson,
9
+ } from "@copilotkit/shared";
10
+ import { useHumanInTheLoop as useHumanInTheLoopVNext } from "@copilotkitnext/react";
11
+ import { ToolCallStatus } from "@copilotkitnext/core";
12
+ import React, { ComponentType, FunctionComponent, useEffect, useRef } from "react";
4
13
 
5
- type UseToolCallArgs<T extends Parameter[] | [] = []> = {
14
+ type HumanInTheLoopOptions = Parameters<typeof useHumanInTheLoopVNext>[0];
15
+ type HumanInTheLoopRender = HumanInTheLoopOptions["render"];
16
+ type HumanInTheLoopRenderArgs = HumanInTheLoopRender extends (props: infer P) => any ? P : never;
17
+
18
+ export type UseHumanInTheLoopArgs<T extends Parameter[] | [] = []> = {
6
19
  available?: "disabled" | "enabled";
7
20
  render: FrontendAction<T>["renderAndWaitForResponse"];
21
+ followUp?: FrontendAction<T>["followUp"];
8
22
  } & Pick<FrontendAction<T>, "name" | "description" | "parameters">;
9
23
 
24
+ type HitlRendererArgs =
25
+ | {
26
+ name: string;
27
+ description: string;
28
+ args: Partial<Record<string, unknown>>;
29
+ status: ToolCallStatus.InProgress;
30
+ result: undefined;
31
+ respond: undefined;
32
+ }
33
+ | {
34
+ name: string;
35
+ description: string;
36
+ args: Record<string, unknown>;
37
+ status: ToolCallStatus.Executing;
38
+ result: undefined;
39
+ respond: (result: unknown) => Promise<void>;
40
+ }
41
+ | {
42
+ name: string;
43
+ description: string;
44
+ args: Record<string, unknown>;
45
+ status: ToolCallStatus.Complete;
46
+ result: string;
47
+ respond: undefined;
48
+ };
49
+ type HitlRenderer = FunctionComponent<HitlRendererArgs>;
50
+
10
51
  export function useHumanInTheLoop<const T extends Parameter[] | [] = []>(
11
- tool: UseToolCallArgs<T>,
52
+ tool: UseHumanInTheLoopArgs<T>,
12
53
  dependencies?: any[],
13
54
  ) {
14
55
  const { render, ...toolRest } = tool;
56
+ const { name, description, parameters, followUp } = toolRest;
57
+ const zodParameters = getZodParameters(parameters);
58
+ const renderRef = useRef<HitlRenderer | null>(null);
59
+
60
+ useEffect(() => {
61
+ renderRef.current = (args: HitlRendererArgs): React.ReactElement | null => {
62
+ if (typeof render === "string") {
63
+ return React.createElement(React.Fragment, null, render);
64
+ }
65
+
66
+ if (!render) {
67
+ return null;
68
+ }
69
+
70
+ const renderProps: ActionRenderPropsWait<T> = (() => {
71
+ const mappedArgs = args.args as unknown as MappedParameterTypes<T>;
72
+
73
+ switch (args.status) {
74
+ case ToolCallStatus.InProgress:
75
+ return {
76
+ args: mappedArgs,
77
+ respond: args.respond,
78
+ status: args.status,
79
+ handler: undefined,
80
+ };
81
+ case ToolCallStatus.Executing:
82
+ return {
83
+ args: mappedArgs,
84
+ respond: args.respond,
85
+ status: args.status,
86
+ handler: () => {},
87
+ };
88
+ case ToolCallStatus.Complete:
89
+ return {
90
+ args: mappedArgs,
91
+ respond: args.respond,
92
+ status: args.status,
93
+ result: args.result ? parseJson(args.result, args.result) : args.result,
94
+ handler: undefined,
95
+ };
96
+ default:
97
+ throw new CopilotKitError({
98
+ code: CopilotKitErrorCode.UNKNOWN,
99
+ message: `Invalid tool call status: ${(args as unknown as { status: string }).status}`,
100
+ });
101
+ }
102
+ })();
103
+
104
+ const rendered = render(renderProps);
105
+
106
+ if (typeof rendered === "string") {
107
+ return React.createElement(React.Fragment, null, rendered);
108
+ }
109
+
110
+ return rendered ?? null;
111
+ };
112
+ }, [render, ...(dependencies ?? [])]);
15
113
 
16
- useCopilotAction(
17
- {
18
- ...toolRest,
19
- available: tool.available === "disabled" ? tool.available : "remote",
20
- renderAndWaitForResponse: render,
21
- },
22
- dependencies,
23
- );
114
+ useHumanInTheLoopVNext({
115
+ name,
116
+ description,
117
+ followUp,
118
+ parameters: zodParameters,
119
+ render: ((args: HumanInTheLoopRenderArgs) =>
120
+ renderRef.current?.(args as HitlRendererArgs) ?? null) as HumanInTheLoopOptions["render"],
121
+ });
24
122
  }
@@ -1,6 +1,8 @@
1
1
  import { useCopilotContext } from "../context";
2
- import React, { useCallback } from "react";
3
- import { executeConditions } from "@copilotkit/shared";
2
+ import React, { useCallback, useEffect, useMemo } from "react";
3
+ import type { AbstractAgent, AgentSubscriber } from "@ag-ui/client";
4
+ import { MetaEventName } from "@copilotkit/runtime-client-gql";
5
+ import { dataToUUID, parseJson } from "@copilotkit/shared";
4
6
 
5
7
  type InterruptProps = {
6
8
  event: any;
@@ -17,52 +19,100 @@ const InterruptRenderer: React.FC<InterruptProps> = ({ event, result, render, re
17
19
  return render({ event, result, resolve });
18
20
  };
19
21
 
20
- export function useLangGraphInterruptRender(): string | React.ReactElement | null {
21
- const { langGraphInterruptAction, setLangGraphInterruptAction, agentSession, threadId } =
22
- useCopilotContext();
22
+ export function useLangGraphInterruptRender(
23
+ agent: AbstractAgent,
24
+ ): string | React.ReactElement | null {
25
+ const {
26
+ interruptActions,
27
+ agentSession,
28
+ threadId,
29
+ interruptEventQueue,
30
+ addInterruptEvent,
31
+ removeInterruptEvent,
32
+ } = useCopilotContext();
23
33
 
24
- const responseRef = React.useRef<string>();
25
- const resolveInterrupt = useCallback(
26
- (response: string) => {
27
- responseRef.current = response;
28
- // Use setTimeout to defer the state update to next tick
29
- setTimeout(() => {
30
- setLangGraphInterruptAction(threadId, { event: { response } });
31
- }, 0);
34
+ useEffect(() => {
35
+ if (!agent) return;
36
+ const subscriber: AgentSubscriber = {
37
+ onCustomEvent: ({ event }) => {
38
+ if (event.name === "on_interrupt") {
39
+ const eventData = {
40
+ name: MetaEventName.LangGraphInterruptEvent,
41
+ type: event.type,
42
+ value: parseJson(event.value, event.value),
43
+ };
44
+ const eventId = dataToUUID(JSON.stringify(eventData), "interruptEvents");
45
+ addInterruptEvent({
46
+ eventId,
47
+ threadId,
48
+ event: eventData,
49
+ });
50
+ }
51
+ },
52
+ };
53
+
54
+ const { unsubscribe } = agent.subscribe(subscriber);
55
+ return () => {
56
+ unsubscribe();
57
+ };
58
+ // eslint-disable-next-line react-hooks/exhaustive-deps
59
+ }, [agent, threadId]);
60
+
61
+ const handleResolve = useCallback(
62
+ (eventId: string, response?: string) => {
63
+ agent?.runAgent({
64
+ forwardedProps: {
65
+ command: {
66
+ resume: response,
67
+ },
68
+ },
69
+ });
70
+ removeInterruptEvent(threadId, eventId);
32
71
  },
33
- [setLangGraphInterruptAction, threadId],
72
+ // eslint-disable-next-line react-hooks/exhaustive-deps
73
+ [agent, threadId],
34
74
  );
35
75
 
36
- if (
37
- !langGraphInterruptAction ||
38
- !langGraphInterruptAction.event ||
39
- !langGraphInterruptAction.render
40
- )
41
- return null;
76
+ return useMemo(() => {
77
+ // Get the queue for this thread and find the first unresponded event
78
+ const eventQueue = interruptEventQueue[threadId] || [];
79
+ const currentQueuedEvent = eventQueue.find((qe) => !qe.event.response);
80
+
81
+ if (!currentQueuedEvent) return null;
82
+
83
+ // Find the first matching action from all registered actions
84
+ const allActions = Object.values(interruptActions);
85
+ const matchingAction = allActions.find((action) => {
86
+ if (!action.enabled) return true; // No filter = match all
87
+ return action.enabled({
88
+ eventValue: currentQueuedEvent.event.value,
89
+ agentMetadata: agentSession,
90
+ });
91
+ });
92
+
93
+ if (!matchingAction) return null;
42
94
 
43
- const { render, handler, event, enabled } = langGraphInterruptAction;
95
+ const { render, handler } = matchingAction;
44
96
 
45
- const conditionsMet =
46
- !agentSession || !enabled
47
- ? true
48
- : enabled({ eventValue: event.value, agentMetadata: agentSession });
97
+ const resolveInterrupt = (response: string) => {
98
+ handleResolve(currentQueuedEvent.eventId, response);
99
+ };
49
100
 
50
- if (!conditionsMet) {
51
- return null;
52
- }
101
+ let result = null;
102
+ if (handler) {
103
+ result = handler({
104
+ event: currentQueuedEvent.event,
105
+ resolve: resolveInterrupt,
106
+ });
107
+ }
53
108
 
54
- let result = null;
55
- if (handler) {
56
- result = handler({
57
- event,
109
+ if (!render) return null;
110
+
111
+ return React.createElement(InterruptRenderer, {
112
+ event: currentQueuedEvent.event,
113
+ result,
114
+ render,
58
115
  resolve: resolveInterrupt,
59
116
  });
60
- }
61
-
62
- return React.createElement(InterruptRenderer, {
63
- event,
64
- result,
65
- render,
66
- resolve: resolveInterrupt,
67
- });
117
+ }, [interruptActions, interruptEventQueue, threadId, agentSession, handleResolve]);
68
118
  }
@@ -1,7 +1,7 @@
1
1
  import { useContext, useEffect, useMemo } from "react";
2
2
  import { CopilotContext } from "../context/copilot-context";
3
3
  import { LangGraphInterruptRender } from "../types/interrupt-action";
4
- import { useCopilotChat } from "./use-copilot-chat_internal";
4
+ import { useCopilotChatInternal } from "./use-copilot-chat_internal";
5
5
  import { useToast } from "../components/toast/toast-provider";
6
6
  import { dataToUUID } from "@copilotkit/shared";
7
7
 
@@ -9,58 +9,29 @@ export function useLangGraphInterrupt<TEventValue = any>(
9
9
  action: Omit<LangGraphInterruptRender<TEventValue>, "id">,
10
10
  dependencies?: any[],
11
11
  ) {
12
- const {
13
- setLangGraphInterruptAction,
14
- removeLangGraphInterruptAction,
15
- langGraphInterruptAction,
16
- threadId,
17
- } = useContext(CopilotContext);
18
- const { runChatCompletion } = useCopilotChat();
12
+ const { setInterruptAction, removeInterruptAction, interruptActions, threadId } =
13
+ useContext(CopilotContext);
19
14
  const { addToast } = useToast();
20
15
 
21
16
  const actionId = dataToUUID(JSON.stringify(action), "lgAction");
22
- // We only consider action to be defined once the ID is there
23
- const hasAction = useMemo(
24
- () => Boolean(langGraphInterruptAction?.id),
25
- [langGraphInterruptAction],
26
- );
27
-
28
- const isCurrentAction = useMemo(
29
- () => langGraphInterruptAction?.id && langGraphInterruptAction?.id === actionId,
30
- [langGraphInterruptAction],
31
- );
32
-
33
- // Run chat completion to submit a response event. Only if it's the current action
34
- useEffect(() => {
35
- if (hasAction && isCurrentAction && langGraphInterruptAction?.event?.response) {
36
- runChatCompletion();
37
- }
38
- }, [langGraphInterruptAction?.event?.response, runChatCompletion, hasAction, isCurrentAction]);
39
17
 
40
18
  useEffect(() => {
41
19
  if (!action) return;
42
- // An action was already set, with no conditions and it's not the action we're using right now.
43
- // Show a warning, as this action will not be executed
44
- if (hasAction && !isCurrentAction && !action.enabled) {
45
- addToast({
46
- type: "warning",
47
- message: "An action is already registered for the interrupt event",
48
- });
49
- return;
50
- }
51
20
 
52
- if (hasAction && isCurrentAction) {
53
- return;
54
- }
21
+ // if (!action.enabled) {
22
+ // TODO: if there are any other actions registered, we need to warn the user that a current action without "enabled" might render for everything
23
+ // addToast({
24
+ // type: "warning",
25
+ // message: "An action is already registered for the interrupt event",
26
+ // });
27
+ // return;
28
+ // }
29
+
30
+ setInterruptAction(threadId, { ...action, id: actionId });
55
31
 
56
- setLangGraphInterruptAction(threadId, { ...action, id: actionId });
57
- }, [
58
- action,
59
- hasAction,
60
- isCurrentAction,
61
- setLangGraphInterruptAction,
62
- removeLangGraphInterruptAction,
63
- threadId,
64
- ...(dependencies || []),
65
- ]);
32
+ // Cleanup: remove action on unmount
33
+ return () => {
34
+ removeInterruptAction(actionId);
35
+ };
36
+ }, [setInterruptAction, removeInterruptAction, threadId, actionId, ...(dependencies || [])]);
66
37
  }
@@ -0,0 +1,30 @@
1
+ import { useRenderToolCall } from "@copilotkitnext/react";
2
+ import { AIMessage, Message, ToolResult } from "@copilotkit/shared";
3
+ import React, { useCallback } from "react";
4
+
5
+ export function useLazyToolRenderer(): (
6
+ message?: AIMessage,
7
+ messages?: Message[],
8
+ ) => null | (() => ReturnType<ReturnType<typeof useRenderToolCall>> | null) {
9
+ const renderToolCall = useRenderToolCall();
10
+
11
+ return useCallback(
12
+ (message?: AIMessage, messages?: Message[]) => {
13
+ if (!message?.toolCalls?.length) return null;
14
+
15
+ const toolCall = message.toolCalls[0];
16
+ if (!toolCall) return null;
17
+
18
+ const toolMessage = messages?.find(
19
+ (m) => m.role === "tool" && m.toolCallId === toolCall.id,
20
+ ) as ToolResult;
21
+
22
+ return () =>
23
+ renderToolCall({
24
+ toolCall,
25
+ toolMessage,
26
+ });
27
+ },
28
+ [renderToolCall],
29
+ );
30
+ }
@@ -15,7 +15,7 @@ export function useMakeCopilotDocumentReadable(
15
15
  dependencies: any[] = [],
16
16
  ): string | undefined {
17
17
  const { addDocumentContext, removeDocumentContext } = useCopilotContext();
18
- const idRef = useRef<string>();
18
+ const idRef = useRef<string>(undefined!);
19
19
 
20
20
  useEffect(() => {
21
21
  const id = addDocumentContext(document, categories);
@@ -1,20 +1,80 @@
1
- import { useCopilotAction } from "./use-copilot-action";
2
- import { FrontendAction, FrontendActionAvailability } from "../types";
3
- import { Parameter } from "@copilotkit/shared";
1
+ import {
2
+ ActionRenderProps,
3
+ ActionRenderPropsNoArgs,
4
+ ActionRenderPropsWait,
5
+ FrontendAction,
6
+ } from "../types";
7
+ import { Parameter, getZodParameters } from "@copilotkit/shared";
8
+ import React, { useEffect, useRef } from "react";
9
+ import { defineToolCallRenderer, useCopilotKit } from "@copilotkitnext/react";
10
+ import { parseJson } from "@copilotkit/shared";
4
11
 
5
- type UseToolCallArgs<T extends Parameter[] | [] = []> = {
12
+ type ToolCallRendererDefinition = Parameters<typeof defineToolCallRenderer>[0];
13
+
14
+ export type UseRenderToolCallArgs<T extends Parameter[] | [] = []> = Pick<
15
+ FrontendAction<T>,
16
+ "name" | "description" | "parameters"
17
+ > & {
6
18
  available?: "disabled" | "enabled";
7
- } & Pick<FrontendAction<T>, "name" | "description" | "parameters" | "render">;
19
+ render: T extends []
20
+ ? (props: ActionRenderPropsNoArgs<T>) => React.ReactElement
21
+ : (props: ActionRenderProps<T>) => React.ReactElement;
22
+ };
8
23
 
9
24
  export function useRenderToolCall<const T extends Parameter[] | [] = []>(
10
- tool: UseToolCallArgs<T>,
25
+ tool: UseRenderToolCallArgs<T>,
11
26
  dependencies?: any[],
12
27
  ) {
13
- useCopilotAction<T>(
14
- {
15
- ...tool,
16
- available: tool.available === "disabled" ? tool.available : "frontend",
17
- },
18
- dependencies,
19
- );
28
+ const { copilotkit } = useCopilotKit();
29
+
30
+ // Track whether we've already added this renderer to avoid duplicates
31
+ const hasAddedRef = useRef(false);
32
+
33
+ useEffect(() => {
34
+ const { name, parameters, render } = tool;
35
+ const zodParameters = getZodParameters(parameters);
36
+
37
+ const renderToolCall =
38
+ name === "*"
39
+ ? defineToolCallRenderer({
40
+ name: "*",
41
+ render: ((args) => {
42
+ return render({
43
+ ...args,
44
+ result: args.result ? parseJson(args.result, args.result) : args.result,
45
+ });
46
+ }) as ToolCallRendererDefinition["render"],
47
+ })
48
+ : defineToolCallRenderer({
49
+ name,
50
+ args: zodParameters,
51
+ render: ((args) => {
52
+ return render({
53
+ ...args,
54
+ result: args.result ? parseJson(args.result, args.result) : args.result,
55
+ });
56
+ }) as ToolCallRendererDefinition["render"],
57
+ });
58
+
59
+ // Remove any existing renderer with the same name
60
+ const existingIndex = copilotkit.renderToolCalls.findIndex((r) => r.name === name);
61
+ if (existingIndex !== -1) {
62
+ copilotkit.renderToolCalls.splice(existingIndex, 1);
63
+ }
64
+
65
+ // Add the new renderer
66
+ copilotkit.renderToolCalls.push(renderToolCall);
67
+ hasAddedRef.current = true;
68
+
69
+ // Cleanup: remove this renderer when the component unmounts or tool changes
70
+ return () => {
71
+ if (hasAddedRef.current) {
72
+ const index = copilotkit.renderToolCalls.findIndex((r) => r.name === name);
73
+ if (index !== -1) {
74
+ copilotkit.renderToolCalls.splice(index, 1);
75
+ }
76
+ hasAddedRef.current = false;
77
+ }
78
+ };
79
+ }, [tool, ...(dependencies ?? [])]);
20
80
  }
@@ -14,3 +14,4 @@ export type {
14
14
 
15
15
  export type { CopilotChatSuggestionConfiguration } from "./chat-suggestion-configuration";
16
16
  export * from "./crew";
17
+ export * from "./interrupt-action";