@copilotkit/react-ui 0.0.0-0.0.0-max-changeset-10101010101010-20260109191632
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17415 -0
- package/LICENSE +21 -0
- package/README.md +141 -0
- package/dist/chunk-3W6J75HS.mjs +126 -0
- package/dist/chunk-3W6J75HS.mjs.map +1 -0
- package/dist/chunk-54JAUBUJ.mjs +26 -0
- package/dist/chunk-54JAUBUJ.mjs.map +1 -0
- package/dist/chunk-7OURDQZJ.mjs +133 -0
- package/dist/chunk-7OURDQZJ.mjs.map +1 -0
- package/dist/chunk-7PR2KJDO.mjs +222 -0
- package/dist/chunk-7PR2KJDO.mjs.map +1 -0
- package/dist/chunk-BH6PCAAL.mjs +81 -0
- package/dist/chunk-BH6PCAAL.mjs.map +1 -0
- package/dist/chunk-C3GSYRC3.mjs +118 -0
- package/dist/chunk-C3GSYRC3.mjs.map +1 -0
- package/dist/chunk-DBKRAOH7.mjs +34 -0
- package/dist/chunk-DBKRAOH7.mjs.map +1 -0
- package/dist/chunk-EFZPSZWO.mjs +1 -0
- package/dist/chunk-EFZPSZWO.mjs.map +1 -0
- package/dist/chunk-ELGRNEAO.mjs +32 -0
- package/dist/chunk-ELGRNEAO.mjs.map +1 -0
- package/dist/chunk-ELUJRANC.mjs +21 -0
- package/dist/chunk-ELUJRANC.mjs.map +1 -0
- package/dist/chunk-FFJHOZX6.mjs +202 -0
- package/dist/chunk-FFJHOZX6.mjs.map +1 -0
- package/dist/chunk-GDSZGYCE.mjs +32 -0
- package/dist/chunk-GDSZGYCE.mjs.map +1 -0
- package/dist/chunk-HIW7RXCD.mjs +184 -0
- package/dist/chunk-HIW7RXCD.mjs.map +1 -0
- package/dist/chunk-IEMQ2SQW.mjs +93 -0
- package/dist/chunk-IEMQ2SQW.mjs.map +1 -0
- package/dist/chunk-IHFR6PYG.mjs +116 -0
- package/dist/chunk-IHFR6PYG.mjs.map +1 -0
- package/dist/chunk-IK2BPURM.mjs +400 -0
- package/dist/chunk-IK2BPURM.mjs.map +1 -0
- package/dist/chunk-IU3WTXLQ.mjs +1 -0
- package/dist/chunk-IU3WTXLQ.mjs.map +1 -0
- package/dist/chunk-JGMFJZMG.mjs +11 -0
- package/dist/chunk-JGMFJZMG.mjs.map +1 -0
- package/dist/chunk-JY2CSDKN.mjs +135 -0
- package/dist/chunk-JY2CSDKN.mjs.map +1 -0
- package/dist/chunk-JZ3RFQQ6.mjs +128 -0
- package/dist/chunk-JZ3RFQQ6.mjs.map +1 -0
- package/dist/chunk-KXE2JCUH.mjs +1 -0
- package/dist/chunk-KXE2JCUH.mjs.map +1 -0
- package/dist/chunk-LQEFRHRT.mjs +30 -0
- package/dist/chunk-LQEFRHRT.mjs.map +1 -0
- package/dist/chunk-MMVDU6DF.mjs +1 -0
- package/dist/chunk-MMVDU6DF.mjs.map +1 -0
- package/dist/chunk-MRXNTQOX.mjs +59 -0
- package/dist/chunk-MRXNTQOX.mjs.map +1 -0
- package/dist/chunk-NCIAFFQ2.mjs +82 -0
- package/dist/chunk-NCIAFFQ2.mjs.map +1 -0
- package/dist/chunk-NGJ32FAP.mjs +30 -0
- package/dist/chunk-NGJ32FAP.mjs.map +1 -0
- package/dist/chunk-NRA3CFEE.mjs +97 -0
- package/dist/chunk-NRA3CFEE.mjs.map +1 -0
- package/dist/chunk-O72ZB5V3.mjs +140 -0
- package/dist/chunk-O72ZB5V3.mjs.map +1 -0
- package/dist/chunk-PLHTVHUW.mjs +82 -0
- package/dist/chunk-PLHTVHUW.mjs.map +1 -0
- package/dist/chunk-Q5V6S67N.mjs +103 -0
- package/dist/chunk-Q5V6S67N.mjs.map +1 -0
- package/dist/chunk-QB3GUN2N.mjs +31 -0
- package/dist/chunk-QB3GUN2N.mjs.map +1 -0
- package/dist/chunk-QIOJXTIQ.mjs +64 -0
- package/dist/chunk-QIOJXTIQ.mjs.map +1 -0
- package/dist/chunk-QPQRLXN3.mjs +435 -0
- package/dist/chunk-QPQRLXN3.mjs.map +1 -0
- package/dist/chunk-RYUCX3ZK.mjs +32 -0
- package/dist/chunk-RYUCX3ZK.mjs.map +1 -0
- package/dist/chunk-SC6JRFAJ.mjs +1 -0
- package/dist/chunk-SC6JRFAJ.mjs.map +1 -0
- package/dist/chunk-T26KLXLH.mjs +1 -0
- package/dist/chunk-T26KLXLH.mjs.map +1 -0
- package/dist/chunk-UFN2VWSR.mjs +25 -0
- package/dist/chunk-UFN2VWSR.mjs.map +1 -0
- package/dist/chunk-V7W6IM2V.mjs +1 -0
- package/dist/chunk-V7W6IM2V.mjs.map +1 -0
- package/dist/chunk-WB3YULQ4.mjs +1 -0
- package/dist/chunk-WB3YULQ4.mjs.map +1 -0
- package/dist/chunk-XWG3L6QC.mjs +258 -0
- package/dist/chunk-XWG3L6QC.mjs.map +1 -0
- package/dist/chunk-Y4FKRAKJ.mjs +12 -0
- package/dist/chunk-Y4FKRAKJ.mjs.map +1 -0
- package/dist/components/chat/Button.d.ts +9 -0
- package/dist/components/chat/Button.js +71 -0
- package/dist/components/chat/Button.js.map +1 -0
- package/dist/components/chat/Button.mjs +10 -0
- package/dist/components/chat/Button.mjs.map +1 -0
- package/dist/components/chat/Chat.d.ts +204 -0
- package/dist/components/chat/Chat.js +2270 -0
- package/dist/components/chat/Chat.js.map +1 -0
- package/dist/components/chat/Chat.mjs +29 -0
- package/dist/components/chat/Chat.mjs.map +1 -0
- package/dist/components/chat/ChatContext.d.ts +145 -0
- package/dist/components/chat/ChatContext.js +329 -0
- package/dist/components/chat/ChatContext.js.map +1 -0
- package/dist/components/chat/ChatContext.mjs +13 -0
- package/dist/components/chat/ChatContext.mjs.map +1 -0
- package/dist/components/chat/CodeBlock.d.ts +14 -0
- package/dist/components/chat/CodeBlock.js +510 -0
- package/dist/components/chat/CodeBlock.js.map +1 -0
- package/dist/components/chat/CodeBlock.mjs +14 -0
- package/dist/components/chat/CodeBlock.mjs.map +1 -0
- package/dist/components/chat/Header.d.ts +9 -0
- package/dist/components/chat/Header.js +582 -0
- package/dist/components/chat/Header.js.map +1 -0
- package/dist/components/chat/Header.mjs +17 -0
- package/dist/components/chat/Header.mjs.map +1 -0
- package/dist/components/chat/Icons.d.ts +20 -0
- package/dist/components/chat/Icons.js +297 -0
- package/dist/components/chat/Icons.js.map +1 -0
- package/dist/components/chat/Icons.mjs +38 -0
- package/dist/components/chat/Icons.mjs.map +1 -0
- package/dist/components/chat/ImageUploadQueue.d.ts +13 -0
- package/dist/components/chat/ImageUploadQueue.js +106 -0
- package/dist/components/chat/ImageUploadQueue.js.map +1 -0
- package/dist/components/chat/ImageUploadQueue.mjs +8 -0
- package/dist/components/chat/ImageUploadQueue.mjs.map +1 -0
- package/dist/components/chat/Input.d.ts +9 -0
- package/dist/components/chat/Input.js +396 -0
- package/dist/components/chat/Input.js.map +1 -0
- package/dist/components/chat/Input.mjs +14 -0
- package/dist/components/chat/Input.mjs.map +1 -0
- package/dist/components/chat/Markdown.d.ts +10 -0
- package/dist/components/chat/Markdown.js +652 -0
- package/dist/components/chat/Markdown.js.map +1 -0
- package/dist/components/chat/Markdown.mjs +11 -0
- package/dist/components/chat/Markdown.mjs.map +1 -0
- package/dist/components/chat/Messages.d.ts +13 -0
- package/dist/components/chat/Messages.js +1195 -0
- package/dist/components/chat/Messages.js.map +1 -0
- package/dist/components/chat/Messages.mjs +20 -0
- package/dist/components/chat/Messages.mjs.map +1 -0
- package/dist/components/chat/Modal.d.ts +51 -0
- package/dist/components/chat/Modal.js +3075 -0
- package/dist/components/chat/Modal.js.map +1 -0
- package/dist/components/chat/Modal.mjs +38 -0
- package/dist/components/chat/Modal.mjs.map +1 -0
- package/dist/components/chat/Popup.d.ts +13 -0
- package/dist/components/chat/Popup.js +3086 -0
- package/dist/components/chat/Popup.js.map +1 -0
- package/dist/components/chat/Popup.mjs +39 -0
- package/dist/components/chat/Popup.mjs.map +1 -0
- package/dist/components/chat/PoweredByTag.d.ts +7 -0
- package/dist/components/chat/PoweredByTag.js +61 -0
- package/dist/components/chat/PoweredByTag.js.map +1 -0
- package/dist/components/chat/PoweredByTag.mjs +9 -0
- package/dist/components/chat/PoweredByTag.mjs.map +1 -0
- package/dist/components/chat/Sidebar.d.ts +13 -0
- package/dist/components/chat/Sidebar.js +3095 -0
- package/dist/components/chat/Sidebar.js.map +1 -0
- package/dist/components/chat/Sidebar.mjs +39 -0
- package/dist/components/chat/Sidebar.mjs.map +1 -0
- package/dist/components/chat/Suggestion.d.ts +12 -0
- package/dist/components/chat/Suggestion.js +56 -0
- package/dist/components/chat/Suggestion.js.map +1 -0
- package/dist/components/chat/Suggestion.mjs +9 -0
- package/dist/components/chat/Suggestion.mjs.map +1 -0
- package/dist/components/chat/Suggestions.d.ts +9 -0
- package/dist/components/chat/Suggestions.js +81 -0
- package/dist/components/chat/Suggestions.js.map +1 -0
- package/dist/components/chat/Suggestions.mjs +10 -0
- package/dist/components/chat/Suggestions.mjs.map +1 -0
- package/dist/components/chat/Textarea.d.ts +15 -0
- package/dist/components/chat/Textarea.js +84 -0
- package/dist/components/chat/Textarea.js.map +1 -0
- package/dist/components/chat/Textarea.mjs +8 -0
- package/dist/components/chat/Textarea.mjs.map +1 -0
- package/dist/components/chat/Window.d.ts +9 -0
- package/dist/components/chat/Window.js +164 -0
- package/dist/components/chat/Window.js.map +1 -0
- package/dist/components/chat/Window.mjs +10 -0
- package/dist/components/chat/Window.mjs.map +1 -0
- package/dist/components/chat/index.d.ts +18 -0
- package/dist/components/chat/index.js +3122 -0
- package/dist/components/chat/index.js.map +1 -0
- package/dist/components/chat/index.mjs +69 -0
- package/dist/components/chat/index.mjs.map +1 -0
- package/dist/components/chat/messages/AssistantMessage.d.ts +9 -0
- package/dist/components/chat/messages/AssistantMessage.js +775 -0
- package/dist/components/chat/messages/AssistantMessage.js.map +1 -0
- package/dist/components/chat/messages/AssistantMessage.mjs +13 -0
- package/dist/components/chat/messages/AssistantMessage.mjs.map +1 -0
- package/dist/components/chat/messages/ErrorMessage.d.ts +9 -0
- package/dist/components/chat/messages/ErrorMessage.js +722 -0
- package/dist/components/chat/messages/ErrorMessage.js.map +1 -0
- package/dist/components/chat/messages/ErrorMessage.mjs +66 -0
- package/dist/components/chat/messages/ErrorMessage.mjs.map +1 -0
- package/dist/components/chat/messages/ImageRenderer.d.ts +12 -0
- package/dist/components/chat/messages/ImageRenderer.js +58 -0
- package/dist/components/chat/messages/ImageRenderer.js.map +1 -0
- package/dist/components/chat/messages/ImageRenderer.mjs +8 -0
- package/dist/components/chat/messages/ImageRenderer.mjs.map +1 -0
- package/dist/components/chat/messages/LegacyRenderMessage.d.ts +28 -0
- package/dist/components/chat/messages/LegacyRenderMessage.js +1023 -0
- package/dist/components/chat/messages/LegacyRenderMessage.js.map +1 -0
- package/dist/components/chat/messages/LegacyRenderMessage.mjs +17 -0
- package/dist/components/chat/messages/LegacyRenderMessage.mjs.map +1 -0
- package/dist/components/chat/messages/RenderMessage.d.ts +9 -0
- package/dist/components/chat/messages/RenderMessage.js +898 -0
- package/dist/components/chat/messages/RenderMessage.js.map +1 -0
- package/dist/components/chat/messages/RenderMessage.mjs +16 -0
- package/dist/components/chat/messages/RenderMessage.mjs.map +1 -0
- package/dist/components/chat/messages/UserMessage.d.ts +9 -0
- package/dist/components/chat/messages/UserMessage.js +56 -0
- package/dist/components/chat/messages/UserMessage.js.map +1 -0
- package/dist/components/chat/messages/UserMessage.mjs +8 -0
- package/dist/components/chat/messages/UserMessage.mjs.map +1 -0
- package/dist/components/chat/props.d.ts +298 -0
- package/dist/components/chat/props.js +19 -0
- package/dist/components/chat/props.js.map +1 -0
- package/dist/components/chat/props.mjs +2 -0
- package/dist/components/chat/props.mjs.map +1 -0
- package/dist/components/dev-console/console.d.ts +11 -0
- package/dist/components/dev-console/console.js +537 -0
- package/dist/components/dev-console/console.js.map +1 -0
- package/dist/components/dev-console/console.mjs +17 -0
- package/dist/components/dev-console/console.mjs.map +1 -0
- package/dist/components/dev-console/icons.d.ts +9 -0
- package/dist/components/dev-console/icons.js +131 -0
- package/dist/components/dev-console/icons.js.map +1 -0
- package/dist/components/dev-console/icons.mjs +16 -0
- package/dist/components/dev-console/icons.mjs.map +1 -0
- package/dist/components/dev-console/index.d.ts +3 -0
- package/dist/components/dev-console/index.js +537 -0
- package/dist/components/dev-console/index.js.map +1 -0
- package/dist/components/dev-console/index.mjs +18 -0
- package/dist/components/dev-console/index.mjs.map +1 -0
- package/dist/components/dev-console/types.d.ts +9 -0
- package/dist/components/dev-console/types.js +19 -0
- package/dist/components/dev-console/types.js.map +1 -0
- package/dist/components/dev-console/types.mjs +1 -0
- package/dist/components/dev-console/types.mjs.map +1 -0
- package/dist/components/dev-console/utils.d.ts +10 -0
- package/dist/components/dev-console/utils.js +177 -0
- package/dist/components/dev-console/utils.js.map +1 -0
- package/dist/components/dev-console/utils.mjs +16 -0
- package/dist/components/dev-console/utils.mjs.map +1 -0
- package/dist/components/help-modal/icons.d.ts +9 -0
- package/dist/components/help-modal/icons.js +107 -0
- package/dist/components/help-modal/icons.js.map +1 -0
- package/dist/components/help-modal/icons.mjs +12 -0
- package/dist/components/help-modal/icons.mjs.map +1 -0
- package/dist/components/help-modal/index.d.ts +2 -0
- package/dist/components/help-modal/index.js +137 -0
- package/dist/components/help-modal/index.js.map +1 -0
- package/dist/components/help-modal/index.mjs +10 -0
- package/dist/components/help-modal/index.mjs.map +1 -0
- package/dist/components/help-modal/modal.d.ts +5 -0
- package/dist/components/help-modal/modal.js +135 -0
- package/dist/components/help-modal/modal.js.map +1 -0
- package/dist/components/help-modal/modal.mjs +9 -0
- package/dist/components/help-modal/modal.mjs.map +1 -0
- package/dist/components/index.d.ts +19 -0
- package/dist/components/index.js +3126 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/index.mjs +76 -0
- package/dist/components/index.mjs.map +1 -0
- package/dist/context/index.d.ts +2 -0
- package/dist/context/index.js +19 -0
- package/dist/context/index.js.map +1 -0
- package/dist/context/index.mjs +2 -0
- package/dist/context/index.mjs.map +1 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.js +36 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/index.mjs +9 -0
- package/dist/hooks/index.mjs.map +1 -0
- package/dist/hooks/use-copilot-chat-suggestions.d.ts +66 -0
- package/dist/hooks/use-copilot-chat-suggestions.js +34 -0
- package/dist/hooks/use-copilot-chat-suggestions.js.map +1 -0
- package/dist/hooks/use-copilot-chat-suggestions.mjs +8 -0
- package/dist/hooks/use-copilot-chat-suggestions.mjs.map +1 -0
- package/dist/hooks/use-copy-to-clipboard.d.ts +9 -0
- package/dist/hooks/use-copy-to-clipboard.js +60 -0
- package/dist/hooks/use-copy-to-clipboard.js.map +1 -0
- package/dist/hooks/use-copy-to-clipboard.mjs +8 -0
- package/dist/hooks/use-copy-to-clipboard.mjs.map +1 -0
- package/dist/hooks/use-dark-mode.d.ts +3 -0
- package/dist/hooks/use-dark-mode.js +35 -0
- package/dist/hooks/use-dark-mode.js.map +1 -0
- package/dist/hooks/use-dark-mode.mjs +8 -0
- package/dist/hooks/use-dark-mode.mjs.map +1 -0
- package/dist/hooks/use-push-to-talk.d.ts +19 -0
- package/dist/hooks/use-push-to-talk.js +195 -0
- package/dist/hooks/use-push-to-talk.js.map +1 -0
- package/dist/hooks/use-push-to-talk.mjs +12 -0
- package/dist/hooks/use-push-to-talk.mjs.map +1 -0
- package/dist/index.css +1258 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +3135 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +84 -0
- package/dist/index.mjs.map +1 -0
- package/dist/lib/utils.d.ts +4 -0
- package/dist/lib/utils.js +76 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/lib/utils.mjs +34 -0
- package/dist/lib/utils.mjs.map +1 -0
- package/dist/types/css.d.ts +22 -0
- package/dist/types/css.js +19 -0
- package/dist/types/css.js.map +1 -0
- package/dist/types/css.mjs +1 -0
- package/dist/types/css.mjs.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.js +19 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/index.mjs +2 -0
- package/dist/types/index.mjs.map +1 -0
- package/dist/types/suggestions.d.ts +9 -0
- package/dist/types/suggestions.js +19 -0
- package/dist/types/suggestions.js.map +1 -0
- package/dist/types/suggestions.mjs +1 -0
- package/dist/types/suggestions.mjs.map +1 -0
- package/dist/v2/index.css +4 -0
- package/dist/v2/index.css.map +1 -0
- package/dist/v2/index.d.ts +2 -0
- package/dist/v2/index.js +2 -0
- package/dist/v2/index.js.map +1 -0
- package/dist/v2/index.mjs +2 -0
- package/dist/v2/index.mjs.map +1 -0
- package/jest.config.js +5 -0
- package/package.json +83 -0
- package/postcss.config.js +60 -0
- package/src/components/chat/Button.tsx +18 -0
- package/src/components/chat/Chat.tsx +795 -0
- package/src/components/chat/ChatContext.tsx +248 -0
- package/src/components/chat/CodeBlock.tsx +418 -0
- package/src/components/chat/Header.tsx +24 -0
- package/src/components/chat/Icons.tsx +237 -0
- package/src/components/chat/ImageUploadQueue.tsx +77 -0
- package/src/components/chat/Input.tsx +156 -0
- package/src/components/chat/Markdown.tsx +144 -0
- package/src/components/chat/Messages.tsx +206 -0
- package/src/components/chat/Modal.tsx +220 -0
- package/src/components/chat/Popup.tsx +77 -0
- package/src/components/chat/PoweredByTag.tsx +42 -0
- package/src/components/chat/Sidebar.tsx +96 -0
- package/src/components/chat/Suggestion.tsx +29 -0
- package/src/components/chat/Suggestions.tsx +23 -0
- package/src/components/chat/Textarea.tsx +77 -0
- package/src/components/chat/Window.tsx +152 -0
- package/src/components/chat/index.tsx +11 -0
- package/src/components/chat/messages/AssistantMessage.tsx +118 -0
- package/src/components/chat/messages/ErrorMessage.tsx +59 -0
- package/src/components/chat/messages/ImageRenderer.tsx +37 -0
- package/src/components/chat/messages/LegacyRenderMessage.tsx +150 -0
- package/src/components/chat/messages/RenderMessage.tsx +61 -0
- package/src/components/chat/messages/UserMessage.tsx +46 -0
- package/src/components/chat/props.ts +353 -0
- package/src/components/dev-console/console.tsx +242 -0
- package/src/components/dev-console/icons.tsx +99 -0
- package/src/components/dev-console/index.tsx +2 -0
- package/src/components/dev-console/types.ts +7 -0
- package/src/components/dev-console/utils.ts +142 -0
- package/src/components/help-modal/icons.tsx +68 -0
- package/src/components/help-modal/index.tsx +1 -0
- package/src/components/help-modal/modal.tsx +101 -0
- package/src/components/index.ts +2 -0
- package/src/context/index.ts +1 -0
- package/src/css/animations.css +35 -0
- package/src/css/button.css +67 -0
- package/src/css/colors.css +78 -0
- package/src/css/console.css +166 -0
- package/src/css/crew.css +277 -0
- package/src/css/header.css +65 -0
- package/src/css/input.css +152 -0
- package/src/css/markdown.css +150 -0
- package/src/css/messages.css +244 -0
- package/src/css/panel.css +39 -0
- package/src/css/popup.css +22 -0
- package/src/css/sidebar.css +34 -0
- package/src/css/suggestions.css +43 -0
- package/src/css/window.css +60 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/use-copilot-chat-suggestions.tsx +71 -0
- package/src/hooks/use-copy-to-clipboard.tsx +29 -0
- package/src/hooks/use-dark-mode.ts +10 -0
- package/src/hooks/use-push-to-talk.tsx +167 -0
- package/src/index.tsx +7 -0
- package/src/lib/utils.test.ts +7 -0
- package/src/lib/utils.ts +27 -0
- package/src/styles.css +14 -0
- package/src/types/css.ts +21 -0
- package/src/types/index.ts +2 -0
- package/src/types/suggestions.ts +7 -0
- package/src/v2/index.ts +1 -0
- package/src/v2/styles.css +1 -0
- package/tailwind.config.js +7 -0
- package/tsconfig.json +12 -0
- package/tsup.config.ts +11 -0
- package/typedoc.json +4 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { UserMessageProps } from "../props";
|
|
2
|
+
|
|
3
|
+
type UserMessageContent = NonNullable<UserMessageProps["message"]>["content"];
|
|
4
|
+
|
|
5
|
+
const getTextContent = (content: UserMessageContent | undefined): string | undefined => {
|
|
6
|
+
if (typeof content === "undefined") {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
if (typeof content === "string") {
|
|
11
|
+
return content;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
content
|
|
16
|
+
.map((part) => {
|
|
17
|
+
if (part.type === "text") {
|
|
18
|
+
return part.text;
|
|
19
|
+
}
|
|
20
|
+
return undefined;
|
|
21
|
+
})
|
|
22
|
+
.filter((value): value is string => typeof value === "string" && value.length > 0)
|
|
23
|
+
.join(" ")
|
|
24
|
+
.trim() || undefined
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const UserMessage = (props: UserMessageProps) => {
|
|
29
|
+
const { message, ImageRenderer } = props;
|
|
30
|
+
const isImageMessage = message && "image" in message && Boolean(message.image);
|
|
31
|
+
|
|
32
|
+
if (isImageMessage) {
|
|
33
|
+
const imageMessage = message!;
|
|
34
|
+
const content = getTextContent(imageMessage?.content);
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<div className="copilotKitMessage copilotKitUserMessage">
|
|
38
|
+
<ImageRenderer image={imageMessage.image!} content={content} />
|
|
39
|
+
</div>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const content = getTextContent(message?.content);
|
|
44
|
+
|
|
45
|
+
return <div className="copilotKitMessage copilotKitUserMessage">{content}</div>;
|
|
46
|
+
};
|
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
import { AIMessage, Message, UserMessage, CopilotErrorEvent } from "@copilotkit/shared";
|
|
2
|
+
import { CopilotChatSuggestion } from "../../types/suggestions";
|
|
3
|
+
import { ReactNode } from "react";
|
|
4
|
+
import { ImageData } from "@copilotkit/shared";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Event hooks for CopilotKit chat events.
|
|
8
|
+
* These hooks only work when publicApiKey is provided.
|
|
9
|
+
*/
|
|
10
|
+
export interface CopilotObservabilityHooks {
|
|
11
|
+
/**
|
|
12
|
+
* Called when a message is sent by the user
|
|
13
|
+
*/
|
|
14
|
+
onMessageSent?: (message: string) => void;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Called when the chat is minimized/closed
|
|
18
|
+
*/
|
|
19
|
+
onChatMinimized?: () => void;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Called when the chat is expanded/opened
|
|
23
|
+
*/
|
|
24
|
+
onChatExpanded?: () => void;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Called when a message is regenerated
|
|
28
|
+
*/
|
|
29
|
+
onMessageRegenerated?: (messageId: string) => void;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Called when a message is copied
|
|
33
|
+
*/
|
|
34
|
+
onMessageCopied?: (content: string) => void;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Called when feedback is given (thumbs up/down)
|
|
38
|
+
*/
|
|
39
|
+
onFeedbackGiven?: (messageId: string, type: "thumbsUp" | "thumbsDown") => void;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Called when chat generation starts
|
|
43
|
+
*/
|
|
44
|
+
onChatStarted?: () => void;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Called when chat generation stops
|
|
48
|
+
*/
|
|
49
|
+
onChatStopped?: () => void;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Called when an error occurs in the chat
|
|
53
|
+
* This enables chat-specific error handling UX while preserving system-wide error monitoring
|
|
54
|
+
*/
|
|
55
|
+
onError?: (errorEvent: CopilotErrorEvent) => void;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface ButtonProps {}
|
|
59
|
+
|
|
60
|
+
export interface WindowProps {
|
|
61
|
+
clickOutsideToClose: boolean;
|
|
62
|
+
hitEscapeToClose: boolean;
|
|
63
|
+
shortcut: string;
|
|
64
|
+
children?: React.ReactNode;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface HeaderProps {}
|
|
68
|
+
|
|
69
|
+
export interface SuggestionsProps {
|
|
70
|
+
title: string;
|
|
71
|
+
message: string;
|
|
72
|
+
partial?: boolean;
|
|
73
|
+
className?: string;
|
|
74
|
+
onClick: (message: string) => void;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export type ComponentsMap<T extends Record<string, object> = Record<string, object>> = {
|
|
78
|
+
[K in keyof T]: React.FC<{ children?: ReactNode } & T[K]>;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export interface MessagesProps {
|
|
82
|
+
messages: Message[];
|
|
83
|
+
inProgress: boolean;
|
|
84
|
+
children?: React.ReactNode;
|
|
85
|
+
chatError?: ChatError | null;
|
|
86
|
+
AssistantMessage: React.ComponentType<AssistantMessageProps>;
|
|
87
|
+
UserMessage: React.ComponentType<UserMessageProps>;
|
|
88
|
+
ErrorMessage?: React.ComponentType<ErrorMessageProps>;
|
|
89
|
+
RenderMessage: React.ComponentType<RenderMessageProps>;
|
|
90
|
+
ImageRenderer: React.ComponentType<ImageRendererProps>;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Callback function to regenerate the assistant's response
|
|
94
|
+
*/
|
|
95
|
+
onRegenerate?: (messageId: string) => void;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Callback function when the message is copied
|
|
99
|
+
*/
|
|
100
|
+
onCopy?: (message: string) => void;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Callback function for thumbs up feedback
|
|
104
|
+
*/
|
|
105
|
+
onThumbsUp?: (message: Message) => void;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Callback function for thumbs down feedback
|
|
109
|
+
*/
|
|
110
|
+
onThumbsDown?: (message: Message) => void;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Map of message IDs to their feedback state
|
|
114
|
+
*/
|
|
115
|
+
messageFeedback?: Record<string, "thumbsUp" | "thumbsDown">;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* A list of markdown components to render in assistant message.
|
|
119
|
+
* Useful when you want to render custom elements in the message (e.g a reference tag element)
|
|
120
|
+
*/
|
|
121
|
+
markdownTagRenderers?: ComponentsMap;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* @deprecated Use RenderMessage instead
|
|
125
|
+
*/
|
|
126
|
+
RenderTextMessage?: React.ComponentType<RenderMessageProps>;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* @deprecated Use RenderMessage instead
|
|
130
|
+
*/
|
|
131
|
+
RenderActionExecutionMessage?: React.ComponentType<RenderMessageProps>;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* @deprecated Use RenderMessage instead
|
|
135
|
+
*/
|
|
136
|
+
RenderAgentStateMessage?: React.ComponentType<RenderMessageProps>;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* @deprecated Use RenderMessage instead
|
|
140
|
+
*/
|
|
141
|
+
RenderResultMessage?: React.ComponentType<RenderMessageProps>;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* @deprecated Use RenderMessage instead
|
|
145
|
+
*/
|
|
146
|
+
RenderImageMessage?: React.ComponentType<RenderMessageProps>;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export interface Renderer {
|
|
150
|
+
content: string;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export interface UserMessageProps {
|
|
154
|
+
message?: UserMessage;
|
|
155
|
+
ImageRenderer: React.ComponentType<ImageRendererProps>;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* @deprecated use message instead
|
|
159
|
+
*
|
|
160
|
+
* The raw data from the assistant's response
|
|
161
|
+
*/
|
|
162
|
+
rawData: any;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export interface AssistantMessageProps {
|
|
166
|
+
/**
|
|
167
|
+
* The message content from the assistant
|
|
168
|
+
*/
|
|
169
|
+
|
|
170
|
+
message?: AIMessage;
|
|
171
|
+
messages?: Message[];
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Indicates if this is the last message
|
|
175
|
+
*/
|
|
176
|
+
isCurrentMessage?: boolean;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Whether a response is loading, this is when the LLM is thinking of a response but hasn't finished yet.
|
|
180
|
+
*/
|
|
181
|
+
isLoading: boolean;
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Whether a response is generating, this is when the LLM is actively generating and streaming content.
|
|
185
|
+
*/
|
|
186
|
+
isGenerating: boolean;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Callback function to regenerate the assistant's response
|
|
190
|
+
*/
|
|
191
|
+
onRegenerate?: () => void;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Callback function when the message is copied
|
|
195
|
+
*/
|
|
196
|
+
onCopy?: (message: string) => void;
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Callback function for thumbs up feedback
|
|
200
|
+
*/
|
|
201
|
+
onThumbsUp?: (message: Message) => void;
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Callback function for thumbs down feedback
|
|
205
|
+
*/
|
|
206
|
+
onThumbsDown?: (message: Message) => void;
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* The feedback state for this message ("thumbsUp" or "thumbsDown")
|
|
210
|
+
*/
|
|
211
|
+
feedback?: "thumbsUp" | "thumbsDown" | null;
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* A list of markdown components to render in assistant message.
|
|
215
|
+
* Useful when you want to render custom elements in the message (e.g a reference tag element)
|
|
216
|
+
*/
|
|
217
|
+
markdownTagRenderers?: ComponentsMap;
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* A custom image rendering component to use instead of the default.
|
|
221
|
+
*/
|
|
222
|
+
ImageRenderer?: React.ComponentType<ImageRendererProps>;
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* @deprecated use message instead
|
|
226
|
+
*
|
|
227
|
+
* The raw data from the assistant's response
|
|
228
|
+
*/
|
|
229
|
+
rawData: any;
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
*
|
|
233
|
+
* @deprecated
|
|
234
|
+
*
|
|
235
|
+
* use `message.generativeUI()` instead.
|
|
236
|
+
*
|
|
237
|
+
* For example:
|
|
238
|
+
*
|
|
239
|
+
* ```tsx
|
|
240
|
+
* const CustomAssistantMessage = ({ message }: AssistantMessageProps) => {
|
|
241
|
+
* const subComponent = message?.generativeUI?.();
|
|
242
|
+
* return <div>{subComponent}</div>;
|
|
243
|
+
* };
|
|
244
|
+
*
|
|
245
|
+
* ```
|
|
246
|
+
*/
|
|
247
|
+
subComponent?: React.JSX.Element;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export interface ErrorMessageProps {
|
|
251
|
+
/**
|
|
252
|
+
* The message content from the assistant
|
|
253
|
+
*/
|
|
254
|
+
|
|
255
|
+
error: ChatError;
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Indicates if this is the last message
|
|
259
|
+
*/
|
|
260
|
+
isCurrentMessage?: boolean;
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Callback function to regenerate the assistant's response
|
|
264
|
+
*/
|
|
265
|
+
onRegenerate?: () => void;
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Callback function when the message is copied
|
|
269
|
+
*/
|
|
270
|
+
onCopy?: (message: string) => void;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export interface RenderMessageProps {
|
|
274
|
+
message: Message;
|
|
275
|
+
messages: Message[];
|
|
276
|
+
inProgress: boolean;
|
|
277
|
+
index: number;
|
|
278
|
+
isCurrentMessage: boolean;
|
|
279
|
+
actionResult?: string;
|
|
280
|
+
AssistantMessage?: React.ComponentType<AssistantMessageProps>;
|
|
281
|
+
UserMessage?: React.ComponentType<UserMessageProps>;
|
|
282
|
+
ImageRenderer?: React.ComponentType<ImageRendererProps>;
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Callback function to regenerate the assistant's response
|
|
286
|
+
*/
|
|
287
|
+
onRegenerate?: (messageId: string) => void;
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Callback function when the message is copied
|
|
291
|
+
*/
|
|
292
|
+
onCopy?: (message: string) => void;
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Callback function for thumbs up feedback
|
|
296
|
+
*/
|
|
297
|
+
onThumbsUp?: (message: Message) => void;
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Callback function for thumbs down feedback
|
|
301
|
+
*/
|
|
302
|
+
onThumbsDown?: (message: Message) => void;
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Map of message IDs to their feedback state
|
|
306
|
+
*/
|
|
307
|
+
messageFeedback?: Record<string, "thumbsUp" | "thumbsDown">;
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* A list of markdown components to render in assistant message.
|
|
311
|
+
* Useful when you want to render custom elements in the message (e.g a reference tag element)
|
|
312
|
+
*/
|
|
313
|
+
markdownTagRenderers?: ComponentsMap;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
export interface InputProps {
|
|
317
|
+
inProgress: boolean;
|
|
318
|
+
onSend: (text: string) => Promise<Message>;
|
|
319
|
+
isVisible?: boolean;
|
|
320
|
+
onStop?: () => void;
|
|
321
|
+
onUpload?: () => void;
|
|
322
|
+
hideStopButton?: boolean;
|
|
323
|
+
chatReady?: boolean;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
export interface RenderSuggestionsListProps {
|
|
327
|
+
suggestions: CopilotChatSuggestion[];
|
|
328
|
+
onSuggestionClick: (message: string) => void;
|
|
329
|
+
isLoading: boolean;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
export interface ImageRendererProps {
|
|
333
|
+
/**
|
|
334
|
+
* The image data containing format and bytes
|
|
335
|
+
*/
|
|
336
|
+
image: ImageData;
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Optional content to display alongside the image
|
|
340
|
+
*/
|
|
341
|
+
content?: string;
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Additional CSS class name for styling
|
|
345
|
+
*/
|
|
346
|
+
className?: string;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
export interface ChatError {
|
|
350
|
+
message: string;
|
|
351
|
+
operation?: string;
|
|
352
|
+
timestamp: number;
|
|
353
|
+
}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useCopilotContext, useCopilotMessagesContext } from "@copilotkit/react-core";
|
|
4
|
+
import {
|
|
5
|
+
getPublishedCopilotKitVersion,
|
|
6
|
+
logActions,
|
|
7
|
+
logMessages,
|
|
8
|
+
logReadables,
|
|
9
|
+
shouldShowDevConsole,
|
|
10
|
+
} from "./utils";
|
|
11
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
12
|
+
import {
|
|
13
|
+
CheckIcon,
|
|
14
|
+
ChevronDownIcon,
|
|
15
|
+
CopilotKitIcon,
|
|
16
|
+
ExclamationMarkIcon,
|
|
17
|
+
ExclamationMarkTriangleIcon,
|
|
18
|
+
} from "./icons";
|
|
19
|
+
import { Menu, MenuButton, MenuItem, MenuItems } from "@headlessui/react";
|
|
20
|
+
import { COPILOTKIT_VERSION } from "@copilotkit/shared";
|
|
21
|
+
import { SmallSpinnerIcon } from "../chat/Icons";
|
|
22
|
+
import { CopilotKitHelpModal } from "../help-modal";
|
|
23
|
+
|
|
24
|
+
type VersionStatus = "unknown" | "checking" | "latest" | "update-available" | "outdated";
|
|
25
|
+
|
|
26
|
+
export function CopilotDevConsole() {
|
|
27
|
+
const currentVersion = COPILOTKIT_VERSION;
|
|
28
|
+
const context = useCopilotContext();
|
|
29
|
+
|
|
30
|
+
// to prevent hydration errors, ensure that the component renders the same content
|
|
31
|
+
// server-side as it does during the initial client-side render to prevent a hydration
|
|
32
|
+
// mismatch
|
|
33
|
+
// see: https://nextjs.org/docs/messages/react-hydration-error#solution-1-using-useeffect-to-run-on-the-client-only
|
|
34
|
+
|
|
35
|
+
const [showDevConsole, setShowDevConsole] = useState(false);
|
|
36
|
+
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
setShowDevConsole(shouldShowDevConsole(context.showDevConsole));
|
|
39
|
+
}, [context.showDevConsole]);
|
|
40
|
+
|
|
41
|
+
const dontRunTwiceInDevMode = useRef(false);
|
|
42
|
+
const [versionStatus, setVersionStatus] = useState<VersionStatus>("unknown");
|
|
43
|
+
const [latestVersion, setLatestVersion] = useState<string>("");
|
|
44
|
+
const consoleRef = useRef<HTMLDivElement>(null);
|
|
45
|
+
const [debugButtonMode, setDebugButtonMode] = useState<"full" | "compact">("full");
|
|
46
|
+
|
|
47
|
+
const checkForUpdates = (force: boolean = false) => {
|
|
48
|
+
setVersionStatus("checking");
|
|
49
|
+
|
|
50
|
+
getPublishedCopilotKitVersion(currentVersion, force)
|
|
51
|
+
.then((v) => {
|
|
52
|
+
setLatestVersion(v.latest);
|
|
53
|
+
let versionOk = false;
|
|
54
|
+
|
|
55
|
+
// match exact version or a version with a letter (e.g. 1.0.0-alpha.1)
|
|
56
|
+
if (v.current === v.latest) {
|
|
57
|
+
versionOk = true;
|
|
58
|
+
} else if (/[a-zA-Z]/.test(v.current)) {
|
|
59
|
+
versionOk = true;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (versionOk) {
|
|
63
|
+
setVersionStatus("latest");
|
|
64
|
+
} else if (v.severity !== "low") {
|
|
65
|
+
setVersionStatus("outdated");
|
|
66
|
+
} else {
|
|
67
|
+
setVersionStatus("update-available");
|
|
68
|
+
}
|
|
69
|
+
})
|
|
70
|
+
.catch((e) => {
|
|
71
|
+
console.error(e);
|
|
72
|
+
setVersionStatus("unknown");
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if (dontRunTwiceInDevMode.current === true) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
dontRunTwiceInDevMode.current = true;
|
|
81
|
+
|
|
82
|
+
checkForUpdates();
|
|
83
|
+
}, []);
|
|
84
|
+
|
|
85
|
+
if (!showDevConsole) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
return (
|
|
89
|
+
<div
|
|
90
|
+
ref={consoleRef}
|
|
91
|
+
className={
|
|
92
|
+
"copilotKitDevConsole " +
|
|
93
|
+
(versionStatus === "update-available" ? "copilotKitDevConsoleUpgrade" : "") +
|
|
94
|
+
(versionStatus === "outdated" ? "copilotKitDevConsoleWarnOutdated" : "")
|
|
95
|
+
}
|
|
96
|
+
>
|
|
97
|
+
<VersionInfo
|
|
98
|
+
showDevConsole={context.showDevConsole}
|
|
99
|
+
versionStatus={versionStatus}
|
|
100
|
+
currentVersion={currentVersion}
|
|
101
|
+
latestVersion={latestVersion}
|
|
102
|
+
/>
|
|
103
|
+
|
|
104
|
+
<CopilotKitHelpModal />
|
|
105
|
+
|
|
106
|
+
<DebugMenuButton
|
|
107
|
+
setShowDevConsole={setShowDevConsole}
|
|
108
|
+
checkForUpdates={checkForUpdates}
|
|
109
|
+
mode={debugButtonMode}
|
|
110
|
+
/>
|
|
111
|
+
</div>
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function VersionInfo({
|
|
116
|
+
showDevConsole,
|
|
117
|
+
versionStatus,
|
|
118
|
+
currentVersion,
|
|
119
|
+
latestVersion,
|
|
120
|
+
}: {
|
|
121
|
+
showDevConsole: boolean;
|
|
122
|
+
versionStatus: VersionStatus;
|
|
123
|
+
currentVersion: string;
|
|
124
|
+
latestVersion: string;
|
|
125
|
+
}) {
|
|
126
|
+
const [copyStatus, setCopyStatus] = useState<string>("");
|
|
127
|
+
|
|
128
|
+
let versionLabel = "";
|
|
129
|
+
let versionIcon: any = "";
|
|
130
|
+
let currentVersionLabel = currentVersion;
|
|
131
|
+
|
|
132
|
+
if (versionStatus === "latest") {
|
|
133
|
+
versionLabel = "latest";
|
|
134
|
+
versionIcon = CheckIcon;
|
|
135
|
+
} else if (versionStatus === "checking") {
|
|
136
|
+
versionLabel = "checking";
|
|
137
|
+
versionIcon = SmallSpinnerIcon;
|
|
138
|
+
} else if (versionStatus === "update-available") {
|
|
139
|
+
versionLabel = "update available";
|
|
140
|
+
versionIcon = ExclamationMarkIcon;
|
|
141
|
+
currentVersionLabel = `${currentVersion} → ${latestVersion}`;
|
|
142
|
+
} else if (versionStatus === "outdated") {
|
|
143
|
+
versionLabel = "outdated";
|
|
144
|
+
versionIcon = ExclamationMarkTriangleIcon;
|
|
145
|
+
currentVersionLabel = `${currentVersion} → ${latestVersion}`;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
let asideLabel = "";
|
|
149
|
+
if (showDevConsole === true) {
|
|
150
|
+
asideLabel = "(enabled)";
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const installCommand = [
|
|
154
|
+
`npm install`,
|
|
155
|
+
`@copilotkit/react-core@${latestVersion}`,
|
|
156
|
+
`@copilotkit/react-ui@${latestVersion}`,
|
|
157
|
+
`@copilotkit/react-textarea@${latestVersion}`,
|
|
158
|
+
`&& npm install @copilotkit/runtime@${latestVersion}`,
|
|
159
|
+
].join(" ");
|
|
160
|
+
|
|
161
|
+
const handleCopyClick = () => {
|
|
162
|
+
navigator.clipboard.writeText(installCommand.trim()).then(() => {
|
|
163
|
+
setCopyStatus("Command copied to clipboard!");
|
|
164
|
+
setTimeout(() => setCopyStatus(""), 1000);
|
|
165
|
+
});
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
if (versionStatus === "update-available" || versionStatus === "outdated") {
|
|
169
|
+
return (
|
|
170
|
+
<div className="copilotKitVersionInfo">
|
|
171
|
+
<p>
|
|
172
|
+
{currentVersionLabel} {versionIcon}
|
|
173
|
+
</p>
|
|
174
|
+
<button onClick={handleCopyClick}>{copyStatus || installCommand}</button>
|
|
175
|
+
</div>
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export default function DebugMenuButton({
|
|
183
|
+
setShowDevConsole,
|
|
184
|
+
checkForUpdates,
|
|
185
|
+
mode,
|
|
186
|
+
}: {
|
|
187
|
+
setShowDevConsole: (show: boolean) => void;
|
|
188
|
+
checkForUpdates: (force: boolean) => void;
|
|
189
|
+
mode: "full" | "compact";
|
|
190
|
+
}) {
|
|
191
|
+
const context = useCopilotContext();
|
|
192
|
+
const messagesContext = useCopilotMessagesContext();
|
|
193
|
+
|
|
194
|
+
return (
|
|
195
|
+
<>
|
|
196
|
+
<Menu>
|
|
197
|
+
<MenuButton
|
|
198
|
+
className={`copilotKitDebugMenuTriggerButton ${mode === "compact" ? "compact" : ""}`}
|
|
199
|
+
>
|
|
200
|
+
{mode == "compact" ? "Debug" : <>Debug {ChevronDownIcon}</>}
|
|
201
|
+
</MenuButton>
|
|
202
|
+
|
|
203
|
+
<MenuItems
|
|
204
|
+
transition
|
|
205
|
+
anchor="bottom end"
|
|
206
|
+
className="copilotKitDebugMenu"
|
|
207
|
+
style={{ zIndex: 40 }}
|
|
208
|
+
>
|
|
209
|
+
<MenuItem>
|
|
210
|
+
<button className="copilotKitDebugMenuItem" onClick={() => logReadables(context)}>
|
|
211
|
+
Log Readables
|
|
212
|
+
</button>
|
|
213
|
+
</MenuItem>
|
|
214
|
+
<MenuItem>
|
|
215
|
+
<button className="copilotKitDebugMenuItem" onClick={() => logActions(context)}>
|
|
216
|
+
Log Actions
|
|
217
|
+
</button>
|
|
218
|
+
</MenuItem>
|
|
219
|
+
<MenuItem>
|
|
220
|
+
<button
|
|
221
|
+
className="copilotKitDebugMenuItem"
|
|
222
|
+
onClick={() => logMessages(messagesContext)}
|
|
223
|
+
>
|
|
224
|
+
Log Messages
|
|
225
|
+
</button>
|
|
226
|
+
</MenuItem>
|
|
227
|
+
<MenuItem>
|
|
228
|
+
<button className="copilotKitDebugMenuItem" onClick={() => checkForUpdates(true)}>
|
|
229
|
+
Check for Updates
|
|
230
|
+
</button>
|
|
231
|
+
</MenuItem>
|
|
232
|
+
<hr />
|
|
233
|
+
<MenuItem>
|
|
234
|
+
<button className="copilotKitDebugMenuItem" onClick={() => setShowDevConsole(false)}>
|
|
235
|
+
Hide Dev Console
|
|
236
|
+
</button>
|
|
237
|
+
</MenuItem>
|
|
238
|
+
</MenuItems>
|
|
239
|
+
</Menu>
|
|
240
|
+
</>
|
|
241
|
+
);
|
|
242
|
+
}
|