@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,236 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example usage of useCopilotAction with complex parameters:
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* useCopilotAction({
|
|
6
|
+
* name: "myAction",
|
|
7
|
+
* parameters: [
|
|
8
|
+
* { name: "arg1", type: "string", enum: ["option1", "option2", "option3"], required: false },
|
|
9
|
+
* { name: "arg2", type: "number" },
|
|
10
|
+
* {
|
|
11
|
+
* name: "arg3",
|
|
12
|
+
* type: "object",
|
|
13
|
+
* attributes: [
|
|
14
|
+
* { name: "nestedArg1", type: "boolean" },
|
|
15
|
+
* { name: "xyz", required: false },
|
|
16
|
+
* ],
|
|
17
|
+
* },
|
|
18
|
+
* { name: "arg4", type: "number[]" },
|
|
19
|
+
* ],
|
|
20
|
+
* handler: ({ arg1, arg2, arg3, arg4 }) => {
|
|
21
|
+
* const x = arg3.nestedArg1;
|
|
22
|
+
* const z = arg3.xyz;
|
|
23
|
+
* console.log(arg1, arg2, arg3);
|
|
24
|
+
* },
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* // Simple action without parameters
|
|
29
|
+
* useCopilotAction({
|
|
30
|
+
* name: "myAction",
|
|
31
|
+
* handler: () => {
|
|
32
|
+
* console.log("No parameters provided.");
|
|
33
|
+
* },
|
|
34
|
+
* });
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* // Interactive action with UI rendering and response handling
|
|
38
|
+
* useCopilotAction({
|
|
39
|
+
* name: "handleMeeting",
|
|
40
|
+
* description: "Handle a meeting by booking or canceling",
|
|
41
|
+
* parameters: [
|
|
42
|
+
* {
|
|
43
|
+
* name: "meeting",
|
|
44
|
+
* type: "string",
|
|
45
|
+
* description: "The meeting to handle",
|
|
46
|
+
* required: true,
|
|
47
|
+
* },
|
|
48
|
+
* {
|
|
49
|
+
* name: "date",
|
|
50
|
+
* type: "string",
|
|
51
|
+
* description: "The date of the meeting",
|
|
52
|
+
* required: true,
|
|
53
|
+
* },
|
|
54
|
+
* {
|
|
55
|
+
* name: "title",
|
|
56
|
+
* type: "string",
|
|
57
|
+
* description: "The title of the meeting",
|
|
58
|
+
* required: true,
|
|
59
|
+
* },
|
|
60
|
+
* ],
|
|
61
|
+
* renderAndWaitForResponse: ({ args, respond, status }) => {
|
|
62
|
+
* const { meeting, date, title } = args;
|
|
63
|
+
* return (
|
|
64
|
+
* <MeetingConfirmationDialog
|
|
65
|
+
* meeting={meeting}
|
|
66
|
+
* date={date}
|
|
67
|
+
* title={title}
|
|
68
|
+
* onConfirm={() => respond('meeting confirmed')}
|
|
69
|
+
* onCancel={() => respond('meeting canceled')}
|
|
70
|
+
* />
|
|
71
|
+
* );
|
|
72
|
+
* },
|
|
73
|
+
* });
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* // Catch all action allows you to render actions that are not defined in the frontend
|
|
77
|
+
* useCopilotAction({
|
|
78
|
+
* name: "*",
|
|
79
|
+
* render: ({ name, args, status, result, handler, respond }) => {
|
|
80
|
+
* return <div>Rendering action: {name}</div>;
|
|
81
|
+
* },
|
|
82
|
+
* });
|
|
83
|
+
*/
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* <img src="https://cdn.copilotkit.ai/docs/copilotkit/images/use-copilot-action/useCopilotAction.gif" width="500" />
|
|
87
|
+
* `useCopilotAction` is a React hook that you can use in your application to provide
|
|
88
|
+
* custom actions that can be called by the AI. Essentially, it allows the Copilot to
|
|
89
|
+
* execute these actions contextually during a chat, based on the user's interactions
|
|
90
|
+
* and needs.
|
|
91
|
+
*
|
|
92
|
+
* Here's how it works:
|
|
93
|
+
*
|
|
94
|
+
* Use `useCopilotAction` to set up actions that the Copilot can call. To provide
|
|
95
|
+
* more context to the Copilot, you can provide it with a `description` (for example to explain
|
|
96
|
+
* what the action does, under which conditions it can be called, etc.).
|
|
97
|
+
*
|
|
98
|
+
* Then you define the parameters of the action, which can be simple, e.g. primitives like strings or numbers,
|
|
99
|
+
* or complex, e.g. objects or arrays.
|
|
100
|
+
*
|
|
101
|
+
* Finally, you provide a `handler` function that receives the parameters and returns a result.
|
|
102
|
+
* CopilotKit takes care of automatically inferring the parameter types, so you get type safety
|
|
103
|
+
* and autocompletion for free.
|
|
104
|
+
*
|
|
105
|
+
* To render a custom UI for the action, you can provide a `render()` function. This function
|
|
106
|
+
* lets you render a custom component or return a string to display.
|
|
107
|
+
*
|
|
108
|
+
* ## Usage
|
|
109
|
+
*
|
|
110
|
+
* ### Simple Usage
|
|
111
|
+
*
|
|
112
|
+
* ```tsx
|
|
113
|
+
* useCopilotAction({
|
|
114
|
+
* name: "sayHello",
|
|
115
|
+
* description: "Say hello to someone.",
|
|
116
|
+
* parameters: [
|
|
117
|
+
* {
|
|
118
|
+
* name: "name",
|
|
119
|
+
* type: "string",
|
|
120
|
+
* description: "name of the person to say greet",
|
|
121
|
+
* },
|
|
122
|
+
* ],
|
|
123
|
+
* handler: async ({ name }) => {
|
|
124
|
+
* alert(`Hello, ${name}!`);
|
|
125
|
+
* },
|
|
126
|
+
* });
|
|
127
|
+
* ```
|
|
128
|
+
*
|
|
129
|
+
* ## Generative UI
|
|
130
|
+
*
|
|
131
|
+
* This hooks enables you to dynamically generate UI elements and render them in the copilot chat. For more information, check out the [Generative UI](/guides/generative-ui) page.
|
|
132
|
+
*/
|
|
133
|
+
import { useEffect, useRef, useState } from "react";
|
|
134
|
+
import { Parameter } from "@copilotkit/shared";
|
|
135
|
+
import { CatchAllFrontendAction, FrontendAction } from "../types/frontend-action";
|
|
136
|
+
import { useFrontendTool, UseFrontendToolArgs } from "./use-frontend-tool";
|
|
137
|
+
import { useRenderToolCall, UseRenderToolCallArgs } from "./use-render-tool-call";
|
|
138
|
+
import { useHumanInTheLoop, UseHumanInTheLoopArgs } from "./use-human-in-the-loop";
|
|
139
|
+
import { useCopilotContext } from "../context";
|
|
140
|
+
|
|
141
|
+
// Helper to determine which component and action config to use
|
|
142
|
+
function getActionConfig<const T extends Parameter[] | [] = []>(
|
|
143
|
+
action: FrontendAction<T> | CatchAllFrontendAction,
|
|
144
|
+
) {
|
|
145
|
+
if (action.name === "*") {
|
|
146
|
+
return {
|
|
147
|
+
type: "render" as const,
|
|
148
|
+
action: action as UseRenderToolCallArgs<T>,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if ("renderAndWaitForResponse" in action || "renderAndWait" in action) {
|
|
153
|
+
let render = action.render;
|
|
154
|
+
if (!render && "renderAndWaitForResponse" in action) {
|
|
155
|
+
// @ts-expect-error -- renderAndWaitForResponse is deprecated, but we need to support it for backwards compatibility
|
|
156
|
+
render = action.renderAndWaitForResponse;
|
|
157
|
+
}
|
|
158
|
+
if (!render && "renderAndWait" in action) {
|
|
159
|
+
// @ts-expect-error -- renderAndWait is deprecated, but we need to support it for backwards compatibility
|
|
160
|
+
render = action.renderAndWait;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return {
|
|
164
|
+
type: "hitl" as const,
|
|
165
|
+
action: { ...action, render } as UseHumanInTheLoopArgs<T>,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if ("available" in action) {
|
|
170
|
+
if (action.available === "enabled" || action.available === "remote") {
|
|
171
|
+
return {
|
|
172
|
+
type: "frontend" as const,
|
|
173
|
+
action: action as UseFrontendToolArgs<T>,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
if (action.available === "frontend" || action.available === "disabled") {
|
|
177
|
+
return {
|
|
178
|
+
type: "render" as const,
|
|
179
|
+
action: action as UseRenderToolCallArgs<T>,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if ("handler" in action) {
|
|
185
|
+
return {
|
|
186
|
+
type: "frontend" as const,
|
|
187
|
+
action: action as UseFrontendToolArgs<T>,
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
throw new Error("Invalid action configuration");
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* useCopilotAction is a legacy hook maintained for backwards compatibility.
|
|
196
|
+
*
|
|
197
|
+
* To avoid violating React's Rules of Hooks (which prohibit conditional hook calls),
|
|
198
|
+
* we use a registration pattern:
|
|
199
|
+
* 1. This hook registers the action configuration with the CopilotContext
|
|
200
|
+
* 2. A renderer component in CopilotKit actually renders the appropriate hook wrapper
|
|
201
|
+
* 3. React properly manages hook state since components are rendered, not conditionally called
|
|
202
|
+
*
|
|
203
|
+
* This allows action types to change between renders without corrupting React's hook state.
|
|
204
|
+
*/
|
|
205
|
+
export function useCopilotAction<const T extends Parameter[] | [] = []>(
|
|
206
|
+
action: FrontendAction<T> | CatchAllFrontendAction,
|
|
207
|
+
dependencies?: any[],
|
|
208
|
+
): void {
|
|
209
|
+
const [initialActionConfig] = useState(getActionConfig(action));
|
|
210
|
+
const currentActionConfig = getActionConfig(action);
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Calling hooks conditionally violates React's Rules of Hooks. This rule exists because
|
|
214
|
+
* React maintains the call stack for hooks like useEffect or useState, and conditionally
|
|
215
|
+
* calling a hook would result in inconsistent call stacks between renders.
|
|
216
|
+
*
|
|
217
|
+
* Unfortunately, useCopilotAction _has_ to conditionally call a hook based on the
|
|
218
|
+
* supplied parameters. In order to avoid breaking React's call stack tracking, while
|
|
219
|
+
* breaking the Rule of Hooks, we use a ref to store the initial action configuration
|
|
220
|
+
* and throw an error if the _configuration_ changes such that we would call a different hook.
|
|
221
|
+
*/
|
|
222
|
+
if (initialActionConfig.type !== currentActionConfig.type) {
|
|
223
|
+
throw new Error("Action configuration changed between renders");
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
switch (currentActionConfig.type) {
|
|
227
|
+
case "render":
|
|
228
|
+
return useRenderToolCall(currentActionConfig.action, dependencies);
|
|
229
|
+
case "hitl":
|
|
230
|
+
return useHumanInTheLoop(currentActionConfig.action, dependencies);
|
|
231
|
+
case "frontend":
|
|
232
|
+
return useFrontendTool(currentActionConfig.action, dependencies);
|
|
233
|
+
default:
|
|
234
|
+
throw new Error("Invalid action configuration");
|
|
235
|
+
}
|
|
236
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `useCopilotAdditionalInstructions` is a React hook that provides additional instructions
|
|
3
|
+
* to the Copilot.
|
|
4
|
+
*
|
|
5
|
+
* ## Usage
|
|
6
|
+
*
|
|
7
|
+
* ### Simple Usage
|
|
8
|
+
*
|
|
9
|
+
* In its most basic usage, useCopilotAdditionalInstructions accepts a single string argument
|
|
10
|
+
* representing the instructions to be added to the Copilot.
|
|
11
|
+
*
|
|
12
|
+
* ```tsx
|
|
13
|
+
* import { useCopilotAdditionalInstructions } from "@copilotkit/react-core";
|
|
14
|
+
*
|
|
15
|
+
* export function MyComponent() {
|
|
16
|
+
* useCopilotAdditionalInstructions({
|
|
17
|
+
* instructions: "Do not answer questions about the weather.",
|
|
18
|
+
* });
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* ### Conditional Usage
|
|
23
|
+
*
|
|
24
|
+
* You can also conditionally add instructions based on the state of your app.
|
|
25
|
+
*
|
|
26
|
+
* ```tsx
|
|
27
|
+
* import { useCopilotAdditionalInstructions } from "@copilotkit/react-core";
|
|
28
|
+
*
|
|
29
|
+
* export function MyComponent() {
|
|
30
|
+
* const [showInstructions, setShowInstructions] = useState(false);
|
|
31
|
+
*
|
|
32
|
+
* useCopilotAdditionalInstructions({
|
|
33
|
+
* available: showInstructions ? "enabled" : "disabled",
|
|
34
|
+
* instructions: "Do not answer questions about the weather.",
|
|
35
|
+
* });
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
import { useEffect } from "react";
|
|
40
|
+
import { useCopilotContext } from "../context/copilot-context";
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Options for the useCopilotAdditionalInstructions hook.
|
|
44
|
+
*/
|
|
45
|
+
export interface UseCopilotAdditionalInstructionsOptions {
|
|
46
|
+
/**
|
|
47
|
+
* The instructions to be added to the Copilot. Will be added to the instructions like so:
|
|
48
|
+
*
|
|
49
|
+
* ```txt
|
|
50
|
+
* You are a helpful assistant.
|
|
51
|
+
* Additionally, follow these instructions:
|
|
52
|
+
* - Do not answer questions about the weather.
|
|
53
|
+
* - Do not answer questions about the stock market.
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
instructions: string;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Whether the instructions are available to the Copilot.
|
|
60
|
+
*/
|
|
61
|
+
available?: "enabled" | "disabled";
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Adds the given instructions to the Copilot context.
|
|
66
|
+
*/
|
|
67
|
+
export function useCopilotAdditionalInstructions(
|
|
68
|
+
{ instructions, available = "enabled" }: UseCopilotAdditionalInstructionsOptions,
|
|
69
|
+
dependencies?: any[],
|
|
70
|
+
) {
|
|
71
|
+
const { setAdditionalInstructions } = useCopilotContext();
|
|
72
|
+
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
if (available === "disabled") return;
|
|
75
|
+
|
|
76
|
+
setAdditionalInstructions((prevInstructions) => [...(prevInstructions || []), instructions]);
|
|
77
|
+
|
|
78
|
+
return () => {
|
|
79
|
+
setAdditionalInstructions(
|
|
80
|
+
(prevInstructions) =>
|
|
81
|
+
prevInstructions?.filter((instruction) => instruction !== instructions) || [],
|
|
82
|
+
);
|
|
83
|
+
};
|
|
84
|
+
}, [available, instructions, setAdditionalInstructions, ...(dependencies || [])]);
|
|
85
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Parameter } from "@copilotkit/shared";
|
|
2
|
+
import { Fragment, useCallback, useRef } from "react";
|
|
3
|
+
import { useCopilotContext } from "../context/copilot-context";
|
|
4
|
+
import { FrontendAction, ActionRenderProps } from "../types/frontend-action";
|
|
5
|
+
import { useCopilotAction } from "./use-copilot-action";
|
|
6
|
+
import React from "react";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Hook to create an authenticated action that requires user sign-in before execution.
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
* This feature is only available when using CopilotKit's hosted cloud service.
|
|
13
|
+
* To use this feature, sign up at https://cloud.copilotkit.ai to get your publicApiKey.
|
|
14
|
+
*
|
|
15
|
+
* @param action - The frontend action to be wrapped with authentication
|
|
16
|
+
* @param dependencies - Optional array of dependencies that will trigger recreation of the action when changed
|
|
17
|
+
*/
|
|
18
|
+
export function useCopilotAuthenticatedAction_c<T extends Parameter[]>(
|
|
19
|
+
action: FrontendAction<T>,
|
|
20
|
+
dependencies?: any[],
|
|
21
|
+
): void {
|
|
22
|
+
const { authConfig_c, authStates_c, setAuthStates_c } = useCopilotContext();
|
|
23
|
+
const pendingActionRef = useRef<ActionRenderProps<Parameter[]> | null>(null);
|
|
24
|
+
|
|
25
|
+
const executeAction = useCallback(
|
|
26
|
+
(props: ActionRenderProps<Parameter[]>) => {
|
|
27
|
+
if (typeof action.render === "function") {
|
|
28
|
+
return action.render(props);
|
|
29
|
+
}
|
|
30
|
+
return action.render || React.createElement(Fragment);
|
|
31
|
+
},
|
|
32
|
+
[action],
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
const wrappedRender = useCallback(
|
|
36
|
+
(props: ActionRenderProps<Parameter[]>): string | React.ReactElement => {
|
|
37
|
+
const isAuthenticated = Object.values(authStates_c || {}).some(
|
|
38
|
+
(state) => state.status === "authenticated",
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
if (!isAuthenticated) {
|
|
42
|
+
// Store action details for later execution
|
|
43
|
+
pendingActionRef.current = props;
|
|
44
|
+
|
|
45
|
+
return authConfig_c?.SignInComponent
|
|
46
|
+
? React.createElement(authConfig_c.SignInComponent, {
|
|
47
|
+
onSignInComplete: (authState) => {
|
|
48
|
+
setAuthStates_c?.((prev) => ({ ...prev, [action.name]: authState }));
|
|
49
|
+
if (pendingActionRef.current) {
|
|
50
|
+
executeAction(pendingActionRef.current);
|
|
51
|
+
pendingActionRef.current = null;
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
})
|
|
55
|
+
: React.createElement(Fragment);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return executeAction(props);
|
|
59
|
+
},
|
|
60
|
+
[action, authStates_c, setAuthStates_c],
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
useCopilotAction(
|
|
64
|
+
{
|
|
65
|
+
...action,
|
|
66
|
+
render: wrappedRender,
|
|
67
|
+
} as FrontendAction<T>,
|
|
68
|
+
dependencies,
|
|
69
|
+
);
|
|
70
|
+
}
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `useCopilotChatHeadless_c` is for building fully custom UI (headless UI) implementations.
|
|
3
|
+
*
|
|
4
|
+
* <Callout title="This is a premium-only feature">
|
|
5
|
+
* Sign up for free on [Copilot Cloud](https://cloud.copilotkit.ai) to get your public license key or read more about <a href="/premium/overview">premium features</a>.
|
|
6
|
+
*
|
|
7
|
+
* Usage is generous, **free** to get started, and works with **either self-hosted or Copilot Cloud** environments.
|
|
8
|
+
* </Callout>
|
|
9
|
+
*
|
|
10
|
+
* ## Key Features
|
|
11
|
+
*
|
|
12
|
+
* - **Fully headless**: Build your own fully custom UI's for your agentic applications.
|
|
13
|
+
* - **Advanced Suggestions**: Direct access to suggestions array with full control
|
|
14
|
+
* - **Interrupt Handling**: Support for advanced interrupt functionality
|
|
15
|
+
* - **MCP Server Support**: Model Context Protocol server configurations
|
|
16
|
+
* - **Chat Controls**: Complete set of chat management functions
|
|
17
|
+
* - **Loading States**: Comprehensive loading state management
|
|
18
|
+
*
|
|
19
|
+
*
|
|
20
|
+
* ## Usage
|
|
21
|
+
*
|
|
22
|
+
* ### Basic Setup
|
|
23
|
+
*
|
|
24
|
+
* ```tsx
|
|
25
|
+
* import { CopilotKit } from "@copilotkit/react-core";
|
|
26
|
+
* import { useCopilotChatHeadless_c } from "@copilotkit/react-core";
|
|
27
|
+
*
|
|
28
|
+
* export function App() {
|
|
29
|
+
* return (
|
|
30
|
+
* <CopilotKit publicApiKey="your-free-public-license-key">
|
|
31
|
+
* <YourComponent />
|
|
32
|
+
* </CopilotKit>
|
|
33
|
+
* );
|
|
34
|
+
* }
|
|
35
|
+
*
|
|
36
|
+
* export function YourComponent() {
|
|
37
|
+
* const { messages, sendMessage, isLoading } = useCopilotChatHeadless_c();
|
|
38
|
+
*
|
|
39
|
+
* const handleSendMessage = async () => {
|
|
40
|
+
* await sendMessage({
|
|
41
|
+
* id: "123",
|
|
42
|
+
* role: "user",
|
|
43
|
+
* content: "Hello World",
|
|
44
|
+
* });
|
|
45
|
+
* };
|
|
46
|
+
*
|
|
47
|
+
* return (
|
|
48
|
+
* <div>
|
|
49
|
+
* {messages.map(msg => <div key={msg.id}>{msg.content}</div>)}
|
|
50
|
+
* <button onClick={handleSendMessage} disabled={isLoading}>
|
|
51
|
+
* Send Message
|
|
52
|
+
* </button>
|
|
53
|
+
* </div>
|
|
54
|
+
* );
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* ### Working with Suggestions
|
|
59
|
+
*
|
|
60
|
+
* ```tsx
|
|
61
|
+
* import { useCopilotChatHeadless_c, useCopilotChatSuggestions } from "@copilotkit/react-core";
|
|
62
|
+
*
|
|
63
|
+
* export function SuggestionExample() {
|
|
64
|
+
* const {
|
|
65
|
+
* suggestions,
|
|
66
|
+
* setSuggestions,
|
|
67
|
+
* generateSuggestions,
|
|
68
|
+
* isLoadingSuggestions
|
|
69
|
+
* } = useCopilotChatHeadless_c();
|
|
70
|
+
*
|
|
71
|
+
* // Configure AI suggestion generation
|
|
72
|
+
* useCopilotChatSuggestions({
|
|
73
|
+
* instructions: "Suggest helpful actions based on the current context",
|
|
74
|
+
* maxSuggestions: 3
|
|
75
|
+
* });
|
|
76
|
+
*
|
|
77
|
+
* return (
|
|
78
|
+
* <div>
|
|
79
|
+
* {suggestions.map(suggestion => (
|
|
80
|
+
* <button key={suggestion.title}>{suggestion.title}</button>
|
|
81
|
+
* ))}
|
|
82
|
+
* <button onClick={generateSuggestions} disabled={isLoadingSuggestions}>
|
|
83
|
+
* Generate Suggestions
|
|
84
|
+
* </button>
|
|
85
|
+
* </div>
|
|
86
|
+
* );
|
|
87
|
+
* }
|
|
88
|
+
* ```
|
|
89
|
+
*
|
|
90
|
+
* ## Return Values
|
|
91
|
+
* The following properties are returned from the hook:
|
|
92
|
+
*
|
|
93
|
+
* <PropertyReference name="messages" type="Message[]">
|
|
94
|
+
* The messages currently in the chat in AG-UI format
|
|
95
|
+
* </PropertyReference>
|
|
96
|
+
*
|
|
97
|
+
* <PropertyReference name="sendMessage" type="(message: Message, options?) => Promise<void>">
|
|
98
|
+
* Send a new message to the chat and trigger AI response
|
|
99
|
+
* </PropertyReference>
|
|
100
|
+
*
|
|
101
|
+
* <PropertyReference name="setMessages" type="(messages: Message[] | DeprecatedGqlMessage[]) => void">
|
|
102
|
+
* Replace all messages in the chat with new array
|
|
103
|
+
* </PropertyReference>
|
|
104
|
+
*
|
|
105
|
+
* <PropertyReference name="deleteMessage" type="(messageId: string) => void">
|
|
106
|
+
* Remove a specific message by ID from the chat
|
|
107
|
+
* </PropertyReference>
|
|
108
|
+
*
|
|
109
|
+
* <PropertyReference name="reloadMessages" type="(messageId: string) => Promise<void>">
|
|
110
|
+
* Regenerate the response for a specific message by ID
|
|
111
|
+
* </PropertyReference>
|
|
112
|
+
*
|
|
113
|
+
* <PropertyReference name="stopGeneration" type="() => void">
|
|
114
|
+
* Stop the current message generation process
|
|
115
|
+
* </PropertyReference>
|
|
116
|
+
*
|
|
117
|
+
* <PropertyReference name="reset" type="() => void">
|
|
118
|
+
* Clear all messages and reset chat state completely
|
|
119
|
+
* </PropertyReference>
|
|
120
|
+
*
|
|
121
|
+
* <PropertyReference name="isLoading" type="boolean">
|
|
122
|
+
* Whether the chat is currently generating a response
|
|
123
|
+
* </PropertyReference>
|
|
124
|
+
*
|
|
125
|
+
* <PropertyReference name="runChatCompletion" type="() => Promise<Message[]>">
|
|
126
|
+
* Manually trigger chat completion for advanced usage
|
|
127
|
+
* </PropertyReference>
|
|
128
|
+
*
|
|
129
|
+
* <PropertyReference name="mcpServers" type="MCPServerConfig[]">
|
|
130
|
+
* Array of Model Context Protocol server configurations
|
|
131
|
+
* </PropertyReference>
|
|
132
|
+
*
|
|
133
|
+
* <PropertyReference name="setMcpServers" type="(servers: MCPServerConfig[]) => void">
|
|
134
|
+
* Update MCP server configurations for enhanced context
|
|
135
|
+
* </PropertyReference>
|
|
136
|
+
*
|
|
137
|
+
* <PropertyReference name="suggestions" type="SuggestionItem[]">
|
|
138
|
+
* Current suggestions array for reading or manual control
|
|
139
|
+
* </PropertyReference>
|
|
140
|
+
*
|
|
141
|
+
* <PropertyReference name="setSuggestions" type="(suggestions: SuggestionItem[]) => void">
|
|
142
|
+
* Manually set suggestions for custom workflows
|
|
143
|
+
* </PropertyReference>
|
|
144
|
+
*
|
|
145
|
+
* <PropertyReference name="generateSuggestions" type="() => Promise<void>">
|
|
146
|
+
* Trigger AI-powered suggestion generation using configured settings
|
|
147
|
+
* </PropertyReference>
|
|
148
|
+
*
|
|
149
|
+
* <PropertyReference name="resetSuggestions" type="() => void">
|
|
150
|
+
* Clear all current suggestions and reset generation state
|
|
151
|
+
* </PropertyReference>
|
|
152
|
+
*
|
|
153
|
+
* <PropertyReference name="isLoadingSuggestions" type="boolean">
|
|
154
|
+
* Whether suggestions are currently being generated
|
|
155
|
+
* </PropertyReference>
|
|
156
|
+
*
|
|
157
|
+
* <PropertyReference name="interrupt" type="string | React.ReactElement | null">
|
|
158
|
+
* Interrupt content for human-in-the-loop workflows
|
|
159
|
+
* </PropertyReference>
|
|
160
|
+
*/
|
|
161
|
+
import { useEffect } from "react";
|
|
162
|
+
import { useCopilotContext } from "../context/copilot-context";
|
|
163
|
+
import {
|
|
164
|
+
useCopilotChatInternal,
|
|
165
|
+
defaultSystemMessage,
|
|
166
|
+
UseCopilotChatOptions as UseCopilotChatOptions_c,
|
|
167
|
+
UseCopilotChatReturn as UseCopilotChatReturn_c,
|
|
168
|
+
MCPServerConfig,
|
|
169
|
+
} from "./use-copilot-chat_internal";
|
|
170
|
+
|
|
171
|
+
import {
|
|
172
|
+
ErrorVisibility,
|
|
173
|
+
Severity,
|
|
174
|
+
CopilotKitError,
|
|
175
|
+
CopilotKitErrorCode,
|
|
176
|
+
styledConsole,
|
|
177
|
+
} from "@copilotkit/shared";
|
|
178
|
+
|
|
179
|
+
// Non-functional fallback implementation
|
|
180
|
+
const createNonFunctionalReturn = (): UseCopilotChatReturn_c => ({
|
|
181
|
+
visibleMessages: [],
|
|
182
|
+
messages: [],
|
|
183
|
+
sendMessage: async () => {},
|
|
184
|
+
appendMessage: async () => {},
|
|
185
|
+
setMessages: () => {},
|
|
186
|
+
deleteMessage: () => {},
|
|
187
|
+
reloadMessages: async () => {},
|
|
188
|
+
stopGeneration: () => {},
|
|
189
|
+
reset: () => {},
|
|
190
|
+
isLoading: false,
|
|
191
|
+
isAvailable: false,
|
|
192
|
+
runChatCompletion: async () => [],
|
|
193
|
+
mcpServers: [],
|
|
194
|
+
setMcpServers: () => {},
|
|
195
|
+
suggestions: [],
|
|
196
|
+
setSuggestions: () => {},
|
|
197
|
+
generateSuggestions: async () => {},
|
|
198
|
+
resetSuggestions: () => {},
|
|
199
|
+
isLoadingSuggestions: false,
|
|
200
|
+
interrupt: null,
|
|
201
|
+
});
|
|
202
|
+
/**
|
|
203
|
+
* Enterprise React hook that provides complete chat functionality for fully custom UI implementations.
|
|
204
|
+
* Includes all advanced features like direct message access, suggestions array, interrupt handling, and MCP support.
|
|
205
|
+
*
|
|
206
|
+
* **Requires a publicApiKey** - Sign up for free at https://cloud.copilotkit.ai/
|
|
207
|
+
*
|
|
208
|
+
* @param options - Configuration options for the chat
|
|
209
|
+
* @returns Complete chat interface with all enterprise features
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```tsx
|
|
213
|
+
* const { messages, sendMessage, suggestions, interrupt } = useCopilotChatHeadless_c();
|
|
214
|
+
* ```
|
|
215
|
+
*/
|
|
216
|
+
function useCopilotChatHeadless_c(options: UseCopilotChatOptions_c = {}): UseCopilotChatReturn_c {
|
|
217
|
+
const { copilotApiConfig, setBannerError } = useCopilotContext();
|
|
218
|
+
|
|
219
|
+
// Check if publicApiKey is available
|
|
220
|
+
const hasPublicApiKey = Boolean(copilotApiConfig.publicApiKey);
|
|
221
|
+
|
|
222
|
+
// Always call the internal hook (follows rules of hooks)
|
|
223
|
+
const internalResult = useCopilotChatInternal(options);
|
|
224
|
+
|
|
225
|
+
// Set banner error when no public API key is provided
|
|
226
|
+
useEffect(() => {
|
|
227
|
+
if (!hasPublicApiKey) {
|
|
228
|
+
setBannerError(
|
|
229
|
+
new CopilotKitError({
|
|
230
|
+
message:
|
|
231
|
+
// add link to documentation here
|
|
232
|
+
"You're using useCopilotChatHeadless_c, a premium-only feature, which offers extensive headless chat capabilities. To continue, you'll need to provide a free public license key.",
|
|
233
|
+
code: CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR,
|
|
234
|
+
severity: Severity.WARNING,
|
|
235
|
+
visibility: ErrorVisibility.BANNER,
|
|
236
|
+
}),
|
|
237
|
+
);
|
|
238
|
+
styledConsole.logCopilotKitPlatformMessage();
|
|
239
|
+
} else {
|
|
240
|
+
setBannerError(null); // Clear banner when API key is provided
|
|
241
|
+
}
|
|
242
|
+
}, [hasPublicApiKey]); // Removed setBannerError dependency
|
|
243
|
+
|
|
244
|
+
// Return internal result if publicApiKey is available, otherwise return fallback
|
|
245
|
+
if (hasPublicApiKey) {
|
|
246
|
+
return internalResult;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// Return non-functional fallback when no publicApiKey
|
|
250
|
+
return createNonFunctionalReturn();
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export { defaultSystemMessage, useCopilotChatHeadless_c };
|
|
254
|
+
export type { UseCopilotChatOptions_c, UseCopilotChatReturn_c, MCPServerConfig };
|
|
255
|
+
|
|
256
|
+
const noKeyWarning = () => {
|
|
257
|
+
styledConsole.logCopilotKitPlatformMessage();
|
|
258
|
+
};
|