@copilotkit/react-core 0.0.0-0.0.0-max-changeset-10101010101010-20260109191632
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 +4188 -0
- package/LICENSE +21 -0
- package/README.md +141 -0
- package/dist/chunk-2IDV5OHF.mjs +11 -0
- package/dist/chunk-2IDV5OHF.mjs.map +1 -0
- package/dist/chunk-336QEM3A.mjs +349 -0
- package/dist/chunk-336QEM3A.mjs.map +1 -0
- package/dist/chunk-36KQV2NA.mjs +1 -0
- package/dist/chunk-36KQV2NA.mjs.map +1 -0
- package/dist/chunk-3MHWEKFN.mjs +759 -0
- package/dist/chunk-3MHWEKFN.mjs.map +1 -0
- package/dist/chunk-4CEQJ2X6.mjs +31 -0
- package/dist/chunk-4CEQJ2X6.mjs.map +1 -0
- package/dist/chunk-4RRMC7L2.mjs +32 -0
- package/dist/chunk-4RRMC7L2.mjs.map +1 -0
- package/dist/chunk-6ESSSQ7Q.mjs +134 -0
- package/dist/chunk-6ESSSQ7Q.mjs.map +1 -0
- package/dist/chunk-6PUNP7CD.mjs +102 -0
- package/dist/chunk-6PUNP7CD.mjs.map +1 -0
- package/dist/chunk-6YOKPWQ7.mjs +1 -0
- package/dist/chunk-6YOKPWQ7.mjs.map +1 -0
- package/dist/chunk-6ZLPNY7X.mjs +225 -0
- package/dist/chunk-6ZLPNY7X.mjs.map +1 -0
- package/dist/chunk-7DTB7S5V.mjs +83 -0
- package/dist/chunk-7DTB7S5V.mjs.map +1 -0
- package/dist/chunk-7IBF6RBW.mjs +23 -0
- package/dist/chunk-7IBF6RBW.mjs.map +1 -0
- package/dist/chunk-7X3E6GHT.mjs +83 -0
- package/dist/chunk-7X3E6GHT.mjs.map +1 -0
- package/dist/chunk-A6NKSGH3.mjs +1 -0
- package/dist/chunk-A6NKSGH3.mjs.map +1 -0
- package/dist/chunk-ABWT4DRT.mjs +24 -0
- package/dist/chunk-ABWT4DRT.mjs.map +1 -0
- package/dist/chunk-AFNWX62Q.mjs +110 -0
- package/dist/chunk-AFNWX62Q.mjs.map +1 -0
- package/dist/chunk-BUSWSDYO.mjs +17 -0
- package/dist/chunk-BUSWSDYO.mjs.map +1 -0
- package/dist/chunk-CDUIA2WM.mjs +60 -0
- package/dist/chunk-CDUIA2WM.mjs.map +1 -0
- package/dist/chunk-CYDWEPFL.mjs +1 -0
- package/dist/chunk-CYDWEPFL.mjs.map +1 -0
- package/dist/chunk-DMLQZG75.mjs +25 -0
- package/dist/chunk-DMLQZG75.mjs.map +1 -0
- package/dist/chunk-E7SE25ZU.mjs +59 -0
- package/dist/chunk-E7SE25ZU.mjs.map +1 -0
- package/dist/chunk-EFL5OBKN.mjs +310 -0
- package/dist/chunk-EFL5OBKN.mjs.map +1 -0
- package/dist/chunk-F555TVE4.mjs +33 -0
- package/dist/chunk-F555TVE4.mjs.map +1 -0
- package/dist/chunk-FD6FGKYY.mjs +1 -0
- package/dist/chunk-FD6FGKYY.mjs.map +1 -0
- package/dist/chunk-FDOMAPJY.mjs +59 -0
- package/dist/chunk-FDOMAPJY.mjs.map +1 -0
- package/dist/chunk-GJOR3RI6.mjs +120 -0
- package/dist/chunk-GJOR3RI6.mjs.map +1 -0
- package/dist/chunk-GPEJNVE5.mjs +80 -0
- package/dist/chunk-GPEJNVE5.mjs.map +1 -0
- package/dist/chunk-HM6ON7AM.mjs +86 -0
- package/dist/chunk-HM6ON7AM.mjs.map +1 -0
- package/dist/chunk-I76HKHPJ.mjs +32 -0
- package/dist/chunk-I76HKHPJ.mjs.map +1 -0
- package/dist/chunk-ICIK2BSB.mjs +17 -0
- package/dist/chunk-ICIK2BSB.mjs.map +1 -0
- package/dist/chunk-JD7BAH7U.mjs +1 -0
- package/dist/chunk-JD7BAH7U.mjs.map +1 -0
- package/dist/chunk-LUGEI4YQ.mjs +1 -0
- package/dist/chunk-LUGEI4YQ.mjs.map +1 -0
- package/dist/chunk-N7FZFIWO.mjs +551 -0
- package/dist/chunk-N7FZFIWO.mjs.map +1 -0
- package/dist/chunk-NB2FKV2V.mjs +1 -0
- package/dist/chunk-NB2FKV2V.mjs.map +1 -0
- package/dist/chunk-NBK4KBLX.mjs +54 -0
- package/dist/chunk-NBK4KBLX.mjs.map +1 -0
- package/dist/chunk-O7ARI5CV.mjs +31 -0
- package/dist/chunk-O7ARI5CV.mjs.map +1 -0
- package/dist/chunk-P2YEE2ZI.mjs +36 -0
- package/dist/chunk-P2YEE2ZI.mjs.map +1 -0
- package/dist/chunk-PIF5KJYI.mjs +103 -0
- package/dist/chunk-PIF5KJYI.mjs.map +1 -0
- package/dist/chunk-PMAFHQ7P.mjs +65 -0
- package/dist/chunk-PMAFHQ7P.mjs.map +1 -0
- package/dist/chunk-QNUAXSDP.mjs +166 -0
- package/dist/chunk-QNUAXSDP.mjs.map +1 -0
- package/dist/chunk-RKTVJRK7.mjs +143 -0
- package/dist/chunk-RKTVJRK7.mjs.map +1 -0
- package/dist/chunk-SKC7AJIV.mjs +61 -0
- package/dist/chunk-SKC7AJIV.mjs.map +1 -0
- package/dist/chunk-SPCZTZCY.mjs +1 -0
- package/dist/chunk-SPCZTZCY.mjs.map +1 -0
- package/dist/chunk-SQDOUMPZ.mjs +125 -0
- package/dist/chunk-SQDOUMPZ.mjs.map +1 -0
- package/dist/chunk-WF65O6HX.mjs +66 -0
- package/dist/chunk-WF65O6HX.mjs.map +1 -0
- package/dist/chunk-XDFVCQD3.mjs +27 -0
- package/dist/chunk-XDFVCQD3.mjs.map +1 -0
- package/dist/chunk-YJ2KZDZJ.mjs +186 -0
- package/dist/chunk-YJ2KZDZJ.mjs.map +1 -0
- package/dist/chunk-YTQHRJUA.mjs +86 -0
- package/dist/chunk-YTQHRJUA.mjs.map +1 -0
- package/dist/chunk-YYN33GSG.mjs +73 -0
- package/dist/chunk-YYN33GSG.mjs.map +1 -0
- package/dist/chunk-Z6JV2LRY.mjs +37 -0
- package/dist/chunk-Z6JV2LRY.mjs.map +1 -0
- package/dist/chunk-ZVF5Q6IH.mjs +29 -0
- package/dist/chunk-ZVF5Q6IH.mjs.map +1 -0
- package/dist/chunk-ZYTXB6HH.mjs +151 -0
- package/dist/chunk-ZYTXB6HH.mjs.map +1 -0
- package/dist/components/CopilotListeners.d.ts +3 -0
- package/dist/components/CopilotListeners.js +101 -0
- package/dist/components/CopilotListeners.js.map +1 -0
- package/dist/components/CopilotListeners.mjs +9 -0
- package/dist/components/CopilotListeners.mjs.map +1 -0
- package/dist/components/copilot-provider/copilot-messages.d.ts +24 -0
- package/dist/components/copilot-provider/copilot-messages.js +351 -0
- package/dist/components/copilot-provider/copilot-messages.js.map +1 -0
- package/dist/components/copilot-provider/copilot-messages.mjs +16 -0
- package/dist/components/copilot-provider/copilot-messages.mjs.map +1 -0
- package/dist/components/copilot-provider/copilotkit-props.d.ts +160 -0
- package/dist/components/copilot-provider/copilotkit-props.js +19 -0
- package/dist/components/copilot-provider/copilotkit-props.js.map +1 -0
- package/dist/components/copilot-provider/copilotkit-props.mjs +1 -0
- package/dist/components/copilot-provider/copilotkit-props.mjs.map +1 -0
- package/dist/components/copilot-provider/copilotkit.d.ts +19 -0
- package/dist/components/copilot-provider/copilotkit.js +1960 -0
- package/dist/components/copilot-provider/copilotkit.js.map +1 -0
- package/dist/components/copilot-provider/copilotkit.mjs +31 -0
- package/dist/components/copilot-provider/copilotkit.mjs.map +1 -0
- package/dist/components/copilot-provider/index.d.ts +14 -0
- package/dist/components/copilot-provider/index.js +1960 -0
- package/dist/components/copilot-provider/index.js.map +1 -0
- package/dist/components/copilot-provider/index.mjs +30 -0
- package/dist/components/copilot-provider/index.mjs.map +1 -0
- package/dist/components/dev-console/console-trigger.d.ts +8 -0
- package/dist/components/dev-console/console-trigger.js +1202 -0
- package/dist/components/dev-console/console-trigger.js.map +1 -0
- package/dist/components/dev-console/console-trigger.mjs +233 -0
- package/dist/components/dev-console/console-trigger.mjs.map +1 -0
- package/dist/components/dev-console/developer-console-modal.d.ts +10 -0
- package/dist/components/dev-console/developer-console-modal.js +987 -0
- package/dist/components/dev-console/developer-console-modal.js.map +1 -0
- package/dist/components/dev-console/developer-console-modal.mjs +12 -0
- package/dist/components/dev-console/developer-console-modal.mjs.map +1 -0
- package/dist/components/dev-console/icons.d.ts +9 -0
- package/dist/components/dev-console/icons.js +131 -0
- package/dist/components/dev-console/icons.js.map +1 -0
- package/dist/components/dev-console/icons.mjs +16 -0
- package/dist/components/dev-console/icons.mjs.map +1 -0
- package/dist/components/error-boundary/error-boundary.d.ts +31 -0
- package/dist/components/error-boundary/error-boundary.js +500 -0
- package/dist/components/error-boundary/error-boundary.js.map +1 -0
- package/dist/components/error-boundary/error-boundary.mjs +15 -0
- package/dist/components/error-boundary/error-boundary.mjs.map +1 -0
- package/dist/components/error-boundary/error-utils.d.ts +11 -0
- package/dist/components/error-boundary/error-utils.js +190 -0
- package/dist/components/error-boundary/error-utils.js.map +1 -0
- package/dist/components/error-boundary/error-utils.mjs +14 -0
- package/dist/components/error-boundary/error-utils.mjs.map +1 -0
- package/dist/components/index.d.ts +14 -0
- package/dist/components/index.js +1960 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/index.mjs +31 -0
- package/dist/components/index.mjs.map +1 -0
- package/dist/components/toast/exclamation-mark-icon.d.ts +9 -0
- package/dist/components/toast/exclamation-mark-icon.js +55 -0
- package/dist/components/toast/exclamation-mark-icon.js.map +1 -0
- package/dist/components/toast/exclamation-mark-icon.mjs +8 -0
- package/dist/components/toast/exclamation-mark-icon.mjs.map +1 -0
- package/dist/components/toast/toast-provider.d.ts +27 -0
- package/dist/components/toast/toast-provider.js +347 -0
- package/dist/components/toast/toast-provider.js.map +1 -0
- package/dist/components/toast/toast-provider.mjs +10 -0
- package/dist/components/toast/toast-provider.mjs.map +1 -0
- package/dist/components/usage-banner.d.ts +29 -0
- package/dist/components/usage-banner.js +247 -0
- package/dist/components/usage-banner.js.map +1 -0
- package/dist/components/usage-banner.mjs +12 -0
- package/dist/components/usage-banner.mjs.map +1 -0
- 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 +10 -0
- package/dist/context/copilot-context.js +161 -0
- package/dist/context/copilot-context.js.map +1 -0
- package/dist/context/copilot-context.mjs +10 -0
- package/dist/context/copilot-context.mjs.map +1 -0
- package/dist/context/copilot-messages-context.d.ts +18 -0
- package/dist/context/copilot-messages-context.js +60 -0
- package/dist/context/copilot-messages-context.js.map +1 -0
- package/dist/context/copilot-messages-context.mjs +10 -0
- package/dist/context/copilot-messages-context.mjs.map +1 -0
- package/dist/context/index.d.ts +15 -0
- package/dist/context/index.js +285 -0
- package/dist/context/index.js.map +1 -0
- package/dist/context/index.mjs +33 -0
- package/dist/context/index.mjs.map +1 -0
- 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-ec77e921.d.ts +209 -0
- package/dist/hooks/index.d.ts +33 -0
- package/dist/hooks/index.js +1774 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/index.mjs +91 -0
- package/dist/hooks/index.mjs.map +1 -0
- package/dist/hooks/use-agent-nodename.d.ts +3 -0
- package/dist/hooks/use-agent-nodename.js +56 -0
- package/dist/hooks/use-agent-nodename.js.map +1 -0
- package/dist/hooks/use-agent-nodename.mjs +8 -0
- package/dist/hooks/use-agent-nodename.mjs.map +1 -0
- package/dist/hooks/use-coagent-state-render-bridge.d.ts +100 -0
- package/dist/hooks/use-coagent-state-render-bridge.js +214 -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.d.ts +55 -0
- package/dist/hooks/use-coagent-state-render.js +255 -0
- package/dist/hooks/use-coagent-state-render.js.map +1 -0
- package/dist/hooks/use-coagent-state-render.mjs +11 -0
- package/dist/hooks/use-coagent-state-render.mjs.map +1 -0
- package/dist/hooks/use-coagent.d.ts +192 -0
- package/dist/hooks/use-coagent.js +233 -0
- package/dist/hooks/use-coagent.js.map +1 -0
- package/dist/hooks/use-coagent.mjs +9 -0
- package/dist/hooks/use-coagent.mjs.map +1 -0
- package/dist/hooks/use-configure-chat-suggestions.d.ts +36 -0
- package/dist/hooks/use-configure-chat-suggestions.js +79 -0
- package/dist/hooks/use-configure-chat-suggestions.js.map +1 -0
- package/dist/hooks/use-configure-chat-suggestions.mjs +47 -0
- package/dist/hooks/use-configure-chat-suggestions.mjs.map +1 -0
- package/dist/hooks/use-copilot-action.d.ts +103 -0
- package/dist/hooks/use-copilot-action.js +295 -0
- package/dist/hooks/use-copilot-action.js.map +1 -0
- package/dist/hooks/use-copilot-action.mjs +11 -0
- package/dist/hooks/use-copilot-action.mjs.map +1 -0
- package/dist/hooks/use-copilot-additional-instructions.d.ts +26 -0
- package/dist/hooks/use-copilot-additional-instructions.js +177 -0
- package/dist/hooks/use-copilot-additional-instructions.js.map +1 -0
- package/dist/hooks/use-copilot-additional-instructions.mjs +9 -0
- package/dist/hooks/use-copilot-additional-instructions.mjs.map +1 -0
- package/dist/hooks/use-copilot-authenticated-action.d.ts +18 -0
- package/dist/hooks/use-copilot-authenticated-action.js +462 -0
- package/dist/hooks/use-copilot-authenticated-action.js.map +1 -0
- package/dist/hooks/use-copilot-authenticated-action.mjs +13 -0
- package/dist/hooks/use-copilot-authenticated-action.mjs.map +1 -0
- package/dist/hooks/use-copilot-chat-headless_c.d.ts +25 -0
- package/dist/hooks/use-copilot-chat-headless_c.js +1044 -0
- package/dist/hooks/use-copilot-chat-headless_c.js.map +1 -0
- package/dist/hooks/use-copilot-chat-headless_c.mjs +24 -0
- package/dist/hooks/use-copilot-chat-headless_c.mjs.map +1 -0
- package/dist/hooks/use-copilot-chat-suggestions.d.ts +35 -0
- package/dist/hooks/use-copilot-chat-suggestions.js +60 -0
- package/dist/hooks/use-copilot-chat-suggestions.js.map +1 -0
- package/dist/hooks/use-copilot-chat-suggestions.mjs +8 -0
- package/dist/hooks/use-copilot-chat-suggestions.mjs.map +1 -0
- package/dist/hooks/use-copilot-chat.d.ts +92 -0
- package/dist/hooks/use-copilot-chat.js +978 -0
- package/dist/hooks/use-copilot-chat.js.map +1 -0
- package/dist/hooks/use-copilot-chat.mjs +21 -0
- package/dist/hooks/use-copilot-chat.mjs.map +1 -0
- package/dist/hooks/use-copilot-chat_internal.d.ts +244 -0
- package/dist/hooks/use-copilot-chat_internal.js +976 -0
- package/dist/hooks/use-copilot-chat_internal.js.map +1 -0
- package/dist/hooks/use-copilot-chat_internal.mjs +22 -0
- package/dist/hooks/use-copilot-chat_internal.mjs.map +1 -0
- package/dist/hooks/use-copilot-readable.d.ts +37 -0
- package/dist/hooks/use-copilot-readable.js +61 -0
- package/dist/hooks/use-copilot-readable.js.map +1 -0
- package/dist/hooks/use-copilot-readable.mjs +8 -0
- package/dist/hooks/use-copilot-readable.mjs.map +1 -0
- package/dist/hooks/use-copilot-runtime-client.d.ts +10 -0
- package/dist/hooks/use-copilot-runtime-client.js +203 -0
- package/dist/hooks/use-copilot-runtime-client.js.map +1 -0
- package/dist/hooks/use-copilot-runtime-client.mjs +9 -0
- package/dist/hooks/use-copilot-runtime-client.mjs.map +1 -0
- package/dist/hooks/use-default-tool.d.ts +8 -0
- package/dist/hooks/use-default-tool.js +302 -0
- package/dist/hooks/use-default-tool.js.map +1 -0
- package/dist/hooks/use-default-tool.mjs +12 -0
- package/dist/hooks/use-default-tool.mjs.map +1 -0
- package/dist/hooks/use-flat-category-store.d.ts +9 -0
- package/dist/hooks/use-flat-category-store.js +93 -0
- package/dist/hooks/use-flat-category-store.js.map +1 -0
- package/dist/hooks/use-flat-category-store.mjs +8 -0
- package/dist/hooks/use-flat-category-store.mjs.map +1 -0
- package/dist/hooks/use-frontend-tool.d.ts +11 -0
- package/dist/hooks/use-frontend-tool.js +104 -0
- package/dist/hooks/use-frontend-tool.js.map +1 -0
- package/dist/hooks/use-frontend-tool.mjs +8 -0
- package/dist/hooks/use-frontend-tool.mjs.map +1 -0
- package/dist/hooks/use-human-in-the-loop.d.ts +13 -0
- package/dist/hooks/use-human-in-the-loop.js +122 -0
- package/dist/hooks/use-human-in-the-loop.js.map +1 -0
- package/dist/hooks/use-human-in-the-loop.mjs +8 -0
- package/dist/hooks/use-human-in-the-loop.mjs.map +1 -0
- package/dist/hooks/use-langgraph-interrupt-render.d.ts +6 -0
- package/dist/hooks/use-langgraph-interrupt-render.js +318 -0
- package/dist/hooks/use-langgraph-interrupt-render.js.map +1 -0
- package/dist/hooks/use-langgraph-interrupt-render.mjs +14 -0
- package/dist/hooks/use-langgraph-interrupt-render.mjs.map +1 -0
- package/dist/hooks/use-langgraph-interrupt.d.ts +14 -0
- package/dist/hooks/use-langgraph-interrupt.js +201 -0
- package/dist/hooks/use-langgraph-interrupt.js.map +1 -0
- package/dist/hooks/use-langgraph-interrupt.mjs +10 -0
- package/dist/hooks/use-langgraph-interrupt.mjs.map +1 -0
- 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.d.ts +12 -0
- package/dist/hooks/use-make-copilot-document-readable.js +176 -0
- package/dist/hooks/use-make-copilot-document-readable.js.map +1 -0
- package/dist/hooks/use-make-copilot-document-readable.mjs +9 -0
- package/dist/hooks/use-make-copilot-document-readable.mjs.map +1 -0
- package/dist/hooks/use-render-tool-call.d.ts +12 -0
- package/dist/hooks/use-render-tool-call.js +90 -0
- package/dist/hooks/use-render-tool-call.js.map +1 -0
- package/dist/hooks/use-render-tool-call.mjs +8 -0
- package/dist/hooks/use-render-tool-call.mjs.map +1 -0
- package/dist/hooks/use-tree.d.ts +19 -0
- package/dist/hooks/use-tree.js +175 -0
- package/dist/hooks/use-tree.js.map +1 -0
- package/dist/hooks/use-tree.mjs +8 -0
- package/dist/hooks/use-tree.mjs.map +1 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.js +3528 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +149 -0
- package/dist/index.mjs.map +1 -0
- package/dist/lib/copilot-task.d.ts +97 -0
- package/dist/lib/copilot-task.js +194 -0
- package/dist/lib/copilot-task.js.map +1 -0
- package/dist/lib/copilot-task.mjs +31 -0
- package/dist/lib/copilot-task.mjs.map +1 -0
- package/dist/lib/index.d.ts +11 -0
- package/dist/lib/index.js +196 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/index.mjs +32 -0
- package/dist/lib/index.mjs.map +1 -0
- package/dist/lib/status-checker.d.ts +17 -0
- package/dist/lib/status-checker.js +102 -0
- package/dist/lib/status-checker.js.map +1 -0
- package/dist/lib/status-checker.mjs +8 -0
- package/dist/lib/status-checker.mjs.map +1 -0
- package/dist/setupTests.d.ts +2 -0
- package/dist/setupTests.js +26 -0
- package/dist/setupTests.js.map +1 -0
- package/dist/setupTests.mjs +24 -0
- package/dist/setupTests.mjs.map +1 -0
- package/dist/types/chat-suggestion-configuration.d.ts +22 -0
- package/dist/types/chat-suggestion-configuration.js +19 -0
- package/dist/types/chat-suggestion-configuration.js.map +1 -0
- package/dist/types/chat-suggestion-configuration.mjs +1 -0
- package/dist/types/chat-suggestion-configuration.mjs.map +1 -0
- package/dist/types/coagent-action.d.ts +29 -0
- package/dist/types/coagent-action.js +19 -0
- package/dist/types/coagent-action.js.map +1 -0
- package/dist/types/coagent-action.mjs +1 -0
- package/dist/types/coagent-action.mjs.map +1 -0
- package/dist/types/coagent-state.d.ts +15 -0
- package/dist/types/coagent-state.js +19 -0
- package/dist/types/coagent-state.js.map +1 -0
- package/dist/types/coagent-state.mjs +1 -0
- package/dist/types/coagent-state.mjs.map +1 -0
- package/dist/types/crew.d.ts +79 -0
- package/dist/types/crew.js +19 -0
- package/dist/types/crew.js.map +1 -0
- package/dist/types/crew.mjs +2 -0
- package/dist/types/crew.mjs.map +1 -0
- package/dist/types/document-pointer.d.ts +9 -0
- package/dist/types/document-pointer.js +19 -0
- package/dist/types/document-pointer.js.map +1 -0
- package/dist/types/document-pointer.mjs +1 -0
- package/dist/types/document-pointer.mjs.map +1 -0
- package/dist/types/frontend-action.d.ts +127 -0
- package/dist/types/frontend-action.js +53 -0
- package/dist/types/frontend-action.js.map +1 -0
- package/dist/types/frontend-action.mjs +8 -0
- package/dist/types/frontend-action.mjs.map +1 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/index.js +19 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/index.mjs +4 -0
- package/dist/types/index.mjs.map +1 -0
- package/dist/types/interrupt-action.d.ts +10 -0
- package/dist/types/interrupt-action.js +19 -0
- package/dist/types/interrupt-action.js.map +1 -0
- package/dist/types/interrupt-action.mjs +2 -0
- package/dist/types/interrupt-action.mjs.map +1 -0
- package/dist/types/system-message.d.ts +3 -0
- package/dist/types/system-message.js +19 -0
- package/dist/types/system-message.js.map +1 -0
- package/dist/types/system-message.mjs +1 -0
- package/dist/types/system-message.mjs.map +1 -0
- package/dist/utils/dev-console.d.ts +3 -0
- package/dist/utils/dev-console.js +41 -0
- package/dist/utils/dev-console.js.map +1 -0
- package/dist/utils/dev-console.mjs +8 -0
- package/dist/utils/dev-console.mjs.map +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +52 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/index.mjs +13 -0
- package/dist/utils/index.mjs.map +1 -0
- package/dist/utils/suggestions-constants.d.ts +9 -0
- package/dist/utils/suggestions-constants.js +35 -0
- package/dist/utils/suggestions-constants.js.map +1 -0
- package/dist/utils/suggestions-constants.mjs +8 -0
- package/dist/utils/suggestions-constants.mjs.map +1 -0
- package/dist/utils/utils.d.ts +2 -0
- package/dist/utils/utils.js +19 -0
- package/dist/utils/utils.js.map +1 -0
- package/dist/utils/utils.mjs +1 -0
- package/dist/utils/utils.mjs.map +1 -0
- package/dist/v2/index.css +4 -0
- package/dist/v2/index.css.map +1 -0
- 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 +6 -0
- package/dist/v2/index.mjs.map +1 -0
- package/jest.config.js +25 -0
- package/package.json +92 -0
- package/src/components/CopilotListeners.tsx +81 -0
- package/src/components/copilot-provider/__tests__/copilotkit-error.test.tsx +75 -0
- package/src/components/copilot-provider/copilot-messages.tsx +274 -0
- package/src/components/copilot-provider/copilotkit-props.tsx +169 -0
- package/src/components/copilot-provider/copilotkit.tsx +671 -0
- package/src/components/copilot-provider/index.ts +3 -0
- package/src/components/dev-console/console-trigger.tsx +254 -0
- package/src/components/dev-console/developer-console-modal.tsx +866 -0
- package/src/components/dev-console/icons.tsx +101 -0
- package/src/components/error-boundary/error-boundary.tsx +91 -0
- package/src/components/error-boundary/error-utils.tsx +100 -0
- package/src/components/index.ts +1 -0
- package/src/components/toast/exclamation-mark-icon.tsx +27 -0
- package/src/components/toast/toast-provider.tsx +363 -0
- package/src/components/usage-banner.tsx +259 -0
- package/src/context/coagent-state-renders-context.tsx +76 -0
- package/src/context/copilot-context.tsx +332 -0
- package/src/context/copilot-messages-context.tsx +35 -0
- package/src/context/index.ts +16 -0
- package/src/context/threads-context.tsx +41 -0
- package/src/hooks/__tests__/use-coagent-config.test.ts +351 -0
- package/src/hooks/index.ts +34 -0
- package/src/hooks/use-agent-nodename.ts +30 -0
- package/src/hooks/use-coagent-state-render-bridge.tsx +293 -0
- package/src/hooks/use-coagent-state-render.ts +152 -0
- package/src/hooks/use-coagent.ts +366 -0
- package/src/hooks/use-configure-chat-suggestions.tsx +86 -0
- package/src/hooks/use-copilot-action.ts +236 -0
- package/src/hooks/use-copilot-additional-instructions.ts +85 -0
- package/src/hooks/use-copilot-authenticated-action.ts +70 -0
- package/src/hooks/use-copilot-chat-headless_c.ts +258 -0
- package/src/hooks/use-copilot-chat-suggestions.tsx +124 -0
- package/src/hooks/use-copilot-chat.ts +130 -0
- package/src/hooks/use-copilot-chat_internal.ts +696 -0
- package/src/hooks/use-copilot-readable.ts +135 -0
- package/src/hooks/use-copilot-runtime-client.ts +164 -0
- package/src/hooks/use-default-tool.ts +7 -0
- package/src/hooks/use-flat-category-store.ts +105 -0
- package/src/hooks/use-frontend-tool.ts +96 -0
- package/src/hooks/use-human-in-the-loop.ts +122 -0
- package/src/hooks/use-langgraph-interrupt-render.ts +136 -0
- package/src/hooks/use-langgraph-interrupt.ts +36 -0
- package/src/hooks/use-lazy-tool-renderer.tsx +30 -0
- package/src/hooks/use-make-copilot-document-readable.ts +30 -0
- package/src/hooks/use-render-tool-call.ts +80 -0
- package/src/hooks/use-tree.ts +207 -0
- package/src/index.tsx +7 -0
- package/src/lib/copilot-task.ts +201 -0
- package/src/lib/index.ts +1 -0
- package/src/lib/status-checker.ts +64 -0
- package/src/setupTests.ts +26 -0
- package/src/types/chat-suggestion-configuration.ts +23 -0
- package/src/types/coagent-action.ts +31 -0
- package/src/types/coagent-state.ts +13 -0
- package/src/types/crew.ts +89 -0
- package/src/types/document-pointer.ts +7 -0
- package/src/types/frontend-action.ts +202 -0
- package/src/types/index.ts +17 -0
- package/src/types/interrupt-action.ts +43 -0
- package/src/types/system-message.ts +4 -0
- package/src/utils/dev-console.ts +19 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/suggestions-constants.ts +8 -0
- package/src/utils/utils.test.ts +7 -0
- package/src/utils/utils.ts +8 -0
- package/src/v2/index.css +1 -0
- package/src/v2/index.ts +4 -0
- package/tsconfig.json +8 -0
- package/tsup.config.ts +16 -0
- package/typedoc.json +4 -0
|
@@ -0,0 +1,671 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This component will typically wrap your entire application (or a sub-tree of your application where you want to have a copilot). It provides the copilot context to all other components and hooks.
|
|
3
|
+
*
|
|
4
|
+
* ## Example
|
|
5
|
+
*
|
|
6
|
+
* You can find more information about self-hosting CopilotKit [here](/guides/self-hosting).
|
|
7
|
+
*
|
|
8
|
+
* ```tsx
|
|
9
|
+
* import { CopilotKit } from "@copilotkit/react-core";
|
|
10
|
+
*
|
|
11
|
+
* <CopilotKit runtimeUrl="<your-runtime-url>">
|
|
12
|
+
* // ... your app ...
|
|
13
|
+
* </CopilotKit>
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { useCallback, useEffect, useMemo, useRef, useState, SetStateAction } from "react";
|
|
18
|
+
import {
|
|
19
|
+
CopilotChatConfigurationProvider,
|
|
20
|
+
CopilotKitInspector,
|
|
21
|
+
CopilotKitProvider as CopilotKitNextProvider,
|
|
22
|
+
} from "@copilotkitnext/react";
|
|
23
|
+
import {
|
|
24
|
+
CopilotContext,
|
|
25
|
+
CopilotApiConfig,
|
|
26
|
+
ChatComponentsCache,
|
|
27
|
+
AgentSession,
|
|
28
|
+
AuthState,
|
|
29
|
+
} from "../../context/copilot-context";
|
|
30
|
+
import useTree from "../../hooks/use-tree";
|
|
31
|
+
import { CopilotChatSuggestionConfiguration, DocumentPointer } from "../../types";
|
|
32
|
+
import { flushSync } from "react-dom";
|
|
33
|
+
import {
|
|
34
|
+
COPILOT_CLOUD_CHAT_URL,
|
|
35
|
+
CopilotCloudConfig,
|
|
36
|
+
FunctionCallHandler,
|
|
37
|
+
COPILOT_CLOUD_PUBLIC_API_KEY_HEADER,
|
|
38
|
+
randomUUID,
|
|
39
|
+
ConfigurationError,
|
|
40
|
+
MissingPublicApiKeyError,
|
|
41
|
+
CopilotKitError,
|
|
42
|
+
CopilotErrorEvent,
|
|
43
|
+
CopilotErrorHandler,
|
|
44
|
+
} from "@copilotkit/shared";
|
|
45
|
+
import { FrontendAction } from "../../types/frontend-action";
|
|
46
|
+
import useFlatCategoryStore from "../../hooks/use-flat-category-store";
|
|
47
|
+
import { CopilotKitProps } from "./copilotkit-props";
|
|
48
|
+
import { CoagentState } from "../../types/coagent-state";
|
|
49
|
+
import { CopilotMessages, MessagesTapProvider } from "./copilot-messages";
|
|
50
|
+
import { ToastProvider } from "../toast/toast-provider";
|
|
51
|
+
import { getErrorActions, UsageBanner } from "../usage-banner";
|
|
52
|
+
import { shouldShowDevConsole } from "../../utils";
|
|
53
|
+
import { CopilotErrorBoundary } from "../error-boundary/error-boundary";
|
|
54
|
+
import { Agent, ExtensionsInput } from "@copilotkit/runtime-client-gql";
|
|
55
|
+
import {
|
|
56
|
+
LangGraphInterruptRender,
|
|
57
|
+
LangGraphInterruptActionSetterArgs,
|
|
58
|
+
QueuedInterruptEvent,
|
|
59
|
+
} from "../../types/interrupt-action";
|
|
60
|
+
import { CoAgentStateRendersProvider } from "../../context/coagent-state-renders-context";
|
|
61
|
+
import { CoAgentStateRenderBridge } from "../../hooks/use-coagent-state-render-bridge";
|
|
62
|
+
import { ThreadsProvider, useThreads } from "../../context/threads-context";
|
|
63
|
+
import { CopilotListeners } from "../CopilotListeners";
|
|
64
|
+
|
|
65
|
+
export function CopilotKit({ children, ...props }: CopilotKitProps) {
|
|
66
|
+
const enabled = shouldShowDevConsole(props.showDevConsole);
|
|
67
|
+
const showInspector = shouldShowDevConsole(props.enableInspector);
|
|
68
|
+
|
|
69
|
+
// Use API key if provided, otherwise use the license key
|
|
70
|
+
const publicApiKey = props.publicApiKey || props.publicLicenseKey;
|
|
71
|
+
|
|
72
|
+
const renderArr = useMemo(() => [{ render: CoAgentStateRenderBridge }], []);
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<ToastProvider enabled={enabled}>
|
|
76
|
+
<CopilotErrorBoundary publicApiKey={publicApiKey} showUsageBanner={enabled}>
|
|
77
|
+
<ThreadsProvider threadId={props.threadId}>
|
|
78
|
+
<CopilotKitNextProvider
|
|
79
|
+
{...props}
|
|
80
|
+
showDevConsole={showInspector}
|
|
81
|
+
renderCustomMessages={renderArr}
|
|
82
|
+
useSingleEndpoint={true}
|
|
83
|
+
>
|
|
84
|
+
<CopilotKitInternal {...props}>{children}</CopilotKitInternal>
|
|
85
|
+
</CopilotKitNextProvider>
|
|
86
|
+
</ThreadsProvider>
|
|
87
|
+
</CopilotErrorBoundary>
|
|
88
|
+
</ToastProvider>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function CopilotKitInternal(cpkProps: CopilotKitProps) {
|
|
93
|
+
const { children, ...props } = cpkProps;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* This will throw an error if the props are invalid.
|
|
97
|
+
*/
|
|
98
|
+
validateProps(cpkProps);
|
|
99
|
+
|
|
100
|
+
// Use license key as API key if provided, otherwise use the API key
|
|
101
|
+
const publicApiKey = props.publicLicenseKey || props.publicApiKey;
|
|
102
|
+
|
|
103
|
+
const chatApiEndpoint = props.runtimeUrl || COPILOT_CLOUD_CHAT_URL;
|
|
104
|
+
|
|
105
|
+
const [actions, setActions] = useState<Record<string, FrontendAction<any>>>({});
|
|
106
|
+
|
|
107
|
+
// State for registered actions from useCopilotAction
|
|
108
|
+
const [registeredActionConfigs, setRegisteredActionConfigs] = useState<
|
|
109
|
+
Map<string, { type: string; action: any; component: any }>
|
|
110
|
+
>(new Map());
|
|
111
|
+
|
|
112
|
+
const chatComponentsCache = useRef<ChatComponentsCache>({
|
|
113
|
+
actions: {},
|
|
114
|
+
coAgentStateRenders: {},
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
const { addElement, removeElement, printTree, getAllElements } = useTree();
|
|
118
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
119
|
+
const [chatInstructions, setChatInstructions] = useState("");
|
|
120
|
+
const [authStates, setAuthStates] = useState<Record<string, AuthState>>({});
|
|
121
|
+
const [extensions, setExtensions] = useState<ExtensionsInput>({});
|
|
122
|
+
const [additionalInstructions, setAdditionalInstructions] = useState<string[]>([]);
|
|
123
|
+
|
|
124
|
+
const {
|
|
125
|
+
addElement: addDocument,
|
|
126
|
+
removeElement: removeDocument,
|
|
127
|
+
allElements: allDocuments,
|
|
128
|
+
} = useFlatCategoryStore<DocumentPointer>();
|
|
129
|
+
|
|
130
|
+
// Compute all the functions and properties that we need to pass
|
|
131
|
+
const setAction = useCallback((id: string, action: FrontendAction<any>) => {
|
|
132
|
+
setActions((prevPoints) => {
|
|
133
|
+
return {
|
|
134
|
+
...prevPoints,
|
|
135
|
+
[id]: action,
|
|
136
|
+
};
|
|
137
|
+
});
|
|
138
|
+
}, []);
|
|
139
|
+
|
|
140
|
+
const removeAction = useCallback((id: string) => {
|
|
141
|
+
setActions((prevPoints) => {
|
|
142
|
+
const newPoints = { ...prevPoints };
|
|
143
|
+
delete newPoints[id];
|
|
144
|
+
return newPoints;
|
|
145
|
+
});
|
|
146
|
+
}, []);
|
|
147
|
+
|
|
148
|
+
const getContextString = useCallback(
|
|
149
|
+
(documents: DocumentPointer[], categories: string[]) => {
|
|
150
|
+
const documentsString = documents
|
|
151
|
+
.map((document) => {
|
|
152
|
+
return `${document.name} (${document.sourceApplication}):\n${document.getContents()}`;
|
|
153
|
+
})
|
|
154
|
+
.join("\n\n");
|
|
155
|
+
|
|
156
|
+
const nonDocumentStrings = printTree(categories);
|
|
157
|
+
|
|
158
|
+
return `${documentsString}\n\n${nonDocumentStrings}`;
|
|
159
|
+
},
|
|
160
|
+
[printTree],
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
const addContext = useCallback(
|
|
164
|
+
(
|
|
165
|
+
context: string,
|
|
166
|
+
parentId?: string,
|
|
167
|
+
categories: string[] = defaultCopilotContextCategories,
|
|
168
|
+
) => {
|
|
169
|
+
return addElement(context, categories, parentId);
|
|
170
|
+
},
|
|
171
|
+
[addElement],
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
const removeContext = useCallback(
|
|
175
|
+
(id: string) => {
|
|
176
|
+
removeElement(id);
|
|
177
|
+
},
|
|
178
|
+
[removeElement],
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
const getAllContext = useCallback(() => {
|
|
182
|
+
return getAllElements();
|
|
183
|
+
}, [getAllElements]);
|
|
184
|
+
|
|
185
|
+
const getFunctionCallHandler = useCallback(
|
|
186
|
+
(customEntryPoints?: Record<string, FrontendAction<any>>) => {
|
|
187
|
+
return entryPointsToFunctionCallHandler(Object.values(customEntryPoints || actions));
|
|
188
|
+
},
|
|
189
|
+
[actions],
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
const getDocumentsContext = useCallback(
|
|
193
|
+
(categories: string[]) => {
|
|
194
|
+
return allDocuments(categories);
|
|
195
|
+
},
|
|
196
|
+
[allDocuments],
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
const addDocumentContext = useCallback(
|
|
200
|
+
(documentPointer: DocumentPointer, categories: string[] = defaultCopilotContextCategories) => {
|
|
201
|
+
return addDocument(documentPointer, categories);
|
|
202
|
+
},
|
|
203
|
+
[addDocument],
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
const removeDocumentContext = useCallback(
|
|
207
|
+
(documentId: string) => {
|
|
208
|
+
removeDocument(documentId);
|
|
209
|
+
},
|
|
210
|
+
[removeDocument],
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
// get the appropriate CopilotApiConfig from the props
|
|
214
|
+
const copilotApiConfig: CopilotApiConfig = useMemo(() => {
|
|
215
|
+
let cloud: CopilotCloudConfig | undefined = undefined;
|
|
216
|
+
if (publicApiKey) {
|
|
217
|
+
cloud = {
|
|
218
|
+
guardrails: {
|
|
219
|
+
input: {
|
|
220
|
+
restrictToTopic: {
|
|
221
|
+
enabled: Boolean(props.guardrails_c),
|
|
222
|
+
validTopics: props.guardrails_c?.validTopics || [],
|
|
223
|
+
invalidTopics: props.guardrails_c?.invalidTopics || [],
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
},
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return {
|
|
231
|
+
publicApiKey: publicApiKey,
|
|
232
|
+
...(cloud ? { cloud } : {}),
|
|
233
|
+
chatApiEndpoint: chatApiEndpoint,
|
|
234
|
+
headers: props.headers || {},
|
|
235
|
+
properties: props.properties || {},
|
|
236
|
+
transcribeAudioUrl: props.transcribeAudioUrl,
|
|
237
|
+
textToSpeechUrl: props.textToSpeechUrl,
|
|
238
|
+
credentials: props.credentials,
|
|
239
|
+
};
|
|
240
|
+
}, [
|
|
241
|
+
publicApiKey,
|
|
242
|
+
props.headers,
|
|
243
|
+
props.properties,
|
|
244
|
+
props.transcribeAudioUrl,
|
|
245
|
+
props.textToSpeechUrl,
|
|
246
|
+
props.credentials,
|
|
247
|
+
props.cloudRestrictToTopic,
|
|
248
|
+
props.guardrails_c,
|
|
249
|
+
]);
|
|
250
|
+
|
|
251
|
+
const headers = useMemo(() => {
|
|
252
|
+
const authHeaders = Object.values(authStates || {}).reduce((acc, state) => {
|
|
253
|
+
if (state.status === "authenticated" && state.authHeaders) {
|
|
254
|
+
return {
|
|
255
|
+
...acc,
|
|
256
|
+
...Object.entries(state.authHeaders).reduce(
|
|
257
|
+
(headers, [key, value]) => ({
|
|
258
|
+
...headers,
|
|
259
|
+
[key.startsWith("X-Custom-") ? key : `X-Custom-${key}`]: value,
|
|
260
|
+
}),
|
|
261
|
+
{},
|
|
262
|
+
),
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
return acc;
|
|
266
|
+
}, {});
|
|
267
|
+
|
|
268
|
+
return {
|
|
269
|
+
...(copilotApiConfig.headers || {}),
|
|
270
|
+
...(copilotApiConfig.publicApiKey
|
|
271
|
+
? { [COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: copilotApiConfig.publicApiKey }
|
|
272
|
+
: {}),
|
|
273
|
+
...authHeaders,
|
|
274
|
+
};
|
|
275
|
+
}, [copilotApiConfig.headers, copilotApiConfig.publicApiKey, authStates]);
|
|
276
|
+
|
|
277
|
+
const [internalErrorHandlers, _setInternalErrorHandler] = useState<
|
|
278
|
+
Record<string, CopilotErrorHandler>
|
|
279
|
+
>({});
|
|
280
|
+
const setInternalErrorHandler = useCallback((handler: Record<string, CopilotErrorHandler>) => {
|
|
281
|
+
_setInternalErrorHandler((prev: Record<string, CopilotErrorHandler>) => ({
|
|
282
|
+
...prev,
|
|
283
|
+
...handler,
|
|
284
|
+
}));
|
|
285
|
+
}, []);
|
|
286
|
+
const removeInternalErrorHandler = useCallback((key: string) => {
|
|
287
|
+
_setInternalErrorHandler((prev) => {
|
|
288
|
+
const { [key]: _removed, ...rest } = prev;
|
|
289
|
+
return rest;
|
|
290
|
+
});
|
|
291
|
+
}, []);
|
|
292
|
+
|
|
293
|
+
// Keep latest values in refs
|
|
294
|
+
const onErrorRef = useRef<CopilotErrorHandler | undefined>(props.onError);
|
|
295
|
+
useEffect(() => {
|
|
296
|
+
onErrorRef.current = props.onError;
|
|
297
|
+
}, [props.onError]);
|
|
298
|
+
|
|
299
|
+
const internalHandlersRef = useRef<Record<string, CopilotErrorHandler>>({});
|
|
300
|
+
useEffect(() => {
|
|
301
|
+
internalHandlersRef.current = internalErrorHandlers;
|
|
302
|
+
}, [internalErrorHandlers]);
|
|
303
|
+
|
|
304
|
+
const handleErrors = useCallback(
|
|
305
|
+
async (error: CopilotErrorEvent) => {
|
|
306
|
+
if (copilotApiConfig.publicApiKey && onErrorRef.current) {
|
|
307
|
+
try {
|
|
308
|
+
await onErrorRef.current(error);
|
|
309
|
+
} catch (e) {
|
|
310
|
+
console.error("Error in public onError handler:", e);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
const handlers = Object.values(internalHandlersRef.current);
|
|
314
|
+
await Promise.all(
|
|
315
|
+
handlers.map((h) =>
|
|
316
|
+
Promise.resolve(h(error)).catch((e) =>
|
|
317
|
+
console.error("Error in internal error handler:", e),
|
|
318
|
+
),
|
|
319
|
+
),
|
|
320
|
+
);
|
|
321
|
+
},
|
|
322
|
+
[copilotApiConfig.publicApiKey],
|
|
323
|
+
);
|
|
324
|
+
|
|
325
|
+
const [chatSuggestionConfiguration, setChatSuggestionConfiguration] = useState<{
|
|
326
|
+
[key: string]: CopilotChatSuggestionConfiguration;
|
|
327
|
+
}>({});
|
|
328
|
+
|
|
329
|
+
const addChatSuggestionConfiguration = useCallback(
|
|
330
|
+
(id: string, suggestion: CopilotChatSuggestionConfiguration) => {
|
|
331
|
+
setChatSuggestionConfiguration((prev) => ({ ...prev, [id]: suggestion }));
|
|
332
|
+
},
|
|
333
|
+
[setChatSuggestionConfiguration],
|
|
334
|
+
);
|
|
335
|
+
|
|
336
|
+
const removeChatSuggestionConfiguration = useCallback(
|
|
337
|
+
(id: string) => {
|
|
338
|
+
setChatSuggestionConfiguration((prev) => {
|
|
339
|
+
const { [id]: _, ...rest } = prev;
|
|
340
|
+
return rest;
|
|
341
|
+
});
|
|
342
|
+
},
|
|
343
|
+
[setChatSuggestionConfiguration],
|
|
344
|
+
);
|
|
345
|
+
|
|
346
|
+
const [availableAgents, setAvailableAgents] = useState<Agent[]>([]);
|
|
347
|
+
const [coagentStates, setCoagentStates] = useState<Record<string, CoagentState>>({});
|
|
348
|
+
const coagentStatesRef = useRef<Record<string, CoagentState>>({});
|
|
349
|
+
const setCoagentStatesWithRef = useCallback(
|
|
350
|
+
(
|
|
351
|
+
value:
|
|
352
|
+
| Record<string, CoagentState>
|
|
353
|
+
| ((prev: Record<string, CoagentState>) => Record<string, CoagentState>),
|
|
354
|
+
) => {
|
|
355
|
+
const newValue = typeof value === "function" ? value(coagentStatesRef.current) : value;
|
|
356
|
+
coagentStatesRef.current = newValue;
|
|
357
|
+
setCoagentStates((prev) => {
|
|
358
|
+
return newValue;
|
|
359
|
+
});
|
|
360
|
+
},
|
|
361
|
+
[],
|
|
362
|
+
);
|
|
363
|
+
|
|
364
|
+
let initialAgentSession: AgentSession | null = null;
|
|
365
|
+
if (props.agent) {
|
|
366
|
+
initialAgentSession = {
|
|
367
|
+
agentName: props.agent,
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
const [agentSession, setAgentSession] = useState<AgentSession | null>(initialAgentSession);
|
|
372
|
+
|
|
373
|
+
// Update agentSession when props.agent changes
|
|
374
|
+
useEffect(() => {
|
|
375
|
+
if (props.agent) {
|
|
376
|
+
setAgentSession({
|
|
377
|
+
agentName: props.agent,
|
|
378
|
+
});
|
|
379
|
+
} else {
|
|
380
|
+
setAgentSession(null);
|
|
381
|
+
}
|
|
382
|
+
}, [props.agent]);
|
|
383
|
+
|
|
384
|
+
const { threadId, setThreadId: setInternalThreadId } = useThreads();
|
|
385
|
+
|
|
386
|
+
const setThreadId = useCallback(
|
|
387
|
+
(value: SetStateAction<string>) => {
|
|
388
|
+
if (props.threadId) {
|
|
389
|
+
throw new Error("Cannot call setThreadId() when threadId is provided via props.");
|
|
390
|
+
}
|
|
391
|
+
setInternalThreadId(value);
|
|
392
|
+
},
|
|
393
|
+
[props.threadId],
|
|
394
|
+
);
|
|
395
|
+
|
|
396
|
+
const [runId, setRunId] = useState<string | null>(null);
|
|
397
|
+
|
|
398
|
+
const chatAbortControllerRef = useRef<AbortController | null>(null);
|
|
399
|
+
|
|
400
|
+
const showDevConsole = shouldShowDevConsole(props.showDevConsole);
|
|
401
|
+
|
|
402
|
+
const [interruptActions, _setInterruptActions] = useState<
|
|
403
|
+
Record<string, LangGraphInterruptRender>
|
|
404
|
+
>({});
|
|
405
|
+
const setInterruptAction = useCallback((action: LangGraphInterruptActionSetterArgs) => {
|
|
406
|
+
_setInterruptActions((prev) => {
|
|
407
|
+
if (action == null || !action.id) {
|
|
408
|
+
// Cannot set action without id
|
|
409
|
+
return prev;
|
|
410
|
+
}
|
|
411
|
+
return {
|
|
412
|
+
...prev,
|
|
413
|
+
[action.id]: { ...(prev[action.id] ?? {}), ...action } as LangGraphInterruptRender,
|
|
414
|
+
};
|
|
415
|
+
});
|
|
416
|
+
}, []);
|
|
417
|
+
const removeInterruptAction = useCallback((actionId: string): void => {
|
|
418
|
+
_setInterruptActions((prev) => {
|
|
419
|
+
const { [actionId]: _, ...rest } = prev;
|
|
420
|
+
return rest;
|
|
421
|
+
});
|
|
422
|
+
}, []);
|
|
423
|
+
|
|
424
|
+
const [interruptEventQueue, setInterruptEventQueue] = useState<
|
|
425
|
+
Record<string, QueuedInterruptEvent[]>
|
|
426
|
+
>({});
|
|
427
|
+
|
|
428
|
+
const addInterruptEvent = useCallback((queuedEvent: QueuedInterruptEvent) => {
|
|
429
|
+
setInterruptEventQueue((prev) => {
|
|
430
|
+
const threadQueue = prev[queuedEvent.threadId] || [];
|
|
431
|
+
return {
|
|
432
|
+
...prev,
|
|
433
|
+
[queuedEvent.threadId]: [...threadQueue, queuedEvent],
|
|
434
|
+
};
|
|
435
|
+
});
|
|
436
|
+
}, []);
|
|
437
|
+
|
|
438
|
+
const resolveInterruptEvent = useCallback(
|
|
439
|
+
(threadId: string, eventId: string, response: string) => {
|
|
440
|
+
setInterruptEventQueue((prev) => {
|
|
441
|
+
const threadQueue = prev[threadId] || [];
|
|
442
|
+
return {
|
|
443
|
+
...prev,
|
|
444
|
+
[threadId]: threadQueue.map((queuedEvent) =>
|
|
445
|
+
queuedEvent.eventId === eventId
|
|
446
|
+
? { ...queuedEvent, event: { ...queuedEvent.event, response } }
|
|
447
|
+
: queuedEvent,
|
|
448
|
+
),
|
|
449
|
+
};
|
|
450
|
+
});
|
|
451
|
+
},
|
|
452
|
+
[],
|
|
453
|
+
);
|
|
454
|
+
|
|
455
|
+
const memoizedChildren = useMemo(() => children, [children]);
|
|
456
|
+
const [bannerError, setBannerError] = useState<CopilotKitError | null>(null);
|
|
457
|
+
|
|
458
|
+
const agentLock = useMemo(() => props.agent ?? null, [props.agent]);
|
|
459
|
+
|
|
460
|
+
const forwardedParameters = useMemo(
|
|
461
|
+
() => props.forwardedParameters ?? {},
|
|
462
|
+
[props.forwardedParameters],
|
|
463
|
+
);
|
|
464
|
+
|
|
465
|
+
const updateExtensions = useCallback(
|
|
466
|
+
(newExtensions: SetStateAction<ExtensionsInput>) => {
|
|
467
|
+
setExtensions((prev: ExtensionsInput) => {
|
|
468
|
+
const resolved = typeof newExtensions === "function" ? newExtensions(prev) : newExtensions;
|
|
469
|
+
const isSameLength = Object.keys(resolved).length === Object.keys(prev).length;
|
|
470
|
+
const isEqual =
|
|
471
|
+
isSameLength &&
|
|
472
|
+
// @ts-ignore
|
|
473
|
+
Object.entries(resolved).every(([key, value]) => prev[key] === value);
|
|
474
|
+
|
|
475
|
+
return isEqual ? prev : resolved;
|
|
476
|
+
});
|
|
477
|
+
},
|
|
478
|
+
[setExtensions],
|
|
479
|
+
);
|
|
480
|
+
|
|
481
|
+
const updateAuthStates = useCallback(
|
|
482
|
+
(newAuthStates: SetStateAction<Record<string, AuthState>>) => {
|
|
483
|
+
setAuthStates((prev) => {
|
|
484
|
+
const resolved = typeof newAuthStates === "function" ? newAuthStates(prev) : newAuthStates;
|
|
485
|
+
const isSameLength = Object.keys(resolved).length === Object.keys(prev).length;
|
|
486
|
+
const isEqual =
|
|
487
|
+
isSameLength &&
|
|
488
|
+
// @ts-ignore
|
|
489
|
+
Object.entries(resolved).every(([key, value]) => prev[key] === value);
|
|
490
|
+
|
|
491
|
+
return isEqual ? prev : resolved;
|
|
492
|
+
});
|
|
493
|
+
},
|
|
494
|
+
[setAuthStates],
|
|
495
|
+
);
|
|
496
|
+
|
|
497
|
+
const handleSetRegisteredActions = useCallback((actionConfig: any): string => {
|
|
498
|
+
const key = actionConfig.action.name || randomUUID();
|
|
499
|
+
setRegisteredActionConfigs((prev) => {
|
|
500
|
+
const newMap = new Map(prev);
|
|
501
|
+
newMap.set(key, actionConfig);
|
|
502
|
+
return newMap;
|
|
503
|
+
});
|
|
504
|
+
return key;
|
|
505
|
+
}, []);
|
|
506
|
+
|
|
507
|
+
const handleRemoveRegisteredAction = useCallback((actionKey: string) => {
|
|
508
|
+
setRegisteredActionConfigs((prev) => {
|
|
509
|
+
const newMap = new Map(prev);
|
|
510
|
+
newMap.delete(actionKey);
|
|
511
|
+
return newMap;
|
|
512
|
+
});
|
|
513
|
+
}, []);
|
|
514
|
+
|
|
515
|
+
// Component to render all registered actions
|
|
516
|
+
const RegisteredActionsRenderer = useMemo(() => {
|
|
517
|
+
return () => (
|
|
518
|
+
<>
|
|
519
|
+
{Array.from(registeredActionConfigs.entries()).map(([key, config]) => {
|
|
520
|
+
const Component = config.component;
|
|
521
|
+
return <Component key={key} action={config.action} />;
|
|
522
|
+
})}
|
|
523
|
+
</>
|
|
524
|
+
);
|
|
525
|
+
}, [registeredActionConfigs]);
|
|
526
|
+
|
|
527
|
+
return (
|
|
528
|
+
<CopilotChatConfigurationProvider
|
|
529
|
+
// labels={labels}
|
|
530
|
+
// isModalDefaultOpen={isModalDefaultOpen}
|
|
531
|
+
agentId={props.agent ?? "default"}
|
|
532
|
+
threadId={threadId}
|
|
533
|
+
>
|
|
534
|
+
<CopilotContext.Provider
|
|
535
|
+
value={{
|
|
536
|
+
actions,
|
|
537
|
+
chatComponentsCache,
|
|
538
|
+
getFunctionCallHandler,
|
|
539
|
+
setAction,
|
|
540
|
+
removeAction,
|
|
541
|
+
setRegisteredActions: handleSetRegisteredActions,
|
|
542
|
+
removeRegisteredAction: handleRemoveRegisteredAction,
|
|
543
|
+
getContextString,
|
|
544
|
+
addContext,
|
|
545
|
+
removeContext,
|
|
546
|
+
getAllContext,
|
|
547
|
+
getDocumentsContext,
|
|
548
|
+
addDocumentContext,
|
|
549
|
+
removeDocumentContext,
|
|
550
|
+
copilotApiConfig: copilotApiConfig,
|
|
551
|
+
isLoading,
|
|
552
|
+
setIsLoading,
|
|
553
|
+
chatSuggestionConfiguration,
|
|
554
|
+
addChatSuggestionConfiguration,
|
|
555
|
+
removeChatSuggestionConfiguration,
|
|
556
|
+
chatInstructions,
|
|
557
|
+
setChatInstructions,
|
|
558
|
+
additionalInstructions,
|
|
559
|
+
setAdditionalInstructions,
|
|
560
|
+
showDevConsole,
|
|
561
|
+
coagentStates,
|
|
562
|
+
setCoagentStates,
|
|
563
|
+
coagentStatesRef,
|
|
564
|
+
setCoagentStatesWithRef,
|
|
565
|
+
agentSession,
|
|
566
|
+
setAgentSession,
|
|
567
|
+
forwardedParameters,
|
|
568
|
+
agentLock,
|
|
569
|
+
threadId,
|
|
570
|
+
setThreadId,
|
|
571
|
+
runId,
|
|
572
|
+
setRunId,
|
|
573
|
+
chatAbortControllerRef,
|
|
574
|
+
availableAgents,
|
|
575
|
+
authConfig_c: props.authConfig_c,
|
|
576
|
+
authStates_c: authStates,
|
|
577
|
+
setAuthStates_c: updateAuthStates,
|
|
578
|
+
extensions,
|
|
579
|
+
setExtensions: updateExtensions,
|
|
580
|
+
interruptActions,
|
|
581
|
+
setInterruptAction,
|
|
582
|
+
removeInterruptAction,
|
|
583
|
+
interruptEventQueue,
|
|
584
|
+
addInterruptEvent,
|
|
585
|
+
resolveInterruptEvent,
|
|
586
|
+
bannerError,
|
|
587
|
+
setBannerError,
|
|
588
|
+
onError: handleErrors,
|
|
589
|
+
internalErrorHandlers,
|
|
590
|
+
setInternalErrorHandler,
|
|
591
|
+
removeInternalErrorHandler,
|
|
592
|
+
}}
|
|
593
|
+
>
|
|
594
|
+
<CopilotListeners />
|
|
595
|
+
<CoAgentStateRendersProvider>
|
|
596
|
+
<MessagesTapProvider>
|
|
597
|
+
<CopilotMessages>
|
|
598
|
+
{memoizedChildren}
|
|
599
|
+
<RegisteredActionsRenderer />
|
|
600
|
+
</CopilotMessages>
|
|
601
|
+
</MessagesTapProvider>
|
|
602
|
+
{bannerError && showDevConsole && (
|
|
603
|
+
<UsageBanner
|
|
604
|
+
severity={bannerError.severity}
|
|
605
|
+
message={bannerError.message}
|
|
606
|
+
onClose={() => setBannerError(null)}
|
|
607
|
+
actions={getErrorActions(bannerError)}
|
|
608
|
+
/>
|
|
609
|
+
)}
|
|
610
|
+
</CoAgentStateRendersProvider>
|
|
611
|
+
</CopilotContext.Provider>
|
|
612
|
+
</CopilotChatConfigurationProvider>
|
|
613
|
+
);
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
export const defaultCopilotContextCategories = ["global"];
|
|
617
|
+
|
|
618
|
+
function entryPointsToFunctionCallHandler(actions: FrontendAction<any>[]): FunctionCallHandler {
|
|
619
|
+
return async ({ name, args }: { name: string; args: Record<string, any> }) => {
|
|
620
|
+
let actionsByFunctionName: Record<string, FrontendAction<any>> = {};
|
|
621
|
+
for (let action of actions) {
|
|
622
|
+
actionsByFunctionName[action.name] = action;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
const action = actionsByFunctionName[name];
|
|
626
|
+
let result: any = undefined;
|
|
627
|
+
if (action) {
|
|
628
|
+
await new Promise<void>((resolve, reject) => {
|
|
629
|
+
flushSync(async () => {
|
|
630
|
+
try {
|
|
631
|
+
result = await action.handler?.(args);
|
|
632
|
+
resolve();
|
|
633
|
+
} catch (error) {
|
|
634
|
+
reject(error);
|
|
635
|
+
}
|
|
636
|
+
});
|
|
637
|
+
});
|
|
638
|
+
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
639
|
+
}
|
|
640
|
+
return result;
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
function formatFeatureName(featureName: string): string {
|
|
645
|
+
return featureName
|
|
646
|
+
.replace(/_c$/, "")
|
|
647
|
+
.split("_")
|
|
648
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
|
649
|
+
.join(" ");
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
function validateProps(props: CopilotKitProps): never | void {
|
|
653
|
+
const cloudFeatures = Object.keys(props).filter((key) => key.endsWith("_c"));
|
|
654
|
+
|
|
655
|
+
// Check if we have either a runtimeUrl or one of the API keys
|
|
656
|
+
const hasApiKey = props.publicApiKey || props.publicLicenseKey;
|
|
657
|
+
|
|
658
|
+
if (!props.runtimeUrl && !hasApiKey) {
|
|
659
|
+
throw new ConfigurationError(
|
|
660
|
+
"Missing required prop: 'runtimeUrl' or 'publicApiKey' or 'publicLicenseKey'",
|
|
661
|
+
);
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
if (cloudFeatures.length > 0 && !hasApiKey) {
|
|
665
|
+
throw new MissingPublicApiKeyError(
|
|
666
|
+
`Missing required prop: 'publicApiKey' or 'publicLicenseKey' to use cloud features: ${cloudFeatures
|
|
667
|
+
.map(formatFeatureName)
|
|
668
|
+
.join(", ")}`,
|
|
669
|
+
);
|
|
670
|
+
}
|
|
671
|
+
}
|