@copilotkit/react-core 1.10.6 → 1.50.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (333) hide show
  1. package/dist/chunk-24SCZAB4.mjs +143 -0
  2. package/dist/chunk-24SCZAB4.mjs.map +1 -0
  3. package/dist/chunk-36KQV2NA.mjs +1 -0
  4. package/dist/{chunk-U7QULEVO.mjs → chunk-3GURHDG7.mjs} +3 -3
  5. package/dist/{chunk-4BHIQMN6.mjs → chunk-3R423LZT.mjs} +6 -5
  6. package/dist/{chunk-4BHIQMN6.mjs.map → chunk-3R423LZT.mjs.map} +1 -1
  7. package/dist/chunk-5X5DJRQQ.mjs +71 -0
  8. package/dist/chunk-5X5DJRQQ.mjs.map +1 -0
  9. package/dist/{chunk-N4WEHORG.mjs → chunk-6PUNP7CD.mjs} +4 -4
  10. package/dist/chunk-6PUNP7CD.mjs.map +1 -0
  11. package/dist/chunk-7BYHZLPL.mjs +32 -0
  12. package/dist/chunk-7BYHZLPL.mjs.map +1 -0
  13. package/dist/chunk-7DTB7S5V.mjs +83 -0
  14. package/dist/chunk-7DTB7S5V.mjs.map +1 -0
  15. package/dist/chunk-A6NKSGH3.mjs +1 -0
  16. package/dist/{chunk-GT5WI3AF.mjs → chunk-BR5YEYZJ.mjs} +7 -9
  17. package/dist/chunk-BR5YEYZJ.mjs.map +1 -0
  18. package/dist/chunk-CB7CRBDG.mjs +48 -0
  19. package/dist/chunk-CB7CRBDG.mjs.map +1 -0
  20. package/dist/chunk-CYDWEPFL.mjs +1 -0
  21. package/dist/{chunk-BBUQMG45.mjs → chunk-D3QSYDJR.mjs} +3 -3
  22. package/dist/{chunk-BBUQMG45.mjs.map → chunk-D3QSYDJR.mjs.map} +1 -1
  23. package/dist/chunk-DCHSCK62.mjs +549 -0
  24. package/dist/chunk-DCHSCK62.mjs.map +1 -0
  25. package/dist/{chunk-ZLQVRPDS.mjs → chunk-DMLQZG75.mjs} +1 -1
  26. package/dist/chunk-DMLQZG75.mjs.map +1 -0
  27. package/dist/chunk-F555TVE4.mjs +33 -0
  28. package/dist/chunk-F555TVE4.mjs.map +1 -0
  29. package/dist/{chunk-C6IANC2R.mjs → chunk-FBD24VEH.mjs} +7 -43
  30. package/dist/chunk-FBD24VEH.mjs.map +1 -0
  31. package/dist/chunk-FD6FGKYY.mjs +1 -0
  32. package/dist/chunk-FDOMAPJY.mjs +59 -0
  33. package/dist/chunk-FDOMAPJY.mjs.map +1 -0
  34. package/dist/{chunk-X7MJWPI7.mjs → chunk-GMI4KO4X.mjs} +8 -6
  35. package/dist/{chunk-X7MJWPI7.mjs.map → chunk-GMI4KO4X.mjs.map} +1 -1
  36. package/dist/chunk-IUSKVYUI.mjs +13 -0
  37. package/dist/chunk-IUSKVYUI.mjs.map +1 -0
  38. package/dist/chunk-JD7BAH7U.mjs +1 -0
  39. package/dist/{chunk-N5HOP3PG.mjs → chunk-JRT5BJF3.mjs} +2 -2
  40. package/dist/{chunk-N4VN2B5S.mjs → chunk-LHERIF3L.mjs} +2 -2
  41. package/dist/{chunk-DXEQPN43.mjs → chunk-LHKZJ2ND.mjs} +3 -3
  42. package/dist/chunk-NB2FKV2V.mjs +1 -0
  43. package/dist/chunk-NBK4KBLX.mjs +54 -0
  44. package/dist/chunk-NBK4KBLX.mjs.map +1 -0
  45. package/dist/chunk-NG26QEGF.mjs +46 -0
  46. package/dist/chunk-NG26QEGF.mjs.map +1 -0
  47. package/dist/chunk-NROJOTQP.mjs +163 -0
  48. package/dist/chunk-NROJOTQP.mjs.map +1 -0
  49. package/dist/{chunk-MGWRDFBE.mjs → chunk-OVYFRPSN.mjs} +2 -2
  50. package/dist/{chunk-MQYWH4E6.mjs → chunk-QU6NONOD.mjs} +2 -2
  51. package/dist/chunk-R4MR43UQ.mjs +101 -0
  52. package/dist/chunk-R4MR43UQ.mjs.map +1 -0
  53. package/dist/chunk-SPCZTZCY.mjs +1 -0
  54. package/dist/chunk-SPCZTZCY.mjs.map +1 -0
  55. package/dist/chunk-TXI72QHK.mjs +80 -0
  56. package/dist/chunk-TXI72QHK.mjs.map +1 -0
  57. package/dist/chunk-UJBV5GAG.mjs +767 -0
  58. package/dist/chunk-UJBV5GAG.mjs.map +1 -0
  59. package/dist/{chunk-OKCYPO4I.mjs → chunk-WMJVBMUX.mjs} +3 -3
  60. package/dist/{chunk-EUX2P2E7.mjs → chunk-WVLHXIFP.mjs} +11 -9
  61. package/dist/chunk-WVLHXIFP.mjs.map +1 -0
  62. package/dist/{chunk-5FHSUKQL.mjs → chunk-YYN33GSG.mjs} +5 -2
  63. package/dist/chunk-YYN33GSG.mjs.map +1 -0
  64. package/dist/chunk-ZVF5Q6IH.mjs +29 -0
  65. package/dist/chunk-ZVF5Q6IH.mjs.map +1 -0
  66. package/dist/components/CopilotListeners.d.ts +3 -0
  67. package/dist/components/CopilotListeners.js +234 -0
  68. package/dist/components/CopilotListeners.js.map +1 -0
  69. package/dist/components/CopilotListeners.mjs +14 -0
  70. package/dist/components/CopilotListeners.mjs.map +1 -0
  71. package/dist/components/copilot-provider/copilot-messages.js +14 -48
  72. package/dist/components/copilot-provider/copilot-messages.js.map +1 -1
  73. package/dist/components/copilot-provider/copilot-messages.mjs +3 -3
  74. package/dist/components/copilot-provider/copilotkit-props.d.ts +9 -2
  75. package/dist/components/copilot-provider/copilotkit-props.js.map +1 -1
  76. package/dist/components/copilot-provider/copilotkit.d.ts +2 -1
  77. package/dist/components/copilot-provider/copilotkit.js +528 -370
  78. package/dist/components/copilot-provider/copilotkit.js.map +1 -1
  79. package/dist/components/copilot-provider/copilotkit.mjs +17 -12
  80. package/dist/components/copilot-provider/index.d.ts +2 -1
  81. package/dist/components/copilot-provider/index.js +528 -370
  82. package/dist/components/copilot-provider/index.js.map +1 -1
  83. package/dist/components/copilot-provider/index.mjs +18 -12
  84. package/dist/components/dev-console/console-trigger.js +10 -8
  85. package/dist/components/dev-console/console-trigger.js.map +1 -1
  86. package/dist/components/dev-console/console-trigger.mjs +4 -4
  87. package/dist/components/dev-console/developer-console-modal.js +10 -8
  88. package/dist/components/dev-console/developer-console-modal.js.map +1 -1
  89. package/dist/components/dev-console/developer-console-modal.mjs +3 -3
  90. package/dist/components/error-boundary/error-boundary.d.ts +7 -7
  91. package/dist/components/error-boundary/error-boundary.js +3 -3
  92. package/dist/components/error-boundary/error-boundary.js.map +1 -1
  93. package/dist/components/error-boundary/error-boundary.mjs +2 -2
  94. package/dist/components/error-boundary/error-utils.d.ts +1 -1
  95. package/dist/components/error-boundary/error-utils.js +3 -3
  96. package/dist/components/error-boundary/error-utils.js.map +1 -1
  97. package/dist/components/error-boundary/error-utils.mjs +1 -1
  98. package/dist/components/index.d.ts +2 -1
  99. package/dist/components/index.js +528 -370
  100. package/dist/components/index.js.map +1 -1
  101. package/dist/components/index.mjs +19 -12
  102. package/dist/components/toast/exclamation-mark-icon.d.ts +2 -2
  103. package/dist/components/toast/toast-provider.d.ts +3 -3
  104. package/dist/components/usage-banner.d.ts +2 -2
  105. package/dist/context/coagent-state-renders-context.d.ts +24 -0
  106. package/dist/context/coagent-state-renders-context.js +91 -0
  107. package/dist/context/coagent-state-renders-context.js.map +1 -0
  108. package/dist/context/coagent-state-renders-context.mjs +12 -0
  109. package/dist/context/coagent-state-renders-context.mjs.map +1 -0
  110. package/dist/context/copilot-context.d.ts +1 -1
  111. package/dist/context/copilot-context.js +10 -8
  112. package/dist/context/copilot-context.js.map +1 -1
  113. package/dist/context/copilot-context.mjs +1 -1
  114. package/dist/context/copilot-messages-context.d.ts +18 -11
  115. package/dist/context/copilot-messages-context.js.map +1 -1
  116. package/dist/context/copilot-messages-context.mjs +1 -1
  117. package/dist/context/index.d.ts +6 -2
  118. package/dist/context/index.js +110 -10
  119. package/dist/context/index.js.map +1 -1
  120. package/dist/context/index.mjs +20 -4
  121. package/dist/context/threads-context.d.ts +16 -0
  122. package/dist/context/threads-context.js +59 -0
  123. package/dist/context/threads-context.js.map +1 -0
  124. package/dist/context/threads-context.mjs +12 -0
  125. package/dist/context/threads-context.mjs.map +1 -0
  126. package/dist/{copilot-context-cf9de848.d.ts → copilot-context-1cd70a3f.d.ts} +36 -32
  127. package/dist/hooks/index.d.ts +9 -6
  128. package/dist/hooks/index.js +1445 -1839
  129. package/dist/hooks/index.js.map +1 -1
  130. package/dist/hooks/index.mjs +47 -56
  131. package/dist/hooks/use-coagent-state-render-bridge.d.ts +100 -0
  132. package/dist/hooks/use-coagent-state-render-bridge.js +211 -0
  133. package/dist/hooks/use-coagent-state-render-bridge.js.map +1 -0
  134. package/dist/hooks/use-coagent-state-render-bridge.mjs +15 -0
  135. package/dist/hooks/use-coagent-state-render-bridge.mjs.map +1 -0
  136. package/dist/hooks/use-coagent-state-render.js +31 -20
  137. package/dist/hooks/use-coagent-state-render.js.map +1 -1
  138. package/dist/hooks/use-coagent-state-render.mjs +3 -2
  139. package/dist/hooks/use-coagent.d.ts +2 -14
  140. package/dist/hooks/use-coagent.js +109 -1906
  141. package/dist/hooks/use-coagent.js.map +1 -1
  142. package/dist/hooks/use-coagent.mjs +1 -30
  143. package/dist/hooks/use-configure-chat-suggestions.d.ts +36 -0
  144. package/dist/hooks/use-configure-chat-suggestions.js +210 -0
  145. package/dist/hooks/use-configure-chat-suggestions.js.map +1 -0
  146. package/dist/hooks/use-configure-chat-suggestions.mjs +13 -0
  147. package/dist/hooks/use-configure-chat-suggestions.mjs.map +1 -0
  148. package/dist/hooks/use-copilot-action.d.ts +8 -45
  149. package/dist/hooks/use-copilot-action.js +207 -349
  150. package/dist/hooks/use-copilot-action.js.map +1 -1
  151. package/dist/hooks/use-copilot-action.mjs +4 -5
  152. package/dist/hooks/use-copilot-additional-instructions.js +10 -8
  153. package/dist/hooks/use-copilot-additional-instructions.js.map +1 -1
  154. package/dist/hooks/use-copilot-additional-instructions.mjs +2 -2
  155. package/dist/hooks/use-copilot-authenticated-action.js +224 -248
  156. package/dist/hooks/use-copilot-authenticated-action.js.map +1 -1
  157. package/dist/hooks/use-copilot-authenticated-action.mjs +6 -6
  158. package/dist/hooks/use-copilot-chat-headless_c.d.ts +2 -10
  159. package/dist/hooks/use-copilot-chat-headless_c.js +973 -1369
  160. package/dist/hooks/use-copilot-chat-headless_c.js.map +1 -1
  161. package/dist/hooks/use-copilot-chat-headless_c.mjs +12 -22
  162. package/dist/hooks/use-copilot-chat.d.ts +2 -10
  163. package/dist/hooks/use-copilot-chat.js +967 -1388
  164. package/dist/hooks/use-copilot-chat.js.map +1 -1
  165. package/dist/hooks/use-copilot-chat.mjs +12 -22
  166. package/dist/hooks/use-copilot-chat_internal.d.ts +38 -14
  167. package/dist/hooks/use-copilot-chat_internal.js +965 -1362
  168. package/dist/hooks/use-copilot-chat_internal.js.map +1 -1
  169. package/dist/hooks/use-copilot-chat_internal.mjs +13 -23
  170. package/dist/hooks/use-copilot-readable.d.ts +1 -1
  171. package/dist/hooks/use-copilot-readable.js +6 -157
  172. package/dist/hooks/use-copilot-readable.js.map +1 -1
  173. package/dist/hooks/use-copilot-readable.mjs +1 -2
  174. package/dist/hooks/use-default-tool.js +204 -349
  175. package/dist/hooks/use-default-tool.js.map +1 -1
  176. package/dist/hooks/use-default-tool.mjs +5 -6
  177. package/dist/hooks/use-flat-category-store.js +4 -1
  178. package/dist/hooks/use-flat-category-store.js.map +1 -1
  179. package/dist/hooks/use-flat-category-store.mjs +1 -1
  180. package/dist/hooks/use-frontend-tool.d.ts +3 -3
  181. package/dist/hooks/use-frontend-tool.js +30 -370
  182. package/dist/hooks/use-frontend-tool.js.map +1 -1
  183. package/dist/hooks/use-frontend-tool.mjs +1 -6
  184. package/dist/hooks/use-human-in-the-loop.d.ts +4 -3
  185. package/dist/hooks/use-human-in-the-loop.js +61 -393
  186. package/dist/hooks/use-human-in-the-loop.js.map +1 -1
  187. package/dist/hooks/use-human-in-the-loop.mjs +1 -6
  188. package/dist/hooks/use-langgraph-interrupt-render.d.ts +3 -2
  189. package/dist/hooks/use-langgraph-interrupt-render.js +92 -36
  190. package/dist/hooks/use-langgraph-interrupt-render.js.map +1 -1
  191. package/dist/hooks/use-langgraph-interrupt-render.mjs +6 -4
  192. package/dist/hooks/use-langgraph-interrupt.d.ts +1 -1
  193. package/dist/hooks/use-langgraph-interrupt.js +24 -1642
  194. package/dist/hooks/use-langgraph-interrupt.js.map +1 -1
  195. package/dist/hooks/use-langgraph-interrupt.mjs +2 -23
  196. package/dist/hooks/use-lazy-tool-renderer.d.ts +6 -0
  197. package/dist/hooks/use-lazy-tool-renderer.js +53 -0
  198. package/dist/hooks/use-lazy-tool-renderer.js.map +1 -0
  199. package/dist/hooks/use-lazy-tool-renderer.mjs +8 -0
  200. package/dist/hooks/use-lazy-tool-renderer.mjs.map +1 -0
  201. package/dist/hooks/use-make-copilot-document-readable.js +11 -9
  202. package/dist/hooks/use-make-copilot-document-readable.js.map +1 -1
  203. package/dist/hooks/use-make-copilot-document-readable.mjs +2 -2
  204. package/dist/hooks/use-render-tool-call.d.ts +7 -6
  205. package/dist/hooks/use-render-tool-call.js +36 -386
  206. package/dist/hooks/use-render-tool-call.js.map +1 -1
  207. package/dist/hooks/use-render-tool-call.mjs +1 -6
  208. package/dist/index.d.ts +11 -6
  209. package/dist/index.js +1841 -2056
  210. package/dist/index.js.map +1 -1
  211. package/dist/index.mjs +82 -63
  212. package/dist/lib/copilot-task.d.ts +1 -1
  213. package/dist/lib/copilot-task.js +1 -0
  214. package/dist/lib/copilot-task.js.map +1 -1
  215. package/dist/lib/copilot-task.mjs +20 -13
  216. package/dist/lib/index.d.ts +1 -1
  217. package/dist/lib/index.js +1 -0
  218. package/dist/lib/index.js.map +1 -1
  219. package/dist/lib/index.mjs +20 -13
  220. package/dist/setupTests.d.ts +2 -2
  221. package/dist/types/frontend-action.d.ts +5 -5
  222. package/dist/types/index.d.ts +4 -0
  223. package/dist/types/index.js.map +1 -1
  224. package/dist/types/index.mjs +2 -1
  225. package/dist/types/interrupt-action.d.ts +1 -1
  226. package/dist/types/interrupt-action.js.map +1 -1
  227. package/dist/types/interrupt-action.mjs +1 -0
  228. package/dist/utils/index.d.ts +0 -12
  229. package/dist/utils/index.js +6 -325
  230. package/dist/utils/index.js.map +1 -1
  231. package/dist/utils/index.mjs +3 -23
  232. package/dist/utils/utils.js.map +1 -1
  233. package/dist/v2/index.d.ts +2 -0
  234. package/dist/v2/index.js +27 -0
  235. package/dist/v2/index.js.map +1 -0
  236. package/dist/v2/index.mjs +4 -0
  237. package/dist/v2/index.mjs.map +1 -0
  238. package/package.json +34 -23
  239. package/src/components/CopilotListeners.tsx +82 -0
  240. package/src/components/copilot-provider/copilot-messages.tsx +46 -47
  241. package/src/components/copilot-provider/copilotkit-props.tsx +8 -1
  242. package/src/components/copilot-provider/copilotkit.tsx +177 -144
  243. package/src/components/error-boundary/error-utils.tsx +3 -3
  244. package/src/context/coagent-state-renders-context.tsx +76 -0
  245. package/src/context/copilot-context.tsx +21 -21
  246. package/src/context/copilot-messages-context.tsx +3 -3
  247. package/src/context/index.ts +8 -0
  248. package/src/context/threads-context.tsx +41 -0
  249. package/src/hooks/index.ts +7 -3
  250. package/src/hooks/use-coagent-state-render-bridge.tsx +293 -0
  251. package/src/hooks/use-coagent-state-render.ts +4 -7
  252. package/src/hooks/use-coagent.ts +129 -249
  253. package/src/hooks/use-configure-chat-suggestions.tsx +85 -0
  254. package/src/hooks/use-copilot-action.ts +88 -199
  255. package/src/hooks/use-copilot-chat-headless_c.ts +2 -1
  256. package/src/hooks/use-copilot-chat.ts +4 -1
  257. package/src/hooks/use-copilot-chat_internal.ts +349 -258
  258. package/src/hooks/use-copilot-readable.ts +6 -26
  259. package/src/hooks/use-flat-category-store.ts +4 -3
  260. package/src/hooks/use-frontend-tool.ts +67 -8
  261. package/src/hooks/use-human-in-the-loop.ts +111 -13
  262. package/src/hooks/use-langgraph-interrupt-render.ts +90 -40
  263. package/src/hooks/use-langgraph-interrupt.ts +18 -47
  264. package/src/hooks/use-lazy-tool-renderer.tsx +30 -0
  265. package/src/hooks/use-make-copilot-document-readable.ts +1 -1
  266. package/src/hooks/use-render-tool-call.ts +73 -13
  267. package/src/types/index.ts +1 -0
  268. package/src/types/interrupt-action.ts +8 -4
  269. package/src/utils/index.ts +0 -3
  270. package/src/utils/utils.ts +7 -0
  271. package/src/v2/index.ts +2 -0
  272. package/src/v2/styles.css +1 -0
  273. package/tsup.config.ts +1 -1
  274. package/dist/chunk-5FHSUKQL.mjs.map +0 -1
  275. package/dist/chunk-6GPVUMBU.mjs +0 -13
  276. package/dist/chunk-6GPVUMBU.mjs.map +0 -1
  277. package/dist/chunk-AKR2SSUJ.mjs +0 -22
  278. package/dist/chunk-AKR2SSUJ.mjs.map +0 -1
  279. package/dist/chunk-C6IANC2R.mjs.map +0 -1
  280. package/dist/chunk-CI4KD357.mjs +0 -804
  281. package/dist/chunk-CI4KD357.mjs.map +0 -1
  282. package/dist/chunk-DZTU6PGS.mjs +0 -1
  283. package/dist/chunk-EUX2P2E7.mjs.map +0 -1
  284. package/dist/chunk-EVVO67QO.mjs +0 -25
  285. package/dist/chunk-EVVO67QO.mjs.map +0 -1
  286. package/dist/chunk-GT5WI3AF.mjs.map +0 -1
  287. package/dist/chunk-HDOG2RTM.mjs +0 -37
  288. package/dist/chunk-HDOG2RTM.mjs.map +0 -1
  289. package/dist/chunk-N4WEHORG.mjs.map +0 -1
  290. package/dist/chunk-OT5NHMEC.mjs +0 -723
  291. package/dist/chunk-OT5NHMEC.mjs.map +0 -1
  292. package/dist/chunk-QHCLJODF.mjs +0 -332
  293. package/dist/chunk-QHCLJODF.mjs.map +0 -1
  294. package/dist/chunk-QV5SBF2S.mjs +0 -239
  295. package/dist/chunk-QV5SBF2S.mjs.map +0 -1
  296. package/dist/chunk-T3376SZS.mjs +0 -142
  297. package/dist/chunk-T3376SZS.mjs.map +0 -1
  298. package/dist/chunk-U3DQY67T.mjs +0 -71
  299. package/dist/chunk-U3DQY67T.mjs.map +0 -1
  300. package/dist/chunk-YPBKY4KY.mjs +0 -1
  301. package/dist/chunk-YPSGKPDA.mjs +0 -1
  302. package/dist/chunk-ZLQVRPDS.mjs.map +0 -1
  303. package/dist/chunk-ZVOLWJCY.mjs +0 -47
  304. package/dist/chunk-ZVOLWJCY.mjs.map +0 -1
  305. package/dist/hooks/use-chat.d.ts +0 -145
  306. package/dist/hooks/use-chat.js +0 -1129
  307. package/dist/hooks/use-chat.js.map +0 -1
  308. package/dist/hooks/use-chat.mjs +0 -14
  309. package/dist/index-1f5b66ac.d.ts +0 -36
  310. package/dist/utils/extract.d.ts +0 -43
  311. package/dist/utils/extract.js +0 -208
  312. package/dist/utils/extract.js.map +0 -1
  313. package/dist/utils/extract.mjs +0 -25
  314. package/dist/utils/suggestions.d.ts +0 -11
  315. package/dist/utils/suggestions.js +0 -343
  316. package/dist/utils/suggestions.js.map +0 -1
  317. package/dist/utils/suggestions.mjs +0 -25
  318. package/src/hooks/use-chat.ts +0 -1142
  319. package/src/utils/extract.ts +0 -215
  320. package/src/utils/suggestions.ts +0 -208
  321. /package/dist/{chunk-DZTU6PGS.mjs.map → chunk-36KQV2NA.mjs.map} +0 -0
  322. /package/dist/{chunk-U7QULEVO.mjs.map → chunk-3GURHDG7.mjs.map} +0 -0
  323. /package/dist/{chunk-YPBKY4KY.mjs.map → chunk-A6NKSGH3.mjs.map} +0 -0
  324. /package/dist/{chunk-YPSGKPDA.mjs.map → chunk-CYDWEPFL.mjs.map} +0 -0
  325. /package/dist/{hooks/use-chat.mjs.map → chunk-FD6FGKYY.mjs.map} +0 -0
  326. /package/dist/{utils/extract.mjs.map → chunk-JD7BAH7U.mjs.map} +0 -0
  327. /package/dist/{chunk-N5HOP3PG.mjs.map → chunk-JRT5BJF3.mjs.map} +0 -0
  328. /package/dist/{chunk-N4VN2B5S.mjs.map → chunk-LHERIF3L.mjs.map} +0 -0
  329. /package/dist/{chunk-DXEQPN43.mjs.map → chunk-LHKZJ2ND.mjs.map} +0 -0
  330. /package/dist/{utils/suggestions.mjs.map → chunk-NB2FKV2V.mjs.map} +0 -0
  331. /package/dist/{chunk-MGWRDFBE.mjs.map → chunk-OVYFRPSN.mjs.map} +0 -0
  332. /package/dist/{chunk-MQYWH4E6.mjs.map → chunk-QU6NONOD.mjs.map} +0 -0
  333. /package/dist/{chunk-OKCYPO4I.mjs.map → chunk-WMJVBMUX.mjs.map} +0 -0
