@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
@@ -22,6 +22,18 @@ var __spreadValues = (a, b) => {
22
22
  return a;
23
23
  };
24
24
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
+ var __objRest = (source, exclude) => {
26
+ var target = {};
27
+ for (var prop in source)
28
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
29
+ target[prop] = source[prop];
30
+ if (source != null && __getOwnPropSymbols)
31
+ for (var prop of __getOwnPropSymbols(source)) {
32
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
33
+ target[prop] = source[prop];
34
+ }
35
+ return target;
36
+ };
25
37
  var __export = (target, all) => {
26
38
  for (var name in all)
27
39
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -70,7 +82,7 @@ __export(use_copilot_authenticated_action_exports, {
70
82
  useCopilotAuthenticatedAction_c: () => useCopilotAuthenticatedAction_c
71
83
  });
72
84
  module.exports = __toCommonJS(use_copilot_authenticated_action_exports);
73
- var import_react5 = require("react");
85
+ var import_react9 = require("react");
74
86
 
75
87
  // src/context/copilot-context.tsx
76
88
  var import_react = __toESM(require("react"));
@@ -80,10 +92,8 @@ var emptyCopilotContext = {
80
92
  },
81
93
  removeAction: () => {
82
94
  },
83
- coAgentStateRenders: {},
84
- setCoAgentStateRender: () => {
85
- },
86
- removeCoAgentStateRender: () => {
95
+ setRegisteredActions: () => "",
96
+ removeRegisteredAction: () => {
87
97
  },
88
98
  chatComponentsCache: { current: { actions: {}, coAgentStateRenders: {} } },
89
99
  getContextString: (documents, categories) => returnAndThrowInDebug(""),
@@ -103,7 +113,6 @@ var emptyCopilotContext = {
103
113
  addDocumentContext: () => returnAndThrowInDebug(""),
104
114
  removeDocumentContext: () => {
105
115
  },
106
- runtimeClient: {},
107
116
  copilotApiConfig: new class {
108
117
  get chatApiEndpoint() {
109
118
  throw new Error("Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!");
@@ -143,10 +152,15 @@ var emptyCopilotContext = {
143
152
  extensions: {},
144
153
  setExtensions: () => {
145
154
  },
146
- langGraphInterruptAction: null,
147
- setLangGraphInterruptAction: () => {
155
+ interruptActions: {},
156
+ setInterruptAction: () => {
157
+ },
158
+ removeInterruptAction: () => {
159
+ },
160
+ interruptEventQueue: {},
161
+ addInterruptEvent: () => {
148
162
  },
149
- removeLangGraphInterruptAction: () => {
163
+ removeInterruptEvent: () => {
150
164
  },
151
165
  onError: () => {
152
166
  },
@@ -172,281 +186,243 @@ function returnAndThrowInDebug(_value) {
172
186
  }
173
187
 
174
188
  // src/hooks/use-copilot-action.ts
175
- var import_shared2 = require("@copilotkit/shared");
176
- var import_react4 = require("react");
189
+ var import_react8 = require("react");
177
190
 
178
- // src/components/error-boundary/error-utils.tsx
179
- var import_react3 = require("react");
180
-
181
- // src/components/toast/toast-provider.tsx
182
- var import_react2 = require("react");
191
+ // src/hooks/use-frontend-tool.ts
192
+ var import_react2 = __toESM(require("react"));
183
193
  var import_shared = require("@copilotkit/shared");
184
- var import_jsx_runtime = require("react/jsx-runtime");
185
- var ToastContext = (0, import_react2.createContext)(void 0);
186
- function useToast() {
187
- const context = (0, import_react2.useContext)(ToastContext);
188
- if (!context) {
189
- throw new Error("useToast must be used within a ToastProvider");
190
- }
191
- return context;
192
- }
193
-
194
- // src/components/toast/exclamation-mark-icon.tsx
195
- var import_jsx_runtime2 = require("react/jsx-runtime");
196
- var ExclamationMarkIcon = ({
197
- className,
198
- style
199
- }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
200
- "svg",
201
- {
202
- xmlns: "http://www.w3.org/2000/svg",
203
- width: "24",
204
- height: "24",
205
- viewBox: "0 0 24 24",
206
- fill: "none",
207
- stroke: "currentColor",
208
- strokeWidth: "2",
209
- strokeLinecap: "round",
210
- strokeLinejoin: "round",
211
- className: `lucide lucide-circle-alert ${className ? className : ""}`,
212
- style,
213
- children: [
214
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
215
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "12", x2: "12", y1: "8", y2: "12" }),
216
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "12", x2: "12.01", y1: "16", y2: "16" })
217
- ]
218
- }
219
- );
220
-
221
- // src/components/error-boundary/error-utils.tsx
222
- var import_react_markdown = __toESM(require("react-markdown"));
223
- var import_jsx_runtime3 = require("react/jsx-runtime");
224
- function ErrorToast({ errors }) {
225
- const errorsToRender = errors.map((error, idx) => {
226
- var _a, _b, _c;
227
- const originalError = "extensions" in error ? (_a = error.extensions) == null ? void 0 : _a.originalError : {};
228
- const message = (_b = originalError == null ? void 0 : originalError.message) != null ? _b : error.message;
229
- const code = "extensions" in error ? (_c = error.extensions) == null ? void 0 : _c.code : null;
230
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
231
- "div",
232
- {
233
- style: {
234
- marginTop: idx === 0 ? 0 : 10,
235
- marginBottom: 14
236
- },
237
- children: [
238
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ExclamationMarkIcon, { style: { marginBottom: 4 } }),
239
- code && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
240
- "div",
241
- {
242
- style: {
243
- fontWeight: "600",
244
- marginBottom: 4
245
- },
246
- children: [
247
- "Copilot Runtime Error:",
248
- " ",
249
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { fontFamily: "monospace", fontWeight: "normal" }, children: code })
250
- ]
251
- }
252
- ),
253
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_markdown.default, { children: message })
254
- ]
255
- },
256
- idx
257
- );
258
- });
259
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
260
- "div",
261
- {
262
- style: {
263
- fontSize: "13px",
264
- maxWidth: "600px"
265
- },
266
- children: [
267
- errorsToRender,
268
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { fontSize: "11px", opacity: 0.75 }, children: "NOTE: This error only displays during local development." })
269
- ]
194
+ var import_shared2 = require("@copilotkit/shared");
195
+ var import_react3 = require("@copilotkitnext/react");
196
+ function useFrontendTool(tool, dependencies) {
197
+ const { name, description, parameters, render, followUp } = tool;
198
+ const zodParameters = (0, import_shared.getZodParameters)(parameters);
199
+ const normalizedRender = (() => {
200
+ if (typeof render === "undefined") {
201
+ return void 0;
270
202
  }
271
- );
272
- }
273
- function useErrorToast() {
274
- const { addToast } = useToast();
275
- return (0, import_react3.useCallback)(
276
- (error) => {
277
- const errorId = error.map((err) => {
278
- var _a, _b;
279
- const message = "extensions" in err ? ((_b = (_a = err.extensions) == null ? void 0 : _a.originalError) == null ? void 0 : _b.message) || err.message : err.message;
280
- const stack = err.stack || "";
281
- return btoa(message + stack).slice(0, 32);
282
- }).join("|");
283
- addToast({
284
- type: "error",
285
- id: errorId,
286
- // Toast libraries typically dedupe by id
287
- message: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ErrorToast, { errors: error })
288
- });
289
- },
290
- [addToast]
291
- );
292
- }
293
- function useAsyncCallback(callback, deps) {
294
- const addErrorToast = useErrorToast();
295
- return (0, import_react3.useCallback)((...args) => __async(this, null, function* () {
296
- try {
297
- return yield callback(...args);
298
- } catch (error) {
299
- console.error("Error in async callback:", error);
300
- addErrorToast([error]);
301
- throw error;
203
+ if (typeof render === "string") {
204
+ const staticRender = render;
205
+ return () => import_react2.default.createElement(import_react2.default.Fragment, null, staticRender);
302
206
  }
303
- }), deps);
207
+ return (args) => {
208
+ const renderArgs = __spreadProps(__spreadValues({}, args), {
209
+ result: typeof args.result === "string" ? (0, import_shared2.parseJson)(args.result, args.result) : args.result
210
+ });
211
+ const rendered = render(renderArgs);
212
+ if (typeof rendered === "string") {
213
+ return import_react2.default.createElement(import_react2.default.Fragment, null, rendered);
214
+ }
215
+ return rendered != null ? rendered : null;
216
+ };
217
+ })();
218
+ (0, import_react3.useFrontendTool)({
219
+ name,
220
+ description,
221
+ parameters: zodParameters,
222
+ handler: tool.handler,
223
+ followUp,
224
+ render: normalizedRender
225
+ });
304
226
  }
