@copilotkitnext/react 0.0.22-alpha.4 → 0.0.22-alpha.5
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/dist/index.d.mts +635 -46
- package/dist/index.d.ts +635 -46
- package/dist/index.js +325 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4286 -109
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/dist/chunk-32YJ5VJ4.mjs +0 -157
- package/dist/chunk-32YJ5VJ4.mjs.map +0 -1
- package/dist/chunk-36HFWACS.mjs +0 -1
- package/dist/chunk-36HFWACS.mjs.map +0 -1
- package/dist/chunk-46BZRXWT.mjs +0 -16
- package/dist/chunk-46BZRXWT.mjs.map +0 -1
- package/dist/chunk-4UDBR75C.mjs +0 -106
- package/dist/chunk-4UDBR75C.mjs.map +0 -1
- package/dist/chunk-4XJK5IVQ.mjs +0 -83
- package/dist/chunk-4XJK5IVQ.mjs.map +0 -1
- package/dist/chunk-5JNWVLQI.mjs +0 -72
- package/dist/chunk-5JNWVLQI.mjs.map +0 -1
- package/dist/chunk-5SC3CO5Q.mjs +0 -69
- package/dist/chunk-5SC3CO5Q.mjs.map +0 -1
- package/dist/chunk-6VUKDHOD.mjs +0 -1
- package/dist/chunk-6VUKDHOD.mjs.map +0 -1
- package/dist/chunk-7HM7CU5A.mjs +0 -122
- package/dist/chunk-7HM7CU5A.mjs.map +0 -1
- package/dist/chunk-AEFM73CL.mjs +0 -32
- package/dist/chunk-AEFM73CL.mjs.map +0 -1
- package/dist/chunk-AI3Z3CHN.mjs +0 -97
- package/dist/chunk-AI3Z3CHN.mjs.map +0 -1
- package/dist/chunk-AXFRCGH6.mjs +0 -107
- package/dist/chunk-AXFRCGH6.mjs.map +0 -1
- package/dist/chunk-BNT754Z2.mjs +0 -185
- package/dist/chunk-BNT754Z2.mjs.map +0 -1
- package/dist/chunk-BT6C5OPU.mjs +0 -278
- package/dist/chunk-BT6C5OPU.mjs.map +0 -1
- package/dist/chunk-CDSO65ZY.mjs +0 -157
- package/dist/chunk-CDSO65ZY.mjs.map +0 -1
- package/dist/chunk-CGLGXQAU.mjs +0 -78
- package/dist/chunk-CGLGXQAU.mjs.map +0 -1
- package/dist/chunk-DVUQO72Z.mjs +0 -1
- package/dist/chunk-DVUQO72Z.mjs.map +0 -1
- package/dist/chunk-E56GYBP3.mjs +0 -101
- package/dist/chunk-E56GYBP3.mjs.map +0 -1
- package/dist/chunk-ETWJDCGE.mjs +0 -1
- package/dist/chunk-ETWJDCGE.mjs.map +0 -1
- package/dist/chunk-FIBK3DYE.mjs +0 -26
- package/dist/chunk-FIBK3DYE.mjs.map +0 -1
- package/dist/chunk-FVURPXQK.mjs +0 -45
- package/dist/chunk-FVURPXQK.mjs.map +0 -1
- package/dist/chunk-FZR2XQKR.mjs +0 -44
- package/dist/chunk-FZR2XQKR.mjs.map +0 -1
- package/dist/chunk-GK4NXPLC.mjs +0 -60
- package/dist/chunk-GK4NXPLC.mjs.map +0 -1
- package/dist/chunk-IA4CLXDM.mjs +0 -76
- package/dist/chunk-IA4CLXDM.mjs.map +0 -1
- package/dist/chunk-IICUCI5S.mjs +0 -43
- package/dist/chunk-IICUCI5S.mjs.map +0 -1
- package/dist/chunk-JLVGSNAO.mjs +0 -311
- package/dist/chunk-JLVGSNAO.mjs.map +0 -1
- package/dist/chunk-JWOIINVV.mjs +0 -237
- package/dist/chunk-JWOIINVV.mjs.map +0 -1
- package/dist/chunk-KCVDFZJX.mjs +0 -873
- package/dist/chunk-KCVDFZJX.mjs.map +0 -1
- package/dist/chunk-KPRUSQ3K.mjs +0 -1
- package/dist/chunk-KPRUSQ3K.mjs.map +0 -1
- package/dist/chunk-MWC5OV7Z.mjs +0 -1
- package/dist/chunk-MWC5OV7Z.mjs.map +0 -1
- package/dist/chunk-N5EP5OD5.mjs +0 -1
- package/dist/chunk-N5EP5OD5.mjs.map +0 -1
- package/dist/chunk-N5HC66HU.mjs +0 -311
- package/dist/chunk-N5HC66HU.mjs.map +0 -1
- package/dist/chunk-NB2GZAKG.mjs +0 -131
- package/dist/chunk-NB2GZAKG.mjs.map +0 -1
- package/dist/chunk-NB4DFAZH.mjs +0 -185
- package/dist/chunk-NB4DFAZH.mjs.map +0 -1
- package/dist/chunk-NNAYEAP2.mjs +0 -49
- package/dist/chunk-NNAYEAP2.mjs.map +0 -1
- package/dist/chunk-NNPKBGD6.mjs +0 -37
- package/dist/chunk-NNPKBGD6.mjs.map +0 -1
- package/dist/chunk-OMPVTGXH.mjs +0 -122
- package/dist/chunk-OMPVTGXH.mjs.map +0 -1
- package/dist/chunk-R5OLAA3L.mjs +0 -135
- package/dist/chunk-R5OLAA3L.mjs.map +0 -1
- package/dist/chunk-RF2CGPHQ.mjs +0 -215
- package/dist/chunk-RF2CGPHQ.mjs.map +0 -1
- package/dist/chunk-RGD2L3Z4.mjs +0 -96
- package/dist/chunk-RGD2L3Z4.mjs.map +0 -1
- package/dist/chunk-RK5P2LG6.mjs +0 -57
- package/dist/chunk-RK5P2LG6.mjs.map +0 -1
- package/dist/chunk-RRXDJCXI.mjs +0 -60
- package/dist/chunk-RRXDJCXI.mjs.map +0 -1
- package/dist/chunk-SPDE34WC.mjs +0 -283
- package/dist/chunk-SPDE34WC.mjs.map +0 -1
- package/dist/chunk-TAUOEJH2.mjs +0 -120
- package/dist/chunk-TAUOEJH2.mjs.map +0 -1
- package/dist/chunk-TBE7ZI5G.mjs +0 -45
- package/dist/chunk-TBE7ZI5G.mjs.map +0 -1
- package/dist/chunk-UOX5D73C.mjs +0 -22
- package/dist/chunk-UOX5D73C.mjs.map +0 -1
- package/dist/chunk-US4KNAAV.mjs +0 -1
- package/dist/chunk-US4KNAAV.mjs.map +0 -1
- package/dist/chunk-UZB3CTOY.mjs +0 -873
- package/dist/chunk-UZB3CTOY.mjs.map +0 -1
- package/dist/chunk-VBI6JXPC.mjs +0 -1
- package/dist/chunk-VBI6JXPC.mjs.map +0 -1
- package/dist/chunk-VVAXSF3M.mjs +0 -61
- package/dist/chunk-VVAXSF3M.mjs.map +0 -1
- package/dist/chunk-XO4IRKSC.mjs +0 -11
- package/dist/chunk-XO4IRKSC.mjs.map +0 -1
- package/dist/chunk-XU5CEPYQ.mjs +0 -75
- package/dist/chunk-XU5CEPYQ.mjs.map +0 -1
- package/dist/chunk-YPH4BHOY.mjs +0 -39
- package/dist/chunk-YPH4BHOY.mjs.map +0 -1
- package/dist/chunk-YZUPVMHC.mjs +0 -1
- package/dist/chunk-YZUPVMHC.mjs.map +0 -1
- package/dist/components/CopilotKitInspector.d.mts +0 -13
- package/dist/components/CopilotKitInspector.d.ts +0 -13
- package/dist/components/CopilotKitInspector.js +0 -69
- package/dist/components/CopilotKitInspector.js.map +0 -1
- package/dist/components/CopilotKitInspector.mjs +0 -7
- package/dist/components/CopilotKitInspector.mjs.map +0 -1
- package/dist/components/WildcardToolCallRender.d.mts +0 -7
- package/dist/components/WildcardToolCallRender.d.ts +0 -7
- package/dist/components/WildcardToolCallRender.js +0 -106
- package/dist/components/WildcardToolCallRender.js.map +0 -1
- package/dist/components/WildcardToolCallRender.mjs +0 -8
- package/dist/components/WildcardToolCallRender.mjs.map +0 -1
- package/dist/components/chat/CopilotChat.d.mts +0 -30
- package/dist/components/chat/CopilotChat.d.ts +0 -30
- package/dist/components/chat/CopilotChat.js +0 -2934
- package/dist/components/chat/CopilotChat.js.map +0 -1
- package/dist/components/chat/CopilotChat.mjs +0 -37
- package/dist/components/chat/CopilotChat.mjs.map +0 -1
- package/dist/components/chat/CopilotChatAssistantMessage.d.mts +0 -45
- package/dist/components/chat/CopilotChatAssistantMessage.d.ts +0 -45
- package/dist/components/chat/CopilotChatAssistantMessage.js +0 -735
- package/dist/components/chat/CopilotChatAssistantMessage.js.map +0 -1
- package/dist/components/chat/CopilotChatAssistantMessage.mjs +0 -29
- package/dist/components/chat/CopilotChatAssistantMessage.mjs.map +0 -1
- package/dist/components/chat/CopilotChatAudioRecorder.d.mts +0 -11
- package/dist/components/chat/CopilotChatAudioRecorder.d.ts +0 -11
- package/dist/components/chat/CopilotChatAudioRecorder.js +0 -131
- package/dist/components/chat/CopilotChatAudioRecorder.js.map +0 -1
- package/dist/components/chat/CopilotChatAudioRecorder.mjs +0 -9
- package/dist/components/chat/CopilotChatAudioRecorder.mjs.map +0 -1
- package/dist/components/chat/CopilotChatInput.d.mts +0 -67
- package/dist/components/chat/CopilotChatInput.d.ts +0 -67
- package/dist/components/chat/CopilotChatInput.js +0 -1305
- package/dist/components/chat/CopilotChatInput.js.map +0 -1
- package/dist/components/chat/CopilotChatInput.mjs +0 -16
- package/dist/components/chat/CopilotChatInput.mjs.map +0 -1
- package/dist/components/chat/CopilotChatMessageView.d.mts +0 -29
- package/dist/components/chat/CopilotChatMessageView.d.ts +0 -29
- package/dist/components/chat/CopilotChatMessageView.js +0 -1164
- package/dist/components/chat/CopilotChatMessageView.js.map +0 -1
- package/dist/components/chat/CopilotChatMessageView.mjs +0 -31
- package/dist/components/chat/CopilotChatMessageView.mjs.map +0 -1
- package/dist/components/chat/CopilotChatSuggestionPill.d.mts +0 -11
- package/dist/components/chat/CopilotChatSuggestionPill.d.ts +0 -11
- package/dist/components/chat/CopilotChatSuggestionPill.js +0 -76
- package/dist/components/chat/CopilotChatSuggestionPill.js.map +0 -1
- package/dist/components/chat/CopilotChatSuggestionPill.mjs +0 -10
- package/dist/components/chat/CopilotChatSuggestionPill.mjs.map +0 -1
- package/dist/components/chat/CopilotChatSuggestionView.d.mts +0 -33
- package/dist/components/chat/CopilotChatSuggestionView.d.ts +0 -33
- package/dist/components/chat/CopilotChatSuggestionView.js +0 -179
- package/dist/components/chat/CopilotChatSuggestionView.js.map +0 -1
- package/dist/components/chat/CopilotChatSuggestionView.mjs +0 -12
- package/dist/components/chat/CopilotChatSuggestionView.mjs.map +0 -1
- package/dist/components/chat/CopilotChatToggleButton.d.mts +0 -14
- package/dist/components/chat/CopilotChatToggleButton.d.ts +0 -14
- package/dist/components/chat/CopilotChatToggleButton.js +0 -222
- package/dist/components/chat/CopilotChatToggleButton.js.map +0 -1
- package/dist/components/chat/CopilotChatToggleButton.mjs +0 -16
- package/dist/components/chat/CopilotChatToggleButton.mjs.map +0 -1
- package/dist/components/chat/CopilotChatToolCallsView.d.mts +0 -10
- package/dist/components/chat/CopilotChatToolCallsView.d.ts +0 -10
- package/dist/components/chat/CopilotChatToolCallsView.js +0 -264
- package/dist/components/chat/CopilotChatToolCallsView.js.map +0 -1
- package/dist/components/chat/CopilotChatToolCallsView.mjs +0 -24
- package/dist/components/chat/CopilotChatToolCallsView.mjs.map +0 -1
- package/dist/components/chat/CopilotChatUserMessage.d.mts +0 -52
- package/dist/components/chat/CopilotChatUserMessage.d.ts +0 -52
- package/dist/components/chat/CopilotChatUserMessage.js +0 -523
- package/dist/components/chat/CopilotChatUserMessage.js.map +0 -1
- package/dist/components/chat/CopilotChatUserMessage.mjs +0 -14
- package/dist/components/chat/CopilotChatUserMessage.mjs.map +0 -1
- package/dist/components/chat/CopilotChatView.d.mts +0 -54
- package/dist/components/chat/CopilotChatView.d.ts +0 -54
- package/dist/components/chat/CopilotChatView.js +0 -2640
- package/dist/components/chat/CopilotChatView.js.map +0 -1
- package/dist/components/chat/CopilotChatView.mjs +0 -38
- package/dist/components/chat/CopilotChatView.mjs.map +0 -1
- package/dist/components/chat/CopilotModalHeader.d.mts +0 -22
- package/dist/components/chat/CopilotModalHeader.d.ts +0 -22
- package/dist/components/chat/CopilotModalHeader.js +0 -186
- package/dist/components/chat/CopilotModalHeader.js.map +0 -1
- package/dist/components/chat/CopilotModalHeader.mjs +0 -12
- package/dist/components/chat/CopilotModalHeader.mjs.map +0 -1
- package/dist/components/chat/CopilotPopup.d.mts +0 -33
- package/dist/components/chat/CopilotPopup.d.ts +0 -33
- package/dist/components/chat/CopilotPopup.js +0 -3343
- package/dist/components/chat/CopilotPopup.js.map +0 -1
- package/dist/components/chat/CopilotPopup.mjs +0 -43
- package/dist/components/chat/CopilotPopup.mjs.map +0 -1
- package/dist/components/chat/CopilotPopupView.d.mts +0 -30
- package/dist/components/chat/CopilotPopupView.d.ts +0 -30
- package/dist/components/chat/CopilotPopupView.js +0 -3003
- package/dist/components/chat/CopilotPopupView.js.map +0 -1
- package/dist/components/chat/CopilotPopupView.mjs +0 -41
- package/dist/components/chat/CopilotPopupView.mjs.map +0 -1
- package/dist/components/chat/CopilotSidebar.d.mts +0 -31
- package/dist/components/chat/CopilotSidebar.d.ts +0 -31
- package/dist/components/chat/CopilotSidebar.js +0 -3266
- package/dist/components/chat/CopilotSidebar.js.map +0 -1
- package/dist/components/chat/CopilotSidebar.mjs +0 -43
- package/dist/components/chat/CopilotSidebar.mjs.map +0 -1
- package/dist/components/chat/CopilotSidebarView.d.mts +0 -28
- package/dist/components/chat/CopilotSidebarView.d.ts +0 -28
- package/dist/components/chat/CopilotSidebarView.js +0 -2941
- package/dist/components/chat/CopilotSidebarView.js.map +0 -1
- package/dist/components/chat/CopilotSidebarView.mjs +0 -41
- package/dist/components/chat/CopilotSidebarView.mjs.map +0 -1
- package/dist/components/chat/index.d.mts +0 -23
- package/dist/components/chat/index.d.ts +0 -23
- package/dist/components/chat/index.js +0 -3503
- package/dist/components/chat/index.js.map +0 -1
- package/dist/components/chat/index.mjs +0 -95
- package/dist/components/chat/index.mjs.map +0 -1
- package/dist/components/index.d.mts +0 -29
- package/dist/components/index.d.ts +0 -29
- package/dist/components/index.js +0 -3583
- package/dist/components/index.js.map +0 -1
- package/dist/components/index.mjs +0 -104
- package/dist/components/index.mjs.map +0 -1
- package/dist/components/ui/button.d.mts +0 -14
- package/dist/components/ui/button.d.ts +0 -14
- package/dist/components/ui/button.js +0 -150
- package/dist/components/ui/button.js.map +0 -1
- package/dist/components/ui/button.mjs +0 -10
- package/dist/components/ui/button.mjs.map +0 -1
- package/dist/components/ui/dropdown-menu.d.mts +0 -28
- package/dist/components/ui/dropdown-menu.d.ts +0 -28
- package/dist/components/ui/dropdown-menu.js +0 -291
- package/dist/components/ui/dropdown-menu.js.map +0 -1
- package/dist/components/ui/dropdown-menu.mjs +0 -37
- package/dist/components/ui/dropdown-menu.mjs.map +0 -1
- package/dist/components/ui/tooltip.d.mts +0 -10
- package/dist/components/ui/tooltip.d.ts +0 -10
- package/dist/components/ui/tooltip.js +0 -103
- package/dist/components/ui/tooltip.js.map +0 -1
- package/dist/components/ui/tooltip.mjs +0 -14
- package/dist/components/ui/tooltip.mjs.map +0 -1
- package/dist/hooks/index.d.mts +0 -19
- package/dist/hooks/index.d.ts +0 -19
- package/dist/hooks/index.js +0 -691
- package/dist/hooks/index.js.map +0 -1
- package/dist/hooks/index.mjs +0 -45
- package/dist/hooks/index.mjs.map +0 -1
- package/dist/hooks/use-agent-context.d.mts +0 -5
- package/dist/hooks/use-agent-context.d.ts +0 -5
- package/dist/hooks/use-agent-context.js +0 -116
- package/dist/hooks/use-agent-context.js.map +0 -1
- package/dist/hooks/use-agent-context.mjs +0 -10
- package/dist/hooks/use-agent-context.mjs.map +0 -1
- package/dist/hooks/use-agent.d.mts +0 -16
- package/dist/hooks/use-agent.d.ts +0 -16
- package/dist/hooks/use-agent.js +0 -171
- package/dist/hooks/use-agent.js.map +0 -1
- package/dist/hooks/use-agent.mjs +0 -12
- package/dist/hooks/use-agent.mjs.map +0 -1
- package/dist/hooks/use-configure-suggestions.d.mts +0 -13
- package/dist/hooks/use-configure-suggestions.d.ts +0 -13
- package/dist/hooks/use-configure-suggestions.js +0 -232
- package/dist/hooks/use-configure-suggestions.js.map +0 -1
- package/dist/hooks/use-configure-suggestions.mjs +0 -11
- package/dist/hooks/use-configure-suggestions.mjs.map +0 -1
- package/dist/hooks/use-frontend-tool.d.mts +0 -8
- package/dist/hooks/use-frontend-tool.d.ts +0 -8
- package/dist/hooks/use-frontend-tool.js +0 -137
- package/dist/hooks/use-frontend-tool.js.map +0 -1
- package/dist/hooks/use-frontend-tool.mjs +0 -10
- package/dist/hooks/use-frontend-tool.mjs.map +0 -1
- package/dist/hooks/use-human-in-the-loop.d.mts +0 -7
- package/dist/hooks/use-human-in-the-loop.d.ts +0 -7
- package/dist/hooks/use-human-in-the-loop.js +0 -206
- package/dist/hooks/use-human-in-the-loop.js.map +0 -1
- package/dist/hooks/use-human-in-the-loop.mjs +0 -11
- package/dist/hooks/use-human-in-the-loop.mjs.map +0 -1
- package/dist/hooks/use-keyboard-height.d.mts +0 -15
- package/dist/hooks/use-keyboard-height.d.ts +0 -15
- package/dist/hooks/use-keyboard-height.js +0 -68
- package/dist/hooks/use-keyboard-height.js.map +0 -1
- package/dist/hooks/use-keyboard-height.mjs +0 -7
- package/dist/hooks/use-keyboard-height.mjs.map +0 -1
- package/dist/hooks/use-render-activity-message.d.mts +0 -5
- package/dist/hooks/use-render-activity-message.d.ts +0 -5
- package/dist/hooks/use-render-activity-message.js +0 -158
- package/dist/hooks/use-render-activity-message.js.map +0 -1
- package/dist/hooks/use-render-activity-message.mjs +0 -12
- package/dist/hooks/use-render-activity-message.mjs.map +0 -1
- package/dist/hooks/use-render-custom-messages.d.mts +0 -11
- package/dist/hooks/use-render-custom-messages.d.ts +0 -11
- package/dist/hooks/use-render-custom-messages.js +0 -170
- package/dist/hooks/use-render-custom-messages.js.map +0 -1
- package/dist/hooks/use-render-custom-messages.mjs +0 -12
- package/dist/hooks/use-render-custom-messages.mjs.map +0 -1
- package/dist/hooks/use-render-tool-call.d.mts +0 -16
- package/dist/hooks/use-render-tool-call.d.ts +0 -16
- package/dist/hooks/use-render-tool-call.js +0 -208
- package/dist/hooks/use-render-tool-call.js.map +0 -1
- package/dist/hooks/use-render-tool-call.mjs +0 -11
- package/dist/hooks/use-render-tool-call.mjs.map +0 -1
- package/dist/hooks/use-suggestions.d.mts +0 -14
- package/dist/hooks/use-suggestions.d.ts +0 -14
- package/dist/hooks/use-suggestions.js +0 -176
- package/dist/hooks/use-suggestions.js.map +0 -1
- package/dist/hooks/use-suggestions.mjs +0 -11
- package/dist/hooks/use-suggestions.mjs.map +0 -1
- package/dist/lib/react-core.d.mts +0 -33
- package/dist/lib/react-core.d.ts +0 -33
- package/dist/lib/react-core.js +0 -73
- package/dist/lib/react-core.js.map +0 -1
- package/dist/lib/react-core.mjs +0 -7
- package/dist/lib/react-core.mjs.map +0 -1
- package/dist/lib/slots.d.mts +0 -16
- package/dist/lib/slots.d.ts +0 -16
- package/dist/lib/slots.js +0 -60
- package/dist/lib/slots.js.map +0 -1
- package/dist/lib/slots.mjs +0 -7
- package/dist/lib/slots.mjs.map +0 -1
- package/dist/lib/utils.d.mts +0 -5
- package/dist/lib/utils.d.ts +0 -5
- package/dist/lib/utils.js +0 -35
- package/dist/lib/utils.js.map +0 -1
- package/dist/lib/utils.mjs +0 -7
- package/dist/lib/utils.mjs.map +0 -1
- package/dist/providers/CopilotChatConfigurationProvider.d.mts +0 -43
- package/dist/providers/CopilotChatConfigurationProvider.d.ts +0 -43
- package/dist/providers/CopilotChatConfigurationProvider.js +0 -109
- package/dist/providers/CopilotChatConfigurationProvider.js.map +0 -1
- package/dist/providers/CopilotChatConfigurationProvider.mjs +0 -11
- package/dist/providers/CopilotChatConfigurationProvider.mjs.map +0 -1
- package/dist/providers/CopilotKitProvider.d.mts +0 -33
- package/dist/providers/CopilotKitProvider.d.ts +0 -33
- package/dist/providers/CopilotKitProvider.js +0 -314
- package/dist/providers/CopilotKitProvider.js.map +0 -1
- package/dist/providers/CopilotKitProvider.mjs +0 -12
- package/dist/providers/CopilotKitProvider.mjs.map +0 -1
- package/dist/providers/index.d.mts +0 -13
- package/dist/providers/index.d.ts +0 -13
- package/dist/providers/index.js +0 -396
- package/dist/providers/index.js.map +0 -1
- package/dist/providers/index.mjs +0 -18
- package/dist/providers/index.mjs.map +0 -1
- package/dist/types/defineToolCallRenderer.d.mts +0 -41
- package/dist/types/defineToolCallRenderer.d.ts +0 -41
- package/dist/types/defineToolCallRenderer.js +0 -40
- package/dist/types/defineToolCallRenderer.js.map +0 -1
- package/dist/types/defineToolCallRenderer.mjs +0 -7
- package/dist/types/defineToolCallRenderer.mjs.map +0 -1
- package/dist/types/frontend-tool.d.mts +0 -9
- package/dist/types/frontend-tool.d.ts +0 -9
- package/dist/types/frontend-tool.js +0 -19
- package/dist/types/frontend-tool.js.map +0 -1
- package/dist/types/frontend-tool.mjs +0 -2
- package/dist/types/frontend-tool.mjs.map +0 -1
- package/dist/types/human-in-the-loop.d.mts +0 -29
- package/dist/types/human-in-the-loop.d.ts +0 -29
- package/dist/types/human-in-the-loop.js +0 -19
- package/dist/types/human-in-the-loop.js.map +0 -1
- package/dist/types/human-in-the-loop.mjs +0 -2
- package/dist/types/human-in-the-loop.mjs.map +0 -1
- package/dist/types/index.d.mts +0 -11
- package/dist/types/index.d.ts +0 -11
- package/dist/types/index.js +0 -42
- package/dist/types/index.js.map +0 -1
- package/dist/types/index.mjs +0 -13
- package/dist/types/index.mjs.map +0 -1
- package/dist/types/react-activity-message-renderer.d.mts +0 -29
- package/dist/types/react-activity-message-renderer.d.ts +0 -29
- package/dist/types/react-activity-message-renderer.js +0 -19
- package/dist/types/react-activity-message-renderer.js.map +0 -1
- package/dist/types/react-activity-message-renderer.mjs +0 -2
- package/dist/types/react-activity-message-renderer.mjs.map +0 -1
- package/dist/types/react-custom-message-renderer.d.mts +0 -18
- package/dist/types/react-custom-message-renderer.d.ts +0 -18
- package/dist/types/react-custom-message-renderer.js +0 -19
- package/dist/types/react-custom-message-renderer.js.map +0 -1
- package/dist/types/react-custom-message-renderer.mjs +0 -2
- package/dist/types/react-custom-message-renderer.mjs.map +0 -1
- package/dist/types/react-tool-call-renderer.d.mts +0 -30
- package/dist/types/react-tool-call-renderer.d.ts +0 -30
- package/dist/types/react-tool-call-renderer.js +0 -19
- package/dist/types/react-tool-call-renderer.js.map +0 -1
- package/dist/types/react-tool-call-renderer.mjs +0 -2
- package/dist/types/react-tool-call-renderer.mjs.map +0 -1
package/dist/hooks/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hooks/index.ts","../../src/hooks/use-render-tool-call.tsx","../../src/providers/CopilotKitProvider.tsx","../../src/lib/react-core.ts","../../src/components/CopilotKitInspector.tsx","../../src/providers/CopilotChatConfigurationProvider.tsx","../../src/hooks/use-render-custom-messages.tsx","../../src/hooks/use-render-activity-message.tsx","../../src/hooks/use-frontend-tool.tsx","../../src/hooks/use-human-in-the-loop.tsx","../../src/hooks/use-agent.tsx","../../src/hooks/use-agent-context.tsx","../../src/hooks/use-suggestions.tsx","../../src/hooks/use-configure-suggestions.tsx"],"sourcesContent":["// React hooks for CopilotKit2\nexport { useRenderToolCall } from \"./use-render-tool-call\";\nexport { useRenderCustomMessages } from \"./use-render-custom-messages\";\nexport { useRenderActivityMessage } from \"./use-render-activity-message\";\nexport { useFrontendTool } from \"./use-frontend-tool\";\nexport { useHumanInTheLoop } from \"./use-human-in-the-loop\";\nexport { useAgent } from \"./use-agent\";\nexport { useAgentContext } from \"./use-agent-context\";\nexport { useSuggestions } from \"./use-suggestions\";\nexport { useConfigureSuggestions } from \"./use-configure-suggestions\";\n","import React, { useCallback, useEffect, useState, useSyncExternalStore } from \"react\";\nimport { ToolCall, ToolMessage } from \"@ag-ui/core\";\nimport { ToolCallStatus } from \"@copilotkitnext/core\";\nimport { useCopilotKit } from \"@/providers/CopilotKitProvider\";\nimport { useCopilotChatConfiguration } from \"@/providers/CopilotChatConfigurationProvider\";\nimport { DEFAULT_AGENT_ID } from \"@copilotkitnext/shared\";\nimport { partialJSONParse } from \"@copilotkitnext/shared\";\n\nexport interface UseRenderToolCallProps {\n toolCall: ToolCall;\n toolMessage?: ToolMessage;\n}\n\n/**\n * Hook that returns a function to render tool calls based on the render functions\n * defined in CopilotKitProvider.\n *\n * @returns A function that takes a tool call and optional tool message and returns the rendered component\n */\nexport function useRenderToolCall() {\n const { copilotkit } = useCopilotKit();\n const config = useCopilotChatConfiguration();\n const agentId = config?.agentId ?? DEFAULT_AGENT_ID;\n const [executingToolCallIds, setExecutingToolCallIds] = useState<\n ReadonlySet<string>\n >(() => new Set());\n\n // Subscribe to render tool calls changes using useSyncExternalStore\n // This ensures we always have the latest value, even if subscriptions run in any order\n const renderToolCalls = useSyncExternalStore(\n (callback) => {\n return copilotkit.subscribe({\n onRenderToolCallsChanged: callback,\n });\n },\n () => copilotkit.renderToolCalls,\n () => copilotkit.renderToolCalls\n );\n\n useEffect(() => {\n const unsubscribe = copilotkit.subscribe({\n onToolExecutionStart: ({ toolCallId }) => {\n setExecutingToolCallIds((prev) => {\n if (prev.has(toolCallId)) return prev;\n const next = new Set(prev);\n next.add(toolCallId);\n return next;\n });\n },\n onToolExecutionEnd: ({ toolCallId }) => {\n setExecutingToolCallIds((prev) => {\n if (!prev.has(toolCallId)) return prev;\n const next = new Set(prev);\n next.delete(toolCallId);\n return next;\n });\n },\n });\n return () => unsubscribe();\n }, [copilotkit]);\n\n const renderToolCall = useCallback(\n ({\n toolCall,\n toolMessage,\n }: UseRenderToolCallProps): React.ReactElement | null => {\n // Find the render config for this tool call by name\n // For rendering, we show all tool calls regardless of agentId\n // The agentId scoping only affects handler execution (in core)\n // Priority order:\n // 1. Exact match by name (prefer agent-specific if multiple exist)\n // 2. Wildcard (*) renderer\n const exactMatches = renderToolCalls.filter(\n (rc) => rc.name === toolCall.function.name\n );\n\n // If multiple renderers with same name exist, prefer the one matching our agentId\n const renderConfig =\n exactMatches.find((rc) => rc.agentId === agentId) ||\n exactMatches.find((rc) => !rc.agentId) ||\n exactMatches[0] ||\n renderToolCalls.find((rc) => rc.name === \"*\");\n\n if (!renderConfig) {\n return null;\n }\n\n const RenderComponent = renderConfig.render;\n\n // Parse the arguments if they're a string\n const args = partialJSONParse(toolCall.function.arguments);\n\n // Create props based on status with proper typing\n const toolName = toolCall.function.name;\n\n if (toolMessage) {\n // Complete status with result\n return (\n <RenderComponent\n key={toolCall.id}\n name={toolName}\n args={args}\n status={ToolCallStatus.Complete}\n result={toolMessage.content}\n />\n );\n } else if (executingToolCallIds.has(toolCall.id)) {\n // Tool is currently executing\n return (\n <RenderComponent\n key={toolCall.id}\n name={toolName}\n // args should be complete when executing; but pass whatever we have\n args={args}\n status={ToolCallStatus.Executing}\n result={undefined}\n />\n );\n } else {\n // In progress status - tool call exists but hasn't completed yet\n // This remains true even after agent stops running, until we get a result\n return (\n <RenderComponent\n key={toolCall.id}\n name={toolName}\n args={args}\n status={ToolCallStatus.InProgress}\n result={undefined}\n />\n );\n }\n },\n [renderToolCalls, executingToolCallIds, agentId]\n );\n\n return renderToolCall;\n}\n","\"use client\";\n\nimport React, {\n createContext,\n useContext,\n ReactNode,\n useMemo,\n useEffect,\n useReducer,\n useRef,\n useState,\n} from \"react\";\nimport { ReactActivityMessageRenderer, ReactToolCallRenderer } from \"../types\";\nimport { ReactCustomMessageRenderer } from \"../types/react-custom-message-renderer\";\nimport { ReactFrontendTool } from \"../types/frontend-tool\";\nimport { ReactHumanInTheLoop } from \"../types/human-in-the-loop\";\nimport { z } from \"zod\";\nimport { FrontendTool } from \"@copilotkitnext/core\";\nimport { AbstractAgent } from \"@ag-ui/client\";\nimport { CopilotKitCoreReact } from \"../lib/react-core\";\nimport { CopilotKitInspector } from \"../components/CopilotKitInspector\";\n\n// Define the context value interface - idiomatic React naming\nexport interface CopilotKitContextValue {\n copilotkit: CopilotKitCoreReact;\n}\n\n// Create the CopilotKit context\nconst CopilotKitContext = createContext<CopilotKitContextValue>({\n copilotkit: null!,\n});\n\n// Provider props interface\nexport interface CopilotKitProviderProps {\n children: ReactNode;\n runtimeUrl?: string;\n headers?: Record<string, string>;\n properties?: Record<string, unknown>;\n useSingleEndpoint?: boolean;\n agents__unsafe_dev_only?: Record<string, AbstractAgent>;\n renderToolCalls?: ReactToolCallRenderer<any>[];\n renderActivityMessages?: ReactActivityMessageRenderer<any>[];\n renderCustomMessages?: ReactCustomMessageRenderer[];\n frontendTools?: ReactFrontendTool[];\n humanInTheLoop?: ReactHumanInTheLoop[];\n showDevConsole?: boolean | \"auto\";\n}\n\n// Small helper to normalize array props to a stable reference and warn\nfunction useStableArrayProp<T>(\n prop: T[] | undefined,\n warningMessage?: string,\n isMeaningfulChange?: (initial: T[], next: T[]) => boolean,\n): T[] {\n const empty = useMemo<T[]>(() => [], []);\n const value = prop ?? empty;\n const initial = useRef(value);\n\n useEffect(() => {\n if (\n warningMessage &&\n value !== initial.current &&\n (isMeaningfulChange ? isMeaningfulChange(initial.current, value) : true)\n ) {\n console.error(warningMessage);\n }\n }, [value, warningMessage]);\n\n return value;\n}\n\n// Provider component\nexport const CopilotKitProvider: React.FC<CopilotKitProviderProps> = ({\n children,\n runtimeUrl,\n headers = {},\n properties = {},\n agents__unsafe_dev_only: agents = {},\n renderToolCalls,\n renderActivityMessages,\n renderCustomMessages,\n frontendTools,\n humanInTheLoop,\n showDevConsole = false,\n useSingleEndpoint = false,\n}) => {\n const [shouldRenderInspector, setShouldRenderInspector] = useState(false);\n\n useEffect(() => {\n if (typeof window === \"undefined\") {\n return;\n }\n\n if (showDevConsole === true) {\n // Explicitly show the inspector\n setShouldRenderInspector(true);\n } else if (showDevConsole === \"auto\") {\n // Show on localhost or 127.0.0.1 only\n const localhostHosts = new Set([\"localhost\", \"127.0.0.1\"]);\n if (localhostHosts.has(window.location.hostname)) {\n setShouldRenderInspector(true);\n } else {\n setShouldRenderInspector(false);\n }\n } else {\n // showDevConsole is false or undefined (default false)\n setShouldRenderInspector(false);\n }\n }, [showDevConsole]);\n\n // Normalize array props to stable references with clear dev warnings\n const renderToolCallsList = useStableArrayProp<ReactToolCallRenderer<any>>(\n renderToolCalls,\n \"renderToolCalls must be a stable array. If you want to dynamically add or remove tools, use `useFrontendTool` instead.\",\n (initial, next) => {\n // Only warn if the shape (names+agentId) changed. Allow identity changes\n // to support updated closures from parents (e.g., Storybook state).\n const key = (rc?: ReactToolCallRenderer<unknown>) => `${rc?.agentId ?? \"\"}:${rc?.name ?? \"\"}`;\n const setFrom = (arr: ReactToolCallRenderer<unknown>[]) => new Set(arr.map(key));\n const a = setFrom(initial);\n const b = setFrom(next);\n if (a.size !== b.size) return true;\n for (const k of a) if (!b.has(k)) return true;\n return false;\n },\n );\n\n const renderCustomMessagesList = useStableArrayProp<ReactCustomMessageRenderer>(\n renderCustomMessages,\n \"renderCustomMessages must be a stable array.\",\n );\n\n const renderActivityMessagesList = useStableArrayProp<ReactActivityMessageRenderer<any>>(\n renderActivityMessages,\n \"renderActivityMessages must be a stable array.\",\n );\n\n const frontendToolsList = useStableArrayProp<ReactFrontendTool>(\n frontendTools,\n \"frontendTools must be a stable array. If you want to dynamically add or remove tools, use `useFrontendTool` instead.\",\n );\n const humanInTheLoopList = useStableArrayProp<ReactHumanInTheLoop>(\n humanInTheLoop,\n \"humanInTheLoop must be a stable array. If you want to dynamically add or remove human-in-the-loop tools, use `useHumanInTheLoop` instead.\",\n );\n\n // Note: warnings for array identity changes are handled by useStableArrayProp\n\n // Process humanInTheLoop tools to create handlers and add render components\n const processedHumanInTheLoopTools = useMemo(() => {\n const processedTools: FrontendTool[] = [];\n const processedRenderToolCalls: ReactToolCallRenderer<unknown>[] = [];\n\n humanInTheLoopList.forEach((tool) => {\n // Create a promise-based handler for each human-in-the-loop tool\n const frontendTool: FrontendTool = {\n name: tool.name,\n description: tool.description,\n parameters: tool.parameters,\n followUp: tool.followUp,\n ...(tool.agentId && { agentId: tool.agentId }),\n handler: async () => {\n // This handler will be replaced by the hook when it runs\n // For provider-level tools, we create a basic handler that waits for user interaction\n return new Promise((resolve) => {\n // The actual implementation will be handled by the render component\n // This is a placeholder that the hook will override\n console.warn(`Human-in-the-loop tool '${tool.name}' called but no interactive handler is set up.`);\n resolve(undefined);\n });\n },\n };\n processedTools.push(frontendTool);\n\n // Add the render component to renderToolCalls\n if (tool.render) {\n processedRenderToolCalls.push({\n name: tool.name,\n args: tool.parameters!,\n render: tool.render,\n ...(tool.agentId && { agentId: tool.agentId }),\n } as ReactToolCallRenderer<unknown>);\n }\n });\n\n return { tools: processedTools, renderToolCalls: processedRenderToolCalls };\n }, [humanInTheLoopList]);\n\n // Combine all tools for CopilotKitCore\n const allTools = useMemo(() => {\n const tools: FrontendTool[] = [];\n\n // Add frontend tools\n tools.push(...frontendToolsList);\n\n // Add processed human-in-the-loop tools\n tools.push(...processedHumanInTheLoopTools.tools);\n\n return tools;\n }, [frontendToolsList, processedHumanInTheLoopTools]);\n\n // Combine all render tool calls\n const allRenderToolCalls = useMemo(() => {\n const combined: ReactToolCallRenderer<unknown>[] = [...renderToolCallsList];\n\n // Add render components from frontend tools\n frontendToolsList.forEach((tool) => {\n if (tool.render) {\n // For wildcard tools without parameters, default to z.any()\n const args = tool.parameters || (tool.name === \"*\" ? z.any() : undefined);\n if (args) {\n combined.push({\n name: tool.name,\n args: args,\n render: tool.render,\n } as ReactToolCallRenderer<unknown>);\n }\n }\n });\n\n // Add render components from human-in-the-loop tools\n combined.push(...processedHumanInTheLoopTools.renderToolCalls);\n\n return combined;\n }, [renderToolCallsList, frontendToolsList, processedHumanInTheLoopTools]);\n\n const copilotkit = useMemo(() => {\n const copilotkit = new CopilotKitCoreReact({\n runtimeUrl,\n runtimeTransport: useSingleEndpoint ? \"single\" : \"rest\",\n headers,\n properties,\n agents__unsafe_dev_only: agents,\n tools: allTools,\n renderToolCalls: allRenderToolCalls,\n renderActivityMessages: renderActivityMessagesList,\n renderCustomMessages: renderCustomMessagesList,\n });\n\n return copilotkit;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [allTools, allRenderToolCalls, renderActivityMessagesList, renderCustomMessagesList, useSingleEndpoint]);\n\n // Subscribe to render tool calls changes to force re-renders\n const [, forceUpdate] = useReducer((x) => x + 1, 0);\n\n useEffect(() => {\n const unsubscribe = copilotkit.subscribe({\n onRenderToolCallsChanged: () => {\n forceUpdate();\n },\n });\n\n return () => {\n unsubscribe();\n };\n }, [copilotkit]);\n\n useEffect(() => {\n copilotkit.setRuntimeUrl(runtimeUrl);\n copilotkit.setRuntimeTransport(useSingleEndpoint ? \"single\" : \"rest\");\n copilotkit.setHeaders(headers);\n copilotkit.setProperties(properties);\n copilotkit.setAgents__unsafe_dev_only(agents);\n }, [runtimeUrl, headers, properties, agents, useSingleEndpoint]);\n\n return (\n <CopilotKitContext.Provider\n value={{\n copilotkit,\n }}\n >\n {children}\n {shouldRenderInspector ? <CopilotKitInspector core={copilotkit} /> : null}\n </CopilotKitContext.Provider>\n );\n};\n\n// Hook to use the CopilotKit instance - returns the full context value\nexport const useCopilotKit = (): CopilotKitContextValue => {\n const context = useContext(CopilotKitContext);\n const [, forceUpdate] = useReducer((x) => x + 1, 0);\n\n if (!context) {\n throw new Error(\"useCopilotKit must be used within CopilotKitProvider\");\n }\n useEffect(() => {\n const unsubscribe = context.copilotkit.subscribe({\n onRuntimeConnectionStatusChanged: () => {\n forceUpdate();\n },\n });\n return () => {\n unsubscribe();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return context;\n};\n","import { ReactActivityMessageRenderer, ReactToolCallRenderer } from \"@/types\";\nimport { ReactCustomMessageRenderer } from \"@/types/react-custom-message-renderer\";\nimport { CopilotKitCore, CopilotKitCoreConfig, CopilotKitCoreSubscriber } from \"@copilotkitnext/core\";\n\nexport interface CopilotKitCoreReactConfig extends CopilotKitCoreConfig {\n // Add any additional configuration properties specific to the React implementation\n renderToolCalls?: ReactToolCallRenderer<any>[];\n renderActivityMessages?: ReactActivityMessageRenderer<any>[];\n\n // Add custom message renderers\n renderCustomMessages?: ReactCustomMessageRenderer[];\n}\n\nexport interface CopilotKitCoreReactSubscriber extends CopilotKitCoreSubscriber {\n onRenderToolCallsChanged?: (event: {\n copilotkit: CopilotKitCore;\n renderToolCalls: ReactToolCallRenderer<any>[];\n }) => void | Promise<void>;\n}\n\nexport class CopilotKitCoreReact extends CopilotKitCore {\n private _renderToolCalls: ReactToolCallRenderer<any>[] = [];\n private _renderCustomMessages: ReactCustomMessageRenderer[] = [];\n private _renderActivityMessages: ReactActivityMessageRenderer<any>[] = [];\n\n constructor(config: CopilotKitCoreReactConfig) {\n super(config);\n this._renderToolCalls = config.renderToolCalls ?? [];\n this._renderCustomMessages = config.renderCustomMessages ?? [];\n this._renderActivityMessages = config.renderActivityMessages ?? [];\n }\n\n get renderCustomMessages(): Readonly<ReactCustomMessageRenderer[]> {\n return this._renderCustomMessages;\n }\n\n get renderActivityMessages(): Readonly<ReactActivityMessageRenderer<any>>[] {\n return this._renderActivityMessages;\n }\n\n get renderToolCalls(): Readonly<ReactToolCallRenderer<any>>[] {\n return this._renderToolCalls;\n }\n\n setRenderToolCalls(renderToolCalls: ReactToolCallRenderer<any>[]): void {\n this._renderToolCalls = renderToolCalls;\n\n // Notify React-specific subscribers\n void this.notifySubscribers(\n (subscriber) => {\n const reactSubscriber = subscriber as CopilotKitCoreReactSubscriber;\n if (reactSubscriber.onRenderToolCallsChanged) {\n reactSubscriber.onRenderToolCallsChanged({\n copilotkit: this,\n renderToolCalls: this.renderToolCalls,\n });\n }\n },\n \"Subscriber onRenderToolCallsChanged error:\"\n );\n }\n\n // Override to accept React-specific subscriber type\n subscribe(subscriber: CopilotKitCoreReactSubscriber): () => void {\n return super.subscribe(subscriber);\n }\n\n unsubscribe(subscriber: CopilotKitCoreReactSubscriber): void {\n super.unsubscribe(subscriber);\n }\n}\n","import * as React from \"react\";\nimport { createComponent } from \"@lit-labs/react\";\nimport {\n WEB_INSPECTOR_TAG,\n WebInspectorElement,\n defineWebInspector,\n} from \"@copilotkitnext/web-inspector\";\nimport type { CopilotKitCore } from \"@copilotkitnext/core\";\n\ndefineWebInspector();\n\nconst CopilotKitInspectorBase = createComponent({\n tagName: WEB_INSPECTOR_TAG,\n elementClass: WebInspectorElement,\n react: React,\n});\n\nexport type CopilotKitInspectorBaseProps = React.ComponentProps<typeof CopilotKitInspectorBase>;\n\nexport interface CopilotKitInspectorProps extends Omit<CopilotKitInspectorBaseProps, \"core\"> {\n core?: CopilotKitCore | null;\n}\n\nexport const CopilotKitInspector = React.forwardRef<\n WebInspectorElement,\n CopilotKitInspectorProps\n>(\n ({ core, ...rest }, ref) => {\n const innerRef = React.useRef<WebInspectorElement>(null);\n\n React.useImperativeHandle(ref, () => innerRef.current as WebInspectorElement, []);\n\n React.useEffect(() => {\n if (innerRef.current) {\n innerRef.current.core = core ?? null;\n }\n }, [core]);\n\n return (\n <CopilotKitInspectorBase\n {...(rest as CopilotKitInspectorBaseProps)}\n ref={innerRef}\n />\n ); // eslint-disable-line react/jsx-props-no-spreading\n },\n);\n\nCopilotKitInspector.displayName = \"CopilotKitInspector\";\n","import React, { createContext, useContext, ReactNode, useMemo, useState } from \"react\";\nimport { DEFAULT_AGENT_ID, randomUUID } from \"@copilotkitnext/shared\";\n\n// Default labels\nexport const CopilotChatDefaultLabels = {\n chatInputPlaceholder: \"Type a message...\",\n chatInputToolbarStartTranscribeButtonLabel: \"Transcribe\",\n chatInputToolbarCancelTranscribeButtonLabel: \"Cancel\",\n chatInputToolbarFinishTranscribeButtonLabel: \"Finish\",\n chatInputToolbarAddButtonLabel: \"Add photos or files\",\n chatInputToolbarToolsButtonLabel: \"Tools\",\n assistantMessageToolbarCopyCodeLabel: \"Copy\",\n assistantMessageToolbarCopyCodeCopiedLabel: \"Copied\",\n assistantMessageToolbarCopyMessageLabel: \"Copy\",\n assistantMessageToolbarThumbsUpLabel: \"Good response\",\n assistantMessageToolbarThumbsDownLabel: \"Bad response\",\n assistantMessageToolbarReadAloudLabel: \"Read aloud\",\n assistantMessageToolbarRegenerateLabel: \"Regenerate\",\n userMessageToolbarCopyMessageLabel: \"Copy\",\n userMessageToolbarEditMessageLabel: \"Edit\",\n chatDisclaimerText: \"AI can make mistakes. Please verify important information.\",\n chatToggleOpenLabel: \"Open chat\",\n chatToggleCloseLabel: \"Close chat\",\n modalHeaderTitle: \"CopilotKit Chat\",\n};\n\nexport type CopilotChatLabels = typeof CopilotChatDefaultLabels;\n\n// Define the full configuration interface\nexport interface CopilotChatConfigurationValue {\n labels: CopilotChatLabels;\n agentId: string;\n threadId: string;\n isModalOpen: boolean;\n setModalOpen: (open: boolean) => void;\n isModalDefaultOpen: boolean;\n}\n\n// Create the configuration context\nconst CopilotChatConfiguration =\n createContext<CopilotChatConfigurationValue | null>(null);\n\n// Provider props interface\nexport interface CopilotChatConfigurationProviderProps {\n children: ReactNode;\n labels?: Partial<CopilotChatLabels>;\n agentId?: string;\n threadId?: string;\n isModalDefaultOpen?: boolean;\n}\n\n// Provider component\nexport const CopilotChatConfigurationProvider: React.FC<\n CopilotChatConfigurationProviderProps\n> = ({ children, labels, agentId, threadId, isModalDefaultOpen }) => {\n const parentConfig = useContext(CopilotChatConfiguration);\n\n const mergedLabels: CopilotChatLabels = useMemo(\n () => ({\n ...CopilotChatDefaultLabels,\n ...(parentConfig?.labels ?? {}),\n ...(labels ?? {}),\n }),\n [labels, parentConfig?.labels],\n );\n\n const resolvedAgentId = agentId ?? parentConfig?.agentId ?? DEFAULT_AGENT_ID;\n\n const resolvedThreadId = useMemo(() => {\n if (threadId) {\n return threadId;\n }\n if (parentConfig?.threadId) {\n return parentConfig.threadId;\n }\n return randomUUID();\n }, [threadId, parentConfig?.threadId]);\n\n const resolvedDefaultOpen = isModalDefaultOpen ?? parentConfig?.isModalDefaultOpen ?? true;\n\n const [internalModalOpen, setInternalModalOpen] = useState<boolean>(\n parentConfig?.isModalOpen ?? resolvedDefaultOpen,\n );\n\n const resolvedIsModalOpen = parentConfig?.isModalOpen ?? internalModalOpen;\n const resolvedSetModalOpen = parentConfig?.setModalOpen ?? setInternalModalOpen;\n\n const configurationValue: CopilotChatConfigurationValue = useMemo(\n () => ({\n labels: mergedLabels,\n agentId: resolvedAgentId,\n threadId: resolvedThreadId,\n isModalOpen: resolvedIsModalOpen,\n setModalOpen: resolvedSetModalOpen,\n isModalDefaultOpen: resolvedDefaultOpen,\n }),\n [\n mergedLabels,\n resolvedAgentId,\n resolvedThreadId,\n resolvedIsModalOpen,\n resolvedSetModalOpen,\n resolvedDefaultOpen,\n ],\n );\n\n return (\n <CopilotChatConfiguration.Provider value={configurationValue}>\n {children}\n </CopilotChatConfiguration.Provider>\n );\n};\n\n// Hook to use the full configuration\nexport const useCopilotChatConfiguration =\n (): CopilotChatConfigurationValue | null => {\n const configuration = useContext(CopilotChatConfiguration);\n return configuration;\n };\n","import { useCopilotChatConfiguration, useCopilotKit } from \"@/providers\";\nimport { ReactCustomMessageRendererPosition } from \"@/types/react-custom-message-renderer\";\nimport { Message } from \"@ag-ui/core\";\n\ninterface UseRenderCustomMessagesParams {\n message: Message;\n position: ReactCustomMessageRendererPosition;\n}\n\nexport function useRenderCustomMessages() {\n const { copilotkit } = useCopilotKit();\n const config = useCopilotChatConfiguration();\n\n if (!config) {\n return null;\n }\n\n const { agentId, threadId } = config;\n\n const customMessageRenderers = copilotkit.renderCustomMessages\n .filter((renderer) => renderer.agentId === undefined || renderer.agentId === agentId)\n .sort((a, b) => {\n const aHasAgent = a.agentId !== undefined;\n const bHasAgent = b.agentId !== undefined;\n if (aHasAgent === bHasAgent) return 0;\n return aHasAgent ? -1 : 1;\n });\n\n return function (params: UseRenderCustomMessagesParams) {\n if (!customMessageRenderers.length) {\n return null;\n }\n const { message, position } = params;\n const runId = copilotkit.getRunIdForMessage(agentId, threadId, message.id)!;\n const agent = copilotkit.getAgent(agentId);\n if (!agent) {\n throw new Error(\"Agent not found\");\n }\n\n const messagesIdsInRun = agent.messages\n .filter((msg) => copilotkit.getRunIdForMessage(agentId, threadId, msg.id) === runId)\n .map((msg) => msg.id);\n\n const messageIndex = agent.messages.findIndex((msg) => msg.id === message.id) ?? 0;\n const messageIndexInRun = Math.min(messagesIdsInRun.indexOf(message.id), 0);\n const numberOfMessagesInRun = messagesIdsInRun.length;\n const stateSnapshot = copilotkit.getStateByRun(agentId, threadId, runId);\n\n let result = null;\n for (const renderer of customMessageRenderers) {\n if (!renderer.render) {\n continue;\n }\n const Component = renderer.render;\n result = (\n <Component\n key={`${runId}-${message.id}-${position}`}\n message={message}\n position={position}\n runId={runId}\n messageIndex={messageIndex}\n messageIndexInRun={messageIndexInRun}\n numberOfMessagesInRun={numberOfMessagesInRun}\n agentId={agentId}\n stateSnapshot={stateSnapshot}\n />\n );\n if (result) {\n break;\n }\n }\n return result;\n };\n}\n","import { ActivityMessage } from \"@ag-ui/core\";\nimport { DEFAULT_AGENT_ID } from \"@copilotkitnext/shared\";\nimport { useCopilotKit, useCopilotChatConfiguration } from \"@/providers\";\nimport { useCallback } from \"react\";\n\nexport function useRenderActivityMessage() {\n const { copilotkit } = useCopilotKit();\n const config = useCopilotChatConfiguration();\n const agentId = config?.agentId ?? DEFAULT_AGENT_ID;\n\n const renderers = copilotkit.renderActivityMessages;\n\n return useCallback(\n (message: ActivityMessage): React.ReactElement | null => {\n if (!renderers.length) {\n return null;\n }\n\n const matches = renderers.filter(\n (renderer) => renderer.activityType === message.activityType\n );\n\n const renderer =\n matches.find((candidate) => candidate.agentId === agentId) ??\n matches.find((candidate) => candidate.agentId === undefined) ??\n renderers.find((candidate) => candidate.activityType === \"*\");\n\n if (!renderer) {\n return null;\n }\n\n const parseResult = renderer.content.safeParse(message.content);\n\n if (!parseResult.success) {\n console.warn(\n `Failed to parse content for activity message '${message.activityType}':`,\n parseResult.error\n );\n return null;\n }\n\n const Component = renderer.render;\n\n const agent = copilotkit.getAgent(agentId);\n\n return (\n <Component\n key={message.id}\n activityType={message.activityType}\n content={parseResult.data}\n message={message}\n agent={agent}\n />\n );\n },\n [agentId, copilotkit, renderers]\n );\n}\n","import { useEffect } from \"react\";\nimport { useCopilotKit } from \"../providers/CopilotKitProvider\";\nimport { ReactFrontendTool } from \"../types/frontend-tool\";\nimport { ReactToolCallRenderer } from \"../types/react-tool-call-renderer\";\n\nexport function useFrontendTool<\n T extends Record<string, unknown> = Record<string, unknown>,\n>(tool: ReactFrontendTool<T>) {\n const { copilotkit } = useCopilotKit();\n\n useEffect(() => {\n const name = tool.name;\n\n // Always register/override the tool for this name on mount\n if (copilotkit.getTool({ toolName: name, agentId: tool.agentId })) {\n console.warn(\n `Tool '${name}' already exists for agent '${tool.agentId || 'global'}'. Overriding with latest registration.`\n );\n copilotkit.removeTool(name, tool.agentId);\n }\n copilotkit.addTool(tool);\n\n // Register/override renderer by name and agentId through core\n if (tool.render) {\n // Get current render tool calls and merge with new entry\n const keyOf = (rc: ReactToolCallRenderer<any>) => `${rc.agentId ?? \"\"}:${rc.name}`;\n const currentRenderToolCalls = copilotkit.renderToolCalls as ReactToolCallRenderer<any>[];\n\n // Build map from existing entries\n const mergedMap = new Map<string, ReactToolCallRenderer<any>>();\n for (const rc of currentRenderToolCalls) {\n mergedMap.set(keyOf(rc), rc);\n }\n\n // Add/overwrite with new entry\n const newEntry = {\n name,\n args: tool.parameters,\n agentId: tool.agentId,\n render: tool.render,\n } as ReactToolCallRenderer<any>;\n mergedMap.set(keyOf(newEntry), newEntry);\n\n // Set the merged list back\n copilotkit.setRenderToolCalls(Array.from(mergedMap.values()));\n }\n\n return () => {\n copilotkit.removeTool(name, tool.agentId);\n // we are intentionally not removing the render here so that the tools can still render in the chat history\n };\n // Depend only on stable keys to avoid re-register loops due to object identity\n }, [tool.name, copilotkit]);\n}\n","import { ReactToolCallRenderer } from \"@/types/react-tool-call-renderer\";\nimport { useFrontendTool } from \"./use-frontend-tool\";\nimport { ReactFrontendTool } from \"@/types/frontend-tool\";\nimport { ReactHumanInTheLoop } from \"@/types/human-in-the-loop\";\nimport { useCallback, useRef, useEffect } from \"react\";\nimport React from \"react\";\nimport { useCopilotKit } from \"@/providers/CopilotKitProvider\";\n\nexport function useHumanInTheLoop<T extends Record<string, unknown> = Record<string, unknown>>(\n tool: ReactHumanInTheLoop<T>,\n) {\n const { copilotkit } = useCopilotKit();\n const resolvePromiseRef = useRef<((result: unknown) => void) | null>(null);\n\n const respond = useCallback(async (result: unknown) => {\n if (resolvePromiseRef.current) {\n resolvePromiseRef.current(result);\n resolvePromiseRef.current = null;\n }\n }, []);\n\n const handler = useCallback(async () => {\n return new Promise((resolve) => {\n resolvePromiseRef.current = resolve;\n });\n }, []);\n\n const RenderComponent: ReactToolCallRenderer<T>[\"render\"] = useCallback(\n (props) => {\n const ToolComponent = tool.render;\n\n // Enhance props based on current status\n if (props.status === \"inProgress\") {\n const enhancedProps = {\n ...props,\n name: tool.name,\n description: tool.description || \"\",\n respond: undefined,\n };\n return React.createElement(ToolComponent, enhancedProps);\n } else if (props.status === \"executing\") {\n const enhancedProps = {\n ...props,\n name: tool.name,\n description: tool.description || \"\",\n respond,\n };\n return React.createElement(ToolComponent, enhancedProps);\n } else if (props.status === \"complete\") {\n const enhancedProps = {\n ...props,\n name: tool.name,\n description: tool.description || \"\",\n respond: undefined,\n };\n return React.createElement(ToolComponent, enhancedProps);\n }\n\n // Fallback - just render with original props\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return React.createElement(ToolComponent, props as any);\n },\n [tool.render, tool.name, tool.description, respond],\n );\n\n const frontendTool: ReactFrontendTool<T> = {\n ...tool,\n handler,\n render: RenderComponent,\n };\n\n useFrontendTool(frontendTool);\n\n // Human-in-the-loop tools should remove their renderer on unmount\n // since they can't respond to user interactions anymore\n useEffect(() => {\n return () => {\n const keyOf = (rc: ReactToolCallRenderer<any>) => `${rc.agentId ?? \"\"}:${rc.name}`;\n const currentRenderToolCalls = copilotkit.renderToolCalls as ReactToolCallRenderer<any>[];\n const filtered = currentRenderToolCalls.filter(\n (rc) => keyOf(rc) !== keyOf({ name: tool.name, agentId: tool.agentId } as any),\n );\n copilotkit.setRenderToolCalls(filtered);\n };\n }, [copilotkit, tool.name, tool.agentId]);\n}\n","import { useCopilotKit } from \"@/providers/CopilotKitProvider\";\nimport { useMemo, useEffect, useReducer } from \"react\";\nimport { DEFAULT_AGENT_ID } from \"@copilotkitnext/shared\";\nimport { AbstractAgent } from \"@ag-ui/client\";\n\nexport enum UseAgentUpdate {\n OnMessagesChanged = \"OnMessagesChanged\",\n OnStateChanged = \"OnStateChanged\",\n OnRunStatusChanged = \"OnRunStatusChanged\",\n}\n\nconst ALL_UPDATES: UseAgentUpdate[] = [\n UseAgentUpdate.OnMessagesChanged,\n UseAgentUpdate.OnStateChanged,\n UseAgentUpdate.OnRunStatusChanged,\n];\n\nexport interface UseAgentProps {\n agentId?: string;\n updates?: UseAgentUpdate[];\n}\n\nexport function useAgent({ agentId, updates }: UseAgentProps = {}) {\n agentId ??= DEFAULT_AGENT_ID;\n\n const { copilotkit } = useCopilotKit();\n const [, forceUpdate] = useReducer((x) => x + 1, 0);\n\n const updateFlags = useMemo(\n () => updates ?? ALL_UPDATES,\n [JSON.stringify(updates)]\n );\n\n const agent: AbstractAgent | undefined = useMemo(() => {\n return copilotkit.getAgent(agentId);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n agentId,\n copilotkit.agents,\n copilotkit.runtimeConnectionStatus,\n copilotkit,\n ]);\n\n useEffect(() => {\n if (!agent) {\n return;\n }\n\n if (updateFlags.length === 0) {\n return;\n }\n\n const handlers: Parameters<AbstractAgent[\"subscribe\"]>[0] = {};\n\n if (updateFlags.includes(UseAgentUpdate.OnMessagesChanged)) {\n handlers.onMessagesChanged = () => {\n forceUpdate();\n };\n }\n\n if (updateFlags.includes(UseAgentUpdate.OnStateChanged)) {\n handlers.onStateChanged = () => {\n forceUpdate();\n };\n }\n\n if (updateFlags.includes(UseAgentUpdate.OnRunStatusChanged)) {\n handlers.onRunInitialized = () => {\n forceUpdate();\n };\n handlers.onRunFinalized = () => {\n forceUpdate();\n };\n handlers.onRunFailed = () => {\n forceUpdate();\n };\n }\n\n const subscription = agent.subscribe(handlers);\n return () => subscription.unsubscribe();\n }, [agent, forceUpdate, JSON.stringify(updateFlags)]);\n\n return {\n agent,\n };\n}\n","import { useCopilotKit } from \"../providers/CopilotKitProvider\";\nimport { Context } from \"@ag-ui/client\";\nimport { useEffect } from \"react\";\n\nexport function useAgentContext(context: Context) {\n const { description, value } = context;\n const { copilotkit } = useCopilotKit();\n\n useEffect(() => {\n if (!copilotkit) return;\n\n const id = copilotkit.addContext(context);\n return () => {\n copilotkit.removeContext(id);\n };\n }, [description, value, copilotkit]);\n}\n","import { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { Suggestion } from \"@copilotkitnext/core\";\nimport { useCopilotKit } from \"@/providers/CopilotKitProvider\";\nimport { useCopilotChatConfiguration } from \"@/providers/CopilotChatConfigurationProvider\";\nimport { DEFAULT_AGENT_ID } from \"@copilotkitnext/shared\";\n\nexport interface UseSuggestionsOptions {\n agentId?: string;\n}\n\nexport interface UseSuggestionsResult {\n suggestions: Suggestion[];\n reloadSuggestions: () => void;\n clearSuggestions: () => void;\n isLoading: boolean;\n}\n\nexport function useSuggestions({ agentId }: UseSuggestionsOptions = {}): UseSuggestionsResult {\n const { copilotkit } = useCopilotKit();\n const config = useCopilotChatConfiguration();\n const resolvedAgentId = useMemo(() => agentId ?? config?.agentId ?? DEFAULT_AGENT_ID, [agentId, config?.agentId]);\n\n const [suggestions, setSuggestions] = useState<Suggestion[]>(() => {\n const result = copilotkit.getSuggestions(resolvedAgentId);\n return result.suggestions;\n });\n const [isLoading, setIsLoading] = useState(() => {\n const result = copilotkit.getSuggestions(resolvedAgentId);\n return result.isLoading;\n });\n\n useEffect(() => {\n const result = copilotkit.getSuggestions(resolvedAgentId);\n setSuggestions(result.suggestions);\n setIsLoading(result.isLoading);\n }, [copilotkit, resolvedAgentId]);\n\n useEffect(() => {\n const unsubscribe = copilotkit.subscribe({\n onSuggestionsChanged: ({ agentId: changedAgentId, suggestions }) => {\n if (changedAgentId !== resolvedAgentId) {\n return;\n }\n setSuggestions(suggestions);\n },\n onSuggestionsStartedLoading: ({ agentId: changedAgentId }) => {\n if (changedAgentId !== resolvedAgentId) {\n return;\n }\n setIsLoading(true);\n },\n onSuggestionsFinishedLoading: ({ agentId: changedAgentId }) => {\n if (changedAgentId !== resolvedAgentId) {\n return;\n }\n setIsLoading(false);\n },\n onSuggestionsConfigChanged: () => {\n const result = copilotkit.getSuggestions(resolvedAgentId);\n setSuggestions(result.suggestions);\n setIsLoading(result.isLoading);\n },\n });\n\n return () => {\n unsubscribe();\n };\n }, [copilotkit, resolvedAgentId]);\n\n const reloadSuggestions = useCallback(() => {\n copilotkit.reloadSuggestions(resolvedAgentId);\n // Loading state is handled by onSuggestionsStartedLoading event\n }, [copilotkit, resolvedAgentId]);\n\n const clearSuggestions = useCallback(() => {\n copilotkit.clearSuggestions(resolvedAgentId);\n // State updates are handled by onSuggestionsChanged event\n }, [copilotkit, resolvedAgentId]);\n\n return {\n suggestions,\n reloadSuggestions,\n clearSuggestions,\n isLoading,\n };\n}\n","import { useCallback, useEffect, useMemo, useRef } from \"react\";\nimport { useCopilotKit } from \"@/providers/CopilotKitProvider\";\nimport { useCopilotChatConfiguration } from \"@/providers/CopilotChatConfigurationProvider\";\nimport { DEFAULT_AGENT_ID } from \"@copilotkitnext/shared\";\nimport {\n DynamicSuggestionsConfig,\n StaticSuggestionsConfig,\n SuggestionsConfig,\n Suggestion,\n} from \"@copilotkitnext/core\";\n\ntype StaticSuggestionInput = Omit<Suggestion, \"isLoading\"> & Partial<Pick<Suggestion, \"isLoading\">>;\n\ntype StaticSuggestionsConfigInput = Omit<StaticSuggestionsConfig, \"suggestions\"> & {\n suggestions: StaticSuggestionInput[];\n};\n\ntype SuggestionsConfigInput = DynamicSuggestionsConfig | StaticSuggestionsConfigInput;\n\nconst EMPTY_DEPS: ReadonlyArray<unknown> = [];\n\nexport interface UseConfigureSuggestionsOptions {\n deps?: ReadonlyArray<unknown>;\n}\n\nexport function useConfigureSuggestions(\n config: SuggestionsConfigInput | null | undefined,\n options?: UseConfigureSuggestionsOptions,\n): void {\n const { copilotkit } = useCopilotKit();\n const chatConfig = useCopilotChatConfiguration();\n const extraDeps = options?.deps ?? EMPTY_DEPS;\n\n const resolvedConsumerAgentId = useMemo(() => chatConfig?.agentId ?? DEFAULT_AGENT_ID, [chatConfig?.agentId]);\n\n const rawConsumerAgentId = useMemo(() => (config ? (config as SuggestionsConfigInput).consumerAgentId : undefined), [config]);\n\n const normalizationCacheRef = useRef<{ serialized: string | null; config: SuggestionsConfig | null }>({\n serialized: null,\n config: null,\n });\n\n const { normalizedConfig, serializedConfig } = useMemo(() => {\n if (!config) {\n normalizationCacheRef.current = { serialized: null, config: null };\n return { normalizedConfig: null, serializedConfig: null };\n }\n\n if (config.available === \"disabled\") {\n normalizationCacheRef.current = { serialized: null, config: null };\n return { normalizedConfig: null, serializedConfig: null };\n }\n\n let built: SuggestionsConfig;\n if (isDynamicConfig(config)) {\n built = {\n ...config,\n } satisfies DynamicSuggestionsConfig;\n } else {\n const normalizedSuggestions = normalizeStaticSuggestions(config.suggestions);\n const baseConfig: StaticSuggestionsConfig = {\n ...config,\n suggestions: normalizedSuggestions,\n };\n built = baseConfig;\n }\n\n const serialized = JSON.stringify(built);\n const cache = normalizationCacheRef.current;\n if (cache.serialized === serialized && cache.config) {\n return { normalizedConfig: cache.config, serializedConfig: serialized };\n }\n\n normalizationCacheRef.current = { serialized, config: built };\n return { normalizedConfig: built, serializedConfig: serialized };\n }, [config, resolvedConsumerAgentId, ...extraDeps]);\n const latestConfigRef = useRef<SuggestionsConfig | null>(null);\n latestConfigRef.current = normalizedConfig;\n const previousSerializedConfigRef = useRef<string | null>(null);\n\n const targetAgentId = useMemo(() => {\n if (!normalizedConfig) {\n return resolvedConsumerAgentId;\n }\n const consumer = (normalizedConfig as StaticSuggestionsConfig | DynamicSuggestionsConfig).consumerAgentId;\n if (!consumer || consumer === \"*\") {\n return resolvedConsumerAgentId;\n }\n return consumer;\n }, [normalizedConfig, resolvedConsumerAgentId]);\n\n const isGlobalConfig = rawConsumerAgentId === undefined || rawConsumerAgentId === \"*\";\n\n const requestReload = useCallback(() => {\n if (!normalizedConfig) {\n return;\n }\n\n if (isGlobalConfig) {\n const agents = Object.values(copilotkit.agents ?? {});\n for (const entry of agents) {\n const agentId = entry.agentId;\n if (!agentId) {\n continue;\n }\n if (!entry.isRunning) {\n copilotkit.reloadSuggestions(agentId);\n }\n }\n return;\n }\n\n if (!targetAgentId) {\n return;\n }\n\n copilotkit.reloadSuggestions(targetAgentId);\n }, [copilotkit, isGlobalConfig, normalizedConfig, targetAgentId]);\n\n useEffect(() => {\n if (!serializedConfig || !latestConfigRef.current) {\n return;\n }\n\n const id = copilotkit.addSuggestionsConfig(latestConfigRef.current);\n\n requestReload();\n\n return () => {\n copilotkit.removeSuggestionsConfig(id);\n };\n }, [copilotkit, serializedConfig, requestReload]);\n\n useEffect(() => {\n if (!normalizedConfig) {\n previousSerializedConfigRef.current = null;\n return;\n }\n if (serializedConfig && previousSerializedConfigRef.current === serializedConfig) {\n return;\n }\n if (serializedConfig) {\n previousSerializedConfigRef.current = serializedConfig;\n }\n requestReload();\n }, [normalizedConfig, requestReload, serializedConfig]);\n\n useEffect(() => {\n if (!normalizedConfig || extraDeps.length === 0) {\n return;\n }\n requestReload();\n }, [extraDeps.length, normalizedConfig, requestReload, ...extraDeps]);\n\n}\n\nfunction isDynamicConfig(config: SuggestionsConfigInput): config is DynamicSuggestionsConfig {\n return \"instructions\" in config;\n}\n\nfunction normalizeStaticSuggestions(suggestions: StaticSuggestionInput[]): Suggestion[] {\n return suggestions.map((suggestion) => ({\n ...suggestion,\n isLoading: suggestion.isLoading ?? false,\n }));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,gBAA8E;AAE9E,IAAAC,eAA+B;;;ACA/B,IAAAC,gBASO;AAKP,iBAAkB;;;ACdlB,kBAA+E;;;ACF/E,YAAuB;AACvB,mBAAgC;AAChC,2BAIO;AAiCD;AAAA,IA9BN,yCAAmB;AAEnB,IAAM,8BAA0B,8BAAgB;AAAA,EAC9C,SAAS;AAAA,EACT,cAAc;AAAA,EACd,OAAO;AACT,CAAC;AAQM,IAAM,sBAA4B;AAAA,EAIvC,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,QAAQ;AAC1B,UAAM,WAAiB,aAA4B,IAAI;AAEvD,IAAM,0BAAoB,KAAK,MAAM,SAAS,SAAg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AAkB,aAAa,CAAC;AAEhE,gCAAU,MAAM;AACd,QAAI,CAAC,oBAAoB,CAAC,gBAAgB,SAAS;AACjD;AAAA,IACF;AAEA,UAAM,KAAK,WAAW,qBAAqB,gBAAgB,OAAO;AAElE,kBAAc;AAEd,WAAO,MAAM;AACX,iBAAW,wBAAwB,EAAE;AAAA,IACvC;AAAA,EACF,GAAG,CAAC,YAAY,kBAAkB,aAAa,CAAC;AAEhD,gCAAU,MAAM;AACd,QAAI,CAAC,kBAAkB;AACrB,kCAA4B,UAAU;AACtC;AAAA,IACF;AACA,QAAI,oBAAoB,4BAA4B,YAAY,kBAAkB;AAChF;AAAA,IACF;AACA,QAAI,kBAAkB;AACpB,kCAA4B,UAAU;AAAA,IACxC;AACA,kBAAc;AAAA,EAChB,GAAG,CAAC,kBAAkB,eAAe,gBAAgB,CAAC;AAEtD,gCAAU,MAAM;AACd,QAAI,CAAC,oBAAoB,UAAU,WAAW,GAAG;AAC/C;AAAA,IACF;AACA,kBAAc;AAAA,EAChB,GAAG,CAAC,UAAU,QAAQ,kBAAkB,eAAe,GAAG,SAAS,CAAC;AAEtE;AAEA,SAAS,gBAAgB,QAAoE;AAC3F,SAAO,kBAAkB;AAC3B;AAEA,SAAS,2BAA2B,aAAoD;AACtF,SAAO,YAAY,IAAI,CAAC,gBAAgB;AAAA,IACtC,GAAG;AAAA,IACH,WAAW,WAAW,aAAa;AAAA,EACrC,EAAE;AACJ;","names":["import_react","import_core","import_react","import_jsx_runtime","import_react","import_jsx_runtime","import_shared","import_jsx_runtime","import_jsx_runtime","import_shared","import_react","import_jsx_runtime","renderer","import_react","import_react","React","import_react","import_shared","import_react","import_react","import_shared","suggestions","import_react","import_shared"]}
|
package/dist/hooks/index.mjs
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import "../chunk-ETWJDCGE.mjs";
|
|
2
|
-
import {
|
|
3
|
-
useHumanInTheLoop
|
|
4
|
-
} from "../chunk-CGLGXQAU.mjs";
|
|
5
|
-
import {
|
|
6
|
-
useFrontendTool
|
|
7
|
-
} from "../chunk-IICUCI5S.mjs";
|
|
8
|
-
import {
|
|
9
|
-
useRenderActivityMessage
|
|
10
|
-
} from "../chunk-RK5P2LG6.mjs";
|
|
11
|
-
import {
|
|
12
|
-
useRenderCustomMessages
|
|
13
|
-
} from "../chunk-5SC3CO5Q.mjs";
|
|
14
|
-
import "../chunk-YZUPVMHC.mjs";
|
|
15
|
-
import {
|
|
16
|
-
useRenderToolCall
|
|
17
|
-
} from "../chunk-AXFRCGH6.mjs";
|
|
18
|
-
import {
|
|
19
|
-
useSuggestions
|
|
20
|
-
} from "../chunk-XU5CEPYQ.mjs";
|
|
21
|
-
import {
|
|
22
|
-
useAgentContext
|
|
23
|
-
} from "../chunk-UOX5D73C.mjs";
|
|
24
|
-
import {
|
|
25
|
-
useAgent
|
|
26
|
-
} from "../chunk-IA4CLXDM.mjs";
|
|
27
|
-
import {
|
|
28
|
-
useConfigureSuggestions
|
|
29
|
-
} from "../chunk-NB2GZAKG.mjs";
|
|
30
|
-
import "../chunk-4XJK5IVQ.mjs";
|
|
31
|
-
import "../chunk-RF2CGPHQ.mjs";
|
|
32
|
-
import "../chunk-NNAYEAP2.mjs";
|
|
33
|
-
import "../chunk-YPH4BHOY.mjs";
|
|
34
|
-
export {
|
|
35
|
-
useAgent,
|
|
36
|
-
useAgentContext,
|
|
37
|
-
useConfigureSuggestions,
|
|
38
|
-
useFrontendTool,
|
|
39
|
-
useHumanInTheLoop,
|
|
40
|
-
useRenderActivityMessage,
|
|
41
|
-
useRenderCustomMessages,
|
|
42
|
-
useRenderToolCall,
|
|
43
|
-
useSuggestions
|
|
44
|
-
};
|
|
45
|
-
//# sourceMappingURL=index.mjs.map
|
package/dist/hooks/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/hooks/use-agent-context.tsx
|
|
31
|
-
var use_agent_context_exports = {};
|
|
32
|
-
__export(use_agent_context_exports, {
|
|
33
|
-
useAgentContext: () => useAgentContext
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(use_agent_context_exports);
|
|
36
|
-
|
|
37
|
-
// src/providers/CopilotKitProvider.tsx
|
|
38
|
-
var import_react2 = require("react");
|
|
39
|
-
var import_zod = require("zod");
|
|
40
|
-
|
|
41
|
-
// src/lib/react-core.ts
|
|
42
|
-
var import_core = require("@copilotkitnext/core");
|
|
43
|
-
|
|
44
|
-
// src/components/CopilotKitInspector.tsx
|
|
45
|
-
var React = __toESM(require("react"));
|
|
46
|
-
var import_react = require("@lit-labs/react");
|
|
47
|
-
var import_web_inspector = require("@copilotkitnext/web-inspector");
|
|
48
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
49
|
-
(0, import_web_inspector.defineWebInspector)();
|
|
50
|
-
var CopilotKitInspectorBase = (0, import_react.createComponent)({
|
|
51
|
-
tagName: import_web_inspector.WEB_INSPECTOR_TAG,
|
|
52
|
-
elementClass: import_web_inspector.WebInspectorElement,
|
|
53
|
-
react: React
|
|
54
|
-
});
|
|
55
|
-
var CopilotKitInspector = React.forwardRef(
|
|
56
|
-
({ core, ...rest }, ref) => {
|
|
57
|
-
const innerRef = React.useRef(null);
|
|
58
|
-
React.useImperativeHandle(ref, () => innerRef.current, []);
|
|
59
|
-
React.useEffect(() => {
|
|
60
|
-
if (innerRef.current) {
|
|
61
|
-
innerRef.current.core = core ?? null;
|
|
62
|
-
}
|
|
63
|
-
}, [core]);
|
|
64
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
65
|
-
CopilotKitInspectorBase,
|
|
66
|
-
{
|
|
67
|
-
...rest,
|
|
68
|
-
ref: innerRef
|
|
69
|
-
}
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
);
|
|
73
|
-
CopilotKitInspector.displayName = "CopilotKitInspector";
|
|
74
|
-
|
|
75
|
-
// src/providers/CopilotKitProvider.tsx
|
|
76
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
77
|
-
var CopilotKitContext = (0, import_react2.createContext)({
|
|
78
|
-
copilotkit: null
|
|
79
|
-
});
|
|
80
|
-
var useCopilotKit = () => {
|
|
81
|
-
const context = (0, import_react2.useContext)(CopilotKitContext);
|
|
82
|
-
const [, forceUpdate] = (0, import_react2.useReducer)((x) => x + 1, 0);
|
|
83
|
-
if (!context) {
|
|
84
|
-
throw new Error("useCopilotKit must be used within CopilotKitProvider");
|
|
85
|
-
}
|
|
86
|
-
(0, import_react2.useEffect)(() => {
|
|
87
|
-
const unsubscribe = context.copilotkit.subscribe({
|
|
88
|
-
onRuntimeConnectionStatusChanged: () => {
|
|
89
|
-
forceUpdate();
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
return () => {
|
|
93
|
-
unsubscribe();
|
|
94
|
-
};
|
|
95
|
-
}, []);
|
|
96
|
-
return context;
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
// src/hooks/use-agent-context.tsx
|
|
100
|
-
var import_react3 = require("react");
|
|
101
|
-
function useAgentContext(context) {
|
|
102
|
-
const { description, value } = context;
|
|
103
|
-
const { copilotkit } = useCopilotKit();
|
|
104
|
-
(0, import_react3.useEffect)(() => {
|
|
105
|
-
if (!copilotkit) return;
|
|
106
|
-
const id = copilotkit.addContext(context);
|
|
107
|
-
return () => {
|
|
108
|
-
copilotkit.removeContext(id);
|
|
109
|
-
};
|
|
110
|
-
}, [description, value, copilotkit]);
|
|
111
|
-
}
|
|
112
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
113
|
-
0 && (module.exports = {
|
|
114
|
-
useAgentContext
|
|
115
|
-
});
|
|
116
|
-
//# sourceMappingURL=use-agent-context.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hooks/use-agent-context.tsx","../../src/providers/CopilotKitProvider.tsx","../../src/lib/react-core.ts","../../src/components/CopilotKitInspector.tsx"],"sourcesContent":["import { useCopilotKit } from \"../providers/CopilotKitProvider\";\nimport { Context } from \"@ag-ui/client\";\nimport { useEffect } from \"react\";\n\nexport function useAgentContext(context: Context) {\n const { description, value } = context;\n const { copilotkit } = useCopilotKit();\n\n useEffect(() => {\n if (!copilotkit) return;\n\n const id = copilotkit.addContext(context);\n return () => {\n copilotkit.removeContext(id);\n };\n }, [description, value, copilotkit]);\n}\n","\"use client\";\n\nimport React, {\n createContext,\n useContext,\n ReactNode,\n useMemo,\n useEffect,\n useReducer,\n useRef,\n useState,\n} from \"react\";\nimport { ReactActivityMessageRenderer, ReactToolCallRenderer } from \"../types\";\nimport { ReactCustomMessageRenderer } from \"../types/react-custom-message-renderer\";\nimport { ReactFrontendTool } from \"../types/frontend-tool\";\nimport { ReactHumanInTheLoop } from \"../types/human-in-the-loop\";\nimport { z } from \"zod\";\nimport { FrontendTool } from \"@copilotkitnext/core\";\nimport { AbstractAgent } from \"@ag-ui/client\";\nimport { CopilotKitCoreReact } from \"../lib/react-core\";\nimport { CopilotKitInspector } from \"../components/CopilotKitInspector\";\n\n// Define the context value interface - idiomatic React naming\nexport interface CopilotKitContextValue {\n copilotkit: CopilotKitCoreReact;\n}\n\n// Create the CopilotKit context\nconst CopilotKitContext = createContext<CopilotKitContextValue>({\n copilotkit: null!,\n});\n\n// Provider props interface\nexport interface CopilotKitProviderProps {\n children: ReactNode;\n runtimeUrl?: string;\n headers?: Record<string, string>;\n properties?: Record<string, unknown>;\n useSingleEndpoint?: boolean;\n agents__unsafe_dev_only?: Record<string, AbstractAgent>;\n renderToolCalls?: ReactToolCallRenderer<any>[];\n renderActivityMessages?: ReactActivityMessageRenderer<any>[];\n renderCustomMessages?: ReactCustomMessageRenderer[];\n frontendTools?: ReactFrontendTool[];\n humanInTheLoop?: ReactHumanInTheLoop[];\n showDevConsole?: boolean | \"auto\";\n}\n\n// Small helper to normalize array props to a stable reference and warn\nfunction useStableArrayProp<T>(\n prop: T[] | undefined,\n warningMessage?: string,\n isMeaningfulChange?: (initial: T[], next: T[]) => boolean,\n): T[] {\n const empty = useMemo<T[]>(() => [], []);\n const value = prop ?? empty;\n const initial = useRef(value);\n\n useEffect(() => {\n if (\n warningMessage &&\n value !== initial.current &&\n (isMeaningfulChange ? isMeaningfulChange(initial.current, value) : true)\n ) {\n console.error(warningMessage);\n }\n }, [value, warningMessage]);\n\n return value;\n}\n\n// Provider component\nexport const CopilotKitProvider: React.FC<CopilotKitProviderProps> = ({\n children,\n runtimeUrl,\n headers = {},\n properties = {},\n agents__unsafe_dev_only: agents = {},\n renderToolCalls,\n renderActivityMessages,\n renderCustomMessages,\n frontendTools,\n humanInTheLoop,\n showDevConsole = false,\n useSingleEndpoint = false,\n}) => {\n const [shouldRenderInspector, setShouldRenderInspector] = useState(false);\n\n useEffect(() => {\n if (typeof window === \"undefined\") {\n return;\n }\n\n if (showDevConsole === true) {\n // Explicitly show the inspector\n setShouldRenderInspector(true);\n } else if (showDevConsole === \"auto\") {\n // Show on localhost or 127.0.0.1 only\n const localhostHosts = new Set([\"localhost\", \"127.0.0.1\"]);\n if (localhostHosts.has(window.location.hostname)) {\n setShouldRenderInspector(true);\n } else {\n setShouldRenderInspector(false);\n }\n } else {\n // showDevConsole is false or undefined (default false)\n setShouldRenderInspector(false);\n }\n }, [showDevConsole]);\n\n // Normalize array props to stable references with clear dev warnings\n const renderToolCallsList = useStableArrayProp<ReactToolCallRenderer<any>>(\n renderToolCalls,\n \"renderToolCalls must be a stable array. If you want to dynamically add or remove tools, use `useFrontendTool` instead.\",\n (initial, next) => {\n // Only warn if the shape (names+agentId) changed. Allow identity changes\n // to support updated closures from parents (e.g., Storybook state).\n const key = (rc?: ReactToolCallRenderer<unknown>) => `${rc?.agentId ?? \"\"}:${rc?.name ?? \"\"}`;\n const setFrom = (arr: ReactToolCallRenderer<unknown>[]) => new Set(arr.map(key));\n const a = setFrom(initial);\n const b = setFrom(next);\n if (a.size !== b.size) return true;\n for (const k of a) if (!b.has(k)) return true;\n return false;\n },\n );\n\n const renderCustomMessagesList = useStableArrayProp<ReactCustomMessageRenderer>(\n renderCustomMessages,\n \"renderCustomMessages must be a stable array.\",\n );\n\n const renderActivityMessagesList = useStableArrayProp<ReactActivityMessageRenderer<any>>(\n renderActivityMessages,\n \"renderActivityMessages must be a stable array.\",\n );\n\n const frontendToolsList = useStableArrayProp<ReactFrontendTool>(\n frontendTools,\n \"frontendTools must be a stable array. If you want to dynamically add or remove tools, use `useFrontendTool` instead.\",\n );\n const humanInTheLoopList = useStableArrayProp<ReactHumanInTheLoop>(\n humanInTheLoop,\n \"humanInTheLoop must be a stable array. If you want to dynamically add or remove human-in-the-loop tools, use `useHumanInTheLoop` instead.\",\n );\n\n // Note: warnings for array identity changes are handled by useStableArrayProp\n\n // Process humanInTheLoop tools to create handlers and add render components\n const processedHumanInTheLoopTools = useMemo(() => {\n const processedTools: FrontendTool[] = [];\n const processedRenderToolCalls: ReactToolCallRenderer<unknown>[] = [];\n\n humanInTheLoopList.forEach((tool) => {\n // Create a promise-based handler for each human-in-the-loop tool\n const frontendTool: FrontendTool = {\n name: tool.name,\n description: tool.description,\n parameters: tool.parameters,\n followUp: tool.followUp,\n ...(tool.agentId && { agentId: tool.agentId }),\n handler: async () => {\n // This handler will be replaced by the hook when it runs\n // For provider-level tools, we create a basic handler that waits for user interaction\n return new Promise((resolve) => {\n // The actual implementation will be handled by the render component\n // This is a placeholder that the hook will override\n console.warn(`Human-in-the-loop tool '${tool.name}' called but no interactive handler is set up.`);\n resolve(undefined);\n });\n },\n };\n processedTools.push(frontendTool);\n\n // Add the render component to renderToolCalls\n if (tool.render) {\n processedRenderToolCalls.push({\n name: tool.name,\n args: tool.parameters!,\n render: tool.render,\n ...(tool.agentId && { agentId: tool.agentId }),\n } as ReactToolCallRenderer<unknown>);\n }\n });\n\n return { tools: processedTools, renderToolCalls: processedRenderToolCalls };\n }, [humanInTheLoopList]);\n\n // Combine all tools for CopilotKitCore\n const allTools = useMemo(() => {\n const tools: FrontendTool[] = [];\n\n // Add frontend tools\n tools.push(...frontendToolsList);\n\n // Add processed human-in-the-loop tools\n tools.push(...processedHumanInTheLoopTools.tools);\n\n return tools;\n }, [frontendToolsList, processedHumanInTheLoopTools]);\n\n // Combine all render tool calls\n const allRenderToolCalls = useMemo(() => {\n const combined: ReactToolCallRenderer<unknown>[] = [...renderToolCallsList];\n\n // Add render components from frontend tools\n frontendToolsList.forEach((tool) => {\n if (tool.render) {\n // For wildcard tools without parameters, default to z.any()\n const args = tool.parameters || (tool.name === \"*\" ? z.any() : undefined);\n if (args) {\n combined.push({\n name: tool.name,\n args: args,\n render: tool.render,\n } as ReactToolCallRenderer<unknown>);\n }\n }\n });\n\n // Add render components from human-in-the-loop tools\n combined.push(...processedHumanInTheLoopTools.renderToolCalls);\n\n return combined;\n }, [renderToolCallsList, frontendToolsList, processedHumanInTheLoopTools]);\n\n const copilotkit = useMemo(() => {\n const copilotkit = new CopilotKitCoreReact({\n runtimeUrl,\n runtimeTransport: useSingleEndpoint ? \"single\" : \"rest\",\n headers,\n properties,\n agents__unsafe_dev_only: agents,\n tools: allTools,\n renderToolCalls: allRenderToolCalls,\n renderActivityMessages: renderActivityMessagesList,\n renderCustomMessages: renderCustomMessagesList,\n });\n\n return copilotkit;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [allTools, allRenderToolCalls, renderActivityMessagesList, renderCustomMessagesList, useSingleEndpoint]);\n\n // Subscribe to render tool calls changes to force re-renders\n const [, forceUpdate] = useReducer((x) => x + 1, 0);\n\n useEffect(() => {\n const unsubscribe = copilotkit.subscribe({\n onRenderToolCallsChanged: () => {\n forceUpdate();\n },\n });\n\n return () => {\n unsubscribe();\n };\n }, [copilotkit]);\n\n useEffect(() => {\n copilotkit.setRuntimeUrl(runtimeUrl);\n copilotkit.setRuntimeTransport(useSingleEndpoint ? \"single\" : \"rest\");\n copilotkit.setHeaders(headers);\n copilotkit.setProperties(properties);\n copilotkit.setAgents__unsafe_dev_only(agents);\n }, [runtimeUrl, headers, properties, agents, useSingleEndpoint]);\n\n return (\n <CopilotKitContext.Provider\n value={{\n copilotkit,\n }}\n >\n {children}\n {shouldRenderInspector ? <CopilotKitInspector core={copilotkit} /> : null}\n </CopilotKitContext.Provider>\n );\n};\n\n// Hook to use the CopilotKit instance - returns the full context value\nexport const useCopilotKit = (): CopilotKitContextValue => {\n const context = useContext(CopilotKitContext);\n const [, forceUpdate] = useReducer((x) => x + 1, 0);\n\n if (!context) {\n throw new Error(\"useCopilotKit must be used within CopilotKitProvider\");\n }\n useEffect(() => {\n const unsubscribe = context.copilotkit.subscribe({\n onRuntimeConnectionStatusChanged: () => {\n forceUpdate();\n },\n });\n return () => {\n unsubscribe();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return context;\n};\n","import { ReactActivityMessageRenderer, ReactToolCallRenderer } from \"@/types\";\nimport { ReactCustomMessageRenderer } from \"@/types/react-custom-message-renderer\";\nimport { CopilotKitCore, CopilotKitCoreConfig, CopilotKitCoreSubscriber } from \"@copilotkitnext/core\";\n\nexport interface CopilotKitCoreReactConfig extends CopilotKitCoreConfig {\n // Add any additional configuration properties specific to the React implementation\n renderToolCalls?: ReactToolCallRenderer<any>[];\n renderActivityMessages?: ReactActivityMessageRenderer<any>[];\n\n // Add custom message renderers\n renderCustomMessages?: ReactCustomMessageRenderer[];\n}\n\nexport interface CopilotKitCoreReactSubscriber extends CopilotKitCoreSubscriber {\n onRenderToolCallsChanged?: (event: {\n copilotkit: CopilotKitCore;\n renderToolCalls: ReactToolCallRenderer<any>[];\n }) => void | Promise<void>;\n}\n\nexport class CopilotKitCoreReact extends CopilotKitCore {\n private _renderToolCalls: ReactToolCallRenderer<any>[] = [];\n private _renderCustomMessages: ReactCustomMessageRenderer[] = [];\n private _renderActivityMessages: ReactActivityMessageRenderer<any>[] = [];\n\n constructor(config: CopilotKitCoreReactConfig) {\n super(config);\n this._renderToolCalls = config.renderToolCalls ?? [];\n this._renderCustomMessages = config.renderCustomMessages ?? [];\n this._renderActivityMessages = config.renderActivityMessages ?? [];\n }\n\n get renderCustomMessages(): Readonly<ReactCustomMessageRenderer[]> {\n return this._renderCustomMessages;\n }\n\n get renderActivityMessages(): Readonly<ReactActivityMessageRenderer<any>>[] {\n return this._renderActivityMessages;\n }\n\n get renderToolCalls(): Readonly<ReactToolCallRenderer<any>>[] {\n return this._renderToolCalls;\n }\n\n setRenderToolCalls(renderToolCalls: ReactToolCallRenderer<any>[]): void {\n this._renderToolCalls = renderToolCalls;\n\n // Notify React-specific subscribers\n void this.notifySubscribers(\n (subscriber) => {\n const reactSubscriber = subscriber as CopilotKitCoreReactSubscriber;\n if (reactSubscriber.onRenderToolCallsChanged) {\n reactSubscriber.onRenderToolCallsChanged({\n copilotkit: this,\n renderToolCalls: this.renderToolCalls,\n });\n }\n },\n \"Subscriber onRenderToolCallsChanged error:\"\n );\n }\n\n // Override to accept React-specific subscriber type\n subscribe(subscriber: CopilotKitCoreReactSubscriber): () => void {\n return super.subscribe(subscriber);\n }\n\n unsubscribe(subscriber: CopilotKitCoreReactSubscriber): void {\n super.unsubscribe(subscriber);\n }\n}\n","import * as React from \"react\";\nimport { createComponent } from \"@lit-labs/react\";\nimport {\n WEB_INSPECTOR_TAG,\n WebInspectorElement,\n defineWebInspector,\n} from \"@copilotkitnext/web-inspector\";\nimport type { CopilotKitCore } from \"@copilotkitnext/core\";\n\ndefineWebInspector();\n\nconst CopilotKitInspectorBase = createComponent({\n tagName: WEB_INSPECTOR_TAG,\n elementClass: WebInspectorElement,\n react: React,\n});\n\nexport type CopilotKitInspectorBaseProps = React.ComponentProps<typeof CopilotKitInspectorBase>;\n\nexport interface CopilotKitInspectorProps extends Omit<CopilotKitInspectorBaseProps, \"core\"> {\n core?: CopilotKitCore | null;\n}\n\nexport const CopilotKitInspector = React.forwardRef<\n WebInspectorElement,\n CopilotKitInspectorProps\n>(\n ({ core, ...rest }, ref) => {\n const innerRef = React.useRef<WebInspectorElement>(null);\n\n React.useImperativeHandle(ref, () => innerRef.current as WebInspectorElement, []);\n\n React.useEffect(() => {\n if (innerRef.current) {\n innerRef.current.core = core ?? null;\n }\n }, [core]);\n\n return (\n <CopilotKitInspectorBase\n {...(rest as CopilotKitInspectorBaseProps)}\n ref={innerRef}\n />\n ); // eslint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IACd;AAAA,EAEF,GAAG,CAAC,CAAC;AAEL,SAAO;AACT;;;ADzSA,IAAAC,gBAA0B;AAEnB,SAAS,gBAAgB,SAAkB;AAChD,QAAM,EAAE,aAAa,MAAM,IAAI;AAC/B,QAAM,EAAE,WAAW,IAAI,cAAc;AAErC,+BAAU,MAAM;AACd,QAAI,CAAC,WAAY;AAEjB,UAAM,KAAK,WAAW,WAAW,OAAO;AACxC,WAAO,MAAM;AACX,iBAAW,cAAc,EAAE;AAAA,IAC7B;AAAA,EACF,GAAG,CAAC,aAAa,OAAO,UAAU,CAAC;AACrC;","names":["import_react","import_jsx_runtime","import_react"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { AbstractAgent } from '@ag-ui/client';
|
|
2
|
-
|
|
3
|
-
declare enum UseAgentUpdate {
|
|
4
|
-
OnMessagesChanged = "OnMessagesChanged",
|
|
5
|
-
OnStateChanged = "OnStateChanged",
|
|
6
|
-
OnRunStatusChanged = "OnRunStatusChanged"
|
|
7
|
-
}
|
|
8
|
-
interface UseAgentProps {
|
|
9
|
-
agentId?: string;
|
|
10
|
-
updates?: UseAgentUpdate[];
|
|
11
|
-
}
|
|
12
|
-
declare function useAgent({ agentId, updates }?: UseAgentProps): {
|
|
13
|
-
agent: AbstractAgent | undefined;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export { type UseAgentProps, UseAgentUpdate, useAgent };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { AbstractAgent } from '@ag-ui/client';
|
|
2
|
-
|
|
3
|
-
declare enum UseAgentUpdate {
|
|
4
|
-
OnMessagesChanged = "OnMessagesChanged",
|
|
5
|
-
OnStateChanged = "OnStateChanged",
|
|
6
|
-
OnRunStatusChanged = "OnRunStatusChanged"
|
|
7
|
-
}
|
|
8
|
-
interface UseAgentProps {
|
|
9
|
-
agentId?: string;
|
|
10
|
-
updates?: UseAgentUpdate[];
|
|
11
|
-
}
|
|
12
|
-
declare function useAgent({ agentId, updates }?: UseAgentProps): {
|
|
13
|
-
agent: AbstractAgent | undefined;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export { type UseAgentProps, UseAgentUpdate, useAgent };
|
package/dist/hooks/use-agent.js
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/hooks/use-agent.tsx
|
|
31
|
-
var use_agent_exports = {};
|
|
32
|
-
__export(use_agent_exports, {
|
|
33
|
-
UseAgentUpdate: () => UseAgentUpdate,
|
|
34
|
-
useAgent: () => useAgent
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(use_agent_exports);
|
|
37
|
-
|
|
38
|
-
// src/providers/CopilotKitProvider.tsx
|
|
39
|
-
var import_react2 = require("react");
|
|
40
|
-
var import_zod = require("zod");
|
|
41
|
-
|
|
42
|
-
// src/lib/react-core.ts
|
|
43
|
-
var import_core = require("@copilotkitnext/core");
|
|
44
|
-
|
|
45
|
-
// src/components/CopilotKitInspector.tsx
|
|
46
|
-
var React = __toESM(require("react"));
|
|
47
|
-
var import_react = require("@lit-labs/react");
|
|
48
|
-
var import_web_inspector = require("@copilotkitnext/web-inspector");
|
|
49
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
50
|
-
(0, import_web_inspector.defineWebInspector)();
|
|
51
|
-
var CopilotKitInspectorBase = (0, import_react.createComponent)({
|
|
52
|
-
tagName: import_web_inspector.WEB_INSPECTOR_TAG,
|
|
53
|
-
elementClass: import_web_inspector.WebInspectorElement,
|
|
54
|
-
react: React
|
|
55
|
-
});
|
|
56
|
-
var CopilotKitInspector = React.forwardRef(
|
|
57
|
-
({ core, ...rest }, ref) => {
|
|
58
|
-
const innerRef = React.useRef(null);
|
|
59
|
-
React.useImperativeHandle(ref, () => innerRef.current, []);
|
|
60
|
-
React.useEffect(() => {
|
|
61
|
-
if (innerRef.current) {
|
|
62
|
-
innerRef.current.core = core ?? null;
|
|
63
|
-
}
|
|
64
|
-
}, [core]);
|
|
65
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
66
|
-
CopilotKitInspectorBase,
|
|
67
|
-
{
|
|
68
|
-
...rest,
|
|
69
|
-
ref: innerRef
|
|
70
|
-
}
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
);
|
|
74
|
-
CopilotKitInspector.displayName = "CopilotKitInspector";
|
|
75
|
-
|
|
76
|
-
// src/providers/CopilotKitProvider.tsx
|
|
77
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
78
|
-
var CopilotKitContext = (0, import_react2.createContext)({
|
|
79
|
-
copilotkit: null
|
|
80
|
-
});
|
|
81
|
-
var useCopilotKit = () => {
|
|
82
|
-
const context = (0, import_react2.useContext)(CopilotKitContext);
|
|
83
|
-
const [, forceUpdate] = (0, import_react2.useReducer)((x) => x + 1, 0);
|
|
84
|
-
if (!context) {
|
|
85
|
-
throw new Error("useCopilotKit must be used within CopilotKitProvider");
|
|
86
|
-
}
|
|
87
|
-
(0, import_react2.useEffect)(() => {
|
|
88
|
-
const unsubscribe = context.copilotkit.subscribe({
|
|
89
|
-
onRuntimeConnectionStatusChanged: () => {
|
|
90
|
-
forceUpdate();
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
return () => {
|
|
94
|
-
unsubscribe();
|
|
95
|
-
};
|
|
96
|
-
}, []);
|
|
97
|
-
return context;
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
// src/hooks/use-agent.tsx
|
|
101
|
-
var import_react3 = require("react");
|
|
102
|
-
var import_shared = require("@copilotkitnext/shared");
|
|
103
|
-
var UseAgentUpdate = /* @__PURE__ */ ((UseAgentUpdate2) => {
|
|
104
|
-
UseAgentUpdate2["OnMessagesChanged"] = "OnMessagesChanged";
|
|
105
|
-
UseAgentUpdate2["OnStateChanged"] = "OnStateChanged";
|
|
106
|
-
UseAgentUpdate2["OnRunStatusChanged"] = "OnRunStatusChanged";
|
|
107
|
-
return UseAgentUpdate2;
|
|
108
|
-
})(UseAgentUpdate || {});
|
|
109
|
-
var ALL_UPDATES = [
|
|
110
|
-
"OnMessagesChanged" /* OnMessagesChanged */,
|
|
111
|
-
"OnStateChanged" /* OnStateChanged */,
|
|
112
|
-
"OnRunStatusChanged" /* OnRunStatusChanged */
|
|
113
|
-
];
|
|
114
|
-
function useAgent({ agentId, updates } = {}) {
|
|
115
|
-
agentId ??= import_shared.DEFAULT_AGENT_ID;
|
|
116
|
-
const { copilotkit } = useCopilotKit();
|
|
117
|
-
const [, forceUpdate] = (0, import_react3.useReducer)((x) => x + 1, 0);
|
|
118
|
-
const updateFlags = (0, import_react3.useMemo)(
|
|
119
|
-
() => updates ?? ALL_UPDATES,
|
|
120
|
-
[JSON.stringify(updates)]
|
|
121
|
-
);
|
|
122
|
-
const agent = (0, import_react3.useMemo)(() => {
|
|
123
|
-
return copilotkit.getAgent(agentId);
|
|
124
|
-
}, [
|
|
125
|
-
agentId,
|
|
126
|
-
copilotkit.agents,
|
|
127
|
-
copilotkit.runtimeConnectionStatus,
|
|
128
|
-
copilotkit
|
|
129
|
-
]);
|
|
130
|
-
(0, import_react3.useEffect)(() => {
|
|
131
|
-
if (!agent) {
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
if (updateFlags.length === 0) {
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
const handlers = {};
|
|
138
|
-
if (updateFlags.includes("OnMessagesChanged" /* OnMessagesChanged */)) {
|
|
139
|
-
handlers.onMessagesChanged = () => {
|
|
140
|
-
forceUpdate();
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
if (updateFlags.includes("OnStateChanged" /* OnStateChanged */)) {
|
|
144
|
-
handlers.onStateChanged = () => {
|
|
145
|
-
forceUpdate();
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
if (updateFlags.includes("OnRunStatusChanged" /* OnRunStatusChanged */)) {
|
|
149
|
-
handlers.onRunInitialized = () => {
|
|
150
|
-
forceUpdate();
|
|
151
|
-
};
|
|
152
|
-
handlers.onRunFinalized = () => {
|
|
153
|
-
forceUpdate();
|
|
154
|
-
};
|
|
155
|
-
handlers.onRunFailed = () => {
|
|
156
|
-
forceUpdate();
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
const subscription = agent.subscribe(handlers);
|
|
160
|
-
return () => subscription.unsubscribe();
|
|
161
|
-
}, [agent, forceUpdate, JSON.stringify(updateFlags)]);
|
|
162
|
-
return {
|
|
163
|
-
agent
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
167
|
-
0 && (module.exports = {
|
|
168
|
-
UseAgentUpdate,
|
|
169
|
-
useAgent
|
|
170
|
-
});
|
|
171
|
-
//# sourceMappingURL=use-agent.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hooks/use-agent.tsx","../../src/providers/CopilotKitProvider.tsx","../../src/lib/react-core.ts","../../src/components/CopilotKitInspector.tsx"],"sourcesContent":["import { useCopilotKit } from \"@/providers/CopilotKitProvider\";\nimport { useMemo, useEffect, useReducer } from \"react\";\nimport { DEFAULT_AGENT_ID } from \"@copilotkitnext/shared\";\nimport { AbstractAgent } from \"@ag-ui/client\";\n\nexport enum UseAgentUpdate {\n OnMessagesChanged = \"OnMessagesChanged\",\n OnStateChanged = \"OnStateChanged\",\n OnRunStatusChanged = \"OnRunStatusChanged\",\n}\n\nconst ALL_UPDATES: UseAgentUpdate[] = [\n UseAgentUpdate.OnMessagesChanged,\n UseAgentUpdate.OnStateChanged,\n UseAgentUpdate.OnRunStatusChanged,\n];\n\nexport interface UseAgentProps {\n agentId?: string;\n updates?: UseAgentUpdate[];\n}\n\nexport function useAgent({ agentId, updates }: UseAgentProps = {}) {\n agentId ??= DEFAULT_AGENT_ID;\n\n const { copilotkit } = useCopilotKit();\n const [, forceUpdate] = useReducer((x) => x + 1, 0);\n\n const updateFlags = useMemo(\n () => updates ?? ALL_UPDATES,\n [JSON.stringify(updates)]\n );\n\n const agent: AbstractAgent | undefined = useMemo(() => {\n return copilotkit.getAgent(agentId);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n agentId,\n copilotkit.agents,\n copilotkit.runtimeConnectionStatus,\n copilotkit,\n ]);\n\n useEffect(() => {\n if (!agent) {\n return;\n }\n\n if (updateFlags.length === 0) {\n return;\n }\n\n const handlers: Parameters<AbstractAgent[\"subscribe\"]>[0] = {};\n\n if (updateFlags.includes(UseAgentUpdate.OnMessagesChanged)) {\n handlers.onMessagesChanged = () => {\n forceUpdate();\n };\n }\n\n if (updateFlags.includes(UseAgentUpdate.OnStateChanged)) {\n handlers.onStateChanged = () => {\n forceUpdate();\n };\n }\n\n if (updateFlags.includes(UseAgentUpdate.OnRunStatusChanged)) {\n handlers.onRunInitialized = () => {\n forceUpdate();\n };\n handlers.onRunFinalized = () => {\n forceUpdate();\n };\n handlers.onRunFailed = () => {\n forceUpdate();\n };\n }\n\n const subscription = agent.subscribe(handlers);\n return () => subscription.unsubscribe();\n }, [agent, forceUpdate, JSON.stringify(updateFlags)]);\n\n return {\n agent,\n };\n}\n","\"use client\";\n\nimport React, {\n createContext,\n useContext,\n ReactNode,\n useMemo,\n useEffect,\n useReducer,\n useRef,\n useState,\n} from \"react\";\nimport { ReactActivityMessageRenderer, ReactToolCallRenderer } from \"../types\";\nimport { ReactCustomMessageRenderer } from \"../types/react-custom-message-renderer\";\nimport { ReactFrontendTool } from \"../types/frontend-tool\";\nimport { ReactHumanInTheLoop } from \"../types/human-in-the-loop\";\nimport { z } from \"zod\";\nimport { FrontendTool } from \"@copilotkitnext/core\";\nimport { AbstractAgent } from \"@ag-ui/client\";\nimport { CopilotKitCoreReact } from \"../lib/react-core\";\nimport { CopilotKitInspector } from \"../components/CopilotKitInspector\";\n\n// Define the context value interface - idiomatic React naming\nexport interface CopilotKitContextValue {\n copilotkit: CopilotKitCoreReact;\n}\n\n// Create the CopilotKit context\nconst CopilotKitContext = createContext<CopilotKitContextValue>({\n copilotkit: null!,\n});\n\n// Provider props interface\nexport interface CopilotKitProviderProps {\n children: ReactNode;\n runtimeUrl?: string;\n headers?: Record<string, string>;\n properties?: Record<string, unknown>;\n useSingleEndpoint?: boolean;\n agents__unsafe_dev_only?: Record<string, AbstractAgent>;\n renderToolCalls?: ReactToolCallRenderer<any>[];\n renderActivityMessages?: ReactActivityMessageRenderer<any>[];\n renderCustomMessages?: ReactCustomMessageRenderer[];\n frontendTools?: ReactFrontendTool[];\n humanInTheLoop?: ReactHumanInTheLoop[];\n showDevConsole?: boolean | \"auto\";\n}\n\n// Small helper to normalize array props to a stable reference and warn\nfunction useStableArrayProp<T>(\n prop: T[] | undefined,\n warningMessage?: string,\n isMeaningfulChange?: (initial: T[], next: T[]) => boolean,\n): T[] {\n const empty = useMemo<T[]>(() => [], []);\n const value = prop ?? empty;\n const initial = useRef(value);\n\n useEffect(() => {\n if (\n warningMessage &&\n value !== initial.current &&\n (isMeaningfulChange ? isMeaningfulChange(initial.current, value) : true)\n ) {\n console.error(warningMessage);\n }\n }, [value, warningMessage]);\n\n return value;\n}\n\n// Provider component\nexport const CopilotKitProvider: React.FC<CopilotKitProviderProps> = ({\n children,\n runtimeUrl,\n headers = {},\n properties = {},\n agents__unsafe_dev_only: agents = {},\n renderToolCalls,\n renderActivityMessages,\n renderCustomMessages,\n frontendTools,\n humanInTheLoop,\n showDevConsole = false,\n useSingleEndpoint = false,\n}) => {\n const [shouldRenderInspector, setShouldRenderInspector] = useState(false);\n\n useEffect(() => {\n if (typeof window === \"undefined\") {\n return;\n }\n\n if (showDevConsole === true) {\n // Explicitly show the inspector\n setShouldRenderInspector(true);\n } else if (showDevConsole === \"auto\") {\n // Show on localhost or 127.0.0.1 only\n const localhostHosts = new Set([\"localhost\", \"127.0.0.1\"]);\n if (localhostHosts.has(window.location.hostname)) {\n setShouldRenderInspector(true);\n } else {\n setShouldRenderInspector(false);\n }\n } else {\n // showDevConsole is false or undefined (default false)\n setShouldRenderInspector(false);\n }\n }, [showDevConsole]);\n\n // Normalize array props to stable references with clear dev warnings\n const renderToolCallsList = useStableArrayProp<ReactToolCallRenderer<any>>(\n renderToolCalls,\n \"renderToolCalls must be a stable array. If you want to dynamically add or remove tools, use `useFrontendTool` instead.\",\n (initial, next) => {\n // Only warn if the shape (names+agentId) changed. Allow identity changes\n // to support updated closures from parents (e.g., Storybook state).\n const key = (rc?: ReactToolCallRenderer<unknown>) => `${rc?.agentId ?? \"\"}:${rc?.name ?? \"\"}`;\n const setFrom = (arr: ReactToolCallRenderer<unknown>[]) => new Set(arr.map(key));\n const a = setFrom(initial);\n const b = setFrom(next);\n if (a.size !== b.size) return true;\n for (const k of a) if (!b.has(k)) return true;\n return false;\n },\n );\n\n const renderCustomMessagesList = useStableArrayProp<ReactCustomMessageRenderer>(\n renderCustomMessages,\n \"renderCustomMessages must be a stable array.\",\n );\n\n const renderActivityMessagesList = useStableArrayProp<ReactActivityMessageRenderer<any>>(\n renderActivityMessages,\n \"renderActivityMessages must be a stable array.\",\n );\n\n const frontendToolsList = useStableArrayProp<ReactFrontendTool>(\n frontendTools,\n \"frontendTools must be a stable array. If you want to dynamically add or remove tools, use `useFrontendTool` instead.\",\n );\n const humanInTheLoopList = useStableArrayProp<ReactHumanInTheLoop>(\n humanInTheLoop,\n \"humanInTheLoop must be a stable array. If you want to dynamically add or remove human-in-the-loop tools, use `useHumanInTheLoop` instead.\",\n );\n\n // Note: warnings for array identity changes are handled by useStableArrayProp\n\n // Process humanInTheLoop tools to create handlers and add render components\n const processedHumanInTheLoopTools = useMemo(() => {\n const processedTools: FrontendTool[] = [];\n const processedRenderToolCalls: ReactToolCallRenderer<unknown>[] = [];\n\n humanInTheLoopList.forEach((tool) => {\n // Create a promise-based handler for each human-in-the-loop tool\n const frontendTool: FrontendTool = {\n name: tool.name,\n description: tool.description,\n parameters: tool.parameters,\n followUp: tool.followUp,\n ...(tool.agentId && { agentId: tool.agentId }),\n handler: async () => {\n // This handler will be replaced by the hook when it runs\n // For provider-level tools, we create a basic handler that waits for user interaction\n return new Promise((resolve) => {\n // The actual implementation will be handled by the render component\n // This is a placeholder that the hook will override\n console.warn(`Human-in-the-loop tool '${tool.name}' called but no interactive handler is set up.`);\n resolve(undefined);\n });\n },\n };\n processedTools.push(frontendTool);\n\n // Add the render component to renderToolCalls\n if (tool.render) {\n processedRenderToolCalls.push({\n name: tool.name,\n args: tool.parameters!,\n render: tool.render,\n ...(tool.agentId && { agentId: tool.agentId }),\n } as ReactToolCallRenderer<unknown>);\n }\n });\n\n return { tools: processedTools, renderToolCalls: processedRenderToolCalls };\n }, [humanInTheLoopList]);\n\n // Combine all tools for CopilotKitCore\n const allTools = useMemo(() => {\n const tools: FrontendTool[] = [];\n\n // Add frontend tools\n tools.push(...frontendToolsList);\n\n // Add processed human-in-the-loop tools\n tools.push(...processedHumanInTheLoopTools.tools);\n\n return tools;\n }, [frontendToolsList, processedHumanInTheLoopTools]);\n\n // Combine all render tool calls\n const allRenderToolCalls = useMemo(() => {\n const combined: ReactToolCallRenderer<unknown>[] = [...renderToolCallsList];\n\n // Add render components from frontend tools\n frontendToolsList.forEach((tool) => {\n if (tool.render) {\n // For wildcard tools without parameters, default to z.any()\n const args = tool.parameters || (tool.name === \"*\" ? z.any() : undefined);\n if (args) {\n combined.push({\n name: tool.name,\n args: args,\n render: tool.render,\n } as ReactToolCallRenderer<unknown>);\n }\n }\n });\n\n // Add render components from human-in-the-loop tools\n combined.push(...processedHumanInTheLoopTools.renderToolCalls);\n\n return combined;\n }, [renderToolCallsList, frontendToolsList, processedHumanInTheLoopTools]);\n\n const copilotkit = useMemo(() => {\n const copilotkit = new CopilotKitCoreReact({\n runtimeUrl,\n runtimeTransport: useSingleEndpoint ? \"single\" : \"rest\",\n headers,\n properties,\n agents__unsafe_dev_only: agents,\n tools: allTools,\n renderToolCalls: allRenderToolCalls,\n renderActivityMessages: renderActivityMessagesList,\n renderCustomMessages: renderCustomMessagesList,\n });\n\n return copilotkit;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [allTools, allRenderToolCalls, renderActivityMessagesList, renderCustomMessagesList, useSingleEndpoint]);\n\n // Subscribe to render tool calls changes to force re-renders\n const [, forceUpdate] = useReducer((x) => x + 1, 0);\n\n useEffect(() => {\n const unsubscribe = copilotkit.subscribe({\n onRenderToolCallsChanged: () => {\n forceUpdate();\n },\n });\n\n return () => {\n unsubscribe();\n };\n }, [copilotkit]);\n\n useEffect(() => {\n copilotkit.setRuntimeUrl(runtimeUrl);\n copilotkit.setRuntimeTransport(useSingleEndpoint ? \"single\" : \"rest\");\n copilotkit.setHeaders(headers);\n copilotkit.setProperties(properties);\n copilotkit.setAgents__unsafe_dev_only(agents);\n }, [runtimeUrl, headers, properties, agents, useSingleEndpoint]);\n\n return (\n <CopilotKitContext.Provider\n value={{\n copilotkit,\n }}\n >\n {children}\n {shouldRenderInspector ? <CopilotKitInspector core={copilotkit} /> : null}\n </CopilotKitContext.Provider>\n );\n};\n\n// Hook to use the CopilotKit instance - returns the full context value\nexport const useCopilotKit = (): CopilotKitContextValue => {\n const context = useContext(CopilotKitContext);\n const [, forceUpdate] = useReducer((x) => x + 1, 0);\n\n if (!context) {\n throw new Error(\"useCopilotKit must be used within CopilotKitProvider\");\n }\n useEffect(() => {\n const unsubscribe = context.copilotkit.subscribe({\n onRuntimeConnectionStatusChanged: () => {\n forceUpdate();\n },\n });\n return () => {\n unsubscribe();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return context;\n};\n","import { ReactActivityMessageRenderer, ReactToolCallRenderer } from \"@/types\";\nimport { ReactCustomMessageRenderer } from \"@/types/react-custom-message-renderer\";\nimport { CopilotKitCore, CopilotKitCoreConfig, CopilotKitCoreSubscriber } from \"@copilotkitnext/core\";\n\nexport interface CopilotKitCoreReactConfig extends CopilotKitCoreConfig {\n // Add any additional configuration properties specific to the React implementation\n renderToolCalls?: ReactToolCallRenderer<any>[];\n renderActivityMessages?: ReactActivityMessageRenderer<any>[];\n\n // Add custom message renderers\n renderCustomMessages?: ReactCustomMessageRenderer[];\n}\n\nexport interface CopilotKitCoreReactSubscriber extends CopilotKitCoreSubscriber {\n onRenderToolCallsChanged?: (event: {\n copilotkit: CopilotKitCore;\n renderToolCalls: ReactToolCallRenderer<any>[];\n }) => void | Promise<void>;\n}\n\nexport class CopilotKitCoreReact extends CopilotKitCore {\n private _renderToolCalls: ReactToolCallRenderer<any>[] = [];\n private _renderCustomMessages: ReactCustomMessageRenderer[] = [];\n private _renderActivityMessages: ReactActivityMessageRenderer<any>[] = [];\n\n constructor(config: CopilotKitCoreReactConfig) {\n super(config);\n this._renderToolCalls = config.renderToolCalls ?? [];\n this._renderCustomMessages = config.renderCustomMessages ?? [];\n this._renderActivityMessages = config.renderActivityMessages ?? [];\n }\n\n get renderCustomMessages(): Readonly<ReactCustomMessageRenderer[]> {\n return this._renderCustomMessages;\n }\n\n get renderActivityMessages(): Readonly<ReactActivityMessageRenderer<any>>[] {\n return this._renderActivityMessages;\n }\n\n get renderToolCalls(): Readonly<ReactToolCallRenderer<any>>[] {\n return this._renderToolCalls;\n }\n\n setRenderToolCalls(renderToolCalls: ReactToolCallRenderer<any>[]): void {\n this._renderToolCalls = renderToolCalls;\n\n // Notify React-specific subscribers\n void this.notifySubscribers(\n (subscriber) => {\n const reactSubscriber = subscriber as CopilotKitCoreReactSubscriber;\n if (reactSubscriber.onRenderToolCallsChanged) {\n reactSubscriber.onRenderToolCallsChanged({\n copilotkit: this,\n renderToolCalls: this.renderToolCalls,\n });\n }\n },\n \"Subscriber onRenderToolCallsChanged error:\"\n );\n }\n\n // Override to accept React-specific subscriber type\n subscribe(subscriber: CopilotKitCoreReactSubscriber): () => void {\n return super.subscribe(subscriber);\n }\n\n unsubscribe(subscriber: CopilotKitCoreReactSubscriber): void {\n super.unsubscribe(subscriber);\n }\n}\n","import * as React from \"react\";\nimport { createComponent } from \"@lit-labs/react\";\nimport {\n WEB_INSPECTOR_TAG,\n WebInspectorElement,\n defineWebInspector,\n} from \"@copilotkitnext/web-inspector\";\nimport type { CopilotKitCore } from \"@copilotkitnext/core\";\n\ndefineWebInspector();\n\nconst CopilotKitInspectorBase = createComponent({\n tagName: WEB_INSPECTOR_TAG,\n elementClass: WebInspectorElement,\n react: React,\n});\n\nexport type CopilotKitInspectorBaseProps = React.ComponentProps<typeof CopilotKitInspectorBase>;\n\nexport interface CopilotKitInspectorProps extends Omit<CopilotKitInspectorBaseProps, \"core\"> {\n core?: CopilotKitCore | null;\n}\n\nexport const CopilotKitInspector = React.forwardRef<\n WebInspectorElement,\n CopilotKitInspectorProps\n>(\n ({ core, ...rest }, ref) => {\n const innerRef = React.useRef<WebInspectorElement>(null);\n\n React.useImperativeHandle(ref, () => innerRef.current as WebInspectorElement, []);\n\n React.useEffect(() => {\n if (innerRef.current) {\n innerRef.current.core = core ?? null;\n }\n }, [core]);\n\n return (\n <CopilotKitInspectorBase\n {...(rest as CopilotKitInspectorBaseProps)}\n ref={innerRef}\n />\n ); // eslint-disable-line react/jsx-props-no-spreading\n },\n);\n\nCopilotKitInspector.displayName = \"CopilotKitInspector\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,IAAAA,gBASO;AAKP,iBAAkB;;;ACdlB,kBAA+E;;;ACF/E,YAAuB;AACvB,mBAAgC;AAChC,2BAIO;AAiCD;AAAA,IA9BN,yCAAmB;AAEnB,IAAM,8BAA0B,8BAAgB;AAAA,EAC9C,SAAS;AAAA,EACT,cAAc;AAAA,EACd,OAAO;AACT,CAAC;AAQM,IAAM,sBAA4B;AAAA,EAIvC,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,QAAQ;AAC1B,UAAM,WAAiB,aAA4B,IAAI;AAEvD,IAAM,0BAAoB,KAAK,MAAM,SAAS,SAAgC,CAAC,CAAC;AAEhF,IAAM,gBAAU,MAAM;AACpB,UAAI,SAAS,SAAS;AACpB,iBAAS,QAAQ,OAAO,QAAQ;AAAA,MAClC;AAAA,IACF,GAAG,CAAC,IAAI,CAAC;AAET,WACE;AAAA,MAAC;AAAA;AAAA,QACE,GAAI;AAAA,QACL,KAAK;AAAA;AAAA,IACP;AAAA,E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