@copilotkit/react-core 0.0.0-0.0.0-max-changeset-10101010101010-20260109191632

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 (497) hide show
  1. package/CHANGELOG.md +4188 -0
  2. package/LICENSE +21 -0
  3. package/README.md +141 -0
  4. package/dist/chunk-2IDV5OHF.mjs +11 -0
  5. package/dist/chunk-2IDV5OHF.mjs.map +1 -0
  6. package/dist/chunk-336QEM3A.mjs +349 -0
  7. package/dist/chunk-336QEM3A.mjs.map +1 -0
  8. package/dist/chunk-36KQV2NA.mjs +1 -0
  9. package/dist/chunk-36KQV2NA.mjs.map +1 -0
  10. package/dist/chunk-3MHWEKFN.mjs +759 -0
  11. package/dist/chunk-3MHWEKFN.mjs.map +1 -0
  12. package/dist/chunk-4CEQJ2X6.mjs +31 -0
  13. package/dist/chunk-4CEQJ2X6.mjs.map +1 -0
  14. package/dist/chunk-4RRMC7L2.mjs +32 -0
  15. package/dist/chunk-4RRMC7L2.mjs.map +1 -0
  16. package/dist/chunk-6ESSSQ7Q.mjs +134 -0
  17. package/dist/chunk-6ESSSQ7Q.mjs.map +1 -0
  18. package/dist/chunk-6PUNP7CD.mjs +102 -0
  19. package/dist/chunk-6PUNP7CD.mjs.map +1 -0
  20. package/dist/chunk-6YOKPWQ7.mjs +1 -0
  21. package/dist/chunk-6YOKPWQ7.mjs.map +1 -0
  22. package/dist/chunk-6ZLPNY7X.mjs +225 -0
  23. package/dist/chunk-6ZLPNY7X.mjs.map +1 -0
  24. package/dist/chunk-7DTB7S5V.mjs +83 -0
  25. package/dist/chunk-7DTB7S5V.mjs.map +1 -0
  26. package/dist/chunk-7IBF6RBW.mjs +23 -0
  27. package/dist/chunk-7IBF6RBW.mjs.map +1 -0
  28. package/dist/chunk-7X3E6GHT.mjs +83 -0
  29. package/dist/chunk-7X3E6GHT.mjs.map +1 -0
  30. package/dist/chunk-A6NKSGH3.mjs +1 -0
  31. package/dist/chunk-A6NKSGH3.mjs.map +1 -0
  32. package/dist/chunk-ABWT4DRT.mjs +24 -0
  33. package/dist/chunk-ABWT4DRT.mjs.map +1 -0
  34. package/dist/chunk-AFNWX62Q.mjs +110 -0
  35. package/dist/chunk-AFNWX62Q.mjs.map +1 -0
  36. package/dist/chunk-BUSWSDYO.mjs +17 -0
  37. package/dist/chunk-BUSWSDYO.mjs.map +1 -0
  38. package/dist/chunk-CDUIA2WM.mjs +60 -0
  39. package/dist/chunk-CDUIA2WM.mjs.map +1 -0
  40. package/dist/chunk-CYDWEPFL.mjs +1 -0
  41. package/dist/chunk-CYDWEPFL.mjs.map +1 -0
  42. package/dist/chunk-DMLQZG75.mjs +25 -0
  43. package/dist/chunk-DMLQZG75.mjs.map +1 -0
  44. package/dist/chunk-E7SE25ZU.mjs +59 -0
  45. package/dist/chunk-E7SE25ZU.mjs.map +1 -0
  46. package/dist/chunk-EFL5OBKN.mjs +310 -0
  47. package/dist/chunk-EFL5OBKN.mjs.map +1 -0
  48. package/dist/chunk-F555TVE4.mjs +33 -0
  49. package/dist/chunk-F555TVE4.mjs.map +1 -0
  50. package/dist/chunk-FD6FGKYY.mjs +1 -0
  51. package/dist/chunk-FD6FGKYY.mjs.map +1 -0
  52. package/dist/chunk-FDOMAPJY.mjs +59 -0
  53. package/dist/chunk-FDOMAPJY.mjs.map +1 -0
  54. package/dist/chunk-GJOR3RI6.mjs +120 -0
  55. package/dist/chunk-GJOR3RI6.mjs.map +1 -0
  56. package/dist/chunk-GPEJNVE5.mjs +80 -0
  57. package/dist/chunk-GPEJNVE5.mjs.map +1 -0
  58. package/dist/chunk-HM6ON7AM.mjs +86 -0
  59. package/dist/chunk-HM6ON7AM.mjs.map +1 -0
  60. package/dist/chunk-I76HKHPJ.mjs +32 -0
  61. package/dist/chunk-I76HKHPJ.mjs.map +1 -0
  62. package/dist/chunk-ICIK2BSB.mjs +17 -0
  63. package/dist/chunk-ICIK2BSB.mjs.map +1 -0
  64. package/dist/chunk-JD7BAH7U.mjs +1 -0
  65. package/dist/chunk-JD7BAH7U.mjs.map +1 -0
  66. package/dist/chunk-LUGEI4YQ.mjs +1 -0
  67. package/dist/chunk-LUGEI4YQ.mjs.map +1 -0
  68. package/dist/chunk-N7FZFIWO.mjs +551 -0
  69. package/dist/chunk-N7FZFIWO.mjs.map +1 -0
  70. package/dist/chunk-NB2FKV2V.mjs +1 -0
  71. package/dist/chunk-NB2FKV2V.mjs.map +1 -0
  72. package/dist/chunk-NBK4KBLX.mjs +54 -0
  73. package/dist/chunk-NBK4KBLX.mjs.map +1 -0
  74. package/dist/chunk-O7ARI5CV.mjs +31 -0
  75. package/dist/chunk-O7ARI5CV.mjs.map +1 -0
  76. package/dist/chunk-P2YEE2ZI.mjs +36 -0
  77. package/dist/chunk-P2YEE2ZI.mjs.map +1 -0
  78. package/dist/chunk-PIF5KJYI.mjs +103 -0
  79. package/dist/chunk-PIF5KJYI.mjs.map +1 -0
  80. package/dist/chunk-PMAFHQ7P.mjs +65 -0
  81. package/dist/chunk-PMAFHQ7P.mjs.map +1 -0
  82. package/dist/chunk-QNUAXSDP.mjs +166 -0
  83. package/dist/chunk-QNUAXSDP.mjs.map +1 -0
  84. package/dist/chunk-RKTVJRK7.mjs +143 -0
  85. package/dist/chunk-RKTVJRK7.mjs.map +1 -0
  86. package/dist/chunk-SKC7AJIV.mjs +61 -0
  87. package/dist/chunk-SKC7AJIV.mjs.map +1 -0
  88. package/dist/chunk-SPCZTZCY.mjs +1 -0
  89. package/dist/chunk-SPCZTZCY.mjs.map +1 -0
  90. package/dist/chunk-SQDOUMPZ.mjs +125 -0
  91. package/dist/chunk-SQDOUMPZ.mjs.map +1 -0
  92. package/dist/chunk-WF65O6HX.mjs +66 -0
  93. package/dist/chunk-WF65O6HX.mjs.map +1 -0
  94. package/dist/chunk-XDFVCQD3.mjs +27 -0
  95. package/dist/chunk-XDFVCQD3.mjs.map +1 -0
  96. package/dist/chunk-YJ2KZDZJ.mjs +186 -0
  97. package/dist/chunk-YJ2KZDZJ.mjs.map +1 -0
  98. package/dist/chunk-YTQHRJUA.mjs +86 -0
  99. package/dist/chunk-YTQHRJUA.mjs.map +1 -0
  100. package/dist/chunk-YYN33GSG.mjs +73 -0
  101. package/dist/chunk-YYN33GSG.mjs.map +1 -0
  102. package/dist/chunk-Z6JV2LRY.mjs +37 -0
  103. package/dist/chunk-Z6JV2LRY.mjs.map +1 -0
  104. package/dist/chunk-ZVF5Q6IH.mjs +29 -0
  105. package/dist/chunk-ZVF5Q6IH.mjs.map +1 -0
  106. package/dist/chunk-ZYTXB6HH.mjs +151 -0
  107. package/dist/chunk-ZYTXB6HH.mjs.map +1 -0
  108. package/dist/components/CopilotListeners.d.ts +3 -0
  109. package/dist/components/CopilotListeners.js +101 -0
  110. package/dist/components/CopilotListeners.js.map +1 -0
  111. package/dist/components/CopilotListeners.mjs +9 -0
  112. package/dist/components/CopilotListeners.mjs.map +1 -0
  113. package/dist/components/copilot-provider/copilot-messages.d.ts +24 -0
  114. package/dist/components/copilot-provider/copilot-messages.js +351 -0
  115. package/dist/components/copilot-provider/copilot-messages.js.map +1 -0
  116. package/dist/components/copilot-provider/copilot-messages.mjs +16 -0
  117. package/dist/components/copilot-provider/copilot-messages.mjs.map +1 -0
  118. package/dist/components/copilot-provider/copilotkit-props.d.ts +160 -0
  119. package/dist/components/copilot-provider/copilotkit-props.js +19 -0
  120. package/dist/components/copilot-provider/copilotkit-props.js.map +1 -0
  121. package/dist/components/copilot-provider/copilotkit-props.mjs +1 -0
  122. package/dist/components/copilot-provider/copilotkit-props.mjs.map +1 -0
  123. package/dist/components/copilot-provider/copilotkit.d.ts +19 -0
  124. package/dist/components/copilot-provider/copilotkit.js +1960 -0
  125. package/dist/components/copilot-provider/copilotkit.js.map +1 -0
  126. package/dist/components/copilot-provider/copilotkit.mjs +31 -0
  127. package/dist/components/copilot-provider/copilotkit.mjs.map +1 -0
  128. package/dist/components/copilot-provider/index.d.ts +14 -0
  129. package/dist/components/copilot-provider/index.js +1960 -0
  130. package/dist/components/copilot-provider/index.js.map +1 -0
  131. package/dist/components/copilot-provider/index.mjs +30 -0
  132. package/dist/components/copilot-provider/index.mjs.map +1 -0
  133. package/dist/components/dev-console/console-trigger.d.ts +8 -0
  134. package/dist/components/dev-console/console-trigger.js +1202 -0
  135. package/dist/components/dev-console/console-trigger.js.map +1 -0
  136. package/dist/components/dev-console/console-trigger.mjs +233 -0
  137. package/dist/components/dev-console/console-trigger.mjs.map +1 -0
  138. package/dist/components/dev-console/developer-console-modal.d.ts +10 -0
  139. package/dist/components/dev-console/developer-console-modal.js +987 -0
  140. package/dist/components/dev-console/developer-console-modal.js.map +1 -0
  141. package/dist/components/dev-console/developer-console-modal.mjs +12 -0
  142. package/dist/components/dev-console/developer-console-modal.mjs.map +1 -0
  143. package/dist/components/dev-console/icons.d.ts +9 -0
  144. package/dist/components/dev-console/icons.js +131 -0
  145. package/dist/components/dev-console/icons.js.map +1 -0
  146. package/dist/components/dev-console/icons.mjs +16 -0
  147. package/dist/components/dev-console/icons.mjs.map +1 -0
  148. package/dist/components/error-boundary/error-boundary.d.ts +31 -0
  149. package/dist/components/error-boundary/error-boundary.js +500 -0
  150. package/dist/components/error-boundary/error-boundary.js.map +1 -0
  151. package/dist/components/error-boundary/error-boundary.mjs +15 -0
  152. package/dist/components/error-boundary/error-boundary.mjs.map +1 -0
  153. package/dist/components/error-boundary/error-utils.d.ts +11 -0
  154. package/dist/components/error-boundary/error-utils.js +190 -0
  155. package/dist/components/error-boundary/error-utils.js.map +1 -0
  156. package/dist/components/error-boundary/error-utils.mjs +14 -0
  157. package/dist/components/error-boundary/error-utils.mjs.map +1 -0
  158. package/dist/components/index.d.ts +14 -0
  159. package/dist/components/index.js +1960 -0
  160. package/dist/components/index.js.map +1 -0
  161. package/dist/components/index.mjs +31 -0
  162. package/dist/components/index.mjs.map +1 -0
  163. package/dist/components/toast/exclamation-mark-icon.d.ts +9 -0
  164. package/dist/components/toast/exclamation-mark-icon.js +55 -0
  165. package/dist/components/toast/exclamation-mark-icon.js.map +1 -0
  166. package/dist/components/toast/exclamation-mark-icon.mjs +8 -0
  167. package/dist/components/toast/exclamation-mark-icon.mjs.map +1 -0
  168. package/dist/components/toast/toast-provider.d.ts +27 -0
  169. package/dist/components/toast/toast-provider.js +347 -0
  170. package/dist/components/toast/toast-provider.js.map +1 -0
  171. package/dist/components/toast/toast-provider.mjs +10 -0
  172. package/dist/components/toast/toast-provider.mjs.map +1 -0
  173. package/dist/components/usage-banner.d.ts +29 -0
  174. package/dist/components/usage-banner.js +247 -0
  175. package/dist/components/usage-banner.js.map +1 -0
  176. package/dist/components/usage-banner.mjs +12 -0
  177. package/dist/components/usage-banner.mjs.map +1 -0
  178. package/dist/context/coagent-state-renders-context.d.ts +24 -0
  179. package/dist/context/coagent-state-renders-context.js +91 -0
  180. package/dist/context/coagent-state-renders-context.js.map +1 -0
  181. package/dist/context/coagent-state-renders-context.mjs +12 -0
  182. package/dist/context/coagent-state-renders-context.mjs.map +1 -0
  183. package/dist/context/copilot-context.d.ts +10 -0
  184. package/dist/context/copilot-context.js +161 -0
  185. package/dist/context/copilot-context.js.map +1 -0
  186. package/dist/context/copilot-context.mjs +10 -0
  187. package/dist/context/copilot-context.mjs.map +1 -0
  188. package/dist/context/copilot-messages-context.d.ts +18 -0
  189. package/dist/context/copilot-messages-context.js +60 -0
  190. package/dist/context/copilot-messages-context.js.map +1 -0
  191. package/dist/context/copilot-messages-context.mjs +10 -0
  192. package/dist/context/copilot-messages-context.mjs.map +1 -0
  193. package/dist/context/index.d.ts +15 -0
  194. package/dist/context/index.js +285 -0
  195. package/dist/context/index.js.map +1 -0
  196. package/dist/context/index.mjs +33 -0
  197. package/dist/context/index.mjs.map +1 -0
  198. package/dist/context/threads-context.d.ts +16 -0
  199. package/dist/context/threads-context.js +59 -0
  200. package/dist/context/threads-context.js.map +1 -0
  201. package/dist/context/threads-context.mjs +12 -0
  202. package/dist/context/threads-context.mjs.map +1 -0
  203. package/dist/copilot-context-ec77e921.d.ts +209 -0
  204. package/dist/hooks/index.d.ts +33 -0
  205. package/dist/hooks/index.js +1774 -0
  206. package/dist/hooks/index.js.map +1 -0
  207. package/dist/hooks/index.mjs +91 -0
  208. package/dist/hooks/index.mjs.map +1 -0
  209. package/dist/hooks/use-agent-nodename.d.ts +3 -0
  210. package/dist/hooks/use-agent-nodename.js +56 -0
  211. package/dist/hooks/use-agent-nodename.js.map +1 -0
  212. package/dist/hooks/use-agent-nodename.mjs +8 -0
  213. package/dist/hooks/use-agent-nodename.mjs.map +1 -0
  214. package/dist/hooks/use-coagent-state-render-bridge.d.ts +100 -0
  215. package/dist/hooks/use-coagent-state-render-bridge.js +214 -0
  216. package/dist/hooks/use-coagent-state-render-bridge.js.map +1 -0
  217. package/dist/hooks/use-coagent-state-render-bridge.mjs +15 -0
  218. package/dist/hooks/use-coagent-state-render-bridge.mjs.map +1 -0
  219. package/dist/hooks/use-coagent-state-render.d.ts +55 -0
  220. package/dist/hooks/use-coagent-state-render.js +255 -0
  221. package/dist/hooks/use-coagent-state-render.js.map +1 -0
  222. package/dist/hooks/use-coagent-state-render.mjs +11 -0
  223. package/dist/hooks/use-coagent-state-render.mjs.map +1 -0
  224. package/dist/hooks/use-coagent.d.ts +192 -0
  225. package/dist/hooks/use-coagent.js +233 -0
  226. package/dist/hooks/use-coagent.js.map +1 -0
  227. package/dist/hooks/use-coagent.mjs +9 -0
  228. package/dist/hooks/use-coagent.mjs.map +1 -0
  229. package/dist/hooks/use-configure-chat-suggestions.d.ts +36 -0
  230. package/dist/hooks/use-configure-chat-suggestions.js +79 -0
  231. package/dist/hooks/use-configure-chat-suggestions.js.map +1 -0
  232. package/dist/hooks/use-configure-chat-suggestions.mjs +47 -0
  233. package/dist/hooks/use-configure-chat-suggestions.mjs.map +1 -0
  234. package/dist/hooks/use-copilot-action.d.ts +103 -0
  235. package/dist/hooks/use-copilot-action.js +295 -0
  236. package/dist/hooks/use-copilot-action.js.map +1 -0
  237. package/dist/hooks/use-copilot-action.mjs +11 -0
  238. package/dist/hooks/use-copilot-action.mjs.map +1 -0
  239. package/dist/hooks/use-copilot-additional-instructions.d.ts +26 -0
  240. package/dist/hooks/use-copilot-additional-instructions.js +177 -0
  241. package/dist/hooks/use-copilot-additional-instructions.js.map +1 -0
  242. package/dist/hooks/use-copilot-additional-instructions.mjs +9 -0
  243. package/dist/hooks/use-copilot-additional-instructions.mjs.map +1 -0
  244. package/dist/hooks/use-copilot-authenticated-action.d.ts +18 -0
  245. package/dist/hooks/use-copilot-authenticated-action.js +462 -0
  246. package/dist/hooks/use-copilot-authenticated-action.js.map +1 -0
  247. package/dist/hooks/use-copilot-authenticated-action.mjs +13 -0
  248. package/dist/hooks/use-copilot-authenticated-action.mjs.map +1 -0
  249. package/dist/hooks/use-copilot-chat-headless_c.d.ts +25 -0
  250. package/dist/hooks/use-copilot-chat-headless_c.js +1044 -0
  251. package/dist/hooks/use-copilot-chat-headless_c.js.map +1 -0
  252. package/dist/hooks/use-copilot-chat-headless_c.mjs +24 -0
  253. package/dist/hooks/use-copilot-chat-headless_c.mjs.map +1 -0
  254. package/dist/hooks/use-copilot-chat-suggestions.d.ts +35 -0
  255. package/dist/hooks/use-copilot-chat-suggestions.js +60 -0
  256. package/dist/hooks/use-copilot-chat-suggestions.js.map +1 -0
  257. package/dist/hooks/use-copilot-chat-suggestions.mjs +8 -0
  258. package/dist/hooks/use-copilot-chat-suggestions.mjs.map +1 -0
  259. package/dist/hooks/use-copilot-chat.d.ts +92 -0
  260. package/dist/hooks/use-copilot-chat.js +978 -0
  261. package/dist/hooks/use-copilot-chat.js.map +1 -0
  262. package/dist/hooks/use-copilot-chat.mjs +21 -0
  263. package/dist/hooks/use-copilot-chat.mjs.map +1 -0
  264. package/dist/hooks/use-copilot-chat_internal.d.ts +244 -0
  265. package/dist/hooks/use-copilot-chat_internal.js +976 -0
  266. package/dist/hooks/use-copilot-chat_internal.js.map +1 -0
  267. package/dist/hooks/use-copilot-chat_internal.mjs +22 -0
  268. package/dist/hooks/use-copilot-chat_internal.mjs.map +1 -0
  269. package/dist/hooks/use-copilot-readable.d.ts +37 -0
  270. package/dist/hooks/use-copilot-readable.js +61 -0
  271. package/dist/hooks/use-copilot-readable.js.map +1 -0
  272. package/dist/hooks/use-copilot-readable.mjs +8 -0
  273. package/dist/hooks/use-copilot-readable.mjs.map +1 -0
  274. package/dist/hooks/use-copilot-runtime-client.d.ts +10 -0
  275. package/dist/hooks/use-copilot-runtime-client.js +203 -0
  276. package/dist/hooks/use-copilot-runtime-client.js.map +1 -0
  277. package/dist/hooks/use-copilot-runtime-client.mjs +9 -0
  278. package/dist/hooks/use-copilot-runtime-client.mjs.map +1 -0
  279. package/dist/hooks/use-default-tool.d.ts +8 -0
  280. package/dist/hooks/use-default-tool.js +302 -0
  281. package/dist/hooks/use-default-tool.js.map +1 -0
  282. package/dist/hooks/use-default-tool.mjs +12 -0
  283. package/dist/hooks/use-default-tool.mjs.map +1 -0
  284. package/dist/hooks/use-flat-category-store.d.ts +9 -0
  285. package/dist/hooks/use-flat-category-store.js +93 -0
  286. package/dist/hooks/use-flat-category-store.js.map +1 -0
  287. package/dist/hooks/use-flat-category-store.mjs +8 -0
  288. package/dist/hooks/use-flat-category-store.mjs.map +1 -0
  289. package/dist/hooks/use-frontend-tool.d.ts +11 -0
  290. package/dist/hooks/use-frontend-tool.js +104 -0
  291. package/dist/hooks/use-frontend-tool.js.map +1 -0
  292. package/dist/hooks/use-frontend-tool.mjs +8 -0
  293. package/dist/hooks/use-frontend-tool.mjs.map +1 -0
  294. package/dist/hooks/use-human-in-the-loop.d.ts +13 -0
  295. package/dist/hooks/use-human-in-the-loop.js +122 -0
  296. package/dist/hooks/use-human-in-the-loop.js.map +1 -0
  297. package/dist/hooks/use-human-in-the-loop.mjs +8 -0
  298. package/dist/hooks/use-human-in-the-loop.mjs.map +1 -0
  299. package/dist/hooks/use-langgraph-interrupt-render.d.ts +6 -0
  300. package/dist/hooks/use-langgraph-interrupt-render.js +318 -0
  301. package/dist/hooks/use-langgraph-interrupt-render.js.map +1 -0
  302. package/dist/hooks/use-langgraph-interrupt-render.mjs +14 -0
  303. package/dist/hooks/use-langgraph-interrupt-render.mjs.map +1 -0
  304. package/dist/hooks/use-langgraph-interrupt.d.ts +14 -0
  305. package/dist/hooks/use-langgraph-interrupt.js +201 -0
  306. package/dist/hooks/use-langgraph-interrupt.js.map +1 -0
  307. package/dist/hooks/use-langgraph-interrupt.mjs +10 -0
  308. package/dist/hooks/use-langgraph-interrupt.mjs.map +1 -0
  309. package/dist/hooks/use-lazy-tool-renderer.d.ts +6 -0
  310. package/dist/hooks/use-lazy-tool-renderer.js +53 -0
  311. package/dist/hooks/use-lazy-tool-renderer.js.map +1 -0
  312. package/dist/hooks/use-lazy-tool-renderer.mjs +8 -0
  313. package/dist/hooks/use-lazy-tool-renderer.mjs.map +1 -0
  314. package/dist/hooks/use-make-copilot-document-readable.d.ts +12 -0
  315. package/dist/hooks/use-make-copilot-document-readable.js +176 -0
  316. package/dist/hooks/use-make-copilot-document-readable.js.map +1 -0
  317. package/dist/hooks/use-make-copilot-document-readable.mjs +9 -0
  318. package/dist/hooks/use-make-copilot-document-readable.mjs.map +1 -0
  319. package/dist/hooks/use-render-tool-call.d.ts +12 -0
  320. package/dist/hooks/use-render-tool-call.js +90 -0
  321. package/dist/hooks/use-render-tool-call.js.map +1 -0
  322. package/dist/hooks/use-render-tool-call.mjs +8 -0
  323. package/dist/hooks/use-render-tool-call.mjs.map +1 -0
  324. package/dist/hooks/use-tree.d.ts +19 -0
  325. package/dist/hooks/use-tree.js +175 -0
  326. package/dist/hooks/use-tree.js.map +1 -0
  327. package/dist/hooks/use-tree.mjs +8 -0
  328. package/dist/hooks/use-tree.mjs.map +1 -0
  329. package/dist/index.d.ts +43 -0
  330. package/dist/index.js +3528 -0
  331. package/dist/index.js.map +1 -0
  332. package/dist/index.mjs +149 -0
  333. package/dist/index.mjs.map +1 -0
  334. package/dist/lib/copilot-task.d.ts +97 -0
  335. package/dist/lib/copilot-task.js +194 -0
  336. package/dist/lib/copilot-task.js.map +1 -0
  337. package/dist/lib/copilot-task.mjs +31 -0
  338. package/dist/lib/copilot-task.mjs.map +1 -0
  339. package/dist/lib/index.d.ts +11 -0
  340. package/dist/lib/index.js +196 -0
  341. package/dist/lib/index.js.map +1 -0
  342. package/dist/lib/index.mjs +32 -0
  343. package/dist/lib/index.mjs.map +1 -0
  344. package/dist/lib/status-checker.d.ts +17 -0
  345. package/dist/lib/status-checker.js +102 -0
  346. package/dist/lib/status-checker.js.map +1 -0
  347. package/dist/lib/status-checker.mjs +8 -0
  348. package/dist/lib/status-checker.mjs.map +1 -0
  349. package/dist/setupTests.d.ts +2 -0
  350. package/dist/setupTests.js +26 -0
  351. package/dist/setupTests.js.map +1 -0
  352. package/dist/setupTests.mjs +24 -0
  353. package/dist/setupTests.mjs.map +1 -0
  354. package/dist/types/chat-suggestion-configuration.d.ts +22 -0
  355. package/dist/types/chat-suggestion-configuration.js +19 -0
  356. package/dist/types/chat-suggestion-configuration.js.map +1 -0
  357. package/dist/types/chat-suggestion-configuration.mjs +1 -0
  358. package/dist/types/chat-suggestion-configuration.mjs.map +1 -0
  359. package/dist/types/coagent-action.d.ts +29 -0
  360. package/dist/types/coagent-action.js +19 -0
  361. package/dist/types/coagent-action.js.map +1 -0
  362. package/dist/types/coagent-action.mjs +1 -0
  363. package/dist/types/coagent-action.mjs.map +1 -0
  364. package/dist/types/coagent-state.d.ts +15 -0
  365. package/dist/types/coagent-state.js +19 -0
  366. package/dist/types/coagent-state.js.map +1 -0
  367. package/dist/types/coagent-state.mjs +1 -0
  368. package/dist/types/coagent-state.mjs.map +1 -0
  369. package/dist/types/crew.d.ts +79 -0
  370. package/dist/types/crew.js +19 -0
  371. package/dist/types/crew.js.map +1 -0
  372. package/dist/types/crew.mjs +2 -0
  373. package/dist/types/crew.mjs.map +1 -0
  374. package/dist/types/document-pointer.d.ts +9 -0
  375. package/dist/types/document-pointer.js +19 -0
  376. package/dist/types/document-pointer.js.map +1 -0
  377. package/dist/types/document-pointer.mjs +1 -0
  378. package/dist/types/document-pointer.mjs.map +1 -0
  379. package/dist/types/frontend-action.d.ts +127 -0
  380. package/dist/types/frontend-action.js +53 -0
  381. package/dist/types/frontend-action.js.map +1 -0
  382. package/dist/types/frontend-action.mjs +8 -0
  383. package/dist/types/frontend-action.mjs.map +1 -0
  384. package/dist/types/index.d.ts +12 -0
  385. package/dist/types/index.js +19 -0
  386. package/dist/types/index.js.map +1 -0
  387. package/dist/types/index.mjs +4 -0
  388. package/dist/types/index.mjs.map +1 -0
  389. package/dist/types/interrupt-action.d.ts +10 -0
  390. package/dist/types/interrupt-action.js +19 -0
  391. package/dist/types/interrupt-action.js.map +1 -0
  392. package/dist/types/interrupt-action.mjs +2 -0
  393. package/dist/types/interrupt-action.mjs.map +1 -0
  394. package/dist/types/system-message.d.ts +3 -0
  395. package/dist/types/system-message.js +19 -0
  396. package/dist/types/system-message.js.map +1 -0
  397. package/dist/types/system-message.mjs +1 -0
  398. package/dist/types/system-message.mjs.map +1 -0
  399. package/dist/utils/dev-console.d.ts +3 -0
  400. package/dist/utils/dev-console.js +41 -0
  401. package/dist/utils/dev-console.js.map +1 -0
  402. package/dist/utils/dev-console.mjs +8 -0
  403. package/dist/utils/dev-console.mjs.map +1 -0
  404. package/dist/utils/index.d.ts +2 -0
  405. package/dist/utils/index.js +52 -0
  406. package/dist/utils/index.js.map +1 -0
  407. package/dist/utils/index.mjs +13 -0
  408. package/dist/utils/index.mjs.map +1 -0
  409. package/dist/utils/suggestions-constants.d.ts +9 -0
  410. package/dist/utils/suggestions-constants.js +35 -0
  411. package/dist/utils/suggestions-constants.js.map +1 -0
  412. package/dist/utils/suggestions-constants.mjs +8 -0
  413. package/dist/utils/suggestions-constants.mjs.map +1 -0
  414. package/dist/utils/utils.d.ts +2 -0
  415. package/dist/utils/utils.js +19 -0
  416. package/dist/utils/utils.js.map +1 -0
  417. package/dist/utils/utils.mjs +1 -0
  418. package/dist/utils/utils.mjs.map +1 -0
  419. package/dist/v2/index.css +4 -0
  420. package/dist/v2/index.css.map +1 -0
  421. package/dist/v2/index.d.ts +2 -0
  422. package/dist/v2/index.js +27 -0
  423. package/dist/v2/index.js.map +1 -0
  424. package/dist/v2/index.mjs +6 -0
  425. package/dist/v2/index.mjs.map +1 -0
  426. package/jest.config.js +25 -0
  427. package/package.json +92 -0
  428. package/src/components/CopilotListeners.tsx +81 -0
  429. package/src/components/copilot-provider/__tests__/copilotkit-error.test.tsx +75 -0
  430. package/src/components/copilot-provider/copilot-messages.tsx +274 -0
  431. package/src/components/copilot-provider/copilotkit-props.tsx +169 -0
  432. package/src/components/copilot-provider/copilotkit.tsx +671 -0
  433. package/src/components/copilot-provider/index.ts +3 -0
  434. package/src/components/dev-console/console-trigger.tsx +254 -0
  435. package/src/components/dev-console/developer-console-modal.tsx +866 -0
  436. package/src/components/dev-console/icons.tsx +101 -0
  437. package/src/components/error-boundary/error-boundary.tsx +91 -0
  438. package/src/components/error-boundary/error-utils.tsx +100 -0
  439. package/src/components/index.ts +1 -0
  440. package/src/components/toast/exclamation-mark-icon.tsx +27 -0
  441. package/src/components/toast/toast-provider.tsx +363 -0
  442. package/src/components/usage-banner.tsx +259 -0
  443. package/src/context/coagent-state-renders-context.tsx +76 -0
  444. package/src/context/copilot-context.tsx +332 -0
  445. package/src/context/copilot-messages-context.tsx +35 -0
  446. package/src/context/index.ts +16 -0
  447. package/src/context/threads-context.tsx +41 -0
  448. package/src/hooks/__tests__/use-coagent-config.test.ts +351 -0
  449. package/src/hooks/index.ts +34 -0
  450. package/src/hooks/use-agent-nodename.ts +30 -0
  451. package/src/hooks/use-coagent-state-render-bridge.tsx +293 -0
  452. package/src/hooks/use-coagent-state-render.ts +152 -0
  453. package/src/hooks/use-coagent.ts +366 -0
  454. package/src/hooks/use-configure-chat-suggestions.tsx +86 -0
  455. package/src/hooks/use-copilot-action.ts +236 -0
  456. package/src/hooks/use-copilot-additional-instructions.ts +85 -0
  457. package/src/hooks/use-copilot-authenticated-action.ts +70 -0
  458. package/src/hooks/use-copilot-chat-headless_c.ts +258 -0
  459. package/src/hooks/use-copilot-chat-suggestions.tsx +124 -0
  460. package/src/hooks/use-copilot-chat.ts +130 -0
  461. package/src/hooks/use-copilot-chat_internal.ts +696 -0
  462. package/src/hooks/use-copilot-readable.ts +135 -0
  463. package/src/hooks/use-copilot-runtime-client.ts +164 -0
  464. package/src/hooks/use-default-tool.ts +7 -0
  465. package/src/hooks/use-flat-category-store.ts +105 -0
  466. package/src/hooks/use-frontend-tool.ts +96 -0
  467. package/src/hooks/use-human-in-the-loop.ts +122 -0
  468. package/src/hooks/use-langgraph-interrupt-render.ts +136 -0
  469. package/src/hooks/use-langgraph-interrupt.ts +36 -0
  470. package/src/hooks/use-lazy-tool-renderer.tsx +30 -0
  471. package/src/hooks/use-make-copilot-document-readable.ts +30 -0
  472. package/src/hooks/use-render-tool-call.ts +80 -0
  473. package/src/hooks/use-tree.ts +207 -0
  474. package/src/index.tsx +7 -0
  475. package/src/lib/copilot-task.ts +201 -0
  476. package/src/lib/index.ts +1 -0
  477. package/src/lib/status-checker.ts +64 -0
  478. package/src/setupTests.ts +26 -0
  479. package/src/types/chat-suggestion-configuration.ts +23 -0
  480. package/src/types/coagent-action.ts +31 -0
  481. package/src/types/coagent-state.ts +13 -0
  482. package/src/types/crew.ts +89 -0
  483. package/src/types/document-pointer.ts +7 -0
  484. package/src/types/frontend-action.ts +202 -0
  485. package/src/types/index.ts +17 -0
  486. package/src/types/interrupt-action.ts +43 -0
  487. package/src/types/system-message.ts +4 -0
  488. package/src/utils/dev-console.ts +19 -0
  489. package/src/utils/index.ts +2 -0
  490. package/src/utils/suggestions-constants.ts +8 -0
  491. package/src/utils/utils.test.ts +7 -0
  492. package/src/utils/utils.ts +8 -0
  493. package/src/v2/index.css +1 -0
  494. package/src/v2/index.ts +4 -0
  495. package/tsconfig.json +8 -0
  496. package/tsup.config.ts +16 -0
  497. package/typedoc.json +4 -0
