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

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-OKCYPO4I.mjs → chunk-3MHWEKFN.mjs} +5 -5
  4. package/dist/chunk-4RRMC7L2.mjs +32 -0
  5. package/dist/chunk-4RRMC7L2.mjs.map +1 -0
  6. package/dist/{chunk-E3624YDU.mjs → chunk-53K6WNJG.mjs} +8 -6
  7. package/dist/{chunk-E3624YDU.mjs.map → chunk-53K6WNJG.mjs.map} +1 -1
  8. package/dist/{chunk-N4WEHORG.mjs → chunk-6PUNP7CD.mjs} +4 -4
  9. package/dist/chunk-6PUNP7CD.mjs.map +1 -0
  10. package/dist/chunk-7DTB7S5V.mjs +83 -0
  11. package/dist/chunk-7DTB7S5V.mjs.map +1 -0
  12. package/dist/{chunk-BBUQMG45.mjs → chunk-7IBF6RBW.mjs} +3 -3
  13. package/dist/{chunk-BBUQMG45.mjs.map → chunk-7IBF6RBW.mjs.map} +1 -1
  14. package/dist/chunk-A6NKSGH3.mjs +1 -0
  15. package/dist/{chunk-MGWRDFBE.mjs → chunk-ABWT4DRT.mjs} +2 -2
  16. package/dist/{chunk-EUX2P2E7.mjs → chunk-AFNWX62Q.mjs} +11 -9
  17. package/dist/chunk-AFNWX62Q.mjs.map +1 -0
  18. package/dist/{chunk-MQYWH4E6.mjs → chunk-BUSWSDYO.mjs} +2 -2
  19. package/dist/chunk-CDUIA2WM.mjs +60 -0
  20. package/dist/chunk-CDUIA2WM.mjs.map +1 -0
  21. package/dist/chunk-CYDWEPFL.mjs +1 -0
  22. package/dist/{chunk-ZLQVRPDS.mjs → chunk-DMLQZG75.mjs} +1 -1
  23. package/dist/chunk-DMLQZG75.mjs.map +1 -0
  24. package/dist/{chunk-U7QULEVO.mjs → chunk-E7SE25ZU.mjs} +3 -3
  25. package/dist/chunk-F555TVE4.mjs +33 -0
  26. package/dist/chunk-F555TVE4.mjs.map +1 -0
  27. package/dist/chunk-FD6FGKYY.mjs +1 -0
  28. package/dist/chunk-FDOMAPJY.mjs +59 -0
  29. package/dist/chunk-FDOMAPJY.mjs.map +1 -0
  30. package/dist/{chunk-OAGAFMUM.mjs → chunk-FQFXYAV7.mjs} +6 -5
  31. package/dist/{chunk-OAGAFMUM.mjs.map → chunk-FQFXYAV7.mjs.map} +1 -1
  32. package/dist/chunk-GPEJNVE5.mjs +80 -0
  33. package/dist/chunk-GPEJNVE5.mjs.map +1 -0
  34. package/dist/chunk-I76HKHPJ.mjs +32 -0
  35. package/dist/chunk-I76HKHPJ.mjs.map +1 -0
  36. package/dist/{chunk-C6IANC2R.mjs → chunk-INPM7YKW.mjs} +9 -45
  37. package/dist/chunk-INPM7YKW.mjs.map +1 -0
  38. package/dist/chunk-JD7BAH7U.mjs +1 -0
  39. package/dist/chunk-LSHFN2Y5.mjs +349 -0
  40. package/dist/chunk-LSHFN2Y5.mjs.map +1 -0
  41. package/dist/chunk-NB2FKV2V.mjs +1 -0
  42. package/dist/chunk-NBK4KBLX.mjs +54 -0
  43. package/dist/chunk-NBK4KBLX.mjs.map +1 -0
  44. package/dist/chunk-QNUAXSDP.mjs +166 -0
  45. package/dist/chunk-QNUAXSDP.mjs.map +1 -0
  46. package/dist/chunk-RB2TXKFP.mjs +551 -0
  47. package/dist/chunk-RB2TXKFP.mjs.map +1 -0
  48. package/dist/{chunk-EDBI5PCJ.mjs → chunk-RW2Y52HO.mjs} +2 -2
  49. package/dist/chunk-RW2Y52HO.mjs.map +1 -0
  50. package/dist/{chunk-N4VN2B5S.mjs → chunk-SNON4QA6.mjs} +4 -4
  51. package/dist/chunk-SPCZTZCY.mjs +1 -0
  52. package/dist/chunk-SPCZTZCY.mjs.map +1 -0
  53. package/dist/chunk-VV56AVPB.mjs +125 -0
  54. package/dist/chunk-VV56AVPB.mjs.map +1 -0
  55. package/dist/chunk-WF65O6HX.mjs +66 -0
  56. package/dist/chunk-WF65O6HX.mjs.map +1 -0
  57. package/dist/chunk-XDFVCQD3.mjs +27 -0
  58. package/dist/chunk-XDFVCQD3.mjs.map +1 -0
  59. package/dist/{chunk-GT5WI3AF.mjs → chunk-YTQHRJUA.mjs} +7 -9
  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 +15 -13
  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 +16 -13
  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 +17 -13
  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 +23 -7
  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 +45 -53
  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 +85 -68
  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-5FHSUKQL.mjs.map +0 -1
  296. package/dist/chunk-6GPVUMBU.mjs +0 -13
  297. package/dist/chunk-6GPVUMBU.mjs.map +0 -1
  298. package/dist/chunk-AKR2SSUJ.mjs +0 -22
  299. package/dist/chunk-AKR2SSUJ.mjs.map +0 -1
  300. package/dist/chunk-BXXJQ2BL.mjs +0 -239
  301. package/dist/chunk-BXXJQ2BL.mjs.map +0 -1
  302. package/dist/chunk-C6IANC2R.mjs.map +0 -1
  303. package/dist/chunk-DXEQPN43.mjs +0 -231
  304. package/dist/chunk-DXEQPN43.mjs.map +0 -1
  305. package/dist/chunk-DZTU6PGS.mjs +0 -1
  306. package/dist/chunk-EDBI5PCJ.mjs.map +0 -1
  307. package/dist/chunk-EUX2P2E7.mjs.map +0 -1
  308. package/dist/chunk-EVVO67QO.mjs +0 -25
  309. package/dist/chunk-EVVO67QO.mjs.map +0 -1
  310. package/dist/chunk-GGLAHG3I.mjs +0 -804
  311. package/dist/chunk-GGLAHG3I.mjs.map +0 -1
  312. package/dist/chunk-GT5WI3AF.mjs.map +0 -1
  313. package/dist/chunk-HDOG2RTM.mjs +0 -37
  314. package/dist/chunk-HDOG2RTM.mjs.map +0 -1
  315. package/dist/chunk-MIXSWZSB.mjs +0 -71
  316. package/dist/chunk-MIXSWZSB.mjs.map +0 -1
  317. package/dist/chunk-N4WEHORG.mjs.map +0 -1
  318. package/dist/chunk-NSBAWITG.mjs +0 -332
  319. package/dist/chunk-NSBAWITG.mjs.map +0 -1
  320. package/dist/chunk-OT5NHMEC.mjs +0 -723
  321. package/dist/chunk-OT5NHMEC.mjs.map +0 -1
  322. package/dist/chunk-T3376SZS.mjs +0 -142
  323. package/dist/chunk-T3376SZS.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-OKCYPO4I.mjs.map → chunk-3MHWEKFN.mjs.map} +0 -0
  347. /package/dist/{chunk-YPBKY4KY.mjs.map → chunk-A6NKSGH3.mjs.map} +0 -0
  348. /package/dist/{chunk-MGWRDFBE.mjs.map → chunk-ABWT4DRT.mjs.map} +0 -0
  349. /package/dist/{chunk-MQYWH4E6.mjs.map → chunk-BUSWSDYO.mjs.map} +0 -0
  350. /package/dist/{chunk-YPSGKPDA.mjs.map → chunk-CYDWEPFL.mjs.map} +0 -0
  351. /package/dist/{chunk-U7QULEVO.mjs.map → chunk-E7SE25ZU.mjs.map} +0 -0
  352. /package/dist/{hooks/use-chat.mjs.map → chunk-FD6FGKYY.mjs.map} +0 -0
  353. /package/dist/{utils/extract.mjs.map → chunk-JD7BAH7U.mjs.map} +0 -0
  354. /package/dist/{utils/suggestions.mjs.map → chunk-NB2FKV2V.mjs.map} +0 -0
  355. /package/dist/{chunk-N4VN2B5S.mjs.map → chunk-SNON4QA6.mjs.map} +0 -0
