@copilotkit/react-core 0.0.0-fix-debug-infosys-20251107151227 → 0.0.0-fix-restore-handle-method-node-http-20251222114321

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 (355) hide show
  1. package/CHANGELOG.md +309 -4
  2. package/dist/chunk-36KQV2NA.mjs +1 -0
  3. package/dist/{chunk-RLR36R2Y.mjs → chunk-3V5TOYKW.mjs} +4 -4
  4. package/dist/chunk-3V5TOYKW.mjs.map +1 -0
  5. package/dist/chunk-4RRMC7L2.mjs +32 -0
  6. package/dist/chunk-4RRMC7L2.mjs.map +1 -0
  7. package/dist/chunk-4YZA2BZC.mjs +551 -0
  8. package/dist/chunk-4YZA2BZC.mjs.map +1 -0
  9. package/dist/{chunk-3HEGBDUK.mjs → chunk-53K6WNJG.mjs} +8 -6
  10. package/dist/{chunk-3HEGBDUK.mjs.map → chunk-53K6WNJG.mjs.map} +1 -1
  11. package/dist/{chunk-N4WEHORG.mjs → chunk-6PUNP7CD.mjs} +4 -4
  12. package/dist/chunk-6PUNP7CD.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-BBUQMG45.mjs → chunk-7IBF6RBW.mjs} +3 -3
  16. package/dist/{chunk-BBUQMG45.mjs.map → chunk-7IBF6RBW.mjs.map} +1 -1
  17. package/dist/chunk-A6NKSGH3.mjs +1 -0
  18. package/dist/{chunk-MGWRDFBE.mjs → chunk-ABWT4DRT.mjs} +2 -2
  19. package/dist/{chunk-EUX2P2E7.mjs → chunk-AFNWX62Q.mjs} +11 -9
  20. package/dist/chunk-AFNWX62Q.mjs.map +1 -0
  21. package/dist/{chunk-E6ER5C5U.mjs → chunk-BUSWSDYO.mjs} +2 -2
  22. package/dist/chunk-CDUIA2WM.mjs +60 -0
  23. package/dist/chunk-CDUIA2WM.mjs.map +1 -0
  24. package/dist/chunk-CYDWEPFL.mjs +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-GIGUZ2OK.mjs → chunk-E7SE25ZU.mjs} +3 -3
  28. package/dist/chunk-F555TVE4.mjs +33 -0
  29. package/dist/chunk-F555TVE4.mjs.map +1 -0
  30. package/dist/chunk-FD6FGKYY.mjs +1 -0
  31. package/dist/chunk-FDOMAPJY.mjs +59 -0
  32. package/dist/chunk-FDOMAPJY.mjs.map +1 -0
  33. package/dist/{chunk-BCZQ5BZB.mjs → chunk-FQFXYAV7.mjs} +6 -5
  34. package/dist/{chunk-BCZQ5BZB.mjs.map → chunk-FQFXYAV7.mjs.map} +1 -1
  35. package/dist/chunk-GPEJNVE5.mjs +80 -0
  36. package/dist/chunk-GPEJNVE5.mjs.map +1 -0
  37. package/dist/{chunk-FPOOU7AG.mjs → chunk-HE22TZMF.mjs} +10 -46
  38. package/dist/chunk-HE22TZMF.mjs.map +1 -0
  39. package/dist/chunk-I76HKHPJ.mjs +32 -0
  40. package/dist/chunk-I76HKHPJ.mjs.map +1 -0
  41. package/dist/chunk-JD7BAH7U.mjs +1 -0
  42. package/dist/{chunk-L3I57GMV.mjs → chunk-LHERIF3L.mjs} +4 -4
  43. package/dist/chunk-LSHFN2Y5.mjs +349 -0
  44. package/dist/chunk-LSHFN2Y5.mjs.map +1 -0
  45. package/dist/chunk-NB2FKV2V.mjs +1 -0
  46. package/dist/chunk-NBK4KBLX.mjs +54 -0
  47. package/dist/chunk-NBK4KBLX.mjs.map +1 -0
  48. package/dist/chunk-QNUAXSDP.mjs +166 -0
  49. package/dist/chunk-QNUAXSDP.mjs.map +1 -0
  50. package/dist/chunk-SPCZTZCY.mjs +1 -0
  51. package/dist/chunk-SPCZTZCY.mjs.map +1 -0
  52. package/dist/chunk-VV56AVPB.mjs +125 -0
  53. package/dist/chunk-VV56AVPB.mjs.map +1 -0
  54. package/dist/chunk-WF65O6HX.mjs +66 -0
  55. package/dist/chunk-WF65O6HX.mjs.map +1 -0
  56. package/dist/chunk-XDFVCQD3.mjs +27 -0
  57. package/dist/chunk-XDFVCQD3.mjs.map +1 -0
  58. package/dist/{chunk-TUTNHDM3.mjs → chunk-YCG6SNAU.mjs} +5 -5
  59. package/dist/{chunk-3WUDRJTT.mjs → chunk-YTQHRJUA.mjs} +9 -11
  60. package/dist/chunk-YTQHRJUA.mjs.map +1 -0
  61. package/dist/{chunk-5FHSUKQL.mjs → chunk-YYN33GSG.mjs} +5 -2
  62. package/dist/chunk-YYN33GSG.mjs.map +1 -0
  63. package/dist/chunk-Z6JV2LRY.mjs +37 -0
  64. package/dist/chunk-Z6JV2LRY.mjs.map +1 -0
  65. package/dist/chunk-ZVF5Q6IH.mjs +29 -0
  66. package/dist/chunk-ZVF5Q6IH.mjs.map +1 -0
  67. package/dist/chunk-ZYTXB6HH.mjs +151 -0
  68. package/dist/chunk-ZYTXB6HH.mjs.map +1 -0
  69. package/dist/components/CopilotListeners.d.ts +3 -0
  70. package/dist/components/CopilotListeners.js +101 -0
  71. package/dist/components/CopilotListeners.js.map +1 -0
  72. package/dist/components/CopilotListeners.mjs +9 -0
  73. package/dist/components/CopilotListeners.mjs.map +1 -0
  74. package/dist/components/copilot-provider/copilot-messages.js +14 -48
  75. package/dist/components/copilot-provider/copilot-messages.js.map +1 -1
  76. package/dist/components/copilot-provider/copilot-messages.mjs +3 -3
  77. package/dist/components/copilot-provider/copilotkit-props.d.ts +15 -2
  78. package/dist/components/copilot-provider/copilotkit-props.js.map +1 -1
  79. package/dist/components/copilot-provider/copilotkit.d.ts +2 -1
  80. package/dist/components/copilot-provider/copilotkit.js +491 -1361
  81. package/dist/components/copilot-provider/copilotkit.js.map +1 -1
  82. package/dist/components/copilot-provider/copilotkit.mjs +14 -12
  83. package/dist/components/copilot-provider/index.d.ts +2 -1
  84. package/dist/components/copilot-provider/index.js +491 -1361
  85. package/dist/components/copilot-provider/index.js.map +1 -1
  86. package/dist/components/copilot-provider/index.mjs +15 -12
  87. package/dist/components/dev-console/console-trigger.js +10 -8
  88. package/dist/components/dev-console/console-trigger.js.map +1 -1
  89. package/dist/components/dev-console/console-trigger.mjs +226 -6
  90. package/dist/components/dev-console/console-trigger.mjs.map +1 -1
  91. package/dist/components/dev-console/developer-console-modal.js +10 -8
  92. package/dist/components/dev-console/developer-console-modal.js.map +1 -1
  93. package/dist/components/dev-console/developer-console-modal.mjs +3 -3
  94. package/dist/components/error-boundary/error-boundary.d.ts +7 -7
  95. package/dist/components/error-boundary/error-boundary.js +3 -3
  96. package/dist/components/error-boundary/error-boundary.js.map +1 -1
  97. package/dist/components/error-boundary/error-boundary.mjs +3 -3
  98. package/dist/components/error-boundary/error-utils.d.ts +1 -1
  99. package/dist/components/error-boundary/error-utils.js +3 -3
  100. package/dist/components/error-boundary/error-utils.js.map +1 -1
  101. package/dist/components/error-boundary/error-utils.mjs +1 -1
  102. package/dist/components/index.d.ts +2 -1
  103. package/dist/components/index.js +491 -1361
  104. package/dist/components/index.js.map +1 -1
  105. package/dist/components/index.mjs +16 -12
  106. package/dist/components/toast/exclamation-mark-icon.d.ts +2 -2
  107. package/dist/components/toast/toast-provider.d.ts +3 -3
  108. package/dist/components/usage-banner.d.ts +2 -2
  109. package/dist/context/coagent-state-renders-context.d.ts +24 -0
  110. package/dist/context/coagent-state-renders-context.js +91 -0
  111. package/dist/context/coagent-state-renders-context.js.map +1 -0
  112. package/dist/context/coagent-state-renders-context.mjs +12 -0
  113. package/dist/context/coagent-state-renders-context.mjs.map +1 -0
  114. package/dist/context/copilot-context.d.ts +1 -1
  115. package/dist/context/copilot-context.js +10 -8
  116. package/dist/context/copilot-context.js.map +1 -1
  117. package/dist/context/copilot-context.mjs +1 -1
  118. package/dist/context/copilot-messages-context.d.ts +18 -11
  119. package/dist/context/copilot-messages-context.js.map +1 -1
  120. package/dist/context/copilot-messages-context.mjs +1 -1
  121. package/dist/context/index.d.ts +6 -2
  122. package/dist/context/index.js +110 -10
  123. package/dist/context/index.js.map +1 -1
  124. package/dist/context/index.mjs +22 -6
  125. package/dist/context/threads-context.d.ts +16 -0
  126. package/dist/context/threads-context.js +59 -0
  127. package/dist/context/threads-context.js.map +1 -0
  128. package/dist/context/threads-context.mjs +12 -0
  129. package/dist/context/threads-context.mjs.map +1 -0
  130. package/dist/{copilot-context-cf9de848.d.ts → copilot-context-ec77e921.d.ts} +36 -32
  131. package/dist/hooks/index.d.ts +9 -6
  132. package/dist/hooks/index.js +1109 -1841
  133. package/dist/hooks/index.js.map +1 -1
  134. package/dist/hooks/index.mjs +50 -58
  135. package/dist/hooks/use-agent-nodename.d.ts +3 -0
  136. package/dist/hooks/use-agent-nodename.js +56 -0
  137. package/dist/hooks/use-agent-nodename.js.map +1 -0
  138. package/dist/hooks/use-agent-nodename.mjs +8 -0
  139. package/dist/hooks/use-agent-nodename.mjs.map +1 -0
  140. package/dist/hooks/use-coagent-state-render-bridge.d.ts +100 -0
  141. package/dist/hooks/use-coagent-state-render-bridge.js +214 -0
  142. package/dist/hooks/use-coagent-state-render-bridge.js.map +1 -0
  143. package/dist/hooks/use-coagent-state-render-bridge.mjs +15 -0
  144. package/dist/hooks/use-coagent-state-render-bridge.mjs.map +1 -0
  145. package/dist/hooks/use-coagent-state-render.js +31 -20
  146. package/dist/hooks/use-coagent-state-render.js.map +1 -1
  147. package/dist/hooks/use-coagent-state-render.mjs +3 -2
  148. package/dist/hooks/use-coagent.d.ts +2 -14
  149. package/dist/hooks/use-coagent.js +138 -1898
  150. package/dist/hooks/use-coagent.js.map +1 -1
  151. package/dist/hooks/use-coagent.mjs +2 -30
  152. package/dist/hooks/use-configure-chat-suggestions.d.ts +36 -0
  153. package/dist/hooks/use-configure-chat-suggestions.js +79 -0
  154. package/dist/hooks/use-configure-chat-suggestions.js.map +1 -0
  155. package/dist/hooks/use-configure-chat-suggestions.mjs +47 -0
  156. package/dist/hooks/use-configure-chat-suggestions.mjs.map +1 -0
  157. package/dist/hooks/use-copilot-action.d.ts +8 -45
  158. package/dist/hooks/use-copilot-action.js +219 -349
  159. package/dist/hooks/use-copilot-action.js.map +1 -1
  160. package/dist/hooks/use-copilot-action.mjs +4 -5
  161. package/dist/hooks/use-copilot-additional-instructions.js +10 -8
  162. package/dist/hooks/use-copilot-additional-instructions.js.map +1 -1
  163. package/dist/hooks/use-copilot-additional-instructions.mjs +2 -2
  164. package/dist/hooks/use-copilot-authenticated-action.js +236 -248
  165. package/dist/hooks/use-copilot-authenticated-action.js.map +1 -1
  166. package/dist/hooks/use-copilot-authenticated-action.mjs +6 -6
  167. package/dist/hooks/use-copilot-chat-headless_c.d.ts +2 -10
  168. package/dist/hooks/use-copilot-chat-headless_c.js +585 -1374
  169. package/dist/hooks/use-copilot-chat-headless_c.js.map +1 -1
  170. package/dist/hooks/use-copilot-chat-headless_c.mjs +12 -22
  171. package/dist/hooks/use-copilot-chat-suggestions.d.ts +35 -0
  172. package/dist/hooks/use-copilot-chat-suggestions.js +60 -0
  173. package/dist/hooks/use-copilot-chat-suggestions.js.map +1 -0
  174. package/dist/hooks/use-copilot-chat-suggestions.mjs +8 -0
  175. package/dist/hooks/use-copilot-chat-suggestions.mjs.map +1 -0
  176. package/dist/hooks/use-copilot-chat.d.ts +2 -10
  177. package/dist/hooks/use-copilot-chat.js +579 -1393
  178. package/dist/hooks/use-copilot-chat.js.map +1 -1
  179. package/dist/hooks/use-copilot-chat.mjs +12 -22
  180. package/dist/hooks/use-copilot-chat_internal.d.ts +77 -14
  181. package/dist/hooks/use-copilot-chat_internal.js +577 -1367
  182. package/dist/hooks/use-copilot-chat_internal.js.map +1 -1
  183. package/dist/hooks/use-copilot-chat_internal.mjs +13 -23
  184. package/dist/hooks/use-copilot-readable.d.ts +1 -1
  185. package/dist/hooks/use-copilot-readable.js +25 -152
  186. package/dist/hooks/use-copilot-readable.js.map +1 -1
  187. package/dist/hooks/use-copilot-readable.mjs +1 -2
  188. package/dist/hooks/use-default-tool.js +216 -349
  189. package/dist/hooks/use-default-tool.js.map +1 -1
  190. package/dist/hooks/use-default-tool.mjs +5 -6
  191. package/dist/hooks/use-flat-category-store.js +4 -1
  192. package/dist/hooks/use-flat-category-store.js.map +1 -1
  193. package/dist/hooks/use-flat-category-store.mjs +1 -1
  194. package/dist/hooks/use-frontend-tool.d.ts +3 -3
  195. package/dist/hooks/use-frontend-tool.js +42 -370
  196. package/dist/hooks/use-frontend-tool.js.map +1 -1
  197. package/dist/hooks/use-frontend-tool.mjs +1 -6
  198. package/dist/hooks/use-human-in-the-loop.d.ts +4 -3
  199. package/dist/hooks/use-human-in-the-loop.js +61 -393
  200. package/dist/hooks/use-human-in-the-loop.js.map +1 -1
  201. package/dist/hooks/use-human-in-the-loop.mjs +1 -6
  202. package/dist/hooks/use-langgraph-interrupt-render.d.ts +3 -2
  203. package/dist/hooks/use-langgraph-interrupt-render.js +157 -37
  204. package/dist/hooks/use-langgraph-interrupt-render.js.map +1 -1
  205. package/dist/hooks/use-langgraph-interrupt-render.mjs +7 -4
  206. package/dist/hooks/use-langgraph-interrupt.d.ts +1 -1
  207. package/dist/hooks/use-langgraph-interrupt.js +24 -1642
  208. package/dist/hooks/use-langgraph-interrupt.js.map +1 -1
  209. package/dist/hooks/use-langgraph-interrupt.mjs +2 -23
  210. package/dist/hooks/use-lazy-tool-renderer.d.ts +6 -0
  211. package/dist/hooks/use-lazy-tool-renderer.js +53 -0
  212. package/dist/hooks/use-lazy-tool-renderer.js.map +1 -0
  213. package/dist/hooks/use-lazy-tool-renderer.mjs +8 -0
  214. package/dist/hooks/use-lazy-tool-renderer.mjs.map +1 -0
  215. package/dist/hooks/use-make-copilot-document-readable.js +11 -9
  216. package/dist/hooks/use-make-copilot-document-readable.js.map +1 -1
  217. package/dist/hooks/use-make-copilot-document-readable.mjs +2 -2
  218. package/dist/hooks/use-render-tool-call.d.ts +7 -6
  219. package/dist/hooks/use-render-tool-call.js +36 -386
  220. package/dist/hooks/use-render-tool-call.js.map +1 -1
  221. package/dist/hooks/use-render-tool-call.mjs +1 -6
  222. package/dist/index.d.ts +11 -6
  223. package/dist/index.js +1456 -3033
  224. package/dist/index.js.map +1 -1
  225. package/dist/index.mjs +82 -65
  226. package/dist/lib/copilot-task.d.ts +2 -2
  227. package/dist/lib/copilot-task.js +1 -0
  228. package/dist/lib/copilot-task.js.map +1 -1
  229. package/dist/lib/copilot-task.mjs +18 -14
  230. package/dist/lib/index.d.ts +1 -1
  231. package/dist/lib/index.js +1 -0
  232. package/dist/lib/index.js.map +1 -1
  233. package/dist/lib/index.mjs +18 -14
  234. package/dist/setupTests.d.ts +2 -2
  235. package/dist/types/frontend-action.d.ts +5 -5
  236. package/dist/types/index.d.ts +4 -0
  237. package/dist/types/index.js.map +1 -1
  238. package/dist/types/index.mjs +2 -1
  239. package/dist/types/interrupt-action.d.ts +1 -1
  240. package/dist/types/interrupt-action.js.map +1 -1
  241. package/dist/types/interrupt-action.mjs +1 -0
  242. package/dist/utils/index.d.ts +0 -12
  243. package/dist/utils/index.js +6 -325
  244. package/dist/utils/index.js.map +1 -1
  245. package/dist/utils/index.mjs +1 -21
  246. package/dist/utils/utils.js.map +1 -1
  247. package/dist/v2/index.css +4 -0
  248. package/dist/v2/index.css.map +1 -0
  249. package/dist/v2/index.d.ts +2 -0
  250. package/dist/v2/index.js +27 -0
  251. package/dist/v2/index.js.map +1 -0
  252. package/dist/v2/index.mjs +6 -0
  253. package/dist/v2/index.mjs.map +1 -0
  254. package/jest.config.js +12 -0
  255. package/package.json +24 -10
  256. package/src/components/CopilotListeners.tsx +81 -0
  257. package/src/components/copilot-provider/copilot-messages.tsx +6 -48
  258. package/src/components/copilot-provider/copilotkit-props.tsx +15 -1
  259. package/src/components/copilot-provider/copilotkit.tsx +189 -148
  260. package/src/components/error-boundary/error-utils.tsx +3 -3
  261. package/src/context/coagent-state-renders-context.tsx +76 -0
  262. package/src/context/copilot-context.tsx +21 -21
  263. package/src/context/copilot-messages-context.tsx +3 -3
  264. package/src/context/index.ts +8 -0
  265. package/src/context/threads-context.tsx +41 -0
  266. package/src/hooks/__tests__/use-coagent-config.test.ts +189 -129
  267. package/src/hooks/index.ts +12 -3
  268. package/src/hooks/use-agent-nodename.ts +30 -0
  269. package/src/hooks/use-coagent-state-render-bridge.tsx +293 -0
  270. package/src/hooks/use-coagent-state-render.ts +4 -7
  271. package/src/hooks/use-coagent.ts +136 -247
  272. package/src/hooks/use-configure-chat-suggestions.tsx +86 -0
  273. package/src/hooks/use-copilot-action.ts +88 -199
  274. package/src/hooks/use-copilot-chat-headless_c.ts +2 -1
  275. package/src/hooks/use-copilot-chat-suggestions.tsx +124 -0
  276. package/src/hooks/use-copilot-chat.ts +4 -1
  277. package/src/hooks/use-copilot-chat_internal.ts +410 -263
  278. package/src/hooks/use-copilot-readable.ts +23 -25
  279. package/src/hooks/use-flat-category-store.ts +4 -3
  280. package/src/hooks/use-frontend-tool.ts +86 -8
  281. package/src/hooks/use-human-in-the-loop.ts +111 -13
  282. package/src/hooks/use-langgraph-interrupt-render.ts +108 -40
  283. package/src/hooks/use-langgraph-interrupt.ts +18 -48
  284. package/src/hooks/use-lazy-tool-renderer.tsx +30 -0
  285. package/src/hooks/use-make-copilot-document-readable.ts +1 -1
  286. package/src/hooks/use-render-tool-call.ts +73 -13
  287. package/src/lib/copilot-task.ts +1 -1
  288. package/src/types/index.ts +1 -0
  289. package/src/types/interrupt-action.ts +8 -7
  290. package/src/utils/index.ts +0 -3
  291. package/src/utils/utils.ts +7 -0
  292. package/src/v2/index.css +1 -0
  293. package/src/v2/index.ts +4 -0
  294. package/tsup.config.ts +1 -1
  295. package/dist/chunk-3MUCKQXM.mjs +0 -71
  296. package/dist/chunk-3MUCKQXM.mjs.map +0 -1
  297. package/dist/chunk-3WUDRJTT.mjs.map +0 -1
  298. package/dist/chunk-4I6ZMKGV.mjs +0 -723
  299. package/dist/chunk-4I6ZMKGV.mjs.map +0 -1
  300. package/dist/chunk-5FHSUKQL.mjs.map +0 -1
  301. package/dist/chunk-CUWOXXM5.mjs +0 -231
  302. package/dist/chunk-CUWOXXM5.mjs.map +0 -1
  303. package/dist/chunk-DZTU6PGS.mjs +0 -1
  304. package/dist/chunk-EUX2P2E7.mjs.map +0 -1
  305. package/dist/chunk-FPOOU7AG.mjs.map +0 -1
  306. package/dist/chunk-H4AHA2Y7.mjs +0 -22
  307. package/dist/chunk-H4AHA2Y7.mjs.map +0 -1
  308. package/dist/chunk-HDOG2RTM.mjs +0 -37
  309. package/dist/chunk-HDOG2RTM.mjs.map +0 -1
  310. package/dist/chunk-HI6SPUOX.mjs +0 -142
  311. package/dist/chunk-HI6SPUOX.mjs.map +0 -1
  312. package/dist/chunk-IN74FLIZ.mjs +0 -804
  313. package/dist/chunk-IN74FLIZ.mjs.map +0 -1
  314. package/dist/chunk-N4WEHORG.mjs.map +0 -1
  315. package/dist/chunk-R4Y45UGQ.mjs +0 -25
  316. package/dist/chunk-R4Y45UGQ.mjs.map +0 -1
  317. package/dist/chunk-RLR36R2Y.mjs.map +0 -1
  318. package/dist/chunk-W2UUH57V.mjs +0 -332
  319. package/dist/chunk-W2UUH57V.mjs.map +0 -1
  320. package/dist/chunk-X5GRTEAW.mjs +0 -13
  321. package/dist/chunk-X5GRTEAW.mjs.map +0 -1
  322. package/dist/chunk-YAV3YNFQ.mjs +0 -239
  323. package/dist/chunk-YAV3YNFQ.mjs.map +0 -1
  324. package/dist/chunk-YPBKY4KY.mjs +0 -1
  325. package/dist/chunk-YPSGKPDA.mjs +0 -1
  326. package/dist/chunk-ZLQVRPDS.mjs.map +0 -1
  327. package/dist/chunk-ZVOLWJCY.mjs +0 -47
  328. package/dist/chunk-ZVOLWJCY.mjs.map +0 -1
  329. package/dist/hooks/use-chat.d.ts +0 -145
  330. package/dist/hooks/use-chat.js +0 -1129
  331. package/dist/hooks/use-chat.js.map +0 -1
  332. package/dist/hooks/use-chat.mjs +0 -14
  333. package/dist/index-1f5b66ac.d.ts +0 -36
  334. package/dist/utils/extract.d.ts +0 -43
  335. package/dist/utils/extract.js +0 -208
  336. package/dist/utils/extract.js.map +0 -1
  337. package/dist/utils/extract.mjs +0 -25
  338. package/dist/utils/suggestions.d.ts +0 -11
  339. package/dist/utils/suggestions.js +0 -343
  340. package/dist/utils/suggestions.js.map +0 -1
  341. package/dist/utils/suggestions.mjs +0 -25
  342. package/src/hooks/use-chat.ts +0 -1142
  343. package/src/utils/extract.ts +0 -215
  344. package/src/utils/suggestions.ts +0 -208
  345. /package/dist/{chunk-DZTU6PGS.mjs.map → chunk-36KQV2NA.mjs.map} +0 -0
  346. /package/dist/{chunk-YPBKY4KY.mjs.map → chunk-A6NKSGH3.mjs.map} +0 -0
  347. /package/dist/{chunk-MGWRDFBE.mjs.map → chunk-ABWT4DRT.mjs.map} +0 -0
  348. /package/dist/{chunk-E6ER5C5U.mjs.map → chunk-BUSWSDYO.mjs.map} +0 -0
  349. /package/dist/{chunk-YPSGKPDA.mjs.map → chunk-CYDWEPFL.mjs.map} +0 -0
  350. /package/dist/{chunk-GIGUZ2OK.mjs.map → chunk-E7SE25ZU.mjs.map} +0 -0
  351. /package/dist/{hooks/use-chat.mjs.map → chunk-FD6FGKYY.mjs.map} +0 -0
  352. /package/dist/{utils/extract.mjs.map → chunk-JD7BAH7U.mjs.map} +0 -0
  353. /package/dist/{chunk-L3I57GMV.mjs.map → chunk-LHERIF3L.mjs.map} +0 -0
  354. /package/dist/{utils/suggestions.mjs.map → chunk-NB2FKV2V.mjs.map} +0 -0
  355. /package/dist/{chunk-TUTNHDM3.mjs.map → chunk-YCG6SNAU.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,231 @@ __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(
84
+ import_react.default.Fragment,
85
+ null,
86
+ staticRender
87
+ );
119
88
  }
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>` !!!");
89
+ return (args) => {
90
+ const renderArgs = __spreadProps(__spreadValues({}, args), {
91
+ result: typeof args.result === "string" ? (0, import_shared2.parseJson)(args.result, args.result) : args.result
92
+ });
93
+ const rendered = render(renderArgs);
94
+ if (typeof rendered === "string") {
95
+ return import_react.default.createElement(import_react.default.Fragment, null, rendered);
96
+ }
97
+ return rendered != null ? rendered : null;
98
+ };
99
+ })();
100
+ const handlerRef = (0, import_react.useRef)(tool.handler);
101
+ (0, import_react.useEffect)(() => {
102
+ handlerRef.current = tool.handler;
103
+ }, [tool.handler, ...dependencies != null ? dependencies : []]);
104
+ const normalizedHandler = tool.handler ? (args) => {
105
+ var _a;
106
+ return (_a = handlerRef.current) == null ? void 0 : _a.call(handlerRef, args);
107
+ } : void 0;
108
+ (0, import_react2.useFrontendTool)({
109
+ name,
110
+ description,
111
+ parameters: zodParameters,
112
+ handler: normalizedHandler,
113
+ followUp,
114
+ render: normalizedRender
115
+ });
175
116
  }
176
117
 
177
- // src/components/error-boundary/error-utils.tsx
118
+ // src/hooks/use-render-tool-call.ts
119
+ var import_shared3 = require("@copilotkit/shared");
178
120
  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;
121
+ var import_react4 = require("@copilotkitnext/react");
122
+ var import_shared4 = require("@copilotkit/shared");
123
+ function useRenderToolCall(tool, dependencies) {
124
+ const { copilotkit } = (0, import_react4.useCopilotKit)();
125
+ const hasAddedRef = (0, import_react3.useRef)(false);
126
+ (0, import_react3.useEffect)(() => {
127
+ const { name, parameters, render } = tool;
128
+ const zodParameters = (0, import_shared3.getZodParameters)(parameters);
129
+ const renderToolCall = name === "*" ? (0, import_react4.defineToolCallRenderer)({
130
+ name: "*",
131
+ render: (args) => {
132
+ return render(__spreadProps(__spreadValues({}, args), {
133
+ result: args.result ? (0, import_shared4.parseJson)(args.result, args.result) : args.result
134
+ }));
135
+ }
136
+ }) : (0, import_react4.defineToolCallRenderer)({
137
+ name,
138
+ args: zodParameters,
139
+ render: (args) => {
140
+ return render(__spreadProps(__spreadValues({}, args), {
141
+ result: args.result ? (0, import_shared4.parseJson)(args.result, args.result) : args.result
142
+ }));
143
+ }
144
+ });
145
+ const existingIndex = copilotkit.renderToolCalls.findIndex((r) => r.name === name);
146
+ if (existingIndex !== -1) {
147
+ copilotkit.renderToolCalls.splice(existingIndex, 1);
301
148
  }
302
- }), deps);
149
+ copilotkit.renderToolCalls.push(renderToolCall);
150
+ hasAddedRef.current = true;
151
+ return () => {
152
+ if (hasAddedRef.current) {
153
+ const index = copilotkit.renderToolCalls.findIndex((r) => r.name === name);
154
+ if (index !== -1) {
155
+ copilotkit.renderToolCalls.splice(index, 1);
156
+ }
157
+ hasAddedRef.current = false;
158
+ }
159
+ };
160
+ }, [tool, ...dependencies != null ? dependencies : []]);
303
161
  }
304
162
 
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
- }
163
+ // src/hooks/use-human-in-the-loop.ts
164
+ var import_shared5 = require("@copilotkit/shared");
165
+ var import_react5 = require("@copilotkitnext/react");
166
+ var import_core = require("@copilotkitnext/core");
167
+ var import_react6 = __toESM(require("react"));
168
+ function useHumanInTheLoop(tool, dependencies) {
169
+ const _a = tool, { render } = _a, toolRest = __objRest(_a, ["render"]);
170
+ const { name, description, parameters, followUp } = toolRest;
171
+ const zodParameters = (0, import_shared5.getZodParameters)(parameters);
172
+ const renderRef = (0, import_react6.useRef)(null);
173
+ (0, import_react6.useEffect)(() => {
174
+ renderRef.current = (args) => {
175
+ if (typeof render === "string") {
176
+ return import_react6.default.createElement(import_react6.default.Fragment, null, render);
351
177
  }
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);
178
+ if (!render) {
179
+ return null;
180
+ }
181
+ const renderProps = (() => {
182
+ const mappedArgs = args.args;
183
+ switch (args.status) {
184
+ case import_core.ToolCallStatus.InProgress:
185
+ return {
186
+ args: mappedArgs,
187
+ respond: args.respond,
188
+ status: args.status,
189
+ handler: void 0
190
+ };
191
+ case import_core.ToolCallStatus.Executing:
192
+ return {
193
+ args: mappedArgs,
194
+ respond: args.respond,
195
+ status: args.status,
196
+ handler: () => {
197
+ }
198
+ };
199
+ case import_core.ToolCallStatus.Complete:
200
+ return {
201
+ args: mappedArgs,
202
+ respond: args.respond,
203
+ status: args.status,
204
+ result: args.result ? (0, import_shared5.parseJson)(args.result, args.result) : args.result,
205
+ handler: void 0
206
+ };
207
+ default:
208
+ throw new import_shared5.CopilotKitError({
209
+ code: import_shared5.CopilotKitErrorCode.UNKNOWN,
210
+ message: `Invalid tool call status: ${args.status}`
211
+ });
370
212
  }
213
+ })();
214
+ const rendered = render(renderProps);
215
+ if (typeof rendered === "string") {
216
+ return import_react6.default.createElement(import_react6.default.Fragment, null, rendered);
371
217
  }
372
- return (0, import_react4.createElement)(import_react4.Fragment);
218
+ return rendered != null ? rendered : null;
219
+ };
220
+ }, [render, ...dependencies != null ? dependencies : []]);
221
+ (0, import_react5.useHumanInTheLoop)({
222
+ name,
223
+ description,
224
+ followUp,
225
+ parameters: zodParameters,
226
+ render: (args) => {
227
+ var _a2, _b;
228
+ return (_b = (_a2 = renderRef.current) == null ? void 0 : _a2.call(renderRef, args)) != null ? _b : null;
229
+ }
230
+ });
231
+ }
232
+
233
+ // src/hooks/use-copilot-action.ts
234
+ function getActionConfig(action) {
235
+ if (action.name === "*") {
236
+ return {
237
+ type: "render",
238
+ action
373
239
  };
374
240
  }
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
- }
241
+ if ("renderAndWaitForResponse" in action || "renderAndWait" in action) {
242
+ let render = action.render;
243
+ if (!render && "renderAndWaitForResponse" in action) {
244
+ render = action.renderAndWaitForResponse;
245
+ }
246
+ if (!render && "renderAndWait" in action) {
247
+ render = action.renderAndWait;
385
248
  }
249
+ return {
250
+ type: "hitl",
251
+ action: __spreadProps(__spreadValues({}, action), { render })
252
+ };
386
253
  }
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
- });
254
+ if ("available" in action) {
255
+ if (action.available === "enabled" || action.available === "remote") {
256
+ return {
257
+ type: "frontend",
258
+ action
259
+ };
397
260
  }
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;
261
+ if (action.available === "frontend" || action.available === "disabled") {
262
+ return {
263
+ type: "render",
264
+ action
265
+ };
403
266
  }
404
- return () => {
405
- removeAction(idRef.current);
267
+ }
268
+ if ("handler" in action) {
269
+ return {
270
+ type: "frontend",
271
+ action
406
272
  };
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
- ]);
273
+ }
274
+ throw new Error("Invalid action configuration");
422
275
  }
423
- function isFrontendAction(action) {
424
- return action.name !== "*";
276
+ function useCopilotAction(action, dependencies) {
277
+ const [initialActionConfig] = (0, import_react7.useState)(getActionConfig(action));
278
+ const currentActionConfig = getActionConfig(action);
279
+ if (initialActionConfig.type !== currentActionConfig.type) {
280
+ throw new Error("Action configuration changed between renders");
281
+ }
282
+ switch (currentActionConfig.type) {
283
+ case "render":
284
+ return useRenderToolCall(currentActionConfig.action, dependencies);
285
+ case "hitl":
286
+ return useHumanInTheLoop(currentActionConfig.action, dependencies);
287
+ case "frontend":
288
+ return useFrontendTool(currentActionConfig.action, dependencies);
289
+ default:
290
+ throw new Error("Invalid action configuration");
291
+ }
425
292
  }
426
293
 
427
294
  // src/hooks/use-default-tool.ts