@@ -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 });
@@ -43,26 +55,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
43
55
  mod
44
56
  ));
45
57
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
46
- var __async = (__this, __arguments, generator) => {
47
- return new Promise((resolve, reject) => {
48
- var fulfilled = (value) => {
49
- try {
50
- step(generator.next(value));
51
- } catch (e) {
52
- reject(e);
53
- }
54
- };
55
- var rejected = (value) => {
56
- try {
57
- step(generator.throw(value));
58
- } catch (e) {
59
- reject(e);
60
- }
61
- };
62
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
63
- step((generator = generator.apply(__this, __arguments)).next());
64
- });
65
- };
66
58
 
67
59
  // src/hooks/use-default-tool.ts
68
60
  var use_default_tool_exports = {};
@@ -72,356 +64,219 @@ __export(use_default_tool_exports, {
72
64
  module.exports = __toCommonJS(use_default_tool_exports);
73
65
 
74
66
  // src/hooks/use-copilot-action.ts
75
- var import_shared2 = require("@copilotkit/shared");
76
- var import_react4 = require("react");
67
+ var import_react7 = require("react");
77
68
 
78
- // src/context/copilot-context.tsx
69
+ // src/hooks/use-frontend-tool.ts
79
70
  var import_react = __toESM(require("react"));
80
- var emptyCopilotContext = {
81
- actions: {},
82
- setAction: () => {
83
- },
84
- removeAction: () => {
85
- },
86
- coAgentStateRenders: {},
87
- setCoAgentStateRender: () => {
88
- },
89
- removeCoAgentStateRender: () => {
90
- },
91
- chatComponentsCache: { current: { actions: {}, coAgentStateRenders: {} } },
92
- getContextString: (documents, categories) => returnAndThrowInDebug(""),
93
- addContext: () => "",
94
- removeContext: () => {
95
- },
96
- getAllContext: () => [],
97
- getFunctionCallHandler: () => returnAndThrowInDebug(() => __async(void 0, null, function* () {
98
- })),
99
- isLoading: false,
100
- setIsLoading: () => returnAndThrowInDebug(false),
101
- chatInstructions: "",
102
- setChatInstructions: () => returnAndThrowInDebug(""),
103
- additionalInstructions: [],
104
- setAdditionalInstructions: () => returnAndThrowInDebug([]),
105
- getDocumentsContext: (categories) => returnAndThrowInDebug([]),
106
- addDocumentContext: () => returnAndThrowInDebug(""),
107
- removeDocumentContext: () => {
108
- },
109
- runtimeClient: {},
110
- copilotApiConfig: new class {
111
- get chatApiEndpoint() {
112
- throw new Error("Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!");
113
- }
114
- get headers() {
115
- return {};
71
+ var import_shared = require("@copilotkit/shared");
72
+ var import_shared2 = require("@copilotkit/shared");
73
+ var import_react2 = require("@copilotkitnext/react");
74
+ function useFrontendTool(tool, dependencies) {
75
+ const { name, description, parameters, render, followUp } = tool;
76
+ const zodParameters = (0, import_shared.getZodParameters)(parameters);
77
+ const normalizedRender = (() => {
78
+ if (typeof render === "undefined") {
79
+ return void 0;
116
80
  }
117
- get body() {
118
- return {};
81
+ if (typeof render === "string") {
82
+ const staticRender = render;
83
+ return () => import_react.default.createElement(import_react.default.Fragment, null, staticRender);
119
84
  }
120
- }(),
121
- chatSuggestionConfiguration: {},
122
- addChatSuggestionConfiguration: () => {
123
- },
124
- removeChatSuggestionConfiguration: () => {
125
- },
126
- showDevConsole: false,
127
- coagentStates: {},
128
- setCoagentStates: () => {
129
- },
130
- coagentStatesRef: { current: {} },
131
- setCoagentStatesWithRef: () => {
132
- },
133
- agentSession: null,
134
- setAgentSession: () => {
135
- },
136
- forwardedParameters: {},
137
- agentLock: null,
138
- threadId: "",
139
- setThreadId: () => {
140
- },
141
- runId: null,
142
- setRunId: () => {
143
- },
144
- chatAbortControllerRef: { current: null },
145
- availableAgents: [],
146
- extensions: {},
147
- setExtensions: () => {
148
- },
149
- langGraphInterruptAction: null,
150
- setLangGraphInterruptAction: () => {
151
- },
152
- removeLangGraphInterruptAction: () => {
153
- },
154
- onError: () => {
155
- },
156
- bannerError: null,
157
- setBannerError: () => {
158
- },
159
- internalErrorHandlers: {},
160
- setInternalErrorHandler: () => {
161
- },
162
- removeInternalErrorHandler: () => {
163
- }
164
- };
165
- var CopilotContext = import_react.default.createContext(emptyCopilotContext);
166
- function useCopilotContext() {
167
- const context = import_react.default.useContext(CopilotContext);
168
- if (context === emptyCopilotContext) {
169
- throw new Error("Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!");
170
- }
171
- return context;
172
- }
173
- function returnAndThrowInDebug(_value) {
174
- throw new Error("Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!");
85
+ return (args) => {
86
+ const renderArgs = __spreadProps(__spreadValues({}, args), {
87
+ result: typeof args.result === "string" ? (0, import_shared2.parseJson)(args.result, args.result) : args.result
88
+ });
89
+ const rendered = render(renderArgs);
90
+ if (typeof rendered === "string") {
91
+ return import_react.default.createElement(import_react.default.Fragment, null, rendered);
92
+ }
93
+ return rendered != null ? rendered : null;
94
+ };
95
+ })();
96
+ (0, import_react2.useFrontendTool)({
97
+ name,
98
+ description,
99
+ parameters: zodParameters,
100
+ handler: tool.handler,
101
+ followUp,
102
+ render: normalizedRender
103
+ });
175
104
  }
176
105
 
177
- // src/components/error-boundary/error-utils.tsx
106
+ // src/hooks/use-render-tool-call.ts
107
+ var import_shared3 = require("@copilotkit/shared");
178
108
  var import_react3 = require("react");
179
-
180
- // src/components/toast/toast-provider.tsx
181
- var import_react2 = require("react");
182
- var import_shared = require("@copilotkit/shared");
183
- var import_jsx_runtime = require("react/jsx-runtime");
184
- var ToastContext = (0, import_react2.createContext)(void 0);
185
- function useToast() {
186
- const context = (0, import_react2.useContext)(ToastContext);
187
- if (!context) {
188
- throw new Error("useToast must be used within a ToastProvider");
189
- }
190
- return context;
191
- }
192
-
193
- // src/components/toast/exclamation-mark-icon.tsx
194
- var import_jsx_runtime2 = require("react/jsx-runtime");
195
- var ExclamationMarkIcon = ({
196
- className,
197
- style
198
- }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
199
- "svg",
200
- {
201
- xmlns: "http://www.w3.org/2000/svg",
202
- width: "24",
203
- height: "24",
204
- viewBox: "0 0 24 24",
205
- fill: "none",
206
- stroke: "currentColor",
207
- strokeWidth: "2",
208
- strokeLinecap: "round",
209
- strokeLinejoin: "round",
210
- className: `lucide lucide-circle-alert ${className ? className : ""}`,
211
- style,
212
- children: [
213
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
214
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "12", x2: "12", y1: "8", y2: "12" }),
215
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "12", x2: "12.01", y1: "16", y2: "16" })
216
- ]
217
- }
218
- );
219
-
220
- // src/components/error-boundary/error-utils.tsx
221
- var import_react_markdown = __toESM(require("react-markdown"));
222
- var import_jsx_runtime3 = require("react/jsx-runtime");
223
- function ErrorToast({ errors }) {
224
- const errorsToRender = errors.map((error, idx) => {
225
- var _a, _b, _c;
226
- const originalError = "extensions" in error ? (_a = error.extensions) == null ? void 0 : _a.originalError : {};
227
- const message = (_b = originalError == null ? void 0 : originalError.message) != null ? _b : error.message;
228
- const code = "extensions" in error ? (_c = error.extensions) == null ? void 0 : _c.code : null;
229
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
230
- "div",
231
- {
232
- style: {
233
- marginTop: idx === 0 ? 0 : 10,
234
- marginBottom: 14
235
- },
236
- children: [
237
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ExclamationMarkIcon, { style: { marginBottom: 4 } }),
238
- code && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
239
- "div",
240
- {
241
- style: {
242
- fontWeight: "600",
243
- marginBottom: 4
244
- },
245
- children: [
246
- "Copilot Runtime Error:",
247
- " ",
248
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { fontFamily: "monospace", fontWeight: "normal" }, children: code })
249
- ]
250
- }
251
- ),
252
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_markdown.default, { children: message })
253
- ]
254
- },
255
- idx
256
- );
257
- });
258
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
259
- "div",
260
- {
261
- style: {
262
- fontSize: "13px",
263
- maxWidth: "600px"
264
- },
265
- children: [
266
- errorsToRender,
267
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { fontSize: "11px", opacity: 0.75 }, children: "NOTE: This error only displays during local development." })
268
- ]
269
- }
270
- );
271
- }
272
- function useErrorToast() {
273
- const { addToast } = useToast();
274
- return (0, import_react3.useCallback)(
275
- (error) => {
276
- const errorId = error.map((err) => {
277
- var _a, _b;
278
- const message = "extensions" in err ? ((_b = (_a = err.extensions) == null ? void 0 : _a.originalError) == null ? void 0 : _b.message) || err.message : err.message;
279
- const stack = err.stack || "";
280
- return btoa(message + stack).slice(0, 32);
281
- }).join("|");
282
- addToast({
283
- type: "error",
284
- id: errorId,
285
- // Toast libraries typically dedupe by id
286
- message: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ErrorToast, { errors: error })
287
- });
288
- },
289
- [addToast]
290
- );
291
- }
292
- function useAsyncCallback(callback, deps) {
293
- const addErrorToast = useErrorToast();
294
- return (0, import_react3.useCallback)((...args) => __async(this, null, function* () {
295
- try {
296
- return yield callback(...args);
297
- } catch (error) {
298
- console.error("Error in async callback:", error);
299
- addErrorToast([error]);
300
- throw error;
109
+ var import_react4 = require("@copilotkitnext/react");
110
+ var import_shared4 = require("@copilotkit/shared");
111
+ function useRenderToolCall(tool, dependencies) {
112
+ const { copilotkit } = (0, import_react4.useCopilotKit)();
113
+ const hasAddedRef = (0, import_react3.useRef)(false);
114
+ (0, import_react3.useEffect)(() => {
115
+ const { name, parameters, render } = tool;
116
+ const zodParameters = (0, import_shared3.getZodParameters)(parameters);
117
+ const renderToolCall = name === "*" ? (0, import_react4.defineToolCallRenderer)({
118
+ name: "*",
119
+ render: (args) => {
120
+ return render(__spreadProps(__spreadValues({}, args), {
121
+ result: args.result ? (0, import_shared4.parseJson)(args.result, args.result) : args.result
122
+ }));
123
+ }
124
+ }) : (0, import_react4.defineToolCallRenderer)({
125
+ name,
126
+ args: zodParameters,
127
+ render: (args) => {
128
+ return render(__spreadProps(__spreadValues({}, args), {
129
+ result: args.result ? (0, import_shared4.parseJson)(args.result, args.result) : args.result
130
+ }));
131
+ }
132
+ });
133
+ const existingIndex = copilotkit.renderToolCalls.findIndex((r) => r.name === name);
134
+ if (existingIndex !== -1) {
135
+ copilotkit.renderToolCalls.splice(existingIndex, 1);
301
136
  }
302
- }), deps);
137
+ copilotkit.renderToolCalls.push(renderToolCall);
138
+ hasAddedRef.current = true;
139
+ return () => {
140
+ if (hasAddedRef.current) {
141
+ const index = copilotkit.renderToolCalls.findIndex((r) => r.name === name);
142
+ if (index !== -1) {
143
+ copilotkit.renderToolCalls.splice(index, 1);
144
+ }
145
+ hasAddedRef.current = false;
146
+ }
147
+ };
148
+ }, [tool, ...dependencies != null ? dependencies : []]);
303
149
  }
304
150
 
305
- // src/hooks/use-copilot-action.ts
306
- function useCopilotAction(action, dependencies) {
307
- const { setAction, removeAction, actions, chatComponentsCache } = useCopilotContext();
308
- const idRef = (0, import_react4.useRef)((0, import_shared2.randomId)());
309
- const renderAndWaitRef = (0, import_react4.useRef)(null);
310
- const activatingMessageIdRef = (0, import_react4.useRef)(null);
311
- const { addToast } = useToast();
312
- action = __spreadValues({}, action);
313
- if (
314
- // renderAndWaitForResponse is not available for catch all actions
315
- isFrontendAction(action) && // check if renderAndWaitForResponse is set
316
- (action.renderAndWait || action.renderAndWaitForResponse)
317
- ) {
318
- action._isRenderAndWait = true;
319
- const renderAndWait = action.renderAndWait || action.renderAndWaitForResponse;
320
- action.renderAndWait = void 0;
321
- action.renderAndWaitForResponse = void 0;
322
- action._setActivatingMessageId = (id) => {
323
- activatingMessageIdRef.current = id;
324
- };
325
- action.handler = useAsyncCallback(() => __async(this, null, function* () {
326
- const currentActivatingId = activatingMessageIdRef.current;
327
- let resolve;
328
- let reject;
329
- const promise = new Promise((resolvePromise, rejectPromise) => {
330
- resolve = resolvePromise;
331
- reject = rejectPromise;
332
- });
333
- renderAndWaitRef.current = {
334
- promise,
335
- resolve,
336
- reject,
337
- messageId: currentActivatingId
338
- };
339
- const result = yield promise;
340
- return result;
341
- }), []);
342
- action.render = (props) => {
343
- const currentRenderMessageId = props.messageId;
344
- let status = props.status;
345
- if (props.status === "executing") {
346
- if (!renderAndWaitRef.current || !renderAndWaitRef.current.promise) {
347
- status = "inProgress";
348
- } else if (renderAndWaitRef.current.messageId !== currentRenderMessageId && activatingMessageIdRef.current !== currentRenderMessageId) {
349
- status = "inProgress";
350
- }
151
+ // src/hooks/use-human-in-the-loop.ts
152
+ var import_shared5 = require("@copilotkit/shared");
153
+ var import_react5 = require("@copilotkitnext/react");
154
+ var import_core = require("@copilotkitnext/core");
155
+ var import_react6 = __toESM(require("react"));
156
+ function useHumanInTheLoop(tool, dependencies) {
157
+ const _a = tool, { render } = _a, toolRest = __objRest(_a, ["render"]);
158
+ const { name, description, parameters, followUp } = toolRest;
159
+ const zodParameters = (0, import_shared5.getZodParameters)(parameters);
160
+ const renderRef = (0, import_react6.useRef)(null);
161
+ (0, import_react6.useEffect)(() => {
162
+ renderRef.current = (args) => {
163
+ if (typeof render === "string") {
164
+ return import_react6.default.createElement(import_react6.default.Fragment, null, render);
351
165
  }
352
- const waitProps = {
353
- status,
354
- args: props.args,
355
- result: props.result,
356
- // handler and respond should only be provided if this is the truly active instance
357
- // and its promise infrastructure is ready.
358
- handler: status === "executing" && renderAndWaitRef.current && renderAndWaitRef.current.messageId === currentRenderMessageId ? renderAndWaitRef.current.resolve : void 0,
359
- respond: status === "executing" && renderAndWaitRef.current && renderAndWaitRef.current.messageId === currentRenderMessageId ? renderAndWaitRef.current.resolve : void 0
360
- };
361
- const isNoArgsRenderWait = (_fn) => {
362
- var _a;
363
- return ((_a = action.parameters) == null ? void 0 : _a.length) === 0;
364
- };
365
- if (renderAndWait) {
366
- if (isNoArgsRenderWait(renderAndWait)) {
367
- return renderAndWait(waitProps);
368
- } else {
369
- return renderAndWait(waitProps);
166
+ if (!render) {
167
+ return null;
168
+ }
169
+ const renderProps = (() => {
170
+ const mappedArgs = args.args;
171
+ switch (args.status) {
172
+ case import_core.ToolCallStatus.InProgress:
173
+ return {
174
+ args: mappedArgs,
175
+ respond: args.respond,
176
+ status: args.status,
177
+ handler: void 0
178
+ };
179
+ case import_core.ToolCallStatus.Executing:
180
+ return {
181
+ args: mappedArgs,
182
+ respond: args.respond,
183
+ status: args.status,
184
+ handler: () => {
185
+ }
186
+ };
187
+ case import_core.ToolCallStatus.Complete:
188
+ return {
189
+ args: mappedArgs,
190
+ respond: args.respond,
191
+ status: args.status,
192
+ result: args.result ? (0, import_shared5.parseJson)(args.result, args.result) : args.result,
193
+ handler: void 0
194
+ };
195
+ default:
196
+ throw new import_shared5.CopilotKitError({
197
+ code: import_shared5.CopilotKitErrorCode.UNKNOWN,
198
+ message: `Invalid tool call status: ${args.status}`
199
+ });
370
200
  }
201
+ })();
202
+ const rendered = render(renderProps);
203
+ if (typeof rendered === "string") {
204
+ return import_react6.default.createElement(import_react6.default.Fragment, null, rendered);
371
205
  }
372
- return (0, import_react4.createElement)(import_react4.Fragment);
206
+ return rendered != null ? rendered : null;
207
+ };
208
+ }, [render, ...dependencies != null ? dependencies : []]);
209
+ (0, import_react5.useHumanInTheLoop)({
210
+ name,
211
+ description,
212
+ followUp,
213
+ parameters: zodParameters,
214
+ render: (args) => {
215
+ var _a2, _b;
216
+ return (_b = (_a2 = renderRef.current) == null ? void 0 : _a2.call(renderRef, args)) != null ? _b : null;
217
+ }
218
+ });
219
+ }
220
+
221
+ // src/hooks/use-copilot-action.ts
222
+ function getActionConfig(action) {
223
+ if (action.name === "*") {
224
+ return {
225
+ type: "render",
226
+ action
373
227
  };
374
228
  }
375
- if (dependencies === void 0) {
376
- if (actions[idRef.current]) {
377
- if (isFrontendAction(action)) {
378
- actions[idRef.current].handler = action.handler;
379
- }
380
- if (typeof action.render === "function") {
381
- if (chatComponentsCache.current !== null) {
382
- chatComponentsCache.current.actions[action.name] = action.render;
383
- }
384
- }
229
+ if ("renderAndWaitForResponse" in action || "renderAndWait" in action) {
230
+ let render = action.render;
231
+ if (!render && "renderAndWaitForResponse" in action) {
232
+ render = action.renderAndWaitForResponse;
233
+ }
234
+ if (!render && "renderAndWait" in action) {
235
+ render = action.renderAndWait;
385
236
  }
237
+ return {
238
+ type: "hitl",
239
+ action: __spreadProps(__spreadValues({}, action), { render })
240
+ };
386
241
  }
387
- (0, import_react4.useEffect)(() => {
388
- const hasDuplicate = Object.values(actions).some(
389
- (otherAction) => otherAction.name === action.name && otherAction !== actions[idRef.current]
390
- );
391
- if (hasDuplicate) {
392
- addToast({
393
- type: "warning",
394
- message: `Found an already registered action with name ${action.name}.`,
395
- id: `dup-action-${action.name}`
396
- });
242
+ if ("available" in action) {
243
+ if (action.available === "enabled" || action.available === "remote") {
244
+ return {
245
+ type: "frontend",
246
+ action
247
+ };
397
248
  }
398
- }, [actions]);
399
- (0, import_react4.useEffect)(() => {
400
- setAction(idRef.current, action);
401
- if (chatComponentsCache.current !== null && action.render !== void 0) {
402
- chatComponentsCache.current.actions[action.name] = action.render;
249
+ if (action.available === "frontend" || action.available === "disabled") {
250
+ return {
251
+ type: "render",
252
+ action
253
+ };
403
254
  }
404
- return () => {
405
- removeAction(idRef.current);
255
+ }
256
+ if ("handler" in action) {
257
+ return {
258
+ type: "frontend",
259
+ action
406
260
  };
407
- }, [
408
- setAction,
409
- removeAction,
410
- isFrontendAction(action) ? action.description : void 0,
411
- action.name,
412
- isFrontendAction(action) ? action.disabled : void 0,
413
- isFrontendAction(action) ? action.available : void 0,
414
- // This should be faster than deep equality checking
415
- // In addition, all major JS engines guarantee the order of object keys
416
- JSON.stringify(isFrontendAction(action) ? action.parameters : []),
417
- // include render only if it's a string
418
- typeof action.render === "string" ? action.render : void 0,
419
- // dependencies set by the developer
420
- ...dependencies || []
421
- ]);
261
+ }
262
+ throw new Error("Invalid action configuration");
422
263
  }
423
- function isFrontendAction(action) {
424
- return action.name !== "*";
264
+ function useCopilotAction(action, dependencies) {
265
+ const [initialActionConfig] = (0, import_react7.useState)(getActionConfig(action));
266
+ const currentActionConfig = getActionConfig(action);
267
+ if (initialActionConfig.type !== currentActionConfig.type) {
268
+ throw new Error("Action configuration changed between renders");
269
+ }
270
+ switch (currentActionConfig.type) {
271
+ case "render":
272
+ return useRenderToolCall(currentActionConfig.action, dependencies);
273
+ case "hitl":
274
+ return useHumanInTheLoop(currentActionConfig.action, dependencies);
275
+ case "frontend":
276
+ return useFrontendTool(currentActionConfig.action, dependencies);
277
+ default:
278
+ throw new Error("Invalid action configuration");
279
+ }
425
280
  }
426
281
 
427
282
  // src/hooks/use-default-tool.ts