@copilotkit/react-core 1.10.7-next.0 → 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/CHANGELOG.md +0 -7
- 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-OAGAFMUM.mjs → chunk-3R423LZT.mjs} +6 -5
- package/dist/{chunk-OAGAFMUM.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-E3624YDU.mjs → chunk-GMI4KO4X.mjs} +8 -6
- package/dist/{chunk-E3624YDU.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-EDBI5PCJ.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 +15 -10
- 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 +16 -10
- 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 +17 -10
- 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 +78 -59
- 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 +18 -11
- 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 +18 -11
- 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 +1 -21
- 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-BXXJQ2BL.mjs +0 -239
- package/dist/chunk-BXXJQ2BL.mjs.map +0 -1
- package/dist/chunk-C6IANC2R.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-GGLAHG3I.mjs +0 -804
- package/dist/chunk-GGLAHG3I.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-MIXSWZSB.mjs +0 -71
- package/dist/chunk-MIXSWZSB.mjs.map +0 -1
- package/dist/chunk-N4WEHORG.mjs.map +0 -1
- package/dist/chunk-NSBAWITG.mjs +0 -332
- package/dist/chunk-NSBAWITG.mjs.map +0 -1
- package/dist/chunk-OT5NHMEC.mjs +0 -723
- package/dist/chunk-OT5NHMEC.mjs.map +0 -1
- package/dist/chunk-T3376SZS.mjs +0 -142
- package/dist/chunk-T3376SZS.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-EDBI5PCJ.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
|
@@ -85,7 +85,8 @@ __export(copilotkit_exports, {
|
|
|
85
85
|
defaultCopilotContextCategories: () => defaultCopilotContextCategories
|
|
86
86
|
});
|
|
87
87
|
module.exports = __toCommonJS(copilotkit_exports);
|
|
88
|
-
var
|
|
88
|
+
var import_react16 = require("react");
|
|
89
|
+
var import_react17 = require("@copilotkitnext/react");
|
|
89
90
|
|
|
90
91
|
// src/context/copilot-context.tsx
|
|
91
92
|
var import_react = __toESM(require("react"));
|
|
@@ -95,10 +96,8 @@ var emptyCopilotContext = {
|
|
|
95
96
|
},
|
|
96
97
|
removeAction: () => {
|
|
97
98
|
},
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
},
|
|
101
|
-
removeCoAgentStateRender: () => {
|
|
99
|
+
setRegisteredActions: () => "",
|
|
100
|
+
removeRegisteredAction: () => {
|
|
102
101
|
},
|
|
103
102
|
chatComponentsCache: { current: { actions: {}, coAgentStateRenders: {} } },
|
|
104
103
|
getContextString: (documents, categories) => returnAndThrowInDebug(""),
|
|
@@ -118,7 +117,6 @@ var emptyCopilotContext = {
|
|
|
118
117
|
addDocumentContext: () => returnAndThrowInDebug(""),
|
|
119
118
|
removeDocumentContext: () => {
|
|
120
119
|
},
|
|
121
|
-
runtimeClient: {},
|
|
122
120
|
copilotApiConfig: new class {
|
|
123
121
|
get chatApiEndpoint() {
|
|
124
122
|
throw new Error("Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!");
|
|
@@ -158,10 +156,15 @@ var emptyCopilotContext = {
|
|
|
158
156
|
extensions: {},
|
|
159
157
|
setExtensions: () => {
|
|
160
158
|
},
|
|
161
|
-
|
|
162
|
-
|
|
159
|
+
interruptActions: {},
|
|
160
|
+
setInterruptAction: () => {
|
|
161
|
+
},
|
|
162
|
+
removeInterruptAction: () => {
|
|
163
|
+
},
|
|
164
|
+
interruptEventQueue: {},
|
|
165
|
+
addInterruptEvent: () => {
|
|
163
166
|
},
|
|
164
|
-
|
|
167
|
+
removeInterruptEvent: () => {
|
|
165
168
|
},
|
|
166
169
|
onError: () => {
|
|
167
170
|
},
|
|
@@ -322,13 +325,16 @@ function setsHaveIntersection(setA, setB) {
|
|
|
322
325
|
|
|
323
326
|
// src/components/copilot-provider/copilotkit.tsx
|
|
324
327
|
var import_react_dom = require("react-dom");
|
|
325
|
-
var
|
|
328
|
+
var import_shared13 = require("@copilotkit/shared");
|
|
326
329
|
|
|
327
330
|
// src/hooks/use-flat-category-store.ts
|
|
328
331
|
var import_react3 = require("react");
|
|
329
332
|
var import_shared2 = require("@copilotkit/shared");
|
|
330
333
|
var useFlatCategoryStore = () => {
|
|
331
|
-
const [elements, dispatch] = (0, import_react3.useReducer)(
|
|
334
|
+
const [elements, dispatch] = (0, import_react3.useReducer)(
|
|
335
|
+
flatCategoryStoreReducer,
|
|
336
|
+
/* @__PURE__ */ new Map()
|
|
337
|
+
);
|
|
332
338
|
const addElement = (0, import_react3.useCallback)((value, categories) => {
|
|
333
339
|
const newId = (0, import_shared2.randomId)();
|
|
334
340
|
dispatch({
|
|
@@ -413,9 +419,6 @@ function useCopilotMessagesContext() {
|
|
|
413
419
|
return context;
|
|
414
420
|
}
|
|
415
421
|
|
|
416
|
-
// src/components/copilot-provider/copilot-messages.tsx
|
|
417
|
-
var import_runtime_client_gql = require("@copilotkit/runtime-client-gql");
|
|
418
|
-
|
|
419
422
|
// src/components/toast/toast-provider.tsx
|
|
420
423
|
var import_react5 = require("react");
|
|
421
424
|
var import_shared3 = require("@copilotkit/shared");
|
|
@@ -751,11 +754,11 @@ function MessagesTapProvider({ children }) {
|
|
|
751
754
|
}
|
|
752
755
|
function CopilotMessages({ children }) {
|
|
753
756
|
const [messages, setMessages] = (0, import_react6.useState)([]);
|
|
754
|
-
const lastLoadedThreadId = (0, import_react6.useRef)();
|
|
755
|
-
const lastLoadedAgentName = (0, import_react6.useRef)();
|
|
756
|
-
const lastLoadedMessages = (0, import_react6.useRef)();
|
|
757
|
+
const lastLoadedThreadId = (0, import_react6.useRef)(void 0);
|
|
758
|
+
const lastLoadedAgentName = (0, import_react6.useRef)(void 0);
|
|
759
|
+
const lastLoadedMessages = (0, import_react6.useRef)(void 0);
|
|
757
760
|
const { updateTapMessages } = useMessagesTap();
|
|
758
|
-
const { threadId, agentSession,
|
|
761
|
+
const { threadId, agentSession, showDevConsole, onError, copilotApiConfig } = useCopilotContext();
|
|
759
762
|
const { setBannerError } = useToast();
|
|
760
763
|
const traceUIError = (0, import_react6.useCallback)(
|
|
761
764
|
(error, originalError) => __async(this, null, function* () {
|
|
@@ -787,7 +790,7 @@ function CopilotMessages({ children }) {
|
|
|
787
790
|
}),
|
|
788
791
|
[onError, copilotApiConfig.publicApiKey, copilotApiConfig.chatApiEndpoint]
|
|
789
792
|
);
|
|
790
|
-
const
|
|
793
|
+
const createStructuredError = (gqlError) => {
|
|
791
794
|
const extensions = gqlError.extensions;
|
|
792
795
|
const originalError = extensions == null ? void 0 : extensions.originalError;
|
|
793
796
|
if (originalError == null ? void 0 : originalError.stack) {
|
|
@@ -828,7 +831,7 @@ function CopilotMessages({ children }) {
|
|
|
828
831
|
console.error("CopilotKit Silent Error:", gqlError.message);
|
|
829
832
|
return;
|
|
830
833
|
}
|
|
831
|
-
const ckError =
|
|
834
|
+
const ckError = createStructuredError(gqlError);
|
|
832
835
|
if (ckError) {
|
|
833
836
|
setBannerError(ckError);
|
|
834
837
|
traceUIError(ckError, gqlError);
|
|
@@ -858,39 +861,6 @@ function CopilotMessages({ children }) {
|
|
|
858
861
|
},
|
|
859
862
|
[setBannerError, showDevConsole, traceUIError]
|
|
860
863
|
);
|
|
861
|
-
(0, import_react6.useEffect)(() => {
|
|
862
|
-
if (!threadId || threadId === lastLoadedThreadId.current)
|
|
863
|
-
return;
|
|
864
|
-
if (threadId === lastLoadedThreadId.current && (agentSession == null ? void 0 : agentSession.agentName) === lastLoadedAgentName.current) {
|
|
865
|
-
return;
|
|
866
|
-
}
|
|
867
|
-
const fetchMessages = () => __async(this, null, function* () {
|
|
868
|
-
var _a, _b, _c;
|
|
869
|
-
if (!(agentSession == null ? void 0 : agentSession.agentName))
|
|
870
|
-
return;
|
|
871
|
-
const result = yield runtimeClient.loadAgentState({
|
|
872
|
-
threadId,
|
|
873
|
-
agentName: agentSession == null ? void 0 : agentSession.agentName
|
|
874
|
-
});
|
|
875
|
-
if (result.error) {
|
|
876
|
-
lastLoadedThreadId.current = threadId;
|
|
877
|
-
lastLoadedAgentName.current = agentSession == null ? void 0 : agentSession.agentName;
|
|
878
|
-
handleGraphQLErrors(result.error);
|
|
879
|
-
return;
|
|
880
|
-
}
|
|
881
|
-
const newMessages = (_b = (_a = result.data) == null ? void 0 : _a.loadAgentState) == null ? void 0 : _b.messages;
|
|
882
|
-
if (newMessages === lastLoadedMessages.current)
|
|
883
|
-
return;
|
|
884
|
-
if ((_c = result.data) == null ? void 0 : _c.loadAgentState) {
|
|
885
|
-
lastLoadedMessages.current = newMessages;
|
|
886
|
-
lastLoadedThreadId.current = threadId;
|
|
887
|
-
lastLoadedAgentName.current = agentSession == null ? void 0 : agentSession.agentName;
|
|
888
|
-
const messages2 = (0, import_runtime_client_gql.loadMessagesFromJsonRepresentation)(JSON.parse(newMessages || "[]"));
|
|
889
|
-
setMessages(messages2);
|
|
890
|
-
}
|
|
891
|
-
});
|
|
892
|
-
void fetchMessages();
|
|
893
|
-
}, [threadId, agentSession == null ? void 0 : agentSession.agentName]);
|
|
894
864
|
(0, import_react6.useEffect)(() => {
|
|
895
865
|
updateTapMessages(messages);
|
|
896
866
|
}, [messages, updateTapMessages]);
|
|
@@ -1111,123 +1081,12 @@ var getErrorActions = (error) => {
|
|
|
1111
1081
|
}
|
|
1112
1082
|
};
|
|
1113
1083
|
|
|
1114
|
-
// src/hooks/use-copilot-runtime-client.ts
|
|
1115
|
-
var import_runtime_client_gql2 = require("@copilotkit/runtime-client-gql");
|
|
1116
|
-
var import_react7 = require("react");
|
|
1117
|
-
var import_shared6 = require("@copilotkit/shared");
|
|
1118
|
-
var useCopilotRuntimeClient = (options) => {
|
|
1119
|
-
const { setBannerError } = useToast();
|
|
1120
|
-
const _a = options, { showDevConsole, onError } = _a, runtimeOptions = __objRest(_a, ["showDevConsole", "onError"]);
|
|
1121
|
-
const lastStructuredErrorRef = (0, import_react7.useRef)(null);
|
|
1122
|
-
const traceUIError = (error, originalError) => __async(void 0, null, function* () {
|
|
1123
|
-
try {
|
|
1124
|
-
const errorEvent = {
|
|
1125
|
-
type: "error",
|
|
1126
|
-
timestamp: Date.now(),
|
|
1127
|
-
context: {
|
|
1128
|
-
source: "ui",
|
|
1129
|
-
request: {
|
|
1130
|
-
operation: "runtimeClient",
|
|
1131
|
-
url: runtimeOptions.url,
|
|
1132
|
-
startTime: Date.now()
|
|
1133
|
-
},
|
|
1134
|
-
technical: {
|
|
1135
|
-
environment: "browser",
|
|
1136
|
-
userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
|
|
1137
|
-
stackTrace: originalError instanceof Error ? originalError.stack : void 0
|
|
1138
|
-
}
|
|
1139
|
-
},
|
|
1140
|
-
error
|
|
1141
|
-
};
|
|
1142
|
-
yield onError(errorEvent);
|
|
1143
|
-
} catch (error2) {
|
|
1144
|
-
console.error("Error in onError handler:", error2);
|
|
1145
|
-
}
|
|
1146
|
-
});
|
|
1147
|
-
const runtimeClient = (0, import_react7.useMemo)(() => {
|
|
1148
|
-
return new import_runtime_client_gql2.CopilotRuntimeClient(__spreadProps(__spreadValues({}, runtimeOptions), {
|
|
1149
|
-
handleGQLErrors: (error) => {
|
|
1150
|
-
var _a2;
|
|
1151
|
-
if ((_a2 = error.graphQLErrors) == null ? void 0 : _a2.length) {
|
|
1152
|
-
const graphQLErrors = error.graphQLErrors;
|
|
1153
|
-
const routeError = (gqlError) => {
|
|
1154
|
-
const extensions = gqlError.extensions;
|
|
1155
|
-
const visibility = extensions == null ? void 0 : extensions.visibility;
|
|
1156
|
-
if (visibility === import_shared6.ErrorVisibility.SILENT) {
|
|
1157
|
-
console.error("CopilotKit Silent Error:", gqlError.message);
|
|
1158
|
-
return;
|
|
1159
|
-
}
|
|
1160
|
-
const now = Date.now();
|
|
1161
|
-
const errorMessage = gqlError.message;
|
|
1162
|
-
if (lastStructuredErrorRef.current && lastStructuredErrorRef.current.message === errorMessage && now - lastStructuredErrorRef.current.timestamp < 150) {
|
|
1163
|
-
return;
|
|
1164
|
-
}
|
|
1165
|
-
lastStructuredErrorRef.current = { message: errorMessage, timestamp: now };
|
|
1166
|
-
const ckError = createStructuredError(gqlError);
|
|
1167
|
-
if (ckError) {
|
|
1168
|
-
setBannerError(ckError);
|
|
1169
|
-
traceUIError(ckError, gqlError);
|
|
1170
|
-
} else {
|
|
1171
|
-
const fallbackError = new import_shared6.CopilotKitError({
|
|
1172
|
-
message: gqlError.message,
|
|
1173
|
-
code: import_shared6.CopilotKitErrorCode.UNKNOWN
|
|
1174
|
-
});
|
|
1175
|
-
setBannerError(fallbackError);
|
|
1176
|
-
traceUIError(fallbackError, gqlError);
|
|
1177
|
-
}
|
|
1178
|
-
};
|
|
1179
|
-
graphQLErrors.forEach(routeError);
|
|
1180
|
-
} else {
|
|
1181
|
-
const fallbackError = new import_shared6.CopilotKitError({
|
|
1182
|
-
message: (error == null ? void 0 : error.message) || String(error),
|
|
1183
|
-
code: import_shared6.CopilotKitErrorCode.UNKNOWN
|
|
1184
|
-
});
|
|
1185
|
-
setBannerError(fallbackError);
|
|
1186
|
-
traceUIError(fallbackError, error);
|
|
1187
|
-
}
|
|
1188
|
-
},
|
|
1189
|
-
handleGQLWarning: (message) => {
|
|
1190
|
-
console.warn(message);
|
|
1191
|
-
const warningError = new import_shared6.CopilotKitError({
|
|
1192
|
-
message,
|
|
1193
|
-
code: import_shared6.CopilotKitErrorCode.UNKNOWN
|
|
1194
|
-
});
|
|
1195
|
-
setBannerError(warningError);
|
|
1196
|
-
}
|
|
1197
|
-
}));
|
|
1198
|
-
}, [runtimeOptions, setBannerError, onError]);
|
|
1199
|
-
return runtimeClient;
|
|
1200
|
-
};
|
|
1201
|
-
function createStructuredError(gqlError) {
|
|
1202
|
-
var _a, _b, _c;
|
|
1203
|
-
const extensions = gqlError.extensions;
|
|
1204
|
-
const originalError = extensions == null ? void 0 : extensions.originalError;
|
|
1205
|
-
const message = (originalError == null ? void 0 : originalError.message) || gqlError.message;
|
|
1206
|
-
const code = extensions == null ? void 0 : extensions.code;
|
|
1207
|
-
if (code) {
|
|
1208
|
-
return new import_shared6.CopilotKitError({ message, code });
|
|
1209
|
-
}
|
|
1210
|
-
if ((_a = originalError == null ? void 0 : originalError.stack) == null ? void 0 : _a.includes("CopilotApiDiscoveryError")) {
|
|
1211
|
-
return new import_shared6.CopilotKitApiDiscoveryError({ message });
|
|
1212
|
-
}
|
|
1213
|
-
if ((_b = originalError == null ? void 0 : originalError.stack) == null ? void 0 : _b.includes("CopilotKitRemoteEndpointDiscoveryError")) {
|
|
1214
|
-
return new import_shared6.CopilotKitRemoteEndpointDiscoveryError({ message });
|
|
1215
|
-
}
|
|
1216
|
-
if ((_c = originalError == null ? void 0 : originalError.stack) == null ? void 0 : _c.includes("CopilotKitAgentDiscoveryError")) {
|
|
1217
|
-
return new import_shared6.CopilotKitAgentDiscoveryError({
|
|
1218
|
-
agentName: "",
|
|
1219
|
-
availableAgents: []
|
|
1220
|
-
});
|
|
1221
|
-
}
|
|
1222
|
-
return null;
|
|
1223
|
-
}
|
|
1224
|
-
|
|
1225
1084
|
// src/components/error-boundary/error-boundary.tsx
|
|
1226
|
-
var
|
|
1227
|
-
var
|
|
1085
|
+
var import_react7 = __toESM(require("react"));
|
|
1086
|
+
var import_shared7 = require("@copilotkit/shared");
|
|
1228
1087
|
|
|
1229
1088
|
// src/lib/status-checker.ts
|
|
1230
|
-
var
|
|
1089
|
+
var import_shared6 = require("@copilotkit/shared");
|
|
1231
1090
|
var STATUS_CHECK_INTERVAL = 1e3 * 60 * 5;
|
|
1232
1091
|
var StatusChecker = class {
|
|
1233
1092
|
constructor() {
|
|
@@ -1245,10 +1104,10 @@ var StatusChecker = class {
|
|
|
1245
1104
|
clearInterval(this.intervalId);
|
|
1246
1105
|
const checkStatus = () => __async(this, null, function* () {
|
|
1247
1106
|
try {
|
|
1248
|
-
const response = yield fetch(`${
|
|
1107
|
+
const response = yield fetch(`${import_shared6.COPILOT_CLOUD_API_URL}/ciu`, {
|
|
1249
1108
|
method: "GET",
|
|
1250
1109
|
headers: {
|
|
1251
|
-
[
|
|
1110
|
+
[import_shared6.COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: publicApiKey
|
|
1252
1111
|
}
|
|
1253
1112
|
}).then((response2) => response2.json());
|
|
1254
1113
|
this.lastResponse = response;
|
|
@@ -1283,7 +1142,7 @@ var StatusChecker = class {
|
|
|
1283
1142
|
// src/components/error-boundary/error-boundary.tsx
|
|
1284
1143
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
1285
1144
|
var statusChecker = new StatusChecker();
|
|
1286
|
-
var CopilotErrorBoundary = class extends
|
|
1145
|
+
var CopilotErrorBoundary = class extends import_react7.default.Component {
|
|
1287
1146
|
constructor(props) {
|
|
1288
1147
|
super(props);
|
|
1289
1148
|
this.state = {
|
|
@@ -1315,7 +1174,7 @@ var CopilotErrorBoundary = class extends import_react8.default.Component {
|
|
|
1315
1174
|
render() {
|
|
1316
1175
|
var _a, _b, _c, _d;
|
|
1317
1176
|
if (this.state.hasError) {
|
|
1318
|
-
if (this.state.error instanceof
|
|
1177
|
+
if (this.state.error instanceof import_shared7.CopilotKitError) {
|
|
1319
1178
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
1320
1179
|
this.props.children,
|
|
1321
1180
|
this.props.showUsageBanner && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
@@ -1335,7 +1194,7 @@ var CopilotErrorBoundary = class extends import_react8.default.Component {
|
|
|
1335
1194
|
};
|
|
1336
1195
|
|
|
1337
1196
|
// src/components/dev-console/console-trigger.tsx
|
|
1338
|
-
var
|
|
1197
|
+
var import_react9 = require("react");
|
|
1339
1198
|
|
|
1340
1199
|
// src/components/dev-console/icons.tsx
|
|
1341
1200
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
@@ -1398,14 +1257,14 @@ var CopilotKitIcon = () => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
|
1398
1257
|
);
|
|
1399
1258
|
|
|
1400
1259
|
// src/components/dev-console/developer-console-modal.tsx
|
|
1401
|
-
var
|
|
1402
|
-
var
|
|
1260
|
+
var import_shared8 = require("@copilotkit/shared");
|
|
1261
|
+
var import_react8 = require("react");
|
|
1403
1262
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1404
1263
|
function DeveloperConsoleModal({ isOpen, onClose, hasApiKey }) {
|
|
1405
1264
|
const context = useCopilotContext();
|
|
1406
1265
|
const messagesContext = useCopilotMessagesContext();
|
|
1407
|
-
const [activeTab, setActiveTab] = (0,
|
|
1408
|
-
(0,
|
|
1266
|
+
const [activeTab, setActiveTab] = (0, import_react8.useState)("actions");
|
|
1267
|
+
(0, import_react8.useEffect)(() => {
|
|
1409
1268
|
const handleEscape = (e) => {
|
|
1410
1269
|
if (e.key === "Escape") {
|
|
1411
1270
|
onClose();
|
|
@@ -1570,7 +1429,7 @@ function DeveloperConsoleModal({ isOpen, onClose, hasApiKey }) {
|
|
|
1570
1429
|
},
|
|
1571
1430
|
children: [
|
|
1572
1431
|
"v",
|
|
1573
|
-
|
|
1432
|
+
import_shared8.COPILOTKIT_VERSION
|
|
1574
1433
|
]
|
|
1575
1434
|
}
|
|
1576
1435
|
)
|
|
@@ -2146,15 +2005,15 @@ var INSPECTOR_HIDE_KEY = "cpk:inspector:hidden";
|
|
|
2146
2005
|
function ConsoleTrigger({ position = "bottom-right" }) {
|
|
2147
2006
|
const context = useCopilotContext();
|
|
2148
2007
|
const hasApiKey = Boolean(context.copilotApiConfig.publicApiKey);
|
|
2149
|
-
const [isModalOpen, setIsModalOpen] = (0,
|
|
2150
|
-
const [isHovered, setIsHovered] = (0,
|
|
2151
|
-
const [isDragging, setIsDragging] = (0,
|
|
2152
|
-
const [buttonPosition, setButtonPosition] = (0,
|
|
2153
|
-
const [mounted, setMounted] = (0,
|
|
2154
|
-
const [isHidden, setIsHidden] = (0,
|
|
2155
|
-
const dragRef = (0,
|
|
2156
|
-
const buttonRef = (0,
|
|
2157
|
-
(0,
|
|
2008
|
+
const [isModalOpen, setIsModalOpen] = (0, import_react9.useState)(false);
|
|
2009
|
+
const [isHovered, setIsHovered] = (0, import_react9.useState)(false);
|
|
2010
|
+
const [isDragging, setIsDragging] = (0, import_react9.useState)(false);
|
|
2011
|
+
const [buttonPosition, setButtonPosition] = (0, import_react9.useState)(null);
|
|
2012
|
+
const [mounted, setMounted] = (0, import_react9.useState)(false);
|
|
2013
|
+
const [isHidden, setIsHidden] = (0, import_react9.useState)(false);
|
|
2014
|
+
const dragRef = (0, import_react9.useRef)(null);
|
|
2015
|
+
const buttonRef = (0, import_react9.useRef)(null);
|
|
2016
|
+
(0, import_react9.useEffect)(() => {
|
|
2158
2017
|
setMounted(true);
|
|
2159
2018
|
try {
|
|
2160
2019
|
const hidden = typeof window !== "undefined" ? localStorage.getItem(INSPECTOR_HIDE_KEY) : null;
|
|
@@ -2185,7 +2044,7 @@ function ConsoleTrigger({ position = "bottom-right" }) {
|
|
|
2185
2044
|
};
|
|
2186
2045
|
setIsDragging(true);
|
|
2187
2046
|
};
|
|
2188
|
-
(0,
|
|
2047
|
+
(0, import_react9.useEffect)(() => {
|
|
2189
2048
|
if (!isDragging)
|
|
2190
2049
|
return;
|
|
2191
2050
|
const handleMouseMove = (e) => {
|
|
@@ -2356,66 +2215,343 @@ function ConsoleTrigger({ position = "bottom-right" }) {
|
|
|
2356
2215
|
] });
|
|
2357
2216
|
}
|
|
2358
2217
|
|
|
2359
|
-
// src/
|
|
2218
|
+
// src/context/coagent-state-renders-context.tsx
|
|
2219
|
+
var import_react10 = require("react");
|
|
2360
2220
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
2221
|
+
var CoAgentStateRendersContext = (0, import_react10.createContext)(
|
|
2222
|
+
void 0
|
|
2223
|
+
);
|
|
2224
|
+
function CoAgentStateRendersProvider({ children }) {
|
|
2225
|
+
const [coAgentStateRenders, setCoAgentStateRenders] = (0, import_react10.useState)({});
|
|
2226
|
+
const setCoAgentStateRender = (0, import_react10.useCallback)((id, stateRender) => {
|
|
2227
|
+
setCoAgentStateRenders((prevPoints) => __spreadProps(__spreadValues({}, prevPoints), {
|
|
2228
|
+
[id]: stateRender
|
|
2229
|
+
}));
|
|
2230
|
+
}, []);
|
|
2231
|
+
const removeCoAgentStateRender = (0, import_react10.useCallback)((id) => {
|
|
2232
|
+
setCoAgentStateRenders((prevPoints) => {
|
|
2233
|
+
const newPoints = __spreadValues({}, prevPoints);
|
|
2234
|
+
delete newPoints[id];
|
|
2235
|
+
return newPoints;
|
|
2236
|
+
});
|
|
2237
|
+
}, []);
|
|
2238
|
+
const claimsRef = (0, import_react10.useRef)({});
|
|
2239
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2240
|
+
CoAgentStateRendersContext.Provider,
|
|
2241
|
+
{
|
|
2242
|
+
value: {
|
|
2243
|
+
coAgentStateRenders,
|
|
2244
|
+
setCoAgentStateRender,
|
|
2245
|
+
removeCoAgentStateRender,
|
|
2246
|
+
claimsRef
|
|
2247
|
+
},
|
|
2248
|
+
children
|
|
2249
|
+
}
|
|
2250
|
+
);
|
|
2251
|
+
}
|
|
2252
|
+
function useCoAgentStateRenders() {
|
|
2253
|
+
const context = (0, import_react10.useContext)(CoAgentStateRendersContext);
|
|
2254
|
+
if (!context) {
|
|
2255
|
+
throw new Error("useCoAgentStateRenders must be used within CoAgentStateRendersProvider");
|
|
2256
|
+
}
|
|
2257
|
+
return context;
|
|
2258
|
+
}
|
|
2259
|
+
|
|
2260
|
+
// src/hooks/use-coagent-state-render-bridge.tsx
|
|
2261
|
+
var import_react12 = require("@copilotkitnext/react");
|
|
2262
|
+
var import_react13 = require("react");
|
|
2263
|
+
|
|
2264
|
+
// src/context/threads-context.tsx
|
|
2265
|
+
var import_react11 = require("react");
|
|
2266
|
+
var import_shared9 = require("@copilotkit/shared");
|
|
2267
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
2268
|
+
var ThreadsContext = (0, import_react11.createContext)(void 0);
|
|
2269
|
+
function ThreadsProvider({ children, threadId: explicitThreadId }) {
|
|
2270
|
+
const [internalThreadId, setThreadId] = (0, import_react11.useState)(explicitThreadId != null ? explicitThreadId : (0, import_shared9.randomUUID)());
|
|
2271
|
+
const threadId = internalThreadId;
|
|
2272
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2273
|
+
ThreadsContext.Provider,
|
|
2274
|
+
{
|
|
2275
|
+
value: {
|
|
2276
|
+
threadId,
|
|
2277
|
+
setThreadId
|
|
2278
|
+
},
|
|
2279
|
+
children
|
|
2280
|
+
}
|
|
2281
|
+
);
|
|
2282
|
+
}
|
|
2283
|
+
function useThreads() {
|
|
2284
|
+
const context = (0, import_react11.useContext)(ThreadsContext);
|
|
2285
|
+
if (!context) {
|
|
2286
|
+
throw new Error("useThreads must be used within ThreadsProvider");
|
|
2287
|
+
}
|
|
2288
|
+
return context;
|
|
2289
|
+
}
|
|
2290
|
+
|
|
2291
|
+
// src/hooks/use-coagent-state-render-bridge.tsx
|
|
2292
|
+
var import_shared10 = require("@copilotkit/shared");
|
|
2293
|
+
function getStateWithoutConstantKeys(state) {
|
|
2294
|
+
const _a = state, { messages, tools, copilotkit } = _a, stateWithoutConstantKeys = __objRest(_a, ["messages", "tools", "copilotkit"]);
|
|
2295
|
+
return stateWithoutConstantKeys;
|
|
2296
|
+
}
|
|
2297
|
+
function areStatesEquals(a, b) {
|
|
2298
|
+
if (a && !b || !a && b)
|
|
2299
|
+
return false;
|
|
2300
|
+
const _a = a, { messages, tools, copilotkit } = _a, aWithoutConstantKeys = __objRest(_a, ["messages", "tools", "copilotkit"]);
|
|
2301
|
+
const _b = b, {
|
|
2302
|
+
messages: bMessages,
|
|
2303
|
+
tools: bTools,
|
|
2304
|
+
copilotkit: bCopilotkit
|
|
2305
|
+
} = _b, bWithoutConstantKeys = __objRest(_b, [
|
|
2306
|
+
"messages",
|
|
2307
|
+
"tools",
|
|
2308
|
+
"copilotkit"
|
|
2309
|
+
]);
|
|
2310
|
+
return JSON.stringify(aWithoutConstantKeys) === JSON.stringify(bWithoutConstantKeys);
|
|
2311
|
+
}
|
|
2312
|
+
function useCoagentStateRenderBridge(agentId, props) {
|
|
2313
|
+
var _a;
|
|
2314
|
+
const { stateSnapshot, messageIndexInRun, message } = props;
|
|
2315
|
+
const { coAgentStateRenders, claimsRef } = useCoAgentStateRenders();
|
|
2316
|
+
const { agent } = (0, import_react12.useAgent)({ agentId });
|
|
2317
|
+
const [nodeName, setNodeName] = (0, import_react13.useState)(void 0);
|
|
2318
|
+
const runId = (_a = props.runId) != null ? _a : message.runId;
|
|
2319
|
+
const effectiveRunId = runId || "pending";
|
|
2320
|
+
(0, import_react13.useEffect)(() => {
|
|
2321
|
+
if (!agent)
|
|
2322
|
+
return;
|
|
2323
|
+
const subscriber = {
|
|
2324
|
+
onStepStartedEvent: ({ event }) => {
|
|
2325
|
+
if (event.stepName !== nodeName) {
|
|
2326
|
+
setNodeName(event.stepName);
|
|
2327
|
+
}
|
|
2328
|
+
},
|
|
2329
|
+
onStepFinishedEvent: ({ event }) => {
|
|
2330
|
+
if (event.stepName === nodeName) {
|
|
2331
|
+
setNodeName(void 0);
|
|
2332
|
+
}
|
|
2333
|
+
}
|
|
2334
|
+
};
|
|
2335
|
+
const { unsubscribe } = agent.subscribe(subscriber);
|
|
2336
|
+
return () => {
|
|
2337
|
+
unsubscribe();
|
|
2338
|
+
};
|
|
2339
|
+
}, [agentId, nodeName]);
|
|
2340
|
+
if (messageIndexInRun !== 0) {
|
|
2341
|
+
return null;
|
|
2342
|
+
}
|
|
2343
|
+
const getStateRender = (0, import_react13.useCallback)(
|
|
2344
|
+
(messageId) => {
|
|
2345
|
+
return Object.entries(coAgentStateRenders).find(([stateRenderId, stateRender]) => {
|
|
2346
|
+
if (claimsRef.current[messageId]) {
|
|
2347
|
+
return stateRenderId === claimsRef.current[messageId].stateRenderId;
|
|
2348
|
+
}
|
|
2349
|
+
const matchingAgentName = stateRender.name === agentId;
|
|
2350
|
+
const matchesNodeContext = stateRender.nodeName ? stateRender.nodeName === nodeName : true;
|
|
2351
|
+
return matchingAgentName && matchesNodeContext;
|
|
2352
|
+
});
|
|
2353
|
+
},
|
|
2354
|
+
[coAgentStateRenders, nodeName, agentId]
|
|
2355
|
+
);
|
|
2356
|
+
const handleRenderRequest = ({
|
|
2357
|
+
stateRenderId,
|
|
2358
|
+
messageId,
|
|
2359
|
+
runId: runId2,
|
|
2360
|
+
stateSnapshot: renderSnapshot
|
|
2361
|
+
}) => {
|
|
2362
|
+
if (claimsRef.current[messageId]) {
|
|
2363
|
+
const canRender = claimsRef.current[messageId].stateRenderId === stateRenderId;
|
|
2364
|
+
if (canRender && runId2 && (!claimsRef.current[messageId].runId || claimsRef.current[messageId].runId === "pending")) {
|
|
2365
|
+
claimsRef.current[messageId].runId = runId2;
|
|
2366
|
+
}
|
|
2367
|
+
return canRender;
|
|
2368
|
+
}
|
|
2369
|
+
const renderClaimedByOtherMessage = Object.values(claimsRef.current).find(
|
|
2370
|
+
(c) => c.stateRenderId === stateRenderId && (0, import_shared10.dataToUUID)(JSON.stringify(getStateWithoutConstantKeys(c.stateSnapshot))) === (0, import_shared10.dataToUUID)(JSON.stringify(getStateWithoutConstantKeys(renderSnapshot)))
|
|
2371
|
+
);
|
|
2372
|
+
if (renderClaimedByOtherMessage) {
|
|
2373
|
+
if (renderSnapshot && renderClaimedByOtherMessage.stateSnapshot && !areStatesEquals(renderClaimedByOtherMessage.stateSnapshot, renderSnapshot)) {
|
|
2374
|
+
claimsRef.current[messageId] = { stateRenderId, runId: runId2 };
|
|
2375
|
+
return true;
|
|
2376
|
+
}
|
|
2377
|
+
return false;
|
|
2378
|
+
}
|
|
2379
|
+
if (!runId2) {
|
|
2380
|
+
return false;
|
|
2381
|
+
}
|
|
2382
|
+
claimsRef.current[messageId] = { stateRenderId, runId: runId2 };
|
|
2383
|
+
return true;
|
|
2384
|
+
};
|
|
2385
|
+
return (0, import_react13.useMemo)(() => {
|
|
2386
|
+
var _a2, _b, _c;
|
|
2387
|
+
const [stateRenderId, stateRender] = (_a2 = getStateRender(message.id)) != null ? _a2 : [];
|
|
2388
|
+
if (!stateRender || !stateRenderId) {
|
|
2389
|
+
return null;
|
|
2390
|
+
}
|
|
2391
|
+
const snapshot = stateSnapshot ? (0, import_shared10.parseJson)(stateSnapshot, stateSnapshot) : agent == null ? void 0 : agent.state;
|
|
2392
|
+
const canRender = handleRenderRequest({
|
|
2393
|
+
stateRenderId,
|
|
2394
|
+
messageId: message.id,
|
|
2395
|
+
runId: effectiveRunId,
|
|
2396
|
+
stateSnapshot: snapshot
|
|
2397
|
+
});
|
|
2398
|
+
if (!canRender) {
|
|
2399
|
+
return null;
|
|
2400
|
+
}
|
|
2401
|
+
if (snapshot && !claimsRef.current[message.id].locked) {
|
|
2402
|
+
if (stateSnapshot) {
|
|
2403
|
+
claimsRef.current[message.id].stateSnapshot = snapshot;
|
|
2404
|
+
claimsRef.current[message.id].locked = true;
|
|
2405
|
+
} else {
|
|
2406
|
+
claimsRef.current[message.id].stateSnapshot = snapshot;
|
|
2407
|
+
}
|
|
2408
|
+
}
|
|
2409
|
+
if (stateRender.handler) {
|
|
2410
|
+
stateRender.handler({
|
|
2411
|
+
state: stateSnapshot ? (0, import_shared10.parseJson)(stateSnapshot, stateSnapshot) : (_b = agent == null ? void 0 : agent.state) != null ? _b : {},
|
|
2412
|
+
nodeName: nodeName != null ? nodeName : ""
|
|
2413
|
+
});
|
|
2414
|
+
}
|
|
2415
|
+
if (stateRender.render) {
|
|
2416
|
+
const status = (agent == null ? void 0 : agent.isRunning) ? "inProgress" : "complete";
|
|
2417
|
+
if (typeof stateRender.render === "string")
|
|
2418
|
+
return stateRender.render;
|
|
2419
|
+
return stateRender.render({
|
|
2420
|
+
status,
|
|
2421
|
+
// Always use state from claim, to make sure the state does not seem "wiped" for a fraction of a second
|
|
2422
|
+
state: (_c = claimsRef.current[message.id].stateSnapshot) != null ? _c : {},
|
|
2423
|
+
nodeName: nodeName != null ? nodeName : ""
|
|
2424
|
+
});
|
|
2425
|
+
}
|
|
2426
|
+
}, [
|
|
2427
|
+
getStateRender,
|
|
2428
|
+
stateSnapshot,
|
|
2429
|
+
agent == null ? void 0 : agent.state,
|
|
2430
|
+
agent == null ? void 0 : agent.isRunning,
|
|
2431
|
+
nodeName,
|
|
2432
|
+
effectiveRunId,
|
|
2433
|
+
message.id
|
|
2434
|
+
]);
|
|
2435
|
+
}
|
|
2436
|
+
function CoAgentStateRenderBridge(props) {
|
|
2437
|
+
return useCoagentStateRenderBridge(props.agentId, props);
|
|
2438
|
+
}
|
|
2439
|
+
|
|
2440
|
+
// src/components/CopilotListeners.tsx
|
|
2441
|
+
var import_react14 = require("react");
|
|
2442
|
+
var import_react15 = require("@copilotkitnext/react");
|
|
2443
|
+
var import_shared11 = require("@copilotkit/shared");
|
|
2444
|
+
var import_shared12 = require("@copilotkit/shared");
|
|
2445
|
+
var usePredictStateSubscription = (agent) => {
|
|
2446
|
+
const predictStateToolsRef = (0, import_react14.useRef)([]);
|
|
2447
|
+
const getSubscriber = (0, import_react14.useCallback)(
|
|
2448
|
+
(agent2) => ({
|
|
2449
|
+
onCustomEvent: ({ event }) => {
|
|
2450
|
+
if (event.name === "PredictState") {
|
|
2451
|
+
predictStateToolsRef.current = event.value;
|
|
2452
|
+
}
|
|
2453
|
+
},
|
|
2454
|
+
onToolCallArgsEvent: ({ partialToolCallArgs, toolCallName }) => {
|
|
2455
|
+
predictStateToolsRef.current.forEach((t) => {
|
|
2456
|
+
if ((t == null ? void 0 : t.tool) !== toolCallName)
|
|
2457
|
+
return;
|
|
2458
|
+
const emittedState = typeof partialToolCallArgs === "string" ? (0, import_shared11.parseJson)(partialToolCallArgs, partialToolCallArgs) : partialToolCallArgs;
|
|
2459
|
+
agent2.setState({
|
|
2460
|
+
[t.state_key]: emittedState[t.state_key]
|
|
2461
|
+
});
|
|
2462
|
+
});
|
|
2463
|
+
}
|
|
2464
|
+
}),
|
|
2465
|
+
[]
|
|
2466
|
+
);
|
|
2467
|
+
(0, import_react14.useEffect)(() => {
|
|
2468
|
+
if (!agent)
|
|
2469
|
+
return;
|
|
2470
|
+
const subscriber = getSubscriber(agent);
|
|
2471
|
+
const { unsubscribe } = agent.subscribe(subscriber);
|
|
2472
|
+
return () => {
|
|
2473
|
+
unsubscribe();
|
|
2474
|
+
};
|
|
2475
|
+
}, [agent, getSubscriber]);
|
|
2476
|
+
};
|
|
2477
|
+
function CopilotListeners() {
|
|
2478
|
+
var _a, _b;
|
|
2479
|
+
const { copilotkit } = (0, import_react15.useCopilotKit)();
|
|
2480
|
+
const { agentSession } = useCopilotContext();
|
|
2481
|
+
const existingConfig = (0, import_react15.useCopilotChatConfiguration)();
|
|
2482
|
+
const resolvedAgentId = (_b = (_a = agentSession == null ? void 0 : agentSession.agentName) != null ? _a : existingConfig == null ? void 0 : existingConfig.agentId) != null ? _b : "default";
|
|
2483
|
+
const { setBannerError } = useToast();
|
|
2484
|
+
const { agent } = (0, import_react15.useAgent)({ agentId: resolvedAgentId });
|
|
2485
|
+
usePredictStateSubscription(agent);
|
|
2486
|
+
(0, import_react14.useEffect)(() => {
|
|
2487
|
+
const subscriber = {
|
|
2488
|
+
onError: ({ error }) => {
|
|
2489
|
+
setBannerError(new import_shared12.CopilotKitLowLevelError({ error, message: error.message }));
|
|
2490
|
+
}
|
|
2491
|
+
};
|
|
2492
|
+
const subscription = copilotkit.subscribe(subscriber);
|
|
2493
|
+
return () => {
|
|
2494
|
+
subscription.unsubscribe();
|
|
2495
|
+
};
|
|
2496
|
+
}, [copilotkit == null ? void 0 : copilotkit.subscribe]);
|
|
2497
|
+
return null;
|
|
2498
|
+
}
|
|
2499
|
+
|
|
2500
|
+
// src/components/copilot-provider/copilotkit.tsx
|
|
2501
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
2361
2502
|
function CopilotKit(_a) {
|
|
2362
2503
|
var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
|
|
2363
2504
|
const enabled = shouldShowDevConsole(props.showDevConsole);
|
|
2364
2505
|
const publicApiKey = props.publicApiKey || props.publicLicenseKey;
|
|
2365
|
-
|
|
2506
|
+
const renderArr = (0, import_react16.useMemo)(() => [{ render: CoAgentStateRenderBridge }], []);
|
|
2507
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ToastProvider, { enabled, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(CopilotErrorBoundary, { publicApiKey, showUsageBanner: enabled, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ThreadsProvider, { threadId: props.threadId, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
2508
|
+
import_react17.CopilotKitProvider,
|
|
2509
|
+
{
|
|
2510
|
+
runtimeUrl: props.runtimeUrl,
|
|
2511
|
+
renderCustomMessages: renderArr,
|
|
2512
|
+
useSingleEndpoint: true,
|
|
2513
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(CopilotKitInternal, __spreadProps(__spreadValues({}, props), { children }))
|
|
2514
|
+
}
|
|
2515
|
+
) }) }) });
|
|
2366
2516
|
}
|
|
2367
2517
|
function CopilotKitInternal(cpkProps) {
|
|
2368
2518
|
var _b;
|
|
2369
2519
|
const _a = cpkProps, { children } = _a, props = __objRest(_a, ["children"]);
|
|
2370
2520
|
validateProps(cpkProps);
|
|
2371
2521
|
const publicApiKey = props.publicLicenseKey || props.publicApiKey;
|
|
2372
|
-
const chatApiEndpoint = props.runtimeUrl ||
|
|
2373
|
-
const [actions, setActions] = (0,
|
|
2374
|
-
const [
|
|
2375
|
-
const chatComponentsCache = (0,
|
|
2522
|
+
const chatApiEndpoint = props.runtimeUrl || import_shared13.COPILOT_CLOUD_CHAT_URL;
|
|
2523
|
+
const [actions, setActions] = (0, import_react16.useState)({});
|
|
2524
|
+
const [registeredActionConfigs, setRegisteredActionConfigs] = (0, import_react16.useState)(/* @__PURE__ */ new Map());
|
|
2525
|
+
const chatComponentsCache = (0, import_react16.useRef)({
|
|
2376
2526
|
actions: {},
|
|
2377
2527
|
coAgentStateRenders: {}
|
|
2378
2528
|
});
|
|
2379
2529
|
const { addElement, removeElement, printTree, getAllElements } = use_tree_default();
|
|
2380
|
-
const [isLoading, setIsLoading] = (0,
|
|
2381
|
-
const [chatInstructions, setChatInstructions] = (0,
|
|
2382
|
-
const [authStates, setAuthStates] = (0,
|
|
2383
|
-
const [extensions, setExtensions] = (0,
|
|
2384
|
-
const [additionalInstructions, setAdditionalInstructions] = (0,
|
|
2530
|
+
const [isLoading, setIsLoading] = (0, import_react16.useState)(false);
|
|
2531
|
+
const [chatInstructions, setChatInstructions] = (0, import_react16.useState)("");
|
|
2532
|
+
const [authStates, setAuthStates] = (0, import_react16.useState)({});
|
|
2533
|
+
const [extensions, setExtensions] = (0, import_react16.useState)({});
|
|
2534
|
+
const [additionalInstructions, setAdditionalInstructions] = (0, import_react16.useState)([]);
|
|
2385
2535
|
const {
|
|
2386
2536
|
addElement: addDocument,
|
|
2387
2537
|
removeElement: removeDocument,
|
|
2388
2538
|
allElements: allDocuments
|
|
2389
2539
|
} = use_flat_category_store_default();
|
|
2390
|
-
const setAction = (0,
|
|
2540
|
+
const setAction = (0, import_react16.useCallback)((id, action) => {
|
|
2391
2541
|
setActions((prevPoints) => {
|
|
2392
2542
|
return __spreadProps(__spreadValues({}, prevPoints), {
|
|
2393
2543
|
[id]: action
|
|
2394
2544
|
});
|
|
2395
2545
|
});
|
|
2396
2546
|
}, []);
|
|
2397
|
-
const removeAction = (0,
|
|
2547
|
+
const removeAction = (0, import_react16.useCallback)((id) => {
|
|
2398
2548
|
setActions((prevPoints) => {
|
|
2399
2549
|
const newPoints = __spreadValues({}, prevPoints);
|
|
2400
2550
|
delete newPoints[id];
|
|
2401
2551
|
return newPoints;
|
|
2402
2552
|
});
|
|
2403
2553
|
}, []);
|
|
2404
|
-
const
|
|
2405
|
-
setCoAgentStateRenders((prevPoints) => {
|
|
2406
|
-
return __spreadProps(__spreadValues({}, prevPoints), {
|
|
2407
|
-
[id]: stateRender
|
|
2408
|
-
});
|
|
2409
|
-
});
|
|
2410
|
-
}, []);
|
|
2411
|
-
const removeCoAgentStateRender = (0, import_react11.useCallback)((id) => {
|
|
2412
|
-
setCoAgentStateRenders((prevPoints) => {
|
|
2413
|
-
const newPoints = __spreadValues({}, prevPoints);
|
|
2414
|
-
delete newPoints[id];
|
|
2415
|
-
return newPoints;
|
|
2416
|
-
});
|
|
2417
|
-
}, []);
|
|
2418
|
-
const getContextString = (0, import_react11.useCallback)(
|
|
2554
|
+
const getContextString = (0, import_react16.useCallback)(
|
|
2419
2555
|
(documents, categories) => {
|
|
2420
2556
|
const documentsString = documents.map((document2) => {
|
|
2421
2557
|
return `${document2.name} (${document2.sourceApplication}):
|
|
@@ -2428,46 +2564,46 @@ ${nonDocumentStrings}`;
|
|
|
2428
2564
|
},
|
|
2429
2565
|
[printTree]
|
|
2430
2566
|
);
|
|
2431
|
-
const addContext = (0,
|
|
2567
|
+
const addContext = (0, import_react16.useCallback)(
|
|
2432
2568
|
(context, parentId, categories = defaultCopilotContextCategories) => {
|
|
2433
2569
|
return addElement(context, categories, parentId);
|
|
2434
2570
|
},
|
|
2435
2571
|
[addElement]
|
|
2436
2572
|
);
|
|
2437
|
-
const removeContext = (0,
|
|
2573
|
+
const removeContext = (0, import_react16.useCallback)(
|
|
2438
2574
|
(id) => {
|
|
2439
2575
|
removeElement(id);
|
|
2440
2576
|
},
|
|
2441
2577
|
[removeElement]
|
|
2442
2578
|
);
|
|
2443
|
-
const getAllContext = (0,
|
|
2579
|
+
const getAllContext = (0, import_react16.useCallback)(() => {
|
|
2444
2580
|
return getAllElements();
|
|
2445
2581
|
}, [getAllElements]);
|
|
2446
|
-
const getFunctionCallHandler = (0,
|
|
2582
|
+
const getFunctionCallHandler = (0, import_react16.useCallback)(
|
|
2447
2583
|
(customEntryPoints) => {
|
|
2448
2584
|
return entryPointsToFunctionCallHandler(Object.values(customEntryPoints || actions));
|
|
2449
2585
|
},
|
|
2450
2586
|
[actions]
|
|
2451
2587
|
);
|
|
2452
|
-
const getDocumentsContext = (0,
|
|
2588
|
+
const getDocumentsContext = (0, import_react16.useCallback)(
|
|
2453
2589
|
(categories) => {
|
|
2454
2590
|
return allDocuments(categories);
|
|
2455
2591
|
},
|
|
2456
2592
|
[allDocuments]
|
|
2457
2593
|
);
|
|
2458
|
-
const addDocumentContext = (0,
|
|
2594
|
+
const addDocumentContext = (0, import_react16.useCallback)(
|
|
2459
2595
|
(documentPointer, categories = defaultCopilotContextCategories) => {
|
|
2460
2596
|
return addDocument(documentPointer, categories);
|
|
2461
2597
|
},
|
|
2462
2598
|
[addDocument]
|
|
2463
2599
|
);
|
|
2464
|
-
const removeDocumentContext = (0,
|
|
2600
|
+
const removeDocumentContext = (0, import_react16.useCallback)(
|
|
2465
2601
|
(documentId) => {
|
|
2466
2602
|
removeDocument(documentId);
|
|
2467
2603
|
},
|
|
2468
2604
|
[removeDocument]
|
|
2469
2605
|
);
|
|
2470
|
-
const copilotApiConfig = (0,
|
|
2606
|
+
const copilotApiConfig = (0, import_react16.useMemo)(() => {
|
|
2471
2607
|
var _a2, _b2;
|
|
2472
2608
|
let cloud = void 0;
|
|
2473
2609
|
if (publicApiKey) {
|
|
@@ -2503,7 +2639,7 @@ ${nonDocumentStrings}`;
|
|
|
2503
2639
|
props.cloudRestrictToTopic,
|
|
2504
2640
|
props.guardrails_c
|
|
2505
2641
|
]);
|
|
2506
|
-
const headers = (0,
|
|
2642
|
+
const headers = (0, import_react16.useMemo)(() => {
|
|
2507
2643
|
const authHeaders = Object.values(authStates || {}).reduce((acc, state) => {
|
|
2508
2644
|
if (state.status === "authenticated" && state.authHeaders) {
|
|
2509
2645
|
return __spreadValues(__spreadValues({}, acc), Object.entries(state.authHeaders).reduce(
|
|
@@ -2515,27 +2651,27 @@ ${nonDocumentStrings}`;
|
|
|
2515
2651
|
}
|
|
2516
2652
|
return acc;
|
|
2517
2653
|
}, {});
|
|
2518
|
-
return __spreadValues(__spreadValues(__spreadValues({}, copilotApiConfig.headers || {}), copilotApiConfig.publicApiKey ? { [
|
|
2654
|
+
return __spreadValues(__spreadValues(__spreadValues({}, copilotApiConfig.headers || {}), copilotApiConfig.publicApiKey ? { [import_shared13.COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: copilotApiConfig.publicApiKey } : {}), authHeaders);
|
|
2519
2655
|
}, [copilotApiConfig.headers, copilotApiConfig.publicApiKey, authStates]);
|
|
2520
|
-
const [internalErrorHandlers, _setInternalErrorHandler] = (0,
|
|
2521
|
-
const setInternalErrorHandler = (0,
|
|
2656
|
+
const [internalErrorHandlers, _setInternalErrorHandler] = (0, import_react16.useState)({});
|
|
2657
|
+
const setInternalErrorHandler = (0, import_react16.useCallback)((handler) => {
|
|
2522
2658
|
_setInternalErrorHandler((prev) => __spreadValues(__spreadValues({}, prev), handler));
|
|
2523
2659
|
}, []);
|
|
2524
|
-
const removeInternalErrorHandler = (0,
|
|
2660
|
+
const removeInternalErrorHandler = (0, import_react16.useCallback)((key) => {
|
|
2525
2661
|
_setInternalErrorHandler((prev) => {
|
|
2526
2662
|
const _a2 = prev, { [key]: _removed } = _a2, rest = __objRest(_a2, [__restKey(key)]);
|
|
2527
2663
|
return rest;
|
|
2528
2664
|
});
|
|
2529
2665
|
}, []);
|
|
2530
|
-
const onErrorRef = (0,
|
|
2531
|
-
(0,
|
|
2666
|
+
const onErrorRef = (0, import_react16.useRef)(props.onError);
|
|
2667
|
+
(0, import_react16.useEffect)(() => {
|
|
2532
2668
|
onErrorRef.current = props.onError;
|
|
2533
2669
|
}, [props.onError]);
|
|
2534
|
-
const internalHandlersRef = (0,
|
|
2535
|
-
(0,
|
|
2670
|
+
const internalHandlersRef = (0, import_react16.useRef)({});
|
|
2671
|
+
(0, import_react16.useEffect)(() => {
|
|
2536
2672
|
internalHandlersRef.current = internalErrorHandlers;
|
|
2537
2673
|
}, [internalErrorHandlers]);
|
|
2538
|
-
const handleErrors = (0,
|
|
2674
|
+
const handleErrors = (0, import_react16.useCallback)(
|
|
2539
2675
|
(error) => __async(this, null, function* () {
|
|
2540
2676
|
if (copilotApiConfig.publicApiKey && onErrorRef.current) {
|
|
2541
2677
|
try {
|
|
@@ -2555,22 +2691,14 @@ ${nonDocumentStrings}`;
|
|
|
2555
2691
|
}),
|
|
2556
2692
|
[copilotApiConfig.publicApiKey]
|
|
2557
2693
|
);
|
|
2558
|
-
const
|
|
2559
|
-
|
|
2560
|
-
publicApiKey,
|
|
2561
|
-
headers,
|
|
2562
|
-
credentials: copilotApiConfig.credentials,
|
|
2563
|
-
showDevConsole: shouldShowDevConsole(props.showDevConsole),
|
|
2564
|
-
onError: handleErrors
|
|
2565
|
-
});
|
|
2566
|
-
const [chatSuggestionConfiguration, setChatSuggestionConfiguration] = (0, import_react11.useState)({});
|
|
2567
|
-
const addChatSuggestionConfiguration = (0, import_react11.useCallback)(
|
|
2694
|
+
const [chatSuggestionConfiguration, setChatSuggestionConfiguration] = (0, import_react16.useState)({});
|
|
2695
|
+
const addChatSuggestionConfiguration = (0, import_react16.useCallback)(
|
|
2568
2696
|
(id, suggestion) => {
|
|
2569
2697
|
setChatSuggestionConfiguration((prev) => __spreadProps(__spreadValues({}, prev), { [id]: suggestion }));
|
|
2570
2698
|
},
|
|
2571
2699
|
[setChatSuggestionConfiguration]
|
|
2572
2700
|
);
|
|
2573
|
-
const removeChatSuggestionConfiguration = (0,
|
|
2701
|
+
const removeChatSuggestionConfiguration = (0, import_react16.useCallback)(
|
|
2574
2702
|
(id) => {
|
|
2575
2703
|
setChatSuggestionConfiguration((prev) => {
|
|
2576
2704
|
const _a2 = prev, { [id]: _ } = _a2, rest = __objRest(_a2, [__restKey(id)]);
|
|
@@ -2579,10 +2707,10 @@ ${nonDocumentStrings}`;
|
|
|
2579
2707
|
},
|
|
2580
2708
|
[setChatSuggestionConfiguration]
|
|
2581
2709
|
);
|
|
2582
|
-
const [availableAgents, setAvailableAgents] = (0,
|
|
2583
|
-
const [coagentStates, setCoagentStates] = (0,
|
|
2584
|
-
const coagentStatesRef = (0,
|
|
2585
|
-
const setCoagentStatesWithRef = (0,
|
|
2710
|
+
const [availableAgents, setAvailableAgents] = (0, import_react16.useState)([]);
|
|
2711
|
+
const [coagentStates, setCoagentStates] = (0, import_react16.useState)({});
|
|
2712
|
+
const coagentStatesRef = (0, import_react16.useRef)({});
|
|
2713
|
+
const setCoagentStatesWithRef = (0, import_react16.useCallback)(
|
|
2586
2714
|
(value) => {
|
|
2587
2715
|
const newValue = typeof value === "function" ? value(coagentStatesRef.current) : value;
|
|
2588
2716
|
coagentStatesRef.current = newValue;
|
|
@@ -2592,28 +2720,14 @@ ${nonDocumentStrings}`;
|
|
|
2592
2720
|
},
|
|
2593
2721
|
[]
|
|
2594
2722
|
);
|
|
2595
|
-
const hasLoadedAgents = (0, import_react11.useRef)(false);
|
|
2596
|
-
(0, import_react11.useEffect)(() => {
|
|
2597
|
-
if (hasLoadedAgents.current)
|
|
2598
|
-
return;
|
|
2599
|
-
const fetchData = () => __async(this, null, function* () {
|
|
2600
|
-
var _a2;
|
|
2601
|
-
const result = yield runtimeClient.availableAgents();
|
|
2602
|
-
if ((_a2 = result.data) == null ? void 0 : _a2.availableAgents) {
|
|
2603
|
-
setAvailableAgents(result.data.availableAgents.agents);
|
|
2604
|
-
}
|
|
2605
|
-
hasLoadedAgents.current = true;
|
|
2606
|
-
});
|
|
2607
|
-
void fetchData();
|
|
2608
|
-
}, []);
|
|
2609
2723
|
let initialAgentSession = null;
|
|
2610
2724
|
if (props.agent) {
|
|
2611
2725
|
initialAgentSession = {
|
|
2612
2726
|
agentName: props.agent
|
|
2613
2727
|
};
|
|
2614
2728
|
}
|
|
2615
|
-
const [agentSession, setAgentSession] = (0,
|
|
2616
|
-
(0,
|
|
2729
|
+
const [agentSession, setAgentSession] = (0, import_react16.useState)(initialAgentSession);
|
|
2730
|
+
(0, import_react16.useEffect)(() => {
|
|
2617
2731
|
if (props.agent) {
|
|
2618
2732
|
setAgentSession({
|
|
2619
2733
|
agentName: props.agent
|
|
@@ -2622,8 +2736,8 @@ ${nonDocumentStrings}`;
|
|
|
2622
2736
|
setAgentSession(null);
|
|
2623
2737
|
}
|
|
2624
2738
|
}, [props.agent]);
|
|
2625
|
-
const
|
|
2626
|
-
const setThreadId = (0,
|
|
2739
|
+
const { threadId, setThreadId: setInternalThreadId } = useThreads();
|
|
2740
|
+
const setThreadId = (0, import_react16.useCallback)(
|
|
2627
2741
|
(value) => {
|
|
2628
2742
|
if (props.threadId) {
|
|
2629
2743
|
throw new Error("Cannot call setThreadId() when threadId is provided via props.");
|
|
@@ -2632,51 +2746,61 @@ ${nonDocumentStrings}`;
|
|
|
2632
2746
|
},
|
|
2633
2747
|
[props.threadId]
|
|
2634
2748
|
);
|
|
2635
|
-
(0,
|
|
2636
|
-
|
|
2637
|
-
setInternalThreadId(props.threadId);
|
|
2638
|
-
}
|
|
2639
|
-
}, [props.threadId]);
|
|
2640
|
-
const [runId, setRunId] = (0, import_react11.useState)(null);
|
|
2641
|
-
const chatAbortControllerRef = (0, import_react11.useRef)(null);
|
|
2749
|
+
const [runId, setRunId] = (0, import_react16.useState)(null);
|
|
2750
|
+
const chatAbortControllerRef = (0, import_react16.useRef)(null);
|
|
2642
2751
|
const showDevConsole = shouldShowDevConsole(props.showDevConsole);
|
|
2643
|
-
const [
|
|
2644
|
-
const
|
|
2645
|
-
(
|
|
2646
|
-
|
|
2647
|
-
var _a2
|
|
2648
|
-
if (action == null)
|
|
2649
|
-
return
|
|
2650
|
-
[threadId]: null
|
|
2651
|
-
});
|
|
2652
|
-
let event = (_a2 = prev[threadId]) == null ? void 0 : _a2.event;
|
|
2653
|
-
if (action.event) {
|
|
2654
|
-
event = __spreadValues(__spreadValues({}, ((_b2 = prev[threadId]) == null ? void 0 : _b2.event) || {}), action.event);
|
|
2752
|
+
const [interruptActions, _setInterruptActions] = (0, import_react16.useState)({});
|
|
2753
|
+
const setInterruptAction = (0, import_react16.useCallback)(
|
|
2754
|
+
(threadId2, action) => {
|
|
2755
|
+
_setInterruptActions((prev) => {
|
|
2756
|
+
var _a2;
|
|
2757
|
+
if (action == null || !action.id) {
|
|
2758
|
+
return prev;
|
|
2655
2759
|
}
|
|
2656
2760
|
return __spreadProps(__spreadValues({}, prev), {
|
|
2657
|
-
[
|
|
2761
|
+
[action.id]: __spreadValues(__spreadValues({}, (_a2 = prev[action.id]) != null ? _a2 : {}), action)
|
|
2658
2762
|
});
|
|
2659
2763
|
});
|
|
2660
2764
|
},
|
|
2661
2765
|
[]
|
|
2662
2766
|
);
|
|
2663
|
-
const
|
|
2664
|
-
|
|
2767
|
+
const removeInterruptAction = (0, import_react16.useCallback)((actionId) => {
|
|
2768
|
+
_setInterruptActions((prev) => {
|
|
2769
|
+
const _a2 = prev, { [actionId]: _ } = _a2, rest = __objRest(_a2, [__restKey(actionId)]);
|
|
2770
|
+
return rest;
|
|
2771
|
+
});
|
|
2665
2772
|
}, []);
|
|
2666
|
-
const
|
|
2667
|
-
const
|
|
2668
|
-
|
|
2773
|
+
const [interruptEventQueue, setInterruptEventQueue] = (0, import_react16.useState)({});
|
|
2774
|
+
const addInterruptEvent = (0, import_react16.useCallback)((queuedEvent) => {
|
|
2775
|
+
setInterruptEventQueue((prev) => {
|
|
2776
|
+
const threadQueue = prev[queuedEvent.threadId] || [];
|
|
2777
|
+
return __spreadProps(__spreadValues({}, prev), {
|
|
2778
|
+
[queuedEvent.threadId]: [...threadQueue, queuedEvent]
|
|
2779
|
+
});
|
|
2780
|
+
});
|
|
2781
|
+
}, []);
|
|
2782
|
+
const removeInterruptEvent = (0, import_react16.useCallback)((threadId2, eventId) => {
|
|
2783
|
+
setInterruptEventQueue((prev) => {
|
|
2784
|
+
const threadQueue = prev[threadId2] || [];
|
|
2785
|
+
return __spreadProps(__spreadValues({}, prev), {
|
|
2786
|
+
[threadId2]: threadQueue.filter((event) => event.eventId !== eventId)
|
|
2787
|
+
});
|
|
2788
|
+
});
|
|
2789
|
+
}, []);
|
|
2790
|
+
const memoizedChildren = (0, import_react16.useMemo)(() => children, [children]);
|
|
2791
|
+
const [bannerError, setBannerError] = (0, import_react16.useState)(null);
|
|
2792
|
+
const agentLock = (0, import_react16.useMemo)(() => {
|
|
2669
2793
|
var _a2;
|
|
2670
2794
|
return (_a2 = props.agent) != null ? _a2 : null;
|
|
2671
2795
|
}, [props.agent]);
|
|
2672
|
-
const forwardedParameters = (0,
|
|
2796
|
+
const forwardedParameters = (0, import_react16.useMemo)(
|
|
2673
2797
|
() => {
|
|
2674
2798
|
var _a2;
|
|
2675
2799
|
return (_a2 = props.forwardedParameters) != null ? _a2 : {};
|
|
2676
2800
|
},
|
|
2677
2801
|
[props.forwardedParameters]
|
|
2678
2802
|
);
|
|
2679
|
-
const updateExtensions = (0,
|
|
2803
|
+
const updateExtensions = (0, import_react16.useCallback)(
|
|
2680
2804
|
(newExtensions) => {
|
|
2681
2805
|
setExtensions((prev) => {
|
|
2682
2806
|
const resolved = typeof newExtensions === "function" ? newExtensions(prev) : newExtensions;
|
|
@@ -2688,7 +2812,7 @@ ${nonDocumentStrings}`;
|
|
|
2688
2812
|
},
|
|
2689
2813
|
[setExtensions]
|
|
2690
2814
|
);
|
|
2691
|
-
const updateAuthStates = (0,
|
|
2815
|
+
const updateAuthStates = (0, import_react16.useCallback)(
|
|
2692
2816
|
(newAuthStates) => {
|
|
2693
2817
|
setAuthStates((prev) => {
|
|
2694
2818
|
const resolved = typeof newAuthStates === "function" ? newAuthStates(prev) : newAuthStates;
|
|
@@ -2700,81 +2824,115 @@ ${nonDocumentStrings}`;
|
|
|
2700
2824
|
},
|
|
2701
2825
|
[setAuthStates]
|
|
2702
2826
|
);
|
|
2703
|
-
|
|
2704
|
-
|
|
2827
|
+
const handleSetRegisteredActions = (0, import_react16.useCallback)((actionConfig) => {
|
|
2828
|
+
const key = actionConfig.action.name || (0, import_shared13.randomUUID)();
|
|
2829
|
+
setRegisteredActionConfigs((prev) => {
|
|
2830
|
+
const newMap = new Map(prev);
|
|
2831
|
+
newMap.set(key, actionConfig);
|
|
2832
|
+
return newMap;
|
|
2833
|
+
});
|
|
2834
|
+
return key;
|
|
2835
|
+
}, []);
|
|
2836
|
+
const handleRemoveRegisteredAction = (0, import_react16.useCallback)((actionKey) => {
|
|
2837
|
+
setRegisteredActionConfigs((prev) => {
|
|
2838
|
+
const newMap = new Map(prev);
|
|
2839
|
+
newMap.delete(actionKey);
|
|
2840
|
+
return newMap;
|
|
2841
|
+
});
|
|
2842
|
+
}, []);
|
|
2843
|
+
const RegisteredActionsRenderer = (0, import_react16.useMemo)(() => {
|
|
2844
|
+
return () => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx_runtime10.Fragment, { children: Array.from(registeredActionConfigs.entries()).map(([key, config]) => {
|
|
2845
|
+
const Component = config.component;
|
|
2846
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Component, { action: config.action }, key);
|
|
2847
|
+
}) });
|
|
2848
|
+
}, [registeredActionConfigs]);
|
|
2849
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
2850
|
+
import_react17.CopilotChatConfigurationProvider,
|
|
2705
2851
|
{
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2852
|
+
agentId: (_b = agentSession == null ? void 0 : agentSession.agentName) != null ? _b : "default",
|
|
2853
|
+
threadId,
|
|
2854
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
2855
|
+
CopilotContext.Provider,
|
|
2856
|
+
{
|
|
2857
|
+
value: {
|
|
2858
|
+
actions,
|
|
2859
|
+
chatComponentsCache,
|
|
2860
|
+
getFunctionCallHandler,
|
|
2861
|
+
setAction,
|
|
2862
|
+
removeAction,
|
|
2863
|
+
setRegisteredActions: handleSetRegisteredActions,
|
|
2864
|
+
removeRegisteredAction: handleRemoveRegisteredAction,
|
|
2865
|
+
getContextString,
|
|
2866
|
+
addContext,
|
|
2867
|
+
removeContext,
|
|
2868
|
+
getAllContext,
|
|
2869
|
+
getDocumentsContext,
|
|
2870
|
+
addDocumentContext,
|
|
2871
|
+
removeDocumentContext,
|
|
2872
|
+
copilotApiConfig,
|
|
2873
|
+
isLoading,
|
|
2874
|
+
setIsLoading,
|
|
2875
|
+
chatSuggestionConfiguration,
|
|
2876
|
+
addChatSuggestionConfiguration,
|
|
2877
|
+
removeChatSuggestionConfiguration,
|
|
2878
|
+
chatInstructions,
|
|
2879
|
+
setChatInstructions,
|
|
2880
|
+
additionalInstructions,
|
|
2881
|
+
setAdditionalInstructions,
|
|
2882
|
+
showDevConsole,
|
|
2883
|
+
coagentStates,
|
|
2884
|
+
setCoagentStates,
|
|
2885
|
+
coagentStatesRef,
|
|
2886
|
+
setCoagentStatesWithRef,
|
|
2887
|
+
agentSession,
|
|
2888
|
+
setAgentSession,
|
|
2889
|
+
forwardedParameters,
|
|
2890
|
+
agentLock,
|
|
2891
|
+
threadId,
|
|
2892
|
+
setThreadId,
|
|
2893
|
+
runId,
|
|
2894
|
+
setRunId,
|
|
2895
|
+
chatAbortControllerRef,
|
|
2896
|
+
availableAgents,
|
|
2897
|
+
authConfig_c: props.authConfig_c,
|
|
2898
|
+
authStates_c: authStates,
|
|
2899
|
+
setAuthStates_c: updateAuthStates,
|
|
2900
|
+
extensions,
|
|
2901
|
+
setExtensions: updateExtensions,
|
|
2902
|
+
interruptActions,
|
|
2903
|
+
setInterruptAction,
|
|
2904
|
+
removeInterruptAction,
|
|
2905
|
+
interruptEventQueue,
|
|
2906
|
+
addInterruptEvent,
|
|
2907
|
+
removeInterruptEvent,
|
|
2908
|
+
bannerError,
|
|
2909
|
+
setBannerError,
|
|
2910
|
+
onError: handleErrors,
|
|
2911
|
+
internalErrorHandlers,
|
|
2912
|
+
setInternalErrorHandler,
|
|
2913
|
+
removeInternalErrorHandler
|
|
2914
|
+
},
|
|
2915
|
+
children: [
|
|
2916
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(CopilotListeners, {}),
|
|
2917
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(CoAgentStateRendersProvider, { children: [
|
|
2918
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(MessagesTapProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(CopilotMessages, { children: [
|
|
2919
|
+
memoizedChildren,
|
|
2920
|
+
showDevConsole && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ConsoleTrigger, {}),
|
|
2921
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(RegisteredActionsRenderer, {})
|
|
2922
|
+
] }) }),
|
|
2923
|
+
bannerError && showDevConsole && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
2924
|
+
UsageBanner,
|
|
2925
|
+
{
|
|
2926
|
+
severity: bannerError.severity,
|
|
2927
|
+
message: bannerError.message,
|
|
2928
|
+
onClose: () => setBannerError(null),
|
|
2929
|
+
actions: getErrorActions(bannerError)
|
|
2930
|
+
}
|
|
2931
|
+
)
|
|
2932
|
+
] })
|
|
2933
|
+
]
|
|
2934
|
+
}
|
|
2935
|
+
)
|
|
2778
2936
|
}
|
|
2779
2937
|
);
|
|
2780
2938
|
}
|
|
@@ -2811,12 +2969,12 @@ function validateProps(props) {
|
|
|
2811
2969
|
const cloudFeatures = Object.keys(props).filter((key) => key.endsWith("_c"));
|
|
2812
2970
|
const hasApiKey = props.publicApiKey || props.publicLicenseKey;
|
|
2813
2971
|
if (!props.runtimeUrl && !hasApiKey) {
|
|
2814
|
-
throw new
|
|
2972
|
+
throw new import_shared13.ConfigurationError(
|
|
2815
2973
|
"Missing required prop: 'runtimeUrl' or 'publicApiKey' or 'publicLicenseKey'"
|
|
2816
2974
|
);
|
|
2817
2975
|
}
|
|
2818
2976
|
if (cloudFeatures.length > 0 && !hasApiKey) {
|
|
2819
|
-
throw new
|
|
2977
|
+
throw new import_shared13.MissingPublicApiKeyError(
|
|
2820
2978
|
`Missing required prop: 'publicApiKey' or 'publicLicenseKey' to use cloud features: ${cloudFeatures.map(formatFeatureName).join(", ")}`
|
|
2821
2979
|
);
|
|
2822
2980
|
}
|