@copilotkit/react-ui 0.0.0-feat-dynamic-copilotcloud-qa-20250117190454
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 +2436 -0
- package/README.md +46 -0
- package/dist/chunk-34FREWVK.mjs +180 -0
- package/dist/chunk-34FREWVK.mjs.map +1 -0
- package/dist/chunk-3VNMQWGT.mjs +25 -0
- package/dist/chunk-3VNMQWGT.mjs.map +1 -0
- package/dist/chunk-3XAXY2Z3.mjs +18 -0
- package/dist/chunk-3XAXY2Z3.mjs.map +1 -0
- package/dist/chunk-54JAUBUJ.mjs +26 -0
- package/dist/chunk-54JAUBUJ.mjs.map +1 -0
- package/dist/chunk-B23XDGH4.mjs +30 -0
- package/dist/chunk-B23XDGH4.mjs.map +1 -0
- package/dist/chunk-BH6PCAAL.mjs +81 -0
- package/dist/chunk-BH6PCAAL.mjs.map +1 -0
- package/dist/chunk-CBBFRI3Q.mjs +81 -0
- package/dist/chunk-CBBFRI3Q.mjs.map +1 -0
- package/dist/chunk-EFZPSZWO.mjs +1 -0
- package/dist/chunk-EFZPSZWO.mjs.map +1 -0
- package/dist/chunk-EMQEEXUB.mjs +97 -0
- package/dist/chunk-EMQEEXUB.mjs.map +1 -0
- package/dist/chunk-F2W5FD7L.mjs +232 -0
- package/dist/chunk-F2W5FD7L.mjs.map +1 -0
- package/dist/chunk-F7VWGY77.mjs +22 -0
- package/dist/chunk-F7VWGY77.mjs.map +1 -0
- package/dist/chunk-FZC7X5PK.mjs +262 -0
- package/dist/chunk-FZC7X5PK.mjs.map +1 -0
- package/dist/chunk-HEIDCT7I.mjs +10 -0
- package/dist/chunk-HEIDCT7I.mjs.map +1 -0
- package/dist/chunk-I7MG52I5.mjs +314 -0
- package/dist/chunk-I7MG52I5.mjs.map +1 -0
- package/dist/chunk-IU3WTXLQ.mjs +1 -0
- package/dist/chunk-IU3WTXLQ.mjs.map +1 -0
- package/dist/chunk-KXE2JCUH.mjs +1 -0
- package/dist/chunk-KXE2JCUH.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-O6JFOQQA.mjs +21 -0
- package/dist/chunk-O6JFOQQA.mjs.map +1 -0
- package/dist/chunk-OFYI4UU4.mjs +35 -0
- package/dist/chunk-OFYI4UU4.mjs.map +1 -0
- package/dist/chunk-OTPAZXVR.mjs +92 -0
- package/dist/chunk-OTPAZXVR.mjs.map +1 -0
- package/dist/chunk-P5A3A5FO.mjs +112 -0
- package/dist/chunk-P5A3A5FO.mjs.map +1 -0
- package/dist/chunk-PNQVKBPN.mjs +146 -0
- package/dist/chunk-PNQVKBPN.mjs.map +1 -0
- package/dist/chunk-RJCZRKTV.mjs +106 -0
- package/dist/chunk-RJCZRKTV.mjs.map +1 -0
- package/dist/chunk-RQNJNK2W.mjs +25 -0
- package/dist/chunk-RQNJNK2W.mjs.map +1 -0
- package/dist/chunk-S5MBUNGN.mjs +140 -0
- package/dist/chunk-S5MBUNGN.mjs.map +1 -0
- package/dist/chunk-SQMEPWVT.mjs +1 -0
- package/dist/chunk-SQMEPWVT.mjs.map +1 -0
- package/dist/chunk-T26KLXLH.mjs +1 -0
- package/dist/chunk-T26KLXLH.mjs.map +1 -0
- package/dist/chunk-TI7SY2RI.mjs +164 -0
- package/dist/chunk-TI7SY2RI.mjs.map +1 -0
- package/dist/chunk-UPTB2MVO.mjs +395 -0
- package/dist/chunk-UPTB2MVO.mjs.map +1 -0
- package/dist/chunk-UWWMAJ7R.mjs +100 -0
- package/dist/chunk-UWWMAJ7R.mjs.map +1 -0
- package/dist/chunk-V7W6IM2V.mjs +1 -0
- package/dist/chunk-V7W6IM2V.mjs.map +1 -0
- package/dist/chunk-VEC45H6Q.mjs +18 -0
- package/dist/chunk-VEC45H6Q.mjs.map +1 -0
- package/dist/chunk-VKVNMHM5.mjs +105 -0
- package/dist/chunk-VKVNMHM5.mjs.map +1 -0
- package/dist/chunk-WB3YULQ4.mjs +1 -0
- package/dist/chunk-WB3YULQ4.mjs.map +1 -0
- package/dist/chunk-YAGE7RCE.mjs +118 -0
- package/dist/chunk-YAGE7RCE.mjs.map +1 -0
- package/dist/chunk-YQ3D5IQV.mjs +75 -0
- package/dist/chunk-YQ3D5IQV.mjs.map +1 -0
- package/dist/chunk-YQFVRDNC.mjs +53 -0
- package/dist/chunk-YQFVRDNC.mjs.map +1 -0
- package/dist/chunk-Z2UZSN3K.mjs +29 -0
- package/dist/chunk-Z2UZSN3K.mjs.map +1 -0
- package/dist/components/chat/Button.d.ts +7 -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 +156 -0
- package/dist/components/chat/Chat.js +2540 -0
- package/dist/components/chat/Chat.js.map +1 -0
- package/dist/components/chat/Chat.mjs +36 -0
- package/dist/components/chat/Chat.mjs.map +1 -0
- package/dist/components/chat/ChatContext.d.ts +105 -0
- package/dist/components/chat/ChatContext.js +279 -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 +523 -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 +7 -0
- package/dist/components/chat/Header.js +64 -0
- package/dist/components/chat/Header.js.map +1 -0
- package/dist/components/chat/Header.mjs +10 -0
- package/dist/components/chat/Header.mjs.map +1 -0
- package/dist/components/chat/Icons.d.ts +18 -0
- package/dist/components/chat/Icons.js +321 -0
- package/dist/components/chat/Icons.js.map +1 -0
- package/dist/components/chat/Icons.mjs +32 -0
- package/dist/components/chat/Icons.mjs.map +1 -0
- package/dist/components/chat/Input.d.ts +7 -0
- package/dist/components/chat/Input.js +324 -0
- package/dist/components/chat/Input.js.map +1 -0
- package/dist/components/chat/Input.mjs +12 -0
- package/dist/components/chat/Input.mjs.map +1 -0
- package/dist/components/chat/Markdown.d.ts +8 -0
- package/dist/components/chat/Markdown.js +583 -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 +12 -0
- package/dist/components/chat/Messages.js +227 -0
- package/dist/components/chat/Messages.js.map +1 -0
- package/dist/components/chat/Messages.mjs +12 -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 +2743 -0
- package/dist/components/chat/Modal.js.map +1 -0
- package/dist/components/chat/Modal.mjs +36 -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 +2754 -0
- package/dist/components/chat/Popup.js.map +1 -0
- package/dist/components/chat/Popup.mjs +37 -0
- package/dist/components/chat/Popup.mjs.map +1 -0
- package/dist/components/chat/Response.d.ts +7 -0
- package/dist/components/chat/Response.js +64 -0
- package/dist/components/chat/Response.js.map +1 -0
- package/dist/components/chat/Response.mjs +10 -0
- package/dist/components/chat/Response.mjs.map +1 -0
- package/dist/components/chat/Sidebar.d.ts +13 -0
- package/dist/components/chat/Sidebar.js +2763 -0
- package/dist/components/chat/Sidebar.js.map +1 -0
- package/dist/components/chat/Sidebar.mjs +37 -0
- package/dist/components/chat/Sidebar.mjs.map +1 -0
- package/dist/components/chat/Suggestion.d.ts +14 -0
- package/dist/components/chat/Suggestion.js +181 -0
- package/dist/components/chat/Suggestion.js.map +1 -0
- package/dist/components/chat/Suggestion.mjs +11 -0
- package/dist/components/chat/Suggestion.mjs.map +1 -0
- package/dist/components/chat/Textarea.d.ts +13 -0
- package/dist/components/chat/Textarea.js +73 -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 +7 -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 +14 -0
- package/dist/components/chat/index.js +2784 -0
- package/dist/components/chat/index.js.map +1 -0
- package/dist/components/chat/index.mjs +58 -0
- package/dist/components/chat/index.mjs.map +1 -0
- package/dist/components/chat/messages/AssistantMessage.d.ts +7 -0
- package/dist/components/chat/messages/AssistantMessage.js +615 -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/RenderActionExecutionMessage.d.ts +7 -0
- package/dist/components/chat/messages/RenderActionExecutionMessage.js +136 -0
- package/dist/components/chat/messages/RenderActionExecutionMessage.js.map +1 -0
- package/dist/components/chat/messages/RenderActionExecutionMessage.mjs +8 -0
- package/dist/components/chat/messages/RenderActionExecutionMessage.mjs.map +1 -0
- package/dist/components/chat/messages/RenderAgentStateMessage.d.ts +7 -0
- package/dist/components/chat/messages/RenderAgentStateMessage.js +124 -0
- package/dist/components/chat/messages/RenderAgentStateMessage.js.map +1 -0
- package/dist/components/chat/messages/RenderAgentStateMessage.mjs +8 -0
- package/dist/components/chat/messages/RenderAgentStateMessage.mjs.map +1 -0
- package/dist/components/chat/messages/RenderResultMessage.d.ts +7 -0
- package/dist/components/chat/messages/RenderResultMessage.js +46 -0
- package/dist/components/chat/messages/RenderResultMessage.js.map +1 -0
- package/dist/components/chat/messages/RenderResultMessage.mjs +8 -0
- package/dist/components/chat/messages/RenderResultMessage.mjs.map +1 -0
- package/dist/components/chat/messages/RenderTextMessage.d.ts +7 -0
- package/dist/components/chat/messages/RenderTextMessage.js +59 -0
- package/dist/components/chat/messages/RenderTextMessage.js.map +1 -0
- package/dist/components/chat/messages/RenderTextMessage.mjs +8 -0
- package/dist/components/chat/messages/RenderTextMessage.mjs.map +1 -0
- package/dist/components/chat/messages/UserMessage.d.ts +7 -0
- package/dist/components/chat/messages/UserMessage.js +34 -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 +81 -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 +10 -0
- package/dist/components/dev-console/console.js +720 -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 +120 -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 +5 -0
- package/dist/components/dev-console/index.js +720 -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 +188 -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 +255 -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 +253 -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 +17 -0
- package/dist/components/index.js +2788 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/index.mjs +65 -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 +1 -0
- package/dist/hooks/index.js +55 -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 +83 -0
- package/dist/hooks/use-copilot-chat-suggestions.js +53 -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-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 +751 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +2816 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +73 -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/lib/utils.test.d.ts +2 -0
- package/dist/lib/utils.test.js +9 -0
- package/dist/lib/utils.test.js.map +1 -0
- package/dist/lib/utils.test.mjs +7 -0
- package/dist/lib/utils.test.mjs.map +1 -0
- package/dist/types/css.d.ts +16 -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 +2 -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 +8 -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/jest.config.js +5 -0
- package/package.json +78 -0
- package/postcss.config.js +60 -0
- package/src/components/chat/Button.tsx +18 -0
- package/src/components/chat/Chat.tsx +541 -0
- package/src/components/chat/ChatContext.tsx +188 -0
- package/src/components/chat/CodeBlock.tsx +408 -0
- package/src/components/chat/Header.tsx +15 -0
- package/src/components/chat/Icons.tsx +223 -0
- package/src/components/chat/Input.tsx +100 -0
- package/src/components/chat/Markdown.tsx +80 -0
- package/src/components/chat/Messages.tsx +188 -0
- package/src/components/chat/Modal.tsx +124 -0
- package/src/components/chat/Popup.tsx +57 -0
- package/src/components/chat/Response.tsx +12 -0
- package/src/components/chat/Sidebar.tsx +74 -0
- package/src/components/chat/Suggestion.tsx +125 -0
- package/src/components/chat/Textarea.tsx +61 -0
- package/src/components/chat/Window.tsx +153 -0
- package/src/components/chat/index.tsx +8 -0
- package/src/components/chat/messages/AssistantMessage.tsx +20 -0
- package/src/components/chat/messages/RenderActionExecutionMessage.tsx +122 -0
- package/src/components/chat/messages/RenderAgentStateMessage.tsx +112 -0
- package/src/components/chat/messages/RenderResultMessage.tsx +17 -0
- package/src/components/chat/messages/RenderTextMessage.tsx +29 -0
- package/src/components/chat/messages/UserMessage.tsx +5 -0
- package/src/components/chat/props.ts +92 -0
- package/src/components/dev-console/console.tsx +281 -0
- package/src/components/dev-console/icons.tsx +92 -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 +162 -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 +164 -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 +56 -0
- package/src/css/colors.css +12 -0
- package/src/css/console.css +134 -0
- package/src/css/header.css +43 -0
- package/src/css/input.css +89 -0
- package/src/css/markdown.css +136 -0
- package/src/css/messages.css +73 -0
- package/src/css/panel.css +38 -0
- package/src/css/popup.css +22 -0
- package/src/css/response.css +26 -0
- package/src/css/sidebar.css +34 -0
- package/src/css/suggestions.css +35 -0
- package/src/css/window.css +60 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/use-copilot-chat-suggestions.tsx +112 -0
- package/src/hooks/use-copy-to-clipboard.tsx +29 -0
- package/src/hooks/use-push-to-talk.tsx +166 -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 +15 -0
- package/src/types/index.ts +1 -0
- package/src/types/suggestions.ts +6 -0
- package/tailwind.config.js +7 -0
- package/tsconfig.json +12 -0
- package/tsup.config.ts +16 -0
- package/typedoc.json +4 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { MessageStatusCode } from "@copilotkit/runtime-client-gql";
|
|
2
|
+
import { RenderMessageProps } from "../props";
|
|
3
|
+
import { RenderFunctionStatus, useCopilotContext } from "@copilotkit/react-core";
|
|
4
|
+
|
|
5
|
+
export function RenderActionExecutionMessage(props: RenderMessageProps) {
|
|
6
|
+
const { chatComponentsCache } = useCopilotContext();
|
|
7
|
+
const { message, inProgress, index, isCurrentMessage, actionResult, AssistantMessage } = props;
|
|
8
|
+
|
|
9
|
+
if (message.isActionExecutionMessage()) {
|
|
10
|
+
if (
|
|
11
|
+
chatComponentsCache.current !== null &&
|
|
12
|
+
(chatComponentsCache.current.actions[message.name] ||
|
|
13
|
+
chatComponentsCache.current.actions["*"])
|
|
14
|
+
) {
|
|
15
|
+
const render =
|
|
16
|
+
chatComponentsCache.current.actions[message.name] ||
|
|
17
|
+
chatComponentsCache.current.actions["*"];
|
|
18
|
+
// render a static string
|
|
19
|
+
if (typeof render === "string") {
|
|
20
|
+
// when render is static, we show it only when in progress
|
|
21
|
+
if (isCurrentMessage && inProgress) {
|
|
22
|
+
return (
|
|
23
|
+
<AssistantMessage
|
|
24
|
+
rawData={message}
|
|
25
|
+
key={index}
|
|
26
|
+
data-message-role="assistant"
|
|
27
|
+
isLoading={false}
|
|
28
|
+
isGenerating={true}
|
|
29
|
+
message={render}
|
|
30
|
+
/>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
// Done - silent by default to avoid a series of "done" messages
|
|
34
|
+
else {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// render is a function
|
|
39
|
+
else {
|
|
40
|
+
const args = message.arguments;
|
|
41
|
+
|
|
42
|
+
let status: RenderFunctionStatus = "inProgress";
|
|
43
|
+
|
|
44
|
+
if (actionResult !== undefined) {
|
|
45
|
+
status = "complete";
|
|
46
|
+
} else if (message.status.code !== MessageStatusCode.Pending) {
|
|
47
|
+
status = "executing";
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
const toRender = render({
|
|
52
|
+
status: status as any,
|
|
53
|
+
args,
|
|
54
|
+
result: actionResult,
|
|
55
|
+
name: message.name,
|
|
56
|
+
});
|
|
57
|
+
// No result and complete: stay silent
|
|
58
|
+
if (!toRender && status === "complete") {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
if (typeof toRender === "string") {
|
|
62
|
+
return (
|
|
63
|
+
<AssistantMessage
|
|
64
|
+
rawData={message}
|
|
65
|
+
data-message-role="assistant"
|
|
66
|
+
key={index}
|
|
67
|
+
isLoading={false}
|
|
68
|
+
isGenerating={false}
|
|
69
|
+
message={toRender}
|
|
70
|
+
/>
|
|
71
|
+
);
|
|
72
|
+
} else {
|
|
73
|
+
return (
|
|
74
|
+
<AssistantMessage
|
|
75
|
+
rawData={message}
|
|
76
|
+
data-message-role="action-render"
|
|
77
|
+
key={index}
|
|
78
|
+
isLoading={false}
|
|
79
|
+
isGenerating={false}
|
|
80
|
+
subComponent={toRender}
|
|
81
|
+
/>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
} catch (e) {
|
|
85
|
+
console.error(`Error executing render function for action ${message.name}: ${e}`);
|
|
86
|
+
return (
|
|
87
|
+
<AssistantMessage
|
|
88
|
+
rawData={message}
|
|
89
|
+
data-message-role="assistant"
|
|
90
|
+
key={index}
|
|
91
|
+
isLoading={false}
|
|
92
|
+
isGenerating={false}
|
|
93
|
+
subComponent={
|
|
94
|
+
<div>
|
|
95
|
+
<b>❌ Error executing render: {message.name}</b>
|
|
96
|
+
<br />
|
|
97
|
+
{e instanceof Error ? e.message : String(e)}
|
|
98
|
+
</div>
|
|
99
|
+
}
|
|
100
|
+
/>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
// No render function found- show the default message
|
|
106
|
+
else if (!inProgress || !isCurrentMessage) {
|
|
107
|
+
// Done - silent by default to avoid a series of "done" messages
|
|
108
|
+
return null;
|
|
109
|
+
} else {
|
|
110
|
+
// In progress
|
|
111
|
+
return (
|
|
112
|
+
<AssistantMessage
|
|
113
|
+
rawData={message}
|
|
114
|
+
key={index}
|
|
115
|
+
data-message-role="assistant"
|
|
116
|
+
isLoading={true}
|
|
117
|
+
isGenerating={true}
|
|
118
|
+
/>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { RenderMessageProps } from "../props";
|
|
2
|
+
import { CoagentInChatRenderFunction, useCopilotContext } from "@copilotkit/react-core";
|
|
3
|
+
|
|
4
|
+
export function RenderAgentStateMessage(props: RenderMessageProps) {
|
|
5
|
+
const { chatComponentsCache } = useCopilotContext();
|
|
6
|
+
const { message, inProgress, index, isCurrentMessage, AssistantMessage } = props;
|
|
7
|
+
|
|
8
|
+
if (message.isAgentStateMessage()) {
|
|
9
|
+
let render: string | CoagentInChatRenderFunction | undefined;
|
|
10
|
+
|
|
11
|
+
if (chatComponentsCache.current !== null) {
|
|
12
|
+
render =
|
|
13
|
+
chatComponentsCache.current.coAgentStateRenders[
|
|
14
|
+
`${message.agentName}-${message.nodeName}`
|
|
15
|
+
] || chatComponentsCache.current.coAgentStateRenders[`${message.agentName}-global`];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (render) {
|
|
19
|
+
// render a static string
|
|
20
|
+
if (typeof render === "string") {
|
|
21
|
+
// when render is static, we show it only when in progress
|
|
22
|
+
if (isCurrentMessage && inProgress) {
|
|
23
|
+
return (
|
|
24
|
+
<AssistantMessage
|
|
25
|
+
rawData={message}
|
|
26
|
+
message={render}
|
|
27
|
+
data-message-role="assistant"
|
|
28
|
+
key={index}
|
|
29
|
+
isLoading={true}
|
|
30
|
+
isGenerating={true}
|
|
31
|
+
/>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
// Done - silent by default to avoid a series of "done" messages
|
|
35
|
+
else {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
// render is a function
|
|
40
|
+
else {
|
|
41
|
+
const state = message.state;
|
|
42
|
+
|
|
43
|
+
let status = message.active ? "inProgress" : "complete";
|
|
44
|
+
|
|
45
|
+
const toRender = render({
|
|
46
|
+
status: status as any,
|
|
47
|
+
state,
|
|
48
|
+
nodeName: message.nodeName,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// No result and complete: stay silent
|
|
52
|
+
if (!toRender && status === "complete") {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (!toRender && isCurrentMessage && inProgress) {
|
|
57
|
+
return (
|
|
58
|
+
<AssistantMessage
|
|
59
|
+
data-message-role="assistant"
|
|
60
|
+
key={index}
|
|
61
|
+
rawData={message}
|
|
62
|
+
isLoading={true}
|
|
63
|
+
isGenerating={true}
|
|
64
|
+
/>
|
|
65
|
+
);
|
|
66
|
+
} else if (!toRender) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (typeof toRender === "string") {
|
|
71
|
+
return (
|
|
72
|
+
<AssistantMessage
|
|
73
|
+
rawData={message}
|
|
74
|
+
message={toRender}
|
|
75
|
+
isLoading={true}
|
|
76
|
+
isGenerating={true}
|
|
77
|
+
data-message-role="assistant"
|
|
78
|
+
key={index}
|
|
79
|
+
/>
|
|
80
|
+
);
|
|
81
|
+
} else {
|
|
82
|
+
return (
|
|
83
|
+
<AssistantMessage
|
|
84
|
+
rawData={message}
|
|
85
|
+
data-message-role="agent-state-render"
|
|
86
|
+
key={index}
|
|
87
|
+
isLoading={false}
|
|
88
|
+
isGenerating={false}
|
|
89
|
+
subComponent={toRender}
|
|
90
|
+
/>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
// No render function found- show the default message
|
|
96
|
+
else if (!inProgress || !isCurrentMessage) {
|
|
97
|
+
// Done - silent by default to avoid a series of "done" messages
|
|
98
|
+
return null;
|
|
99
|
+
} else {
|
|
100
|
+
// In progress
|
|
101
|
+
return (
|
|
102
|
+
<AssistantMessage
|
|
103
|
+
rawData={message}
|
|
104
|
+
isLoading={true}
|
|
105
|
+
isGenerating={true}
|
|
106
|
+
data-message-role="assistant"
|
|
107
|
+
key={index}
|
|
108
|
+
/>
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { RenderMessageProps } from "../props";
|
|
2
|
+
|
|
3
|
+
export function RenderResultMessage(props: RenderMessageProps) {
|
|
4
|
+
const { message, inProgress, index, isCurrentMessage, AssistantMessage } = props;
|
|
5
|
+
|
|
6
|
+
if (message.isResultMessage() && inProgress && isCurrentMessage) {
|
|
7
|
+
return (
|
|
8
|
+
<AssistantMessage
|
|
9
|
+
key={index}
|
|
10
|
+
data-message-role="assistant"
|
|
11
|
+
rawData={message}
|
|
12
|
+
isLoading={true}
|
|
13
|
+
isGenerating={true}
|
|
14
|
+
/>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { RenderMessageProps } from "../props";
|
|
2
|
+
|
|
3
|
+
export function RenderTextMessage(props: RenderMessageProps) {
|
|
4
|
+
const { message, inProgress, index, isCurrentMessage, UserMessage, AssistantMessage } = props;
|
|
5
|
+
|
|
6
|
+
if (message.isTextMessage()) {
|
|
7
|
+
if (message.role === "user") {
|
|
8
|
+
return (
|
|
9
|
+
<UserMessage
|
|
10
|
+
key={index}
|
|
11
|
+
data-message-role="user"
|
|
12
|
+
message={message.content}
|
|
13
|
+
rawData={message}
|
|
14
|
+
/>
|
|
15
|
+
);
|
|
16
|
+
} else if (message.role == "assistant") {
|
|
17
|
+
return (
|
|
18
|
+
<AssistantMessage
|
|
19
|
+
key={index}
|
|
20
|
+
data-message-role="assistant"
|
|
21
|
+
message={message.content}
|
|
22
|
+
rawData={message}
|
|
23
|
+
isLoading={inProgress && isCurrentMessage && !message.content}
|
|
24
|
+
isGenerating={inProgress && isCurrentMessage && !!message.content}
|
|
25
|
+
/>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { Message } from "@copilotkit/runtime-client-gql";
|
|
2
|
+
|
|
3
|
+
export interface ButtonProps {}
|
|
4
|
+
|
|
5
|
+
export interface WindowProps {
|
|
6
|
+
clickOutsideToClose: boolean;
|
|
7
|
+
hitEscapeToClose: boolean;
|
|
8
|
+
shortcut: string;
|
|
9
|
+
children?: React.ReactNode;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface HeaderProps {}
|
|
13
|
+
|
|
14
|
+
export interface SuggestionsProps {
|
|
15
|
+
title: string;
|
|
16
|
+
message: string;
|
|
17
|
+
partial?: boolean;
|
|
18
|
+
className?: string;
|
|
19
|
+
onClick: (message: string) => void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface MessagesProps {
|
|
23
|
+
messages: Message[];
|
|
24
|
+
inProgress: boolean;
|
|
25
|
+
children?: React.ReactNode;
|
|
26
|
+
AssistantMessage: React.ComponentType<AssistantMessageProps>;
|
|
27
|
+
UserMessage: React.ComponentType<UserMessageProps>;
|
|
28
|
+
RenderTextMessage: React.ComponentType<RenderMessageProps>;
|
|
29
|
+
RenderActionExecutionMessage: React.ComponentType<RenderMessageProps>;
|
|
30
|
+
RenderAgentStateMessage: React.ComponentType<RenderMessageProps>;
|
|
31
|
+
RenderResultMessage: React.ComponentType<RenderMessageProps>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface Renderer {
|
|
35
|
+
content: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface UserMessageProps {
|
|
39
|
+
message?: string;
|
|
40
|
+
rawData: any;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface AssistantMessageProps {
|
|
44
|
+
/**
|
|
45
|
+
* The message content from the assistant
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
message?: string;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The raw data from the assistant's response
|
|
52
|
+
*/
|
|
53
|
+
rawData: any;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* A component that was decided to render by the LLM.
|
|
57
|
+
* When working with useCopilotActions and useCoAgentStateRender, this will be
|
|
58
|
+
* the render component that was specified.
|
|
59
|
+
*/
|
|
60
|
+
subComponent?: React.JSX.Element;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Whether a response is loading, this is when the LLM is thinking of a response but hasn't finished yet.
|
|
64
|
+
*/
|
|
65
|
+
isLoading: boolean;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Whether a response is generating, this is when the LLM is actively generating and streaming content.
|
|
69
|
+
*/
|
|
70
|
+
isGenerating: boolean;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface RenderMessageProps {
|
|
74
|
+
message: Message;
|
|
75
|
+
inProgress: boolean;
|
|
76
|
+
index: number;
|
|
77
|
+
isCurrentMessage: boolean;
|
|
78
|
+
actionResult?: string;
|
|
79
|
+
AssistantMessage: React.ComponentType<AssistantMessageProps>;
|
|
80
|
+
UserMessage: React.ComponentType<UserMessageProps>;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface InputProps {
|
|
84
|
+
inProgress: boolean;
|
|
85
|
+
onSend: (text: string) => Promise<Message>;
|
|
86
|
+
isVisible?: boolean;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface ResponseButtonProps {
|
|
90
|
+
onClick: () => void;
|
|
91
|
+
inProgress: boolean;
|
|
92
|
+
}
|
|
@@ -0,0 +1,281 @@
|
|
|
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
|
+
useEffect(() => {
|
|
86
|
+
const handleResize = (entries: ResizeObserverEntry[]) => {
|
|
87
|
+
for (let entry of entries) {
|
|
88
|
+
if (entry.target === consoleRef.current) {
|
|
89
|
+
const width = entry.contentRect.width;
|
|
90
|
+
if (width < 400) {
|
|
91
|
+
setDebugButtonMode("compact");
|
|
92
|
+
} else {
|
|
93
|
+
setDebugButtonMode("full");
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const observer = new ResizeObserver(handleResize);
|
|
100
|
+
if (consoleRef.current) {
|
|
101
|
+
observer.observe(consoleRef.current);
|
|
102
|
+
|
|
103
|
+
const initialWidth = consoleRef.current.getBoundingClientRect().width;
|
|
104
|
+
if (initialWidth < 400) {
|
|
105
|
+
setDebugButtonMode("compact");
|
|
106
|
+
} else {
|
|
107
|
+
setDebugButtonMode("full");
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return () => {
|
|
112
|
+
if (consoleRef.current) {
|
|
113
|
+
observer.unobserve(consoleRef.current);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
}, [consoleRef.current]);
|
|
117
|
+
|
|
118
|
+
if (!showDevConsole) {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
return (
|
|
122
|
+
<div
|
|
123
|
+
ref={consoleRef}
|
|
124
|
+
className={
|
|
125
|
+
"copilotKitDevConsole " +
|
|
126
|
+
(versionStatus === "update-available" ? "copilotKitDevConsoleUpgrade" : "") +
|
|
127
|
+
(versionStatus === "outdated" ? "copilotKitDevConsoleWarnOutdated" : "")
|
|
128
|
+
}
|
|
129
|
+
>
|
|
130
|
+
<div className="copilotKitDevConsoleLogo">
|
|
131
|
+
<a href="https://copilotkit.ai" target="_blank">
|
|
132
|
+
{CopilotKitIcon}
|
|
133
|
+
</a>
|
|
134
|
+
</div>
|
|
135
|
+
<VersionInfo
|
|
136
|
+
showDevConsole={context.showDevConsole}
|
|
137
|
+
versionStatus={versionStatus}
|
|
138
|
+
currentVersion={currentVersion}
|
|
139
|
+
latestVersion={latestVersion}
|
|
140
|
+
/>
|
|
141
|
+
|
|
142
|
+
<CopilotKitHelpModal />
|
|
143
|
+
|
|
144
|
+
<DebugMenuButton
|
|
145
|
+
setShowDevConsole={setShowDevConsole}
|
|
146
|
+
checkForUpdates={checkForUpdates}
|
|
147
|
+
mode={debugButtonMode}
|
|
148
|
+
/>
|
|
149
|
+
</div>
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function VersionInfo({
|
|
154
|
+
showDevConsole,
|
|
155
|
+
versionStatus,
|
|
156
|
+
currentVersion,
|
|
157
|
+
latestVersion,
|
|
158
|
+
}: {
|
|
159
|
+
showDevConsole: boolean | "auto";
|
|
160
|
+
versionStatus: VersionStatus;
|
|
161
|
+
currentVersion: string;
|
|
162
|
+
latestVersion: string;
|
|
163
|
+
}) {
|
|
164
|
+
const [copyStatus, setCopyStatus] = useState<string>("");
|
|
165
|
+
|
|
166
|
+
let versionLabel = "";
|
|
167
|
+
let versionIcon: any = "";
|
|
168
|
+
let currentVersionLabel = currentVersion;
|
|
169
|
+
|
|
170
|
+
if (versionStatus === "latest") {
|
|
171
|
+
versionLabel = "latest";
|
|
172
|
+
versionIcon = CheckIcon;
|
|
173
|
+
} else if (versionStatus === "checking") {
|
|
174
|
+
versionLabel = "checking";
|
|
175
|
+
versionIcon = SmallSpinnerIcon;
|
|
176
|
+
} else if (versionStatus === "update-available") {
|
|
177
|
+
versionLabel = "update available";
|
|
178
|
+
versionIcon = ExclamationMarkIcon;
|
|
179
|
+
currentVersionLabel = `${currentVersion} → ${latestVersion}`;
|
|
180
|
+
} else if (versionStatus === "outdated") {
|
|
181
|
+
versionLabel = "outdated";
|
|
182
|
+
versionIcon = ExclamationMarkTriangleIcon;
|
|
183
|
+
currentVersionLabel = `${currentVersion} → ${latestVersion}`;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
let asideLabel = "";
|
|
187
|
+
if (showDevConsole === "auto") {
|
|
188
|
+
asideLabel = "(localhost only)";
|
|
189
|
+
} else if (showDevConsole === true) {
|
|
190
|
+
asideLabel = "(always on)";
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const installCommand = [
|
|
194
|
+
`npm install`,
|
|
195
|
+
`@copilotkit/react-core@${latestVersion}`,
|
|
196
|
+
`@copilotkit/react-ui@${latestVersion}`,
|
|
197
|
+
`@copilotkit/react-textarea@${latestVersion}`,
|
|
198
|
+
].join(" ");
|
|
199
|
+
|
|
200
|
+
const handleCopyClick = () => {
|
|
201
|
+
navigator.clipboard.writeText(installCommand.trim()).then(() => {
|
|
202
|
+
setCopyStatus("Command copied to clipboard!");
|
|
203
|
+
setTimeout(() => setCopyStatus(""), 1000);
|
|
204
|
+
});
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
return (
|
|
208
|
+
<div className="copilotKitVersionInfo">
|
|
209
|
+
<header>
|
|
210
|
+
COPILOTKIT DEV CONSOLE{showDevConsole === "auto" && <aside>{asideLabel}</aside>}
|
|
211
|
+
</header>
|
|
212
|
+
<section>
|
|
213
|
+
Version: {versionLabel} ({currentVersionLabel}) {versionIcon}
|
|
214
|
+
</section>
|
|
215
|
+
{(versionStatus === "update-available" || versionStatus === "outdated") && (
|
|
216
|
+
<footer>
|
|
217
|
+
<button onClick={handleCopyClick}>{copyStatus || installCommand}</button>
|
|
218
|
+
</footer>
|
|
219
|
+
)}
|
|
220
|
+
</div>
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
export default function DebugMenuButton({
|
|
224
|
+
setShowDevConsole,
|
|
225
|
+
checkForUpdates,
|
|
226
|
+
mode,
|
|
227
|
+
}: {
|
|
228
|
+
setShowDevConsole: (show: boolean) => void;
|
|
229
|
+
checkForUpdates: (force: boolean) => void;
|
|
230
|
+
mode: "full" | "compact";
|
|
231
|
+
}) {
|
|
232
|
+
const context = useCopilotContext();
|
|
233
|
+
const messagesContext = useCopilotMessagesContext();
|
|
234
|
+
|
|
235
|
+
return (
|
|
236
|
+
<div className="bg-black top-24 w-52 text-right">
|
|
237
|
+
<Menu>
|
|
238
|
+
<MenuButton className={`copilotKitDebugMenuButton ${mode === "compact" ? "compact" : ""}`}>
|
|
239
|
+
{mode == "compact" ? "Debug" : <>Debug {ChevronDownIcon}</>}
|
|
240
|
+
</MenuButton>
|
|
241
|
+
|
|
242
|
+
<MenuItems
|
|
243
|
+
transition
|
|
244
|
+
anchor="bottom end"
|
|
245
|
+
className="copilotKitDebugMenu"
|
|
246
|
+
style={{ zIndex: 40 }}
|
|
247
|
+
>
|
|
248
|
+
<MenuItem>
|
|
249
|
+
<button className="copilotKitDebugMenuItem" onClick={() => logReadables(context)}>
|
|
250
|
+
Log Readables
|
|
251
|
+
</button>
|
|
252
|
+
</MenuItem>
|
|
253
|
+
<MenuItem>
|
|
254
|
+
<button className="copilotKitDebugMenuItem" onClick={() => logActions(context)}>
|
|
255
|
+
Log Actions
|
|
256
|
+
</button>
|
|
257
|
+
</MenuItem>
|
|
258
|
+
<MenuItem>
|
|
259
|
+
<button
|
|
260
|
+
className="copilotKitDebugMenuItem"
|
|
261
|
+
onClick={() => logMessages(messagesContext)}
|
|
262
|
+
>
|
|
263
|
+
Log Messages
|
|
264
|
+
</button>
|
|
265
|
+
</MenuItem>
|
|
266
|
+
<MenuItem>
|
|
267
|
+
<button className="copilotKitDebugMenuItem" onClick={() => checkForUpdates(true)}>
|
|
268
|
+
Check for Updates
|
|
269
|
+
</button>
|
|
270
|
+
</MenuItem>
|
|
271
|
+
<hr />
|
|
272
|
+
<MenuItem>
|
|
273
|
+
<button className="copilotKitDebugMenuItem" onClick={() => setShowDevConsole(false)}>
|
|
274
|
+
Hide Dev Console
|
|
275
|
+
</button>
|
|
276
|
+
</MenuItem>
|
|
277
|
+
</MenuItems>
|
|
278
|
+
</Menu>
|
|
279
|
+
</div>
|
|
280
|
+
);
|
|
281
|
+
}
|