@@ -1,1129 +0,0 @@
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-chat.ts
80
- var use_chat_exports = {};
81
- __export(use_chat_exports, {
82
- useChat: () => useChat
83
- });
84
- module.exports = __toCommonJS(use_chat_exports);
85
- var import_react5 = require("react");
86
- var import_react_dom = require("react-dom");
87
- var import_shared4 = require("@copilotkit/shared");
88
- var import_runtime_client_gql3 = require("@copilotkit/runtime-client-gql");
89
-
90
- // src/types/frontend-action.ts
91
- var import_runtime_client_gql = require("@copilotkit/runtime-client-gql");
92
- var import_shared = require("@copilotkit/shared");
93
- function processActionsForRuntimeRequest(actions) {
94
- const filteredActions = actions.filter(
95
- (action) => action.available !== import_runtime_client_gql.ActionInputAvailability.Disabled && action.disabled !== true && action.name !== "*" && action.available != "frontend" && !action.pairedAction
96
- ).map((action) => {
97
- let available = import_runtime_client_gql.ActionInputAvailability.Enabled;
98
- if (action.disabled) {
99
- available = import_runtime_client_gql.ActionInputAvailability.Disabled;
100
- } else if (action.available === "disabled") {
101
- available = import_runtime_client_gql.ActionInputAvailability.Disabled;
102
- } else if (action.available === "remote") {
103
- available = import_runtime_client_gql.ActionInputAvailability.Remote;
104
- }
105
- return {
106
- name: action.name,
107
- description: action.description || "",
108
- jsonSchema: JSON.stringify((0, import_shared.actionParametersToJsonSchema)(action.parameters || [])),
109
- available
110
- };
111
- });
112
- return filteredActions;
113
- }
114
-
115
- // src/context/copilot-context.tsx
116
- var import_react = __toESM(require("react"));
117
- var emptyCopilotContext = {
118
- actions: {},
119
- setAction: () => {
120
- },
121
- removeAction: () => {
122
- },
123
- coAgentStateRenders: {},
124
- setCoAgentStateRender: () => {
125
- },
126
- removeCoAgentStateRender: () => {
127
- },
128
- chatComponentsCache: { current: { actions: {}, coAgentStateRenders: {} } },
129
- getContextString: (documents, categories) => returnAndThrowInDebug(""),
130
- addContext: () => "",
131
- removeContext: () => {
132
- },
133
- getAllContext: () => [],
134
- getFunctionCallHandler: () => returnAndThrowInDebug(() => __async(void 0, null, function* () {
135
- })),
136
- isLoading: false,
137
- setIsLoading: () => returnAndThrowInDebug(false),
138
- chatInstructions: "",
139
- setChatInstructions: () => returnAndThrowInDebug(""),
140
- additionalInstructions: [],
141
- setAdditionalInstructions: () => returnAndThrowInDebug([]),
142
- getDocumentsContext: (categories) => returnAndThrowInDebug([]),
143
- addDocumentContext: () => returnAndThrowInDebug(""),
144
- removeDocumentContext: () => {
145
- },
146
- runtimeClient: {},
147
- copilotApiConfig: new class {
148
- get chatApiEndpoint() {
149
- throw new Error("Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!");
150
- }
151
- get headers() {
152
- return {};
153
- }
154
- get body() {
155
- return {};
156
- }
157
- }(),
158
- chatSuggestionConfiguration: {},
159
- addChatSuggestionConfiguration: () => {
160
- },
161
- removeChatSuggestionConfiguration: () => {
162
- },
163
- showDevConsole: false,
164
- coagentStates: {},
165
- setCoagentStates: () => {
166
- },
167
- coagentStatesRef: { current: {} },
168
- setCoagentStatesWithRef: () => {
169
- },
170
- agentSession: null,
171
- setAgentSession: () => {
172
- },
173
- forwardedParameters: {},
174
- agentLock: null,
175
- threadId: "",
176
- setThreadId: () => {
177
- },
178
- runId: null,
179
- setRunId: () => {
180
- },
181
- chatAbortControllerRef: { current: null },
182
- availableAgents: [],
183
- extensions: {},
184
- setExtensions: () => {
185
- },
186
- langGraphInterruptAction: null,
187
- setLangGraphInterruptAction: () => {
188
- },
189
- removeLangGraphInterruptAction: () => {
190
- },
191
- onError: () => {
192
- },
193
- bannerError: null,
194
- setBannerError: () => {
195
- },
196
- internalErrorHandlers: {},
197
- setInternalErrorHandler: () => {
198
- },
199
- removeInternalErrorHandler: () => {
200
- }
201
- };
202
- var CopilotContext = import_react.default.createContext(emptyCopilotContext);
203
- function useCopilotContext() {
204
- const context = import_react.default.useContext(CopilotContext);
205
- if (context === emptyCopilotContext) {
206
- throw new Error("Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!");
207
- }
208
- return context;
209
- }
210
- function returnAndThrowInDebug(_value) {
211
- throw new Error("Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!");
212
- }
213
-
214
- // src/hooks/use-copilot-runtime-client.ts
215
- var import_runtime_client_gql2 = require("@copilotkit/runtime-client-gql");
216
-
217
- // src/components/toast/toast-provider.tsx
218
- var import_react2 = require("react");
219
- var import_shared2 = require("@copilotkit/shared");
220
- var import_jsx_runtime = require("react/jsx-runtime");
221
- var ToastContext = (0, import_react2.createContext)(void 0);
222
- function useToast() {
223
- const context = (0, import_react2.useContext)(ToastContext);
224
- if (!context) {
225
- throw new Error("useToast must be used within a ToastProvider");
226
- }
227
- return context;
228
- }
229
-
230
- // src/hooks/use-copilot-runtime-client.ts
231
- var import_react3 = require("react");
232
- var import_shared3 = require("@copilotkit/shared");
233
- var useCopilotRuntimeClient = (options) => {
234
- const { setBannerError } = useToast();
235
- const _a = options, { showDevConsole, onError } = _a, runtimeOptions = __objRest(_a, ["showDevConsole", "onError"]);
236
- const lastStructuredErrorRef = (0, import_react3.useRef)(null);
237
- const traceUIError = (error, originalError) => __async(void 0, null, function* () {
238
- try {
239
- const errorEvent = {
240
- type: "error",
241
- timestamp: Date.now(),
242
- context: {
243
- source: "ui",
244
- request: {
245
- operation: "runtimeClient",
246
- url: runtimeOptions.url,
247
- startTime: Date.now()
248
- },
249
- technical: {
250
- environment: "browser",
251
- userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
252
- stackTrace: originalError instanceof Error ? originalError.stack : void 0
253
- }
254
- },
255
- error
256
- };
257
- yield onError(errorEvent);
258
- } catch (error2) {
259
- console.error("Error in onError handler:", error2);
260
- }
261
- });
262
- const runtimeClient = (0, import_react3.useMemo)(() => {
263
- return new import_runtime_client_gql2.CopilotRuntimeClient(__spreadProps(__spreadValues({}, runtimeOptions), {
264
- handleGQLErrors: (error) => {
265
- var _a2;
266
- if ((_a2 = error.graphQLErrors) == null ? void 0 : _a2.length) {
267
- const graphQLErrors = error.graphQLErrors;
268
- const routeError = (gqlError) => {
269
- const extensions = gqlError.extensions;
270
- const visibility = extensions == null ? void 0 : extensions.visibility;
271
- if (visibility === import_shared3.ErrorVisibility.SILENT) {
272
- console.error("CopilotKit Silent Error:", gqlError.message);
273
- return;
274
- }
275
- const now = Date.now();
276
- const errorMessage = gqlError.message;
277
- if (lastStructuredErrorRef.current && lastStructuredErrorRef.current.message === errorMessage && now - lastStructuredErrorRef.current.timestamp < 150) {
278
- return;
279
- }
280
- lastStructuredErrorRef.current = { message: errorMessage, timestamp: now };
281
- const ckError = createStructuredError(gqlError);
282
- if (ckError) {
283
- setBannerError(ckError);
284
- traceUIError(ckError, gqlError);
285
- } else {
286
- const fallbackError = new import_shared3.CopilotKitError({
287
- message: gqlError.message,
288
- code: import_shared3.CopilotKitErrorCode.UNKNOWN
289
- });
290
- setBannerError(fallbackError);
291
- traceUIError(fallbackError, gqlError);
292
- }
293
- };
294
- graphQLErrors.forEach(routeError);
295
- } else {
296
- const fallbackError = new import_shared3.CopilotKitError({
297
- message: (error == null ? void 0 : error.message) || String(error),
298
- code: import_shared3.CopilotKitErrorCode.UNKNOWN
299
- });
300
- setBannerError(fallbackError);
301
- traceUIError(fallbackError, error);
302
- }
303
- },
304
- handleGQLWarning: (message) => {
305
- console.warn(message);
306
- const warningError = new import_shared3.CopilotKitError({
307
- message,
308
- code: import_shared3.CopilotKitErrorCode.UNKNOWN
309
- });
310
- setBannerError(warningError);
311
- }
312
- }));
313
- }, [runtimeOptions, setBannerError, onError]);
314
- return runtimeClient;
315
- };
316
- function createStructuredError(gqlError) {
317
- var _a, _b, _c;
318
- const extensions = gqlError.extensions;
319
- const originalError = extensions == null ? void 0 : extensions.originalError;
320
- const message = (originalError == null ? void 0 : originalError.message) || gqlError.message;
321
- const code = extensions == null ? void 0 : extensions.code;
322
- if (code) {
323
- return new import_shared3.CopilotKitError({ message, code });
324
- }
325
- if ((_a = originalError == null ? void 0 : originalError.stack) == null ? void 0 : _a.includes("CopilotApiDiscoveryError")) {
326
- return new import_shared3.CopilotKitApiDiscoveryError({ message });
327
- }
328
- if ((_b = originalError == null ? void 0 : originalError.stack) == null ? void 0 : _b.includes("CopilotKitRemoteEndpointDiscoveryError")) {
329
- return new import_shared3.CopilotKitRemoteEndpointDiscoveryError({ message });
330
- }
331
- if ((_c = originalError == null ? void 0 : originalError.stack) == null ? void 0 : _c.includes("CopilotKitAgentDiscoveryError")) {
332
- return new import_shared3.CopilotKitAgentDiscoveryError({
333
- agentName: "",
334
- availableAgents: []
335
- });
336
- }
337
- return null;
338
- }
339
-
340
- // src/components/error-boundary/error-utils.tsx
341
- var import_react4 = require("react");
342
-
343
- // src/components/toast/exclamation-mark-icon.tsx
344
- var import_jsx_runtime2 = require("react/jsx-runtime");
345
- var ExclamationMarkIcon = ({
346
- className,
347
- style
348
- }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
349
- "svg",
350
- {
351
- xmlns: "http://www.w3.org/2000/svg",
352
- width: "24",
353
- height: "24",
354
- viewBox: "0 0 24 24",
355
- fill: "none",
356
- stroke: "currentColor",
357
- strokeWidth: "2",
358
- strokeLinecap: "round",
359
- strokeLinejoin: "round",
360
- className: `lucide lucide-circle-alert ${className ? className : ""}`,
361
- style,
362
- children: [
363
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
364
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "12", x2: "12", y1: "8", y2: "12" }),
365
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "12", x2: "12.01", y1: "16", y2: "16" })
366
- ]
367
- }
368
- );
369
-
370
- // src/components/error-boundary/error-utils.tsx
371
- var import_react_markdown = __toESM(require("react-markdown"));
372
- var import_jsx_runtime3 = require("react/jsx-runtime");
373
- function ErrorToast({ errors }) {
374
- const errorsToRender = errors.map((error, idx) => {
375
- var _a, _b, _c;
376
- const originalError = "extensions" in error ? (_a = error.extensions) == null ? void 0 : _a.originalError : {};
377
- const message = (_b = originalError == null ? void 0 : originalError.message) != null ? _b : error.message;
378
- const code = "extensions" in error ? (_c = error.extensions) == null ? void 0 : _c.code : null;
379
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
380
- "div",
381
- {
382
- style: {
383
- marginTop: idx === 0 ? 0 : 10,
384
- marginBottom: 14
385
- },
386
- children: [
387
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ExclamationMarkIcon, { style: { marginBottom: 4 } }),
388
- code && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
389
- "div",
390
- {
391
- style: {
392
- fontWeight: "600",
393
- marginBottom: 4
394
- },
395
- children: [
396
- "Copilot Runtime Error:",
397
- " ",
398
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { fontFamily: "monospace", fontWeight: "normal" }, children: code })
399
- ]
400
- }
401
- ),
402
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_markdown.default, { children: message })
403
- ]
404
- },
405
- idx
406
- );
407
- });
408
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
409
- "div",
410
- {
411
- style: {
412
- fontSize: "13px",
413
- maxWidth: "600px"
414
- },
415
- children: [
416
- errorsToRender,
417
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { fontSize: "11px", opacity: 0.75 }, children: "NOTE: This error only displays during local development." })
418
- ]
419
- }
420
- );
421
- }
422
- function useErrorToast() {
423
- const { addToast } = useToast();
424
- return (0, import_react4.useCallback)(
425
- (error) => {
426
- const errorId = error.map((err) => {
427
- var _a, _b;
428
- const message = "extensions" in err ? ((_b = (_a = err.extensions) == null ? void 0 : _a.originalError) == null ? void 0 : _b.message) || err.message : err.message;
429
- const stack = err.stack || "";
430
- return btoa(message + stack).slice(0, 32);
431
- }).join("|");
432
- addToast({
433
- type: "error",
434
- id: errorId,
435
- // Toast libraries typically dedupe by id
436
- message: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ErrorToast, { errors: error })
437
- });
438
- },
439
- [addToast]
440
- );
441
- }
442
- function useAsyncCallback(callback, deps) {
443
- const addErrorToast = useErrorToast();
444
- return (0, import_react4.useCallback)((...args) => __async(this, null, function* () {
445
- try {
446
- return yield callback(...args);
447
- } catch (error) {
448
- console.error("Error in async callback:", error);
449
- addErrorToast([error]);
450
- throw error;
451
- }
452
- }), deps);
453
- }
454
-
455
- // src/hooks/use-chat.ts
456
- function useChat(options) {
457
- const {
458
- messages,
459
- setMessages,
460
- makeSystemMessageCallback,
461
- copilotConfig,
462
- setIsLoading,
463
- initialMessages,
464
- isLoading,
465
- actions,
466
- onFunctionCall,
467
- onCoAgentStateRender,
468
- setCoagentStatesWithRef,
469
- coagentStatesRef,
470
- agentSession,
471
- setAgentSession,
472
- threadId,
473
- setThreadId,
474
- runId,
475
- setRunId,
476
- chatAbortControllerRef,
477
- agentLock,
478
- extensions,
479
- setExtensions,
480
- langGraphInterruptAction,
481
- setLangGraphInterruptAction,
482
- disableSystemMessage = false
483
- } = options;
484
- const runChatCompletionRef = (0, import_react5.useRef)();
485
- const addErrorToast = useErrorToast();
486
- const { setBannerError } = useToast();
487
- const { onError, showDevConsole, getAllContext } = useCopilotContext();
488
- const copilotReadableContext = getAllContext();
489
- const context = (0, import_react5.useMemo)(
490
- () => copilotReadableContext.map((contextItem) => {
491
- const [description, ...valueParts] = contextItem.value.split(":");
492
- return {
493
- description: description.trim(),
494
- value: valueParts.join(":").trim()
495
- };
496
- }),
497
- [copilotReadableContext]
498
- );
499
- const traceUIError = (error, originalError) => __async(this, null, function* () {
500
- try {
501
- const traceEvent = {
502
- type: "error",
503
- timestamp: Date.now(),
504
- context: {
505
- source: "ui",
506
- request: {
507
- operation: "useChatCompletion",
508
- url: copilotConfig.chatApiEndpoint,
509
- startTime: Date.now()
510
- },
511
- technical: {
512
- environment: "browser",
513
- userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
514
- stackTrace: originalError instanceof Error ? originalError.stack : void 0
515
- }
516
- },
517
- error
518
- };
519
- yield onError(traceEvent);
520
- } catch (traceError) {
521
- console.error("Error in use-chat onError handler:", traceError);
522
- }
523
- });
524
- const agentSessionRef = (0, import_react5.useRef)(agentSession);
525
- agentSessionRef.current = agentSession;
526
- const runIdRef = (0, import_react5.useRef)(runId);
527
- runIdRef.current = runId;
528
- const extensionsRef = (0, import_react5.useRef)(extensions);
529
- extensionsRef.current = extensions;
530
- const publicApiKey = copilotConfig.publicApiKey;
531
- const headers = __spreadValues(__spreadValues({}, copilotConfig.headers || {}), publicApiKey ? { [import_shared4.COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: publicApiKey } : {});
532
- const runtimeClient = useCopilotRuntimeClient({
533
- url: copilotConfig.chatApiEndpoint,
534
- publicApiKey: copilotConfig.publicApiKey,
535
- headers,
536
- credentials: copilotConfig.credentials,
537
- showDevConsole,
538
- onError
539
- });
540
- const pendingAppendsRef = (0, import_react5.useRef)([]);
541
- const runChatCompletion = useAsyncCallback(
542
- (previousMessages) => __async(this, null, function* () {
543
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
544
- setIsLoading(true);
545
- const interruptEvent = langGraphInterruptAction == null ? void 0 : langGraphInterruptAction.event;
546
- if ((interruptEvent == null ? void 0 : interruptEvent.name) === import_runtime_client_gql3.MetaEventName.LangGraphInterruptEvent && (interruptEvent == null ? void 0 : interruptEvent.value) && !(interruptEvent == null ? void 0 : interruptEvent.response) && agentSessionRef.current) {
547
- addErrorToast([
548
- new Error(
549
- "A message was sent while interrupt is active. This will cause failure on the agent side"
550
- )
551
- ]);
552
- }
553
- let newMessages = [
554
- new import_runtime_client_gql3.TextMessage({
555
- content: "",
556
- role: import_runtime_client_gql3.Role.Assistant
557
- })
558
- ];
559
- chatAbortControllerRef.current = new AbortController();
560
- setMessages([...previousMessages, ...newMessages]);
561
- const messagesWithContext = disableSystemMessage ? [...initialMessages || [], ...previousMessages] : [makeSystemMessageCallback(), ...initialMessages || [], ...previousMessages];
562
- const finalProperties = __spreadValues({}, copilotConfig.properties || {});
563
- let mcpServersToUse = null;
564
- if (copilotConfig.mcpServers && Array.isArray(copilotConfig.mcpServers) && copilotConfig.mcpServers.length > 0) {
565
- mcpServersToUse = copilotConfig.mcpServers;
566
- } else if (((_a = copilotConfig.properties) == null ? void 0 : _a.mcpServers) && Array.isArray(copilotConfig.properties.mcpServers) && copilotConfig.properties.mcpServers.length > 0) {
567
- mcpServersToUse = copilotConfig.properties.mcpServers;
568
- }
569
- if (mcpServersToUse) {
570
- finalProperties.mcpServers = mcpServersToUse;
571
- copilotConfig.mcpServers = mcpServersToUse;
572
- }
573
- const isAgentRun = agentSessionRef.current !== null;
574
- const stream = runtimeClient.asStream(
575
- runtimeClient.generateCopilotResponse({
576
- data: __spreadProps(__spreadValues(__spreadProps(__spreadValues({
577
- frontend: {
578
- actions: processActionsForRuntimeRequest(actions),
579
- url: window.location.href
580
- },
581
- threadId,
582
- runId: runIdRef.current,
583
- extensions: extensionsRef.current,
584
- metaEvents: composeAndFlushMetaEventsInput([langGraphInterruptAction == null ? void 0 : langGraphInterruptAction.event]),
585
- messages: (0, import_runtime_client_gql3.convertMessagesToGqlInput)((0, import_runtime_client_gql3.filterAgentStateMessages)(messagesWithContext))
586
- }, copilotConfig.cloud ? {
587
- cloud: __spreadValues({}, ((_d = (_c = (_b = copilotConfig.cloud.guardrails) == null ? void 0 : _b.input) == null ? void 0 : _c.restrictToTopic) == null ? void 0 : _d.enabled) ? {
588
- guardrails: {
589
- inputValidationRules: {
590
- allowList: copilotConfig.cloud.guardrails.input.restrictToTopic.validTopics,
591
- denyList: copilotConfig.cloud.guardrails.input.restrictToTopic.invalidTopics
592
- }
593
- }
594
- } : {})
595
- } : {}), {
596
- metadata: {
597
- requestType: import_runtime_client_gql3.CopilotRequestType.Chat
598
- }
599
- }), agentSessionRef.current ? {
600
- agentSession: agentSessionRef.current
601
- } : {}), {
602
- agentStates: Object.values(coagentStatesRef.current).map((state) => {
603
- const stateObject = {
604
- agentName: state.name,
605
- state: JSON.stringify(state.state)
606
- };
607
- if (state.config !== void 0) {
608
- stateObject.config = JSON.stringify(state.config);
609
- }
610
- return stateObject;
611
- }),
612
- forwardedParameters: options.forwardedParameters || {},
613
- context
614
- }),
615
- properties: finalProperties,
616
- signal: (_e = chatAbortControllerRef.current) == null ? void 0 : _e.signal
617
- })
618
- );
619
- const guardrailsEnabled = ((_h = (_g = (_f = copilotConfig.cloud) == null ? void 0 : _f.guardrails) == null ? void 0 : _g.input) == null ? void 0 : _h.restrictToTopic.enabled) || false;
620
- const reader = stream.getReader();
621
- let executedCoAgentStateRenders = [];
622
- let followUp = void 0;
623
- let messages2 = [];
624
- let syncedMessages = [];
625
- let interruptMessages = [];
626
- try {
627
- while (true) {
628
- let done, value;
629
- try {
630
- const readResult = yield reader.read();
631
- done = readResult.done;
632
- value = readResult.value;
633
- } catch (readError) {
634
- break;
635
- }
636
- if (done) {
637
- if (chatAbortControllerRef.current.signal.aborted) {
638
- return [];
639
- }
640
- break;
641
- }
642
- if (!(value == null ? void 0 : value.generateCopilotResponse)) {
643
- continue;
644
- }
645
- runIdRef.current = value.generateCopilotResponse.runId || null;
646
- extensionsRef.current = import_runtime_client_gql3.CopilotRuntimeClient.removeGraphQLTypename(
647
- value.generateCopilotResponse.extensions || {}
648
- );
649
- setRunId(runIdRef.current);
650
- setExtensions(extensionsRef.current);
651
- let rawMessagesResponse = value.generateCopilotResponse.messages;
652
- const metaEvents = (_j = (_i = value.generateCopilotResponse) == null ? void 0 : _i.metaEvents) != null ? _j : [];
653
- (metaEvents != null ? metaEvents : []).forEach((ev) => {
654
- if (ev.name === import_runtime_client_gql3.MetaEventName.LangGraphInterruptEvent) {
655
- let eventValue = (0, import_runtime_client_gql3.langGraphInterruptEvent)(ev).value;
656
- eventValue = (0, import_shared4.parseJson)(eventValue, eventValue);
657
- setLangGraphInterruptAction(threadId, {
658
- event: __spreadProps(__spreadValues({}, (0, import_runtime_client_gql3.langGraphInterruptEvent)(ev)), {
659
- value: eventValue
660
- })
661
- });
662
- }
663
- if (ev.name === import_runtime_client_gql3.MetaEventName.CopilotKitLangGraphInterruptEvent) {
664
- const data = ev.data;
665
- rawMessagesResponse = [...rawMessagesResponse, ...data.messages];
666
- interruptMessages = (0, import_runtime_client_gql3.convertGqlOutputToMessages)(
667
- // @ts-ignore
668
- (0, import_runtime_client_gql3.filterAdjacentAgentStateMessages)(data.messages)
669
- );
670
- }
671
- });
672
- messages2 = (0, import_runtime_client_gql3.convertGqlOutputToMessages)(
673
- (0, import_runtime_client_gql3.filterAdjacentAgentStateMessages)(rawMessagesResponse)
674
- );
675
- newMessages = [];
676
- if (((_k = value.generateCopilotResponse.status) == null ? void 0 : _k.__typename) === "FailedResponseStatus" && value.generateCopilotResponse.status.reason === "GUARDRAILS_VALIDATION_FAILED") {
677
- const guardrailsReason = ((_l = value.generateCopilotResponse.status.details) == null ? void 0 : _l.guardrailsReason) || "";
678
- newMessages = [
679
- new import_runtime_client_gql3.TextMessage({
680
- role: import_runtime_client_gql3.MessageRole.Assistant,
681
- content: guardrailsReason
682
- })
683
- ];
684
- const guardrailsError = new import_shared4.CopilotKitError({
685
- message: `Guardrails validation failed: ${guardrailsReason}`,
686
- code: import_shared4.CopilotKitErrorCode.MISUSE
687
- });
688
- yield traceUIError(guardrailsError, {
689
- statusReason: value.generateCopilotResponse.status.reason,
690
- statusDetails: value.generateCopilotResponse.status.details
691
- });
692
- setMessages([...previousMessages, ...newMessages]);
693
- break;
694
- }
695
- if (((_m = value.generateCopilotResponse.status) == null ? void 0 : _m.__typename) === "FailedResponseStatus" && value.generateCopilotResponse.status.reason === "UNKNOWN_ERROR") {
696
- const errorMessage = ((_n = value.generateCopilotResponse.status.details) == null ? void 0 : _n.description) || "An unknown error occurred";
697
- const statusDetails = value.generateCopilotResponse.status.details;
698
- const originalError = (statusDetails == null ? void 0 : statusDetails.originalError) || (statusDetails == null ? void 0 : statusDetails.error);
699
- const originalCode = (originalError == null ? void 0 : originalError.code) || ((_o = originalError == null ? void 0 : originalError.extensions) == null ? void 0 : _o.code);
700
- const originalSeverity = (originalError == null ? void 0 : originalError.severity) || ((_p = originalError == null ? void 0 : originalError.extensions) == null ? void 0 : _p.severity);
701
- const originalVisibility = (originalError == null ? void 0 : originalError.visibility) || ((_q = originalError == null ? void 0 : originalError.extensions) == null ? void 0 : _q.visibility);
702
- let errorCode = import_shared4.CopilotKitErrorCode.NETWORK_ERROR;
703
- if (originalCode && Object.values(import_shared4.CopilotKitErrorCode).includes(originalCode)) {
704
- errorCode = originalCode;
705
- }
706
- const structuredError = new import_shared4.CopilotKitError({
707
- message: errorMessage,
708
- code: errorCode,
709
- severity: originalSeverity,
710
- visibility: originalVisibility
711
- });
712
- setBannerError(structuredError);
713
- yield traceUIError(structuredError, {
714
- statusReason: value.generateCopilotResponse.status.reason,
715
- statusDetails: value.generateCopilotResponse.status.details,
716
- originalErrorCode: originalCode,
717
- preservedStructure: !!originalCode
718
- });
719
- setIsLoading(false);
720
- throw new Error(structuredError.message);
721
- } else if (messages2.length > 0) {
722
- newMessages = [...messages2];
723
- for (const message of messages2) {
724
- if (message.isAgentStateMessage() && !message.active && !executedCoAgentStateRenders.includes(message.id) && onCoAgentStateRender) {
725
- if (guardrailsEnabled && value.generateCopilotResponse.status === void 0) {
726
- break;
727
- }
728
- yield onCoAgentStateRender({
729
- name: message.agentName,
730
- nodeName: message.nodeName,
731
- state: message.state
732
- });
733
- executedCoAgentStateRenders.push(message.id);
734
- }
735
- }
736
- const lastAgentStateMessage = [...messages2].reverse().find((message) => message.isAgentStateMessage());
737
- if (lastAgentStateMessage) {
738
- if (lastAgentStateMessage.state.messages && lastAgentStateMessage.state.messages.length > 0) {
739
- syncedMessages = (0, import_runtime_client_gql3.loadMessagesFromJsonRepresentation)(
740
- lastAgentStateMessage.state.messages
741
- );
742
- }
743
- setCoagentStatesWithRef((prevAgentStates) => {
744
- var _a2;
745
- return __spreadProps(__spreadValues({}, prevAgentStates), {
746
- [lastAgentStateMessage.agentName]: {
747
- name: lastAgentStateMessage.agentName,
748
- state: lastAgentStateMessage.state,
749
- running: lastAgentStateMessage.running,
750
- active: lastAgentStateMessage.active,
751
- threadId: lastAgentStateMessage.threadId,
752
- nodeName: lastAgentStateMessage.nodeName,
753
- runId: lastAgentStateMessage.runId,
754
- // Preserve existing config from previous state
755
- config: (_a2 = prevAgentStates[lastAgentStateMessage.agentName]) == null ? void 0 : _a2.config
756
- }
757
- });
758
- });
759
- if (lastAgentStateMessage.running) {
760
- setAgentSession({
761
- threadId: lastAgentStateMessage.threadId,
762
- agentName: lastAgentStateMessage.agentName,
763
- nodeName: lastAgentStateMessage.nodeName
764
- });
765
- } else {
766
- if (agentLock) {
767
- setAgentSession({
768
- threadId: (0, import_shared4.randomId)(),
769
- agentName: agentLock,
770
- nodeName: void 0
771
- });
772
- } else {
773
- setAgentSession(null);
774
- }
775
- }
776
- }
777
- }
778
- if (newMessages.length > 0) {
779
- setMessages([...previousMessages, ...newMessages]);
780
- }
781
- }
782
- let finalMessages = constructFinalMessages(
783
- [...syncedMessages, ...interruptMessages],
784
- previousMessages,
785
- newMessages
786
- );
787
- let didExecuteAction = false;
788
- const executeActionFromMessage = (currentAction, actionMessage) => __async(this, null, function* () {
789
- var _a2;
790
- const isInterruptAction = interruptMessages.find((m) => m.id === actionMessage.id);
791
- followUp = (_a2 = currentAction == null ? void 0 : currentAction.followUp) != null ? _a2 : !isInterruptAction;
792
- if (currentAction == null ? void 0 : currentAction._setActivatingMessageId) {
793
- currentAction._setActivatingMessageId(actionMessage.id);
794
- }
795
- const resultMessage = yield executeAction({
796
- onFunctionCall,
797
- message: actionMessage,
798
- chatAbortControllerRef,
799
- onError: (error) => {
800
- addErrorToast([error]);
801
- console.error(`Failed to execute action ${actionMessage.name}: ${error}`);
802
- },
803
- setMessages,
804
- getFinalMessages: () => finalMessages,
805
- isRenderAndWait: (currentAction == null ? void 0 : currentAction._isRenderAndWait) || false
806
- });
807
- didExecuteAction = true;
808
- const messageIndex = finalMessages.findIndex((msg) => msg.id === actionMessage.id);
809
- finalMessages.splice(messageIndex + 1, 0, resultMessage);
810
- if (currentAction == null ? void 0 : currentAction._isRenderAndWait) {
811
- const messagesForImmediateUpdate = [...finalMessages];
812
- (0, import_react_dom.flushSync)(() => {
813
- setMessages(messagesForImmediateUpdate);
814
- });
815
- }
816
- if (currentAction == null ? void 0 : currentAction._setActivatingMessageId) {
817
- currentAction._setActivatingMessageId(null);
818
- }
819
- return resultMessage;
820
- });
821
- if (onFunctionCall) {
822
- const lastMessages = [];
823
- for (let i = finalMessages.length - 1; i >= 0; i--) {
824
- const message = finalMessages[i];
825
- if ((message.isActionExecutionMessage() || message.isResultMessage()) && message.status.code !== import_runtime_client_gql3.MessageStatusCode.Pending) {
826
- lastMessages.unshift(message);
827
- } else if (!message.isAgentStateMessage()) {
828
- break;
829
- }
830
- }
831
- for (const message of lastMessages) {
832
- setMessages(finalMessages);
833
- const action = actions.find(
834
- (action2) => action2.name === message.name
835
- );
836
- if (action && action.available === "frontend") {
837
- continue;
838
- }
839
- const currentResultMessagePairedFeAction = message.isResultMessage() ? getPairedFeAction(actions, message) : null;
840
- if (action && message.isActionExecutionMessage()) {
841
- const isRenderAndWaitAction = (action == null ? void 0 : action._isRenderAndWait) || false;
842
- const alreadyProcessed = isRenderAndWaitAction && finalMessages.some(
843
- (fm) => fm.isResultMessage() && fm.actionExecutionId === message.id
844
- );
845
- if (alreadyProcessed) {
846
- } else {
847
- const resultMessage = yield executeActionFromMessage(
848
- action,
849
- message
850
- );
851
- const pairedFeAction = getPairedFeAction(actions, resultMessage);
852
- if (pairedFeAction) {
853
- const newExecutionMessage = new import_runtime_client_gql3.ActionExecutionMessage({
854
- name: pairedFeAction.name,
855
- arguments: (0, import_shared4.parseJson)(resultMessage.result, resultMessage.result),
856
- status: message.status,
857
- createdAt: message.createdAt,
858
- parentMessageId: message.parentMessageId
859
- });
860
- yield executeActionFromMessage(pairedFeAction, newExecutionMessage);
861
- }
862
- }
863
- } else if (message.isResultMessage() && currentResultMessagePairedFeAction) {
864
- const newExecutionMessage = new import_runtime_client_gql3.ActionExecutionMessage({
865
- name: currentResultMessagePairedFeAction.name,
866
- arguments: (0, import_shared4.parseJson)(message.result, message.result),
867
- status: message.status,
868
- createdAt: message.createdAt
869
- });
870
- finalMessages.push(newExecutionMessage);
871
- yield executeActionFromMessage(
872
- currentResultMessagePairedFeAction,
873
- newExecutionMessage
874
- );
875
- }
876
- }
877
- setMessages(finalMessages);
878
- }
879
- if (followUp !== false && (didExecuteAction || // the last message is a server side result
880
- !isAgentRun && finalMessages.length && finalMessages[finalMessages.length - 1].isResultMessage()) && // the user did not stop generation
881
- !((_r = chatAbortControllerRef.current) == null ? void 0 : _r.signal.aborted)) {
882
- yield new Promise((resolve) => setTimeout(resolve, 10));
883
- return yield runChatCompletionRef.current(finalMessages);
884
- } else if ((_s = chatAbortControllerRef.current) == null ? void 0 : _s.signal.aborted) {
885
- const repairedMessages = finalMessages.filter((message, actionExecutionIndex) => {
886
- if (message.isActionExecutionMessage()) {
887
- return finalMessages.find(
888
- (msg, resultIndex) => msg.isResultMessage() && msg.actionExecutionId === message.id && resultIndex === actionExecutionIndex + 1
889
- );
890
- }
891
- return true;
892
- });
893
- const repairedMessageIds = repairedMessages.map((message) => message.id);
894
- setMessages(repairedMessages);
895
- if ((_t = agentSessionRef.current) == null ? void 0 : _t.nodeName) {
896
- setAgentSession({
897
- threadId: agentSessionRef.current.threadId,
898
- agentName: agentSessionRef.current.agentName,
899
- nodeName: "__end__"
900
- });
901
- }
902
- return newMessages.filter((message) => repairedMessageIds.includes(message.id));
903
- } else {
904
- return newMessages.slice();
905
- }
906
- } finally {
907
- setIsLoading(false);
908
- }
909
- }),
910
- [
911
- messages,
912
- setMessages,
913
- makeSystemMessageCallback,
914
- copilotConfig,
915
- setIsLoading,
916
- initialMessages,
917
- isLoading,
918
- actions,
919
- onFunctionCall,
920
- onCoAgentStateRender,
921
- setCoagentStatesWithRef,
922
- coagentStatesRef,
923
- agentSession,
924
- setAgentSession,
925
- disableSystemMessage,
926
- context
927
- ]
928
- );
929
- runChatCompletionRef.current = runChatCompletion;
930
- const runChatCompletionAndHandleFunctionCall = useAsyncCallback(
931
- (messages2) => __async(this, null, function* () {
932
- yield runChatCompletionRef.current(messages2);
933
- }),
934
- [messages]
935
- );
936
- (0, import_react5.useEffect)(() => {
937
- if (!isLoading && pendingAppendsRef.current.length > 0) {
938
- const pending = pendingAppendsRef.current.splice(0);
939
- const followUp = pending.some((p) => p.followUp);
940
- const newMessages = [...messages, ...pending.map((p) => p.message)];
941
- setMessages(newMessages);
942
- if (followUp) {
943
- runChatCompletionAndHandleFunctionCall(newMessages);
944
- }
945
- }
946
- }, [isLoading, messages, setMessages, runChatCompletionAndHandleFunctionCall]);
947
- const composeAndFlushMetaEventsInput = (0, import_react5.useCallback)(
948
- (metaEvents) => {
949
- return metaEvents.reduce((acc, event) => {
950
- if (!event)
951
- return acc;
952
- switch (event.name) {
953
- case import_runtime_client_gql3.MetaEventName.LangGraphInterruptEvent:
954
- if (event.response) {
955
- setLangGraphInterruptAction(threadId, null);
956
- const value = event.value;
957
- return [
958
- ...acc,
959
- {
960
- name: event.name,
961
- value: typeof value === "string" ? value : JSON.stringify(value),
962
- response: typeof event.response === "string" ? event.response : JSON.stringify(event.response)
963
- }
964
- ];
965
- }
966
- return acc;
967
- default:
968
- return acc;
969
- }
970
- }, []);
971
- },
972
- [setLangGraphInterruptAction]
973
- );
974
- const append = useAsyncCallback(
975
- (message, options2) => __async(this, null, function* () {
976
- var _a;
977
- const followUp = (_a = options2 == null ? void 0 : options2.followUp) != null ? _a : true;
978
- if (isLoading) {
979
- pendingAppendsRef.current.push({ message, followUp });
980
- return;
981
- }
982
- const newMessages = [...messages, message];
983
- setMessages(newMessages);
984
- if (followUp) {
985
- return runChatCompletionAndHandleFunctionCall(newMessages);
986
- }
987
- }),
988
- [isLoading, messages, setMessages, runChatCompletionAndHandleFunctionCall]
989
- );
990
- const reload = useAsyncCallback(
991
- (reloadMessageId) => __async(this, null, function* () {
992
- if (isLoading || messages.length === 0) {
993
- return;
994
- }
995
- const reloadMessageIndex = messages.findIndex((msg) => msg.id === reloadMessageId);
996
- if (reloadMessageIndex === -1) {
997
- console.warn(`Message with id ${reloadMessageId} not found`);
998
- return;
999
- }
1000
- const reloadMessageRole = messages[reloadMessageIndex].role;
1001
- if (reloadMessageRole !== import_runtime_client_gql3.MessageRole.Assistant) {
1002
- console.warn(`Regenerate cannot be performed on ${reloadMessageRole} role`);
1003
- return;
1004
- }
1005
- let historyCutoff = [messages[0]];
1006
- if (messages.length > 2 && reloadMessageIndex !== 0) {
1007
- const lastUserMessageBeforeRegenerate = messages.slice(0, reloadMessageIndex).reverse().find(
1008
- (msg) => (
1009
- // @ts-expect-error -- message has role
1010
- msg.role === import_runtime_client_gql3.MessageRole.User
1011
- )
1012
- );
1013
- const indexOfLastUserMessageBeforeRegenerate = messages.findIndex(
1014
- (msg) => msg.id === lastUserMessageBeforeRegenerate.id
1015
- );
1016
- historyCutoff = messages.slice(0, indexOfLastUserMessageBeforeRegenerate + 1);
1017
- } else if (messages.length > 2 && reloadMessageIndex === 0) {
1018
- historyCutoff = [messages[0], messages[1]];
1019
- }
1020
- setMessages(historyCutoff);
1021
- return runChatCompletionAndHandleFunctionCall(historyCutoff);
1022
- }),
1023
- [isLoading, messages, setMessages, runChatCompletionAndHandleFunctionCall]
1024
- );
1025
- const stop = () => {
1026
- var _a;
1027
- (_a = chatAbortControllerRef.current) == null ? void 0 : _a.abort("Stop was called");
1028
- };
1029
- return {
1030
- append,
1031
- reload,
1032
- stop,
1033
- runChatCompletion: () => runChatCompletionRef.current(messages)
1034
- };
1035
- }
1036
- function constructFinalMessages(syncedMessages, previousMessages, newMessages) {
1037
- const finalMessages = syncedMessages.length > 0 ? [...syncedMessages] : [...previousMessages, ...newMessages];
1038
- if (syncedMessages.length > 0) {
1039
- const messagesWithAgentState = [...previousMessages, ...newMessages];
1040
- let previousMessageId = void 0;
1041
- for (const message of messagesWithAgentState) {
1042
- if (message.isAgentStateMessage()) {
1043
- const index = finalMessages.findIndex((msg) => msg.id === previousMessageId);
1044
- if (index !== -1) {
1045
- finalMessages.splice(index + 1, 0, message);
1046
- }
1047
- }
1048
- previousMessageId = message.id;
1049
- }
1050
- }
1051
- return finalMessages;
1052
- }
1053
- function executeAction(_0) {
1054
- return __async(this, arguments, function* ({
1055
- onFunctionCall,
1056
- message,
1057
- chatAbortControllerRef,
1058
- onError,
1059
- setMessages,
1060
- getFinalMessages,
1061
- isRenderAndWait
1062
- }) {
1063
- let result;
1064
- let error = null;
1065
- const currentMessagesForHandler = getFinalMessages();
1066
- const handlerReturnedPromise = onFunctionCall({
1067
- messages: currentMessagesForHandler,
1068
- name: message.name,
1069
- args: message.arguments
1070
- });
1071
- if (isRenderAndWait) {
1072
- const currentMessagesForRender = getFinalMessages();
1073
- (0, import_react_dom.flushSync)(() => {
1074
- setMessages([...currentMessagesForRender]);
1075
- });
1076
- }
1077
- try {
1078
- result = yield Promise.race([
1079
- handlerReturnedPromise,
1080
- // Await the promise returned by the handler
1081
- new Promise(
1082
- (resolve) => {
1083
- var _a;
1084
- return (_a = chatAbortControllerRef.current) == null ? void 0 : _a.signal.addEventListener(
1085
- "abort",
1086
- () => resolve("Operation was aborted by the user")
1087
- );
1088
- }
1089
- ),
1090
- // if the user stopped generation, we also abort consecutive actions
1091
- new Promise((resolve) => {
1092
- var _a;
1093
- if ((_a = chatAbortControllerRef.current) == null ? void 0 : _a.signal.aborted) {
1094
- resolve("Operation was aborted by the user");
1095
- }
1096
- })
1097
- ]);
1098
- } catch (e) {
1099
- onError(e);
1100
- }
1101
- return new import_runtime_client_gql3.ResultMessage({
1102
- id: "result-" + message.id,
1103
- result: import_runtime_client_gql3.ResultMessage.encodeResult(
1104
- error ? {
1105
- content: result,
1106
- error: JSON.parse(JSON.stringify(error, Object.getOwnPropertyNames(error)))
1107
- } : result
1108
- ),
1109
- actionExecutionId: message.id,
1110
- actionName: message.name
1111
- });
1112
- });
1113
- }
1114
- function getPairedFeAction(actions, message) {
1115
- let actionName = null;
1116
- if (message.isActionExecutionMessage()) {
1117
- actionName = message.name;
1118
- } else if (message.isResultMessage()) {
1119
- actionName = message.actionName;
1120
- }
1121
- return actions.find(
1122
- (action) => action.name === actionName && action.available === "frontend" || action.pairedAction === actionName
1123
- );
1124
- }
1125
- // Annotate the CommonJS export names for ESM import in node:
1126
- 0 && (module.exports = {
1127
- useChat
1128
- });
1129
- //# sourceMappingURL=use-chat.js.map