@copilotkit/react-core 1.10.6 → 1.50.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-24SCZAB4.mjs +143 -0
- package/dist/chunk-24SCZAB4.mjs.map +1 -0
- package/dist/chunk-36KQV2NA.mjs +1 -0
- package/dist/{chunk-U7QULEVO.mjs → chunk-3GURHDG7.mjs} +3 -3
- package/dist/{chunk-4BHIQMN6.mjs → chunk-3R423LZT.mjs} +6 -5
- package/dist/{chunk-4BHIQMN6.mjs.map → chunk-3R423LZT.mjs.map} +1 -1
- package/dist/chunk-5X5DJRQQ.mjs +71 -0
- package/dist/chunk-5X5DJRQQ.mjs.map +1 -0
- package/dist/{chunk-N4WEHORG.mjs → chunk-6PUNP7CD.mjs} +4 -4
- package/dist/chunk-6PUNP7CD.mjs.map +1 -0
- package/dist/chunk-7BYHZLPL.mjs +32 -0
- package/dist/chunk-7BYHZLPL.mjs.map +1 -0
- package/dist/chunk-7DTB7S5V.mjs +83 -0
- package/dist/chunk-7DTB7S5V.mjs.map +1 -0
- package/dist/chunk-A6NKSGH3.mjs +1 -0
- package/dist/{chunk-GT5WI3AF.mjs → chunk-BR5YEYZJ.mjs} +7 -9
- package/dist/chunk-BR5YEYZJ.mjs.map +1 -0
- package/dist/chunk-CB7CRBDG.mjs +48 -0
- package/dist/chunk-CB7CRBDG.mjs.map +1 -0
- package/dist/chunk-CYDWEPFL.mjs +1 -0
- package/dist/{chunk-BBUQMG45.mjs → chunk-D3QSYDJR.mjs} +3 -3
- package/dist/{chunk-BBUQMG45.mjs.map → chunk-D3QSYDJR.mjs.map} +1 -1
- package/dist/chunk-DCHSCK62.mjs +549 -0
- package/dist/chunk-DCHSCK62.mjs.map +1 -0
- package/dist/{chunk-ZLQVRPDS.mjs → chunk-DMLQZG75.mjs} +1 -1
- package/dist/chunk-DMLQZG75.mjs.map +1 -0
- package/dist/chunk-F555TVE4.mjs +33 -0
- package/dist/chunk-F555TVE4.mjs.map +1 -0
- package/dist/{chunk-C6IANC2R.mjs → chunk-FBD24VEH.mjs} +7 -43
- package/dist/chunk-FBD24VEH.mjs.map +1 -0
- package/dist/chunk-FD6FGKYY.mjs +1 -0
- package/dist/chunk-FDOMAPJY.mjs +59 -0
- package/dist/chunk-FDOMAPJY.mjs.map +1 -0
- package/dist/{chunk-X7MJWPI7.mjs → chunk-GMI4KO4X.mjs} +8 -6
- package/dist/{chunk-X7MJWPI7.mjs.map → chunk-GMI4KO4X.mjs.map} +1 -1
- package/dist/chunk-IUSKVYUI.mjs +13 -0
- package/dist/chunk-IUSKVYUI.mjs.map +1 -0
- package/dist/chunk-JD7BAH7U.mjs +1 -0
- package/dist/{chunk-N5HOP3PG.mjs → chunk-JRT5BJF3.mjs} +2 -2
- package/dist/{chunk-N4VN2B5S.mjs → chunk-LHERIF3L.mjs} +2 -2
- package/dist/{chunk-DXEQPN43.mjs → chunk-LHKZJ2ND.mjs} +3 -3
- package/dist/chunk-NB2FKV2V.mjs +1 -0
- package/dist/chunk-NBK4KBLX.mjs +54 -0
- package/dist/chunk-NBK4KBLX.mjs.map +1 -0
- package/dist/chunk-NG26QEGF.mjs +46 -0
- package/dist/chunk-NG26QEGF.mjs.map +1 -0
- package/dist/chunk-NROJOTQP.mjs +163 -0
- package/dist/chunk-NROJOTQP.mjs.map +1 -0
- package/dist/{chunk-MGWRDFBE.mjs → chunk-OVYFRPSN.mjs} +2 -2
- package/dist/{chunk-MQYWH4E6.mjs → chunk-QU6NONOD.mjs} +2 -2
- package/dist/chunk-R4MR43UQ.mjs +101 -0
- package/dist/chunk-R4MR43UQ.mjs.map +1 -0
- package/dist/chunk-SPCZTZCY.mjs +1 -0
- package/dist/chunk-SPCZTZCY.mjs.map +1 -0
- package/dist/chunk-TXI72QHK.mjs +80 -0
- package/dist/chunk-TXI72QHK.mjs.map +1 -0
- package/dist/chunk-UJBV5GAG.mjs +767 -0
- package/dist/chunk-UJBV5GAG.mjs.map +1 -0
- package/dist/{chunk-OKCYPO4I.mjs → chunk-WMJVBMUX.mjs} +3 -3
- package/dist/{chunk-EUX2P2E7.mjs → chunk-WVLHXIFP.mjs} +11 -9
- package/dist/chunk-WVLHXIFP.mjs.map +1 -0
- package/dist/{chunk-5FHSUKQL.mjs → chunk-YYN33GSG.mjs} +5 -2
- package/dist/chunk-YYN33GSG.mjs.map +1 -0
- package/dist/chunk-ZVF5Q6IH.mjs +29 -0
- package/dist/chunk-ZVF5Q6IH.mjs.map +1 -0
- package/dist/components/CopilotListeners.d.ts +3 -0
- package/dist/components/CopilotListeners.js +234 -0
- package/dist/components/CopilotListeners.js.map +1 -0
- package/dist/components/CopilotListeners.mjs +14 -0
- package/dist/components/CopilotListeners.mjs.map +1 -0
- package/dist/components/copilot-provider/copilot-messages.js +14 -48
- package/dist/components/copilot-provider/copilot-messages.js.map +1 -1
- package/dist/components/copilot-provider/copilot-messages.mjs +3 -3
- package/dist/components/copilot-provider/copilotkit-props.d.ts +9 -2
- package/dist/components/copilot-provider/copilotkit-props.js.map +1 -1
- package/dist/components/copilot-provider/copilotkit.d.ts +2 -1
- package/dist/components/copilot-provider/copilotkit.js +528 -370
- package/dist/components/copilot-provider/copilotkit.js.map +1 -1
- package/dist/components/copilot-provider/copilotkit.mjs +17 -12
- package/dist/components/copilot-provider/index.d.ts +2 -1
- package/dist/components/copilot-provider/index.js +528 -370
- package/dist/components/copilot-provider/index.js.map +1 -1
- package/dist/components/copilot-provider/index.mjs +18 -12
- package/dist/components/dev-console/console-trigger.js +10 -8
- package/dist/components/dev-console/console-trigger.js.map +1 -1
- package/dist/components/dev-console/console-trigger.mjs +4 -4
- package/dist/components/dev-console/developer-console-modal.js +10 -8
- package/dist/components/dev-console/developer-console-modal.js.map +1 -1
- package/dist/components/dev-console/developer-console-modal.mjs +3 -3
- package/dist/components/error-boundary/error-boundary.d.ts +7 -7
- package/dist/components/error-boundary/error-boundary.js +3 -3
- package/dist/components/error-boundary/error-boundary.js.map +1 -1
- package/dist/components/error-boundary/error-boundary.mjs +2 -2
- package/dist/components/error-boundary/error-utils.d.ts +1 -1
- package/dist/components/error-boundary/error-utils.js +3 -3
- package/dist/components/error-boundary/error-utils.js.map +1 -1
- package/dist/components/error-boundary/error-utils.mjs +1 -1
- package/dist/components/index.d.ts +2 -1
- package/dist/components/index.js +528 -370
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +19 -12
- package/dist/components/toast/exclamation-mark-icon.d.ts +2 -2
- package/dist/components/toast/toast-provider.d.ts +3 -3
- package/dist/components/usage-banner.d.ts +2 -2
- package/dist/context/coagent-state-renders-context.d.ts +24 -0
- package/dist/context/coagent-state-renders-context.js +91 -0
- package/dist/context/coagent-state-renders-context.js.map +1 -0
- package/dist/context/coagent-state-renders-context.mjs +12 -0
- package/dist/context/coagent-state-renders-context.mjs.map +1 -0
- package/dist/context/copilot-context.d.ts +1 -1
- package/dist/context/copilot-context.js +10 -8
- package/dist/context/copilot-context.js.map +1 -1
- package/dist/context/copilot-context.mjs +1 -1
- package/dist/context/copilot-messages-context.d.ts +18 -11
- package/dist/context/copilot-messages-context.js.map +1 -1
- package/dist/context/copilot-messages-context.mjs +1 -1
- package/dist/context/index.d.ts +6 -2
- package/dist/context/index.js +110 -10
- package/dist/context/index.js.map +1 -1
- package/dist/context/index.mjs +20 -4
- package/dist/context/threads-context.d.ts +16 -0
- package/dist/context/threads-context.js +59 -0
- package/dist/context/threads-context.js.map +1 -0
- package/dist/context/threads-context.mjs +12 -0
- package/dist/context/threads-context.mjs.map +1 -0
- package/dist/{copilot-context-cf9de848.d.ts → copilot-context-1cd70a3f.d.ts} +36 -32
- package/dist/hooks/index.d.ts +9 -6
- package/dist/hooks/index.js +1445 -1839
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +47 -56
- package/dist/hooks/use-coagent-state-render-bridge.d.ts +100 -0
- package/dist/hooks/use-coagent-state-render-bridge.js +211 -0
- package/dist/hooks/use-coagent-state-render-bridge.js.map +1 -0
- package/dist/hooks/use-coagent-state-render-bridge.mjs +15 -0
- package/dist/hooks/use-coagent-state-render-bridge.mjs.map +1 -0
- package/dist/hooks/use-coagent-state-render.js +31 -20
- package/dist/hooks/use-coagent-state-render.js.map +1 -1
- package/dist/hooks/use-coagent-state-render.mjs +3 -2
- package/dist/hooks/use-coagent.d.ts +2 -14
- package/dist/hooks/use-coagent.js +109 -1906
- package/dist/hooks/use-coagent.js.map +1 -1
- package/dist/hooks/use-coagent.mjs +1 -30
- package/dist/hooks/use-configure-chat-suggestions.d.ts +36 -0
- package/dist/hooks/use-configure-chat-suggestions.js +210 -0
- package/dist/hooks/use-configure-chat-suggestions.js.map +1 -0
- package/dist/hooks/use-configure-chat-suggestions.mjs +13 -0
- package/dist/hooks/use-configure-chat-suggestions.mjs.map +1 -0
- package/dist/hooks/use-copilot-action.d.ts +8 -45
- package/dist/hooks/use-copilot-action.js +207 -349
- package/dist/hooks/use-copilot-action.js.map +1 -1
- package/dist/hooks/use-copilot-action.mjs +4 -5
- package/dist/hooks/use-copilot-additional-instructions.js +10 -8
- package/dist/hooks/use-copilot-additional-instructions.js.map +1 -1
- package/dist/hooks/use-copilot-additional-instructions.mjs +2 -2
- package/dist/hooks/use-copilot-authenticated-action.js +224 -248
- package/dist/hooks/use-copilot-authenticated-action.js.map +1 -1
- package/dist/hooks/use-copilot-authenticated-action.mjs +6 -6
- package/dist/hooks/use-copilot-chat-headless_c.d.ts +2 -10
- package/dist/hooks/use-copilot-chat-headless_c.js +973 -1369
- package/dist/hooks/use-copilot-chat-headless_c.js.map +1 -1
- package/dist/hooks/use-copilot-chat-headless_c.mjs +12 -22
- package/dist/hooks/use-copilot-chat.d.ts +2 -10
- package/dist/hooks/use-copilot-chat.js +967 -1388
- package/dist/hooks/use-copilot-chat.js.map +1 -1
- package/dist/hooks/use-copilot-chat.mjs +12 -22
- package/dist/hooks/use-copilot-chat_internal.d.ts +38 -14
- package/dist/hooks/use-copilot-chat_internal.js +965 -1362
- package/dist/hooks/use-copilot-chat_internal.js.map +1 -1
- package/dist/hooks/use-copilot-chat_internal.mjs +13 -23
- package/dist/hooks/use-copilot-readable.d.ts +1 -1
- package/dist/hooks/use-copilot-readable.js +6 -157
- package/dist/hooks/use-copilot-readable.js.map +1 -1
- package/dist/hooks/use-copilot-readable.mjs +1 -2
- package/dist/hooks/use-default-tool.js +204 -349
- package/dist/hooks/use-default-tool.js.map +1 -1
- package/dist/hooks/use-default-tool.mjs +5 -6
- package/dist/hooks/use-flat-category-store.js +4 -1
- package/dist/hooks/use-flat-category-store.js.map +1 -1
- package/dist/hooks/use-flat-category-store.mjs +1 -1
- package/dist/hooks/use-frontend-tool.d.ts +3 -3
- package/dist/hooks/use-frontend-tool.js +30 -370
- package/dist/hooks/use-frontend-tool.js.map +1 -1
- package/dist/hooks/use-frontend-tool.mjs +1 -6
- package/dist/hooks/use-human-in-the-loop.d.ts +4 -3
- package/dist/hooks/use-human-in-the-loop.js +61 -393
- package/dist/hooks/use-human-in-the-loop.js.map +1 -1
- package/dist/hooks/use-human-in-the-loop.mjs +1 -6
- package/dist/hooks/use-langgraph-interrupt-render.d.ts +3 -2
- package/dist/hooks/use-langgraph-interrupt-render.js +92 -36
- package/dist/hooks/use-langgraph-interrupt-render.js.map +1 -1
- package/dist/hooks/use-langgraph-interrupt-render.mjs +6 -4
- package/dist/hooks/use-langgraph-interrupt.d.ts +1 -1
- package/dist/hooks/use-langgraph-interrupt.js +24 -1642
- package/dist/hooks/use-langgraph-interrupt.js.map +1 -1
- package/dist/hooks/use-langgraph-interrupt.mjs +2 -23
- package/dist/hooks/use-lazy-tool-renderer.d.ts +6 -0
- package/dist/hooks/use-lazy-tool-renderer.js +53 -0
- package/dist/hooks/use-lazy-tool-renderer.js.map +1 -0
- package/dist/hooks/use-lazy-tool-renderer.mjs +8 -0
- package/dist/hooks/use-lazy-tool-renderer.mjs.map +1 -0
- package/dist/hooks/use-make-copilot-document-readable.js +11 -9
- package/dist/hooks/use-make-copilot-document-readable.js.map +1 -1
- package/dist/hooks/use-make-copilot-document-readable.mjs +2 -2
- package/dist/hooks/use-render-tool-call.d.ts +7 -6
- package/dist/hooks/use-render-tool-call.js +36 -386
- package/dist/hooks/use-render-tool-call.js.map +1 -1
- package/dist/hooks/use-render-tool-call.mjs +1 -6
- package/dist/index.d.ts +11 -6
- package/dist/index.js +1841 -2056
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +82 -63
- package/dist/lib/copilot-task.d.ts +1 -1
- package/dist/lib/copilot-task.js +1 -0
- package/dist/lib/copilot-task.js.map +1 -1
- package/dist/lib/copilot-task.mjs +20 -13
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.js +1 -0
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +20 -13
- package/dist/setupTests.d.ts +2 -2
- package/dist/types/frontend-action.d.ts +5 -5
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/index.mjs +2 -1
- package/dist/types/interrupt-action.d.ts +1 -1
- package/dist/types/interrupt-action.js.map +1 -1
- package/dist/types/interrupt-action.mjs +1 -0
- package/dist/utils/index.d.ts +0 -12
- package/dist/utils/index.js +6 -325
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +3 -23
- package/dist/utils/utils.js.map +1 -1
- package/dist/v2/index.d.ts +2 -0
- package/dist/v2/index.js +27 -0
- package/dist/v2/index.js.map +1 -0
- package/dist/v2/index.mjs +4 -0
- package/dist/v2/index.mjs.map +1 -0
- package/package.json +34 -23
- package/src/components/CopilotListeners.tsx +82 -0
- package/src/components/copilot-provider/copilot-messages.tsx +46 -47
- package/src/components/copilot-provider/copilotkit-props.tsx +8 -1
- package/src/components/copilot-provider/copilotkit.tsx +177 -144
- package/src/components/error-boundary/error-utils.tsx +3 -3
- package/src/context/coagent-state-renders-context.tsx +76 -0
- package/src/context/copilot-context.tsx +21 -21
- package/src/context/copilot-messages-context.tsx +3 -3
- package/src/context/index.ts +8 -0
- package/src/context/threads-context.tsx +41 -0
- package/src/hooks/index.ts +7 -3
- package/src/hooks/use-coagent-state-render-bridge.tsx +293 -0
- package/src/hooks/use-coagent-state-render.ts +4 -7
- package/src/hooks/use-coagent.ts +129 -249
- package/src/hooks/use-configure-chat-suggestions.tsx +85 -0
- package/src/hooks/use-copilot-action.ts +88 -199
- package/src/hooks/use-copilot-chat-headless_c.ts +2 -1
- package/src/hooks/use-copilot-chat.ts +4 -1
- package/src/hooks/use-copilot-chat_internal.ts +349 -258
- package/src/hooks/use-copilot-readable.ts +6 -26
- package/src/hooks/use-flat-category-store.ts +4 -3
- package/src/hooks/use-frontend-tool.ts +67 -8
- package/src/hooks/use-human-in-the-loop.ts +111 -13
- package/src/hooks/use-langgraph-interrupt-render.ts +90 -40
- package/src/hooks/use-langgraph-interrupt.ts +18 -47
- package/src/hooks/use-lazy-tool-renderer.tsx +30 -0
- package/src/hooks/use-make-copilot-document-readable.ts +1 -1
- package/src/hooks/use-render-tool-call.ts +73 -13
- package/src/types/index.ts +1 -0
- package/src/types/interrupt-action.ts +8 -4
- package/src/utils/index.ts +0 -3
- package/src/utils/utils.ts +7 -0
- package/src/v2/index.ts +2 -0
- package/src/v2/styles.css +1 -0
- package/tsup.config.ts +1 -1
- package/dist/chunk-5FHSUKQL.mjs.map +0 -1
- package/dist/chunk-6GPVUMBU.mjs +0 -13
- package/dist/chunk-6GPVUMBU.mjs.map +0 -1
- package/dist/chunk-AKR2SSUJ.mjs +0 -22
- package/dist/chunk-AKR2SSUJ.mjs.map +0 -1
- package/dist/chunk-C6IANC2R.mjs.map +0 -1
- package/dist/chunk-CI4KD357.mjs +0 -804
- package/dist/chunk-CI4KD357.mjs.map +0 -1
- package/dist/chunk-DZTU6PGS.mjs +0 -1
- package/dist/chunk-EUX2P2E7.mjs.map +0 -1
- package/dist/chunk-EVVO67QO.mjs +0 -25
- package/dist/chunk-EVVO67QO.mjs.map +0 -1
- package/dist/chunk-GT5WI3AF.mjs.map +0 -1
- package/dist/chunk-HDOG2RTM.mjs +0 -37
- package/dist/chunk-HDOG2RTM.mjs.map +0 -1
- package/dist/chunk-N4WEHORG.mjs.map +0 -1
- package/dist/chunk-OT5NHMEC.mjs +0 -723
- package/dist/chunk-OT5NHMEC.mjs.map +0 -1
- package/dist/chunk-QHCLJODF.mjs +0 -332
- package/dist/chunk-QHCLJODF.mjs.map +0 -1
- package/dist/chunk-QV5SBF2S.mjs +0 -239
- package/dist/chunk-QV5SBF2S.mjs.map +0 -1
- package/dist/chunk-T3376SZS.mjs +0 -142
- package/dist/chunk-T3376SZS.mjs.map +0 -1
- package/dist/chunk-U3DQY67T.mjs +0 -71
- package/dist/chunk-U3DQY67T.mjs.map +0 -1
- package/dist/chunk-YPBKY4KY.mjs +0 -1
- package/dist/chunk-YPSGKPDA.mjs +0 -1
- package/dist/chunk-ZLQVRPDS.mjs.map +0 -1
- package/dist/chunk-ZVOLWJCY.mjs +0 -47
- package/dist/chunk-ZVOLWJCY.mjs.map +0 -1
- package/dist/hooks/use-chat.d.ts +0 -145
- package/dist/hooks/use-chat.js +0 -1129
- package/dist/hooks/use-chat.js.map +0 -1
- package/dist/hooks/use-chat.mjs +0 -14
- package/dist/index-1f5b66ac.d.ts +0 -36
- package/dist/utils/extract.d.ts +0 -43
- package/dist/utils/extract.js +0 -208
- package/dist/utils/extract.js.map +0 -1
- package/dist/utils/extract.mjs +0 -25
- package/dist/utils/suggestions.d.ts +0 -11
- package/dist/utils/suggestions.js +0 -343
- package/dist/utils/suggestions.js.map +0 -1
- package/dist/utils/suggestions.mjs +0 -25
- package/src/hooks/use-chat.ts +0 -1142
- package/src/utils/extract.ts +0 -215
- package/src/utils/suggestions.ts +0 -208
- /package/dist/{chunk-DZTU6PGS.mjs.map → chunk-36KQV2NA.mjs.map} +0 -0
- /package/dist/{chunk-U7QULEVO.mjs.map → chunk-3GURHDG7.mjs.map} +0 -0
- /package/dist/{chunk-YPBKY4KY.mjs.map → chunk-A6NKSGH3.mjs.map} +0 -0
- /package/dist/{chunk-YPSGKPDA.mjs.map → chunk-CYDWEPFL.mjs.map} +0 -0
- /package/dist/{hooks/use-chat.mjs.map → chunk-FD6FGKYY.mjs.map} +0 -0
- /package/dist/{utils/extract.mjs.map → chunk-JD7BAH7U.mjs.map} +0 -0
- /package/dist/{chunk-N5HOP3PG.mjs.map → chunk-JRT5BJF3.mjs.map} +0 -0
- /package/dist/{chunk-N4VN2B5S.mjs.map → chunk-LHERIF3L.mjs.map} +0 -0
- /package/dist/{chunk-DXEQPN43.mjs.map → chunk-LHKZJ2ND.mjs.map} +0 -0
- /package/dist/{utils/suggestions.mjs.map → chunk-NB2FKV2V.mjs.map} +0 -0
- /package/dist/{chunk-MGWRDFBE.mjs.map → chunk-OVYFRPSN.mjs.map} +0 -0
- /package/dist/{chunk-MQYWH4E6.mjs.map → chunk-QU6NONOD.mjs.map} +0 -0
- /package/dist/{chunk-OKCYPO4I.mjs.map → chunk-WMJVBMUX.mjs.map} +0 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef } from "react";
|
|
2
|
+
import { useAgent, useCopilotChatConfiguration, useCopilotKit } from "@copilotkitnext/react";
|
|
3
|
+
import { CopilotKitError, parseJson } from "@copilotkit/shared";
|
|
4
|
+
import { useCopilotContext } from "../context";
|
|
5
|
+
import { AbstractAgent, AgentSubscriber, AGUIConnectNotImplementedError } from "@ag-ui/client";
|
|
6
|
+
import { useErrorToast } from "./error-boundary/error-utils";
|
|
7
|
+
import { CopilotKitCoreSubscriber } from "@copilotkitnext/core";
|
|
8
|
+
import { useToast } from "./toast/toast-provider";
|
|
9
|
+
import { CopilotKitLowLevelError } from "@copilotkit/shared";
|
|
10
|
+
|
|
11
|
+
const usePredictStateSubscription = (agent?: AbstractAgent) => {
|
|
12
|
+
const predictStateToolsRef = useRef<
|
|
13
|
+
{
|
|
14
|
+
tool: string;
|
|
15
|
+
state_key: string;
|
|
16
|
+
tool_argument: string;
|
|
17
|
+
}[]
|
|
18
|
+
>([]);
|
|
19
|
+
|
|
20
|
+
const getSubscriber = useCallback(
|
|
21
|
+
(agent: AbstractAgent): AgentSubscriber => ({
|
|
22
|
+
onCustomEvent: ({ event }) => {
|
|
23
|
+
if (event.name === "PredictState") {
|
|
24
|
+
predictStateToolsRef.current = event.value;
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
onToolCallArgsEvent: ({ partialToolCallArgs, toolCallName }) => {
|
|
28
|
+
predictStateToolsRef.current.forEach((t) => {
|
|
29
|
+
if (t?.tool !== toolCallName) return;
|
|
30
|
+
|
|
31
|
+
const emittedState =
|
|
32
|
+
typeof partialToolCallArgs === "string"
|
|
33
|
+
? parseJson(partialToolCallArgs as unknown as string, partialToolCallArgs)
|
|
34
|
+
: partialToolCallArgs;
|
|
35
|
+
|
|
36
|
+
agent.setState({
|
|
37
|
+
[t.state_key]: emittedState[t.state_key],
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
}),
|
|
42
|
+
[],
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (!agent) return;
|
|
47
|
+
|
|
48
|
+
const subscriber = getSubscriber(agent);
|
|
49
|
+
const { unsubscribe } = agent.subscribe(subscriber);
|
|
50
|
+
return () => {
|
|
51
|
+
unsubscribe();
|
|
52
|
+
};
|
|
53
|
+
}, [agent, getSubscriber]);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export function CopilotListeners() {
|
|
57
|
+
const { copilotkit } = useCopilotKit();
|
|
58
|
+
const { agentSession } = useCopilotContext();
|
|
59
|
+
const existingConfig = useCopilotChatConfiguration();
|
|
60
|
+
const resolvedAgentId = agentSession?.agentName ?? existingConfig?.agentId ?? "default";
|
|
61
|
+
const { setBannerError } = useToast();
|
|
62
|
+
|
|
63
|
+
const { agent } = useAgent({ agentId: resolvedAgentId });
|
|
64
|
+
|
|
65
|
+
usePredictStateSubscription(agent);
|
|
66
|
+
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
const subscriber: CopilotKitCoreSubscriber = {
|
|
69
|
+
onError: ({ error }) => {
|
|
70
|
+
// @ts-expect-error -- for now, choose a random CPK error type to display the error toast
|
|
71
|
+
setBannerError(new CopilotKitLowLevelError({ error, message: error.message }));
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
const subscription = copilotkit.subscribe(subscriber);
|
|
75
|
+
|
|
76
|
+
return () => {
|
|
77
|
+
subscription.unsubscribe();
|
|
78
|
+
};
|
|
79
|
+
}, [copilotkit?.subscribe]);
|
|
80
|
+
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
CopilotKitError,
|
|
30
30
|
CopilotKitErrorCode,
|
|
31
31
|
} from "@copilotkit/shared";
|
|
32
|
-
import {
|
|
32
|
+
import { Suggestion } from "@copilotkitnext/core";
|
|
33
33
|
|
|
34
34
|
// Helper to determine if error should show as banner based on visibility and legacy patterns
|
|
35
35
|
function shouldShowAsBanner(gqlError: GraphQLError): boolean {
|
|
@@ -118,14 +118,13 @@ export function MessagesTapProvider({ children }: { children: React.ReactNode })
|
|
|
118
118
|
|
|
119
119
|
export function CopilotMessages({ children }: { children: ReactNode }) {
|
|
120
120
|
const [messages, setMessages] = useState<Message[]>([]);
|
|
121
|
-
const lastLoadedThreadId = useRef<string>();
|
|
122
|
-
const lastLoadedAgentName = useRef<string>();
|
|
123
|
-
const lastLoadedMessages = useRef<string>();
|
|
121
|
+
const lastLoadedThreadId = useRef<string>(undefined!);
|
|
122
|
+
const lastLoadedAgentName = useRef<string>(undefined!);
|
|
123
|
+
const lastLoadedMessages = useRef<string>(undefined!);
|
|
124
124
|
|
|
125
125
|
const { updateTapMessages } = useMessagesTap();
|
|
126
126
|
|
|
127
|
-
const { threadId, agentSession,
|
|
128
|
-
useCopilotContext();
|
|
127
|
+
const { threadId, agentSession, showDevConsole, onError, copilotApiConfig } = useCopilotContext();
|
|
129
128
|
const { setBannerError } = useToast();
|
|
130
129
|
|
|
131
130
|
// Helper function to trace UI errors (similar to useCopilotRuntimeClient)
|
|
@@ -253,53 +252,53 @@ export function CopilotMessages({ children }: { children: ReactNode }) {
|
|
|
253
252
|
[setBannerError, showDevConsole, traceUIError],
|
|
254
253
|
);
|
|
255
254
|
|
|
256
|
-
useEffect(() => {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
}, [threadId, agentSession?.agentName]);
|
|
255
|
+
// useEffect(() => {
|
|
256
|
+
// if (!threadId || threadId === lastLoadedThreadId.current) return;
|
|
257
|
+
// if (
|
|
258
|
+
// threadId === lastLoadedThreadId.current &&
|
|
259
|
+
// agentSession?.agentName === lastLoadedAgentName.current
|
|
260
|
+
// ) {
|
|
261
|
+
// return;
|
|
262
|
+
// }
|
|
263
|
+
//
|
|
264
|
+
// const fetchMessages = async () => {
|
|
265
|
+
// if (!agentSession?.agentName) return;
|
|
266
|
+
//
|
|
267
|
+
// const result = await runtimeClient.loadAgentState({
|
|
268
|
+
// threadId,
|
|
269
|
+
// agentName: agentSession?.agentName,
|
|
270
|
+
// });
|
|
271
|
+
//
|
|
272
|
+
// // Check for GraphQL errors and manually trigger error handling
|
|
273
|
+
// if (result.error) {
|
|
274
|
+
// // Update refs to prevent infinite retries of the same failed request
|
|
275
|
+
// lastLoadedThreadId.current = threadId;
|
|
276
|
+
// lastLoadedAgentName.current = agentSession?.agentName;
|
|
277
|
+
// handleGraphQLErrors(result.error);
|
|
278
|
+
// return; // Don't try to process the data if there's an error
|
|
279
|
+
// }
|
|
280
|
+
//
|
|
281
|
+
// const newMessages = result.data?.loadAgentState?.messages;
|
|
282
|
+
// if (newMessages === lastLoadedMessages.current) return;
|
|
283
|
+
//
|
|
284
|
+
// if (result.data?.loadAgentState) {
|
|
285
|
+
// lastLoadedMessages.current = newMessages;
|
|
286
|
+
// lastLoadedThreadId.current = threadId;
|
|
287
|
+
// lastLoadedAgentName.current = agentSession?.agentName;
|
|
288
|
+
//
|
|
289
|
+
// const messages = loadMessagesFromJsonRepresentation(JSON.parse(newMessages || "[]"));
|
|
290
|
+
// setMessages(messages);
|
|
291
|
+
// }
|
|
292
|
+
// };
|
|
293
|
+
// void fetchMessages();
|
|
294
|
+
// }, [threadId, agentSession?.agentName]);
|
|
296
295
|
|
|
297
296
|
useEffect(() => {
|
|
298
297
|
updateTapMessages(messages);
|
|
299
298
|
}, [messages, updateTapMessages]);
|
|
300
299
|
|
|
301
300
|
const memoizedChildren = useMemo(() => children, [children]);
|
|
302
|
-
const [suggestions, setSuggestions] = useState<
|
|
301
|
+
const [suggestions, setSuggestions] = useState<Suggestion[]>([]);
|
|
303
302
|
|
|
304
303
|
return (
|
|
305
304
|
<CopilotMessagesContext.Provider
|
|
@@ -2,11 +2,18 @@ import { ForwardedParametersInput } from "@copilotkit/runtime-client-gql";
|
|
|
2
2
|
import { ReactNode } from "react";
|
|
3
3
|
import { AuthState } from "../../context/copilot-context";
|
|
4
4
|
import { CopilotErrorHandler } from "@copilotkit/shared";
|
|
5
|
+
import { CopilotKitProviderProps } from "@copilotkitnext/react";
|
|
5
6
|
/**
|
|
6
7
|
* Props for CopilotKit.
|
|
7
8
|
*/
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
/**
|
|
11
|
+
* We shouldn't need this `Omit` here, but using it because `CopilotKitProps`
|
|
12
|
+
* and `CopilotKitProviderProps` have non-identical `children` types
|
|
13
|
+
*
|
|
14
|
+
* TODO: Remove this `Omit` once this is resolved.
|
|
15
|
+
*/
|
|
16
|
+
export interface CopilotKitProps extends Omit<CopilotKitProviderProps, "children"> {
|
|
10
17
|
/**
|
|
11
18
|
* Your Copilot Cloud API key.
|
|
12
19
|
*
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import { useCallback, useEffect, useMemo, useRef, useState, SetStateAction } from "react";
|
|
18
|
+
import { CopilotChatConfigurationProvider, CopilotKitProvider } from "@copilotkitnext/react";
|
|
18
19
|
import {
|
|
19
20
|
CopilotContext,
|
|
20
21
|
CopilotApiConfig,
|
|
@@ -40,20 +41,23 @@ import {
|
|
|
40
41
|
import { FrontendAction } from "../../types/frontend-action";
|
|
41
42
|
import useFlatCategoryStore from "../../hooks/use-flat-category-store";
|
|
42
43
|
import { CopilotKitProps } from "./copilotkit-props";
|
|
43
|
-
import { CoAgentStateRender } from "../../types/coagent-action";
|
|
44
44
|
import { CoagentState } from "../../types/coagent-state";
|
|
45
45
|
import { CopilotMessages, MessagesTapProvider } from "./copilot-messages";
|
|
46
46
|
import { ToastProvider } from "../toast/toast-provider";
|
|
47
47
|
import { getErrorActions, UsageBanner } from "../usage-banner";
|
|
48
|
-
import { useCopilotRuntimeClient } from "../../hooks/use-copilot-runtime-client";
|
|
49
48
|
import { shouldShowDevConsole } from "../../utils";
|
|
50
49
|
import { CopilotErrorBoundary } from "../error-boundary/error-boundary";
|
|
51
50
|
import { Agent, ExtensionsInput } from "@copilotkit/runtime-client-gql";
|
|
52
51
|
import {
|
|
53
|
-
|
|
52
|
+
LangGraphInterruptRender,
|
|
54
53
|
LangGraphInterruptActionSetterArgs,
|
|
54
|
+
QueuedInterruptEvent,
|
|
55
55
|
} from "../../types/interrupt-action";
|
|
56
56
|
import { ConsoleTrigger } from "../dev-console/console-trigger";
|
|
57
|
+
import { CoAgentStateRendersProvider } from "../../context/coagent-state-renders-context";
|
|
58
|
+
import { CoAgentStateRenderBridge } from "../../hooks/use-coagent-state-render-bridge";
|
|
59
|
+
import { ThreadsProvider, useThreads } from "../../context/threads-context";
|
|
60
|
+
import { CopilotListeners } from "../CopilotListeners";
|
|
57
61
|
|
|
58
62
|
export function CopilotKit({ children, ...props }: CopilotKitProps) {
|
|
59
63
|
const enabled = shouldShowDevConsole(props.showDevConsole);
|
|
@@ -61,10 +65,20 @@ export function CopilotKit({ children, ...props }: CopilotKitProps) {
|
|
|
61
65
|
// Use API key if provided, otherwise use the license key
|
|
62
66
|
const publicApiKey = props.publicApiKey || props.publicLicenseKey;
|
|
63
67
|
|
|
68
|
+
const renderArr = useMemo(() => [{ render: CoAgentStateRenderBridge }], []);
|
|
69
|
+
|
|
64
70
|
return (
|
|
65
71
|
<ToastProvider enabled={enabled}>
|
|
66
72
|
<CopilotErrorBoundary publicApiKey={publicApiKey} showUsageBanner={enabled}>
|
|
67
|
-
<
|
|
73
|
+
<ThreadsProvider threadId={props.threadId}>
|
|
74
|
+
<CopilotKitProvider
|
|
75
|
+
runtimeUrl={props.runtimeUrl}
|
|
76
|
+
renderCustomMessages={renderArr}
|
|
77
|
+
useSingleEndpoint={true}
|
|
78
|
+
>
|
|
79
|
+
<CopilotKitInternal {...props}>{children}</CopilotKitInternal>
|
|
80
|
+
</CopilotKitProvider>
|
|
81
|
+
</ThreadsProvider>
|
|
68
82
|
</CopilotErrorBoundary>
|
|
69
83
|
</ToastProvider>
|
|
70
84
|
);
|
|
@@ -84,9 +98,11 @@ export function CopilotKitInternal(cpkProps: CopilotKitProps) {
|
|
|
84
98
|
const chatApiEndpoint = props.runtimeUrl || COPILOT_CLOUD_CHAT_URL;
|
|
85
99
|
|
|
86
100
|
const [actions, setActions] = useState<Record<string, FrontendAction<any>>>({});
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
101
|
+
|
|
102
|
+
// State for registered actions from useCopilotAction
|
|
103
|
+
const [registeredActionConfigs, setRegisteredActionConfigs] = useState<
|
|
104
|
+
Map<string, { type: string; action: any; component: any }>
|
|
105
|
+
>(new Map());
|
|
90
106
|
|
|
91
107
|
const chatComponentsCache = useRef<ChatComponentsCache>({
|
|
92
108
|
actions: {},
|
|
@@ -124,23 +140,6 @@ export function CopilotKitInternal(cpkProps: CopilotKitProps) {
|
|
|
124
140
|
});
|
|
125
141
|
}, []);
|
|
126
142
|
|
|
127
|
-
const setCoAgentStateRender = useCallback((id: string, stateRender: CoAgentStateRender<any>) => {
|
|
128
|
-
setCoAgentStateRenders((prevPoints) => {
|
|
129
|
-
return {
|
|
130
|
-
...prevPoints,
|
|
131
|
-
[id]: stateRender,
|
|
132
|
-
};
|
|
133
|
-
});
|
|
134
|
-
}, []);
|
|
135
|
-
|
|
136
|
-
const removeCoAgentStateRender = useCallback((id: string) => {
|
|
137
|
-
setCoAgentStateRenders((prevPoints) => {
|
|
138
|
-
const newPoints = { ...prevPoints };
|
|
139
|
-
delete newPoints[id];
|
|
140
|
-
return newPoints;
|
|
141
|
-
});
|
|
142
|
-
}, []);
|
|
143
|
-
|
|
144
143
|
const getContextString = useCallback(
|
|
145
144
|
(documents: DocumentPointer[], categories: string[]) => {
|
|
146
145
|
const documentsString = documents
|
|
@@ -318,15 +317,6 @@ export function CopilotKitInternal(cpkProps: CopilotKitProps) {
|
|
|
318
317
|
[copilotApiConfig.publicApiKey],
|
|
319
318
|
);
|
|
320
319
|
|
|
321
|
-
const runtimeClient = useCopilotRuntimeClient({
|
|
322
|
-
url: copilotApiConfig.chatApiEndpoint,
|
|
323
|
-
publicApiKey: publicApiKey,
|
|
324
|
-
headers,
|
|
325
|
-
credentials: copilotApiConfig.credentials,
|
|
326
|
-
showDevConsole: shouldShowDevConsole(props.showDevConsole),
|
|
327
|
-
onError: handleErrors,
|
|
328
|
-
});
|
|
329
|
-
|
|
330
320
|
const [chatSuggestionConfiguration, setChatSuggestionConfiguration] = useState<{
|
|
331
321
|
[key: string]: CopilotChatSuggestionConfiguration;
|
|
332
322
|
}>({});
|
|
@@ -365,20 +355,6 @@ export function CopilotKitInternal(cpkProps: CopilotKitProps) {
|
|
|
365
355
|
},
|
|
366
356
|
[],
|
|
367
357
|
);
|
|
368
|
-
const hasLoadedAgents = useRef(false);
|
|
369
|
-
|
|
370
|
-
useEffect(() => {
|
|
371
|
-
if (hasLoadedAgents.current) return;
|
|
372
|
-
|
|
373
|
-
const fetchData = async () => {
|
|
374
|
-
const result = await runtimeClient.availableAgents();
|
|
375
|
-
if (result.data?.availableAgents) {
|
|
376
|
-
setAvailableAgents(result.data.availableAgents.agents);
|
|
377
|
-
}
|
|
378
|
-
hasLoadedAgents.current = true;
|
|
379
|
-
};
|
|
380
|
-
void fetchData();
|
|
381
|
-
}, []);
|
|
382
358
|
|
|
383
359
|
let initialAgentSession: AgentSession | null = null;
|
|
384
360
|
if (props.agent) {
|
|
@@ -400,7 +376,8 @@ export function CopilotKitInternal(cpkProps: CopilotKitProps) {
|
|
|
400
376
|
}
|
|
401
377
|
}, [props.agent]);
|
|
402
378
|
|
|
403
|
-
const
|
|
379
|
+
const { threadId, setThreadId: setInternalThreadId } = useThreads();
|
|
380
|
+
|
|
404
381
|
const setThreadId = useCallback(
|
|
405
382
|
(value: SetStateAction<string>) => {
|
|
406
383
|
if (props.threadId) {
|
|
@@ -411,45 +388,59 @@ export function CopilotKitInternal(cpkProps: CopilotKitProps) {
|
|
|
411
388
|
[props.threadId],
|
|
412
389
|
);
|
|
413
390
|
|
|
414
|
-
// update the internal threadId if the props.threadId changes
|
|
415
|
-
useEffect(() => {
|
|
416
|
-
if (props.threadId !== undefined) {
|
|
417
|
-
setInternalThreadId(props.threadId);
|
|
418
|
-
}
|
|
419
|
-
}, [props.threadId]);
|
|
420
|
-
|
|
421
391
|
const [runId, setRunId] = useState<string | null>(null);
|
|
422
392
|
|
|
423
393
|
const chatAbortControllerRef = useRef<AbortController | null>(null);
|
|
424
394
|
|
|
425
395
|
const showDevConsole = shouldShowDevConsole(props.showDevConsole);
|
|
426
396
|
|
|
427
|
-
const [
|
|
428
|
-
Record<string,
|
|
397
|
+
const [interruptActions, _setInterruptActions] = useState<
|
|
398
|
+
Record<string, LangGraphInterruptRender>
|
|
429
399
|
>({});
|
|
430
|
-
const
|
|
400
|
+
const setInterruptAction = useCallback(
|
|
431
401
|
(threadId: string, action: LangGraphInterruptActionSetterArgs) => {
|
|
432
|
-
|
|
433
|
-
if (action == null)
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
[threadId]: null,
|
|
437
|
-
};
|
|
438
|
-
let event = prev[threadId]?.event;
|
|
439
|
-
if (action.event) {
|
|
440
|
-
// @ts-ignore
|
|
441
|
-
event = { ...(prev[threadId]?.event || {}), ...action.event };
|
|
402
|
+
_setInterruptActions((prev) => {
|
|
403
|
+
if (action == null || !action.id) {
|
|
404
|
+
// Cannot set action without id
|
|
405
|
+
return prev;
|
|
442
406
|
}
|
|
443
407
|
return {
|
|
444
408
|
...prev,
|
|
445
|
-
[
|
|
409
|
+
[action.id]: { ...(prev[action.id] ?? {}), ...action } as LangGraphInterruptRender,
|
|
446
410
|
};
|
|
447
411
|
});
|
|
448
412
|
},
|
|
449
413
|
[],
|
|
450
414
|
);
|
|
451
|
-
const
|
|
452
|
-
|
|
415
|
+
const removeInterruptAction = useCallback((actionId: string): void => {
|
|
416
|
+
_setInterruptActions((prev) => {
|
|
417
|
+
const { [actionId]: _, ...rest } = prev;
|
|
418
|
+
return rest;
|
|
419
|
+
});
|
|
420
|
+
}, []);
|
|
421
|
+
|
|
422
|
+
const [interruptEventQueue, setInterruptEventQueue] = useState<
|
|
423
|
+
Record<string, QueuedInterruptEvent[]>
|
|
424
|
+
>({});
|
|
425
|
+
|
|
426
|
+
const addInterruptEvent = useCallback((queuedEvent: QueuedInterruptEvent) => {
|
|
427
|
+
setInterruptEventQueue((prev) => {
|
|
428
|
+
const threadQueue = prev[queuedEvent.threadId] || [];
|
|
429
|
+
return {
|
|
430
|
+
...prev,
|
|
431
|
+
[queuedEvent.threadId]: [...threadQueue, queuedEvent],
|
|
432
|
+
};
|
|
433
|
+
});
|
|
434
|
+
}, []);
|
|
435
|
+
|
|
436
|
+
const removeInterruptEvent = useCallback((threadId: string, eventId: string) => {
|
|
437
|
+
setInterruptEventQueue((prev) => {
|
|
438
|
+
const threadQueue = prev[threadId] || [];
|
|
439
|
+
return {
|
|
440
|
+
...prev,
|
|
441
|
+
[threadId]: threadQueue.filter((event) => event.eventId !== eventId),
|
|
442
|
+
};
|
|
443
|
+
});
|
|
453
444
|
}, []);
|
|
454
445
|
|
|
455
446
|
const memoizedChildren = useMemo(() => children, [children]);
|
|
@@ -494,81 +485,123 @@ export function CopilotKitInternal(cpkProps: CopilotKitProps) {
|
|
|
494
485
|
[setAuthStates],
|
|
495
486
|
);
|
|
496
487
|
|
|
488
|
+
const handleSetRegisteredActions = useCallback((actionConfig: any): string => {
|
|
489
|
+
const key = actionConfig.action.name || randomUUID();
|
|
490
|
+
setRegisteredActionConfigs((prev) => {
|
|
491
|
+
const newMap = new Map(prev);
|
|
492
|
+
newMap.set(key, actionConfig);
|
|
493
|
+
return newMap;
|
|
494
|
+
});
|
|
495
|
+
return key;
|
|
496
|
+
}, []);
|
|
497
|
+
|
|
498
|
+
const handleRemoveRegisteredAction = useCallback((actionKey: string) => {
|
|
499
|
+
setRegisteredActionConfigs((prev) => {
|
|
500
|
+
const newMap = new Map(prev);
|
|
501
|
+
newMap.delete(actionKey);
|
|
502
|
+
return newMap;
|
|
503
|
+
});
|
|
504
|
+
}, []);
|
|
505
|
+
|
|
506
|
+
// Component to render all registered actions
|
|
507
|
+
const RegisteredActionsRenderer = useMemo(() => {
|
|
508
|
+
return () => (
|
|
509
|
+
<>
|
|
510
|
+
{Array.from(registeredActionConfigs.entries()).map(([key, config]) => {
|
|
511
|
+
const Component = config.component;
|
|
512
|
+
return <Component key={key} action={config.action} />;
|
|
513
|
+
})}
|
|
514
|
+
</>
|
|
515
|
+
);
|
|
516
|
+
}, [registeredActionConfigs]);
|
|
517
|
+
|
|
497
518
|
return (
|
|
498
|
-
<
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
setAction,
|
|
504
|
-
removeAction,
|
|
505
|
-
coAgentStateRenders,
|
|
506
|
-
setCoAgentStateRender,
|
|
507
|
-
removeCoAgentStateRender,
|
|
508
|
-
getContextString,
|
|
509
|
-
addContext,
|
|
510
|
-
removeContext,
|
|
511
|
-
getAllContext,
|
|
512
|
-
getDocumentsContext,
|
|
513
|
-
addDocumentContext,
|
|
514
|
-
removeDocumentContext,
|
|
515
|
-
copilotApiConfig: copilotApiConfig,
|
|
516
|
-
isLoading,
|
|
517
|
-
setIsLoading,
|
|
518
|
-
chatSuggestionConfiguration,
|
|
519
|
-
addChatSuggestionConfiguration,
|
|
520
|
-
removeChatSuggestionConfiguration,
|
|
521
|
-
chatInstructions,
|
|
522
|
-
setChatInstructions,
|
|
523
|
-
additionalInstructions,
|
|
524
|
-
setAdditionalInstructions,
|
|
525
|
-
showDevConsole,
|
|
526
|
-
coagentStates,
|
|
527
|
-
setCoagentStates,
|
|
528
|
-
coagentStatesRef,
|
|
529
|
-
setCoagentStatesWithRef,
|
|
530
|
-
agentSession,
|
|
531
|
-
setAgentSession,
|
|
532
|
-
runtimeClient,
|
|
533
|
-
forwardedParameters,
|
|
534
|
-
agentLock,
|
|
535
|
-
threadId: internalThreadId,
|
|
536
|
-
setThreadId,
|
|
537
|
-
runId,
|
|
538
|
-
setRunId,
|
|
539
|
-
chatAbortControllerRef,
|
|
540
|
-
availableAgents,
|
|
541
|
-
authConfig_c: props.authConfig_c,
|
|
542
|
-
authStates_c: authStates,
|
|
543
|
-
setAuthStates_c: updateAuthStates,
|
|
544
|
-
extensions,
|
|
545
|
-
setExtensions: updateExtensions,
|
|
546
|
-
langGraphInterruptAction: langGraphInterruptActions[internalThreadId] ?? null,
|
|
547
|
-
setLangGraphInterruptAction,
|
|
548
|
-
removeLangGraphInterruptAction,
|
|
549
|
-
bannerError,
|
|
550
|
-
setBannerError,
|
|
551
|
-
onError: handleErrors,
|
|
552
|
-
internalErrorHandlers,
|
|
553
|
-
setInternalErrorHandler,
|
|
554
|
-
removeInternalErrorHandler,
|
|
555
|
-
}}
|
|
519
|
+
<CopilotChatConfigurationProvider
|
|
520
|
+
// labels={labels}
|
|
521
|
+
// isModalDefaultOpen={isModalDefaultOpen}
|
|
522
|
+
agentId={agentSession?.agentName ?? "default"}
|
|
523
|
+
threadId={threadId}
|
|
556
524
|
>
|
|
557
|
-
<
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
525
|
+
<CopilotContext.Provider
|
|
526
|
+
value={{
|
|
527
|
+
actions,
|
|
528
|
+
chatComponentsCache,
|
|
529
|
+
getFunctionCallHandler,
|
|
530
|
+
setAction,
|
|
531
|
+
removeAction,
|
|
532
|
+
setRegisteredActions: handleSetRegisteredActions,
|
|
533
|
+
removeRegisteredAction: handleRemoveRegisteredAction,
|
|
534
|
+
getContextString,
|
|
535
|
+
addContext,
|
|
536
|
+
removeContext,
|
|
537
|
+
getAllContext,
|
|
538
|
+
getDocumentsContext,
|
|
539
|
+
addDocumentContext,
|
|
540
|
+
removeDocumentContext,
|
|
541
|
+
copilotApiConfig: copilotApiConfig,
|
|
542
|
+
isLoading,
|
|
543
|
+
setIsLoading,
|
|
544
|
+
chatSuggestionConfiguration,
|
|
545
|
+
addChatSuggestionConfiguration,
|
|
546
|
+
removeChatSuggestionConfiguration,
|
|
547
|
+
chatInstructions,
|
|
548
|
+
setChatInstructions,
|
|
549
|
+
additionalInstructions,
|
|
550
|
+
setAdditionalInstructions,
|
|
551
|
+
showDevConsole,
|
|
552
|
+
coagentStates,
|
|
553
|
+
setCoagentStates,
|
|
554
|
+
coagentStatesRef,
|
|
555
|
+
setCoagentStatesWithRef,
|
|
556
|
+
agentSession,
|
|
557
|
+
setAgentSession,
|
|
558
|
+
forwardedParameters,
|
|
559
|
+
agentLock,
|
|
560
|
+
threadId,
|
|
561
|
+
setThreadId,
|
|
562
|
+
runId,
|
|
563
|
+
setRunId,
|
|
564
|
+
chatAbortControllerRef,
|
|
565
|
+
availableAgents,
|
|
566
|
+
authConfig_c: props.authConfig_c,
|
|
567
|
+
authStates_c: authStates,
|
|
568
|
+
setAuthStates_c: updateAuthStates,
|
|
569
|
+
extensions,
|
|
570
|
+
setExtensions: updateExtensions,
|
|
571
|
+
interruptActions,
|
|
572
|
+
setInterruptAction,
|
|
573
|
+
removeInterruptAction,
|
|
574
|
+
interruptEventQueue,
|
|
575
|
+
addInterruptEvent,
|
|
576
|
+
removeInterruptEvent,
|
|
577
|
+
bannerError,
|
|
578
|
+
setBannerError,
|
|
579
|
+
onError: handleErrors,
|
|
580
|
+
internalErrorHandlers,
|
|
581
|
+
setInternalErrorHandler,
|
|
582
|
+
removeInternalErrorHandler,
|
|
583
|
+
}}
|
|
584
|
+
>
|
|
585
|
+
<CopilotListeners />
|
|
586
|
+
<CoAgentStateRendersProvider>
|
|
587
|
+
<MessagesTapProvider>
|
|
588
|
+
<CopilotMessages>
|
|
589
|
+
{memoizedChildren}
|
|
590
|
+
{showDevConsole && <ConsoleTrigger />}
|
|
591
|
+
<RegisteredActionsRenderer />
|
|
592
|
+
</CopilotMessages>
|
|
593
|
+
</MessagesTapProvider>
|
|
594
|
+
{bannerError && showDevConsole && (
|
|
595
|
+
<UsageBanner
|
|
596
|
+
severity={bannerError.severity}
|
|
597
|
+
message={bannerError.message}
|
|
598
|
+
onClose={() => setBannerError(null)}
|
|
599
|
+
actions={getErrorActions(bannerError)}
|
|
600
|
+
/>
|
|
601
|
+
)}
|
|
602
|
+
</CoAgentStateRendersProvider>
|
|
603
|
+
</CopilotContext.Provider>
|
|
604
|
+
</CopilotChatConfigurationProvider>
|
|
572
605
|
);
|
|
573
606
|
}
|
|
574
607
|
|
|
@@ -60,8 +60,8 @@ export function useErrorToast() {
|
|
|
60
60
|
const { addToast } = useToast();
|
|
61
61
|
|
|
62
62
|
return useCallback(
|
|
63
|
-
(
|
|
64
|
-
const errorId =
|
|
63
|
+
(errors: (Error | GraphQLError)[]) => {
|
|
64
|
+
const errorId = errors
|
|
65
65
|
.map((err) => {
|
|
66
66
|
const message =
|
|
67
67
|
"extensions" in err
|
|
@@ -75,7 +75,7 @@ export function useErrorToast() {
|
|
|
75
75
|
addToast({
|
|
76
76
|
type: "error",
|
|
77
77
|
id: errorId, // Toast libraries typically dedupe by id
|
|
78
|
-
message: <ErrorToast errors={
|
|
78
|
+
message: <ErrorToast errors={errors} />,
|
|
79
79
|
});
|
|
80
80
|
},
|
|
81
81
|
[addToast],
|