@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,978 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defProps = Object.defineProperties;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
10
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
+
var __spreadValues = (a, b) => {
|
|
14
|
+
for (var prop in b || (b = {}))
|
|
15
|
+
if (__hasOwnProp.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
if (__getOwnPropSymbols)
|
|
18
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
+
if (__propIsEnum.call(b, prop))
|
|
20
|
+
__defNormalProp(a, prop, b[prop]);
|
|
21
|
+
}
|
|
22
|
+
return a;
|
|
23
|
+
};
|
|
24
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
|
+
var __objRest = (source, exclude) => {
|
|
26
|
+
var target = {};
|
|
27
|
+
for (var prop in source)
|
|
28
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
if (source != null && __getOwnPropSymbols)
|
|
31
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
32
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
33
|
+
target[prop] = source[prop];
|
|
34
|
+
}
|
|
35
|
+
return target;
|
|
36
|
+
};
|
|
37
|
+
var __export = (target, all) => {
|
|
38
|
+
for (var name in all)
|
|
39
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
40
|
+
};
|
|
41
|
+
var __copyProps = (to, from, except, desc) => {
|
|
42
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
43
|
+
for (let key of __getOwnPropNames(from))
|
|
44
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
45
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
46
|
+
}
|
|
47
|
+
return to;
|
|
48
|
+
};
|
|
49
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
50
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
51
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
52
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
53
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
54
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
55
|
+
mod
|
|
56
|
+
));
|
|
57
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
58
|
+
var __async = (__this, __arguments, generator) => {
|
|
59
|
+
return new Promise((resolve, reject) => {
|
|
60
|
+
var fulfilled = (value) => {
|
|
61
|
+
try {
|
|
62
|
+
step(generator.next(value));
|
|
63
|
+
} catch (e) {
|
|
64
|
+
reject(e);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
var rejected = (value) => {
|
|
68
|
+
try {
|
|
69
|
+
step(generator.throw(value));
|
|
70
|
+
} catch (e) {
|
|
71
|
+
reject(e);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
75
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// src/hooks/use-copilot-chat.ts
|
|
80
|
+
var use_copilot_chat_exports = {};
|
|
81
|
+
__export(use_copilot_chat_exports, {
|
|
82
|
+
useCopilotChat: () => useCopilotChat
|
|
83
|
+
});
|
|
84
|
+
module.exports = __toCommonJS(use_copilot_chat_exports);
|
|
85
|
+
|
|
86
|
+
// src/hooks/use-copilot-chat_internal.ts
|
|
87
|
+
var import_react13 = require("react");
|
|
88
|
+
|
|
89
|
+
// src/context/copilot-context.tsx
|
|
90
|
+
var import_react = __toESM(require("react"));
|
|
91
|
+
var emptyCopilotContext = {
|
|
92
|
+
actions: {},
|
|
93
|
+
setAction: () => {
|
|
94
|
+
},
|
|
95
|
+
removeAction: () => {
|
|
96
|
+
},
|
|
97
|
+
setRegisteredActions: () => "",
|
|
98
|
+
removeRegisteredAction: () => {
|
|
99
|
+
},
|
|
100
|
+
chatComponentsCache: { current: { actions: {}, coAgentStateRenders: {} } },
|
|
101
|
+
getContextString: (documents, categories) => returnAndThrowInDebug(""),
|
|
102
|
+
addContext: () => "",
|
|
103
|
+
removeContext: () => {
|
|
104
|
+
},
|
|
105
|
+
getAllContext: () => [],
|
|
106
|
+
getFunctionCallHandler: () => returnAndThrowInDebug(() => __async(void 0, null, function* () {
|
|
107
|
+
})),
|
|
108
|
+
isLoading: false,
|
|
109
|
+
setIsLoading: () => returnAndThrowInDebug(false),
|
|
110
|
+
chatInstructions: "",
|
|
111
|
+
setChatInstructions: () => returnAndThrowInDebug(""),
|
|
112
|
+
additionalInstructions: [],
|
|
113
|
+
setAdditionalInstructions: () => returnAndThrowInDebug([]),
|
|
114
|
+
getDocumentsContext: (categories) => returnAndThrowInDebug([]),
|
|
115
|
+
addDocumentContext: () => returnAndThrowInDebug(""),
|
|
116
|
+
removeDocumentContext: () => {
|
|
117
|
+
},
|
|
118
|
+
copilotApiConfig: new class {
|
|
119
|
+
get chatApiEndpoint() {
|
|
120
|
+
throw new Error("Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!");
|
|
121
|
+
}
|
|
122
|
+
get headers() {
|
|
123
|
+
return {};
|
|
124
|
+
}
|
|
125
|
+
get body() {
|
|
126
|
+
return {};
|
|
127
|
+
}
|
|
128
|
+
}(),
|
|
129
|
+
chatSuggestionConfiguration: {},
|
|
130
|
+
addChatSuggestionConfiguration: () => {
|
|
131
|
+
},
|
|
132
|
+
removeChatSuggestionConfiguration: () => {
|
|
133
|
+
},
|
|
134
|
+
showDevConsole: false,
|
|
135
|
+
coagentStates: {},
|
|
136
|
+
setCoagentStates: () => {
|
|
137
|
+
},
|
|
138
|
+
coagentStatesRef: { current: {} },
|
|
139
|
+
setCoagentStatesWithRef: () => {
|
|
140
|
+
},
|
|
141
|
+
agentSession: null,
|
|
142
|
+
setAgentSession: () => {
|
|
143
|
+
},
|
|
144
|
+
forwardedParameters: {},
|
|
145
|
+
agentLock: null,
|
|
146
|
+
threadId: "",
|
|
147
|
+
setThreadId: () => {
|
|
148
|
+
},
|
|
149
|
+
runId: null,
|
|
150
|
+
setRunId: () => {
|
|
151
|
+
},
|
|
152
|
+
chatAbortControllerRef: { current: null },
|
|
153
|
+
availableAgents: [],
|
|
154
|
+
extensions: {},
|
|
155
|
+
setExtensions: () => {
|
|
156
|
+
},
|
|
157
|
+
interruptActions: {},
|
|
158
|
+
setInterruptAction: () => {
|
|
159
|
+
},
|
|
160
|
+
removeInterruptAction: () => {
|
|
161
|
+
},
|
|
162
|
+
interruptEventQueue: {},
|
|
163
|
+
addInterruptEvent: () => {
|
|
164
|
+
},
|
|
165
|
+
resolveInterruptEvent: () => {
|
|
166
|
+
},
|
|
167
|
+
onError: () => {
|
|
168
|
+
},
|
|
169
|
+
bannerError: null,
|
|
170
|
+
setBannerError: () => {
|
|
171
|
+
},
|
|
172
|
+
internalErrorHandlers: {},
|
|
173
|
+
setInternalErrorHandler: () => {
|
|
174
|
+
},
|
|
175
|
+
removeInternalErrorHandler: () => {
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
var CopilotContext = import_react.default.createContext(emptyCopilotContext);
|
|
179
|
+
function useCopilotContext() {
|
|
180
|
+
const context = import_react.default.useContext(CopilotContext);
|
|
181
|
+
if (context === emptyCopilotContext) {
|
|
182
|
+
throw new Error("Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!");
|
|
183
|
+
}
|
|
184
|
+
return context;
|
|
185
|
+
}
|
|
186
|
+
function returnAndThrowInDebug(_value) {
|
|
187
|
+
throw new Error("Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!");
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// src/components/error-boundary/error-utils.tsx
|
|
191
|
+
var import_react3 = require("react");
|
|
192
|
+
|
|
193
|
+
// src/components/toast/toast-provider.tsx
|
|
194
|
+
var import_react2 = require("react");
|
|
195
|
+
var import_shared = require("@copilotkit/shared");
|
|
196
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
197
|
+
var ToastContext = (0, import_react2.createContext)(void 0);
|
|
198
|
+
function useToast() {
|
|
199
|
+
const context = (0, import_react2.useContext)(ToastContext);
|
|
200
|
+
if (!context) {
|
|
201
|
+
throw new Error("useToast must be used within a ToastProvider");
|
|
202
|
+
}
|
|
203
|
+
return context;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// src/components/toast/exclamation-mark-icon.tsx
|
|
207
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
208
|
+
var ExclamationMarkIcon = ({
|
|
209
|
+
className,
|
|
210
|
+
style
|
|
211
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
212
|
+
"svg",
|
|
213
|
+
{
|
|
214
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
215
|
+
width: "24",
|
|
216
|
+
height: "24",
|
|
217
|
+
viewBox: "0 0 24 24",
|
|
218
|
+
fill: "none",
|
|
219
|
+
stroke: "currentColor",
|
|
220
|
+
strokeWidth: "2",
|
|
221
|
+
strokeLinecap: "round",
|
|
222
|
+
strokeLinejoin: "round",
|
|
223
|
+
className: `lucide lucide-circle-alert ${className ? className : ""}`,
|
|
224
|
+
style,
|
|
225
|
+
children: [
|
|
226
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
|
|
227
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "12", x2: "12", y1: "8", y2: "12" }),
|
|
228
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "12", x2: "12.01", y1: "16", y2: "16" })
|
|
229
|
+
]
|
|
230
|
+
}
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
// src/components/error-boundary/error-utils.tsx
|
|
234
|
+
var import_react_markdown = __toESM(require("react-markdown"));
|
|
235
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
236
|
+
function ErrorToast({ errors }) {
|
|
237
|
+
const errorsToRender = errors.map((error, idx) => {
|
|
238
|
+
var _a, _b, _c;
|
|
239
|
+
const originalError = "extensions" in error ? (_a = error.extensions) == null ? void 0 : _a.originalError : {};
|
|
240
|
+
const message = (_b = originalError == null ? void 0 : originalError.message) != null ? _b : error.message;
|
|
241
|
+
const code = "extensions" in error ? (_c = error.extensions) == null ? void 0 : _c.code : null;
|
|
242
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
243
|
+
"div",
|
|
244
|
+
{
|
|
245
|
+
style: {
|
|
246
|
+
marginTop: idx === 0 ? 0 : 10,
|
|
247
|
+
marginBottom: 14
|
|
248
|
+
},
|
|
249
|
+
children: [
|
|
250
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ExclamationMarkIcon, { style: { marginBottom: 4 } }),
|
|
251
|
+
code && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
252
|
+
"div",
|
|
253
|
+
{
|
|
254
|
+
style: {
|
|
255
|
+
fontWeight: "600",
|
|
256
|
+
marginBottom: 4
|
|
257
|
+
},
|
|
258
|
+
children: [
|
|
259
|
+
"Copilot Runtime Error:",
|
|
260
|
+
" ",
|
|
261
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { fontFamily: "monospace", fontWeight: "normal" }, children: code })
|
|
262
|
+
]
|
|
263
|
+
}
|
|
264
|
+
),
|
|
265
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_markdown.default, { children: message })
|
|
266
|
+
]
|
|
267
|
+
},
|
|
268
|
+
idx
|
|
269
|
+
);
|
|
270
|
+
});
|
|
271
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
272
|
+
"div",
|
|
273
|
+
{
|
|
274
|
+
style: {
|
|
275
|
+
fontSize: "13px",
|
|
276
|
+
maxWidth: "600px"
|
|
277
|
+
},
|
|
278
|
+
children: [
|
|
279
|
+
errorsToRender,
|
|
280
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { fontSize: "11px", opacity: 0.75 }, children: "NOTE: This error only displays during local development." })
|
|
281
|
+
]
|
|
282
|
+
}
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
function useErrorToast() {
|
|
286
|
+
const { addToast } = useToast();
|
|
287
|
+
return (0, import_react3.useCallback)(
|
|
288
|
+
(errors) => {
|
|
289
|
+
const errorId = errors.map((err) => {
|
|
290
|
+
var _a, _b;
|
|
291
|
+
const message = "extensions" in err ? ((_b = (_a = err.extensions) == null ? void 0 : _a.originalError) == null ? void 0 : _b.message) || err.message : err.message;
|
|
292
|
+
const stack = err.stack || "";
|
|
293
|
+
return btoa(message + stack).slice(0, 32);
|
|
294
|
+
}).join("|");
|
|
295
|
+
addToast({
|
|
296
|
+
type: "error",
|
|
297
|
+
id: errorId,
|
|
298
|
+
// Toast libraries typically dedupe by id
|
|
299
|
+
message: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ErrorToast, { errors })
|
|
300
|
+
});
|
|
301
|
+
},
|
|
302
|
+
[addToast]
|
|
303
|
+
);
|
|
304
|
+
}
|
|
305
|
+
function useAsyncCallback(callback, deps) {
|
|
306
|
+
const addErrorToast = useErrorToast();
|
|
307
|
+
return (0, import_react3.useCallback)((...args) => __async(this, null, function* () {
|
|
308
|
+
try {
|
|
309
|
+
return yield callback(...args);
|
|
310
|
+
} catch (error) {
|
|
311
|
+
console.error("Error in async callback:", error);
|
|
312
|
+
addErrorToast([error]);
|
|
313
|
+
throw error;
|
|
314
|
+
}
|
|
315
|
+
}), deps);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// src/hooks/use-copilot-chat_internal.ts
|
|
319
|
+
var import_runtime_client_gql2 = require("@copilotkit/runtime-client-gql");
|
|
320
|
+
|
|
321
|
+
// src/context/coagent-state-renders-context.tsx
|
|
322
|
+
var import_react4 = require("react");
|
|
323
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
324
|
+
var CoAgentStateRendersContext = (0, import_react4.createContext)(
|
|
325
|
+
void 0
|
|
326
|
+
);
|
|
327
|
+
function useCoAgentStateRenders() {
|
|
328
|
+
const context = (0, import_react4.useContext)(CoAgentStateRendersContext);
|
|
329
|
+
if (!context) {
|
|
330
|
+
throw new Error("useCoAgentStateRenders must be used within CoAgentStateRendersProvider");
|
|
331
|
+
}
|
|
332
|
+
return context;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// src/hooks/use-langgraph-interrupt-render.ts
|
|
336
|
+
var import_react7 = __toESM(require("react"));
|
|
337
|
+
var import_runtime_client_gql = require("@copilotkit/runtime-client-gql");
|
|
338
|
+
var import_shared2 = require("@copilotkit/shared");
|
|
339
|
+
|
|
340
|
+
// src/hooks/use-agent-nodename.ts
|
|
341
|
+
var import_react5 = require("react");
|
|
342
|
+
var import_react6 = require("@copilotkitnext/react");
|
|
343
|
+
function useAgentNodeName(agentName) {
|
|
344
|
+
const { agent } = (0, import_react6.useAgent)({ agentId: agentName });
|
|
345
|
+
const nodeNameRef = (0, import_react5.useRef)("start");
|
|
346
|
+
(0, import_react5.useEffect)(() => {
|
|
347
|
+
if (!agent)
|
|
348
|
+
return;
|
|
349
|
+
const subscriber = {
|
|
350
|
+
onStepStartedEvent: ({ event }) => {
|
|
351
|
+
nodeNameRef.current = event.stepName;
|
|
352
|
+
},
|
|
353
|
+
onRunStartedEvent: () => {
|
|
354
|
+
nodeNameRef.current = "start";
|
|
355
|
+
},
|
|
356
|
+
onRunFinishedEvent: () => {
|
|
357
|
+
nodeNameRef.current = "end";
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
const subscription = agent.subscribe(subscriber);
|
|
361
|
+
return () => {
|
|
362
|
+
subscription.unsubscribe();
|
|
363
|
+
};
|
|
364
|
+
}, [agent]);
|
|
365
|
+
return nodeNameRef.current;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
// src/hooks/use-langgraph-interrupt-render.ts
|
|
369
|
+
var import_react8 = require("@copilotkitnext/react");
|
|
370
|
+
var InterruptRenderer = ({ event, result, render, resolve }) => {
|
|
371
|
+
return render({ event, result, resolve });
|
|
372
|
+
};
|
|
373
|
+
function useLangGraphInterruptRender(agent) {
|
|
374
|
+
var _a;
|
|
375
|
+
const {
|
|
376
|
+
interruptActions,
|
|
377
|
+
agentSession,
|
|
378
|
+
threadId,
|
|
379
|
+
interruptEventQueue,
|
|
380
|
+
addInterruptEvent,
|
|
381
|
+
resolveInterruptEvent
|
|
382
|
+
} = useCopilotContext();
|
|
383
|
+
const existingConfig = (0, import_react8.useCopilotChatConfiguration)();
|
|
384
|
+
const resolvedAgentId = (_a = existingConfig == null ? void 0 : existingConfig.agentId) != null ? _a : "default";
|
|
385
|
+
const nodeName = useAgentNodeName(resolvedAgentId);
|
|
386
|
+
(0, import_react7.useEffect)(() => {
|
|
387
|
+
if (!agent)
|
|
388
|
+
return;
|
|
389
|
+
let localInterrupt = null;
|
|
390
|
+
const subscriber = {
|
|
391
|
+
onCustomEvent: ({ event }) => {
|
|
392
|
+
if (event.name === "on_interrupt") {
|
|
393
|
+
const eventData = {
|
|
394
|
+
name: import_runtime_client_gql.MetaEventName.LangGraphInterruptEvent,
|
|
395
|
+
type: event.type,
|
|
396
|
+
value: (0, import_shared2.parseJson)(event.value, event.value)
|
|
397
|
+
};
|
|
398
|
+
const eventId = (0, import_shared2.dataToUUID)(eventData, "interruptEvents");
|
|
399
|
+
localInterrupt = {
|
|
400
|
+
eventId,
|
|
401
|
+
threadId,
|
|
402
|
+
event: eventData
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
},
|
|
406
|
+
onRunStartedEvent: () => {
|
|
407
|
+
localInterrupt = null;
|
|
408
|
+
},
|
|
409
|
+
onRunFinalized: () => {
|
|
410
|
+
if (localInterrupt) {
|
|
411
|
+
addInterruptEvent(localInterrupt);
|
|
412
|
+
localInterrupt = null;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
};
|
|
416
|
+
const { unsubscribe } = agent.subscribe(subscriber);
|
|
417
|
+
return () => {
|
|
418
|
+
unsubscribe();
|
|
419
|
+
};
|
|
420
|
+
}, [agent, threadId]);
|
|
421
|
+
const handleResolve = (0, import_react7.useCallback)(
|
|
422
|
+
(eventId, response) => {
|
|
423
|
+
agent == null ? void 0 : agent.runAgent({
|
|
424
|
+
forwardedProps: {
|
|
425
|
+
command: {
|
|
426
|
+
resume: response
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
resolveInterruptEvent(threadId, eventId, response != null ? response : "");
|
|
431
|
+
},
|
|
432
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
433
|
+
[agent, threadId]
|
|
434
|
+
);
|
|
435
|
+
return (0, import_react7.useMemo)(() => {
|
|
436
|
+
const eventQueue = interruptEventQueue[threadId] || [];
|
|
437
|
+
const currentQueuedEvent = eventQueue.find((qe) => !qe.event.response);
|
|
438
|
+
if (!currentQueuedEvent || !agentSession)
|
|
439
|
+
return null;
|
|
440
|
+
const allActions = Object.values(interruptActions);
|
|
441
|
+
const matchingAction = allActions.find((action) => {
|
|
442
|
+
if (!action.enabled)
|
|
443
|
+
return true;
|
|
444
|
+
return action.enabled({
|
|
445
|
+
eventValue: currentQueuedEvent.event.value,
|
|
446
|
+
agentMetadata: __spreadProps(__spreadValues({}, agentSession), {
|
|
447
|
+
nodeName
|
|
448
|
+
})
|
|
449
|
+
});
|
|
450
|
+
});
|
|
451
|
+
if (!matchingAction)
|
|
452
|
+
return null;
|
|
453
|
+
const { render, handler } = matchingAction;
|
|
454
|
+
const resolveInterrupt = (response) => {
|
|
455
|
+
handleResolve(currentQueuedEvent.eventId, response);
|
|
456
|
+
};
|
|
457
|
+
let result = null;
|
|
458
|
+
if (handler) {
|
|
459
|
+
result = handler({
|
|
460
|
+
event: currentQueuedEvent.event,
|
|
461
|
+
resolve: resolveInterrupt
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
if (!render)
|
|
465
|
+
return null;
|
|
466
|
+
return import_react7.default.createElement(InterruptRenderer, {
|
|
467
|
+
event: currentQueuedEvent.event,
|
|
468
|
+
result,
|
|
469
|
+
render,
|
|
470
|
+
resolve: resolveInterrupt
|
|
471
|
+
});
|
|
472
|
+
}, [interruptActions, interruptEventQueue, threadId, agentSession, handleResolve]);
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
// src/hooks/use-copilot-chat_internal.ts
|
|
476
|
+
var import_react14 = require("@copilotkitnext/react");
|
|
477
|
+
|
|
478
|
+
// src/hooks/use-lazy-tool-renderer.tsx
|
|
479
|
+
var import_react9 = require("@copilotkitnext/react");
|
|
480
|
+
var import_react10 = require("react");
|
|
481
|
+
function useLazyToolRenderer() {
|
|
482
|
+
const renderToolCall = (0, import_react9.useRenderToolCall)();
|
|
483
|
+
return (0, import_react10.useCallback)(
|
|
484
|
+
(message, messages) => {
|
|
485
|
+
var _a;
|
|
486
|
+
if (!((_a = message == null ? void 0 : message.toolCalls) == null ? void 0 : _a.length))
|
|
487
|
+
return null;
|
|
488
|
+
const toolCall = message.toolCalls[0];
|
|
489
|
+
if (!toolCall)
|
|
490
|
+
return null;
|
|
491
|
+
const toolMessage = messages == null ? void 0 : messages.find(
|
|
492
|
+
(m) => m.role === "tool" && m.toolCallId === toolCall.id
|
|
493
|
+
);
|
|
494
|
+
return () => renderToolCall({
|
|
495
|
+
toolCall,
|
|
496
|
+
toolMessage
|
|
497
|
+
});
|
|
498
|
+
},
|
|
499
|
+
[renderToolCall]
|
|
500
|
+
);
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
// src/hooks/use-copilot-chat_internal.ts
|
|
504
|
+
var import_client = require("@ag-ui/client");
|
|
505
|
+
|
|
506
|
+
// src/hooks/use-coagent-state-render-bridge.tsx
|
|
507
|
+
var import_react11 = require("@copilotkitnext/react");
|
|
508
|
+
var import_react12 = require("react");
|
|
509
|
+
var import_shared3 = require("@copilotkit/shared");
|
|
510
|
+
function getStateWithoutConstantKeys(state) {
|
|
511
|
+
if (!state)
|
|
512
|
+
return {};
|
|
513
|
+
const _a = state, { messages, tools, copilotkit } = _a, stateWithoutConstantKeys = __objRest(_a, ["messages", "tools", "copilotkit"]);
|
|
514
|
+
return stateWithoutConstantKeys;
|
|
515
|
+
}
|
|
516
|
+
function areStatesEquals(a, b) {
|
|
517
|
+
if (a && !b || !a && b)
|
|
518
|
+
return false;
|
|
519
|
+
const _a = a, { messages, tools, copilotkit } = _a, aWithoutConstantKeys = __objRest(_a, ["messages", "tools", "copilotkit"]);
|
|
520
|
+
const _b = b, {
|
|
521
|
+
messages: bMessages,
|
|
522
|
+
tools: bTools,
|
|
523
|
+
copilotkit: bCopilotkit
|
|
524
|
+
} = _b, bWithoutConstantKeys = __objRest(_b, [
|
|
525
|
+
"messages",
|
|
526
|
+
"tools",
|
|
527
|
+
"copilotkit"
|
|
528
|
+
]);
|
|
529
|
+
return JSON.stringify(aWithoutConstantKeys) === JSON.stringify(bWithoutConstantKeys);
|
|
530
|
+
}
|
|
531
|
+
function useCoagentStateRenderBridge(agentId, props) {
|
|
532
|
+
var _a;
|
|
533
|
+
const { stateSnapshot, messageIndexInRun, message } = props;
|
|
534
|
+
const { coAgentStateRenders, claimsRef } = useCoAgentStateRenders();
|
|
535
|
+
const { agent } = (0, import_react11.useAgent)({ agentId });
|
|
536
|
+
const [nodeName, setNodeName] = (0, import_react12.useState)(void 0);
|
|
537
|
+
const runId = (_a = props.runId) != null ? _a : message.runId;
|
|
538
|
+
const effectiveRunId = runId || "pending";
|
|
539
|
+
(0, import_react12.useEffect)(() => {
|
|
540
|
+
if (!agent)
|
|
541
|
+
return;
|
|
542
|
+
const subscriber = {
|
|
543
|
+
onStepStartedEvent: ({ event }) => {
|
|
544
|
+
if (event.stepName !== nodeName) {
|
|
545
|
+
setNodeName(event.stepName);
|
|
546
|
+
}
|
|
547
|
+
},
|
|
548
|
+
onStepFinishedEvent: ({ event }) => {
|
|
549
|
+
if (event.stepName === nodeName) {
|
|
550
|
+
setNodeName(void 0);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
};
|
|
554
|
+
const { unsubscribe } = agent.subscribe(subscriber);
|
|
555
|
+
return () => {
|
|
556
|
+
unsubscribe();
|
|
557
|
+
};
|
|
558
|
+
}, [agentId, nodeName]);
|
|
559
|
+
const getStateRender = (0, import_react12.useCallback)(
|
|
560
|
+
(messageId) => {
|
|
561
|
+
return Object.entries(coAgentStateRenders).find(([stateRenderId, stateRender]) => {
|
|
562
|
+
if (claimsRef.current[messageId]) {
|
|
563
|
+
return stateRenderId === claimsRef.current[messageId].stateRenderId;
|
|
564
|
+
}
|
|
565
|
+
const matchingAgentName = stateRender.name === agentId;
|
|
566
|
+
const matchesNodeContext = stateRender.nodeName ? stateRender.nodeName === nodeName : true;
|
|
567
|
+
return matchingAgentName && matchesNodeContext;
|
|
568
|
+
});
|
|
569
|
+
},
|
|
570
|
+
[coAgentStateRenders, nodeName, agentId]
|
|
571
|
+
);
|
|
572
|
+
const handleRenderRequest = ({
|
|
573
|
+
stateRenderId,
|
|
574
|
+
messageId,
|
|
575
|
+
runId: runId2,
|
|
576
|
+
stateSnapshot: renderSnapshot
|
|
577
|
+
}) => {
|
|
578
|
+
if (claimsRef.current[messageId]) {
|
|
579
|
+
const canRender = claimsRef.current[messageId].stateRenderId === stateRenderId;
|
|
580
|
+
if (canRender && runId2 && (!claimsRef.current[messageId].runId || claimsRef.current[messageId].runId === "pending")) {
|
|
581
|
+
claimsRef.current[messageId].runId = runId2;
|
|
582
|
+
}
|
|
583
|
+
return canRender;
|
|
584
|
+
}
|
|
585
|
+
const renderClaimedByOtherMessage = Object.values(claimsRef.current).find(
|
|
586
|
+
(c) => c.stateRenderId === stateRenderId && (0, import_shared3.dataToUUID)(getStateWithoutConstantKeys(c.stateSnapshot)) === (0, import_shared3.dataToUUID)(getStateWithoutConstantKeys(renderSnapshot))
|
|
587
|
+
);
|
|
588
|
+
if (renderClaimedByOtherMessage) {
|
|
589
|
+
if (renderSnapshot && renderClaimedByOtherMessage.stateSnapshot && !areStatesEquals(renderClaimedByOtherMessage.stateSnapshot, renderSnapshot)) {
|
|
590
|
+
claimsRef.current[messageId] = { stateRenderId, runId: runId2 };
|
|
591
|
+
return true;
|
|
592
|
+
}
|
|
593
|
+
return false;
|
|
594
|
+
}
|
|
595
|
+
if (!runId2) {
|
|
596
|
+
return false;
|
|
597
|
+
}
|
|
598
|
+
claimsRef.current[messageId] = { stateRenderId, runId: runId2 };
|
|
599
|
+
return true;
|
|
600
|
+
};
|
|
601
|
+
return (0, import_react12.useMemo)(() => {
|
|
602
|
+
var _a2, _b, _c;
|
|
603
|
+
if (messageIndexInRun !== 0) {
|
|
604
|
+
return null;
|
|
605
|
+
}
|
|
606
|
+
const [stateRenderId, stateRender] = (_a2 = getStateRender(message.id)) != null ? _a2 : [];
|
|
607
|
+
if (!stateRender || !stateRenderId) {
|
|
608
|
+
return null;
|
|
609
|
+
}
|
|
610
|
+
const snapshot = stateSnapshot ? (0, import_shared3.parseJson)(stateSnapshot, stateSnapshot) : agent == null ? void 0 : agent.state;
|
|
611
|
+
const canRender = handleRenderRequest({
|
|
612
|
+
stateRenderId,
|
|
613
|
+
messageId: message.id,
|
|
614
|
+
runId: effectiveRunId,
|
|
615
|
+
stateSnapshot: snapshot
|
|
616
|
+
});
|
|
617
|
+
if (!canRender) {
|
|
618
|
+
return null;
|
|
619
|
+
}
|
|
620
|
+
if (snapshot && !claimsRef.current[message.id].locked) {
|
|
621
|
+
if (stateSnapshot) {
|
|
622
|
+
claimsRef.current[message.id].stateSnapshot = snapshot;
|
|
623
|
+
claimsRef.current[message.id].locked = true;
|
|
624
|
+
} else {
|
|
625
|
+
claimsRef.current[message.id].stateSnapshot = snapshot;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
if (stateRender.handler) {
|
|
629
|
+
stateRender.handler({
|
|
630
|
+
state: stateSnapshot ? (0, import_shared3.parseJson)(stateSnapshot, stateSnapshot) : (_b = agent == null ? void 0 : agent.state) != null ? _b : {},
|
|
631
|
+
nodeName: nodeName != null ? nodeName : ""
|
|
632
|
+
});
|
|
633
|
+
}
|
|
634
|
+
if (stateRender.render) {
|
|
635
|
+
const status = (agent == null ? void 0 : agent.isRunning) ? "inProgress" : "complete";
|
|
636
|
+
if (typeof stateRender.render === "string")
|
|
637
|
+
return stateRender.render;
|
|
638
|
+
return stateRender.render({
|
|
639
|
+
status,
|
|
640
|
+
// Always use state from claim, to make sure the state does not seem "wiped" for a fraction of a second
|
|
641
|
+
state: (_c = claimsRef.current[message.id].stateSnapshot) != null ? _c : {},
|
|
642
|
+
nodeName: nodeName != null ? nodeName : ""
|
|
643
|
+
});
|
|
644
|
+
}
|
|
645
|
+
}, [
|
|
646
|
+
getStateRender,
|
|
647
|
+
stateSnapshot,
|
|
648
|
+
agent == null ? void 0 : agent.state,
|
|
649
|
+
agent == null ? void 0 : agent.isRunning,
|
|
650
|
+
nodeName,
|
|
651
|
+
effectiveRunId,
|
|
652
|
+
message.id,
|
|
653
|
+
messageIndexInRun
|
|
654
|
+
]);
|
|
655
|
+
}
|
|
656
|
+
function CoAgentStateRenderBridge(props) {
|
|
657
|
+
return useCoagentStateRenderBridge(props.agentId, props);
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
// src/hooks/use-copilot-chat_internal.ts
|
|
661
|
+
function useCopilotChatInternal({
|
|
662
|
+
suggestions,
|
|
663
|
+
onInProgress,
|
|
664
|
+
onSubmitMessage,
|
|
665
|
+
onStopGeneration,
|
|
666
|
+
onReloadMessages
|
|
667
|
+
} = {}) {
|
|
668
|
+
var _a, _b, _c;
|
|
669
|
+
const { copilotkit } = (0, import_react14.useCopilotKit)();
|
|
670
|
+
const { threadId, agentSession } = useCopilotContext();
|
|
671
|
+
const existingConfig = (0, import_react14.useCopilotChatConfiguration)();
|
|
672
|
+
const [agentAvailable, setAgentAvailable] = (0, import_react13.useState)(false);
|
|
673
|
+
const resolvedAgentId = (_a = existingConfig == null ? void 0 : existingConfig.agentId) != null ? _a : "default";
|
|
674
|
+
const { agent } = (0, import_react14.useAgent)({ agentId: resolvedAgentId });
|
|
675
|
+
(0, import_react13.useEffect)(() => {
|
|
676
|
+
const connect = (agent2) => __async(this, null, function* () {
|
|
677
|
+
setAgentAvailable(false);
|
|
678
|
+
try {
|
|
679
|
+
yield copilotkit.connectAgent({ agent: agent2 });
|
|
680
|
+
setAgentAvailable(true);
|
|
681
|
+
} catch (error) {
|
|
682
|
+
if (error instanceof import_client.AGUIConnectNotImplementedError) {
|
|
683
|
+
} else {
|
|
684
|
+
throw error;
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
});
|
|
688
|
+
if (agent && (existingConfig == null ? void 0 : existingConfig.threadId) && agent.threadId !== existingConfig.threadId) {
|
|
689
|
+
agent.threadId = existingConfig.threadId;
|
|
690
|
+
connect(agent);
|
|
691
|
+
}
|
|
692
|
+
return () => {
|
|
693
|
+
};
|
|
694
|
+
}, [existingConfig == null ? void 0 : existingConfig.threadId, agent, copilotkit, resolvedAgentId]);
|
|
695
|
+
(0, import_react13.useEffect)(() => {
|
|
696
|
+
onInProgress == null ? void 0 : onInProgress(Boolean(agent == null ? void 0 : agent.isRunning));
|
|
697
|
+
}, [agent == null ? void 0 : agent.isRunning, onInProgress]);
|
|
698
|
+
const interrupt = useLangGraphInterruptRender(agent);
|
|
699
|
+
const reset = () => {
|
|
700
|
+
agent == null ? void 0 : agent.setMessages([]);
|
|
701
|
+
agent == null ? void 0 : agent.setState(null);
|
|
702
|
+
};
|
|
703
|
+
const deleteMessage = (0, import_react13.useCallback)(
|
|
704
|
+
(messageId) => {
|
|
705
|
+
var _a2;
|
|
706
|
+
const filteredMessages = ((_a2 = agent == null ? void 0 : agent.messages) != null ? _a2 : []).filter(
|
|
707
|
+
(message) => message.id !== messageId
|
|
708
|
+
);
|
|
709
|
+
agent == null ? void 0 : agent.setMessages(filteredMessages);
|
|
710
|
+
},
|
|
711
|
+
[agent == null ? void 0 : agent.setMessages, agent == null ? void 0 : agent.messages]
|
|
712
|
+
);
|
|
713
|
+
const latestDelete = useUpdatedRef(deleteMessage);
|
|
714
|
+
const latestDeleteFunc = (0, import_react13.useCallback)(
|
|
715
|
+
(messageId) => {
|
|
716
|
+
return latestDelete.current(messageId);
|
|
717
|
+
},
|
|
718
|
+
[latestDelete]
|
|
719
|
+
);
|
|
720
|
+
const currentSuggestions = (0, import_react14.useSuggestions)({ agentId: resolvedAgentId });
|
|
721
|
+
const reload = useAsyncCallback(
|
|
722
|
+
(reloadMessageId) => __async(this, null, function* () {
|
|
723
|
+
var _a2;
|
|
724
|
+
const messages = (_a2 = agent == null ? void 0 : agent.messages) != null ? _a2 : [];
|
|
725
|
+
const isLoading = false;
|
|
726
|
+
if (isLoading || messages.length === 0) {
|
|
727
|
+
return;
|
|
728
|
+
}
|
|
729
|
+
const reloadMessageIndex = messages.findIndex((msg) => msg.id === reloadMessageId);
|
|
730
|
+
if (reloadMessageIndex === -1) {
|
|
731
|
+
console.warn(`Message with id ${reloadMessageId} not found`);
|
|
732
|
+
return;
|
|
733
|
+
}
|
|
734
|
+
const reloadMessageRole = messages[reloadMessageIndex].role;
|
|
735
|
+
if (reloadMessageRole !== "assistant") {
|
|
736
|
+
console.warn(`Regenerate cannot be performed on ${reloadMessageRole} role`);
|
|
737
|
+
return;
|
|
738
|
+
}
|
|
739
|
+
let historyCutoff = [messages[0]];
|
|
740
|
+
if (messages.length > 2 && reloadMessageIndex !== 0) {
|
|
741
|
+
const lastUserMessageBeforeRegenerate = messages.slice(0, reloadMessageIndex).reverse().find((msg) => msg.role === "user");
|
|
742
|
+
if (!lastUserMessageBeforeRegenerate) {
|
|
743
|
+
historyCutoff = [messages[0]];
|
|
744
|
+
} else {
|
|
745
|
+
const indexOfLastUserMessageBeforeRegenerate = messages.findIndex(
|
|
746
|
+
(msg) => msg.id === lastUserMessageBeforeRegenerate.id
|
|
747
|
+
);
|
|
748
|
+
historyCutoff = messages.slice(0, indexOfLastUserMessageBeforeRegenerate + 1);
|
|
749
|
+
}
|
|
750
|
+
} else if (messages.length > 2 && reloadMessageIndex === 0) {
|
|
751
|
+
historyCutoff = [messages[0], messages[1]];
|
|
752
|
+
}
|
|
753
|
+
agent == null ? void 0 : agent.setMessages(historyCutoff);
|
|
754
|
+
if (agent) {
|
|
755
|
+
copilotkit.runAgent({ agent });
|
|
756
|
+
}
|
|
757
|
+
return;
|
|
758
|
+
}),
|
|
759
|
+
[agent == null ? void 0 : agent.setMessages, copilotkit == null ? void 0 : copilotkit.runAgent]
|
|
760
|
+
);
|
|
761
|
+
const latestSendMessageFunc = useAsyncCallback(
|
|
762
|
+
(message, options) => __async(this, null, function* () {
|
|
763
|
+
var _a2;
|
|
764
|
+
if (!agent)
|
|
765
|
+
return;
|
|
766
|
+
const followUp = (_a2 = options == null ? void 0 : options.followUp) != null ? _a2 : true;
|
|
767
|
+
if (options == null ? void 0 : options.clearSuggestions) {
|
|
768
|
+
copilotkit.clearSuggestions(resolvedAgentId);
|
|
769
|
+
}
|
|
770
|
+
agent == null ? void 0 : agent.addMessage(message);
|
|
771
|
+
if (followUp) {
|
|
772
|
+
try {
|
|
773
|
+
yield copilotkit.runAgent({ agent });
|
|
774
|
+
} catch (error) {
|
|
775
|
+
console.error("CopilotChat: runAgent failed", error);
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
if (onSubmitMessage) {
|
|
779
|
+
const content = typeof message.content === "string" ? message.content : message.content && "text" in message.content ? message.content.text : message.content && "filename" in message.content ? message.content.filename : "";
|
|
780
|
+
onSubmitMessage(content);
|
|
781
|
+
}
|
|
782
|
+
}),
|
|
783
|
+
[agent, copilotkit, resolvedAgentId, onSubmitMessage]
|
|
784
|
+
);
|
|
785
|
+
const latestAppendFunc = useAsyncCallback(
|
|
786
|
+
(message, options) => __async(this, null, function* () {
|
|
787
|
+
return latestSendMessageFunc((0, import_runtime_client_gql2.gqlToAGUI)([message])[0], options);
|
|
788
|
+
}),
|
|
789
|
+
[latestSendMessageFunc]
|
|
790
|
+
);
|
|
791
|
+
const latestSetMessagesFunc = (0, import_react13.useCallback)(
|
|
792
|
+
(messages) => {
|
|
793
|
+
var _a2, _b2;
|
|
794
|
+
if (messages.every((message) => message instanceof import_runtime_client_gql2.Message)) {
|
|
795
|
+
return (_a2 = agent == null ? void 0 : agent.setMessages) == null ? void 0 : _a2.call(agent, (0, import_runtime_client_gql2.gqlToAGUI)(messages));
|
|
796
|
+
}
|
|
797
|
+
return (_b2 = agent == null ? void 0 : agent.setMessages) == null ? void 0 : _b2.call(agent, messages);
|
|
798
|
+
},
|
|
799
|
+
[agent == null ? void 0 : agent.setMessages, agent]
|
|
800
|
+
);
|
|
801
|
+
const latestReload = useUpdatedRef(reload);
|
|
802
|
+
const latestReloadFunc = useAsyncCallback(
|
|
803
|
+
(messageId) => __async(this, null, function* () {
|
|
804
|
+
var _a2;
|
|
805
|
+
onReloadMessages == null ? void 0 : onReloadMessages({
|
|
806
|
+
messageId,
|
|
807
|
+
currentAgentName: agent == null ? void 0 : agent.agentId,
|
|
808
|
+
messages: (_a2 = agent == null ? void 0 : agent.messages) != null ? _a2 : []
|
|
809
|
+
});
|
|
810
|
+
return yield latestReload.current(messageId);
|
|
811
|
+
}),
|
|
812
|
+
[latestReload, agent, onReloadMessages]
|
|
813
|
+
);
|
|
814
|
+
const latestStopFunc = (0, import_react13.useCallback)(() => {
|
|
815
|
+
var _a2, _b2;
|
|
816
|
+
onStopGeneration == null ? void 0 : onStopGeneration({
|
|
817
|
+
currentAgentName: agent == null ? void 0 : agent.agentId,
|
|
818
|
+
messages: (_a2 = agent == null ? void 0 : agent.messages) != null ? _a2 : []
|
|
819
|
+
});
|
|
820
|
+
return (_b2 = agent == null ? void 0 : agent.abortRun) == null ? void 0 : _b2.call(agent);
|
|
821
|
+
}, [onStopGeneration, agent]);
|
|
822
|
+
const latestReset = useUpdatedRef(reset);
|
|
823
|
+
const latestResetFunc = (0, import_react13.useCallback)(() => {
|
|
824
|
+
return latestReset.current();
|
|
825
|
+
}, [latestReset]);
|
|
826
|
+
const lazyToolRendered = useLazyToolRenderer();
|
|
827
|
+
const renderCustomMessage = (0, import_react14.useRenderCustomMessages)();
|
|
828
|
+
const legacyCustomMessageRenderer = useLegacyCoagentRenderer({
|
|
829
|
+
copilotkit,
|
|
830
|
+
agent,
|
|
831
|
+
agentId: resolvedAgentId,
|
|
832
|
+
threadId: (_b = existingConfig == null ? void 0 : existingConfig.threadId) != null ? _b : threadId
|
|
833
|
+
});
|
|
834
|
+
const allMessages = (_c = agent == null ? void 0 : agent.messages) != null ? _c : [];
|
|
835
|
+
const resolvedMessages = (0, import_react13.useMemo)(() => {
|
|
836
|
+
let processedMessages = allMessages.map((message) => {
|
|
837
|
+
if (message.role !== "assistant") {
|
|
838
|
+
return message;
|
|
839
|
+
}
|
|
840
|
+
const lazyRendered = lazyToolRendered(message, allMessages);
|
|
841
|
+
if (lazyRendered) {
|
|
842
|
+
const renderedGenUi = lazyRendered();
|
|
843
|
+
if (renderedGenUi) {
|
|
844
|
+
return __spreadProps(__spreadValues({}, message), { generativeUI: () => renderedGenUi });
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
const bridgeRenderer = legacyCustomMessageRenderer || renderCustomMessage ? () => {
|
|
848
|
+
const customRender = renderCustomMessage == null ? void 0 : renderCustomMessage({
|
|
849
|
+
message,
|
|
850
|
+
position: "before"
|
|
851
|
+
});
|
|
852
|
+
if (customRender) {
|
|
853
|
+
return customRender;
|
|
854
|
+
}
|
|
855
|
+
return legacyCustomMessageRenderer == null ? void 0 : legacyCustomMessageRenderer({ message, position: "before" });
|
|
856
|
+
} : null;
|
|
857
|
+
if (bridgeRenderer) {
|
|
858
|
+
return __spreadProps(__spreadValues({}, message), { generativeUI: bridgeRenderer });
|
|
859
|
+
}
|
|
860
|
+
return message;
|
|
861
|
+
});
|
|
862
|
+
const hasAssistantMessages = processedMessages.some((msg) => msg.role === "assistant");
|
|
863
|
+
return processedMessages;
|
|
864
|
+
}, [
|
|
865
|
+
agent == null ? void 0 : agent.messages,
|
|
866
|
+
lazyToolRendered,
|
|
867
|
+
allMessages,
|
|
868
|
+
renderCustomMessage,
|
|
869
|
+
// legacyCustomMessageRenderer,
|
|
870
|
+
resolvedAgentId
|
|
871
|
+
]);
|
|
872
|
+
const renderedSuggestions = (0, import_react13.useMemo)(() => {
|
|
873
|
+
if (Array.isArray(suggestions)) {
|
|
874
|
+
return {
|
|
875
|
+
suggestions: suggestions.map((s) => __spreadProps(__spreadValues({}, s), { isLoading: false })),
|
|
876
|
+
isLoading: false
|
|
877
|
+
};
|
|
878
|
+
}
|
|
879
|
+
return currentSuggestions;
|
|
880
|
+
}, [suggestions, currentSuggestions]);
|
|
881
|
+
return {
|
|
882
|
+
messages: resolvedMessages,
|
|
883
|
+
sendMessage: latestSendMessageFunc,
|
|
884
|
+
appendMessage: latestAppendFunc,
|
|
885
|
+
setMessages: latestSetMessagesFunc,
|
|
886
|
+
reloadMessages: latestReloadFunc,
|
|
887
|
+
stopGeneration: latestStopFunc,
|
|
888
|
+
reset: latestResetFunc,
|
|
889
|
+
deleteMessage: latestDeleteFunc,
|
|
890
|
+
isAvailable: agentAvailable,
|
|
891
|
+
isLoading: Boolean(agent == null ? void 0 : agent.isRunning),
|
|
892
|
+
// mcpServers,
|
|
893
|
+
// setMcpServers,
|
|
894
|
+
suggestions: renderedSuggestions.suggestions,
|
|
895
|
+
setSuggestions: (suggestions2) => copilotkit.addSuggestionsConfig({ suggestions: suggestions2 }),
|
|
896
|
+
generateSuggestions: () => __async(this, null, function* () {
|
|
897
|
+
return copilotkit.reloadSuggestions(resolvedAgentId);
|
|
898
|
+
}),
|
|
899
|
+
resetSuggestions: () => copilotkit.clearSuggestions(resolvedAgentId),
|
|
900
|
+
isLoadingSuggestions: renderedSuggestions.isLoading,
|
|
901
|
+
interrupt,
|
|
902
|
+
agent,
|
|
903
|
+
threadId
|
|
904
|
+
};
|
|
905
|
+
}
|
|
906
|
+
function useUpdatedRef(value) {
|
|
907
|
+
const ref = (0, import_react13.useRef)(value);
|
|
908
|
+
(0, import_react13.useEffect)(() => {
|
|
909
|
+
ref.current = value;
|
|
910
|
+
}, [value]);
|
|
911
|
+
return ref;
|
|
912
|
+
}
|
|
913
|
+
function useLegacyCoagentRenderer({
|
|
914
|
+
copilotkit,
|
|
915
|
+
agent,
|
|
916
|
+
agentId,
|
|
917
|
+
threadId
|
|
918
|
+
}) {
|
|
919
|
+
return (0, import_react13.useMemo)(() => {
|
|
920
|
+
if (!copilotkit || !agent) {
|
|
921
|
+
return null;
|
|
922
|
+
}
|
|
923
|
+
return ({ message, position }) => {
|
|
924
|
+
var _a;
|
|
925
|
+
const effectiveThreadId = (_a = threadId != null ? threadId : agent.threadId) != null ? _a : "default";
|
|
926
|
+
const existingRunId = copilotkit.getRunIdForMessage(agentId, effectiveThreadId, message.id);
|
|
927
|
+
const runId = existingRunId || `pending:${message.id}`;
|
|
928
|
+
const messageIndex = Math.max(
|
|
929
|
+
agent.messages.findIndex((msg) => msg.id === message.id),
|
|
930
|
+
0
|
|
931
|
+
);
|
|
932
|
+
const bridgeProps = {
|
|
933
|
+
message,
|
|
934
|
+
position,
|
|
935
|
+
runId,
|
|
936
|
+
messageIndex,
|
|
937
|
+
messageIndexInRun: 0,
|
|
938
|
+
numberOfMessagesInRun: 1,
|
|
939
|
+
agentId,
|
|
940
|
+
stateSnapshot: message.state
|
|
941
|
+
};
|
|
942
|
+
return (0, import_react13.createElement)(CoAgentStateRenderBridge, bridgeProps);
|
|
943
|
+
};
|
|
944
|
+
}, [agent, agentId, copilotkit, threadId]);
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
// src/hooks/use-copilot-chat.ts
|
|
948
|
+
function useCopilotChat(options = {}) {
|
|
949
|
+
const {
|
|
950
|
+
visibleMessages,
|
|
951
|
+
appendMessage,
|
|
952
|
+
reloadMessages,
|
|
953
|
+
stopGeneration,
|
|
954
|
+
reset,
|
|
955
|
+
isLoading,
|
|
956
|
+
isAvailable,
|
|
957
|
+
runChatCompletion,
|
|
958
|
+
mcpServers,
|
|
959
|
+
setMcpServers
|
|
960
|
+
} = useCopilotChatInternal(options);
|
|
961
|
+
return {
|
|
962
|
+
visibleMessages,
|
|
963
|
+
appendMessage,
|
|
964
|
+
reloadMessages,
|
|
965
|
+
stopGeneration,
|
|
966
|
+
reset,
|
|
967
|
+
isLoading,
|
|
968
|
+
isAvailable,
|
|
969
|
+
runChatCompletion,
|
|
970
|
+
mcpServers,
|
|
971
|
+
setMcpServers
|
|
972
|
+
};
|
|
973
|
+
}
|
|
974
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
975
|
+
0 && (module.exports = {
|
|
976
|
+
useCopilotChat
|
|
977
|
+
});
|
|
978
|
+
//# sourceMappingURL=use-copilot-chat.js.map
|