@copilotkitnext/react 0.0.22-alpha.4 → 0.0.22-alpha.6
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 +6 -6
- 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
|
@@ -1,2640 +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/components/chat/CopilotChatView.tsx
|
|
31
|
-
var CopilotChatView_exports = {};
|
|
32
|
-
__export(CopilotChatView_exports, {
|
|
33
|
-
CopilotChatView: () => CopilotChatView,
|
|
34
|
-
default: () => CopilotChatView_default
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(CopilotChatView_exports);
|
|
37
|
-
var import_react22 = __toESM(require("react"));
|
|
38
|
-
|
|
39
|
-
// src/lib/slots.tsx
|
|
40
|
-
var import_react = __toESM(require("react"));
|
|
41
|
-
function renderSlot(slot, DefaultComponent, props) {
|
|
42
|
-
if (typeof slot === "string") {
|
|
43
|
-
return import_react.default.createElement(DefaultComponent, {
|
|
44
|
-
...props,
|
|
45
|
-
className: slot
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
if (typeof slot === "function") {
|
|
49
|
-
const Comp = slot;
|
|
50
|
-
return import_react.default.createElement(Comp, props);
|
|
51
|
-
}
|
|
52
|
-
if (slot && typeof slot === "object" && !import_react.default.isValidElement(slot)) {
|
|
53
|
-
return import_react.default.createElement(DefaultComponent, {
|
|
54
|
-
...props,
|
|
55
|
-
...slot
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
return import_react.default.createElement(DefaultComponent, props);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// src/components/chat/CopilotChatAssistantMessage.tsx
|
|
62
|
-
var import_react15 = require("react");
|
|
63
|
-
var import_lucide_react = require("lucide-react");
|
|
64
|
-
|
|
65
|
-
// src/providers/CopilotChatConfigurationProvider.tsx
|
|
66
|
-
var import_react2 = require("react");
|
|
67
|
-
var import_shared = require("@copilotkitnext/shared");
|
|
68
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
69
|
-
var CopilotChatDefaultLabels = {
|
|
70
|
-
chatInputPlaceholder: "Type a message...",
|
|
71
|
-
chatInputToolbarStartTranscribeButtonLabel: "Transcribe",
|
|
72
|
-
chatInputToolbarCancelTranscribeButtonLabel: "Cancel",
|
|
73
|
-
chatInputToolbarFinishTranscribeButtonLabel: "Finish",
|
|
74
|
-
chatInputToolbarAddButtonLabel: "Add photos or files",
|
|
75
|
-
chatInputToolbarToolsButtonLabel: "Tools",
|
|
76
|
-
assistantMessageToolbarCopyCodeLabel: "Copy",
|
|
77
|
-
assistantMessageToolbarCopyCodeCopiedLabel: "Copied",
|
|
78
|
-
assistantMessageToolbarCopyMessageLabel: "Copy",
|
|
79
|
-
assistantMessageToolbarThumbsUpLabel: "Good response",
|
|
80
|
-
assistantMessageToolbarThumbsDownLabel: "Bad response",
|
|
81
|
-
assistantMessageToolbarReadAloudLabel: "Read aloud",
|
|
82
|
-
assistantMessageToolbarRegenerateLabel: "Regenerate",
|
|
83
|
-
userMessageToolbarCopyMessageLabel: "Copy",
|
|
84
|
-
userMessageToolbarEditMessageLabel: "Edit",
|
|
85
|
-
chatDisclaimerText: "AI can make mistakes. Please verify important information.",
|
|
86
|
-
chatToggleOpenLabel: "Open chat",
|
|
87
|
-
chatToggleCloseLabel: "Close chat",
|
|
88
|
-
modalHeaderTitle: "CopilotKit Chat"
|
|
89
|
-
};
|
|
90
|
-
var CopilotChatConfiguration = (0, import_react2.createContext)(null);
|
|
91
|
-
var useCopilotChatConfiguration = () => {
|
|
92
|
-
const configuration = (0, import_react2.useContext)(CopilotChatConfiguration);
|
|
93
|
-
return configuration;
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
// src/components/chat/CopilotChatAssistantMessage.tsx
|
|
97
|
-
var import_tailwind_merge2 = require("tailwind-merge");
|
|
98
|
-
|
|
99
|
-
// src/components/ui/button.tsx
|
|
100
|
-
var import_react_slot = require("@radix-ui/react-slot");
|
|
101
|
-
var import_class_variance_authority = require("class-variance-authority");
|
|
102
|
-
|
|
103
|
-
// src/lib/utils.ts
|
|
104
|
-
var import_clsx = require("clsx");
|
|
105
|
-
var import_tailwind_merge = require("tailwind-merge");
|
|
106
|
-
function cn(...inputs) {
|
|
107
|
-
return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// src/components/ui/button.tsx
|
|
111
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
112
|
-
var buttonVariants = (0, import_class_variance_authority.cva)(
|
|
113
|
-
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
|
114
|
-
{
|
|
115
|
-
variants: {
|
|
116
|
-
variant: {
|
|
117
|
-
default: "bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",
|
|
118
|
-
destructive: "bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
|
|
119
|
-
outline: "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
|
|
120
|
-
secondary: "bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",
|
|
121
|
-
ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50 cursor-pointer",
|
|
122
|
-
link: "text-primary underline-offset-4 hover:underline",
|
|
123
|
-
assistantMessageToolbarButton: [
|
|
124
|
-
"cursor-pointer",
|
|
125
|
-
// Background and text
|
|
126
|
-
"p-0 text-[rgb(93,93,93)] hover:bg-[#E8E8E8]",
|
|
127
|
-
// Dark mode - lighter gray for better contrast
|
|
128
|
-
"dark:text-[rgb(243,243,243)] dark:hover:bg-[#303030]",
|
|
129
|
-
// Shape and sizing
|
|
130
|
-
"h-8 w-8",
|
|
131
|
-
// Interactions
|
|
132
|
-
"transition-colors",
|
|
133
|
-
// Hover states
|
|
134
|
-
"hover:text-[rgb(93,93,93)]",
|
|
135
|
-
"dark:hover:text-[rgb(243,243,243)]"
|
|
136
|
-
],
|
|
137
|
-
chatInputToolbarPrimary: [
|
|
138
|
-
"cursor-pointer",
|
|
139
|
-
// Background and text
|
|
140
|
-
"bg-black text-white",
|
|
141
|
-
// Dark mode
|
|
142
|
-
"dark:bg-white dark:text-black dark:focus-visible:outline-white",
|
|
143
|
-
// Shape and sizing
|
|
144
|
-
"rounded-full",
|
|
145
|
-
// Interactions
|
|
146
|
-
"transition-colors",
|
|
147
|
-
// Focus states
|
|
148
|
-
"focus:outline-none",
|
|
149
|
-
// Hover states
|
|
150
|
-
"hover:opacity-70 disabled:hover:opacity-100",
|
|
151
|
-
// Disabled states
|
|
152
|
-
"disabled:cursor-not-allowed disabled:bg-[#00000014] disabled:text-[rgb(13,13,13)]",
|
|
153
|
-
"dark:disabled:bg-[#454545] dark:disabled:text-white "
|
|
154
|
-
],
|
|
155
|
-
chatInputToolbarSecondary: [
|
|
156
|
-
"cursor-pointer",
|
|
157
|
-
// Background and text
|
|
158
|
-
"bg-transparent text-[#444444]",
|
|
159
|
-
// Dark mode
|
|
160
|
-
"dark:text-white dark:border-[#404040]",
|
|
161
|
-
// Shape and sizing
|
|
162
|
-
"rounded-full",
|
|
163
|
-
// Interactions
|
|
164
|
-
"transition-colors",
|
|
165
|
-
// Focus states
|
|
166
|
-
"focus:outline-none",
|
|
167
|
-
// Hover states
|
|
168
|
-
"hover:bg-[#f8f8f8] hover:text-[#333333]",
|
|
169
|
-
"dark:hover:bg-[#404040] dark:hover:text-[#FFFFFF]",
|
|
170
|
-
// Disabled states
|
|
171
|
-
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
172
|
-
"disabled:hover:bg-transparent disabled:hover:text-[#444444]",
|
|
173
|
-
"dark:disabled:hover:bg-transparent dark:disabled:hover:text-[#CCCCCC]"
|
|
174
|
-
]
|
|
175
|
-
},
|
|
176
|
-
size: {
|
|
177
|
-
default: "h-9 px-4 py-2 has-[>svg]:px-3",
|
|
178
|
-
sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
|
|
179
|
-
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
|
|
180
|
-
icon: "size-9",
|
|
181
|
-
chatInputToolbarIcon: [
|
|
182
|
-
// Shape and sizing
|
|
183
|
-
"h-9 w-9 rounded-full"
|
|
184
|
-
],
|
|
185
|
-
chatInputToolbarIconLabel: [
|
|
186
|
-
// Shape and sizing
|
|
187
|
-
"h-9 px-3 rounded-full",
|
|
188
|
-
// Layout
|
|
189
|
-
"gap-2",
|
|
190
|
-
// Typography
|
|
191
|
-
"font-normal"
|
|
192
|
-
]
|
|
193
|
-
}
|
|
194
|
-
},
|
|
195
|
-
defaultVariants: {
|
|
196
|
-
variant: "default",
|
|
197
|
-
size: "default"
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
);
|
|
201
|
-
function Button({
|
|
202
|
-
className,
|
|
203
|
-
variant,
|
|
204
|
-
size,
|
|
205
|
-
asChild = false,
|
|
206
|
-
...props
|
|
207
|
-
}) {
|
|
208
|
-
const Comp = asChild ? import_react_slot.Slot : "button";
|
|
209
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
210
|
-
Comp,
|
|
211
|
-
{
|
|
212
|
-
"data-slot": "button",
|
|
213
|
-
className: cn(buttonVariants({ variant, size, className })),
|
|
214
|
-
...props
|
|
215
|
-
}
|
|
216
|
-
);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
// src/components/ui/tooltip.tsx
|
|
220
|
-
var TooltipPrimitive = __toESM(require("@radix-ui/react-tooltip"));
|
|
221
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
222
|
-
function TooltipProvider({
|
|
223
|
-
delayDuration = 0,
|
|
224
|
-
...props
|
|
225
|
-
}) {
|
|
226
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
227
|
-
TooltipPrimitive.Provider,
|
|
228
|
-
{
|
|
229
|
-
"data-slot": "tooltip-provider",
|
|
230
|
-
delayDuration,
|
|
231
|
-
...props
|
|
232
|
-
}
|
|
233
|
-
);
|
|
234
|
-
}
|
|
235
|
-
function Tooltip({
|
|
236
|
-
...props
|
|
237
|
-
}) {
|
|
238
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(TooltipProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(TooltipPrimitive.Root, { "data-slot": "tooltip", ...props }) });
|
|
239
|
-
}
|
|
240
|
-
function TooltipTrigger({
|
|
241
|
-
...props
|
|
242
|
-
}) {
|
|
243
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(TooltipPrimitive.Trigger, { "data-slot": "tooltip-trigger", ...props });
|
|
244
|
-
}
|
|
245
|
-
function TooltipContent({
|
|
246
|
-
className,
|
|
247
|
-
sideOffset = 0,
|
|
248
|
-
children,
|
|
249
|
-
...props
|
|
250
|
-
}) {
|
|
251
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(TooltipPrimitive.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
252
|
-
TooltipPrimitive.Content,
|
|
253
|
-
{
|
|
254
|
-
"data-slot": "tooltip-content",
|
|
255
|
-
sideOffset,
|
|
256
|
-
className: cn(
|
|
257
|
-
"bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",
|
|
258
|
-
className
|
|
259
|
-
),
|
|
260
|
-
...props,
|
|
261
|
-
children: [
|
|
262
|
-
children,
|
|
263
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(TooltipPrimitive.Arrow, { className: "bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]" })
|
|
264
|
-
]
|
|
265
|
-
}
|
|
266
|
-
) });
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
// src/components/chat/CopilotChatAssistantMessage.tsx
|
|
270
|
-
var import_katex_min = require("katex/dist/katex.min.css");
|
|
271
|
-
var import_streamdown = require("streamdown");
|
|
272
|
-
|
|
273
|
-
// src/hooks/use-render-tool-call.tsx
|
|
274
|
-
var import_react5 = require("react");
|
|
275
|
-
var import_core2 = require("@copilotkitnext/core");
|
|
276
|
-
|
|
277
|
-
// src/providers/CopilotKitProvider.tsx
|
|
278
|
-
var import_react4 = require("react");
|
|
279
|
-
var import_zod = require("zod");
|
|
280
|
-
|
|
281
|
-
// src/lib/react-core.ts
|
|
282
|
-
var import_core = require("@copilotkitnext/core");
|
|
283
|
-
|
|
284
|
-
// src/components/CopilotKitInspector.tsx
|
|
285
|
-
var React3 = __toESM(require("react"));
|
|
286
|
-
var import_react3 = require("@lit-labs/react");
|
|
287
|
-
var import_web_inspector = require("@copilotkitnext/web-inspector");
|
|
288
|
-
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
289
|
-
(0, import_web_inspector.defineWebInspector)();
|
|
290
|
-
var CopilotKitInspectorBase = (0, import_react3.createComponent)({
|
|
291
|
-
tagName: import_web_inspector.WEB_INSPECTOR_TAG,
|
|
292
|
-
elementClass: import_web_inspector.WebInspectorElement,
|
|
293
|
-
react: React3
|
|
294
|
-
});
|
|
295
|
-
var CopilotKitInspector = React3.forwardRef(
|
|
296
|
-
({ core, ...rest }, ref) => {
|
|
297
|
-
const innerRef = React3.useRef(null);
|
|
298
|
-
React3.useImperativeHandle(ref, () => innerRef.current, []);
|
|
299
|
-
React3.useEffect(() => {
|
|
300
|
-
if (innerRef.current) {
|
|
301
|
-
innerRef.current.core = core ?? null;
|
|
302
|
-
}
|
|
303
|
-
}, [core]);
|
|
304
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
305
|
-
CopilotKitInspectorBase,
|
|
306
|
-
{
|
|
307
|
-
...rest,
|
|
308
|
-
ref: innerRef
|
|
309
|
-
}
|
|
310
|
-
);
|
|
311
|
-
}
|
|
312
|
-
);
|
|
313
|
-
CopilotKitInspector.displayName = "CopilotKitInspector";
|
|
314
|
-
|
|
315
|
-
// src/providers/CopilotKitProvider.tsx
|
|
316
|
-
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
317
|
-
var CopilotKitContext = (0, import_react4.createContext)({
|
|
318
|
-
copilotkit: null
|
|
319
|
-
});
|
|
320
|
-
var useCopilotKit = () => {
|
|
321
|
-
const context = (0, import_react4.useContext)(CopilotKitContext);
|
|
322
|
-
const [, forceUpdate] = (0, import_react4.useReducer)((x) => x + 1, 0);
|
|
323
|
-
if (!context) {
|
|
324
|
-
throw new Error("useCopilotKit must be used within CopilotKitProvider");
|
|
325
|
-
}
|
|
326
|
-
(0, import_react4.useEffect)(() => {
|
|
327
|
-
const unsubscribe = context.copilotkit.subscribe({
|
|
328
|
-
onRuntimeConnectionStatusChanged: () => {
|
|
329
|
-
forceUpdate();
|
|
330
|
-
}
|
|
331
|
-
});
|
|
332
|
-
return () => {
|
|
333
|
-
unsubscribe();
|
|
334
|
-
};
|
|
335
|
-
}, []);
|
|
336
|
-
return context;
|
|
337
|
-
};
|
|
338
|
-
|
|
339
|
-
// src/hooks/use-render-tool-call.tsx
|
|
340
|
-
var import_shared2 = require("@copilotkitnext/shared");
|
|
341
|
-
var import_shared3 = require("@copilotkitnext/shared");
|
|
342
|
-
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
343
|
-
function useRenderToolCall() {
|
|
344
|
-
const { copilotkit } = useCopilotKit();
|
|
345
|
-
const config = useCopilotChatConfiguration();
|
|
346
|
-
const agentId = config?.agentId ?? import_shared2.DEFAULT_AGENT_ID;
|
|
347
|
-
const [executingToolCallIds, setExecutingToolCallIds] = (0, import_react5.useState)(() => /* @__PURE__ */ new Set());
|
|
348
|
-
const renderToolCalls = (0, import_react5.useSyncExternalStore)(
|
|
349
|
-
(callback) => {
|
|
350
|
-
return copilotkit.subscribe({
|
|
351
|
-
onRenderToolCallsChanged: callback
|
|
352
|
-
});
|
|
353
|
-
},
|
|
354
|
-
() => copilotkit.renderToolCalls,
|
|
355
|
-
() => copilotkit.renderToolCalls
|
|
356
|
-
);
|
|
357
|
-
(0, import_react5.useEffect)(() => {
|
|
358
|
-
const unsubscribe = copilotkit.subscribe({
|
|
359
|
-
onToolExecutionStart: ({ toolCallId }) => {
|
|
360
|
-
setExecutingToolCallIds((prev) => {
|
|
361
|
-
if (prev.has(toolCallId)) return prev;
|
|
362
|
-
const next = new Set(prev);
|
|
363
|
-
next.add(toolCallId);
|
|
364
|
-
return next;
|
|
365
|
-
});
|
|
366
|
-
},
|
|
367
|
-
onToolExecutionEnd: ({ toolCallId }) => {
|
|
368
|
-
setExecutingToolCallIds((prev) => {
|
|
369
|
-
if (!prev.has(toolCallId)) return prev;
|
|
370
|
-
const next = new Set(prev);
|
|
371
|
-
next.delete(toolCallId);
|
|
372
|
-
return next;
|
|
373
|
-
});
|
|
374
|
-
}
|
|
375
|
-
});
|
|
376
|
-
return () => unsubscribe();
|
|
377
|
-
}, [copilotkit]);
|
|
378
|
-
const renderToolCall = (0, import_react5.useCallback)(
|
|
379
|
-
({
|
|
380
|
-
toolCall,
|
|
381
|
-
toolMessage
|
|
382
|
-
}) => {
|
|
383
|
-
const exactMatches = renderToolCalls.filter(
|
|
384
|
-
(rc) => rc.name === toolCall.function.name
|
|
385
|
-
);
|
|
386
|
-
const renderConfig = exactMatches.find((rc) => rc.agentId === agentId) || exactMatches.find((rc) => !rc.agentId) || exactMatches[0] || renderToolCalls.find((rc) => rc.name === "*");
|
|
387
|
-
if (!renderConfig) {
|
|
388
|
-
return null;
|
|
389
|
-
}
|
|
390
|
-
const RenderComponent = renderConfig.render;
|
|
391
|
-
const args = (0, import_shared3.partialJSONParse)(toolCall.function.arguments);
|
|
392
|
-
const toolName = toolCall.function.name;
|
|
393
|
-
if (toolMessage) {
|
|
394
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
395
|
-
RenderComponent,
|
|
396
|
-
{
|
|
397
|
-
name: toolName,
|
|
398
|
-
args,
|
|
399
|
-
status: import_core2.ToolCallStatus.Complete,
|
|
400
|
-
result: toolMessage.content
|
|
401
|
-
},
|
|
402
|
-
toolCall.id
|
|
403
|
-
);
|
|
404
|
-
} else if (executingToolCallIds.has(toolCall.id)) {
|
|
405
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
406
|
-
RenderComponent,
|
|
407
|
-
{
|
|
408
|
-
name: toolName,
|
|
409
|
-
args,
|
|
410
|
-
status: import_core2.ToolCallStatus.Executing,
|
|
411
|
-
result: void 0
|
|
412
|
-
},
|
|
413
|
-
toolCall.id
|
|
414
|
-
);
|
|
415
|
-
} else {
|
|
416
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
417
|
-
RenderComponent,
|
|
418
|
-
{
|
|
419
|
-
name: toolName,
|
|
420
|
-
args,
|
|
421
|
-
status: import_core2.ToolCallStatus.InProgress,
|
|
422
|
-
result: void 0
|
|
423
|
-
},
|
|
424
|
-
toolCall.id
|
|
425
|
-
);
|
|
426
|
-
}
|
|
427
|
-
},
|
|
428
|
-
[renderToolCalls, executingToolCallIds, agentId]
|
|
429
|
-
);
|
|
430
|
-
return renderToolCall;
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
// src/hooks/use-render-custom-messages.tsx
|
|
434
|
-
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
435
|
-
function useRenderCustomMessages() {
|
|
436
|
-
const { copilotkit } = useCopilotKit();
|
|
437
|
-
const config = useCopilotChatConfiguration();
|
|
438
|
-
if (!config) {
|
|
439
|
-
return null;
|
|
440
|
-
}
|
|
441
|
-
const { agentId, threadId } = config;
|
|
442
|
-
const customMessageRenderers = copilotkit.renderCustomMessages.filter((renderer) => renderer.agentId === void 0 || renderer.agentId === agentId).sort((a, b) => {
|
|
443
|
-
const aHasAgent = a.agentId !== void 0;
|
|
444
|
-
const bHasAgent = b.agentId !== void 0;
|
|
445
|
-
if (aHasAgent === bHasAgent) return 0;
|
|
446
|
-
return aHasAgent ? -1 : 1;
|
|
447
|
-
});
|
|
448
|
-
return function(params) {
|
|
449
|
-
if (!customMessageRenderers.length) {
|
|
450
|
-
return null;
|
|
451
|
-
}
|
|
452
|
-
const { message, position } = params;
|
|
453
|
-
const runId = copilotkit.getRunIdForMessage(agentId, threadId, message.id);
|
|
454
|
-
const agent = copilotkit.getAgent(agentId);
|
|
455
|
-
if (!agent) {
|
|
456
|
-
throw new Error("Agent not found");
|
|
457
|
-
}
|
|
458
|
-
const messagesIdsInRun = agent.messages.filter((msg) => copilotkit.getRunIdForMessage(agentId, threadId, msg.id) === runId).map((msg) => msg.id);
|
|
459
|
-
const messageIndex = agent.messages.findIndex((msg) => msg.id === message.id) ?? 0;
|
|
460
|
-
const messageIndexInRun = Math.min(messagesIdsInRun.indexOf(message.id), 0);
|
|
461
|
-
const numberOfMessagesInRun = messagesIdsInRun.length;
|
|
462
|
-
const stateSnapshot = copilotkit.getStateByRun(agentId, threadId, runId);
|
|
463
|
-
let result = null;
|
|
464
|
-
for (const renderer of customMessageRenderers) {
|
|
465
|
-
if (!renderer.render) {
|
|
466
|
-
continue;
|
|
467
|
-
}
|
|
468
|
-
const Component = renderer.render;
|
|
469
|
-
result = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
470
|
-
Component,
|
|
471
|
-
{
|
|
472
|
-
message,
|
|
473
|
-
position,
|
|
474
|
-
runId,
|
|
475
|
-
messageIndex,
|
|
476
|
-
messageIndexInRun,
|
|
477
|
-
numberOfMessagesInRun,
|
|
478
|
-
agentId,
|
|
479
|
-
stateSnapshot
|
|
480
|
-
},
|
|
481
|
-
`${runId}-${message.id}-${position}`
|
|
482
|
-
);
|
|
483
|
-
if (result) {
|
|
484
|
-
break;
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
return result;
|
|
488
|
-
};
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
// src/hooks/use-render-activity-message.tsx
|
|
492
|
-
var import_shared4 = require("@copilotkitnext/shared");
|
|
493
|
-
var import_react6 = require("react");
|
|
494
|
-
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
495
|
-
function useRenderActivityMessage() {
|
|
496
|
-
const { copilotkit } = useCopilotKit();
|
|
497
|
-
const config = useCopilotChatConfiguration();
|
|
498
|
-
const agentId = config?.agentId ?? import_shared4.DEFAULT_AGENT_ID;
|
|
499
|
-
const renderers = copilotkit.renderActivityMessages;
|
|
500
|
-
return (0, import_react6.useCallback)(
|
|
501
|
-
(message) => {
|
|
502
|
-
if (!renderers.length) {
|
|
503
|
-
return null;
|
|
504
|
-
}
|
|
505
|
-
const matches = renderers.filter(
|
|
506
|
-
(renderer2) => renderer2.activityType === message.activityType
|
|
507
|
-
);
|
|
508
|
-
const renderer = matches.find((candidate) => candidate.agentId === agentId) ?? matches.find((candidate) => candidate.agentId === void 0) ?? renderers.find((candidate) => candidate.activityType === "*");
|
|
509
|
-
if (!renderer) {
|
|
510
|
-
return null;
|
|
511
|
-
}
|
|
512
|
-
const parseResult = renderer.content.safeParse(message.content);
|
|
513
|
-
if (!parseResult.success) {
|
|
514
|
-
console.warn(
|
|
515
|
-
`Failed to parse content for activity message '${message.activityType}':`,
|
|
516
|
-
parseResult.error
|
|
517
|
-
);
|
|
518
|
-
return null;
|
|
519
|
-
}
|
|
520
|
-
const Component = renderer.render;
|
|
521
|
-
const agent = copilotkit.getAgent(agentId);
|
|
522
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
523
|
-
Component,
|
|
524
|
-
{
|
|
525
|
-
activityType: message.activityType,
|
|
526
|
-
content: parseResult.data,
|
|
527
|
-
message,
|
|
528
|
-
agent
|
|
529
|
-
},
|
|
530
|
-
message.id
|
|
531
|
-
);
|
|
532
|
-
},
|
|
533
|
-
[agentId, copilotkit, renderers]
|
|
534
|
-
);
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
// src/hooks/use-frontend-tool.tsx
|
|
538
|
-
var import_react7 = require("react");
|
|
539
|
-
|
|
540
|
-
// src/hooks/use-human-in-the-loop.tsx
|
|
541
|
-
var import_react8 = require("react");
|
|
542
|
-
var import_react9 = __toESM(require("react"));
|
|
543
|
-
|
|
544
|
-
// src/hooks/use-agent.tsx
|
|
545
|
-
var import_react10 = require("react");
|
|
546
|
-
var import_shared5 = require("@copilotkitnext/shared");
|
|
547
|
-
|
|
548
|
-
// src/hooks/use-agent-context.tsx
|
|
549
|
-
var import_react11 = require("react");
|
|
550
|
-
|
|
551
|
-
// src/hooks/use-suggestions.tsx
|
|
552
|
-
var import_react12 = require("react");
|
|
553
|
-
var import_shared6 = require("@copilotkitnext/shared");
|
|
554
|
-
|
|
555
|
-
// src/hooks/use-configure-suggestions.tsx
|
|
556
|
-
var import_react13 = require("react");
|
|
557
|
-
var import_shared7 = require("@copilotkitnext/shared");
|
|
558
|
-
|
|
559
|
-
// src/components/chat/CopilotChatToolCallsView.tsx
|
|
560
|
-
var import_react14 = __toESM(require("react"));
|
|
561
|
-
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
562
|
-
function CopilotChatToolCallsView({
|
|
563
|
-
message,
|
|
564
|
-
messages = []
|
|
565
|
-
}) {
|
|
566
|
-
const renderToolCall = useRenderToolCall();
|
|
567
|
-
if (!message.toolCalls || message.toolCalls.length === 0) {
|
|
568
|
-
return null;
|
|
569
|
-
}
|
|
570
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children: message.toolCalls.map((toolCall) => {
|
|
571
|
-
const toolMessage = messages.find(
|
|
572
|
-
(m) => m.role === "tool" && m.toolCallId === toolCall.id
|
|
573
|
-
);
|
|
574
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react14.default.Fragment, { children: renderToolCall({
|
|
575
|
-
toolCall,
|
|
576
|
-
toolMessage
|
|
577
|
-
}) }, toolCall.id);
|
|
578
|
-
}) });
|
|
579
|
-
}
|
|
580
|
-
var CopilotChatToolCallsView_default = CopilotChatToolCallsView;
|
|
581
|
-
|
|
582
|
-
// src/components/chat/CopilotChatAssistantMessage.tsx
|
|
583
|
-
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
584
|
-
function CopilotChatAssistantMessage({
|
|
585
|
-
message,
|
|
586
|
-
messages,
|
|
587
|
-
isRunning,
|
|
588
|
-
onThumbsUp,
|
|
589
|
-
onThumbsDown,
|
|
590
|
-
onReadAloud,
|
|
591
|
-
onRegenerate,
|
|
592
|
-
additionalToolbarItems,
|
|
593
|
-
toolbarVisible = true,
|
|
594
|
-
markdownRenderer,
|
|
595
|
-
toolbar,
|
|
596
|
-
copyButton,
|
|
597
|
-
thumbsUpButton,
|
|
598
|
-
thumbsDownButton,
|
|
599
|
-
readAloudButton,
|
|
600
|
-
regenerateButton,
|
|
601
|
-
toolCallsView,
|
|
602
|
-
children,
|
|
603
|
-
className,
|
|
604
|
-
...props
|
|
605
|
-
}) {
|
|
606
|
-
const boundMarkdownRenderer = renderSlot(
|
|
607
|
-
markdownRenderer,
|
|
608
|
-
CopilotChatAssistantMessage.MarkdownRenderer,
|
|
609
|
-
{
|
|
610
|
-
content: message.content || ""
|
|
611
|
-
}
|
|
612
|
-
);
|
|
613
|
-
const boundCopyButton = renderSlot(
|
|
614
|
-
copyButton,
|
|
615
|
-
CopilotChatAssistantMessage.CopyButton,
|
|
616
|
-
{
|
|
617
|
-
onClick: async () => {
|
|
618
|
-
if (message.content) {
|
|
619
|
-
try {
|
|
620
|
-
await navigator.clipboard.writeText(message.content);
|
|
621
|
-
} catch (err) {
|
|
622
|
-
console.error("Failed to copy message:", err);
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
);
|
|
628
|
-
const boundThumbsUpButton = renderSlot(
|
|
629
|
-
thumbsUpButton,
|
|
630
|
-
CopilotChatAssistantMessage.ThumbsUpButton,
|
|
631
|
-
{
|
|
632
|
-
onClick: onThumbsUp
|
|
633
|
-
}
|
|
634
|
-
);
|
|
635
|
-
const boundThumbsDownButton = renderSlot(
|
|
636
|
-
thumbsDownButton,
|
|
637
|
-
CopilotChatAssistantMessage.ThumbsDownButton,
|
|
638
|
-
{
|
|
639
|
-
onClick: onThumbsDown
|
|
640
|
-
}
|
|
641
|
-
);
|
|
642
|
-
const boundReadAloudButton = renderSlot(
|
|
643
|
-
readAloudButton,
|
|
644
|
-
CopilotChatAssistantMessage.ReadAloudButton,
|
|
645
|
-
{
|
|
646
|
-
onClick: onReadAloud
|
|
647
|
-
}
|
|
648
|
-
);
|
|
649
|
-
const boundRegenerateButton = renderSlot(
|
|
650
|
-
regenerateButton,
|
|
651
|
-
CopilotChatAssistantMessage.RegenerateButton,
|
|
652
|
-
{
|
|
653
|
-
onClick: onRegenerate
|
|
654
|
-
}
|
|
655
|
-
);
|
|
656
|
-
const boundToolbar = renderSlot(
|
|
657
|
-
toolbar,
|
|
658
|
-
CopilotChatAssistantMessage.Toolbar,
|
|
659
|
-
{
|
|
660
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
661
|
-
boundCopyButton,
|
|
662
|
-
(onThumbsUp || thumbsUpButton) && boundThumbsUpButton,
|
|
663
|
-
(onThumbsDown || thumbsDownButton) && boundThumbsDownButton,
|
|
664
|
-
(onReadAloud || readAloudButton) && boundReadAloudButton,
|
|
665
|
-
(onRegenerate || regenerateButton) && boundRegenerateButton,
|
|
666
|
-
additionalToolbarItems
|
|
667
|
-
] })
|
|
668
|
-
}
|
|
669
|
-
);
|
|
670
|
-
const boundToolCallsView = renderSlot(
|
|
671
|
-
toolCallsView,
|
|
672
|
-
CopilotChatToolCallsView_default,
|
|
673
|
-
{
|
|
674
|
-
message,
|
|
675
|
-
messages
|
|
676
|
-
}
|
|
677
|
-
);
|
|
678
|
-
const hasContent = !!(message.content && message.content.trim().length > 0);
|
|
679
|
-
const isLatestAssistantMessage = message.role === "assistant" && messages?.[messages.length - 1]?.id === message.id;
|
|
680
|
-
const shouldShowToolbar = toolbarVisible && hasContent && !(isRunning && isLatestAssistantMessage);
|
|
681
|
-
if (children) {
|
|
682
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx_runtime10.Fragment, { children: children({
|
|
683
|
-
markdownRenderer: boundMarkdownRenderer,
|
|
684
|
-
toolbar: boundToolbar,
|
|
685
|
-
toolCallsView: boundToolCallsView,
|
|
686
|
-
copyButton: boundCopyButton,
|
|
687
|
-
thumbsUpButton: boundThumbsUpButton,
|
|
688
|
-
thumbsDownButton: boundThumbsDownButton,
|
|
689
|
-
readAloudButton: boundReadAloudButton,
|
|
690
|
-
regenerateButton: boundRegenerateButton,
|
|
691
|
-
message,
|
|
692
|
-
messages,
|
|
693
|
-
isRunning,
|
|
694
|
-
onThumbsUp,
|
|
695
|
-
onThumbsDown,
|
|
696
|
-
onReadAloud,
|
|
697
|
-
onRegenerate,
|
|
698
|
-
additionalToolbarItems,
|
|
699
|
-
toolbarVisible: shouldShowToolbar
|
|
700
|
-
}) });
|
|
701
|
-
}
|
|
702
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
703
|
-
"div",
|
|
704
|
-
{
|
|
705
|
-
className: (0, import_tailwind_merge2.twMerge)(
|
|
706
|
-
"prose max-w-full break-words dark:prose-invert",
|
|
707
|
-
className
|
|
708
|
-
),
|
|
709
|
-
...props,
|
|
710
|
-
"data-message-id": message.id,
|
|
711
|
-
children: [
|
|
712
|
-
boundMarkdownRenderer,
|
|
713
|
-
boundToolCallsView,
|
|
714
|
-
shouldShowToolbar && boundToolbar
|
|
715
|
-
]
|
|
716
|
-
}
|
|
717
|
-
);
|
|
718
|
-
}
|
|
719
|
-
((CopilotChatAssistantMessage2) => {
|
|
720
|
-
CopilotChatAssistantMessage2.MarkdownRenderer = ({ content, className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_streamdown.Streamdown, { className, ...props, children: content ?? "" });
|
|
721
|
-
CopilotChatAssistantMessage2.Toolbar = ({
|
|
722
|
-
className,
|
|
723
|
-
...props
|
|
724
|
-
}) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
725
|
-
"div",
|
|
726
|
-
{
|
|
727
|
-
className: (0, import_tailwind_merge2.twMerge)(
|
|
728
|
-
"w-full bg-transparent flex items-center -ml-[5px] -mt-[0px]",
|
|
729
|
-
className
|
|
730
|
-
),
|
|
731
|
-
...props
|
|
732
|
-
}
|
|
733
|
-
);
|
|
734
|
-
CopilotChatAssistantMessage2.ToolbarButton = ({ title, children, ...props }) => {
|
|
735
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Tooltip, { children: [
|
|
736
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
737
|
-
Button,
|
|
738
|
-
{
|
|
739
|
-
type: "button",
|
|
740
|
-
variant: "assistantMessageToolbarButton",
|
|
741
|
-
"aria-label": title,
|
|
742
|
-
...props,
|
|
743
|
-
children
|
|
744
|
-
}
|
|
745
|
-
) }),
|
|
746
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TooltipContent, { side: "bottom", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { children: title }) })
|
|
747
|
-
] });
|
|
748
|
-
};
|
|
749
|
-
CopilotChatAssistantMessage2.CopyButton = ({ className, title, onClick, ...props }) => {
|
|
750
|
-
const config = useCopilotChatConfiguration();
|
|
751
|
-
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
752
|
-
const [copied, setCopied] = (0, import_react15.useState)(false);
|
|
753
|
-
const handleClick = (event) => {
|
|
754
|
-
setCopied(true);
|
|
755
|
-
setTimeout(() => setCopied(false), 2e3);
|
|
756
|
-
if (onClick) {
|
|
757
|
-
onClick(event);
|
|
758
|
-
}
|
|
759
|
-
};
|
|
760
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
761
|
-
CopilotChatAssistantMessage2.ToolbarButton,
|
|
762
|
-
{
|
|
763
|
-
title: title || labels.assistantMessageToolbarCopyMessageLabel,
|
|
764
|
-
onClick: handleClick,
|
|
765
|
-
className,
|
|
766
|
-
...props,
|
|
767
|
-
children: copied ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react.Check, { className: "size-[18px]" }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react.Copy, { className: "size-[18px]" })
|
|
768
|
-
}
|
|
769
|
-
);
|
|
770
|
-
};
|
|
771
|
-
CopilotChatAssistantMessage2.ThumbsUpButton = ({ title, ...props }) => {
|
|
772
|
-
const config = useCopilotChatConfiguration();
|
|
773
|
-
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
774
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
775
|
-
CopilotChatAssistantMessage2.ToolbarButton,
|
|
776
|
-
{
|
|
777
|
-
title: title || labels.assistantMessageToolbarThumbsUpLabel,
|
|
778
|
-
...props,
|
|
779
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react.ThumbsUp, { className: "size-[18px]" })
|
|
780
|
-
}
|
|
781
|
-
);
|
|
782
|
-
};
|
|
783
|
-
CopilotChatAssistantMessage2.ThumbsDownButton = ({ title, ...props }) => {
|
|
784
|
-
const config = useCopilotChatConfiguration();
|
|
785
|
-
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
786
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
787
|
-
CopilotChatAssistantMessage2.ToolbarButton,
|
|
788
|
-
{
|
|
789
|
-
title: title || labels.assistantMessageToolbarThumbsDownLabel,
|
|
790
|
-
...props,
|
|
791
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react.ThumbsDown, { className: "size-[18px]" })
|
|
792
|
-
}
|
|
793
|
-
);
|
|
794
|
-
};
|
|
795
|
-
CopilotChatAssistantMessage2.ReadAloudButton = ({ title, ...props }) => {
|
|
796
|
-
const config = useCopilotChatConfiguration();
|
|
797
|
-
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
798
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
799
|
-
CopilotChatAssistantMessage2.ToolbarButton,
|
|
800
|
-
{
|
|
801
|
-
title: title || labels.assistantMessageToolbarReadAloudLabel,
|
|
802
|
-
...props,
|
|
803
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react.Volume2, { className: "size-[20px]" })
|
|
804
|
-
}
|
|
805
|
-
);
|
|
806
|
-
};
|
|
807
|
-
CopilotChatAssistantMessage2.RegenerateButton = ({ title, ...props }) => {
|
|
808
|
-
const config = useCopilotChatConfiguration();
|
|
809
|
-
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
810
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
811
|
-
CopilotChatAssistantMessage2.ToolbarButton,
|
|
812
|
-
{
|
|
813
|
-
title: title || labels.assistantMessageToolbarRegenerateLabel,
|
|
814
|
-
...props,
|
|
815
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react.RefreshCw, { className: "size-[18px]" })
|
|
816
|
-
}
|
|
817
|
-
);
|
|
818
|
-
};
|
|
819
|
-
})(CopilotChatAssistantMessage || (CopilotChatAssistantMessage = {}));
|
|
820
|
-
CopilotChatAssistantMessage.MarkdownRenderer.displayName = "CopilotChatAssistantMessage.MarkdownRenderer";
|
|
821
|
-
CopilotChatAssistantMessage.Toolbar.displayName = "CopilotChatAssistantMessage.Toolbar";
|
|
822
|
-
CopilotChatAssistantMessage.CopyButton.displayName = "CopilotChatAssistantMessage.CopyButton";
|
|
823
|
-
CopilotChatAssistantMessage.ThumbsUpButton.displayName = "CopilotChatAssistantMessage.ThumbsUpButton";
|
|
824
|
-
CopilotChatAssistantMessage.ThumbsDownButton.displayName = "CopilotChatAssistantMessage.ThumbsDownButton";
|
|
825
|
-
CopilotChatAssistantMessage.ReadAloudButton.displayName = "CopilotChatAssistantMessage.ReadAloudButton";
|
|
826
|
-
CopilotChatAssistantMessage.RegenerateButton.displayName = "CopilotChatAssistantMessage.RegenerateButton";
|
|
827
|
-
var CopilotChatAssistantMessage_default = CopilotChatAssistantMessage;
|
|
828
|
-
|
|
829
|
-
// src/components/chat/CopilotChatUserMessage.tsx
|
|
830
|
-
var import_react16 = require("react");
|
|
831
|
-
var import_lucide_react2 = require("lucide-react");
|
|
832
|
-
var import_tailwind_merge3 = require("tailwind-merge");
|
|
833
|
-
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
834
|
-
function flattenUserMessageContent(content) {
|
|
835
|
-
if (!content) {
|
|
836
|
-
return "";
|
|
837
|
-
}
|
|
838
|
-
if (typeof content === "string") {
|
|
839
|
-
return content;
|
|
840
|
-
}
|
|
841
|
-
return content.map((part) => {
|
|
842
|
-
if (part && typeof part === "object" && "type" in part && part.type === "text" && typeof part.text === "string") {
|
|
843
|
-
return part.text;
|
|
844
|
-
}
|
|
845
|
-
return "";
|
|
846
|
-
}).filter((text) => text.length > 0).join("\n");
|
|
847
|
-
}
|
|
848
|
-
function CopilotChatUserMessage({
|
|
849
|
-
message,
|
|
850
|
-
onEditMessage,
|
|
851
|
-
branchIndex,
|
|
852
|
-
numberOfBranches,
|
|
853
|
-
onSwitchToBranch,
|
|
854
|
-
additionalToolbarItems,
|
|
855
|
-
messageRenderer,
|
|
856
|
-
toolbar,
|
|
857
|
-
copyButton,
|
|
858
|
-
editButton,
|
|
859
|
-
branchNavigation,
|
|
860
|
-
children,
|
|
861
|
-
className,
|
|
862
|
-
...props
|
|
863
|
-
}) {
|
|
864
|
-
const flattenedContent = (0, import_react16.useMemo)(
|
|
865
|
-
() => flattenUserMessageContent(message.content),
|
|
866
|
-
[message.content]
|
|
867
|
-
);
|
|
868
|
-
const BoundMessageRenderer = renderSlot(
|
|
869
|
-
messageRenderer,
|
|
870
|
-
CopilotChatUserMessage.MessageRenderer,
|
|
871
|
-
{
|
|
872
|
-
content: flattenedContent
|
|
873
|
-
}
|
|
874
|
-
);
|
|
875
|
-
const BoundCopyButton = renderSlot(
|
|
876
|
-
copyButton,
|
|
877
|
-
CopilotChatUserMessage.CopyButton,
|
|
878
|
-
{
|
|
879
|
-
onClick: async () => {
|
|
880
|
-
if (flattenedContent) {
|
|
881
|
-
try {
|
|
882
|
-
await navigator.clipboard.writeText(flattenedContent);
|
|
883
|
-
} catch (err) {
|
|
884
|
-
console.error("Failed to copy message:", err);
|
|
885
|
-
}
|
|
886
|
-
}
|
|
887
|
-
}
|
|
888
|
-
}
|
|
889
|
-
);
|
|
890
|
-
const BoundEditButton = renderSlot(
|
|
891
|
-
editButton,
|
|
892
|
-
CopilotChatUserMessage.EditButton,
|
|
893
|
-
{
|
|
894
|
-
onClick: () => onEditMessage?.({ message })
|
|
895
|
-
}
|
|
896
|
-
);
|
|
897
|
-
const BoundBranchNavigation = renderSlot(
|
|
898
|
-
branchNavigation,
|
|
899
|
-
CopilotChatUserMessage.BranchNavigation,
|
|
900
|
-
{
|
|
901
|
-
currentBranch: branchIndex,
|
|
902
|
-
numberOfBranches,
|
|
903
|
-
onSwitchToBranch,
|
|
904
|
-
message
|
|
905
|
-
}
|
|
906
|
-
);
|
|
907
|
-
const showBranchNavigation = numberOfBranches && numberOfBranches > 1 && onSwitchToBranch;
|
|
908
|
-
const BoundToolbar = renderSlot(toolbar, CopilotChatUserMessage.Toolbar, {
|
|
909
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex items-center gap-1 justify-end", children: [
|
|
910
|
-
additionalToolbarItems,
|
|
911
|
-
BoundCopyButton,
|
|
912
|
-
onEditMessage && BoundEditButton,
|
|
913
|
-
showBranchNavigation && BoundBranchNavigation
|
|
914
|
-
] })
|
|
915
|
-
});
|
|
916
|
-
if (children) {
|
|
917
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_jsx_runtime11.Fragment, { children: children({
|
|
918
|
-
messageRenderer: BoundMessageRenderer,
|
|
919
|
-
toolbar: BoundToolbar,
|
|
920
|
-
copyButton: BoundCopyButton,
|
|
921
|
-
editButton: BoundEditButton,
|
|
922
|
-
branchNavigation: BoundBranchNavigation,
|
|
923
|
-
message,
|
|
924
|
-
branchIndex,
|
|
925
|
-
numberOfBranches,
|
|
926
|
-
additionalToolbarItems
|
|
927
|
-
}) });
|
|
928
|
-
}
|
|
929
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
930
|
-
"div",
|
|
931
|
-
{
|
|
932
|
-
className: (0, import_tailwind_merge3.twMerge)("flex flex-col items-end group pt-10", className),
|
|
933
|
-
"data-message-id": message.id,
|
|
934
|
-
...props,
|
|
935
|
-
children: [
|
|
936
|
-
BoundMessageRenderer,
|
|
937
|
-
BoundToolbar
|
|
938
|
-
]
|
|
939
|
-
}
|
|
940
|
-
);
|
|
941
|
-
}
|
|
942
|
-
((CopilotChatUserMessage2) => {
|
|
943
|
-
CopilotChatUserMessage2.Container = ({ children, className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
944
|
-
"div",
|
|
945
|
-
{
|
|
946
|
-
className: (0, import_tailwind_merge3.twMerge)("flex flex-col items-end group", className),
|
|
947
|
-
...props,
|
|
948
|
-
children
|
|
949
|
-
}
|
|
950
|
-
);
|
|
951
|
-
CopilotChatUserMessage2.MessageRenderer = ({ content, className }) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
952
|
-
"div",
|
|
953
|
-
{
|
|
954
|
-
className: (0, import_tailwind_merge3.twMerge)(
|
|
955
|
-
"prose dark:prose-invert bg-muted relative max-w-[80%] rounded-[18px] px-4 py-1.5 data-[multiline]:py-3 inline-block whitespace-pre-wrap",
|
|
956
|
-
className
|
|
957
|
-
),
|
|
958
|
-
children: content
|
|
959
|
-
}
|
|
960
|
-
);
|
|
961
|
-
CopilotChatUserMessage2.Toolbar = ({
|
|
962
|
-
className,
|
|
963
|
-
...props
|
|
964
|
-
}) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
965
|
-
"div",
|
|
966
|
-
{
|
|
967
|
-
className: (0, import_tailwind_merge3.twMerge)(
|
|
968
|
-
"w-full bg-transparent flex items-center justify-end -mr-[5px] mt-[4px] invisible group-hover:visible",
|
|
969
|
-
className
|
|
970
|
-
),
|
|
971
|
-
...props
|
|
972
|
-
}
|
|
973
|
-
);
|
|
974
|
-
CopilotChatUserMessage2.ToolbarButton = ({ title, children, className, ...props }) => {
|
|
975
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Tooltip, { children: [
|
|
976
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
977
|
-
Button,
|
|
978
|
-
{
|
|
979
|
-
type: "button",
|
|
980
|
-
variant: "assistantMessageToolbarButton",
|
|
981
|
-
"aria-label": title,
|
|
982
|
-
className: (0, import_tailwind_merge3.twMerge)(className),
|
|
983
|
-
...props,
|
|
984
|
-
children
|
|
985
|
-
}
|
|
986
|
-
) }),
|
|
987
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(TooltipContent, { side: "bottom", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { children: title }) })
|
|
988
|
-
] });
|
|
989
|
-
};
|
|
990
|
-
CopilotChatUserMessage2.CopyButton = ({ className, title, onClick, ...props }) => {
|
|
991
|
-
const config = useCopilotChatConfiguration();
|
|
992
|
-
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
993
|
-
const [copied, setCopied] = (0, import_react16.useState)(false);
|
|
994
|
-
const handleClick = (event) => {
|
|
995
|
-
setCopied(true);
|
|
996
|
-
setTimeout(() => setCopied(false), 2e3);
|
|
997
|
-
if (onClick) {
|
|
998
|
-
onClick(event);
|
|
999
|
-
}
|
|
1000
|
-
};
|
|
1001
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1002
|
-
CopilotChatUserMessage2.ToolbarButton,
|
|
1003
|
-
{
|
|
1004
|
-
title: title || labels.userMessageToolbarCopyMessageLabel,
|
|
1005
|
-
onClick: handleClick,
|
|
1006
|
-
className,
|
|
1007
|
-
...props,
|
|
1008
|
-
children: copied ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react2.Check, { className: "size-[18px]" }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react2.Copy, { className: "size-[18px]" })
|
|
1009
|
-
}
|
|
1010
|
-
);
|
|
1011
|
-
};
|
|
1012
|
-
CopilotChatUserMessage2.EditButton = ({ className, title, ...props }) => {
|
|
1013
|
-
const config = useCopilotChatConfiguration();
|
|
1014
|
-
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
1015
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1016
|
-
CopilotChatUserMessage2.ToolbarButton,
|
|
1017
|
-
{
|
|
1018
|
-
title: title || labels.userMessageToolbarEditMessageLabel,
|
|
1019
|
-
className,
|
|
1020
|
-
...props,
|
|
1021
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react2.Edit, { className: "size-[18px]" })
|
|
1022
|
-
}
|
|
1023
|
-
);
|
|
1024
|
-
};
|
|
1025
|
-
CopilotChatUserMessage2.BranchNavigation = ({
|
|
1026
|
-
className,
|
|
1027
|
-
currentBranch = 0,
|
|
1028
|
-
numberOfBranches = 1,
|
|
1029
|
-
onSwitchToBranch,
|
|
1030
|
-
message,
|
|
1031
|
-
...props
|
|
1032
|
-
}) => {
|
|
1033
|
-
if (!numberOfBranches || numberOfBranches <= 1 || !onSwitchToBranch) {
|
|
1034
|
-
return null;
|
|
1035
|
-
}
|
|
1036
|
-
const canGoPrev = currentBranch > 0;
|
|
1037
|
-
const canGoNext = currentBranch < numberOfBranches - 1;
|
|
1038
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: (0, import_tailwind_merge3.twMerge)("flex items-center gap-1", className), ...props, children: [
|
|
1039
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1040
|
-
Button,
|
|
1041
|
-
{
|
|
1042
|
-
type: "button",
|
|
1043
|
-
variant: "assistantMessageToolbarButton",
|
|
1044
|
-
onClick: () => onSwitchToBranch?.({
|
|
1045
|
-
branchIndex: currentBranch - 1,
|
|
1046
|
-
numberOfBranches,
|
|
1047
|
-
message
|
|
1048
|
-
}),
|
|
1049
|
-
disabled: !canGoPrev,
|
|
1050
|
-
className: "h-6 w-6 p-0",
|
|
1051
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react2.ChevronLeft, { className: "size-[20px]" })
|
|
1052
|
-
}
|
|
1053
|
-
),
|
|
1054
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { className: "text-sm text-muted-foreground px-0 font-medium", children: [
|
|
1055
|
-
currentBranch + 1,
|
|
1056
|
-
"/",
|
|
1057
|
-
numberOfBranches
|
|
1058
|
-
] }),
|
|
1059
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1060
|
-
Button,
|
|
1061
|
-
{
|
|
1062
|
-
type: "button",
|
|
1063
|
-
variant: "assistantMessageToolbarButton",
|
|
1064
|
-
onClick: () => onSwitchToBranch?.({
|
|
1065
|
-
branchIndex: currentBranch + 1,
|
|
1066
|
-
numberOfBranches,
|
|
1067
|
-
message
|
|
1068
|
-
}),
|
|
1069
|
-
disabled: !canGoNext,
|
|
1070
|
-
className: "h-6 w-6 p-0",
|
|
1071
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react2.ChevronRight, { className: "size-[20px]" })
|
|
1072
|
-
}
|
|
1073
|
-
)
|
|
1074
|
-
] });
|
|
1075
|
-
};
|
|
1076
|
-
})(CopilotChatUserMessage || (CopilotChatUserMessage = {}));
|
|
1077
|
-
CopilotChatUserMessage.Container.displayName = "CopilotChatUserMessage.Container";
|
|
1078
|
-
CopilotChatUserMessage.MessageRenderer.displayName = "CopilotChatUserMessage.MessageRenderer";
|
|
1079
|
-
CopilotChatUserMessage.Toolbar.displayName = "CopilotChatUserMessage.Toolbar";
|
|
1080
|
-
CopilotChatUserMessage.ToolbarButton.displayName = "CopilotChatUserMessage.ToolbarButton";
|
|
1081
|
-
CopilotChatUserMessage.CopyButton.displayName = "CopilotChatUserMessage.CopyButton";
|
|
1082
|
-
CopilotChatUserMessage.EditButton.displayName = "CopilotChatUserMessage.EditButton";
|
|
1083
|
-
CopilotChatUserMessage.BranchNavigation.displayName = "CopilotChatUserMessage.BranchNavigation";
|
|
1084
|
-
var CopilotChatUserMessage_default = CopilotChatUserMessage;
|
|
1085
|
-
|
|
1086
|
-
// src/components/chat/CopilotChatMessageView.tsx
|
|
1087
|
-
var import_tailwind_merge4 = require("tailwind-merge");
|
|
1088
|
-
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1089
|
-
function CopilotChatMessageView({
|
|
1090
|
-
messages = [],
|
|
1091
|
-
assistantMessage,
|
|
1092
|
-
userMessage,
|
|
1093
|
-
cursor,
|
|
1094
|
-
isRunning = false,
|
|
1095
|
-
children,
|
|
1096
|
-
className,
|
|
1097
|
-
...props
|
|
1098
|
-
}) {
|
|
1099
|
-
const renderCustomMessage = useRenderCustomMessages();
|
|
1100
|
-
const renderActivityMessage = useRenderActivityMessage();
|
|
1101
|
-
const messageElements = messages.flatMap((message) => {
|
|
1102
|
-
const elements = [];
|
|
1103
|
-
if (renderCustomMessage) {
|
|
1104
|
-
elements.push(
|
|
1105
|
-
renderCustomMessage({
|
|
1106
|
-
message,
|
|
1107
|
-
position: "before"
|
|
1108
|
-
})
|
|
1109
|
-
);
|
|
1110
|
-
}
|
|
1111
|
-
if (message.role === "assistant") {
|
|
1112
|
-
elements.push(
|
|
1113
|
-
renderSlot(assistantMessage, CopilotChatAssistantMessage_default, {
|
|
1114
|
-
key: message.id,
|
|
1115
|
-
message,
|
|
1116
|
-
messages,
|
|
1117
|
-
isRunning
|
|
1118
|
-
})
|
|
1119
|
-
);
|
|
1120
|
-
} else if (message.role === "user") {
|
|
1121
|
-
elements.push(
|
|
1122
|
-
renderSlot(userMessage, CopilotChatUserMessage_default, {
|
|
1123
|
-
key: message.id,
|
|
1124
|
-
message
|
|
1125
|
-
})
|
|
1126
|
-
);
|
|
1127
|
-
} else if (message.role === "activity") {
|
|
1128
|
-
const renderedActivity = renderActivityMessage(message);
|
|
1129
|
-
if (renderedActivity) {
|
|
1130
|
-
elements.push(renderedActivity);
|
|
1131
|
-
}
|
|
1132
|
-
}
|
|
1133
|
-
if (renderCustomMessage) {
|
|
1134
|
-
elements.push(
|
|
1135
|
-
renderCustomMessage({
|
|
1136
|
-
message,
|
|
1137
|
-
position: "after"
|
|
1138
|
-
})
|
|
1139
|
-
);
|
|
1140
|
-
}
|
|
1141
|
-
return elements;
|
|
1142
|
-
}).filter(Boolean);
|
|
1143
|
-
if (children) {
|
|
1144
|
-
return children({ messageElements, messages, isRunning });
|
|
1145
|
-
}
|
|
1146
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: (0, import_tailwind_merge4.twMerge)("flex flex-col", className), ...props, children: [
|
|
1147
|
-
messageElements,
|
|
1148
|
-
isRunning && renderSlot(cursor, CopilotChatMessageView.Cursor, {})
|
|
1149
|
-
] });
|
|
1150
|
-
}
|
|
1151
|
-
CopilotChatMessageView.Cursor = function Cursor({ className, ...props }) {
|
|
1152
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1153
|
-
"div",
|
|
1154
|
-
{
|
|
1155
|
-
className: (0, import_tailwind_merge4.twMerge)("w-[11px] h-[11px] rounded-full bg-foreground animate-pulse-cursor ml-1", className),
|
|
1156
|
-
...props
|
|
1157
|
-
}
|
|
1158
|
-
);
|
|
1159
|
-
};
|
|
1160
|
-
var CopilotChatMessageView_default = CopilotChatMessageView;
|
|
1161
|
-
|
|
1162
|
-
// src/components/chat/CopilotChatInput.tsx
|
|
1163
|
-
var import_react18 = require("react");
|
|
1164
|
-
var import_tailwind_merge6 = require("tailwind-merge");
|
|
1165
|
-
var import_lucide_react4 = require("lucide-react");
|
|
1166
|
-
|
|
1167
|
-
// src/components/ui/dropdown-menu.tsx
|
|
1168
|
-
var DropdownMenuPrimitive = __toESM(require("@radix-ui/react-dropdown-menu"));
|
|
1169
|
-
var import_lucide_react3 = require("lucide-react");
|
|
1170
|
-
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1171
|
-
function DropdownMenu({
|
|
1172
|
-
...props
|
|
1173
|
-
}) {
|
|
1174
|
-
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DropdownMenuPrimitive.Root, { "data-slot": "dropdown-menu", ...props });
|
|
1175
|
-
}
|
|
1176
|
-
function DropdownMenuTrigger({
|
|
1177
|
-
...props
|
|
1178
|
-
}) {
|
|
1179
|
-
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1180
|
-
DropdownMenuPrimitive.Trigger,
|
|
1181
|
-
{
|
|
1182
|
-
"data-slot": "dropdown-menu-trigger",
|
|
1183
|
-
...props
|
|
1184
|
-
}
|
|
1185
|
-
);
|
|
1186
|
-
}
|
|
1187
|
-
function DropdownMenuContent({
|
|
1188
|
-
className,
|
|
1189
|
-
sideOffset = 4,
|
|
1190
|
-
...props
|
|
1191
|
-
}) {
|
|
1192
|
-
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DropdownMenuPrimitive.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1193
|
-
DropdownMenuPrimitive.Content,
|
|
1194
|
-
{
|
|
1195
|
-
"data-slot": "dropdown-menu-content",
|
|
1196
|
-
sideOffset,
|
|
1197
|
-
className: cn(
|
|
1198
|
-
"bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",
|
|
1199
|
-
className
|
|
1200
|
-
),
|
|
1201
|
-
...props
|
|
1202
|
-
}
|
|
1203
|
-
) });
|
|
1204
|
-
}
|
|
1205
|
-
function DropdownMenuItem({
|
|
1206
|
-
className,
|
|
1207
|
-
inset,
|
|
1208
|
-
variant = "default",
|
|
1209
|
-
...props
|
|
1210
|
-
}) {
|
|
1211
|
-
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1212
|
-
DropdownMenuPrimitive.Item,
|
|
1213
|
-
{
|
|
1214
|
-
"data-slot": "dropdown-menu-item",
|
|
1215
|
-
"data-inset": inset,
|
|
1216
|
-
"data-variant": variant,
|
|
1217
|
-
className: cn(
|
|
1218
|
-
"focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
1219
|
-
className
|
|
1220
|
-
),
|
|
1221
|
-
...props
|
|
1222
|
-
}
|
|
1223
|
-
);
|
|
1224
|
-
}
|
|
1225
|
-
function DropdownMenuSeparator({
|
|
1226
|
-
className,
|
|
1227
|
-
...props
|
|
1228
|
-
}) {
|
|
1229
|
-
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1230
|
-
DropdownMenuPrimitive.Separator,
|
|
1231
|
-
{
|
|
1232
|
-
"data-slot": "dropdown-menu-separator",
|
|
1233
|
-
className: cn("bg-border -mx-1 my-1 h-px", className),
|
|
1234
|
-
...props
|
|
1235
|
-
}
|
|
1236
|
-
);
|
|
1237
|
-
}
|
|
1238
|
-
function DropdownMenuSub({
|
|
1239
|
-
...props
|
|
1240
|
-
}) {
|
|
1241
|
-
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DropdownMenuPrimitive.Sub, { "data-slot": "dropdown-menu-sub", ...props });
|
|
1242
|
-
}
|
|
1243
|
-
function DropdownMenuSubTrigger({
|
|
1244
|
-
className,
|
|
1245
|
-
inset,
|
|
1246
|
-
children,
|
|
1247
|
-
...props
|
|
1248
|
-
}) {
|
|
1249
|
-
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
1250
|
-
DropdownMenuPrimitive.SubTrigger,
|
|
1251
|
-
{
|
|
1252
|
-
"data-slot": "dropdown-menu-sub-trigger",
|
|
1253
|
-
"data-inset": inset,
|
|
1254
|
-
className: cn(
|
|
1255
|
-
"focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground flex cursor-default items-center rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[inset]:pl-8",
|
|
1256
|
-
className
|
|
1257
|
-
),
|
|
1258
|
-
...props,
|
|
1259
|
-
children: [
|
|
1260
|
-
children,
|
|
1261
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react3.ChevronRightIcon, { className: "ml-auto size-4" })
|
|
1262
|
-
]
|
|
1263
|
-
}
|
|
1264
|
-
);
|
|
1265
|
-
}
|
|
1266
|
-
function DropdownMenuSubContent({
|
|
1267
|
-
className,
|
|
1268
|
-
...props
|
|
1269
|
-
}) {
|
|
1270
|
-
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1271
|
-
DropdownMenuPrimitive.SubContent,
|
|
1272
|
-
{
|
|
1273
|
-
"data-slot": "dropdown-menu-sub-content",
|
|
1274
|
-
className: cn(
|
|
1275
|
-
"bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-md border p-1 shadow-lg",
|
|
1276
|
-
className
|
|
1277
|
-
),
|
|
1278
|
-
...props
|
|
1279
|
-
}
|
|
1280
|
-
);
|
|
1281
|
-
}
|
|
1282
|
-
|
|
1283
|
-
// src/components/chat/CopilotChatAudioRecorder.tsx
|
|
1284
|
-
var import_react17 = require("react");
|
|
1285
|
-
var import_tailwind_merge5 = require("tailwind-merge");
|
|
1286
|
-
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1287
|
-
var CopilotChatAudioRecorder = (0, import_react17.forwardRef)((props, ref) => {
|
|
1288
|
-
const { className, ...divProps } = props;
|
|
1289
|
-
const canvasRef = (0, import_react17.useRef)(null);
|
|
1290
|
-
const getLoudness = (n) => {
|
|
1291
|
-
const elapsed = Date.now() / 1e3;
|
|
1292
|
-
const samples = [];
|
|
1293
|
-
for (let i = 0; i < n; i++) {
|
|
1294
|
-
const position = i / n * 10 + elapsed * 0.5;
|
|
1295
|
-
const wave1 = Math.sin(position * 2) * 0.3;
|
|
1296
|
-
const wave2 = Math.sin(position * 5 + elapsed) * 0.2;
|
|
1297
|
-
const wave3 = Math.sin(position * 0.5 + elapsed * 0.3) * 0.4;
|
|
1298
|
-
const noise = (Math.random() - 0.5) * 0.1;
|
|
1299
|
-
const envelope = Math.sin(elapsed * 0.7) * 0.5 + 0.5;
|
|
1300
|
-
let amplitude = (wave1 + wave2 + wave3 + noise) * envelope;
|
|
1301
|
-
amplitude = Math.max(0, Math.min(1, amplitude * 0.5 + 0.3));
|
|
1302
|
-
samples.push(amplitude);
|
|
1303
|
-
}
|
|
1304
|
-
return samples;
|
|
1305
|
-
};
|
|
1306
|
-
(0, import_react17.useEffect)(() => {
|
|
1307
|
-
const canvas = canvasRef.current;
|
|
1308
|
-
if (!canvas) return;
|
|
1309
|
-
const ctx = canvas.getContext("2d");
|
|
1310
|
-
if (!ctx) return;
|
|
1311
|
-
let animationId;
|
|
1312
|
-
const draw = () => {
|
|
1313
|
-
const rect = canvas.getBoundingClientRect();
|
|
1314
|
-
const dpr = window.devicePixelRatio || 1;
|
|
1315
|
-
if (canvas.width !== rect.width * dpr || canvas.height !== rect.height * dpr) {
|
|
1316
|
-
canvas.width = rect.width * dpr;
|
|
1317
|
-
canvas.height = rect.height * dpr;
|
|
1318
|
-
ctx.scale(dpr, dpr);
|
|
1319
|
-
ctx.imageSmoothingEnabled = false;
|
|
1320
|
-
}
|
|
1321
|
-
const barWidth = 2;
|
|
1322
|
-
const minHeight = 2;
|
|
1323
|
-
const maxHeight = 20;
|
|
1324
|
-
const gap = 2;
|
|
1325
|
-
const numSamples = Math.ceil(rect.width / (barWidth + gap));
|
|
1326
|
-
const loudnessData = getLoudness(numSamples);
|
|
1327
|
-
ctx.clearRect(0, 0, rect.width, rect.height);
|
|
1328
|
-
const computedStyle = getComputedStyle(canvas);
|
|
1329
|
-
const currentForeground = computedStyle.color;
|
|
1330
|
-
ctx.fillStyle = currentForeground;
|
|
1331
|
-
const centerY = rect.height / 2;
|
|
1332
|
-
for (let i = 0; i < loudnessData.length; i++) {
|
|
1333
|
-
const sample = loudnessData[i] ?? 0;
|
|
1334
|
-
const barHeight = Math.round(
|
|
1335
|
-
sample * (maxHeight - minHeight) + minHeight
|
|
1336
|
-
);
|
|
1337
|
-
const x = Math.round(i * (barWidth + gap));
|
|
1338
|
-
const y = Math.round(centerY - barHeight / 2);
|
|
1339
|
-
ctx.fillRect(x, y, barWidth, barHeight);
|
|
1340
|
-
}
|
|
1341
|
-
animationId = requestAnimationFrame(draw);
|
|
1342
|
-
};
|
|
1343
|
-
draw();
|
|
1344
|
-
return () => {
|
|
1345
|
-
if (animationId) {
|
|
1346
|
-
cancelAnimationFrame(animationId);
|
|
1347
|
-
}
|
|
1348
|
-
};
|
|
1349
|
-
}, []);
|
|
1350
|
-
(0, import_react17.useImperativeHandle)(
|
|
1351
|
-
ref,
|
|
1352
|
-
() => ({
|
|
1353
|
-
get state() {
|
|
1354
|
-
return "idle";
|
|
1355
|
-
},
|
|
1356
|
-
start: async () => {
|
|
1357
|
-
},
|
|
1358
|
-
stop: () => new Promise((resolve) => {
|
|
1359
|
-
const emptyBlob = new Blob([], { type: "audio/webm" });
|
|
1360
|
-
resolve(emptyBlob);
|
|
1361
|
-
}),
|
|
1362
|
-
dispose: () => {
|
|
1363
|
-
}
|
|
1364
|
-
}),
|
|
1365
|
-
[]
|
|
1366
|
-
);
|
|
1367
|
-
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: (0, import_tailwind_merge5.twMerge)("h-[44px] w-full px-5", className), ...divProps, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1368
|
-
"canvas",
|
|
1369
|
-
{
|
|
1370
|
-
ref: canvasRef,
|
|
1371
|
-
className: "w-full h-full",
|
|
1372
|
-
style: { imageRendering: "pixelated" }
|
|
1373
|
-
}
|
|
1374
|
-
) });
|
|
1375
|
-
});
|
|
1376
|
-
CopilotChatAudioRecorder.displayName = "WebAudioRecorder";
|
|
1377
|
-
|
|
1378
|
-
// src/components/chat/CopilotChatInput.tsx
|
|
1379
|
-
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1380
|
-
var SLASH_MENU_MAX_VISIBLE_ITEMS = 5;
|
|
1381
|
-
var SLASH_MENU_ITEM_HEIGHT_PX = 40;
|
|
1382
|
-
function CopilotChatInput({
|
|
1383
|
-
mode = "input",
|
|
1384
|
-
onSubmitMessage,
|
|
1385
|
-
onStop,
|
|
1386
|
-
isRunning = false,
|
|
1387
|
-
onStartTranscribe,
|
|
1388
|
-
onCancelTranscribe,
|
|
1389
|
-
onFinishTranscribe,
|
|
1390
|
-
onAddFile,
|
|
1391
|
-
onChange,
|
|
1392
|
-
value,
|
|
1393
|
-
toolsMenu,
|
|
1394
|
-
autoFocus = true,
|
|
1395
|
-
textArea,
|
|
1396
|
-
sendButton,
|
|
1397
|
-
startTranscribeButton,
|
|
1398
|
-
cancelTranscribeButton,
|
|
1399
|
-
finishTranscribeButton,
|
|
1400
|
-
addMenuButton,
|
|
1401
|
-
audioRecorder,
|
|
1402
|
-
children,
|
|
1403
|
-
className,
|
|
1404
|
-
...props
|
|
1405
|
-
}) {
|
|
1406
|
-
const isControlled = value !== void 0;
|
|
1407
|
-
const [internalValue, setInternalValue] = (0, import_react18.useState)(() => value ?? "");
|
|
1408
|
-
(0, import_react18.useEffect)(() => {
|
|
1409
|
-
if (!isControlled && value !== void 0) {
|
|
1410
|
-
setInternalValue(value);
|
|
1411
|
-
}
|
|
1412
|
-
}, [isControlled, value]);
|
|
1413
|
-
const resolvedValue = isControlled ? value ?? "" : internalValue;
|
|
1414
|
-
const [layout, setLayout] = (0, import_react18.useState)("compact");
|
|
1415
|
-
const ignoreResizeRef = (0, import_react18.useRef)(false);
|
|
1416
|
-
const resizeEvaluationRafRef = (0, import_react18.useRef)(null);
|
|
1417
|
-
const isExpanded = mode === "input" && layout === "expanded";
|
|
1418
|
-
const [commandQuery, setCommandQuery] = (0, import_react18.useState)(null);
|
|
1419
|
-
const [slashHighlightIndex, setSlashHighlightIndex] = (0, import_react18.useState)(0);
|
|
1420
|
-
const inputRef = (0, import_react18.useRef)(null);
|
|
1421
|
-
const gridRef = (0, import_react18.useRef)(null);
|
|
1422
|
-
const addButtonContainerRef = (0, import_react18.useRef)(null);
|
|
1423
|
-
const actionsContainerRef = (0, import_react18.useRef)(null);
|
|
1424
|
-
const audioRecorderRef = (0, import_react18.useRef)(null);
|
|
1425
|
-
const slashMenuRef = (0, import_react18.useRef)(null);
|
|
1426
|
-
const config = useCopilotChatConfiguration();
|
|
1427
|
-
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
1428
|
-
const previousModalStateRef = (0, import_react18.useRef)(void 0);
|
|
1429
|
-
const measurementCanvasRef = (0, import_react18.useRef)(null);
|
|
1430
|
-
const measurementsRef = (0, import_react18.useRef)({
|
|
1431
|
-
singleLineHeight: 0,
|
|
1432
|
-
maxHeight: 0,
|
|
1433
|
-
paddingLeft: 0,
|
|
1434
|
-
paddingRight: 0
|
|
1435
|
-
});
|
|
1436
|
-
const commandItems = (0, import_react18.useMemo)(() => {
|
|
1437
|
-
const entries = [];
|
|
1438
|
-
const seen = /* @__PURE__ */ new Set();
|
|
1439
|
-
const pushItem = (item) => {
|
|
1440
|
-
if (item === "-") {
|
|
1441
|
-
return;
|
|
1442
|
-
}
|
|
1443
|
-
if (item.items && item.items.length > 0) {
|
|
1444
|
-
for (const nested of item.items) {
|
|
1445
|
-
pushItem(nested);
|
|
1446
|
-
}
|
|
1447
|
-
return;
|
|
1448
|
-
}
|
|
1449
|
-
if (!seen.has(item.label)) {
|
|
1450
|
-
seen.add(item.label);
|
|
1451
|
-
entries.push(item);
|
|
1452
|
-
}
|
|
1453
|
-
};
|
|
1454
|
-
if (onAddFile) {
|
|
1455
|
-
pushItem({
|
|
1456
|
-
label: labels.chatInputToolbarAddButtonLabel,
|
|
1457
|
-
action: onAddFile
|
|
1458
|
-
});
|
|
1459
|
-
}
|
|
1460
|
-
if (toolsMenu && toolsMenu.length > 0) {
|
|
1461
|
-
for (const item of toolsMenu) {
|
|
1462
|
-
pushItem(item);
|
|
1463
|
-
}
|
|
1464
|
-
}
|
|
1465
|
-
return entries;
|
|
1466
|
-
}, [labels.chatInputToolbarAddButtonLabel, onAddFile, toolsMenu]);
|
|
1467
|
-
const filteredCommands = (0, import_react18.useMemo)(() => {
|
|
1468
|
-
if (commandQuery === null) {
|
|
1469
|
-
return [];
|
|
1470
|
-
}
|
|
1471
|
-
if (commandItems.length === 0) {
|
|
1472
|
-
return [];
|
|
1473
|
-
}
|
|
1474
|
-
const query = commandQuery.trim().toLowerCase();
|
|
1475
|
-
if (query.length === 0) {
|
|
1476
|
-
return commandItems;
|
|
1477
|
-
}
|
|
1478
|
-
const startsWith = [];
|
|
1479
|
-
const contains = [];
|
|
1480
|
-
for (const item of commandItems) {
|
|
1481
|
-
const label = item.label.toLowerCase();
|
|
1482
|
-
if (label.startsWith(query)) {
|
|
1483
|
-
startsWith.push(item);
|
|
1484
|
-
} else if (label.includes(query)) {
|
|
1485
|
-
contains.push(item);
|
|
1486
|
-
}
|
|
1487
|
-
}
|
|
1488
|
-
return [...startsWith, ...contains];
|
|
1489
|
-
}, [commandItems, commandQuery]);
|
|
1490
|
-
(0, import_react18.useEffect)(() => {
|
|
1491
|
-
if (!autoFocus) {
|
|
1492
|
-
previousModalStateRef.current = config?.isModalOpen;
|
|
1493
|
-
return;
|
|
1494
|
-
}
|
|
1495
|
-
if (config?.isModalOpen && !previousModalStateRef.current) {
|
|
1496
|
-
inputRef.current?.focus();
|
|
1497
|
-
}
|
|
1498
|
-
previousModalStateRef.current = config?.isModalOpen;
|
|
1499
|
-
}, [config?.isModalOpen, autoFocus]);
|
|
1500
|
-
(0, import_react18.useEffect)(() => {
|
|
1501
|
-
if (commandItems.length === 0 && commandQuery !== null) {
|
|
1502
|
-
setCommandQuery(null);
|
|
1503
|
-
}
|
|
1504
|
-
}, [commandItems.length, commandQuery]);
|
|
1505
|
-
const previousCommandQueryRef = (0, import_react18.useRef)(null);
|
|
1506
|
-
(0, import_react18.useEffect)(() => {
|
|
1507
|
-
if (commandQuery !== null && commandQuery !== previousCommandQueryRef.current && filteredCommands.length > 0) {
|
|
1508
|
-
setSlashHighlightIndex(0);
|
|
1509
|
-
}
|
|
1510
|
-
previousCommandQueryRef.current = commandQuery;
|
|
1511
|
-
}, [commandQuery, filteredCommands.length]);
|
|
1512
|
-
(0, import_react18.useEffect)(() => {
|
|
1513
|
-
if (commandQuery === null) {
|
|
1514
|
-
setSlashHighlightIndex(0);
|
|
1515
|
-
return;
|
|
1516
|
-
}
|
|
1517
|
-
if (filteredCommands.length === 0) {
|
|
1518
|
-
setSlashHighlightIndex(-1);
|
|
1519
|
-
} else if (slashHighlightIndex < 0 || slashHighlightIndex >= filteredCommands.length) {
|
|
1520
|
-
setSlashHighlightIndex(0);
|
|
1521
|
-
}
|
|
1522
|
-
}, [commandQuery, filteredCommands, slashHighlightIndex]);
|
|
1523
|
-
(0, import_react18.useEffect)(() => {
|
|
1524
|
-
const recorder = audioRecorderRef.current;
|
|
1525
|
-
if (!recorder) {
|
|
1526
|
-
return;
|
|
1527
|
-
}
|
|
1528
|
-
if (mode === "transcribe") {
|
|
1529
|
-
recorder.start().catch(console.error);
|
|
1530
|
-
} else {
|
|
1531
|
-
if (recorder.state === "recording") {
|
|
1532
|
-
recorder.stop().catch(console.error);
|
|
1533
|
-
}
|
|
1534
|
-
}
|
|
1535
|
-
}, [mode]);
|
|
1536
|
-
(0, import_react18.useEffect)(() => {
|
|
1537
|
-
if (mode !== "input") {
|
|
1538
|
-
setLayout("compact");
|
|
1539
|
-
setCommandQuery(null);
|
|
1540
|
-
}
|
|
1541
|
-
}, [mode]);
|
|
1542
|
-
const updateSlashState = (0, import_react18.useCallback)(
|
|
1543
|
-
(value2) => {
|
|
1544
|
-
if (commandItems.length === 0) {
|
|
1545
|
-
setCommandQuery((prev) => prev === null ? prev : null);
|
|
1546
|
-
return;
|
|
1547
|
-
}
|
|
1548
|
-
if (value2.startsWith("/")) {
|
|
1549
|
-
const firstLine = value2.split(/\r?\n/, 1)[0] ?? "";
|
|
1550
|
-
const query = firstLine.slice(1);
|
|
1551
|
-
setCommandQuery((prev) => prev === query ? prev : query);
|
|
1552
|
-
} else {
|
|
1553
|
-
setCommandQuery((prev) => prev === null ? prev : null);
|
|
1554
|
-
}
|
|
1555
|
-
},
|
|
1556
|
-
[commandItems.length]
|
|
1557
|
-
);
|
|
1558
|
-
(0, import_react18.useEffect)(() => {
|
|
1559
|
-
updateSlashState(resolvedValue);
|
|
1560
|
-
}, [resolvedValue, updateSlashState]);
|
|
1561
|
-
const handleChange = (e) => {
|
|
1562
|
-
const nextValue = e.target.value;
|
|
1563
|
-
if (!isControlled) {
|
|
1564
|
-
setInternalValue(nextValue);
|
|
1565
|
-
}
|
|
1566
|
-
onChange?.(nextValue);
|
|
1567
|
-
updateSlashState(nextValue);
|
|
1568
|
-
};
|
|
1569
|
-
const clearInputValue = (0, import_react18.useCallback)(() => {
|
|
1570
|
-
if (!isControlled) {
|
|
1571
|
-
setInternalValue("");
|
|
1572
|
-
}
|
|
1573
|
-
if (onChange) {
|
|
1574
|
-
onChange("");
|
|
1575
|
-
}
|
|
1576
|
-
}, [isControlled, onChange]);
|
|
1577
|
-
const runCommand = (0, import_react18.useCallback)(
|
|
1578
|
-
(item) => {
|
|
1579
|
-
clearInputValue();
|
|
1580
|
-
item.action?.();
|
|
1581
|
-
setCommandQuery(null);
|
|
1582
|
-
setSlashHighlightIndex(0);
|
|
1583
|
-
requestAnimationFrame(() => {
|
|
1584
|
-
inputRef.current?.focus();
|
|
1585
|
-
});
|
|
1586
|
-
},
|
|
1587
|
-
[clearInputValue]
|
|
1588
|
-
);
|
|
1589
|
-
const handleKeyDown = (e) => {
|
|
1590
|
-
if (commandQuery !== null && mode === "input") {
|
|
1591
|
-
if (e.key === "ArrowDown") {
|
|
1592
|
-
if (filteredCommands.length > 0) {
|
|
1593
|
-
e.preventDefault();
|
|
1594
|
-
setSlashHighlightIndex((prev) => {
|
|
1595
|
-
if (filteredCommands.length === 0) {
|
|
1596
|
-
return prev;
|
|
1597
|
-
}
|
|
1598
|
-
const next = prev === -1 ? 0 : (prev + 1) % filteredCommands.length;
|
|
1599
|
-
return next;
|
|
1600
|
-
});
|
|
1601
|
-
}
|
|
1602
|
-
return;
|
|
1603
|
-
}
|
|
1604
|
-
if (e.key === "ArrowUp") {
|
|
1605
|
-
if (filteredCommands.length > 0) {
|
|
1606
|
-
e.preventDefault();
|
|
1607
|
-
setSlashHighlightIndex((prev) => {
|
|
1608
|
-
if (filteredCommands.length === 0) {
|
|
1609
|
-
return prev;
|
|
1610
|
-
}
|
|
1611
|
-
if (prev === -1) {
|
|
1612
|
-
return filteredCommands.length - 1;
|
|
1613
|
-
}
|
|
1614
|
-
return prev <= 0 ? filteredCommands.length - 1 : prev - 1;
|
|
1615
|
-
});
|
|
1616
|
-
}
|
|
1617
|
-
return;
|
|
1618
|
-
}
|
|
1619
|
-
if (e.key === "Enter") {
|
|
1620
|
-
const selected = slashHighlightIndex >= 0 ? filteredCommands[slashHighlightIndex] : void 0;
|
|
1621
|
-
if (selected) {
|
|
1622
|
-
e.preventDefault();
|
|
1623
|
-
runCommand(selected);
|
|
1624
|
-
return;
|
|
1625
|
-
}
|
|
1626
|
-
}
|
|
1627
|
-
if (e.key === "Escape") {
|
|
1628
|
-
e.preventDefault();
|
|
1629
|
-
setCommandQuery(null);
|
|
1630
|
-
return;
|
|
1631
|
-
}
|
|
1632
|
-
}
|
|
1633
|
-
if (e.key === "Enter" && !e.shiftKey) {
|
|
1634
|
-
e.preventDefault();
|
|
1635
|
-
if (isProcessing) {
|
|
1636
|
-
onStop?.();
|
|
1637
|
-
} else {
|
|
1638
|
-
send();
|
|
1639
|
-
}
|
|
1640
|
-
}
|
|
1641
|
-
};
|
|
1642
|
-
const send = () => {
|
|
1643
|
-
if (!onSubmitMessage) {
|
|
1644
|
-
return;
|
|
1645
|
-
}
|
|
1646
|
-
const trimmed = resolvedValue.trim();
|
|
1647
|
-
if (!trimmed) {
|
|
1648
|
-
return;
|
|
1649
|
-
}
|
|
1650
|
-
onSubmitMessage(trimmed);
|
|
1651
|
-
if (!isControlled) {
|
|
1652
|
-
setInternalValue("");
|
|
1653
|
-
onChange?.("");
|
|
1654
|
-
}
|
|
1655
|
-
if (inputRef.current) {
|
|
1656
|
-
inputRef.current.focus();
|
|
1657
|
-
}
|
|
1658
|
-
};
|
|
1659
|
-
const BoundTextArea = renderSlot(textArea, CopilotChatInput.TextArea, {
|
|
1660
|
-
ref: inputRef,
|
|
1661
|
-
value: resolvedValue,
|
|
1662
|
-
onChange: handleChange,
|
|
1663
|
-
onKeyDown: handleKeyDown,
|
|
1664
|
-
autoFocus,
|
|
1665
|
-
className: (0, import_tailwind_merge6.twMerge)(
|
|
1666
|
-
"w-full py-3",
|
|
1667
|
-
isExpanded ? "px-5" : "pr-5"
|
|
1668
|
-
)
|
|
1669
|
-
});
|
|
1670
|
-
const isProcessing = mode !== "transcribe" && isRunning;
|
|
1671
|
-
const canSend = resolvedValue.trim().length > 0 && !!onSubmitMessage;
|
|
1672
|
-
const canStop = !!onStop;
|
|
1673
|
-
const handleSendButtonClick = () => {
|
|
1674
|
-
if (isProcessing) {
|
|
1675
|
-
onStop?.();
|
|
1676
|
-
return;
|
|
1677
|
-
}
|
|
1678
|
-
send();
|
|
1679
|
-
};
|
|
1680
|
-
const BoundAudioRecorder = renderSlot(audioRecorder, CopilotChatAudioRecorder, {
|
|
1681
|
-
ref: audioRecorderRef
|
|
1682
|
-
});
|
|
1683
|
-
const BoundSendButton = renderSlot(sendButton, CopilotChatInput.SendButton, {
|
|
1684
|
-
onClick: handleSendButtonClick,
|
|
1685
|
-
disabled: isProcessing ? !canStop : !canSend,
|
|
1686
|
-
children: isProcessing && canStop ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react4.Square, { className: "size-[18px] fill-current" }) : void 0
|
|
1687
|
-
});
|
|
1688
|
-
const BoundStartTranscribeButton = renderSlot(startTranscribeButton, CopilotChatInput.StartTranscribeButton, {
|
|
1689
|
-
onClick: onStartTranscribe
|
|
1690
|
-
});
|
|
1691
|
-
const BoundCancelTranscribeButton = renderSlot(cancelTranscribeButton, CopilotChatInput.CancelTranscribeButton, {
|
|
1692
|
-
onClick: onCancelTranscribe
|
|
1693
|
-
});
|
|
1694
|
-
const BoundFinishTranscribeButton = renderSlot(finishTranscribeButton, CopilotChatInput.FinishTranscribeButton, {
|
|
1695
|
-
onClick: onFinishTranscribe
|
|
1696
|
-
});
|
|
1697
|
-
const BoundAddMenuButton = renderSlot(addMenuButton, CopilotChatInput.AddMenuButton, {
|
|
1698
|
-
disabled: mode === "transcribe",
|
|
1699
|
-
onAddFile,
|
|
1700
|
-
toolsMenu
|
|
1701
|
-
});
|
|
1702
|
-
if (children) {
|
|
1703
|
-
const childProps = {
|
|
1704
|
-
textArea: BoundTextArea,
|
|
1705
|
-
audioRecorder: BoundAudioRecorder,
|
|
1706
|
-
sendButton: BoundSendButton,
|
|
1707
|
-
startTranscribeButton: BoundStartTranscribeButton,
|
|
1708
|
-
cancelTranscribeButton: BoundCancelTranscribeButton,
|
|
1709
|
-
finishTranscribeButton: BoundFinishTranscribeButton,
|
|
1710
|
-
addMenuButton: BoundAddMenuButton,
|
|
1711
|
-
onSubmitMessage,
|
|
1712
|
-
onStop,
|
|
1713
|
-
isRunning,
|
|
1714
|
-
onStartTranscribe,
|
|
1715
|
-
onCancelTranscribe,
|
|
1716
|
-
onFinishTranscribe,
|
|
1717
|
-
onAddFile,
|
|
1718
|
-
mode,
|
|
1719
|
-
toolsMenu,
|
|
1720
|
-
autoFocus
|
|
1721
|
-
};
|
|
1722
|
-
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_jsx_runtime15.Fragment, { children: children(childProps) });
|
|
1723
|
-
}
|
|
1724
|
-
const handleContainerClick = (e) => {
|
|
1725
|
-
const target = e.target;
|
|
1726
|
-
if (target.tagName !== "BUTTON" && !target.closest("button") && inputRef.current && mode === "input") {
|
|
1727
|
-
inputRef.current.focus();
|
|
1728
|
-
}
|
|
1729
|
-
};
|
|
1730
|
-
const ensureMeasurements = (0, import_react18.useCallback)(() => {
|
|
1731
|
-
const textarea = inputRef.current;
|
|
1732
|
-
if (!textarea) {
|
|
1733
|
-
return;
|
|
1734
|
-
}
|
|
1735
|
-
const previousValue = textarea.value;
|
|
1736
|
-
const previousHeight = textarea.style.height;
|
|
1737
|
-
textarea.style.height = "auto";
|
|
1738
|
-
const computedStyle = window.getComputedStyle(textarea);
|
|
1739
|
-
const paddingLeft = parseFloat(computedStyle.paddingLeft) || 0;
|
|
1740
|
-
const paddingRight = parseFloat(computedStyle.paddingRight) || 0;
|
|
1741
|
-
const paddingTop = parseFloat(computedStyle.paddingTop) || 0;
|
|
1742
|
-
const paddingBottom = parseFloat(computedStyle.paddingBottom) || 0;
|
|
1743
|
-
textarea.value = "";
|
|
1744
|
-
const singleLineHeight = textarea.scrollHeight;
|
|
1745
|
-
textarea.value = previousValue;
|
|
1746
|
-
const contentHeight = singleLineHeight - paddingTop - paddingBottom;
|
|
1747
|
-
const maxHeight = contentHeight * 5 + paddingTop + paddingBottom;
|
|
1748
|
-
measurementsRef.current = {
|
|
1749
|
-
singleLineHeight,
|
|
1750
|
-
maxHeight,
|
|
1751
|
-
paddingLeft,
|
|
1752
|
-
paddingRight
|
|
1753
|
-
};
|
|
1754
|
-
textarea.style.height = previousHeight;
|
|
1755
|
-
textarea.style.maxHeight = `${maxHeight}px`;
|
|
1756
|
-
}, []);
|
|
1757
|
-
const adjustTextareaHeight = (0, import_react18.useCallback)(() => {
|
|
1758
|
-
const textarea = inputRef.current;
|
|
1759
|
-
if (!textarea) {
|
|
1760
|
-
return 0;
|
|
1761
|
-
}
|
|
1762
|
-
if (measurementsRef.current.singleLineHeight === 0) {
|
|
1763
|
-
ensureMeasurements();
|
|
1764
|
-
}
|
|
1765
|
-
const { maxHeight } = measurementsRef.current;
|
|
1766
|
-
if (maxHeight) {
|
|
1767
|
-
textarea.style.maxHeight = `${maxHeight}px`;
|
|
1768
|
-
}
|
|
1769
|
-
textarea.style.height = "auto";
|
|
1770
|
-
const scrollHeight = textarea.scrollHeight;
|
|
1771
|
-
if (maxHeight) {
|
|
1772
|
-
textarea.style.height = `${Math.min(scrollHeight, maxHeight)}px`;
|
|
1773
|
-
} else {
|
|
1774
|
-
textarea.style.height = `${scrollHeight}px`;
|
|
1775
|
-
}
|
|
1776
|
-
return scrollHeight;
|
|
1777
|
-
}, [ensureMeasurements]);
|
|
1778
|
-
const updateLayout = (0, import_react18.useCallback)((nextLayout) => {
|
|
1779
|
-
setLayout((prev) => {
|
|
1780
|
-
if (prev === nextLayout) {
|
|
1781
|
-
return prev;
|
|
1782
|
-
}
|
|
1783
|
-
ignoreResizeRef.current = true;
|
|
1784
|
-
return nextLayout;
|
|
1785
|
-
});
|
|
1786
|
-
}, []);
|
|
1787
|
-
const evaluateLayout = (0, import_react18.useCallback)(() => {
|
|
1788
|
-
if (mode !== "input") {
|
|
1789
|
-
updateLayout("compact");
|
|
1790
|
-
return;
|
|
1791
|
-
}
|
|
1792
|
-
if (typeof window !== "undefined" && typeof window.matchMedia === "function") {
|
|
1793
|
-
const isMobileViewport = window.matchMedia("(max-width: 767px)").matches;
|
|
1794
|
-
if (isMobileViewport) {
|
|
1795
|
-
ensureMeasurements();
|
|
1796
|
-
adjustTextareaHeight();
|
|
1797
|
-
updateLayout("expanded");
|
|
1798
|
-
return;
|
|
1799
|
-
}
|
|
1800
|
-
}
|
|
1801
|
-
const textarea = inputRef.current;
|
|
1802
|
-
const grid = gridRef.current;
|
|
1803
|
-
const addContainer = addButtonContainerRef.current;
|
|
1804
|
-
const actionsContainer = actionsContainerRef.current;
|
|
1805
|
-
if (!textarea || !grid || !addContainer || !actionsContainer) {
|
|
1806
|
-
return;
|
|
1807
|
-
}
|
|
1808
|
-
if (measurementsRef.current.singleLineHeight === 0) {
|
|
1809
|
-
ensureMeasurements();
|
|
1810
|
-
}
|
|
1811
|
-
const scrollHeight = adjustTextareaHeight();
|
|
1812
|
-
const baseline = measurementsRef.current.singleLineHeight;
|
|
1813
|
-
const hasExplicitBreak = resolvedValue.includes("\n");
|
|
1814
|
-
const renderedMultiline = baseline > 0 ? scrollHeight > baseline + 1 : false;
|
|
1815
|
-
let shouldExpand = hasExplicitBreak || renderedMultiline;
|
|
1816
|
-
if (!shouldExpand) {
|
|
1817
|
-
const gridStyles = window.getComputedStyle(grid);
|
|
1818
|
-
const paddingLeft = parseFloat(gridStyles.paddingLeft) || 0;
|
|
1819
|
-
const paddingRight = parseFloat(gridStyles.paddingRight) || 0;
|
|
1820
|
-
const columnGap = parseFloat(gridStyles.columnGap) || 0;
|
|
1821
|
-
const gridAvailableWidth = grid.clientWidth - paddingLeft - paddingRight;
|
|
1822
|
-
if (gridAvailableWidth > 0) {
|
|
1823
|
-
const addWidth = addContainer.getBoundingClientRect().width;
|
|
1824
|
-
const actionsWidth = actionsContainer.getBoundingClientRect().width;
|
|
1825
|
-
const compactWidth = Math.max(gridAvailableWidth - addWidth - actionsWidth - columnGap * 2, 0);
|
|
1826
|
-
const canvas = measurementCanvasRef.current ?? document.createElement("canvas");
|
|
1827
|
-
if (!measurementCanvasRef.current) {
|
|
1828
|
-
measurementCanvasRef.current = canvas;
|
|
1829
|
-
}
|
|
1830
|
-
const context = canvas.getContext("2d");
|
|
1831
|
-
if (context) {
|
|
1832
|
-
const textareaStyles = window.getComputedStyle(textarea);
|
|
1833
|
-
const font = textareaStyles.font || `${textareaStyles.fontStyle} ${textareaStyles.fontVariant} ${textareaStyles.fontWeight} ${textareaStyles.fontSize}/${textareaStyles.lineHeight} ${textareaStyles.fontFamily}`;
|
|
1834
|
-
context.font = font;
|
|
1835
|
-
const compactInnerWidth = Math.max(
|
|
1836
|
-
compactWidth - (measurementsRef.current.paddingLeft || 0) - (measurementsRef.current.paddingRight || 0),
|
|
1837
|
-
0
|
|
1838
|
-
);
|
|
1839
|
-
if (compactInnerWidth > 0) {
|
|
1840
|
-
const lines = resolvedValue.length > 0 ? resolvedValue.split("\n") : [""];
|
|
1841
|
-
let longestWidth = 0;
|
|
1842
|
-
for (const line of lines) {
|
|
1843
|
-
const metrics = context.measureText(line || " ");
|
|
1844
|
-
if (metrics.width > longestWidth) {
|
|
1845
|
-
longestWidth = metrics.width;
|
|
1846
|
-
}
|
|
1847
|
-
}
|
|
1848
|
-
if (longestWidth > compactInnerWidth) {
|
|
1849
|
-
shouldExpand = true;
|
|
1850
|
-
}
|
|
1851
|
-
}
|
|
1852
|
-
}
|
|
1853
|
-
}
|
|
1854
|
-
}
|
|
1855
|
-
const nextLayout = shouldExpand ? "expanded" : "compact";
|
|
1856
|
-
updateLayout(nextLayout);
|
|
1857
|
-
}, [adjustTextareaHeight, ensureMeasurements, mode, resolvedValue, updateLayout]);
|
|
1858
|
-
(0, import_react18.useLayoutEffect)(() => {
|
|
1859
|
-
evaluateLayout();
|
|
1860
|
-
}, [evaluateLayout]);
|
|
1861
|
-
(0, import_react18.useEffect)(() => {
|
|
1862
|
-
if (typeof ResizeObserver === "undefined") {
|
|
1863
|
-
return;
|
|
1864
|
-
}
|
|
1865
|
-
const textarea = inputRef.current;
|
|
1866
|
-
const grid = gridRef.current;
|
|
1867
|
-
const addContainer = addButtonContainerRef.current;
|
|
1868
|
-
const actionsContainer = actionsContainerRef.current;
|
|
1869
|
-
if (!textarea || !grid || !addContainer || !actionsContainer) {
|
|
1870
|
-
return;
|
|
1871
|
-
}
|
|
1872
|
-
const scheduleEvaluation = () => {
|
|
1873
|
-
if (ignoreResizeRef.current) {
|
|
1874
|
-
ignoreResizeRef.current = false;
|
|
1875
|
-
return;
|
|
1876
|
-
}
|
|
1877
|
-
if (typeof window === "undefined") {
|
|
1878
|
-
evaluateLayout();
|
|
1879
|
-
return;
|
|
1880
|
-
}
|
|
1881
|
-
if (resizeEvaluationRafRef.current !== null) {
|
|
1882
|
-
cancelAnimationFrame(resizeEvaluationRafRef.current);
|
|
1883
|
-
}
|
|
1884
|
-
resizeEvaluationRafRef.current = window.requestAnimationFrame(() => {
|
|
1885
|
-
resizeEvaluationRafRef.current = null;
|
|
1886
|
-
evaluateLayout();
|
|
1887
|
-
});
|
|
1888
|
-
};
|
|
1889
|
-
const observer = new ResizeObserver(() => {
|
|
1890
|
-
scheduleEvaluation();
|
|
1891
|
-
});
|
|
1892
|
-
observer.observe(grid);
|
|
1893
|
-
observer.observe(addContainer);
|
|
1894
|
-
observer.observe(actionsContainer);
|
|
1895
|
-
observer.observe(textarea);
|
|
1896
|
-
return () => {
|
|
1897
|
-
observer.disconnect();
|
|
1898
|
-
if (typeof window !== "undefined" && resizeEvaluationRafRef.current !== null) {
|
|
1899
|
-
cancelAnimationFrame(resizeEvaluationRafRef.current);
|
|
1900
|
-
resizeEvaluationRafRef.current = null;
|
|
1901
|
-
}
|
|
1902
|
-
};
|
|
1903
|
-
}, [evaluateLayout]);
|
|
1904
|
-
const slashMenuVisible = commandQuery !== null && commandItems.length > 0;
|
|
1905
|
-
(0, import_react18.useEffect)(() => {
|
|
1906
|
-
if (!slashMenuVisible || slashHighlightIndex < 0) {
|
|
1907
|
-
return;
|
|
1908
|
-
}
|
|
1909
|
-
const active = slashMenuRef.current?.querySelector(
|
|
1910
|
-
`[data-slash-index="${slashHighlightIndex}"]`
|
|
1911
|
-
);
|
|
1912
|
-
active?.scrollIntoView({ block: "nearest" });
|
|
1913
|
-
}, [slashMenuVisible, slashHighlightIndex]);
|
|
1914
|
-
const slashMenu = slashMenuVisible ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1915
|
-
"div",
|
|
1916
|
-
{
|
|
1917
|
-
"data-testid": "copilot-slash-menu",
|
|
1918
|
-
role: "listbox",
|
|
1919
|
-
"aria-label": "Slash commands",
|
|
1920
|
-
ref: slashMenuRef,
|
|
1921
|
-
className: "absolute bottom-full left-0 right-0 z-30 mb-2 max-h-64 overflow-y-auto rounded-lg border border-border bg-white shadow-lg dark:border-[#3a3a3a] dark:bg-[#1f1f1f]",
|
|
1922
|
-
style: { maxHeight: `${SLASH_MENU_MAX_VISIBLE_ITEMS * SLASH_MENU_ITEM_HEIGHT_PX}px` },
|
|
1923
|
-
children: filteredCommands.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "px-3 py-2 text-sm text-muted-foreground", children: "No commands found" }) : filteredCommands.map((item, index) => {
|
|
1924
|
-
const isActive = index === slashHighlightIndex;
|
|
1925
|
-
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1926
|
-
"button",
|
|
1927
|
-
{
|
|
1928
|
-
type: "button",
|
|
1929
|
-
role: "option",
|
|
1930
|
-
"aria-selected": isActive,
|
|
1931
|
-
"data-active": isActive ? "true" : void 0,
|
|
1932
|
-
"data-slash-index": index,
|
|
1933
|
-
className: (0, import_tailwind_merge6.twMerge)(
|
|
1934
|
-
"w-full px-3 py-2 text-left text-sm transition-colors",
|
|
1935
|
-
"hover:bg-muted dark:hover:bg-[#2f2f2f]",
|
|
1936
|
-
isActive ? "bg-muted dark:bg-[#2f2f2f]" : "bg-transparent"
|
|
1937
|
-
),
|
|
1938
|
-
onMouseEnter: () => setSlashHighlightIndex(index),
|
|
1939
|
-
onMouseDown: (event) => {
|
|
1940
|
-
event.preventDefault();
|
|
1941
|
-
runCommand(item);
|
|
1942
|
-
},
|
|
1943
|
-
children: item.label
|
|
1944
|
-
},
|
|
1945
|
-
`${item.label}-${index}`
|
|
1946
|
-
);
|
|
1947
|
-
})
|
|
1948
|
-
}
|
|
1949
|
-
) : null;
|
|
1950
|
-
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1951
|
-
"div",
|
|
1952
|
-
{
|
|
1953
|
-
className: (0, import_tailwind_merge6.twMerge)(
|
|
1954
|
-
// Layout
|
|
1955
|
-
"flex w-full flex-col items-center justify-center",
|
|
1956
|
-
// Interaction
|
|
1957
|
-
"cursor-text",
|
|
1958
|
-
// Overflow and clipping
|
|
1959
|
-
"overflow-visible bg-clip-padding contain-inline-size",
|
|
1960
|
-
// Background
|
|
1961
|
-
"bg-white dark:bg-[#303030]",
|
|
1962
|
-
// Visual effects
|
|
1963
|
-
"shadow-[0_4px_4px_0_#0000000a,0_0_1px_0_#0000009e] rounded-[28px]",
|
|
1964
|
-
className
|
|
1965
|
-
),
|
|
1966
|
-
onClick: handleContainerClick,
|
|
1967
|
-
...props,
|
|
1968
|
-
"data-layout": isExpanded ? "expanded" : "compact",
|
|
1969
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
1970
|
-
"div",
|
|
1971
|
-
{
|
|
1972
|
-
ref: gridRef,
|
|
1973
|
-
className: (0, import_tailwind_merge6.twMerge)(
|
|
1974
|
-
"grid w-full gap-x-3 gap-y-3 px-3 py-2",
|
|
1975
|
-
isExpanded ? "grid-cols-[auto_minmax(0,1fr)_auto] grid-rows-[auto_auto]" : "grid-cols-[auto_minmax(0,1fr)_auto] items-center"
|
|
1976
|
-
),
|
|
1977
|
-
"data-layout": isExpanded ? "expanded" : "compact",
|
|
1978
|
-
children: [
|
|
1979
|
-
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1980
|
-
"div",
|
|
1981
|
-
{
|
|
1982
|
-
ref: addButtonContainerRef,
|
|
1983
|
-
className: (0, import_tailwind_merge6.twMerge)(
|
|
1984
|
-
"flex items-center",
|
|
1985
|
-
isExpanded ? "row-start-2" : "row-start-1",
|
|
1986
|
-
"col-start-1"
|
|
1987
|
-
),
|
|
1988
|
-
children: BoundAddMenuButton
|
|
1989
|
-
}
|
|
1990
|
-
),
|
|
1991
|
-
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1992
|
-
"div",
|
|
1993
|
-
{
|
|
1994
|
-
className: (0, import_tailwind_merge6.twMerge)(
|
|
1995
|
-
"relative flex min-w-0 flex-col",
|
|
1996
|
-
isExpanded ? "col-span-3 row-start-1" : "col-start-2 row-start-1"
|
|
1997
|
-
),
|
|
1998
|
-
children: mode === "transcribe" ? BoundAudioRecorder : /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
|
|
1999
|
-
BoundTextArea,
|
|
2000
|
-
slashMenu
|
|
2001
|
-
] })
|
|
2002
|
-
}
|
|
2003
|
-
),
|
|
2004
|
-
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2005
|
-
"div",
|
|
2006
|
-
{
|
|
2007
|
-
ref: actionsContainerRef,
|
|
2008
|
-
className: (0, import_tailwind_merge6.twMerge)(
|
|
2009
|
-
"flex items-center justify-end gap-2",
|
|
2010
|
-
isExpanded ? "col-start-3 row-start-2" : "col-start-3 row-start-1"
|
|
2011
|
-
),
|
|
2012
|
-
children: mode === "transcribe" ? /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
|
|
2013
|
-
onCancelTranscribe && BoundCancelTranscribeButton,
|
|
2014
|
-
onFinishTranscribe && BoundFinishTranscribeButton
|
|
2015
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
|
|
2016
|
-
onStartTranscribe && BoundStartTranscribeButton,
|
|
2017
|
-
BoundSendButton
|
|
2018
|
-
] })
|
|
2019
|
-
}
|
|
2020
|
-
)
|
|
2021
|
-
]
|
|
2022
|
-
}
|
|
2023
|
-
)
|
|
2024
|
-
}
|
|
2025
|
-
);
|
|
2026
|
-
}
|
|
2027
|
-
((CopilotChatInput2) => {
|
|
2028
|
-
CopilotChatInput2.SendButton = ({ className, children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "mr-[10px]", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2029
|
-
Button,
|
|
2030
|
-
{
|
|
2031
|
-
type: "button",
|
|
2032
|
-
variant: "chatInputToolbarPrimary",
|
|
2033
|
-
size: "chatInputToolbarIcon",
|
|
2034
|
-
className,
|
|
2035
|
-
...props,
|
|
2036
|
-
children: children ?? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react4.ArrowUp, { className: "size-[18px]" })
|
|
2037
|
-
}
|
|
2038
|
-
) });
|
|
2039
|
-
CopilotChatInput2.ToolbarButton = ({ icon, labelKey, defaultClassName, className, ...props }) => {
|
|
2040
|
-
const config = useCopilotChatConfiguration();
|
|
2041
|
-
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
2042
|
-
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(Tooltip, { children: [
|
|
2043
|
-
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2044
|
-
Button,
|
|
2045
|
-
{
|
|
2046
|
-
type: "button",
|
|
2047
|
-
variant: "chatInputToolbarSecondary",
|
|
2048
|
-
size: "chatInputToolbarIcon",
|
|
2049
|
-
className: (0, import_tailwind_merge6.twMerge)(defaultClassName, className),
|
|
2050
|
-
...props,
|
|
2051
|
-
children: icon
|
|
2052
|
-
}
|
|
2053
|
-
) }),
|
|
2054
|
-
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(TooltipContent, { side: "bottom", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { children: labels[labelKey] }) })
|
|
2055
|
-
] });
|
|
2056
|
-
};
|
|
2057
|
-
CopilotChatInput2.StartTranscribeButton = (props) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2058
|
-
CopilotChatInput2.ToolbarButton,
|
|
2059
|
-
{
|
|
2060
|
-
icon: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react4.Mic, { className: "size-[18px]" }),
|
|
2061
|
-
labelKey: "chatInputToolbarStartTranscribeButtonLabel",
|
|
2062
|
-
defaultClassName: "mr-2",
|
|
2063
|
-
...props
|
|
2064
|
-
}
|
|
2065
|
-
);
|
|
2066
|
-
CopilotChatInput2.CancelTranscribeButton = (props) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2067
|
-
CopilotChatInput2.ToolbarButton,
|
|
2068
|
-
{
|
|
2069
|
-
icon: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react4.X, { className: "size-[18px]" }),
|
|
2070
|
-
labelKey: "chatInputToolbarCancelTranscribeButtonLabel",
|
|
2071
|
-
defaultClassName: "mr-2",
|
|
2072
|
-
...props
|
|
2073
|
-
}
|
|
2074
|
-
);
|
|
2075
|
-
CopilotChatInput2.FinishTranscribeButton = (props) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2076
|
-
CopilotChatInput2.ToolbarButton,
|
|
2077
|
-
{
|
|
2078
|
-
icon: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react4.Check, { className: "size-[18px]" }),
|
|
2079
|
-
labelKey: "chatInputToolbarFinishTranscribeButtonLabel",
|
|
2080
|
-
defaultClassName: "mr-[10px]",
|
|
2081
|
-
...props
|
|
2082
|
-
}
|
|
2083
|
-
);
|
|
2084
|
-
CopilotChatInput2.AddMenuButton = ({ className, toolsMenu, onAddFile, disabled, ...props }) => {
|
|
2085
|
-
const config = useCopilotChatConfiguration();
|
|
2086
|
-
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
2087
|
-
const menuItems = (0, import_react18.useMemo)(() => {
|
|
2088
|
-
const items = [];
|
|
2089
|
-
if (onAddFile) {
|
|
2090
|
-
items.push({
|
|
2091
|
-
label: labels.chatInputToolbarAddButtonLabel,
|
|
2092
|
-
action: onAddFile
|
|
2093
|
-
});
|
|
2094
|
-
}
|
|
2095
|
-
if (toolsMenu && toolsMenu.length > 0) {
|
|
2096
|
-
if (items.length > 0) {
|
|
2097
|
-
items.push("-");
|
|
2098
|
-
}
|
|
2099
|
-
for (const item of toolsMenu) {
|
|
2100
|
-
if (item === "-") {
|
|
2101
|
-
if (items.length === 0 || items[items.length - 1] === "-") {
|
|
2102
|
-
continue;
|
|
2103
|
-
}
|
|
2104
|
-
items.push(item);
|
|
2105
|
-
} else {
|
|
2106
|
-
items.push(item);
|
|
2107
|
-
}
|
|
2108
|
-
}
|
|
2109
|
-
while (items.length > 0 && items[items.length - 1] === "-") {
|
|
2110
|
-
items.pop();
|
|
2111
|
-
}
|
|
2112
|
-
}
|
|
2113
|
-
return items;
|
|
2114
|
-
}, [onAddFile, toolsMenu, labels.chatInputToolbarAddButtonLabel]);
|
|
2115
|
-
const renderMenuItems = (0, import_react18.useCallback)(
|
|
2116
|
-
(items) => items.map((item, index) => {
|
|
2117
|
-
if (item === "-") {
|
|
2118
|
-
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(DropdownMenuSeparator, {}, `separator-${index}`);
|
|
2119
|
-
}
|
|
2120
|
-
if (item.items && item.items.length > 0) {
|
|
2121
|
-
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(DropdownMenuSub, { children: [
|
|
2122
|
-
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(DropdownMenuSubTrigger, { children: item.label }),
|
|
2123
|
-
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(DropdownMenuSubContent, { children: renderMenuItems(item.items) })
|
|
2124
|
-
] }, `group-${index}`);
|
|
2125
|
-
}
|
|
2126
|
-
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(DropdownMenuItem, { onClick: item.action, children: item.label }, `item-${index}`);
|
|
2127
|
-
}),
|
|
2128
|
-
[]
|
|
2129
|
-
);
|
|
2130
|
-
const hasMenuItems = menuItems.length > 0;
|
|
2131
|
-
const isDisabled = disabled || !hasMenuItems;
|
|
2132
|
-
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(DropdownMenu, { children: [
|
|
2133
|
-
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(Tooltip, { children: [
|
|
2134
|
-
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2135
|
-
Button,
|
|
2136
|
-
{
|
|
2137
|
-
type: "button",
|
|
2138
|
-
variant: "chatInputToolbarSecondary",
|
|
2139
|
-
size: "chatInputToolbarIcon",
|
|
2140
|
-
className: (0, import_tailwind_merge6.twMerge)("ml-1", className),
|
|
2141
|
-
disabled: isDisabled,
|
|
2142
|
-
...props,
|
|
2143
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react4.Plus, { className: "size-[20px]" })
|
|
2144
|
-
}
|
|
2145
|
-
) }) }),
|
|
2146
|
-
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(TooltipContent, { side: "bottom", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("p", { className: "flex items-center gap-1 text-xs font-medium", children: [
|
|
2147
|
-
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { children: "Add files and more" }),
|
|
2148
|
-
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("code", { className: "rounded bg-[#4a4a4a] px-1 py-[1px] font-mono text-[11px] text-white dark:bg-[#e0e0e0] dark:text-black", children: "/" })
|
|
2149
|
-
] }) })
|
|
2150
|
-
] }),
|
|
2151
|
-
hasMenuItems && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(DropdownMenuContent, { side: "top", align: "start", children: renderMenuItems(menuItems) })
|
|
2152
|
-
] });
|
|
2153
|
-
};
|
|
2154
|
-
CopilotChatInput2.TextArea = (0, import_react18.forwardRef)(function TextArea2({ style, className, autoFocus, ...props }, ref) {
|
|
2155
|
-
const internalTextareaRef = (0, import_react18.useRef)(null);
|
|
2156
|
-
const config = useCopilotChatConfiguration();
|
|
2157
|
-
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
2158
|
-
(0, import_react18.useImperativeHandle)(ref, () => internalTextareaRef.current);
|
|
2159
|
-
(0, import_react18.useEffect)(() => {
|
|
2160
|
-
const textarea = internalTextareaRef.current;
|
|
2161
|
-
if (!textarea) return;
|
|
2162
|
-
const handleFocus = () => {
|
|
2163
|
-
setTimeout(() => {
|
|
2164
|
-
textarea.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
2165
|
-
}, 300);
|
|
2166
|
-
};
|
|
2167
|
-
textarea.addEventListener("focus", handleFocus);
|
|
2168
|
-
return () => textarea.removeEventListener("focus", handleFocus);
|
|
2169
|
-
}, []);
|
|
2170
|
-
(0, import_react18.useEffect)(() => {
|
|
2171
|
-
if (autoFocus) {
|
|
2172
|
-
internalTextareaRef.current?.focus();
|
|
2173
|
-
}
|
|
2174
|
-
}, [autoFocus]);
|
|
2175
|
-
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2176
|
-
"textarea",
|
|
2177
|
-
{
|
|
2178
|
-
ref: internalTextareaRef,
|
|
2179
|
-
...props,
|
|
2180
|
-
style: {
|
|
2181
|
-
overflow: "auto",
|
|
2182
|
-
resize: "none",
|
|
2183
|
-
...style
|
|
2184
|
-
},
|
|
2185
|
-
placeholder: labels.chatInputPlaceholder,
|
|
2186
|
-
className: (0, import_tailwind_merge6.twMerge)(
|
|
2187
|
-
"bg-transparent outline-none antialiased font-regular leading-relaxed text-[16px] placeholder:text-[#00000077] dark:placeholder:text-[#fffc]",
|
|
2188
|
-
className
|
|
2189
|
-
),
|
|
2190
|
-
rows: 1
|
|
2191
|
-
}
|
|
2192
|
-
);
|
|
2193
|
-
});
|
|
2194
|
-
CopilotChatInput2.AudioRecorder = CopilotChatAudioRecorder;
|
|
2195
|
-
})(CopilotChatInput || (CopilotChatInput = {}));
|
|
2196
|
-
CopilotChatInput.TextArea.displayName = "CopilotChatInput.TextArea";
|
|
2197
|
-
CopilotChatInput.SendButton.displayName = "CopilotChatInput.SendButton";
|
|
2198
|
-
CopilotChatInput.ToolbarButton.displayName = "CopilotChatInput.ToolbarButton";
|
|
2199
|
-
CopilotChatInput.StartTranscribeButton.displayName = "CopilotChatInput.StartTranscribeButton";
|
|
2200
|
-
CopilotChatInput.CancelTranscribeButton.displayName = "CopilotChatInput.CancelTranscribeButton";
|
|
2201
|
-
CopilotChatInput.FinishTranscribeButton.displayName = "CopilotChatInput.FinishTranscribeButton";
|
|
2202
|
-
CopilotChatInput.AddMenuButton.displayName = "CopilotChatInput.AddMenuButton";
|
|
2203
|
-
var CopilotChatInput_default = CopilotChatInput;
|
|
2204
|
-
|
|
2205
|
-
// src/components/chat/CopilotChatSuggestionView.tsx
|
|
2206
|
-
var import_react20 = __toESM(require("react"));
|
|
2207
|
-
|
|
2208
|
-
// src/components/chat/CopilotChatSuggestionPill.tsx
|
|
2209
|
-
var import_react19 = __toESM(require("react"));
|
|
2210
|
-
var import_lucide_react5 = require("lucide-react");
|
|
2211
|
-
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
2212
|
-
var baseClasses = "group inline-flex h-7 sm:h-8 items-center gap-1 sm:gap-1.5 rounded-full border border-border/60 bg-background px-2.5 sm:px-3 text-[11px] sm:text-xs leading-none text-foreground transition-colors cursor-pointer hover:bg-accent/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:text-muted-foreground disabled:hover:bg-background disabled:hover:text-muted-foreground pointer-events-auto";
|
|
2213
|
-
var labelClasses = "whitespace-nowrap font-medium leading-none";
|
|
2214
|
-
var CopilotChatSuggestionPill = import_react19.default.forwardRef(function CopilotChatSuggestionPill2({ className, children, icon, isLoading, type, ...props }, ref) {
|
|
2215
|
-
const showIcon = !isLoading && icon;
|
|
2216
|
-
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
2217
|
-
"button",
|
|
2218
|
-
{
|
|
2219
|
-
ref,
|
|
2220
|
-
"data-slot": "suggestion-pill",
|
|
2221
|
-
className: cn(baseClasses, className),
|
|
2222
|
-
type: type ?? "button",
|
|
2223
|
-
"aria-busy": isLoading || void 0,
|
|
2224
|
-
disabled: isLoading || props.disabled,
|
|
2225
|
-
...props,
|
|
2226
|
-
children: [
|
|
2227
|
-
isLoading ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "flex h-3.5 sm:h-4 w-3.5 sm:w-4 items-center justify-center text-muted-foreground", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_lucide_react5.Loader2, { className: "h-3.5 sm:h-4 w-3.5 sm:w-4 animate-spin", "aria-hidden": "true" }) }) : showIcon && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "flex h-3.5 sm:h-4 w-3.5 sm:w-4 items-center justify-center text-muted-foreground", children: icon }),
|
|
2228
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: labelClasses, children })
|
|
2229
|
-
]
|
|
2230
|
-
}
|
|
2231
|
-
);
|
|
2232
|
-
});
|
|
2233
|
-
CopilotChatSuggestionPill.displayName = "CopilotChatSuggestionPill";
|
|
2234
|
-
var CopilotChatSuggestionPill_default = CopilotChatSuggestionPill;
|
|
2235
|
-
|
|
2236
|
-
// src/components/chat/CopilotChatSuggestionView.tsx
|
|
2237
|
-
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
2238
|
-
var DefaultContainer = import_react20.default.forwardRef(function DefaultContainer2({ className, ...props }, ref) {
|
|
2239
|
-
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2240
|
-
"div",
|
|
2241
|
-
{
|
|
2242
|
-
ref,
|
|
2243
|
-
className: cn(
|
|
2244
|
-
"flex flex-wrap items-center gap-1.5 sm:gap-2 pl-0 pr-4 sm:px-0 pointer-events-none",
|
|
2245
|
-
className
|
|
2246
|
-
),
|
|
2247
|
-
...props
|
|
2248
|
-
}
|
|
2249
|
-
);
|
|
2250
|
-
});
|
|
2251
|
-
var CopilotChatSuggestionView = import_react20.default.forwardRef(function CopilotChatSuggestionView2({
|
|
2252
|
-
suggestions,
|
|
2253
|
-
onSelectSuggestion,
|
|
2254
|
-
loadingIndexes,
|
|
2255
|
-
container,
|
|
2256
|
-
suggestion: suggestionSlot,
|
|
2257
|
-
className,
|
|
2258
|
-
children,
|
|
2259
|
-
...restProps
|
|
2260
|
-
}, ref) {
|
|
2261
|
-
const loadingSet = import_react20.default.useMemo(() => {
|
|
2262
|
-
if (!loadingIndexes || loadingIndexes.length === 0) {
|
|
2263
|
-
return /* @__PURE__ */ new Set();
|
|
2264
|
-
}
|
|
2265
|
-
return new Set(loadingIndexes);
|
|
2266
|
-
}, [loadingIndexes]);
|
|
2267
|
-
const ContainerElement = renderSlot(container, DefaultContainer, {
|
|
2268
|
-
ref,
|
|
2269
|
-
className,
|
|
2270
|
-
...restProps
|
|
2271
|
-
});
|
|
2272
|
-
const suggestionElements = suggestions.map((suggestion, index) => {
|
|
2273
|
-
const isLoading = loadingSet.has(index) || suggestion.isLoading === true;
|
|
2274
|
-
const pill = renderSlot(suggestionSlot, CopilotChatSuggestionPill_default, {
|
|
2275
|
-
children: suggestion.title,
|
|
2276
|
-
isLoading,
|
|
2277
|
-
type: "button",
|
|
2278
|
-
onClick: () => onSelectSuggestion?.(suggestion, index)
|
|
2279
|
-
});
|
|
2280
|
-
return import_react20.default.cloneElement(pill, {
|
|
2281
|
-
key: `${suggestion.title}-${index}`
|
|
2282
|
-
});
|
|
2283
|
-
});
|
|
2284
|
-
const boundContainer = import_react20.default.cloneElement(
|
|
2285
|
-
ContainerElement,
|
|
2286
|
-
void 0,
|
|
2287
|
-
suggestionElements
|
|
2288
|
-
);
|
|
2289
|
-
if (typeof children === "function") {
|
|
2290
|
-
const sampleSuggestion = renderSlot(suggestionSlot, CopilotChatSuggestionPill_default, {
|
|
2291
|
-
children: suggestions[0]?.title ?? "",
|
|
2292
|
-
isLoading: suggestions.length > 0 ? loadingSet.has(0) || suggestions[0]?.isLoading === true : false,
|
|
2293
|
-
type: "button"
|
|
2294
|
-
});
|
|
2295
|
-
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_jsx_runtime17.Fragment, { children: children({
|
|
2296
|
-
container: boundContainer,
|
|
2297
|
-
suggestion: sampleSuggestion,
|
|
2298
|
-
suggestions,
|
|
2299
|
-
onSelectSuggestion,
|
|
2300
|
-
loadingIndexes,
|
|
2301
|
-
className,
|
|
2302
|
-
...restProps
|
|
2303
|
-
}) });
|
|
2304
|
-
}
|
|
2305
|
-
if (children) {
|
|
2306
|
-
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
|
|
2307
|
-
boundContainer,
|
|
2308
|
-
children
|
|
2309
|
-
] });
|
|
2310
|
-
}
|
|
2311
|
-
return boundContainer;
|
|
2312
|
-
});
|
|
2313
|
-
CopilotChatSuggestionView.displayName = "CopilotChatSuggestionView";
|
|
2314
|
-
var CopilotChatSuggestionView_default = CopilotChatSuggestionView;
|
|
2315
|
-
|
|
2316
|
-
// src/components/chat/CopilotChatView.tsx
|
|
2317
|
-
var import_tailwind_merge7 = require("tailwind-merge");
|
|
2318
|
-
var import_use_stick_to_bottom = require("use-stick-to-bottom");
|
|
2319
|
-
var import_lucide_react6 = require("lucide-react");
|
|
2320
|
-
|
|
2321
|
-
// src/hooks/use-keyboard-height.tsx
|
|
2322
|
-
var import_react21 = require("react");
|
|
2323
|
-
function useKeyboardHeight() {
|
|
2324
|
-
const [keyboardState, setKeyboardState] = (0, import_react21.useState)({
|
|
2325
|
-
isKeyboardOpen: false,
|
|
2326
|
-
keyboardHeight: 0,
|
|
2327
|
-
availableHeight: typeof window !== "undefined" ? window.innerHeight : 0,
|
|
2328
|
-
viewportHeight: typeof window !== "undefined" ? window.innerHeight : 0
|
|
2329
|
-
});
|
|
2330
|
-
(0, import_react21.useEffect)(() => {
|
|
2331
|
-
if (typeof window === "undefined") {
|
|
2332
|
-
return;
|
|
2333
|
-
}
|
|
2334
|
-
const visualViewport = window.visualViewport;
|
|
2335
|
-
if (!visualViewport) {
|
|
2336
|
-
return;
|
|
2337
|
-
}
|
|
2338
|
-
const updateKeyboardState = () => {
|
|
2339
|
-
const layoutHeight = window.innerHeight;
|
|
2340
|
-
const visualHeight = visualViewport.height;
|
|
2341
|
-
const keyboardHeight = Math.max(0, layoutHeight - visualHeight);
|
|
2342
|
-
const isKeyboardOpen = keyboardHeight > 150;
|
|
2343
|
-
setKeyboardState({
|
|
2344
|
-
isKeyboardOpen,
|
|
2345
|
-
keyboardHeight,
|
|
2346
|
-
availableHeight: visualHeight,
|
|
2347
|
-
viewportHeight: layoutHeight
|
|
2348
|
-
});
|
|
2349
|
-
};
|
|
2350
|
-
updateKeyboardState();
|
|
2351
|
-
visualViewport.addEventListener("resize", updateKeyboardState);
|
|
2352
|
-
visualViewport.addEventListener("scroll", updateKeyboardState);
|
|
2353
|
-
return () => {
|
|
2354
|
-
visualViewport.removeEventListener("resize", updateKeyboardState);
|
|
2355
|
-
visualViewport.removeEventListener("scroll", updateKeyboardState);
|
|
2356
|
-
};
|
|
2357
|
-
}, []);
|
|
2358
|
-
return keyboardState;
|
|
2359
|
-
}
|
|
2360
|
-
|
|
2361
|
-
// src/components/chat/CopilotChatView.tsx
|
|
2362
|
-
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
2363
|
-
function CopilotChatView({
|
|
2364
|
-
messageView,
|
|
2365
|
-
input,
|
|
2366
|
-
scrollView,
|
|
2367
|
-
scrollToBottomButton,
|
|
2368
|
-
feather,
|
|
2369
|
-
inputContainer,
|
|
2370
|
-
disclaimer,
|
|
2371
|
-
suggestionView,
|
|
2372
|
-
messages = [],
|
|
2373
|
-
autoScroll = true,
|
|
2374
|
-
inputProps,
|
|
2375
|
-
isRunning = false,
|
|
2376
|
-
suggestions,
|
|
2377
|
-
suggestionLoadingIndexes,
|
|
2378
|
-
onSelectSuggestion,
|
|
2379
|
-
children,
|
|
2380
|
-
className,
|
|
2381
|
-
...props
|
|
2382
|
-
}) {
|
|
2383
|
-
const inputContainerRef = (0, import_react22.useRef)(null);
|
|
2384
|
-
const [inputContainerHeight, setInputContainerHeight] = (0, import_react22.useState)(0);
|
|
2385
|
-
const [isResizing, setIsResizing] = (0, import_react22.useState)(false);
|
|
2386
|
-
const resizeTimeoutRef = (0, import_react22.useRef)(null);
|
|
2387
|
-
const { isKeyboardOpen, keyboardHeight, availableHeight } = useKeyboardHeight();
|
|
2388
|
-
(0, import_react22.useEffect)(() => {
|
|
2389
|
-
const element = inputContainerRef.current;
|
|
2390
|
-
if (!element) return;
|
|
2391
|
-
const resizeObserver = new ResizeObserver((entries) => {
|
|
2392
|
-
for (const entry of entries) {
|
|
2393
|
-
const newHeight = entry.contentRect.height;
|
|
2394
|
-
setInputContainerHeight((prevHeight) => {
|
|
2395
|
-
if (newHeight !== prevHeight) {
|
|
2396
|
-
setIsResizing(true);
|
|
2397
|
-
if (resizeTimeoutRef.current) {
|
|
2398
|
-
clearTimeout(resizeTimeoutRef.current);
|
|
2399
|
-
}
|
|
2400
|
-
resizeTimeoutRef.current = setTimeout(() => {
|
|
2401
|
-
setIsResizing(false);
|
|
2402
|
-
}, 250);
|
|
2403
|
-
return newHeight;
|
|
2404
|
-
}
|
|
2405
|
-
return prevHeight;
|
|
2406
|
-
});
|
|
2407
|
-
}
|
|
2408
|
-
});
|
|
2409
|
-
resizeObserver.observe(element);
|
|
2410
|
-
setInputContainerHeight(element.offsetHeight);
|
|
2411
|
-
return () => {
|
|
2412
|
-
resizeObserver.disconnect();
|
|
2413
|
-
if (resizeTimeoutRef.current) {
|
|
2414
|
-
clearTimeout(resizeTimeoutRef.current);
|
|
2415
|
-
}
|
|
2416
|
-
};
|
|
2417
|
-
}, []);
|
|
2418
|
-
const BoundMessageView = renderSlot(messageView, CopilotChatMessageView_default, {
|
|
2419
|
-
messages,
|
|
2420
|
-
isRunning
|
|
2421
|
-
});
|
|
2422
|
-
const BoundInput = renderSlot(input, CopilotChatInput_default, inputProps ?? {});
|
|
2423
|
-
const hasSuggestions = Array.isArray(suggestions) && suggestions.length > 0;
|
|
2424
|
-
const BoundSuggestionView = hasSuggestions ? renderSlot(
|
|
2425
|
-
suggestionView,
|
|
2426
|
-
CopilotChatSuggestionView_default,
|
|
2427
|
-
{
|
|
2428
|
-
suggestions,
|
|
2429
|
-
loadingIndexes: suggestionLoadingIndexes,
|
|
2430
|
-
onSelectSuggestion,
|
|
2431
|
-
className: "mb-3 lg:ml-4 lg:mr-4 ml-0 mr-0"
|
|
2432
|
-
}
|
|
2433
|
-
) : null;
|
|
2434
|
-
const BoundFeather = renderSlot(feather, CopilotChatView.Feather, {});
|
|
2435
|
-
const BoundScrollView = renderSlot(scrollView, CopilotChatView.ScrollView, {
|
|
2436
|
-
autoScroll,
|
|
2437
|
-
scrollToBottomButton,
|
|
2438
|
-
inputContainerHeight,
|
|
2439
|
-
isResizing,
|
|
2440
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { style: { paddingBottom: `${inputContainerHeight + (hasSuggestions ? 4 : 32)}px` }, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "max-w-3xl mx-auto", children: [
|
|
2441
|
-
BoundMessageView,
|
|
2442
|
-
hasSuggestions ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "pl-0 pr-4 sm:px-0 mt-4", children: BoundSuggestionView }) : null
|
|
2443
|
-
] }) })
|
|
2444
|
-
});
|
|
2445
|
-
const BoundScrollToBottomButton = renderSlot(scrollToBottomButton, CopilotChatView.ScrollToBottomButton, {});
|
|
2446
|
-
const BoundDisclaimer = renderSlot(disclaimer, CopilotChatView.Disclaimer, {});
|
|
2447
|
-
const BoundInputContainer = renderSlot(inputContainer, CopilotChatView.InputContainer, {
|
|
2448
|
-
ref: inputContainerRef,
|
|
2449
|
-
keyboardHeight: isKeyboardOpen ? keyboardHeight : 0,
|
|
2450
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
|
|
2451
|
-
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "max-w-3xl mx-auto py-0 px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6 pointer-events-auto", children: BoundInput }),
|
|
2452
|
-
BoundDisclaimer
|
|
2453
|
-
] })
|
|
2454
|
-
});
|
|
2455
|
-
if (children) {
|
|
2456
|
-
return children({
|
|
2457
|
-
messageView: BoundMessageView,
|
|
2458
|
-
input: BoundInput,
|
|
2459
|
-
scrollView: BoundScrollView,
|
|
2460
|
-
scrollToBottomButton: BoundScrollToBottomButton,
|
|
2461
|
-
feather: BoundFeather,
|
|
2462
|
-
inputContainer: BoundInputContainer,
|
|
2463
|
-
disclaimer: BoundDisclaimer,
|
|
2464
|
-
suggestionView: BoundSuggestionView ?? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_jsx_runtime18.Fragment, {})
|
|
2465
|
-
});
|
|
2466
|
-
}
|
|
2467
|
-
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: (0, import_tailwind_merge7.twMerge)("relative h-full", className), ...props, children: [
|
|
2468
|
-
BoundScrollView,
|
|
2469
|
-
BoundFeather,
|
|
2470
|
-
BoundInputContainer
|
|
2471
|
-
] });
|
|
2472
|
-
}
|
|
2473
|
-
((CopilotChatView2) => {
|
|
2474
|
-
const ScrollContent = ({ children, scrollToBottomButton, inputContainerHeight, isResizing }) => {
|
|
2475
|
-
const { isAtBottom, scrollToBottom } = (0, import_use_stick_to_bottom.useStickToBottomContext)();
|
|
2476
|
-
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
|
|
2477
|
-
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_use_stick_to_bottom.StickToBottom.Content, { className: "overflow-y-scroll overflow-x-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6", children }) }),
|
|
2478
|
-
!isAtBottom && !isResizing && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2479
|
-
"div",
|
|
2480
|
-
{
|
|
2481
|
-
className: "absolute inset-x-0 flex justify-center z-10 pointer-events-none",
|
|
2482
|
-
style: {
|
|
2483
|
-
bottom: `${inputContainerHeight + 16}px`
|
|
2484
|
-
},
|
|
2485
|
-
children: renderSlot(scrollToBottomButton, CopilotChatView2.ScrollToBottomButton, {
|
|
2486
|
-
onClick: () => scrollToBottom()
|
|
2487
|
-
})
|
|
2488
|
-
}
|
|
2489
|
-
)
|
|
2490
|
-
] });
|
|
2491
|
-
};
|
|
2492
|
-
CopilotChatView2.ScrollView = ({
|
|
2493
|
-
children,
|
|
2494
|
-
autoScroll = true,
|
|
2495
|
-
scrollToBottomButton,
|
|
2496
|
-
inputContainerHeight = 0,
|
|
2497
|
-
isResizing = false,
|
|
2498
|
-
className,
|
|
2499
|
-
...props
|
|
2500
|
-
}) => {
|
|
2501
|
-
const [hasMounted, setHasMounted] = (0, import_react22.useState)(false);
|
|
2502
|
-
const { scrollRef, contentRef, scrollToBottom } = (0, import_use_stick_to_bottom.useStickToBottom)();
|
|
2503
|
-
const [showScrollButton, setShowScrollButton] = (0, import_react22.useState)(false);
|
|
2504
|
-
(0, import_react22.useEffect)(() => {
|
|
2505
|
-
setHasMounted(true);
|
|
2506
|
-
}, []);
|
|
2507
|
-
(0, import_react22.useEffect)(() => {
|
|
2508
|
-
if (autoScroll) return;
|
|
2509
|
-
const scrollElement = scrollRef.current;
|
|
2510
|
-
if (!scrollElement) return;
|
|
2511
|
-
const checkScroll = () => {
|
|
2512
|
-
const atBottom = scrollElement.scrollHeight - scrollElement.scrollTop - scrollElement.clientHeight < 10;
|
|
2513
|
-
setShowScrollButton(!atBottom);
|
|
2514
|
-
};
|
|
2515
|
-
checkScroll();
|
|
2516
|
-
scrollElement.addEventListener("scroll", checkScroll);
|
|
2517
|
-
const resizeObserver = new ResizeObserver(checkScroll);
|
|
2518
|
-
resizeObserver.observe(scrollElement);
|
|
2519
|
-
return () => {
|
|
2520
|
-
scrollElement.removeEventListener("scroll", checkScroll);
|
|
2521
|
-
resizeObserver.disconnect();
|
|
2522
|
-
};
|
|
2523
|
-
}, [scrollRef, autoScroll]);
|
|
2524
|
-
if (!hasMounted) {
|
|
2525
|
-
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "h-full max-h-full flex flex-col min-h-0 overflow-y-scroll overflow-x-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6", children }) });
|
|
2526
|
-
}
|
|
2527
|
-
if (!autoScroll) {
|
|
2528
|
-
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
2529
|
-
"div",
|
|
2530
|
-
{
|
|
2531
|
-
ref: scrollRef,
|
|
2532
|
-
className: cn(
|
|
2533
|
-
"h-full max-h-full flex flex-col min-h-0 overflow-y-scroll overflow-x-hidden relative",
|
|
2534
|
-
className
|
|
2535
|
-
),
|
|
2536
|
-
...props,
|
|
2537
|
-
children: [
|
|
2538
|
-
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { ref: contentRef, className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6", children }),
|
|
2539
|
-
showScrollButton && !isResizing && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2540
|
-
"div",
|
|
2541
|
-
{
|
|
2542
|
-
className: "absolute inset-x-0 flex justify-center z-10 pointer-events-none",
|
|
2543
|
-
style: {
|
|
2544
|
-
bottom: `${inputContainerHeight + 16}px`
|
|
2545
|
-
},
|
|
2546
|
-
children: renderSlot(scrollToBottomButton, CopilotChatView2.ScrollToBottomButton, {
|
|
2547
|
-
onClick: () => scrollToBottom()
|
|
2548
|
-
})
|
|
2549
|
-
}
|
|
2550
|
-
)
|
|
2551
|
-
]
|
|
2552
|
-
}
|
|
2553
|
-
);
|
|
2554
|
-
}
|
|
2555
|
-
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2556
|
-
import_use_stick_to_bottom.StickToBottom,
|
|
2557
|
-
{
|
|
2558
|
-
className: cn("h-full max-h-full flex flex-col min-h-0 relative", className),
|
|
2559
|
-
resize: "smooth",
|
|
2560
|
-
initial: "smooth",
|
|
2561
|
-
...props,
|
|
2562
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2563
|
-
ScrollContent,
|
|
2564
|
-
{
|
|
2565
|
-
scrollToBottomButton,
|
|
2566
|
-
inputContainerHeight,
|
|
2567
|
-
isResizing,
|
|
2568
|
-
children
|
|
2569
|
-
}
|
|
2570
|
-
)
|
|
2571
|
-
}
|
|
2572
|
-
);
|
|
2573
|
-
};
|
|
2574
|
-
CopilotChatView2.ScrollToBottomButton = ({
|
|
2575
|
-
className,
|
|
2576
|
-
...props
|
|
2577
|
-
}) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2578
|
-
Button,
|
|
2579
|
-
{
|
|
2580
|
-
variant: "outline",
|
|
2581
|
-
size: "sm",
|
|
2582
|
-
className: (0, import_tailwind_merge7.twMerge)(
|
|
2583
|
-
"rounded-full w-10 h-10 p-0 pointer-events-auto",
|
|
2584
|
-
"bg-white dark:bg-gray-900",
|
|
2585
|
-
"shadow-lg border border-gray-200 dark:border-gray-700",
|
|
2586
|
-
"hover:bg-gray-50 dark:hover:bg-gray-800",
|
|
2587
|
-
"flex items-center justify-center cursor-pointer",
|
|
2588
|
-
className
|
|
2589
|
-
),
|
|
2590
|
-
...props,
|
|
2591
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_lucide_react6.ChevronDown, { className: "w-4 h-4 text-gray-600 dark:text-white" })
|
|
2592
|
-
}
|
|
2593
|
-
);
|
|
2594
|
-
CopilotChatView2.Feather = ({ className, style, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2595
|
-
"div",
|
|
2596
|
-
{
|
|
2597
|
-
className: cn(
|
|
2598
|
-
"absolute bottom-0 left-0 right-4 h-24 pointer-events-none z-10 bg-gradient-to-t",
|
|
2599
|
-
"from-white via-white to-transparent",
|
|
2600
|
-
"dark:from-[rgb(33,33,33)] dark:via-[rgb(33,33,33)]",
|
|
2601
|
-
className
|
|
2602
|
-
),
|
|
2603
|
-
style,
|
|
2604
|
-
...props
|
|
2605
|
-
}
|
|
2606
|
-
);
|
|
2607
|
-
CopilotChatView2.InputContainer = import_react22.default.forwardRef(({ children, className, keyboardHeight = 0, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2608
|
-
"div",
|
|
2609
|
-
{
|
|
2610
|
-
ref,
|
|
2611
|
-
className: cn("absolute bottom-0 left-0 right-0 z-20 pointer-events-none", className),
|
|
2612
|
-
style: {
|
|
2613
|
-
// Adjust position when keyboard is open to keep input visible
|
|
2614
|
-
transform: keyboardHeight > 0 ? `translateY(-${keyboardHeight}px)` : void 0,
|
|
2615
|
-
transition: "transform 0.2s ease-out"
|
|
2616
|
-
},
|
|
2617
|
-
...props,
|
|
2618
|
-
children
|
|
2619
|
-
}
|
|
2620
|
-
));
|
|
2621
|
-
CopilotChatView2.InputContainer.displayName = "CopilotChatView.InputContainer";
|
|
2622
|
-
CopilotChatView2.Disclaimer = ({ className, ...props }) => {
|
|
2623
|
-
const config = useCopilotChatConfiguration();
|
|
2624
|
-
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
2625
|
-
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2626
|
-
"div",
|
|
2627
|
-
{
|
|
2628
|
-
className: cn("text-center text-xs text-muted-foreground py-3 px-4 max-w-3xl mx-auto", className),
|
|
2629
|
-
...props,
|
|
2630
|
-
children: labels.chatDisclaimerText
|
|
2631
|
-
}
|
|
2632
|
-
);
|
|
2633
|
-
};
|
|
2634
|
-
})(CopilotChatView || (CopilotChatView = {}));
|
|
2635
|
-
var CopilotChatView_default = CopilotChatView;
|
|
2636
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
2637
|
-
0 && (module.exports = {
|
|
2638
|
-
CopilotChatView
|
|
2639
|
-
});
|
|
2640
|
-
//# sourceMappingURL=CopilotChatView.js.map
|