@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
@@ -105,7 +105,9 @@ export function ToastProvider({
105
105
  children: React.ReactNode;
106
106
  }) {
107
107
  const [toasts, setToasts] = useState<Toast[]>([]);
108
- const [bannerError, setBannerErrorState] = useState<CopilotKitError | null>(null);
108
+ const [bannerError, setBannerErrorState] = useState<CopilotKitError | null>(
109
+ null,
110
+ );
109
111
 
110
112
  const removeToast = useCallback((id: string) => {
111
113
  setToasts((prev) => prev.filter((toast) => toast.id !== id));
@@ -121,7 +123,8 @@ export function ToastProvider({
121
123
  const id = toast.id ?? Math.random().toString(36).substring(2, 9);
122
124
 
123
125
  setToasts((currentToasts) => {
124
- if (currentToasts.find((toast) => toast.id === id)) return currentToasts;
126
+ if (currentToasts.find((toast) => toast.id === id))
127
+ return currentToasts;
125
128
  return [...currentToasts, { ...toast, id }];
126
129
  });
127
130
 
@@ -147,7 +150,9 @@ export function ToastProvider({
147
150
 
148
151
  const addGraphQLErrorsToast = useCallback((errors: GraphQLError[]) => {
149
152
  // DEPRECATED: All errors now route to banners for consistency
150
- console.warn("addGraphQLErrorsToast is deprecated. All errors now show as banners.");
153
+ console.warn(
154
+ "addGraphQLErrorsToast is deprecated. All errors now show as banners.",
155
+ );
151
156
  // Function kept for backward compatibility - does nothing
152
157
  }, []);
153
158
 
@@ -246,7 +251,9 @@ export function ToastProvider({
246
251
  let message = bannerError.message;
247
252
 
248
253
  // Try to extract the useful message from JSON first
249
- const jsonMatch = message.match(/'message':\s*'([^']+)'/);
254
+ const jsonMatch = message.match(
255
+ /'message':\s*'([^']+)'/,
256
+ );
250
257
  if (jsonMatch) {
251
258
  return jsonMatch[1]; // Return the actual error message
252
259
  }
@@ -294,7 +301,9 @@ export function ToastProvider({
294
301
 
295
302
  return (
296
303
  <button
297
- onClick={() => window.open(url, "_blank", "noopener,noreferrer")}
304
+ onClick={() =>
305
+ window.open(url, "_blank", "noopener,noreferrer")
306
+ }
298
307
  style={{
299
308
  background: colors.border,
300
309
  color: "white",
@@ -309,7 +318,8 @@ export function ToastProvider({
309
318
  }}
310
319
  onMouseEnter={(e) => {
311
320
  e.currentTarget.style.opacity = "0.9";
312
- e.currentTarget.style.transform = "translateY(-1px)";
321
+ e.currentTarget.style.transform =
322
+ "translateY(-1px)";
313
323
  }}
314
324
  onMouseLeave={(e) => {
315
325
  e.currentTarget.style.opacity = "1";
@@ -234,7 +234,11 @@ export const getErrorActions = (error: CopilotKitError) => {
234
234
  primary: {
235
235
  label: "Upgrade",
236
236
  onClick: () =>
237
- window.open("https://cloud.copilotkit.ai", "_blank", "noopener,noreferrer"),
237
+ window.open(
238
+ "https://cloud.copilotkit.ai",
239
+ "_blank",
240
+ "noopener,noreferrer",
241
+ ),
238
242
  },
239
243
  };
240
244
  default:
@@ -242,7 +246,10 @@ export const getErrorActions = (error: CopilotKitError) => {
242
246
  }
243
247
  };
244
248
 
245
- export function renderCopilotKitUsage(error: CopilotKitError, onClose?: () => void) {
249
+ export function renderCopilotKitUsage(
250
+ error: CopilotKitError,
251
+ onClose?: () => void,
252
+ ) {
246
253
  // Route based on error visibility level
247
254
  if (error.visibility !== ErrorVisibility.BANNER) {
248
255
  return null;
@@ -21,26 +21,36 @@ type ClaimsRef = Record<string, StateRenderClaim>;
21
21
 
22
22
  export interface CoAgentStateRendersContextValue {
23
23
  coAgentStateRenders: Record<string, CoAgentStateRender<any>>;
24
- setCoAgentStateRender: (id: string, stateRender: CoAgentStateRender<any>) => void;
24
+ setCoAgentStateRender: (
25
+ id: string,
26
+ stateRender: CoAgentStateRender<any>,
27
+ ) => void;
25
28
  removeCoAgentStateRender: (id: string) => void;
26
29
  claimsRef: RefObject<ClaimsRef>;
27
30
  }
28
31
 
29
- const CoAgentStateRendersContext = createContext<CoAgentStateRendersContextValue | undefined>(
30
- undefined,
31
- );
32
+ const CoAgentStateRendersContext = createContext<
33
+ CoAgentStateRendersContextValue | undefined
34
+ >(undefined);
32
35
 
33
- export function CoAgentStateRendersProvider({ children }: { children: ReactNode }) {
36
+ export function CoAgentStateRendersProvider({
37
+ children,
38
+ }: {
39
+ children: ReactNode;
40
+ }) {
34
41
  const [coAgentStateRenders, setCoAgentStateRenders] = useState<
35
42
  Record<string, CoAgentStateRender<any>>
36
43
  >({});
37
44
 
38
- const setCoAgentStateRender = useCallback((id: string, stateRender: CoAgentStateRender<any>) => {
39
- setCoAgentStateRenders((prevPoints) => ({
40
- ...prevPoints,
41
- [id]: stateRender,
42
- }));
43
- }, []);
45
+ const setCoAgentStateRender = useCallback(
46
+ (id: string, stateRender: CoAgentStateRender<any>) => {
47
+ setCoAgentStateRenders((prevPoints) => ({
48
+ ...prevPoints,
49
+ [id]: stateRender,
50
+ }));
51
+ },
52
+ [],
53
+ );
44
54
 
45
55
  const removeCoAgentStateRender = useCallback((id: string) => {
46
56
  setCoAgentStateRenders((prevPoints) => {
@@ -69,7 +79,9 @@ export function CoAgentStateRendersProvider({ children }: { children: ReactNode
69
79
  export function useCoAgentStateRenders() {
70
80
  const context = useContext(CoAgentStateRendersContext);
71
81
  if (!context) {
72
- throw new Error("useCoAgentStateRenders must be used within CoAgentStateRendersProvider");
82
+ throw new Error(
83
+ "useCoAgentStateRenders must be used within CoAgentStateRendersProvider",
84
+ );
73
85
  }
74
86
  return context;
75
87
  }
@@ -13,7 +13,10 @@ import React from "react";
13
13
  import { TreeNodeId, Tree } from "../hooks/use-tree";
14
14
  import { DocumentPointer } from "../types";
15
15
  import { CopilotChatSuggestionConfiguration } from "../types/chat-suggestion-configuration";
16
- import { CoAgentStateRender, CoAgentStateRenderProps } from "../types/coagent-action";
16
+ import {
17
+ CoAgentStateRender,
18
+ CoAgentStateRenderProps,
19
+ } from "../types/coagent-action";
17
20
  import { CoagentState } from "../types/coagent-state";
18
21
  import {
19
22
  CopilotRuntimeClient,
@@ -94,8 +97,9 @@ export interface CopilotApiConfig {
94
97
  mcpServers?: Array<{ endpoint: string; apiKey?: string }>;
95
98
  }
96
99
 
97
- export type InChatRenderFunction<TProps = ActionRenderProps<any> | CatchAllActionRenderProps<any>> =
98
- (props: TProps) => string | React.JSX.Element;
100
+ export type InChatRenderFunction<
101
+ TProps = ActionRenderProps<any> | CatchAllActionRenderProps<any>,
102
+ > = (props: TProps) => string | React.JSX.Element;
99
103
  export type CoagentInChatRenderFunction = (
100
104
  props: CoAgentStateRenderProps<any>,
101
105
  ) => string | React.JSX.Element | undefined | null;
@@ -138,20 +142,32 @@ export interface CopilotContextParams {
138
142
  ) => FunctionCallHandler;
139
143
 
140
144
  // text context
141
- addContext: (context: string, parentId?: string, categories?: string[]) => TreeNodeId;
145
+ addContext: (
146
+ context: string,
147
+ parentId?: string,
148
+ categories?: string[],
149
+ ) => TreeNodeId;
142
150
  removeContext: (id: TreeNodeId) => void;
143
151
  getAllContext: () => Tree;
144
- getContextString: (documents: DocumentPointer[], categories: string[]) => string;
152
+ getContextString: (
153
+ documents: DocumentPointer[],
154
+ categories: string[],
155
+ ) => string;
145
156
 
146
157
  // document context
147
- addDocumentContext: (documentPointer: DocumentPointer, categories?: string[]) => TreeNodeId;
158
+ addDocumentContext: (
159
+ documentPointer: DocumentPointer,
160
+ categories?: string[],
161
+ ) => TreeNodeId;
148
162
  removeDocumentContext: (documentId: string) => void;
149
163
  getDocumentsContext: (categories: string[]) => DocumentPointer[];
150
164
 
151
165
  isLoading: boolean;
152
166
  setIsLoading: React.Dispatch<React.SetStateAction<boolean>>;
153
167
 
154
- chatSuggestionConfiguration: { [key: string]: CopilotChatSuggestionConfiguration };
168
+ chatSuggestionConfiguration: {
169
+ [key: string]: CopilotChatSuggestionConfiguration;
170
+ };
155
171
  addChatSuggestionConfiguration: (
156
172
  id: string,
157
173
  suggestion: CopilotChatSuggestionConfiguration,
@@ -171,7 +187,9 @@ export interface CopilotContextParams {
171
187
 
172
188
  // agents
173
189
  coagentStates: Record<string, CoagentState>;
174
- setCoagentStates: React.Dispatch<React.SetStateAction<Record<string, CoagentState>>>;
190
+ setCoagentStates: React.Dispatch<
191
+ React.SetStateAction<Record<string, CoagentState>>
192
+ >;
175
193
  coagentStatesRef: React.RefObject<Record<string, CoagentState>>;
176
194
  setCoagentStatesWithRef: (
177
195
  value:
@@ -204,7 +222,9 @@ export interface CopilotContextParams {
204
222
  * The auth states for the CopilotKit.
205
223
  */
206
224
  authStates_c?: Record<ActionName, AuthState>;
207
- setAuthStates_c?: React.Dispatch<React.SetStateAction<Record<ActionName, AuthState>>>;
225
+ setAuthStates_c?: React.Dispatch<
226
+ React.SetStateAction<Record<ActionName, AuthState>>
227
+ >;
208
228
 
209
229
  /**
210
230
  * The auth config for the CopilotKit.
@@ -222,7 +242,11 @@ export interface CopilotContextParams {
222
242
  removeInterruptAction: (actionId: string) => void;
223
243
  interruptEventQueue: Record<string, QueuedInterruptEvent[]>;
224
244
  addInterruptEvent: (queuedEvent: QueuedInterruptEvent) => void;
225
- resolveInterruptEvent: (threadId: string, eventId: string, response: string) => void;
245
+ resolveInterruptEvent: (
246
+ threadId: string,
247
+ eventId: string,
248
+ response: string,
249
+ ) => void;
226
250
 
227
251
  /**
228
252
  * Optional trace handler for comprehensive debugging and observability.
@@ -236,7 +260,9 @@ export interface CopilotContextParams {
236
260
  // These are used to handle errors that occur during the execution of the chat.
237
261
  // They are not intended for use by the developer. A component can register itself an error listener to be activated somewhere else as needed
238
262
  internalErrorHandlers: Record<string, CopilotErrorHandler>;
239
- setInternalErrorHandler: (handler: Record<string, CopilotErrorHandler>) => void;
263
+ setInternalErrorHandler: (
264
+ handler: Record<string, CopilotErrorHandler>,
265
+ ) => void;
240
266
  removeInternalErrorHandler: (id: string) => void;
241
267
  }
242
268
 
@@ -272,7 +298,9 @@ const emptyCopilotContext: CopilotContextParams = {
272
298
 
273
299
  copilotApiConfig: new (class implements CopilotApiConfig {
274
300
  get chatApiEndpoint(): string {
275
- throw new Error("Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!");
301
+ throw new Error(
302
+ "Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!",
303
+ );
276
304
  }
277
305
 
278
306
  get headers(): Record<string, string> {
@@ -317,16 +345,21 @@ const emptyCopilotContext: CopilotContextParams = {
317
345
  removeInternalErrorHandler: () => {},
318
346
  };
319
347
 
320
- export const CopilotContext = React.createContext<CopilotContextParams>(emptyCopilotContext);
348
+ export const CopilotContext =
349
+ React.createContext<CopilotContextParams>(emptyCopilotContext);
321
350
 
322
351
  export function useCopilotContext(): CopilotContextParams {
323
352
  const context = React.useContext(CopilotContext);
324
353
  if (context === emptyCopilotContext) {
325
- throw new Error("Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!");
354
+ throw new Error(
355
+ "Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!",
356
+ );
326
357
  }
327
358
  return context;
328
359
  }
329
360
 
330
361
  function returnAndThrowInDebug<T>(_value: T): T {
331
- throw new Error("Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!");
362
+ throw new Error(
363
+ "Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!",
364
+ );
332
365
  }
@@ -1,5 +1,8 @@
1
1
  export { CopilotContext, useCopilotContext } from "./copilot-context";
2
- export { CopilotMessagesContext, useCopilotMessagesContext } from "./copilot-messages-context";
2
+ export {
3
+ CopilotMessagesContext,
4
+ useCopilotMessagesContext,
5
+ } from "./copilot-messages-context";
3
6
  export {
4
7
  CoAgentStateRendersContext,
5
8
  CoAgentStateRendersProvider,
@@ -13,4 +16,7 @@ export type {
13
16
  } from "./copilot-context";
14
17
  export type { CopilotMessagesContextParams } from "./copilot-messages-context";
15
18
  export type { CoAgentStateRendersContextValue } from "./coagent-state-renders-context";
16
- export type { ThreadsContextValue, ThreadsProviderProps } from "./threads-context";
19
+ export type {
20
+ ThreadsContextValue,
21
+ ThreadsProviderProps,
22
+ } from "./threads-context";
@@ -1,4 +1,10 @@
1
- import React, { createContext, useContext, useState, ReactNode, SetStateAction } from "react";
1
+ import React, {
2
+ createContext,
3
+ useContext,
4
+ useState,
5
+ ReactNode,
6
+ SetStateAction,
7
+ } from "react";
2
8
  import { randomUUID } from "@copilotkit/shared";
3
9
 
4
10
  export interface ThreadsContextValue {
@@ -6,14 +12,19 @@ export interface ThreadsContextValue {
6
12
  setThreadId: (value: SetStateAction<string>) => void;
7
13
  }
8
14
 
9
- const ThreadsContext = createContext<ThreadsContextValue | undefined>(undefined);
15
+ const ThreadsContext = createContext<ThreadsContextValue | undefined>(
16
+ undefined,
17
+ );
10
18
 
11
19
  export interface ThreadsProviderProps {
12
20
  children: ReactNode;
13
21
  threadId?: string;
14
22
  }
15
23
 
16
- export function ThreadsProvider({ children, threadId: explicitThreadId }: ThreadsProviderProps) {
24
+ export function ThreadsProvider({
25
+ children,
26
+ threadId: explicitThreadId,
27
+ }: ThreadsProviderProps) {
17
28
  const [internalThreadId, setThreadId] = useState<string>(() => randomUUID());
18
29
 
19
30
  const threadId = explicitThreadId ?? internalThreadId;
@@ -20,7 +20,11 @@ describe("useCoAgentStateRenderBridge helpers", () => {
20
20
  runId: "run-123",
21
21
  };
22
22
 
23
- const result = resolveClaim({ claims, context, stateSnapshot: { step: 1 } });
23
+ const result = resolveClaim({
24
+ claims,
25
+ context,
26
+ stateSnapshot: { step: 1 },
27
+ });
24
28
  expect(result.action).toBe(ClaimAction.Existing);
25
29
  expect(result.canRender).toBe(true);
26
30
  expect(result.updateRunId).toBe("run-123");
@@ -43,7 +47,11 @@ describe("useCoAgentStateRenderBridge helpers", () => {
43
47
  messageIndex: 1,
44
48
  };
45
49
 
46
- const result = resolveClaim({ claims, context, stateSnapshot: { step: 2 } });
50
+ const result = resolveClaim({
51
+ claims,
52
+ context,
53
+ stateSnapshot: { step: 2 },
54
+ });
47
55
  expect(result.action).toBe(ClaimAction.Override);
48
56
  expect(result.canRender).toBe(true);
49
57
  expect(result.nextClaim).toMatchObject({
@@ -53,7 +61,6 @@ describe("useCoAgentStateRenderBridge helpers", () => {
53
61
  });
54
62
  expect(result.lockOthers).toBe(true);
55
63
  });
56
-
57
64
  });
58
65
 
59
66
  describe("selectSnapshot", () => {
@@ -67,7 +74,7 @@ describe("useCoAgentStateRenderBridge helpers", () => {
67
74
  messageId: "msg1",
68
75
  stateRenderId: "render-a",
69
76
  effectiveRunId: "run-1",
70
- stateSnapshotProp: "{\"phase\":\"planning\"}",
77
+ stateSnapshotProp: '{"phase":"planning"}',
71
78
  agentState: { phase: "ignored" },
72
79
  agentMessages: [{ id: "assistant-1", role: "assistant" }],
73
80
  caches,