305
227
 
306
- // src/hooks/use-copilot-action.ts
307
- function useCopilotAction(action, dependencies) {
308
- const { setAction, removeAction, actions, chatComponentsCache } = useCopilotContext();
309
- const idRef = (0, import_react4.useRef)((0, import_shared2.randomId)());
310
- const renderAndWaitRef = (0, import_react4.useRef)(null);
311
- const activatingMessageIdRef = (0, import_react4.useRef)(null);
312
- const { addToast } = useToast();
313
- action = __spreadValues({}, action);
314
- if (
315
- // renderAndWaitForResponse is not available for catch all actions
316
- isFrontendAction(action) && // check if renderAndWaitForResponse is set
317
- (action.renderAndWait || action.renderAndWaitForResponse)
318
- ) {
319
- action._isRenderAndWait = true;
320
- const renderAndWait = action.renderAndWait || action.renderAndWaitForResponse;
321
- action.renderAndWait = void 0;
322
- action.renderAndWaitForResponse = void 0;
323
- action._setActivatingMessageId = (id) => {
324
- activatingMessageIdRef.current = id;
325
- };
326
- action.handler = useAsyncCallback(() => __async(this, null, function* () {
327
- const currentActivatingId = activatingMessageIdRef.current;
328
- let resolve;
329
- let reject;
330
- const promise = new Promise((resolvePromise, rejectPromise) => {
331
- resolve = resolvePromise;
332
- reject = rejectPromise;
333
- });
334
- renderAndWaitRef.current = {
335
- promise,
336
- resolve,
337
- reject,
338
- messageId: currentActivatingId
339
- };
340
- const result = yield promise;
341
- return result;
342
- }), []);
343
- action.render = (props) => {
344
- const currentRenderMessageId = props.messageId;
345
- let status = props.status;
346
- if (props.status === "executing") {
347
- if (!renderAndWaitRef.current || !renderAndWaitRef.current.promise) {
348
- status = "inProgress";
349
- } else if (renderAndWaitRef.current.messageId !== currentRenderMessageId && activatingMessageIdRef.current !== currentRenderMessageId) {
350
- status = "inProgress";
351
- }
228
+ // src/hooks/use-render-tool-call.ts
229
+ var import_shared3 = require("@copilotkit/shared");
230
+ var import_react4 = require("react");
231
+ var import_react5 = require("@copilotkitnext/react");
232
+ var import_shared4 = require("@copilotkit/shared");
233
+ function useRenderToolCall(tool, dependencies) {
234
+ const { copilotkit } = (0, import_react5.useCopilotKit)();
235
+ const hasAddedRef = (0, import_react4.useRef)(false);
236
+ (0, import_react4.useEffect)(() => {
237
+ const { name, parameters, render } = tool;
238
+ const zodParameters = (0, import_shared3.getZodParameters)(parameters);
239
+ const renderToolCall = name === "*" ? (0, import_react5.defineToolCallRenderer)({
240
+ name: "*",
241
+ render: (args) => {
242
+ return render(__spreadProps(__spreadValues({}, args), {
243
+ result: args.result ? (0, import_shared4.parseJson)(args.result, args.result) : args.result
244
+ }));
352
245
  }
353
- const waitProps = {
354
- status,
355
- args: props.args,
356
- result: props.result,
357
- // handler and respond should only be provided if this is the truly active instance
358
- // and its promise infrastructure is ready.
359
- handler: status === "executing" && renderAndWaitRef.current && renderAndWaitRef.current.messageId === currentRenderMessageId ? renderAndWaitRef.current.resolve : void 0,
360
- respond: status === "executing" && renderAndWaitRef.current && renderAndWaitRef.current.messageId === currentRenderMessageId ? renderAndWaitRef.current.resolve : void 0
361
- };
362
- const isNoArgsRenderWait = (_fn) => {
363
- var _a;
364
- return ((_a = action.parameters) == null ? void 0 : _a.length) === 0;
365
- };
366
- if (renderAndWait) {
367
- if (isNoArgsRenderWait(renderAndWait)) {
368
- return renderAndWait(waitProps);
369
- } else {
370
- return renderAndWait(waitProps);
246
+ }) : (0, import_react5.defineToolCallRenderer)({
247
+ name,
248
+ args: zodParameters,
249
+ render: (args) => {
250
+ return render(__spreadProps(__spreadValues({}, args), {
251
+ result: args.result ? (0, import_shared4.parseJson)(args.result, args.result) : args.result
252
+ }));
253
+ }
254
+ });
255
+ const existingIndex = copilotkit.renderToolCalls.findIndex((r) => r.name === name);
256
+ if (existingIndex !== -1) {
257
+ copilotkit.renderToolCalls.splice(existingIndex, 1);
258
+ }
259
+ copilotkit.renderToolCalls.push(renderToolCall);
260
+ hasAddedRef.current = true;
261
+ return () => {
262
+ if (hasAddedRef.current) {
263
+ const index = copilotkit.renderToolCalls.findIndex((r) => r.name === name);
264
+ if (index !== -1) {
265
+ copilotkit.renderToolCalls.splice(index, 1);
371
266
  }
267
+ hasAddedRef.current = false;
372
268
  }
373
- return (0, import_react4.createElement)(import_react4.Fragment);
374
269
  };
375
- }
376
- if (dependencies === void 0) {
377
- if (actions[idRef.current]) {
378
- if (isFrontendAction(action)) {
379
- actions[idRef.current].handler = action.handler;
270
+ }, [tool, ...dependencies != null ? dependencies : []]);
271
+ }
272
+
273
+ // src/hooks/use-human-in-the-loop.ts
274
+ var import_shared5 = require("@copilotkit/shared");
275
+ var import_react6 = require("@copilotkitnext/react");
276
+ var import_core = require("@copilotkitnext/core");
277
+ var import_react7 = __toESM(require("react"));
278
+ function useHumanInTheLoop(tool, dependencies) {
279
+ const _a = tool, { render } = _a, toolRest = __objRest(_a, ["render"]);
280
+ const { name, description, parameters, followUp } = toolRest;
281
+ const zodParameters = (0, import_shared5.getZodParameters)(parameters);
282
+ const renderRef = (0, import_react7.useRef)(null);
283
+ (0, import_react7.useEffect)(() => {
284
+ renderRef.current = (args) => {
285
+ if (typeof render === "string") {
286
+ return import_react7.default.createElement(import_react7.default.Fragment, null, render);
380
287
  }
381
- if (typeof action.render === "function") {
382
- if (chatComponentsCache.current !== null) {
383
- chatComponentsCache.current.actions[action.name] = action.render;
288
+ if (!render) {
289
+ return null;
290
+ }
291
+ const renderProps = (() => {
292
+ const mappedArgs = args.args;
293
+ switch (args.status) {
294
+ case import_core.ToolCallStatus.InProgress:
295
+ return {
296
+ args: mappedArgs,
297
+ respond: args.respond,
298
+ status: args.status,
299
+ handler: void 0
300
+ };
301
+ case import_core.ToolCallStatus.Executing:
302
+ return {
303
+ args: mappedArgs,
304
+ respond: args.respond,
305
+ status: args.status,
306
+ handler: () => {
307
+ }
308
+ };
309
+ case import_core.ToolCallStatus.Complete:
310
+ return {
311
+ args: mappedArgs,
312
+ respond: args.respond,
313
+ status: args.status,
314
+ result: args.result ? (0, import_shared5.parseJson)(args.result, args.result) : args.result,
315
+ handler: void 0
316
+ };
317
+ default:
318
+ throw new import_shared5.CopilotKitError({
319
+ code: import_shared5.CopilotKitErrorCode.UNKNOWN,
320
+ message: `Invalid tool call status: ${args.status}`
321
+ });
384
322
  }
323
+ })();
324
+ const rendered = render(renderProps);
325
+ if (typeof rendered === "string") {
326
+ return import_react7.default.createElement(import_react7.default.Fragment, null, rendered);
385
327
  }
328
+ return rendered != null ? rendered : null;
329
+ };
330
+ }, [render, ...dependencies != null ? dependencies : []]);
331
+ (0, import_react6.useHumanInTheLoop)({
332
+ name,
333
+ description,
334
+ followUp,
335
+ parameters: zodParameters,
336
+ render: (args) => {
337
+ var _a2, _b;
338
+ return (_b = (_a2 = renderRef.current) == null ? void 0 : _a2.call(renderRef, args)) != null ? _b : null;
386
339
  }
340
+ });
341
+ }
342
+
343
+ // src/hooks/use-copilot-action.ts
344
+ function getActionConfig(action) {
345
+ if (action.name === "*") {
346
+ return {
347
+ type: "render",
348
+ action
349
+ };
387
350
  }
388
- (0, import_react4.useEffect)(() => {
389
- const hasDuplicate = Object.values(actions).some(
390
- (otherAction) => otherAction.name === action.name && otherAction !== actions[idRef.current]
391
- );
392
- if (hasDuplicate) {
393
- addToast({
394
- type: "warning",
395
- message: `Found an already registered action with name ${action.name}.`,
396
- id: `dup-action-${action.name}`
397
- });
351
+ if ("renderAndWaitForResponse" in action || "renderAndWait" in action) {
352
+ let render = action.render;
353
+ if (!render && "renderAndWaitForResponse" in action) {
354
+ render = action.renderAndWaitForResponse;
398
355
  }
399
- }, [actions]);
400
- (0, import_react4.useEffect)(() => {
401
- setAction(idRef.current, action);
402
- if (chatComponentsCache.current !== null && action.render !== void 0) {
403
- chatComponentsCache.current.actions[action.name] = action.render;
356
+ if (!render && "renderAndWait" in action) {
357
+ render = action.renderAndWait;
404
358
  }
405
- return () => {
406
- removeAction(idRef.current);
359
+ return {
360
+ type: "hitl",
361
+ action: __spreadProps(__spreadValues({}, action), { render })
362
+ };
363
+ }
364
+ if ("available" in action) {
365
+ if (action.available === "enabled" || action.available === "remote") {
366
+ return {
367
+ type: "frontend",
368
+ action
369
+ };
370
+ }
371
+ if (action.available === "frontend" || action.available === "disabled") {
372
+ return {
373
+ type: "render",
374
+ action
375
+ };
376
+ }
377
+ }
378
+ if ("handler" in action) {
379
+ return {
380
+ type: "frontend",
381
+ action
407
382
  };
408
- }, [
409
- setAction,
410
- removeAction,
411
- isFrontendAction(action) ? action.description : void 0,
412
- action.name,
413
- isFrontendAction(action) ? action.disabled : void 0,
414
- isFrontendAction(action) ? action.available : void 0,
415
- // This should be faster than deep equality checking
416
- // In addition, all major JS engines guarantee the order of object keys
417
- JSON.stringify(isFrontendAction(action) ? action.parameters : []),
418
- // include render only if it's a string
419
- typeof action.render === "string" ? action.render : void 0,
420
- // dependencies set by the developer
421
- ...dependencies || []
422
- ]);
383
+ }
384
+ throw new Error("Invalid action configuration");
423
385
  }
424
- function isFrontendAction(action) {
425
- return action.name !== "*";
386
+ function useCopilotAction(action, dependencies) {
387
+ const [initialActionConfig] = (0, import_react8.useState)(getActionConfig(action));
388
+ const currentActionConfig = getActionConfig(action);
389
+ if (initialActionConfig.type !== currentActionConfig.type) {
390
+ throw new Error("Action configuration changed between renders");
391
+ }
392
+ switch (currentActionConfig.type) {
393
+ case "render":
394
+ return useRenderToolCall(currentActionConfig.action, dependencies);
395
+ case "hitl":
396
+ return useHumanInTheLoop(currentActionConfig.action, dependencies);
397
+ case "frontend":
398
+ return useFrontendTool(currentActionConfig.action, dependencies);
399
+ default:
400
+ throw new Error("Invalid action configuration");
401
+ }
426
402
  }
427
403
 
428
404
  // src/hooks/use-copilot-authenticated-action.ts
429
- var import_react6 = __toESM(require("react"));
405
+ var import_react10 = __toESM(require("react"));
430
406
  function useCopilotAuthenticatedAction_c(action, dependencies) {
431
407
  const { authConfig_c, authStates_c, setAuthStates_c } = useCopilotContext();
432
- const pendingActionRef = (0, import_react5.useRef)(null);
433
- const executeAction = (0, import_react5.useCallback)(
408
+ const pendingActionRef = (0, import_react9.useRef)(null);
409
+ const executeAction = (0, import_react9.useCallback)(
434
410
  (props) => {
435
411
  if (typeof action.render === "function") {
436
412
  return action.render(props);
437
413
  }
438
- return action.render || import_react6.default.createElement(import_react5.Fragment);
414
+ return action.render || import_react10.default.createElement(import_react9.Fragment);
439
415
  },
440
416
  [action]
441
417
  );
442
- const wrappedRender = (0, import_react5.useCallback)(
418
+ const wrappedRender = (0, import_react9.useCallback)(
443
419
  (props) => {
444
420
  const isAuthenticated = Object.values(authStates_c || {}).some(
445
421
  (state) => state.status === "authenticated"
446
422
  );
447
423
  if (!isAuthenticated) {
448
424
  pendingActionRef.current = props;
449
- return (authConfig_c == null ? void 0 : authConfig_c.SignInComponent) ? import_react6.default.createElement(authConfig_c.SignInComponent, {
425
+ return (authConfig_c == null ? void 0 : authConfig_c.SignInComponent) ? import_react10.default.createElement(authConfig_c.SignInComponent, {
450
426
  onSignInComplete: (authState) => {
451
427
  setAuthStates_c == null ? void 0 : setAuthStates_c((prev) => __spreadProps(__spreadValues({}, prev), { [action.name]: authState }));
452
428
  if (pendingActionRef.current) {
@@ -454,7 +430,7 @@ function useCopilotAuthenticatedAction_c(action, dependencies) {
454
430
  pendingActionRef.current = null;
455
431
  }
456
432
  }
457
- }) : import_react6.default.createElement(import_react5.Fragment);
433
+ }) : import_react10.default.createElement(import_react9.Fragment);
458
434
  }
459
435
  return executeAction(props);
460
436
  },