@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
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defProps = Object.defineProperties;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
7
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
8
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
9
|
var __getProtoOf = Object.getPrototypeOf;
|
|
@@ -19,6 +21,19 @@ var __spreadValues = (a, b) => {
|
|
|
19
21
|
}
|
|
20
22
|
return a;
|
|
21
23
|
};
|
|
24
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
|
+
var __objRest = (source, exclude) => {
|
|
26
|
+
var target = {};
|
|
27
|
+
for (var prop in source)
|
|
28
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
if (source != null && __getOwnPropSymbols)
|
|
31
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
32
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
33
|
+
target[prop] = source[prop];
|
|
34
|
+
}
|
|
35
|
+
return target;
|
|
36
|
+
};
|
|
22
37
|
var __export = (target, all) => {
|
|
23
38
|
for (var name in all)
|
|
24
39
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -40,26 +55,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
40
55
|
mod
|
|
41
56
|
));
|
|
42
57
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
43
|
-
var __async = (__this, __arguments, generator) => {
|
|
44
|
-
return new Promise((resolve, reject) => {
|
|
45
|
-
var fulfilled = (value) => {
|
|
46
|
-
try {
|
|
47
|
-
step(generator.next(value));
|
|
48
|
-
} catch (e) {
|
|
49
|
-
reject(e);
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
var rejected = (value) => {
|
|
53
|
-
try {
|
|
54
|
-
step(generator.throw(value));
|
|
55
|
-
} catch (e) {
|
|
56
|
-
reject(e);
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
60
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
61
|
-
});
|
|
62
|
-
};
|
|
63
58
|
|
|
64
59
|
// src/hooks/use-copilot-action.ts
|
|
65
60
|
var use_copilot_action_exports = {};
|
|
@@ -67,356 +62,219 @@ __export(use_copilot_action_exports, {
|
|
|
67
62
|
useCopilotAction: () => useCopilotAction
|
|
68
63
|
});
|
|
69
64
|
module.exports = __toCommonJS(use_copilot_action_exports);
|
|
70
|
-
var
|
|
71
|
-
var import_react4 = require("react");
|
|
65
|
+
var import_react7 = require("react");
|
|
72
66
|
|
|
73
|
-
// src/
|
|
67
|
+
// src/hooks/use-frontend-tool.ts
|
|
74
68
|
var import_react = __toESM(require("react"));
|
|
75
|
-
var
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
removeCoAgentStateRender: () => {
|
|
85
|
-
},
|
|
86
|
-
chatComponentsCache: { current: { actions: {}, coAgentStateRenders: {} } },
|
|
87
|
-
getContextString: (documents, categories) => returnAndThrowInDebug(""),
|
|
88
|
-
addContext: () => "",
|
|
89
|
-
removeContext: () => {
|
|
90
|
-
},
|
|
91
|
-
getAllContext: () => [],
|
|
92
|
-
getFunctionCallHandler: () => returnAndThrowInDebug(() => __async(void 0, null, function* () {
|
|
93
|
-
})),
|
|
94
|
-
isLoading: false,
|
|
95
|
-
setIsLoading: () => returnAndThrowInDebug(false),
|
|
96
|
-
chatInstructions: "",
|
|
97
|
-
setChatInstructions: () => returnAndThrowInDebug(""),
|
|
98
|
-
additionalInstructions: [],
|
|
99
|
-
setAdditionalInstructions: () => returnAndThrowInDebug([]),
|
|
100
|
-
getDocumentsContext: (categories) => returnAndThrowInDebug([]),
|
|
101
|
-
addDocumentContext: () => returnAndThrowInDebug(""),
|
|
102
|
-
removeDocumentContext: () => {
|
|
103
|
-
},
|
|
104
|
-
runtimeClient: {},
|
|
105
|
-
copilotApiConfig: new class {
|
|
106
|
-
get chatApiEndpoint() {
|
|
107
|
-
throw new Error("Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!");
|
|
108
|
-
}
|
|
109
|
-
get headers() {
|
|
110
|
-
return {};
|
|
69
|
+
var import_shared = require("@copilotkit/shared");
|
|
70
|
+
var import_shared2 = require("@copilotkit/shared");
|
|
71
|
+
var import_react2 = require("@copilotkitnext/react");
|
|
72
|
+
function useFrontendTool(tool, dependencies) {
|
|
73
|
+
const { name, description, parameters, render, followUp } = tool;
|
|
74
|
+
const zodParameters = (0, import_shared.getZodParameters)(parameters);
|
|
75
|
+
const normalizedRender = (() => {
|
|
76
|
+
if (typeof render === "undefined") {
|
|
77
|
+
return void 0;
|
|
111
78
|
}
|
|
112
|
-
|
|
113
|
-
|
|
79
|
+
if (typeof render === "string") {
|
|
80
|
+
const staticRender = render;
|
|
81
|
+
return () => import_react.default.createElement(import_react.default.Fragment, null, staticRender);
|
|
114
82
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
setThreadId: () => {
|
|
135
|
-
},
|
|
136
|
-
runId: null,
|
|
137
|
-
setRunId: () => {
|
|
138
|
-
},
|
|
139
|
-
chatAbortControllerRef: { current: null },
|
|
140
|
-
availableAgents: [],
|
|
141
|
-
extensions: {},
|
|
142
|
-
setExtensions: () => {
|
|
143
|
-
},
|
|
144
|
-
langGraphInterruptAction: null,
|
|
145
|
-
setLangGraphInterruptAction: () => {
|
|
146
|
-
},
|
|
147
|
-
removeLangGraphInterruptAction: () => {
|
|
148
|
-
},
|
|
149
|
-
onError: () => {
|
|
150
|
-
},
|
|
151
|
-
bannerError: null,
|
|
152
|
-
setBannerError: () => {
|
|
153
|
-
},
|
|
154
|
-
internalErrorHandlers: {},
|
|
155
|
-
setInternalErrorHandler: () => {
|
|
156
|
-
},
|
|
157
|
-
removeInternalErrorHandler: () => {
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
var CopilotContext = import_react.default.createContext(emptyCopilotContext);
|
|
161
|
-
function useCopilotContext() {
|
|
162
|
-
const context = import_react.default.useContext(CopilotContext);
|
|
163
|
-
if (context === emptyCopilotContext) {
|
|
164
|
-
throw new Error("Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!");
|
|
165
|
-
}
|
|
166
|
-
return context;
|
|
167
|
-
}
|
|
168
|
-
function returnAndThrowInDebug(_value) {
|
|
169
|
-
throw new Error("Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!");
|
|
83
|
+
return (args) => {
|
|
84
|
+
const renderArgs = __spreadProps(__spreadValues({}, args), {
|
|
85
|
+
result: typeof args.result === "string" ? (0, import_shared2.parseJson)(args.result, args.result) : args.result
|
|
86
|
+
});
|
|
87
|
+
const rendered = render(renderArgs);
|
|
88
|
+
if (typeof rendered === "string") {
|
|
89
|
+
return import_react.default.createElement(import_react.default.Fragment, null, rendered);
|
|
90
|
+
}
|
|
91
|
+
return rendered != null ? rendered : null;
|
|
92
|
+
};
|
|
93
|
+
})();
|
|
94
|
+
(0, import_react2.useFrontendTool)({
|
|
95
|
+
name,
|
|
96
|
+
description,
|
|
97
|
+
parameters: zodParameters,
|
|
98
|
+
handler: tool.handler,
|
|
99
|
+
followUp,
|
|
100
|
+
render: normalizedRender
|
|
101
|
+
});
|
|
170
102
|
}
|
|
171
103
|
|
|
172
|
-
// src/
|
|
104
|
+
// src/hooks/use-render-tool-call.ts
|
|
105
|
+
var import_shared3 = require("@copilotkit/shared");
|
|
173
106
|
var import_react3 = require("react");
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
stroke: "currentColor",
|
|
202
|
-
strokeWidth: "2",
|
|
203
|
-
strokeLinecap: "round",
|
|
204
|
-
strokeLinejoin: "round",
|
|
205
|
-
className: `lucide lucide-circle-alert ${className ? className : ""}`,
|
|
206
|
-
style,
|
|
207
|
-
children: [
|
|
208
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
|
|
209
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "12", x2: "12", y1: "8", y2: "12" }),
|
|
210
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "12", x2: "12.01", y1: "16", y2: "16" })
|
|
211
|
-
]
|
|
212
|
-
}
|
|
213
|
-
);
|
|
214
|
-
|
|
215
|
-
// src/components/error-boundary/error-utils.tsx
|
|
216
|
-
var import_react_markdown = __toESM(require("react-markdown"));
|
|
217
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
218
|
-
function ErrorToast({ errors }) {
|
|
219
|
-
const errorsToRender = errors.map((error, idx) => {
|
|
220
|
-
var _a, _b, _c;
|
|
221
|
-
const originalError = "extensions" in error ? (_a = error.extensions) == null ? void 0 : _a.originalError : {};
|
|
222
|
-
const message = (_b = originalError == null ? void 0 : originalError.message) != null ? _b : error.message;
|
|
223
|
-
const code = "extensions" in error ? (_c = error.extensions) == null ? void 0 : _c.code : null;
|
|
224
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
225
|
-
"div",
|
|
226
|
-
{
|
|
227
|
-
style: {
|
|
228
|
-
marginTop: idx === 0 ? 0 : 10,
|
|
229
|
-
marginBottom: 14
|
|
230
|
-
},
|
|
231
|
-
children: [
|
|
232
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ExclamationMarkIcon, { style: { marginBottom: 4 } }),
|
|
233
|
-
code && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
234
|
-
"div",
|
|
235
|
-
{
|
|
236
|
-
style: {
|
|
237
|
-
fontWeight: "600",
|
|
238
|
-
marginBottom: 4
|
|
239
|
-
},
|
|
240
|
-
children: [
|
|
241
|
-
"Copilot Runtime Error:",
|
|
242
|
-
" ",
|
|
243
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { fontFamily: "monospace", fontWeight: "normal" }, children: code })
|
|
244
|
-
]
|
|
245
|
-
}
|
|
246
|
-
),
|
|
247
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_markdown.default, { children: message })
|
|
248
|
-
]
|
|
249
|
-
},
|
|
250
|
-
idx
|
|
251
|
-
);
|
|
252
|
-
});
|
|
253
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
254
|
-
"div",
|
|
255
|
-
{
|
|
256
|
-
style: {
|
|
257
|
-
fontSize: "13px",
|
|
258
|
-
maxWidth: "600px"
|
|
259
|
-
},
|
|
260
|
-
children: [
|
|
261
|
-
errorsToRender,
|
|
262
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { fontSize: "11px", opacity: 0.75 }, children: "NOTE: This error only displays during local development." })
|
|
263
|
-
]
|
|
264
|
-
}
|
|
265
|
-
);
|
|
266
|
-
}
|
|
267
|
-
function useErrorToast() {
|
|
268
|
-
const { addToast } = useToast();
|
|
269
|
-
return (0, import_react3.useCallback)(
|
|
270
|
-
(error) => {
|
|
271
|
-
const errorId = error.map((err) => {
|
|
272
|
-
var _a, _b;
|
|
273
|
-
const message = "extensions" in err ? ((_b = (_a = err.extensions) == null ? void 0 : _a.originalError) == null ? void 0 : _b.message) || err.message : err.message;
|
|
274
|
-
const stack = err.stack || "";
|
|
275
|
-
return btoa(message + stack).slice(0, 32);
|
|
276
|
-
}).join("|");
|
|
277
|
-
addToast({
|
|
278
|
-
type: "error",
|
|
279
|
-
id: errorId,
|
|
280
|
-
// Toast libraries typically dedupe by id
|
|
281
|
-
message: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ErrorToast, { errors: error })
|
|
282
|
-
});
|
|
283
|
-
},
|
|
284
|
-
[addToast]
|
|
285
|
-
);
|
|
286
|
-
}
|
|
287
|
-
function useAsyncCallback(callback, deps) {
|
|
288
|
-
const addErrorToast = useErrorToast();
|
|
289
|
-
return (0, import_react3.useCallback)((...args) => __async(this, null, function* () {
|
|
290
|
-
try {
|
|
291
|
-
return yield callback(...args);
|
|
292
|
-
} catch (error) {
|
|
293
|
-
console.error("Error in async callback:", error);
|
|
294
|
-
addErrorToast([error]);
|
|
295
|
-
throw error;
|
|
107
|
+
var import_react4 = require("@copilotkitnext/react");
|
|
108
|
+
var import_shared4 = require("@copilotkit/shared");
|
|
109
|
+
function useRenderToolCall(tool, dependencies) {
|
|
110
|
+
const { copilotkit } = (0, import_react4.useCopilotKit)();
|
|
111
|
+
const hasAddedRef = (0, import_react3.useRef)(false);
|
|
112
|
+
(0, import_react3.useEffect)(() => {
|
|
113
|
+
const { name, parameters, render } = tool;
|
|
114
|
+
const zodParameters = (0, import_shared3.getZodParameters)(parameters);
|
|
115
|
+
const renderToolCall = name === "*" ? (0, import_react4.defineToolCallRenderer)({
|
|
116
|
+
name: "*",
|
|
117
|
+
render: (args) => {
|
|
118
|
+
return render(__spreadProps(__spreadValues({}, args), {
|
|
119
|
+
result: args.result ? (0, import_shared4.parseJson)(args.result, args.result) : args.result
|
|
120
|
+
}));
|
|
121
|
+
}
|
|
122
|
+
}) : (0, import_react4.defineToolCallRenderer)({
|
|
123
|
+
name,
|
|
124
|
+
args: zodParameters,
|
|
125
|
+
render: (args) => {
|
|
126
|
+
return render(__spreadProps(__spreadValues({}, args), {
|
|
127
|
+
result: args.result ? (0, import_shared4.parseJson)(args.result, args.result) : args.result
|
|
128
|
+
}));
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
const existingIndex = copilotkit.renderToolCalls.findIndex((r) => r.name === name);
|
|
132
|
+
if (existingIndex !== -1) {
|
|
133
|
+
copilotkit.renderToolCalls.splice(existingIndex, 1);
|
|
296
134
|
}
|
|
297
|
-
|
|
135
|
+
copilotkit.renderToolCalls.push(renderToolCall);
|
|
136
|
+
hasAddedRef.current = true;
|
|
137
|
+
return () => {
|
|
138
|
+
if (hasAddedRef.current) {
|
|
139
|
+
const index = copilotkit.renderToolCalls.findIndex((r) => r.name === name);
|
|
140
|
+
if (index !== -1) {
|
|
141
|
+
copilotkit.renderToolCalls.splice(index, 1);
|
|
142
|
+
}
|
|
143
|
+
hasAddedRef.current = false;
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
}, [tool, ...dependencies != null ? dependencies : []]);
|
|
298
147
|
}
|
|
299
148
|
|
|
300
|
-
// src/hooks/use-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
const {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
const renderAndWait = action.renderAndWait || action.renderAndWaitForResponse;
|
|
315
|
-
action.renderAndWait = void 0;
|
|
316
|
-
action.renderAndWaitForResponse = void 0;
|
|
317
|
-
action._setActivatingMessageId = (id) => {
|
|
318
|
-
activatingMessageIdRef.current = id;
|
|
319
|
-
};
|
|
320
|
-
action.handler = useAsyncCallback(() => __async(this, null, function* () {
|
|
321
|
-
const currentActivatingId = activatingMessageIdRef.current;
|
|
322
|
-
let resolve;
|
|
323
|
-
let reject;
|
|
324
|
-
const promise = new Promise((resolvePromise, rejectPromise) => {
|
|
325
|
-
resolve = resolvePromise;
|
|
326
|
-
reject = rejectPromise;
|
|
327
|
-
});
|
|
328
|
-
renderAndWaitRef.current = {
|
|
329
|
-
promise,
|
|
330
|
-
resolve,
|
|
331
|
-
reject,
|
|
332
|
-
messageId: currentActivatingId
|
|
333
|
-
};
|
|
334
|
-
const result = yield promise;
|
|
335
|
-
return result;
|
|
336
|
-
}), []);
|
|
337
|
-
action.render = (props) => {
|
|
338
|
-
const currentRenderMessageId = props.messageId;
|
|
339
|
-
let status = props.status;
|
|
340
|
-
if (props.status === "executing") {
|
|
341
|
-
if (!renderAndWaitRef.current || !renderAndWaitRef.current.promise) {
|
|
342
|
-
status = "inProgress";
|
|
343
|
-
} else if (renderAndWaitRef.current.messageId !== currentRenderMessageId && activatingMessageIdRef.current !== currentRenderMessageId) {
|
|
344
|
-
status = "inProgress";
|
|
345
|
-
}
|
|
149
|
+
// src/hooks/use-human-in-the-loop.ts
|
|
150
|
+
var import_shared5 = require("@copilotkit/shared");
|
|
151
|
+
var import_react5 = require("@copilotkitnext/react");
|
|
152
|
+
var import_core = require("@copilotkitnext/core");
|
|
153
|
+
var import_react6 = __toESM(require("react"));
|
|
154
|
+
function useHumanInTheLoop(tool, dependencies) {
|
|
155
|
+
const _a = tool, { render } = _a, toolRest = __objRest(_a, ["render"]);
|
|
156
|
+
const { name, description, parameters, followUp } = toolRest;
|
|
157
|
+
const zodParameters = (0, import_shared5.getZodParameters)(parameters);
|
|
158
|
+
const renderRef = (0, import_react6.useRef)(null);
|
|
159
|
+
(0, import_react6.useEffect)(() => {
|
|
160
|
+
renderRef.current = (args) => {
|
|
161
|
+
if (typeof render === "string") {
|
|
162
|
+
return import_react6.default.createElement(import_react6.default.Fragment, null, render);
|
|
346
163
|
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
164
|
+
if (!render) {
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
const renderProps = (() => {
|
|
168
|
+
const mappedArgs = args.args;
|
|
169
|
+
switch (args.status) {
|
|
170
|
+
case import_core.ToolCallStatus.InProgress:
|
|
171
|
+
return {
|
|
172
|
+
args: mappedArgs,
|
|
173
|
+
respond: args.respond,
|
|
174
|
+
status: args.status,
|
|
175
|
+
handler: void 0
|
|
176
|
+
};
|
|
177
|
+
case import_core.ToolCallStatus.Executing:
|
|
178
|
+
return {
|
|
179
|
+
args: mappedArgs,
|
|
180
|
+
respond: args.respond,
|
|
181
|
+
status: args.status,
|
|
182
|
+
handler: () => {
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
case import_core.ToolCallStatus.Complete:
|
|
186
|
+
return {
|
|
187
|
+
args: mappedArgs,
|
|
188
|
+
respond: args.respond,
|
|
189
|
+
status: args.status,
|
|
190
|
+
result: args.result ? (0, import_shared5.parseJson)(args.result, args.result) : args.result,
|
|
191
|
+
handler: void 0
|
|
192
|
+
};
|
|
193
|
+
default:
|
|
194
|
+
throw new import_shared5.CopilotKitError({
|
|
195
|
+
code: import_shared5.CopilotKitErrorCode.UNKNOWN,
|
|
196
|
+
message: `Invalid tool call status: ${args.status}`
|
|
197
|
+
});
|
|
365
198
|
}
|
|
199
|
+
})();
|
|
200
|
+
const rendered = render(renderProps);
|
|
201
|
+
if (typeof rendered === "string") {
|
|
202
|
+
return import_react6.default.createElement(import_react6.default.Fragment, null, rendered);
|
|
366
203
|
}
|
|
367
|
-
return
|
|
204
|
+
return rendered != null ? rendered : null;
|
|
205
|
+
};
|
|
206
|
+
}, [render, ...dependencies != null ? dependencies : []]);
|
|
207
|
+
(0, import_react5.useHumanInTheLoop)({
|
|
208
|
+
name,
|
|
209
|
+
description,
|
|
210
|
+
followUp,
|
|
211
|
+
parameters: zodParameters,
|
|
212
|
+
render: (args) => {
|
|
213
|
+
var _a2, _b;
|
|
214
|
+
return (_b = (_a2 = renderRef.current) == null ? void 0 : _a2.call(renderRef, args)) != null ? _b : null;
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// src/hooks/use-copilot-action.ts
|
|
220
|
+
function getActionConfig(action) {
|
|
221
|
+
if (action.name === "*") {
|
|
222
|
+
return {
|
|
223
|
+
type: "render",
|
|
224
|
+
action
|
|
368
225
|
};
|
|
369
226
|
}
|
|
370
|
-
if (
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
chatComponentsCache.current.actions[action.name] = action.render;
|
|
378
|
-
}
|
|
379
|
-
}
|
|
227
|
+
if ("renderAndWaitForResponse" in action || "renderAndWait" in action) {
|
|
228
|
+
let render = action.render;
|
|
229
|
+
if (!render && "renderAndWaitForResponse" in action) {
|
|
230
|
+
render = action.renderAndWaitForResponse;
|
|
231
|
+
}
|
|
232
|
+
if (!render && "renderAndWait" in action) {
|
|
233
|
+
render = action.renderAndWait;
|
|
380
234
|
}
|
|
235
|
+
return {
|
|
236
|
+
type: "hitl",
|
|
237
|
+
action: __spreadProps(__spreadValues({}, action), { render })
|
|
238
|
+
};
|
|
381
239
|
}
|
|
382
|
-
(
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
type: "warning",
|
|
389
|
-
message: `Found an already registered action with name ${action.name}.`,
|
|
390
|
-
id: `dup-action-${action.name}`
|
|
391
|
-
});
|
|
240
|
+
if ("available" in action) {
|
|
241
|
+
if (action.available === "enabled" || action.available === "remote") {
|
|
242
|
+
return {
|
|
243
|
+
type: "frontend",
|
|
244
|
+
action
|
|
245
|
+
};
|
|
392
246
|
}
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
247
|
+
if (action.available === "frontend" || action.available === "disabled") {
|
|
248
|
+
return {
|
|
249
|
+
type: "render",
|
|
250
|
+
action
|
|
251
|
+
};
|
|
398
252
|
}
|
|
399
|
-
|
|
400
|
-
|
|
253
|
+
}
|
|
254
|
+
if ("handler" in action) {
|
|
255
|
+
return {
|
|
256
|
+
type: "frontend",
|
|
257
|
+
action
|
|
401
258
|
};
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
removeAction,
|
|
405
|
-
isFrontendAction(action) ? action.description : void 0,
|
|
406
|
-
action.name,
|
|
407
|
-
isFrontendAction(action) ? action.disabled : void 0,
|
|
408
|
-
isFrontendAction(action) ? action.available : void 0,
|
|
409
|
-
// This should be faster than deep equality checking
|
|
410
|
-
// In addition, all major JS engines guarantee the order of object keys
|
|
411
|
-
JSON.stringify(isFrontendAction(action) ? action.parameters : []),
|
|
412
|
-
// include render only if it's a string
|
|
413
|
-
typeof action.render === "string" ? action.render : void 0,
|
|
414
|
-
// dependencies set by the developer
|
|
415
|
-
...dependencies || []
|
|
416
|
-
]);
|
|
259
|
+
}
|
|
260
|
+
throw new Error("Invalid action configuration");
|
|
417
261
|
}
|
|
418
|
-
function
|
|
419
|
-
|
|
262
|
+
function useCopilotAction(action, dependencies) {
|
|
263
|
+
const [initialActionConfig] = (0, import_react7.useState)(getActionConfig(action));
|
|
264
|
+
const currentActionConfig = getActionConfig(action);
|
|
265
|
+
if (initialActionConfig.type !== currentActionConfig.type) {
|
|
266
|
+
throw new Error("Action configuration changed between renders");
|
|
267
|
+
}
|
|
268
|
+
switch (currentActionConfig.type) {
|
|
269
|
+
case "render":
|
|
270
|
+
return useRenderToolCall(currentActionConfig.action, dependencies);
|
|
271
|
+
case "hitl":
|
|
272
|
+
return useHumanInTheLoop(currentActionConfig.action, dependencies);
|
|
273
|
+
case "frontend":
|
|
274
|
+
return useFrontendTool(currentActionConfig.action, dependencies);
|
|
275
|
+
default:
|
|
276
|
+
throw new Error("Invalid action configuration");
|
|
277
|
+
}
|
|
420
278
|
}
|
|
421
279
|
// Annotate the CommonJS export names for ESM import in node:
|
|
422
280
|
0 && (module.exports = {
|