@copilotkit/react-core 1.51.4-next.7 → 1.51.4

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 (301) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +18 -12
  3. package/dist/{chunk-6ESSSQ7Q.mjs → chunk-2RSAYTXH.mjs} +6 -3
  4. package/dist/chunk-2RSAYTXH.mjs.map +1 -0
  5. package/dist/chunk-3LZZ4RVM.mjs +37 -0
  6. package/dist/{chunk-ABWT4DRT.mjs.map → chunk-3LZZ4RVM.mjs.map} +1 -1
  7. package/dist/{chunk-QDES5PDW.mjs → chunk-4ZQYMC5F.mjs} +2 -2
  8. package/dist/{chunk-QDES5PDW.mjs.map → chunk-4ZQYMC5F.mjs.map} +1 -1
  9. package/dist/{chunk-VKNLTZJE.mjs → chunk-6ABVYB2U.mjs} +28 -19
  10. package/dist/chunk-6ABVYB2U.mjs.map +1 -0
  11. package/dist/{chunk-6PUNP7CD.mjs → chunk-6AWG5FWL.mjs} +2 -2
  12. package/dist/chunk-6AWG5FWL.mjs.map +1 -0
  13. package/dist/{chunk-C3YJYDK4.mjs → chunk-7GIBHX6X.mjs} +8 -2
  14. package/dist/chunk-7GIBHX6X.mjs.map +1 -0
  15. package/dist/{chunk-PIF5KJYI.mjs → chunk-7PJKPWMD.mjs} +15 -6
  16. package/dist/chunk-7PJKPWMD.mjs.map +1 -0
  17. package/dist/{chunk-7JTI6ZL4.mjs → chunk-7U3DNFBF.mjs} +6 -3
  18. package/dist/chunk-7U3DNFBF.mjs.map +1 -0
  19. package/dist/{chunk-KNJHRVKW.mjs → chunk-AAGMWZCN.mjs} +45 -14
  20. package/dist/chunk-AAGMWZCN.mjs.map +1 -0
  21. package/dist/{chunk-AFNWX62Q.mjs → chunk-C7HSVDHD.mjs} +10 -4
  22. package/dist/chunk-C7HSVDHD.mjs.map +1 -0
  23. package/dist/{chunk-ZYTXB6HH.mjs → chunk-CZT7JUIM.mjs} +4 -2
  24. package/dist/chunk-CZT7JUIM.mjs.map +1 -0
  25. package/dist/{chunk-BKMJ4LC7.mjs → chunk-G7SUZGGB.mjs} +19 -12
  26. package/dist/chunk-G7SUZGGB.mjs.map +1 -0
  27. package/dist/{chunk-7IBF6RBW.mjs → chunk-GY3FQICF.mjs} +2 -2
  28. package/dist/{chunk-QD7EID4N.mjs → chunk-IHMMKEFG.mjs} +16 -11
  29. package/dist/chunk-IHMMKEFG.mjs.map +1 -0
  30. package/dist/{chunk-YYN33GSG.mjs → chunk-K5OXUXCG.mjs} +14 -11
  31. package/dist/chunk-K5OXUXCG.mjs.map +1 -0
  32. package/dist/{chunk-6ZLPNY7X.mjs → chunk-L7GPCF2V.mjs} +6 -2
  33. package/dist/{chunk-6ZLPNY7X.mjs.map → chunk-L7GPCF2V.mjs.map} +1 -1
  34. package/dist/{chunk-LHERIF3L.mjs → chunk-LD34IXVT.mjs} +8 -5
  35. package/dist/chunk-LD34IXVT.mjs.map +1 -0
  36. package/dist/{chunk-7DTB7S5V.mjs → chunk-LNGBARXE.mjs} +5 -2
  37. package/dist/chunk-LNGBARXE.mjs.map +1 -0
  38. package/dist/{chunk-DQXCQWSG.mjs → chunk-LRPWSPXG.mjs} +85 -50
  39. package/dist/chunk-LRPWSPXG.mjs.map +1 -0
  40. package/dist/{chunk-NBK4KBLX.mjs → chunk-MBJ7OLYI.mjs} +9 -5
  41. package/dist/chunk-MBJ7OLYI.mjs.map +1 -0
  42. package/dist/{chunk-MA3CUMCY.mjs → chunk-P6ZPE4XJ.mjs} +3 -3
  43. package/dist/{chunk-MA3CUMCY.mjs.map → chunk-P6ZPE4XJ.mjs.map} +1 -1
  44. package/dist/{chunk-77IVITG3.mjs → chunk-QXZTCGF4.mjs} +9 -4
  45. package/dist/chunk-QXZTCGF4.mjs.map +1 -0
  46. package/dist/{chunk-VP43SLSZ.mjs → chunk-R2DP4APC.mjs} +10 -5
  47. package/dist/chunk-R2DP4APC.mjs.map +1 -0
  48. package/dist/{chunk-RKTVJRK7.mjs → chunk-R7BV32X4.mjs} +5 -2
  49. package/dist/chunk-R7BV32X4.mjs.map +1 -0
  50. package/dist/{chunk-YCG6SNAU.mjs → chunk-SBRCWA4S.mjs} +186 -32
  51. package/dist/chunk-SBRCWA4S.mjs.map +1 -0
  52. package/dist/{chunk-LMHB2D4J.mjs → chunk-SK2XMJUD.mjs} +13 -4
  53. package/dist/chunk-SK2XMJUD.mjs.map +1 -0
  54. package/dist/{chunk-HE22TZMF.mjs → chunk-SLM6CLAH.mjs} +16 -7
  55. package/dist/chunk-SLM6CLAH.mjs.map +1 -0
  56. package/dist/{chunk-XDFVCQD3.mjs → chunk-SYGQHN3H.mjs} +1 -1
  57. package/dist/{chunk-XDFVCQD3.mjs.map → chunk-SYGQHN3H.mjs.map} +1 -1
  58. package/dist/{chunk-4RRMC7L2.mjs → chunk-SYMT73HM.mjs} +16 -5
  59. package/dist/chunk-SYMT73HM.mjs.map +1 -0
  60. package/dist/{chunk-SRJT5VVY.mjs → chunk-TFZXOEY4.mjs} +6 -4
  61. package/dist/{chunk-SRJT5VVY.mjs.map → chunk-TFZXOEY4.mjs.map} +1 -1
  62. package/dist/{chunk-4CEQJ2X6.mjs → chunk-TPN7WC53.mjs} +4 -2
  63. package/dist/{chunk-4CEQJ2X6.mjs.map → chunk-TPN7WC53.mjs.map} +1 -1
  64. package/dist/{chunk-VGL3DGUW.mjs → chunk-UA23VX5J.mjs} +4 -2
  65. package/dist/chunk-UA23VX5J.mjs.map +1 -0
  66. package/dist/{chunk-VV56AVPB.mjs → chunk-V42VL2JR.mjs} +15 -4
  67. package/dist/chunk-V42VL2JR.mjs.map +1 -0
  68. package/dist/{chunk-RBGVEVWY.mjs → chunk-VZ4NSOFQ.mjs} +4 -4
  69. package/dist/chunk-VZ4NSOFQ.mjs.map +1 -0
  70. package/dist/{chunk-WF65O6HX.mjs → chunk-WRALJIW5.mjs} +18 -5
  71. package/dist/chunk-WRALJIW5.mjs.map +1 -0
  72. package/dist/{chunk-PMAFHQ7P.mjs → chunk-WV2EA7SX.mjs} +1 -1
  73. package/dist/chunk-WV2EA7SX.mjs.map +1 -0
  74. package/dist/{chunk-EFL5OBKN.mjs → chunk-ZP2IMXFY.mjs} +10 -4
  75. package/dist/chunk-ZP2IMXFY.mjs.map +1 -0
  76. package/dist/components/CopilotListeners.js +11 -2
  77. package/dist/components/CopilotListeners.js.map +1 -1
  78. package/dist/components/CopilotListeners.mjs +2 -2
  79. package/dist/components/copilot-provider/copilot-messages.d.ts +1 -1
  80. package/dist/components/copilot-provider/copilot-messages.js +22 -7
  81. package/dist/components/copilot-provider/copilot-messages.js.map +1 -1
  82. package/dist/components/copilot-provider/copilot-messages.mjs +3 -3
  83. package/dist/components/copilot-provider/copilotkit-props.js.map +1 -1
  84. package/dist/components/copilot-provider/copilotkit.js +179 -84
  85. package/dist/components/copilot-provider/copilotkit.js.map +1 -1
  86. package/dist/components/copilot-provider/copilotkit.mjs +16 -16
  87. package/dist/components/copilot-provider/index.js +179 -84
  88. package/dist/components/copilot-provider/index.js.map +1 -1
  89. package/dist/components/copilot-provider/index.mjs +16 -16
  90. package/dist/components/dev-console/console-trigger.d.ts +1 -1
  91. package/dist/components/dev-console/console-trigger.js +227 -42
  92. package/dist/components/dev-console/console-trigger.js.map +1 -1
  93. package/dist/components/dev-console/console-trigger.mjs +24 -8
  94. package/dist/components/dev-console/console-trigger.mjs.map +1 -1
  95. package/dist/components/dev-console/developer-console-modal.d.ts +1 -1
  96. package/dist/components/dev-console/developer-console-modal.js +206 -37
  97. package/dist/components/dev-console/developer-console-modal.js.map +1 -1
  98. package/dist/components/dev-console/developer-console-modal.mjs +3 -3
  99. package/dist/components/dev-console/icons.js +14 -5
  100. package/dist/components/dev-console/icons.js.map +1 -1
  101. package/dist/components/dev-console/icons.mjs +1 -1
  102. package/dist/components/error-boundary/error-boundary.d.ts +1 -1
  103. package/dist/components/error-boundary/error-boundary.js +9 -2
  104. package/dist/components/error-boundary/error-boundary.js.map +1 -1
  105. package/dist/components/error-boundary/error-boundary.mjs +5 -5
  106. package/dist/components/error-boundary/error-utils.js.map +1 -1
  107. package/dist/components/error-boundary/error-utils.mjs +2 -2
  108. package/dist/components/index.js +179 -84
  109. package/dist/components/index.js.map +1 -1
  110. package/dist/components/index.mjs +16 -16
  111. package/dist/components/toast/toast-provider.js +9 -3
  112. package/dist/components/toast/toast-provider.js.map +1 -1
  113. package/dist/components/toast/toast-provider.mjs +1 -1
  114. package/dist/components/usage-banner.js +5 -1
  115. package/dist/components/usage-banner.js.map +1 -1
  116. package/dist/components/usage-banner.mjs +1 -1
  117. package/dist/context/coagent-state-renders-context.d.ts +1 -1
  118. package/dist/context/coagent-state-renders-context.js +15 -10
  119. package/dist/context/coagent-state-renders-context.js.map +1 -1
  120. package/dist/context/coagent-state-renders-context.mjs +1 -1
  121. package/dist/context/copilot-context.js +9 -3
  122. package/dist/context/copilot-context.js.map +1 -1
  123. package/dist/context/copilot-context.mjs +1 -1
  124. package/dist/context/index.js +31 -15
  125. package/dist/context/index.js.map +1 -1
  126. package/dist/context/index.mjs +3 -3
  127. package/dist/context/threads-context.d.ts +1 -1
  128. package/dist/context/threads-context.js +7 -2
  129. package/dist/context/threads-context.js.map +1 -1
  130. package/dist/context/threads-context.mjs +1 -1
  131. package/dist/hooks/index.js +162 -61
  132. package/dist/hooks/index.js.map +1 -1
  133. package/dist/hooks/index.mjs +25 -25
  134. package/dist/hooks/use-coagent-state-render-bridge.helpers.js +7 -1
  135. package/dist/hooks/use-coagent-state-render-bridge.helpers.js.map +1 -1
  136. package/dist/hooks/use-coagent-state-render-bridge.helpers.mjs +1 -1
  137. package/dist/hooks/use-coagent-state-render-bridge.js +31 -15
  138. package/dist/hooks/use-coagent-state-render-bridge.js.map +1 -1
  139. package/dist/hooks/use-coagent-state-render-bridge.mjs +6 -6
  140. package/dist/hooks/use-coagent-state-render-registry.js +14 -3
  141. package/dist/hooks/use-coagent-state-render-registry.js.map +1 -1
  142. package/dist/hooks/use-coagent-state-render-registry.mjs +2 -2
  143. package/dist/hooks/use-coagent-state-render.js +34 -21
  144. package/dist/hooks/use-coagent-state-render.js.map +1 -1
  145. package/dist/hooks/use-coagent-state-render.mjs +4 -4
  146. package/dist/hooks/use-coagent.js +3 -1
  147. package/dist/hooks/use-coagent.js.map +1 -1
  148. package/dist/hooks/use-coagent.mjs +1 -1
  149. package/dist/hooks/use-configure-chat-suggestions.js.map +1 -1
  150. package/dist/hooks/use-configure-chat-suggestions.mjs.map +1 -1
  151. package/dist/hooks/use-copilot-action.js +13 -9
  152. package/dist/hooks/use-copilot-action.js.map +1 -1
  153. package/dist/hooks/use-copilot-action.mjs +4 -4
  154. package/dist/hooks/use-copilot-additional-instructions.d.ts +1 -1
  155. package/dist/hooks/use-copilot-additional-instructions.js +26 -7
  156. package/dist/hooks/use-copilot-additional-instructions.js.map +1 -1
  157. package/dist/hooks/use-copilot-additional-instructions.mjs +2 -2
  158. package/dist/hooks/use-copilot-authenticated-action.js +25 -13
  159. package/dist/hooks/use-copilot-authenticated-action.js.map +1 -1
  160. package/dist/hooks/use-copilot-authenticated-action.mjs +6 -6
  161. package/dist/hooks/use-copilot-chat-headless_c.js +81 -27
  162. package/dist/hooks/use-copilot-chat-headless_c.js.map +1 -1
  163. package/dist/hooks/use-copilot-chat-headless_c.mjs +11 -11
  164. package/dist/hooks/use-copilot-chat-suggestions.js.map +1 -1
  165. package/dist/hooks/use-copilot-chat-suggestions.mjs +1 -1
  166. package/dist/hooks/use-copilot-chat.js +81 -27
  167. package/dist/hooks/use-copilot-chat.js.map +1 -1
  168. package/dist/hooks/use-copilot-chat.mjs +11 -11
  169. package/dist/hooks/use-copilot-chat_internal.js +81 -27
  170. package/dist/hooks/use-copilot-chat_internal.js.map +1 -1
  171. package/dist/hooks/use-copilot-chat_internal.mjs +10 -10
  172. package/dist/hooks/use-copilot-runtime-client.js +4 -1
  173. package/dist/hooks/use-copilot-runtime-client.js.map +1 -1
  174. package/dist/hooks/use-copilot-runtime-client.mjs +2 -2
  175. package/dist/hooks/use-default-tool.js +17 -10
  176. package/dist/hooks/use-default-tool.js.map +1 -1
  177. package/dist/hooks/use-default-tool.mjs +5 -5
  178. package/dist/hooks/use-flat-category-store.js +13 -10
  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.js.map +1 -1
  182. package/dist/hooks/use-frontend-tool.mjs +1 -1
  183. package/dist/hooks/use-human-in-the-loop.js.map +1 -1
  184. package/dist/hooks/use-human-in-the-loop.mjs +1 -1
  185. package/dist/hooks/use-langgraph-interrupt-render.js +22 -5
  186. package/dist/hooks/use-langgraph-interrupt-render.js.map +1 -1
  187. package/dist/hooks/use-langgraph-interrupt-render.mjs +4 -4
  188. package/dist/hooks/use-langgraph-interrupt.js +19 -4
  189. package/dist/hooks/use-langgraph-interrupt.js.map +1 -1
  190. package/dist/hooks/use-langgraph-interrupt.mjs +3 -3
  191. package/dist/hooks/use-make-copilot-document-readable.js +9 -3
  192. package/dist/hooks/use-make-copilot-document-readable.js.map +1 -1
  193. package/dist/hooks/use-make-copilot-document-readable.mjs +2 -2
  194. package/dist/hooks/use-render-tool-call.d.ts +1 -1
  195. package/dist/hooks/use-render-tool-call.js +13 -9
  196. package/dist/hooks/use-render-tool-call.js.map +1 -1
  197. package/dist/hooks/use-render-tool-call.mjs +1 -1
  198. package/dist/hooks/use-tree.js +4 -1
  199. package/dist/hooks/use-tree.js.map +1 -1
  200. package/dist/hooks/use-tree.mjs +1 -1
  201. package/dist/index.js +311 -130
  202. package/dist/index.js.map +1 -1
  203. package/dist/index.mjs +35 -35
  204. package/dist/index.umd.js +1 -1
  205. package/dist/index.umd.js.map +1 -1
  206. package/dist/lib/copilot-task.js +10 -3
  207. package/dist/lib/copilot-task.js.map +1 -1
  208. package/dist/lib/copilot-task.mjs +18 -18
  209. package/dist/lib/index.js +10 -3
  210. package/dist/lib/index.js.map +1 -1
  211. package/dist/lib/index.mjs +18 -18
  212. package/dist/lib/status-checker.js.map +1 -1
  213. package/dist/lib/status-checker.mjs +1 -1
  214. package/dist/types/coagent-action.js.map +1 -1
  215. package/dist/types/frontend-action.js +3 -1
  216. package/dist/types/frontend-action.js.map +1 -1
  217. package/dist/types/frontend-action.mjs +1 -1
  218. package/dist/types/interrupt-action.js.map +1 -1
  219. package/dist/v2/index.umd.js.map +1 -1
  220. package/jest.config.js +1 -0
  221. package/package.json +7 -8
  222. package/src/__mocks__/analytics-node.js +9 -0
  223. package/src/components/CopilotListeners.tsx +21 -5
  224. package/src/components/copilot-provider/__tests__/copilotkit-error.test.tsx +3 -1
  225. package/src/components/copilot-provider/copilot-messages.tsx +36 -11
  226. package/src/components/copilot-provider/copilotkit-props.tsx +4 -1
  227. package/src/components/copilot-provider/copilotkit.tsx +116 -50
  228. package/src/components/dev-console/console-trigger.tsx +39 -10
  229. package/src/components/dev-console/developer-console-modal.tsx +207 -57
  230. package/src/components/dev-console/icons.tsx +6 -1
  231. package/src/components/error-boundary/error-boundary.tsx +10 -2
  232. package/src/components/error-boundary/error-utils.tsx +8 -3
  233. package/src/components/toast/toast-provider.tsx +16 -6
  234. package/src/components/usage-banner.tsx +9 -2
  235. package/src/context/coagent-state-renders-context.tsx +24 -12
  236. package/src/context/copilot-context.tsx +48 -15
  237. package/src/context/index.ts +8 -2
  238. package/src/context/threads-context.tsx +14 -3
  239. package/src/hooks/__tests__/use-coagent-state-render-bridge.helpers.test.ts +11 -4
  240. package/src/hooks/__tests__/use-coagent-state-render.e2e.test.tsx +175 -47
  241. package/src/hooks/__tests__/use-coagent-state-render.test.tsx +31 -10
  242. package/src/hooks/__tests__/use-frontend-tool-remount.e2e.test.tsx +10 -2
  243. package/src/hooks/use-coagent-state-render-bridge.helpers.ts +49 -16
  244. package/src/hooks/use-coagent-state-render-bridge.tsx +30 -13
  245. package/src/hooks/use-coagent-state-render-registry.ts +36 -21
  246. package/src/hooks/use-coagent-state-render.ts +30 -19
  247. package/src/hooks/use-coagent.ts +15 -4
  248. package/src/hooks/use-configure-chat-suggestions.tsx +14 -4
  249. package/src/hooks/use-copilot-action.ts +12 -3
  250. package/src/hooks/use-copilot-additional-instructions.ts +17 -4
  251. package/src/hooks/use-copilot-authenticated-action.ts +4 -1
  252. package/src/hooks/use-copilot-chat-headless_c.ts +8 -2
  253. package/src/hooks/use-copilot-chat-suggestions.tsx +14 -4
  254. package/src/hooks/use-copilot-chat.ts +3 -1
  255. package/src/hooks/use-copilot-chat_internal.ts +72 -19
  256. package/src/hooks/use-copilot-runtime-client.ts +20 -6
  257. package/src/hooks/use-default-tool.ts +8 -2
  258. package/src/hooks/use-flat-category-store.ts +15 -11
  259. package/src/hooks/use-frontend-tool.ts +35 -25
  260. package/src/hooks/use-human-in-the-loop.ts +21 -5
  261. package/src/hooks/use-langgraph-interrupt-render.ts +13 -2
  262. package/src/hooks/use-langgraph-interrupt.ts +13 -3
  263. package/src/hooks/use-render-tool-call.ts +20 -11
  264. package/src/hooks/use-tree.ts +20 -5
  265. package/src/lib/copilot-task.ts +20 -6
  266. package/src/lib/status-checker.ts +4 -1
  267. package/src/types/coagent-action.ts +6 -2
  268. package/src/types/frontend-action.ts +16 -5
  269. package/src/types/interrupt-action.ts +15 -5
  270. package/tsconfig.json +1 -1
  271. package/dist/chunk-4RRMC7L2.mjs.map +0 -1
  272. package/dist/chunk-6ESSSQ7Q.mjs.map +0 -1
  273. package/dist/chunk-6PUNP7CD.mjs.map +0 -1
  274. package/dist/chunk-77IVITG3.mjs.map +0 -1
  275. package/dist/chunk-7DTB7S5V.mjs.map +0 -1
  276. package/dist/chunk-7JTI6ZL4.mjs.map +0 -1
  277. package/dist/chunk-ABWT4DRT.mjs +0 -24
  278. package/dist/chunk-AFNWX62Q.mjs.map +0 -1
  279. package/dist/chunk-BKMJ4LC7.mjs.map +0 -1
  280. package/dist/chunk-C3YJYDK4.mjs.map +0 -1
  281. package/dist/chunk-DQXCQWSG.mjs.map +0 -1
  282. package/dist/chunk-EFL5OBKN.mjs.map +0 -1
  283. package/dist/chunk-HE22TZMF.mjs.map +0 -1
  284. package/dist/chunk-KNJHRVKW.mjs.map +0 -1
  285. package/dist/chunk-LHERIF3L.mjs.map +0 -1
  286. package/dist/chunk-LMHB2D4J.mjs.map +0 -1
  287. package/dist/chunk-NBK4KBLX.mjs.map +0 -1
  288. package/dist/chunk-PIF5KJYI.mjs.map +0 -1
  289. package/dist/chunk-PMAFHQ7P.mjs.map +0 -1
  290. package/dist/chunk-QD7EID4N.mjs.map +0 -1
  291. package/dist/chunk-RBGVEVWY.mjs.map +0 -1
  292. package/dist/chunk-RKTVJRK7.mjs.map +0 -1
  293. package/dist/chunk-VGL3DGUW.mjs.map +0 -1
  294. package/dist/chunk-VKNLTZJE.mjs.map +0 -1
  295. package/dist/chunk-VP43SLSZ.mjs.map +0 -1
  296. package/dist/chunk-VV56AVPB.mjs.map +0 -1
  297. package/dist/chunk-WF65O6HX.mjs.map +0 -1
  298. package/dist/chunk-YCG6SNAU.mjs.map +0 -1
  299. package/dist/chunk-YYN33GSG.mjs.map +0 -1
  300. package/dist/chunk-ZYTXB6HH.mjs.map +0 -1
  301. /package/dist/{chunk-7IBF6RBW.mjs.map → chunk-GY3FQICF.mjs.map} +0 -0