@@ -0,0 +1,976 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __defProps = Object.defineProperties;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
+ var __getProtoOf = Object.getPrototypeOf;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
+ var __spreadValues = (a, b) => {
14
+ for (var prop in b || (b = {}))
15
+ if (__hasOwnProp.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ if (__getOwnPropSymbols)
18
+ for (var prop of __getOwnPropSymbols(b)) {
19
+ if (__propIsEnum.call(b, prop))
20
+ __defNormalProp(a, prop, b[prop]);
21
+ }
22
+ return a;
23
+ };
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
+ };
37
+ var __export = (target, all) => {
38
+ for (var name in all)
39
+ __defProp(target, name, { get: all[name], enumerable: true });
40
+ };
41
+ var __copyProps = (to, from, except, desc) => {
42
+ if (from && typeof from === "object" || typeof from === "function") {
43
+ for (let key of __getOwnPropNames(from))
44
+ if (!__hasOwnProp.call(to, key) && key !== except)
45
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
46
+ }
47
+ return to;
48
+ };
49
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
50
+ // If the importer is in node compatibility mode or this is not an ESM
51
+ // file that has been converted to a CommonJS file using a Babel-
52
+ // compatible transform (i.e. "__esModule" has not been set), then set
53
+ // "default" to the CommonJS "module.exports" for node compatibility.
54
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
55
+ mod
56
+ ));
57
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
58
+ var __async = (__this, __arguments, generator) => {
59
+ return new Promise((resolve, reject) => {
60
+ var fulfilled = (value) => {
61
+ try {
62
+ step(generator.next(value));
63
+ } catch (e) {
64
+ reject(e);
65
+ }
66
+ };
67
+ var rejected = (value) => {
68
+ try {
69
+ step(generator.throw(value));
70
+ } catch (e) {
71
+ reject(e);
72
+ }
73
+ };
74
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
75
+ step((generator = generator.apply(__this, __arguments)).next());
76
+ });
77
+ };
78
+
79
+ // src/hooks/use-copilot-chat_internal.ts
80
+ var use_copilot_chat_internal_exports = {};
81
+ __export(use_copilot_chat_internal_exports, {
82
+ defaultSystemMessage: () => defaultSystemMessage,
83
+ useCopilotChatInternal: () => useCopilotChatInternal
84
+ });
85
+ module.exports = __toCommonJS(use_copilot_chat_internal_exports);
86
+ var import_react13 = require("react");
87
+
88
+ // src/context/copilot-context.tsx
89
+ var import_react = __toESM(require("react"));
90
+ var emptyCopilotContext = {
91
+ actions: {},
92
+ setAction: () => {
93
+ },
94
+ removeAction: () => {
95
+ },
96
+ setRegisteredActions: () => "",
97
+ removeRegisteredAction: () => {
98
+ },
99
+ chatComponentsCache: { current: { actions: {}, coAgentStateRenders: {} } },
100
+ getContextString: (documents, categories) => returnAndThrowInDebug(""),
101
+ addContext: () => "",
102
+ removeContext: () => {
103
+ },
104
+ getAllContext: () => [],
105
+ getFunctionCallHandler: () => returnAndThrowInDebug(() => __async(void 0, null, function* () {
106
+ })),
107
+ isLoading: false,
108
+ setIsLoading: () => returnAndThrowInDebug(false),
109
+ chatInstructions: "",
110
+ setChatInstructions: () => returnAndThrowInDebug(""),
111
+ additionalInstructions: [],
112
+ setAdditionalInstructions: () => returnAndThrowInDebug([]),
113
+ getDocumentsContext: (categories) => returnAndThrowInDebug([]),
114
+ addDocumentContext: () => returnAndThrowInDebug(""),
115
+ removeDocumentContext: () => {
116
+ },
117
+ copilotApiConfig: new class {
118
+ get chatApiEndpoint() {
119
+ throw new Error("Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!");
120
+ }
121
+ get headers() {
122
+ return {};
123
+ }
124
+ get body() {
125
+ return {};
126
+ }
127
+ }(),
128
+ chatSuggestionConfiguration: {},
129
+ addChatSuggestionConfiguration: () => {
130
+ },
131
+ removeChatSuggestionConfiguration: () => {
132
+ },
133
+ showDevConsole: false,
134
+ coagentStates: {},
135
+ setCoagentStates: () => {
136
+ },
137
+ coagentStatesRef: { current: {} },
138
+ setCoagentStatesWithRef: () => {
139
+ },
140
+ agentSession: null,
141
+ setAgentSession: () => {
142
+ },
143
+ forwardedParameters: {},
144
+ agentLock: null,
145
+ threadId: "",
146
+ setThreadId: () => {
147
+ },
148
+ runId: null,
149
+ setRunId: () => {
150
+ },
151
+ chatAbortControllerRef: { current: null },
152
+ availableAgents: [],
153
+ extensions: {},
154
+ setExtensions: () => {
155
+ },
156
+ interruptActions: {},
157
+ setInterruptAction: () => {
158
+ },
159
+ removeInterruptAction: () => {
160
+ },
161
+ interruptEventQueue: {},
162
+ addInterruptEvent: () => {
163
+ },
164
+ resolveInterruptEvent: () => {
165
+ },
166
+ onError: () => {
167
+ },
168
+ bannerError: null,
169
+ setBannerError: () => {
170
+ },
171
+ internalErrorHandlers: {},
172
+ setInternalErrorHandler: () => {
173
+ },
174
+ removeInternalErrorHandler: () => {
175
+ }
176
+ };
177
+ var CopilotContext = import_react.default.createContext(emptyCopilotContext);
178
+ function useCopilotContext() {
179
+ const context = import_react.default.useContext(CopilotContext);
180
+ if (context === emptyCopilotContext) {
181
+ throw new Error("Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!");
182
+ }
183
+ return context;
184
+ }
185
+ function returnAndThrowInDebug(_value) {
186
+ throw new Error("Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!");
187
+ }
188
+
189
+ // src/components/error-boundary/error-utils.tsx
190
+ var import_react3 = require("react");
191
+
192
+ // src/components/toast/toast-provider.tsx
193
+ var import_react2 = require("react");
194
+ var import_shared = require("@copilotkit/shared");
195
+ var import_jsx_runtime = require("react/jsx-runtime");
196
+ var ToastContext = (0, import_react2.createContext)(void 0);
197
+ function useToast() {
198
+ const context = (0, import_react2.useContext)(ToastContext);
199
+ if (!context) {
200
+ throw new Error("useToast must be used within a ToastProvider");
201
+ }
202
+ return context;
203
+ }
204
+
205
+ // src/components/toast/exclamation-mark-icon.tsx
206
+ var import_jsx_runtime2 = require("react/jsx-runtime");
207
+ var ExclamationMarkIcon = ({
208
+ className,
209
+ style
210
+ }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
211
+ "svg",
212
+ {
213
+ xmlns: "http://www.w3.org/2000/svg",
214
+ width: "24",
215
+ height: "24",
216
+ viewBox: "0 0 24 24",
217
+ fill: "none",
218
+ stroke: "currentColor",
219
+ strokeWidth: "2",
220
+ strokeLinecap: "round",
221
+ strokeLinejoin: "round",
222
+ className: `lucide lucide-circle-alert ${className ? className : ""}`,
223
+ style,
224
+ children: [
225
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
226
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "12", x2: "12", y1: "8", y2: "12" }),
227
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "12", x2: "12.01", y1: "16", y2: "16" })
228
+ ]
229
+ }
230
+ );
231
+
232
+ // src/components/error-boundary/error-utils.tsx
233
+ var import_react_markdown = __toESM(require("react-markdown"));
234
+ var import_jsx_runtime3 = require("react/jsx-runtime");
235
+ function ErrorToast({ errors }) {
236
+ const errorsToRender = errors.map((error, idx) => {
237
+ var _a, _b, _c;
238
+ const originalError = "extensions" in error ? (_a = error.extensions) == null ? void 0 : _a.originalError : {};
239
+ const message = (_b = originalError == null ? void 0 : originalError.message) != null ? _b : error.message;
240
+ const code = "extensions" in error ? (_c = error.extensions) == null ? void 0 : _c.code : null;
241
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
242
+ "div",
243
+ {
244
+ style: {
245
+ marginTop: idx === 0 ? 0 : 10,
246
+ marginBottom: 14
247
+ },
248
+ children: [
249
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ExclamationMarkIcon, { style: { marginBottom: 4 } }),
250
+ code && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
251
+ "div",
252
+ {
253
+ style: {
254
+ fontWeight: "600",
255
+ marginBottom: 4
256
+ },
257
+ children: [
258
+ "Copilot Runtime Error:",
259
+ " ",
260
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { fontFamily: "monospace", fontWeight: "normal" }, children: code })
261
+ ]
262
+ }
263
+ ),
264
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_markdown.default, { children: message })
265
+ ]
266
+ },
267
+ idx
268
+ );
269
+ });
270
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
271
+ "div",
272
+ {
273
+ style: {
274
+ fontSize: "13px",
275
+ maxWidth: "600px"
276
+ },
277
+ children: [
278
+ errorsToRender,
279
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { fontSize: "11px", opacity: 0.75 }, children: "NOTE: This error only displays during local development." })
280
+ ]
281
+ }
282
+ );
283
+ }
284
+ function useErrorToast() {
285
+ const { addToast } = useToast();
286
+ return (0, import_react3.useCallback)(
287
+ (errors) => {
288
+ const errorId = errors.map((err) => {
289
+ var _a, _b;
290
+ const message = "extensions" in err ? ((_b = (_a = err.extensions) == null ? void 0 : _a.originalError) == null ? void 0 : _b.message) || err.message : err.message;
291
+ const stack = err.stack || "";
292
+ return btoa(message + stack).slice(0, 32);
293
+ }).join("|");
294
+ addToast({
295
+ type: "error",
296
+ id: errorId,
297
+ // Toast libraries typically dedupe by id
298
+ message: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ErrorToast, { errors })
299
+ });
300
+ },
301
+ [addToast]
302
+ );
303
+ }
304
+ function useAsyncCallback(callback, deps) {
305
+ const addErrorToast = useErrorToast();
306
+ return (0, import_react3.useCallback)((...args) => __async(this, null, function* () {
307
+ try {
308
+ return yield callback(...args);
309
+ } catch (error) {
310
+ console.error("Error in async callback:", error);
311
+ addErrorToast([error]);
312
+ throw error;
313
+ }
314
+ }), deps);
315
+ }
316
+
317
+ // src/hooks/use-copilot-chat_internal.ts
318
+ var import_runtime_client_gql2 = require("@copilotkit/runtime-client-gql");
319
+
320
+ // src/context/coagent-state-renders-context.tsx
321
+ var import_react4 = require("react");
322
+ var import_jsx_runtime4 = require("react/jsx-runtime");
323
+ var CoAgentStateRendersContext = (0, import_react4.createContext)(
324
+ void 0
325
+ );
326
+ function useCoAgentStateRenders() {
327
+ const context = (0, import_react4.useContext)(CoAgentStateRendersContext);
328
+ if (!context) {
329
+ throw new Error("useCoAgentStateRenders must be used within CoAgentStateRendersProvider");
330
+ }
331
+ return context;
332
+ }
333
+
334
+ // src/hooks/use-langgraph-interrupt-render.ts
335
+ var import_react7 = __toESM(require("react"));
336
+ var import_runtime_client_gql = require("@copilotkit/runtime-client-gql");
337
+ var import_shared2 = require("@copilotkit/shared");
338
+
339
+ // src/hooks/use-agent-nodename.ts
340
+ var import_react5 = require("react");
341
+ var import_react6 = require("@copilotkitnext/react");
342
+ function useAgentNodeName(agentName) {
343
+ const { agent } = (0, import_react6.useAgent)({ agentId: agentName });
344
+ const nodeNameRef = (0, import_react5.useRef)("start");
345
+ (0, import_react5.useEffect)(() => {
346
+ if (!agent)
347
+ return;
348
+ const subscriber = {
349
+ onStepStartedEvent: ({ event }) => {
350
+ nodeNameRef.current = event.stepName;
351
+ },
352
+ onRunStartedEvent: () => {
353
+ nodeNameRef.current = "start";
354
+ },
355
+ onRunFinishedEvent: () => {
356
+ nodeNameRef.current = "end";
357
+ }
358
+ };
359
+ const subscription = agent.subscribe(subscriber);
360
+ return () => {
361
+ subscription.unsubscribe();
362
+ };
363
+ }, [agent]);
364
+ return nodeNameRef.current;
365
+ }
366
+
367
+ // src/hooks/use-langgraph-interrupt-render.ts
368
+ var import_react8 = require("@copilotkitnext/react");
369
+ var InterruptRenderer = ({ event, result, render, resolve }) => {
370
+ return render({ event, result, resolve });
371
+ };
372
+ function useLangGraphInterruptRender(agent) {
373
+ var _a;
374
+ const {
375
+ interruptActions,
376
+ agentSession,
377
+ threadId,
378
+ interruptEventQueue,
379
+ addInterruptEvent,
380
+ resolveInterruptEvent
381
+ } = useCopilotContext();
382
+ const existingConfig = (0, import_react8.useCopilotChatConfiguration)();
383
+ const resolvedAgentId = (_a = existingConfig == null ? void 0 : existingConfig.agentId) != null ? _a : "default";
384
+ const nodeName = useAgentNodeName(resolvedAgentId);
385
+ (0, import_react7.useEffect)(() => {
386
+ if (!agent)
387
+ return;
388
+ let localInterrupt = null;
389
+ const subscriber = {
390
+ onCustomEvent: ({ event }) => {
391
+ if (event.name === "on_interrupt") {
392
+ const eventData = {
393
+ name: import_runtime_client_gql.MetaEventName.LangGraphInterruptEvent,
394
+ type: event.type,
395
+ value: (0, import_shared2.parseJson)(event.value, event.value)
396
+ };
397
+ const eventId = (0, import_shared2.dataToUUID)(eventData, "interruptEvents");
398
+ localInterrupt = {
399
+ eventId,
400
+ threadId,
401
+ event: eventData
402
+ };
403
+ }
404
+ },
405
+ onRunStartedEvent: () => {
406
+ localInterrupt = null;
407
+ },
408
+ onRunFinalized: () => {
409
+ if (localInterrupt) {
410
+ addInterruptEvent(localInterrupt);
411
+ localInterrupt = null;
412
+ }
413
+ }
414
+ };
415
+ const { unsubscribe } = agent.subscribe(subscriber);
416
+ return () => {
417
+ unsubscribe();
418
+ };
419
+ }, [agent, threadId]);
420
+ const handleResolve = (0, import_react7.useCallback)(
421
+ (eventId, response) => {
422
+ agent == null ? void 0 : agent.runAgent({
423
+ forwardedProps: {
424
+ command: {
425
+ resume: response
426
+ }
427
+ }
428
+ });
429
+ resolveInterruptEvent(threadId, eventId, response != null ? response : "");
430
+ },
431
+ // eslint-disable-next-line react-hooks/exhaustive-deps
432
+ [agent, threadId]
433
+ );
434
+ return (0, import_react7.useMemo)(() => {
435
+ const eventQueue = interruptEventQueue[threadId] || [];
436
+ const currentQueuedEvent = eventQueue.find((qe) => !qe.event.response);
437
+ if (!currentQueuedEvent || !agentSession)
438
+ return null;
439
+ const allActions = Object.values(interruptActions);
440
+ const matchingAction = allActions.find((action) => {
441
+ if (!action.enabled)
442
+ return true;
443
+ return action.enabled({
444
+ eventValue: currentQueuedEvent.event.value,
445
+ agentMetadata: __spreadProps(__spreadValues({}, agentSession), {
446
+ nodeName
447
+ })
448
+ });
449
+ });
450
+ if (!matchingAction)
451
+ return null;
452
+ const { render, handler } = matchingAction;
453
+ const resolveInterrupt = (response) => {
454
+ handleResolve(currentQueuedEvent.eventId, response);
455
+ };
456
+ let result = null;
457
+ if (handler) {
458
+ result = handler({
459
+ event: currentQueuedEvent.event,
460
+ resolve: resolveInterrupt
461
+ });
462
+ }
463
+ if (!render)
464
+ return null;
465
+ return import_react7.default.createElement(InterruptRenderer, {
466
+ event: currentQueuedEvent.event,
467
+ result,
468
+ render,
469
+ resolve: resolveInterrupt
470
+ });
471
+ }, [interruptActions, interruptEventQueue, threadId, agentSession, handleResolve]);
472
+ }
473
+
474
+ // src/hooks/use-copilot-chat_internal.ts
475
+ var import_react14 = require("@copilotkitnext/react");
476
+
477
+ // src/hooks/use-lazy-tool-renderer.tsx
478
+ var import_react9 = require("@copilotkitnext/react");
479
+ var import_react10 = require("react");
480
+ function useLazyToolRenderer() {
481
+ const renderToolCall = (0, import_react9.useRenderToolCall)();
482
+ return (0, import_react10.useCallback)(
483
+ (message, messages) => {
484
+ var _a;
485
+ if (!((_a = message == null ? void 0 : message.toolCalls) == null ? void 0 : _a.length))
486
+ return null;
487
+ const toolCall = message.toolCalls[0];
488
+ if (!toolCall)
489
+ return null;
490
+ const toolMessage = messages == null ? void 0 : messages.find(
491
+ (m) => m.role === "tool" && m.toolCallId === toolCall.id
492
+ );
493
+ return () => renderToolCall({
494
+ toolCall,
495
+ toolMessage
496
+ });
497
+ },
498
+ [renderToolCall]
499
+ );
500
+ }
501
+
502
+ // src/hooks/use-copilot-chat_internal.ts
503
+ var import_client = require("@ag-ui/client");
504
+
505
+ // src/hooks/use-coagent-state-render-bridge.tsx
506
+ var import_react11 = require("@copilotkitnext/react");
507
+ var import_react12 = require("react");
508
+ var import_shared3 = require("@copilotkit/shared");
509
+ function getStateWithoutConstantKeys(state) {
510
+ if (!state)
511
+ return {};
512
+ const _a = state, { messages, tools, copilotkit } = _a, stateWithoutConstantKeys = __objRest(_a, ["messages", "tools", "copilotkit"]);
513
+ return stateWithoutConstantKeys;
514
+ }
515
+ function areStatesEquals(a, b) {
516
+ if (a && !b || !a && b)
517
+ return false;
518
+ const _a = a, { messages, tools, copilotkit } = _a, aWithoutConstantKeys = __objRest(_a, ["messages", "tools", "copilotkit"]);
519
+ const _b = b, {
520
+ messages: bMessages,
521
+ tools: bTools,
522
+ copilotkit: bCopilotkit
523
+ } = _b, bWithoutConstantKeys = __objRest(_b, [
524
+ "messages",
525
+ "tools",
526
+ "copilotkit"
527
+ ]);
528
+ return JSON.stringify(aWithoutConstantKeys) === JSON.stringify(bWithoutConstantKeys);
529
+ }
530
+ function useCoagentStateRenderBridge(agentId, props) {
531
+ var _a;
532
+ const { stateSnapshot, messageIndexInRun, message } = props;
533
+ const { coAgentStateRenders, claimsRef } = useCoAgentStateRenders();
534
+ const { agent } = (0, import_react11.useAgent)({ agentId });
535
+ const [nodeName, setNodeName] = (0, import_react12.useState)(void 0);
536
+ const runId = (_a = props.runId) != null ? _a : message.runId;
537
+ const effectiveRunId = runId || "pending";
538
+ (0, import_react12.useEffect)(() => {
539
+ if (!agent)
540
+ return;
541
+ const subscriber = {
542
+ onStepStartedEvent: ({ event }) => {
543
+ if (event.stepName !== nodeName) {
544
+ setNodeName(event.stepName);
545
+ }
546
+ },
547
+ onStepFinishedEvent: ({ event }) => {
548
+ if (event.stepName === nodeName) {
549
+ setNodeName(void 0);
550
+ }
551
+ }
552
+ };
553
+ const { unsubscribe } = agent.subscribe(subscriber);
554
+ return () => {
555
+ unsubscribe();
556
+ };
557
+ }, [agentId, nodeName]);
558
+ const getStateRender = (0, import_react12.useCallback)(
559
+ (messageId) => {
560
+ return Object.entries(coAgentStateRenders).find(([stateRenderId, stateRender]) => {
561
+ if (claimsRef.current[messageId]) {
562
+ return stateRenderId === claimsRef.current[messageId].stateRenderId;
563
+ }
564
+ const matchingAgentName = stateRender.name === agentId;
565
+ const matchesNodeContext = stateRender.nodeName ? stateRender.nodeName === nodeName : true;
566
+ return matchingAgentName && matchesNodeContext;
567
+ });
568
+ },
569
+ [coAgentStateRenders, nodeName, agentId]
570
+ );
571
+ const handleRenderRequest = ({
572
+ stateRenderId,
573
+ messageId,
574
+ runId: runId2,
575
+ stateSnapshot: renderSnapshot
576
+ }) => {
577
+ if (claimsRef.current[messageId]) {
578
+ const canRender = claimsRef.current[messageId].stateRenderId === stateRenderId;
579
+ if (canRender && runId2 && (!claimsRef.current[messageId].runId || claimsRef.current[messageId].runId === "pending")) {
580
+ claimsRef.current[messageId].runId = runId2;
581
+ }
582
+ return canRender;
583
+ }
584
+ const renderClaimedByOtherMessage = Object.values(claimsRef.current).find(
585
+ (c) => c.stateRenderId === stateRenderId && (0, import_shared3.dataToUUID)(getStateWithoutConstantKeys(c.stateSnapshot)) === (0, import_shared3.dataToUUID)(getStateWithoutConstantKeys(renderSnapshot))
586
+ );
587
+ if (renderClaimedByOtherMessage) {
588
+ if (renderSnapshot && renderClaimedByOtherMessage.stateSnapshot && !areStatesEquals(renderClaimedByOtherMessage.stateSnapshot, renderSnapshot)) {
589
+ claimsRef.current[messageId] = { stateRenderId, runId: runId2 };
590
+ return true;
591
+ }
592
+ return false;
593
+ }
594
+ if (!runId2) {
595
+ return false;
596
+ }
597
+ claimsRef.current[messageId] = { stateRenderId, runId: runId2 };
598
+ return true;
599
+ };
600
+ return (0, import_react12.useMemo)(() => {
601
+ var _a2, _b, _c;
602
+ if (messageIndexInRun !== 0) {
603
+ return null;
604
+ }
605
+ const [stateRenderId, stateRender] = (_a2 = getStateRender(message.id)) != null ? _a2 : [];
606
+ if (!stateRender || !stateRenderId) {
607
+ return null;
608
+ }
609
+ const snapshot = stateSnapshot ? (0, import_shared3.parseJson)(stateSnapshot, stateSnapshot) : agent == null ? void 0 : agent.state;
610
+ const canRender = handleRenderRequest({
611
+ stateRenderId,
612
+ messageId: message.id,
613
+ runId: effectiveRunId,
614
+ stateSnapshot: snapshot
615
+ });
616
+ if (!canRender) {
617
+ return null;
618
+ }
619
+ if (snapshot && !claimsRef.current[message.id].locked) {
620
+ if (stateSnapshot) {
621
+ claimsRef.current[message.id].stateSnapshot = snapshot;
622
+ claimsRef.current[message.id].locked = true;
623
+ } else {
624
+ claimsRef.current[message.id].stateSnapshot = snapshot;
625
+ }
626
+ }
627
+ if (stateRender.handler) {
628
+ stateRender.handler({
629
+ state: stateSnapshot ? (0, import_shared3.parseJson)(stateSnapshot, stateSnapshot) : (_b = agent == null ? void 0 : agent.state) != null ? _b : {},
630
+ nodeName: nodeName != null ? nodeName : ""
631
+ });
632
+ }
633
+ if (stateRender.render) {
634
+ const status = (agent == null ? void 0 : agent.isRunning) ? "inProgress" : "complete";
635
+ if (typeof stateRender.render === "string")
636
+ return stateRender.render;
637
+ return stateRender.render({
638
+ status,
639
+ // Always use state from claim, to make sure the state does not seem "wiped" for a fraction of a second
640
+ state: (_c = claimsRef.current[message.id].stateSnapshot) != null ? _c : {},
641
+ nodeName: nodeName != null ? nodeName : ""
642
+ });
643
+ }
644
+ }, [
645
+ getStateRender,
646
+ stateSnapshot,
647
+ agent == null ? void 0 : agent.state,
648
+ agent == null ? void 0 : agent.isRunning,
649
+ nodeName,
650
+ effectiveRunId,
651
+ message.id,
652
+ messageIndexInRun
653
+ ]);
654
+ }
655
+ function CoAgentStateRenderBridge(props) {
656
+ return useCoagentStateRenderBridge(props.agentId, props);
657
+ }
658
+
659
+ // src/hooks/use-copilot-chat_internal.ts
660
+ function useCopilotChatInternal({
661
+ suggestions,
662
+ onInProgress,
663
+ onSubmitMessage,
664
+ onStopGeneration,
665
+ onReloadMessages
666
+ } = {}) {
667
+ var _a, _b, _c;
668
+ const { copilotkit } = (0, import_react14.useCopilotKit)();
669
+ const { threadId, agentSession } = useCopilotContext();
670
+ const existingConfig = (0, import_react14.useCopilotChatConfiguration)();
671
+ const [agentAvailable, setAgentAvailable] = (0, import_react13.useState)(false);
672
+ const resolvedAgentId = (_a = existingConfig == null ? void 0 : existingConfig.agentId) != null ? _a : "default";
673
+ const { agent } = (0, import_react14.useAgent)({ agentId: resolvedAgentId });
674
+ (0, import_react13.useEffect)(() => {
675
+ const connect = (agent2) => __async(this, null, function* () {
676
+ setAgentAvailable(false);
677
+ try {
678
+ yield copilotkit.connectAgent({ agent: agent2 });
679
+ setAgentAvailable(true);
680
+ } catch (error) {
681
+ if (error instanceof import_client.AGUIConnectNotImplementedError) {
682
+ } else {
683
+ throw error;
684
+ }
685
+ }
686
+ });
687
+ if (agent && (existingConfig == null ? void 0 : existingConfig.threadId) && agent.threadId !== existingConfig.threadId) {
688
+ agent.threadId = existingConfig.threadId;
689
+ connect(agent);
690
+ }
691
+ return () => {
692
+ };
693
+ }, [existingConfig == null ? void 0 : existingConfig.threadId, agent, copilotkit, resolvedAgentId]);
694
+ (0, import_react13.useEffect)(() => {
695
+ onInProgress == null ? void 0 : onInProgress(Boolean(agent == null ? void 0 : agent.isRunning));
696
+ }, [agent == null ? void 0 : agent.isRunning, onInProgress]);
697
+ const interrupt = useLangGraphInterruptRender(agent);
698
+ const reset = () => {
699
+ agent == null ? void 0 : agent.setMessages([]);
700
+ agent == null ? void 0 : agent.setState(null);
701
+ };
702
+ const deleteMessage = (0, import_react13.useCallback)(
703
+ (messageId) => {
704
+ var _a2;
705
+ const filteredMessages = ((_a2 = agent == null ? void 0 : agent.messages) != null ? _a2 : []).filter(
706
+ (message) => message.id !== messageId
707
+ );
708
+ agent == null ? void 0 : agent.setMessages(filteredMessages);
709
+ },
710
+ [agent == null ? void 0 : agent.setMessages, agent == null ? void 0 : agent.messages]
711
+ );
712
+ const latestDelete = useUpdatedRef(deleteMessage);
713
+ const latestDeleteFunc = (0, import_react13.useCallback)(
714
+ (messageId) => {
715
+ return latestDelete.current(messageId);
716
+ },
717
+ [latestDelete]
718
+ );
719
+ const currentSuggestions = (0, import_react14.useSuggestions)({ agentId: resolvedAgentId });
720
+ const reload = useAsyncCallback(
721
+ (reloadMessageId) => __async(this, null, function* () {
722
+ var _a2;
723
+ const messages = (_a2 = agent == null ? void 0 : agent.messages) != null ? _a2 : [];
724
+ const isLoading = false;
725
+ if (isLoading || messages.length === 0) {
726
+ return;
727
+ }
728
+ const reloadMessageIndex = messages.findIndex((msg) => msg.id === reloadMessageId);
729
+ if (reloadMessageIndex === -1) {
730
+ console.warn(`Message with id ${reloadMessageId} not found`);
731
+ return;
732
+ }
733
+ const reloadMessageRole = messages[reloadMessageIndex].role;
734
+ if (reloadMessageRole !== "assistant") {
735
+ console.warn(`Regenerate cannot be performed on ${reloadMessageRole} role`);
736
+ return;
737
+ }
738
+ let historyCutoff = [messages[0]];
739
+ if (messages.length > 2 && reloadMessageIndex !== 0) {
740
+ const lastUserMessageBeforeRegenerate = messages.slice(0, reloadMessageIndex).reverse().find((msg) => msg.role === "user");
741
+ if (!lastUserMessageBeforeRegenerate) {
742
+ historyCutoff = [messages[0]];
743
+ } else {
744
+ const indexOfLastUserMessageBeforeRegenerate = messages.findIndex(
745
+ (msg) => msg.id === lastUserMessageBeforeRegenerate.id
746
+ );
747
+ historyCutoff = messages.slice(0, indexOfLastUserMessageBeforeRegenerate + 1);
748
+ }
749
+ } else if (messages.length > 2 && reloadMessageIndex === 0) {
750
+ historyCutoff = [messages[0], messages[1]];
751
+ }
752
+ agent == null ? void 0 : agent.setMessages(historyCutoff);
753
+ if (agent) {
754
+ copilotkit.runAgent({ agent });
755
+ }
756
+ return;
757
+ }),
758
+ [agent == null ? void 0 : agent.setMessages, copilotkit == null ? void 0 : copilotkit.runAgent]
759
+ );
760
+ const latestSendMessageFunc = useAsyncCallback(
761
+ (message, options) => __async(this, null, function* () {
762
+ var _a2;
763
+ if (!agent)
764
+ return;
765
+ const followUp = (_a2 = options == null ? void 0 : options.followUp) != null ? _a2 : true;
766
+ if (options == null ? void 0 : options.clearSuggestions) {
767
+ copilotkit.clearSuggestions(resolvedAgentId);
768
+ }
769
+ agent == null ? void 0 : agent.addMessage(message);
770
+ if (followUp) {
771
+ try {
772
+ yield copilotkit.runAgent({ agent });
773
+ } catch (error) {
774
+ console.error("CopilotChat: runAgent failed", error);
775
+ }
776
+ }
777
+ if (onSubmitMessage) {
778
+ const content = typeof message.content === "string" ? message.content : message.content && "text" in message.content ? message.content.text : message.content && "filename" in message.content ? message.content.filename : "";
779
+ onSubmitMessage(content);
780
+ }
781
+ }),
782
+ [agent, copilotkit, resolvedAgentId, onSubmitMessage]
783
+ );
784
+ const latestAppendFunc = useAsyncCallback(
785
+ (message, options) => __async(this, null, function* () {
786
+ return latestSendMessageFunc((0, import_runtime_client_gql2.gqlToAGUI)([message])[0], options);
787
+ }),
788
+ [latestSendMessageFunc]
789
+ );
790
+ const latestSetMessagesFunc = (0, import_react13.useCallback)(
791
+ (messages) => {
792
+ var _a2, _b2;
793
+ if (messages.every((message) => message instanceof import_runtime_client_gql2.Message)) {
794
+ return (_a2 = agent == null ? void 0 : agent.setMessages) == null ? void 0 : _a2.call(agent, (0, import_runtime_client_gql2.gqlToAGUI)(messages));
795
+ }
796
+ return (_b2 = agent == null ? void 0 : agent.setMessages) == null ? void 0 : _b2.call(agent, messages);
797
+ },
798
+ [agent == null ? void 0 : agent.setMessages, agent]
799
+ );
800
+ const latestReload = useUpdatedRef(reload);
801
+ const latestReloadFunc = useAsyncCallback(
802
+ (messageId) => __async(this, null, function* () {
803
+ var _a2;
804
+ onReloadMessages == null ? void 0 : onReloadMessages({
805
+ messageId,
806
+ currentAgentName: agent == null ? void 0 : agent.agentId,
807
+ messages: (_a2 = agent == null ? void 0 : agent.messages) != null ? _a2 : []
808
+ });
809
+ return yield latestReload.current(messageId);
810
+ }),
811
+ [latestReload, agent, onReloadMessages]
812
+ );
813
+ const latestStopFunc = (0, import_react13.useCallback)(() => {
814
+ var _a2, _b2;
815
+ onStopGeneration == null ? void 0 : onStopGeneration({
816
+ currentAgentName: agent == null ? void 0 : agent.agentId,
817
+ messages: (_a2 = agent == null ? void 0 : agent.messages) != null ? _a2 : []
818
+ });
819
+ return (_b2 = agent == null ? void 0 : agent.abortRun) == null ? void 0 : _b2.call(agent);
820
+ }, [onStopGeneration, agent]);
821
+ const latestReset = useUpdatedRef(reset);
822
+ const latestResetFunc = (0, import_react13.useCallback)(() => {
823
+ return latestReset.current();
824
+ }, [latestReset]);
825
+ const lazyToolRendered = useLazyToolRenderer();
826
+ const renderCustomMessage = (0, import_react14.useRenderCustomMessages)();
827
+ const legacyCustomMessageRenderer = useLegacyCoagentRenderer({
828
+ copilotkit,
829
+ agent,
830
+ agentId: resolvedAgentId,
831
+ threadId: (_b = existingConfig == null ? void 0 : existingConfig.threadId) != null ? _b : threadId
832
+ });
833
+ const allMessages = (_c = agent == null ? void 0 : agent.messages) != null ? _c : [];
834
+ const resolvedMessages = (0, import_react13.useMemo)(() => {
835
+ let processedMessages = allMessages.map((message) => {
836
+ if (message.role !== "assistant") {
837
+ return message;
838
+ }
839
+ const lazyRendered = lazyToolRendered(message, allMessages);
840
+ if (lazyRendered) {
841
+ const renderedGenUi = lazyRendered();
842
+ if (renderedGenUi) {
843
+ return __spreadProps(__spreadValues({}, message), { generativeUI: () => renderedGenUi });
844
+ }
845
+ }
846
+ const bridgeRenderer = legacyCustomMessageRenderer || renderCustomMessage ? () => {
847
+ const customRender = renderCustomMessage == null ? void 0 : renderCustomMessage({
848
+ message,
849
+ position: "before"
850
+ });
851
+ if (customRender) {
852
+ return customRender;
853
+ }
854
+ return legacyCustomMessageRenderer == null ? void 0 : legacyCustomMessageRenderer({ message, position: "before" });
855
+ } : null;
856
+ if (bridgeRenderer) {
857
+ return __spreadProps(__spreadValues({}, message), { generativeUI: bridgeRenderer });
858
+ }
859
+ return message;
860
+ });
861
+ const hasAssistantMessages = processedMessages.some((msg) => msg.role === "assistant");
862
+ return processedMessages;
863
+ }, [
864
+ agent == null ? void 0 : agent.messages,
865
+ lazyToolRendered,
866
+ allMessages,
867
+ renderCustomMessage,
868
+ // legacyCustomMessageRenderer,
869
+ resolvedAgentId
870
+ ]);
871
+ const renderedSuggestions = (0, import_react13.useMemo)(() => {
872
+ if (Array.isArray(suggestions)) {
873
+ return {
874
+ suggestions: suggestions.map((s) => __spreadProps(__spreadValues({}, s), { isLoading: false })),
875
+ isLoading: false
876
+ };
877
+ }
878
+ return currentSuggestions;
879
+ }, [suggestions, currentSuggestions]);
880
+ return {
881
+ messages: resolvedMessages,
882
+ sendMessage: latestSendMessageFunc,
883
+ appendMessage: latestAppendFunc,
884
+ setMessages: latestSetMessagesFunc,
885
+ reloadMessages: latestReloadFunc,
886
+ stopGeneration: latestStopFunc,
887
+ reset: latestResetFunc,
888
+ deleteMessage: latestDeleteFunc,
889
+ isAvailable: agentAvailable,
890
+ isLoading: Boolean(agent == null ? void 0 : agent.isRunning),
891
+ // mcpServers,
892
+ // setMcpServers,
893
+ suggestions: renderedSuggestions.suggestions,
894
+ setSuggestions: (suggestions2) => copilotkit.addSuggestionsConfig({ suggestions: suggestions2 }),
895
+ generateSuggestions: () => __async(this, null, function* () {
896
+ return copilotkit.reloadSuggestions(resolvedAgentId);
897
+ }),
898
+ resetSuggestions: () => copilotkit.clearSuggestions(resolvedAgentId),
899
+ isLoadingSuggestions: renderedSuggestions.isLoading,
900
+ interrupt,
901
+ agent,
902
+ threadId
903
+ };
904
+ }
905
+ function useUpdatedRef(value) {
906
+ const ref = (0, import_react13.useRef)(value);
907
+ (0, import_react13.useEffect)(() => {
908
+ ref.current = value;
909
+ }, [value]);
910
+ return ref;
911
+ }
912
+ function useLegacyCoagentRenderer({
913
+ copilotkit,
914
+ agent,
915
+ agentId,
916
+ threadId
917
+ }) {
918
+ return (0, import_react13.useMemo)(() => {
919
+ if (!copilotkit || !agent) {
920
+ return null;
921
+ }
922
+ return ({ message, position }) => {
923
+ var _a;
924
+ const effectiveThreadId = (_a = threadId != null ? threadId : agent.threadId) != null ? _a : "default";
925
+ const existingRunId = copilotkit.getRunIdForMessage(agentId, effectiveThreadId, message.id);
926
+ const runId = existingRunId || `pending:${message.id}`;
927
+ const messageIndex = Math.max(
928
+ agent.messages.findIndex((msg) => msg.id === message.id),
929
+ 0
930
+ );
931
+ const bridgeProps = {
932
+ message,
933
+ position,
934
+ runId,
935
+ messageIndex,
936
+ messageIndexInRun: 0,
937
+ numberOfMessagesInRun: 1,
938
+ agentId,
939
+ stateSnapshot: message.state
940
+ };
941
+ return (0, import_react13.createElement)(CoAgentStateRenderBridge, bridgeProps);
942
+ };
943
+ }, [agent, agentId, copilotkit, threadId]);
944
+ }
945
+ function defaultSystemMessage(contextString, additionalInstructions) {
946
+ return `
947
+ Please act as an efficient, competent, conscientious, and industrious professional assistant.
948
+
949
+ Help the user achieve their goals, and you do so in a way that is as efficient as possible, without unnecessary fluff, but also without sacrificing professionalism.
950
+ Always be polite and respectful, and prefer brevity over verbosity.
951
+
952
+ The user has provided you with the following context:
953
+ \`\`\`
954
+ ${contextString}
955
+ \`\`\`
956
+
957
+ They have also provided you with functions you can call to initiate actions on their behalf, or functions you can call to receive more information.
958
+
959
+ Please assist them as best you can.
960
+
961
+ You can ask them for clarifying questions if needed, but don't be annoying about it. If you can reasonably 'fill in the blanks' yourself, do so.
962
+
963
+ If you would like to call a function, call it without saying anything else.
964
+ In case of a function error:
965
+ - If this error stems from incorrect function parameters or syntax, you may retry with corrected arguments.
966
+ - If the error's source is unclear or seems unrelated to your input, do not attempt further retries.
967
+ ` + (additionalInstructions ? `
968
+
969
+ ${additionalInstructions}` : "");
970
+ }
971
+ // Annotate the CommonJS export names for ESM import in node:
972
+ 0 && (module.exports = {
973
+ defaultSystemMessage,
974
+ useCopilotChatInternal
975
+ });
976
+ //# sourceMappingURL=use-copilot-chat_internal.js.map