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