@@ -1,9 +1,19 @@
1
- import { useRef, useEffect, useCallback, useMemo, useState, createElement } from "react";
1
+ import {
2
+ useRef,
3
+ useEffect,
4
+ useCallback,
5
+ useMemo,
6
+ useState,
7
+ createElement,
8
+ } from "react";
2
9
  import { useCopilotContext } from "../context/copilot-context";
3
10
  import { SystemMessageFunction } from "../types";
4
11
  import { useAsyncCallback } from "../components/error-boundary/error-utils";
5
12
  import { Message } from "@copilotkit/shared";
6
- import { gqlToAGUI, Message as DeprecatedGqlMessage } from "@copilotkit/runtime-client-gql";
13
+ import {
14
+ gqlToAGUI,
15
+ Message as DeprecatedGqlMessage,
16
+ } from "@copilotkit/runtime-client-gql";
7
17
  import { useLangGraphInterruptRender } from "./use-langgraph-interrupt-render";
8
18
  import {
9
19
  useAgent,
@@ -27,7 +37,10 @@ import {
27
37
  * `manual` - Suggestions are controlled programmatically.
28
38
  * `SuggestionItem[]` - Static suggestions array.
29
39
  */
30
- export type ChatSuggestions = "auto" | "manual" | Omit<Suggestion, "isLoading">[];
40
+ export type ChatSuggestions =
41
+ | "auto"
42
+ | "manual"
43
+ | Omit<Suggestion, "isLoading">[];
31
44
 
32
45
  export interface AppendMessageOptions {
33
46
  /**
@@ -143,7 +156,10 @@ export interface UseCopilotChatReturn {
143
156
  messages: Message[];
144
157
 
145
158
  /** @deprecated use `sendMessage` in `useCopilotChatHeadless_c` instead. This will be removed in a future major version. */
146
- appendMessage: (message: DeprecatedGqlMessage, options?: AppendMessageOptions) => Promise<void>;
159
+ appendMessage: (
160
+ message: DeprecatedGqlMessage,
161
+ options?: AppendMessageOptions,
162
+ ) => Promise<void>;
147
163
 
148
164
  /**
149
165
  * Send a new message to the chat
@@ -156,7 +172,10 @@ export interface UseCopilotChatReturn {
156
172
  * });
157
173
  * ```
158
174
  */
159
- sendMessage: (message: Message, options?: AppendMessageOptions) => Promise<void>;
175
+ sendMessage: (
176
+ message: Message,
177
+ options?: AppendMessageOptions,
178
+ ) => Promise<void>;
160
179
 
161
180
  /**
162
181
  * Replace all messages in the chat
@@ -329,7 +348,11 @@ export function useCopilotChatInternal({
329
348
  }
330
349
  }
331
350
  };
332
- if (agent && existingConfig?.threadId && agent.threadId !== existingConfig.threadId) {
351
+ if (
352
+ agent &&
353
+ existingConfig?.threadId &&
354
+ agent.threadId !== existingConfig.threadId
355
+ ) {
333
356
  agent.threadId = existingConfig.threadId;
334
357
  connect(agent);
335
358
  }
@@ -376,7 +399,9 @@ export function useCopilotChatInternal({
376
399
  return;
377
400
  }
378
401
 
379
- const reloadMessageIndex = messages.findIndex((msg) => msg.id === reloadMessageId);
402
+ const reloadMessageIndex = messages.findIndex(
403
+ (msg) => msg.id === reloadMessageId,
404
+ );
380
405
  if (reloadMessageIndex === -1) {
381
406
  console.warn(`Message with id ${reloadMessageId} not found`);
382
407
  return;
@@ -384,7 +409,9 @@ export function useCopilotChatInternal({
384
409
 
385
410
  const reloadMessageRole = messages[reloadMessageIndex].role;
386
411
  if (reloadMessageRole !== "assistant") {
387
- console.warn(`Regenerate cannot be performed on ${reloadMessageRole} role`);
412
+ console.warn(
413
+ `Regenerate cannot be performed on ${reloadMessageRole} role`,
414
+ );
388
415
  return;
389
416
  }
390
417
  let historyCutoff: Message[] = [messages[0]];
@@ -404,7 +431,10 @@ export function useCopilotChatInternal({
404
431
  (msg) => msg.id === lastUserMessageBeforeRegenerate.id,
405
432
  );
406
433
  // Include the user message, remove everything after it
407
- historyCutoff = messages.slice(0, indexOfLastUserMessageBeforeRegenerate + 1);
434
+ historyCutoff = messages.slice(
435
+ 0,
436
+ indexOfLastUserMessageBeforeRegenerate + 1,
437
+ );
408
438
  }
409
439
  } else if (messages.length > 2 && reloadMessageIndex === 0) {
410
440
  historyCutoff = [messages[0], messages[1]];
@@ -422,7 +452,12 @@ export function useCopilotChatInternal({
422
452
  }
423
453
  return;
424
454
  },
425
- [agent?.messages.length, agent?.isRunning ,agent?.setMessages, copilotkit?.runAgent],
455
+ [
456
+ agent?.messages.length,
457
+ agent?.isRunning,
458
+ agent?.setMessages,
459
+ copilotkit?.runAgent,
460
+ ],
426
461
  );
427
462
 
428
463
  const latestSendMessageFunc = useAsyncCallback(
@@ -473,7 +508,9 @@ export function useCopilotChatInternal({
473
508
 
474
509
  const latestSetMessagesFunc = useCallback(
475
510
  (messages: Message[] | DeprecatedGqlMessage[]) => {
476
- if (messages.every((message) => message instanceof DeprecatedGqlMessage)) {
511
+ if (
512
+ messages.every((message) => message instanceof DeprecatedGqlMessage)
513
+ ) {
477
514
  return agent?.setMessages?.(gqlToAGUI(messages));
478
515
  }
479
516
  return agent?.setMessages?.(messages);
@@ -534,10 +571,15 @@ export function useCopilotChatInternal({
534
571
  legacyCustomMessageRenderer || renderCustomMessage
535
572
  ? () => {
536
573
  if (legacyCustomMessageRenderer) {
537
- return legacyCustomMessageRenderer({ message, position: "before" });
574
+ return legacyCustomMessageRenderer({
575
+ message,
576
+ position: "before",
577
+ });
538
578
  }
539
579
  try {
540
- return renderCustomMessage?.({ message, position: "before" }) ?? null;
580
+ return (
581
+ renderCustomMessage?.({ message, position: "before" }) ?? null
582
+ );
541
583
  } catch (error) {
542
584
  console.warn(
543
585
  "[CopilotKit] renderCustomMessages failed, falling back to legacy renderer",
@@ -559,7 +601,9 @@ export function useCopilotChatInternal({
559
601
  return message;
560
602
  });
561
603
 
562
- const hasAssistantMessages = processedMessages.some((msg) => msg.role === "assistant");
604
+ const hasAssistantMessages = processedMessages.some(
605
+ (msg) => msg.role === "assistant",
606
+ );
563
607
  const canUseCustomRenderer = Boolean(
564
608
  renderCustomMessage && copilotkit?.getAgent?.(resolvedAgentId),
565
609
  );
@@ -570,7 +614,8 @@ export function useCopilotChatInternal({
570
614
  : null;
571
615
 
572
616
  const shouldRenderPlaceholder =
573
- Boolean(agent?.isRunning) || Boolean(agent?.state && Object.keys(agent.state).length);
617
+ Boolean(agent?.isRunning) ||
618
+ Boolean(agent?.state && Object.keys(agent.state).length);
574
619
 
575
620
  const effectiveThreadId = threadId ?? agent?.threadId ?? "default";
576
621
  let latestUserIndex = -1;
@@ -583,8 +628,11 @@ export function useCopilotChatInternal({
583
628
  const latestUserMessageId =
584
629
  latestUserIndex >= 0 ? processedMessages[latestUserIndex].id : undefined;
585
630
  const currentRunId = latestUserMessageId
586
- ? copilotkit.getRunIdForMessage(resolvedAgentId, effectiveThreadId, latestUserMessageId) ||
587
- `pending:${latestUserMessageId}`
631
+ ? copilotkit.getRunIdForMessage(
632
+ resolvedAgentId,
633
+ effectiveThreadId,
634
+ latestUserMessageId,
635
+ ) || `pending:${latestUserMessageId}`
588
636
  : undefined;
589
637
  const hasAssistantForCurrentRun =
590
638
  latestUserIndex >= 0
@@ -595,7 +643,11 @@ export function useCopilotChatInternal({
595
643
 
596
644
  // Insert a placeholder assistant message so state snapshots can render before any
597
645
  // assistant text exists for the current run.
598
- if (placeholderRenderer && shouldRenderPlaceholder && !hasAssistantForCurrentRun) {
646
+ if (
647
+ placeholderRenderer &&
648
+ shouldRenderPlaceholder &&
649
+ !hasAssistantForCurrentRun
650
+ ) {
599
651
  const placeholderId = currentRunId
600
652
  ? `coagent-state-render-${resolvedAgentId}-${currentRunId}`
601
653
  : `coagent-state-render-${resolvedAgentId}`;
@@ -660,7 +712,8 @@ export function useCopilotChatInternal({
660
712
  suggestions: renderedSuggestions.suggestions,
661
713
  setSuggestions: (suggestions: Omit<Suggestion, "isLoading">[]) =>
662
714
  copilotkit.addSuggestionsConfig({ suggestions }),
663
- generateSuggestions: async () => copilotkit.reloadSuggestions(resolvedAgentId),
715
+ generateSuggestions: async () =>
716
+ copilotkit.reloadSuggestions(resolvedAgentId),
664
717
  resetSuggestions: () => copilotkit.clearSuggestions(resolvedAgentId),
665
718
  isLoadingSuggestions: renderedSuggestions.isLoading,
666
719
  interrupt,
@@ -22,12 +22,17 @@ export interface CopilotRuntimeClientHookOptions extends CopilotRuntimeClientOpt
22
22
  onError: CopilotErrorHandler;
23
23
  }
24
24
 
25
- export const useCopilotRuntimeClient = (options: CopilotRuntimeClientHookOptions) => {
25
+ export const useCopilotRuntimeClient = (
26
+ options: CopilotRuntimeClientHookOptions,
27
+ ) => {
26
28
  const { setBannerError } = useToast();
27
29
  const { showDevConsole, onError, ...runtimeOptions } = options;
28
30
 
29
31
  // Deduplication state for structured errors
30
- const lastStructuredErrorRef = useRef<{ message: string; timestamp: number } | null>(null);
32
+ const lastStructuredErrorRef = useRef<{
33
+ message: string;
34
+ timestamp: number;
35
+ } | null>(null);
31
36
 
32
37
  // Helper function to trace UI errors
33
38
  const traceUIError = async (error: CopilotKitError, originalError?: any) => {
@@ -44,8 +49,12 @@ export const useCopilotRuntimeClient = (options: CopilotRuntimeClientHookOptions
44
49
  },
45
50
  technical: {
46
51
  environment: "browser",
47
- userAgent: typeof navigator !== "undefined" ? navigator.userAgent : undefined,
48
- stackTrace: originalError instanceof Error ? originalError.stack : undefined,
52
+ userAgent:
53
+ typeof navigator !== "undefined"
54
+ ? navigator.userAgent
55
+ : undefined,
56
+ stackTrace:
57
+ originalError instanceof Error ? originalError.stack : undefined,
49
58
  },
50
59
  },
51
60
  error,
@@ -85,7 +94,10 @@ export const useCopilotRuntimeClient = (options: CopilotRuntimeClientHookOptions
85
94
  ) {
86
95
  return; // Skip duplicate
87
96
  }
88
- lastStructuredErrorRef.current = { message: errorMessage, timestamp: now };
97
+ lastStructuredErrorRef.current = {
98
+ message: errorMessage,
99
+ timestamp: now,
100
+ };
89
101
 
90
102
  const ckError = createStructuredError(gqlError);
91
103
  if (ckError) {
@@ -150,7 +162,9 @@ function createStructuredError(gqlError: GraphQLError): CopilotKitError | null {
150
162
  if (originalError?.stack?.includes("CopilotApiDiscoveryError")) {
151
163
  return new CopilotKitApiDiscoveryError({ message });
152
164
  }
153
- if (originalError?.stack?.includes("CopilotKitRemoteEndpointDiscoveryError")) {
165
+ if (
166
+ originalError?.stack?.includes("CopilotKitRemoteEndpointDiscoveryError")
167
+ ) {
154
168
  return new CopilotKitRemoteEndpointDiscoveryError({ message });
155
169
  }
156
170
  if (originalError?.stack?.includes("CopilotKitAgentDiscoveryError")) {
@@ -1,7 +1,13 @@
1
1
  import { useCopilotAction } from "./use-copilot-action";
2
2
  import { CatchAllFrontendAction } from "../types/frontend-action";
3
3
 
4
- export function useDefaultTool(tool: Omit<CatchAllFrontendAction, "name">, dependencies?: any[]) {
4
+ export function useDefaultTool(
5
+ tool: Omit<CatchAllFrontendAction, "name">,
6
+ dependencies?: any[],
7
+ ) {
5
8
  // Use the existing useCopilotAction hook
6
- useCopilotAction({ ...tool, name: "*" } satisfies CatchAllFrontendAction, dependencies);
9
+ useCopilotAction(
10
+ { ...tool, name: "*" } satisfies CatchAllFrontendAction,
11
+ dependencies,
12
+ );
7
13
  }
@@ -21,16 +21,19 @@ const useFlatCategoryStore = <T>(): UseFlatCategoryStoreReturn<T> => {
21
21
  new Map<FlatCategoryStoreId, FlatCategoryStoreElement<T>>(),
22
22
  );
23
23
 
24
- const addElement = useCallback((value: T, categories: string[]): FlatCategoryStoreId => {
25
- const newId = randomId();
26
- dispatch({
27
- type: "ADD_ELEMENT",
28
- value,
29
- id: newId,
30
- categories,
31
- });
32
- return newId;
33
- }, []);
24
+ const addElement = useCallback(
25
+ (value: T, categories: string[]): FlatCategoryStoreId => {
26
+ const newId = randomId();
27
+ dispatch({
28
+ type: "ADD_ELEMENT",
29
+ value,
30
+ id: newId,
31
+ categories,
32
+ });
33
+ return newId;
34
+ },
35
+ [],
36
+ );
34
37
 
35
38
  const removeElement = useCallback((id: FlatCategoryStoreId): void => {
36
39
  dispatch({ type: "REMOVE_ELEMENT", id });
@@ -93,7 +96,8 @@ function flatCategoryStoreReducer<T>(
93
96
  }
94
97
 
95
98
  function setsHaveIntersection<T>(setA: Set<T>, setB: Set<T>): boolean {
96
- const [smallerSet, largerSet] = setA.size <= setB.size ? [setA, setB] : [setB, setA];
99
+ const [smallerSet, largerSet] =
100
+ setA.size <= setB.size ? [setA, setB] : [setB, setA];
97
101
 
98
102
  for (let item of smallerSet) {
99
103
  if (largerSet.has(item)) {
@@ -1,6 +1,10 @@
1
1
  import React, { useEffect, useMemo, useRef } from "react";
2
2
  import { ActionRenderProps, FrontendAction } from "../types/frontend-action";
3
- import { Parameter, getZodParameters, MappedParameterTypes } from "@copilotkit/shared";
3
+ import {
4
+ Parameter,
5
+ getZodParameters,
6
+ MappedParameterTypes,
7
+ } from "@copilotkit/shared";
4
8
  import { parseJson } from "@copilotkit/shared";
5
9
  import { ToolCallStatus } from "@copilotkitnext/core";
6
10
  import {
@@ -8,7 +12,9 @@ import {
8
12
  useFrontendTool as useFrontendToolVNext,
9
13
  } from "@copilotkitnext/react";
10
14
 
11
- type FrontendToolOptions<T extends Parameter[] | []> = ReactFrontendTool<MappedParameterTypes<T>>;
15
+ type FrontendToolOptions<T extends Parameter[] | []> = ReactFrontendTool<
16
+ MappedParameterTypes<T>
17
+ >;
12
18
  type FrontendToolRenderArgs<T extends Parameter[] | []> =
13
19
  | {
14
20
  name: string;
@@ -49,36 +55,40 @@ export function useFrontendTool<const T extends Parameter[] = []>(
49
55
  renderRef.current = render;
50
56
  }, [render, ...(dependencies ?? [])]);
51
57
 
52
- const normalizedRender: FrontendToolOptions<T>["render"] | undefined = useMemo(() => {
53
- if (typeof render === "undefined") {
54
- return undefined;
55
- }
58
+ const normalizedRender: FrontendToolOptions<T>["render"] | undefined =
59
+ useMemo(() => {
60
+ if (typeof render === "undefined") {
61
+ return undefined;
62
+ }
56
63
 
57
- return ((args: FrontendToolRenderArgs<T>) => {
58
- const currentRender = renderRef.current;
64
+ return ((args: FrontendToolRenderArgs<T>) => {
65
+ const currentRender = renderRef.current;
59
66
 
60
- if (typeof currentRender === "undefined") {
61
- return null;
62
- }
67
+ if (typeof currentRender === "undefined") {
68
+ return null;
69
+ }
63
70
 
64
- if (typeof currentRender === "string") {
65
- return React.createElement(React.Fragment, null, currentRender);
66
- }
71
+ if (typeof currentRender === "string") {
72
+ return React.createElement(React.Fragment, null, currentRender);
73
+ }
67
74
 
68
- const renderArgs = {
69
- ...args,
70
- result: typeof args.result === "string" ? parseJson(args.result, args.result) : args.result,
71
- } as ActionRenderProps<T>;
75
+ const renderArgs = {
76
+ ...args,
77
+ result:
78
+ typeof args.result === "string"
79
+ ? parseJson(args.result, args.result)
80
+ : args.result,
81
+ } as ActionRenderProps<T>;
72
82
 
73
- const rendered = currentRender(renderArgs);
83
+ const rendered = currentRender(renderArgs);
74
84
 
75
- if (typeof rendered === "string") {
76
- return React.createElement(React.Fragment, null, rendered);
77
- }
85
+ if (typeof rendered === "string") {
86
+ return React.createElement(React.Fragment, null, rendered);
87
+ }
78
88
 
79
- return rendered ?? null;
80
- }) as FrontendToolOptions<T>["render"];
81
- }, []);
89
+ return rendered ?? null;
90
+ }) as FrontendToolOptions<T>["render"];
91
+ }, []);
82
92
 
83
93
  // Handler ref to avoid stale closures
84
94
  const handlerRef = useRef<typeof tool.handler>(tool.handler);
@@ -1,4 +1,8 @@
1
- import { ActionRenderProps, ActionRenderPropsWait, FrontendAction } from "../types";
1
+ import {
2
+ ActionRenderProps,
3
+ ActionRenderPropsWait,
4
+ FrontendAction,
5
+ } from "../types";
2
6
  import {
3
7
  CopilotKitError,
4
8
  CopilotKitErrorCode,
@@ -9,11 +13,20 @@ import {
9
13
  } from "@copilotkit/shared";
10
14
  import { useHumanInTheLoop as useHumanInTheLoopVNext } from "@copilotkitnext/react";
11
15
  import { ToolCallStatus } from "@copilotkitnext/core";
12
- import React, { ComponentType, FunctionComponent, useEffect, useRef } from "react";
16
+ import React, {
17
+ ComponentType,
18
+ FunctionComponent,
19
+ useEffect,
20
+ useRef,
21
+ } from "react";
13
22
 
14
23
  type HumanInTheLoopOptions = Parameters<typeof useHumanInTheLoopVNext>[0];
15
24
  type HumanInTheLoopRender = HumanInTheLoopOptions["render"];
16
- type HumanInTheLoopRenderArgs = HumanInTheLoopRender extends (props: infer P) => any ? P : never;
25
+ type HumanInTheLoopRenderArgs = HumanInTheLoopRender extends (
26
+ props: infer P,
27
+ ) => any
28
+ ? P
29
+ : never;
17
30
 
18
31
  export type UseHumanInTheLoopArgs<T extends Parameter[] | [] = []> = {
19
32
  available?: "disabled" | "enabled";
@@ -90,7 +103,9 @@ export function useHumanInTheLoop<const T extends Parameter[] | [] = []>(
90
103
  args: mappedArgs,
91
104
  respond: args.respond,
92
105
  status: args.status,
93
- result: args.result ? parseJson(args.result, args.result) : args.result,
106
+ result: args.result
107
+ ? parseJson(args.result, args.result)
108
+ : args.result,
94
109
  handler: undefined,
95
110
  };
96
111
  default:
@@ -117,6 +132,7 @@ export function useHumanInTheLoop<const T extends Parameter[] | [] = []>(
117
132
  followUp,
118
133
  parameters: zodParameters,
119
134
  render: ((args: HumanInTheLoopRenderArgs) =>
120
- renderRef.current?.(args as HitlRendererArgs) ?? null) as HumanInTheLoopOptions["render"],
135
+ renderRef.current?.(args as HitlRendererArgs) ??
136
+ null) as HumanInTheLoopOptions["render"],
121
137
  });
122
138
  }
@@ -17,7 +17,12 @@ type InterruptProps = {
17
17
  resolve: (response: string) => void;
18
18
  };
19
19
 
20
- const InterruptRenderer: React.FC<InterruptProps> = ({ event, result, render, resolve }) => {
20
+ const InterruptRenderer: React.FC<InterruptProps> = ({
21
+ event,
22
+ result,
23
+ render,
24
+ resolve,
25
+ }) => {
21
26
  return render({ event, result, resolve });
22
27
  };
23
28
 
@@ -132,5 +137,11 @@ export function useLangGraphInterruptRender(
132
137
  render,
133
138
  resolve: resolveInterrupt,
134
139
  });
135
- }, [interruptActions, interruptEventQueue, threadId, agentSession, handleResolve]);
140
+ }, [
141
+ interruptActions,
142
+ interruptEventQueue,
143
+ threadId,
144
+ agentSession,
145
+ handleResolve,
146
+ ]);
136
147
  }
@@ -8,8 +8,12 @@ export function useLangGraphInterrupt<TEventValue = any>(
8
8
  action: Omit<LangGraphInterruptRender<TEventValue>, "id">,
9
9
  dependencies?: any[],
10
10
  ) {
11
- const { setInterruptAction, removeInterruptAction, interruptActions, threadId } =
12
- useContext(CopilotContext);
11
+ const {
12
+ setInterruptAction,
13
+ removeInterruptAction,
14
+ interruptActions,
15
+ threadId,
16
+ } = useContext(CopilotContext);
13
17
  const { addToast } = useToast();
14
18
 
15
19
  const actionId = dataToUUID(action, "lgAction");
@@ -32,5 +36,11 @@ export function useLangGraphInterrupt<TEventValue = any>(
32
36
  return () => {
33
37
  removeInterruptAction(actionId);
34
38
  };
35
- }, [setInterruptAction, removeInterruptAction, threadId, actionId, ...(dependencies || [])]);
39
+ }, [
40
+ setInterruptAction,
41
+ removeInterruptAction,
42
+ threadId,
43
+ actionId,
44
+ ...(dependencies || []),
45
+ ]);
36
46
  }
@@ -1,13 +1,14 @@
1
+ import { type Parameter, getZodParameters } from "@copilotkit/shared";
2
+ import { parseJson } from "@copilotkit/shared";
3
+ import { defineToolCallRenderer, useCopilotKit } from "@copilotkitnext/react";
4
+ import type React from "react";
5
+ import { useEffect, useRef } from "react";
1
6
  import {
2
- ActionRenderProps,
3
- ActionRenderPropsNoArgs,
7
+ type ActionRenderProps,
8
+ type ActionRenderPropsNoArgs,
4
9
  ActionRenderPropsWait,
5
- FrontendAction,
10
+ type FrontendAction,
6
11
  } 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";
11
12
 
12
13
  type ToolCallRendererDefinition = Parameters<typeof defineToolCallRenderer>[0];
13
14
 
@@ -41,7 +42,9 @@ export function useRenderToolCall<const T extends Parameter[] | [] = []>(
41
42
  render: ((args) => {
42
43
  return render({
43
44
  ...args,
44
- result: args.result ? parseJson(args.result, args.result) : args.result,
45
+ result: args.result
46
+ ? parseJson(args.result, args.result)
47
+ : args.result,
45
48
  });
46
49
  }) as ToolCallRendererDefinition["render"],
47
50
  })
@@ -51,13 +54,17 @@ export function useRenderToolCall<const T extends Parameter[] | [] = []>(
51
54
  render: ((args) => {
52
55
  return render({
53
56
  ...args,
54
- result: args.result ? parseJson(args.result, args.result) : args.result,
57
+ result: args.result
58
+ ? parseJson(args.result, args.result)
59
+ : args.result,
55
60
  });
56
61
  }) as ToolCallRendererDefinition["render"],
57
62
  });
58
63
 
59
64
  // Remove any existing renderer with the same name
60
- const existingIndex = copilotkit.renderToolCalls.findIndex((r) => r.name === name);
65
+ const existingIndex = copilotkit.renderToolCalls.findIndex(
66
+ (r) => r.name === name,
67
+ );
61
68
  if (existingIndex !== -1) {
62
69
  copilotkit.renderToolCalls.splice(existingIndex, 1);
63
70
  }
@@ -69,7 +76,9 @@ export function useRenderToolCall<const T extends Parameter[] | [] = []>(
69
76
  // Cleanup: remove this renderer when the component unmounts or tool changes
70
77
  return () => {
71
78
  if (hasAddedRef.current) {
72
- const index = copilotkit.renderToolCalls.findIndex((r) => r.name === name);
79
+ const index = copilotkit.renderToolCalls.findIndex(
80
+ (r) => r.name === name,
81
+ );
73
82
  if (index !== -1) {
74
83
  copilotkit.renderToolCalls.splice(index, 1);
75
84
  }
@@ -15,7 +15,11 @@ export type Tree = TreeNode[];
15
15
 
16
16
  export interface UseTreeReturn {
17
17
  tree: Tree;
18
- addElement: (value: string, categories: string[], parentId?: TreeNodeId) => TreeNodeId;
18
+ addElement: (
19
+ value: string,
20
+ categories: string[],
21
+ parentId?: TreeNodeId,
22
+ ) => TreeNodeId;
19
23
  printTree: (categories: string[]) => string;
20
24
  removeElement: (id: TreeNodeId) => void;
21
25
  getAllElements: () => Tree;
@@ -44,7 +48,11 @@ const removeNode = (nodes: Tree, id: TreeNodeId): Tree => {
44
48
  }, []);
45
49
  };
46
50
 
47
- const addNode = (nodes: Tree, newNode: TreeNode, parentId?: TreeNodeId): Tree => {
51
+ const addNode = (
52
+ nodes: Tree,
53
+ newNode: TreeNode,
54
+ parentId?: TreeNodeId,
55
+ ): Tree => {
48
56
  if (!parentId) {
49
57
  return [...nodes, newNode];
50
58
  }
@@ -58,7 +66,10 @@ const addNode = (nodes: Tree, newNode: TreeNode, parentId?: TreeNodeId): Tree =>
58
66
  });
59
67
  };
60
68
 
61
- const treeIndentationRepresentation = (index: number, indentLevel: number): string => {
69
+ const treeIndentationRepresentation = (
70
+ index: number,
71
+ indentLevel: number,
72
+ ): string => {
62
73
  if (indentLevel === 0) {
63
74
  return (index + 1).toString();
64
75
  } else if (indentLevel === 1) {
@@ -182,7 +193,10 @@ const useTree = (): UseTreeReturn => {
182
193
  output += "\n";
183
194
  }
184
195
 
185
- output += printNode(node, `${treeIndentationRepresentation(index, 0)}. `);
196
+ output += printNode(
197
+ node,
198
+ `${treeIndentationRepresentation(index, 0)}. `,
199
+ );
186
200
  });
187
201
  return output;
188
202
  },
@@ -195,7 +209,8 @@ const useTree = (): UseTreeReturn => {
195
209
  export default useTree;
196
210
 
197
211
  function setsHaveIntersection<T>(setA: Set<T>, setB: Set<T>): boolean {
198
- const [smallerSet, largerSet] = setA.size <= setB.size ? [setA, setB] : [setB, setA];
212
+ const [smallerSet, largerSet] =
213
+ setA.size <= setB.size ? [setA, setB] : [setB, setA];
199
214
 
200
215
  for (let item of smallerSet) {
201
216
  if (largerSet.has(item)) {