@copilotkit/vue 1.57.1
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/AGENTS.md +50 -0
- package/CHANGELOG.md +13 -0
- package/PARITY.md +434 -0
- package/README.md +396 -0
- package/dist/components/copilot-provider/CopilotKit.vue.d.ts +20 -0
- package/dist/components/copilot-provider/CopilotKit.vue.d.ts.map +1 -0
- package/dist/components/copilot-provider/index.d.ts +3 -0
- package/dist/components/copilot-provider/index.d.ts.map +1 -0
- package/dist/components/copilot-provider/types.d.ts +22 -0
- package/dist/components/copilot-provider/types.d.ts.map +1 -0
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/use-copilot-action.d.ts +27 -0
- package/dist/hooks/use-copilot-action.d.ts.map +1 -0
- package/dist/hooks/use-copilot-readable.d.ts +20 -0
- package/dist/hooks/use-copilot-readable.d.ts.map +1 -0
- package/dist/hooks/use-frontend-tool.d.ts +21 -0
- package/dist/hooks/use-frontend-tool.d.ts.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +10 -0
- package/dist/index.d.mts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +252 -0
- package/dist/index.mjs.map +1 -0
- package/dist/styles.css +2 -0
- package/dist/use-render-activity-message-BRL1Rpl-.cjs +85 -0
- package/dist/use-render-activity-message-BRL1Rpl-.cjs.map +1 -0
- package/dist/use-render-activity-message-CqtxiFSs.js +8927 -0
- package/dist/use-render-activity-message-CqtxiFSs.js.map +1 -0
- package/dist/v2/components/A2UIMessageRenderer.d.ts +9 -0
- package/dist/v2/components/A2UIMessageRenderer.d.ts.map +1 -0
- package/dist/v2/components/A2UISurfaceActivityRenderer.vue.d.ts +16 -0
- package/dist/v2/components/A2UISurfaceActivityRenderer.vue.d.ts.map +1 -0
- package/dist/v2/components/CopilotKitInspector.vue.d.ts +7 -0
- package/dist/v2/components/CopilotKitInspector.vue.d.ts.map +1 -0
- package/dist/v2/components/InlineFeatureWarning.vue.d.ts +6 -0
- package/dist/v2/components/InlineFeatureWarning.vue.d.ts.map +1 -0
- package/dist/v2/components/LicenseWarningBanner.vue.d.ts +18 -0
- package/dist/v2/components/LicenseWarningBanner.vue.d.ts.map +1 -0
- package/dist/v2/components/MCPAppsActivityRenderer.d.ts +88 -0
- package/dist/v2/components/MCPAppsActivityRenderer.d.ts.map +1 -0
- package/dist/v2/components/OpenGenerativeUIRenderer.d.ts +154 -0
- package/dist/v2/components/OpenGenerativeUIRenderer.d.ts.map +1 -0
- package/dist/v2/components/a2ui/A2UIBuiltInToolCallRenderer.d.ts +19 -0
- package/dist/v2/components/a2ui/A2UIBuiltInToolCallRenderer.d.ts.map +1 -0
- package/dist/v2/components/a2ui/A2UICatalogContext.d.ts +16 -0
- package/dist/v2/components/a2ui/A2UICatalogContext.d.ts.map +1 -0
- package/dist/v2/components/a2ui/VueSurface.d.ts +62 -0
- package/dist/v2/components/a2ui/VueSurface.d.ts.map +1 -0
- package/dist/v2/components/a2ui/adapter.d.ts +38 -0
- package/dist/v2/components/a2ui/adapter.d.ts.map +1 -0
- package/dist/v2/components/a2ui/catalog.d.ts +29 -0
- package/dist/v2/components/a2ui/catalog.d.ts.map +1 -0
- package/dist/v2/components/a2ui/index.d.ts +5 -0
- package/dist/v2/components/a2ui/index.d.ts.map +1 -0
- package/dist/v2/components/a2ui/utils.d.ts +18 -0
- package/dist/v2/components/a2ui/utils.d.ts.map +1 -0
- package/dist/v2/components/a2ui.d.ts +12 -0
- package/dist/v2/components/a2ui.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChat.vue.d.ts +50 -0
- package/dist/v2/components/chat/CopilotChat.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatAssistantMessage.vue.d.ts +164 -0
- package/dist/v2/components/chat/CopilotChatAssistantMessage.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatAttachmentQueue.vue.d.ts +12 -0
- package/dist/v2/components/chat/CopilotChatAttachmentQueue.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatAttachmentRenderer.vue.d.ts +7 -0
- package/dist/v2/components/chat/CopilotChatAttachmentRenderer.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatAudioRecorder.vue.d.ts +12 -0
- package/dist/v2/components/chat/CopilotChatAudioRecorder.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatInput.vue.d.ts +290 -0
- package/dist/v2/components/chat/CopilotChatInput.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatMessageView.vue.d.ts +72 -0
- package/dist/v2/components/chat/CopilotChatMessageView.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatReasoningMessage.vue.d.ts +65 -0
- package/dist/v2/components/chat/CopilotChatReasoningMessage.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatSuggestionPill.vue.d.ts +27 -0
- package/dist/v2/components/chat/CopilotChatSuggestionPill.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatSuggestionView.vue.d.ts +26 -0
- package/dist/v2/components/chat/CopilotChatSuggestionView.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatToggleButton.vue.d.ts +17 -0
- package/dist/v2/components/chat/CopilotChatToggleButton.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatToggleButtonCloseIcon.d.ts +5 -0
- package/dist/v2/components/chat/CopilotChatToggleButtonCloseIcon.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatToggleButtonOpenIcon.d.ts +5 -0
- package/dist/v2/components/chat/CopilotChatToggleButtonOpenIcon.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatToolCallsView.vue.d.ts +21 -0
- package/dist/v2/components/chat/CopilotChatToolCallsView.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatUserMessage.vue.d.ts +34 -0
- package/dist/v2/components/chat/CopilotChatUserMessage.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatView.vue.d.ts +106 -0
- package/dist/v2/components/chat/CopilotChatView.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotModalHeader.vue.d.ts +15 -0
- package/dist/v2/components/chat/CopilotModalHeader.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotModalHeaderCloseButton.d.ts +5 -0
- package/dist/v2/components/chat/CopilotModalHeaderCloseButton.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotModalHeaderTitle.d.ts +5 -0
- package/dist/v2/components/chat/CopilotModalHeaderTitle.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotPopup.vue.d.ts +50 -0
- package/dist/v2/components/chat/CopilotPopup.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotPopupView.vue.d.ts +55 -0
- package/dist/v2/components/chat/CopilotPopupView.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotPopupViewInternal.vue.d.ts +55 -0
- package/dist/v2/components/chat/CopilotPopupViewInternal.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotPopupWelcomeScreen.vue.d.ts +28 -0
- package/dist/v2/components/chat/CopilotPopupWelcomeScreen.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotSidebar.vue.d.ts +48 -0
- package/dist/v2/components/chat/CopilotSidebar.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotSidebarView.vue.d.ts +62 -0
- package/dist/v2/components/chat/CopilotSidebarView.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotSidebarViewInternal.vue.d.ts +53 -0
- package/dist/v2/components/chat/CopilotSidebarViewInternal.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotSidebarWelcomeScreen.vue.d.ts +28 -0
- package/dist/v2/components/chat/CopilotSidebarWelcomeScreen.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/audioRecorder.d.ts +11 -0
- package/dist/v2/components/chat/audioRecorder.d.ts.map +1 -0
- package/dist/v2/components/chat/index.d.ts +682 -0
- package/dist/v2/components/chat/index.d.ts.map +1 -0
- package/dist/v2/components/chat/last-user-message-context.d.ts +29 -0
- package/dist/v2/components/chat/last-user-message-context.d.ts.map +1 -0
- package/dist/v2/components/chat/normalize-auto-scroll.d.ts +3 -0
- package/dist/v2/components/chat/normalize-auto-scroll.d.ts.map +1 -0
- package/dist/v2/components/chat/types.d.ts +380 -0
- package/dist/v2/components/chat/types.d.ts.map +1 -0
- package/dist/v2/components/icons/index.d.ts +2 -0
- package/dist/v2/components/icons/index.d.ts.map +1 -0
- package/dist/v2/components/index.d.ts +8 -0
- package/dist/v2/components/index.d.ts.map +1 -0
- package/dist/v2/hooks/index.d.ts +24 -0
- package/dist/v2/hooks/index.d.ts.map +1 -0
- package/dist/v2/hooks/use-agent-context.d.ts +24 -0
- package/dist/v2/hooks/use-agent-context.d.ts.map +1 -0
- package/dist/v2/hooks/use-agent.d.ts +53 -0
- package/dist/v2/hooks/use-agent.d.ts.map +1 -0
- package/dist/v2/hooks/use-attachments.d.ts +21 -0
- package/dist/v2/hooks/use-attachments.d.ts.map +1 -0
- package/dist/v2/hooks/use-capabilities.d.ts +16 -0
- package/dist/v2/hooks/use-capabilities.d.ts.map +1 -0
- package/dist/v2/hooks/use-component.d.ts +13 -0
- package/dist/v2/hooks/use-component.d.ts.map +1 -0
- package/dist/v2/hooks/use-configure-suggestions.d.ts +24 -0
- package/dist/v2/hooks/use-configure-suggestions.d.ts.map +1 -0
- package/dist/v2/hooks/use-default-render-tool.d.ts +14 -0
- package/dist/v2/hooks/use-default-render-tool.d.ts.map +1 -0
- package/dist/v2/hooks/use-frontend-tool.d.ts +19 -0
- package/dist/v2/hooks/use-frontend-tool.d.ts.map +1 -0
- package/dist/v2/hooks/use-human-in-the-loop.d.ts +19 -0
- package/dist/v2/hooks/use-human-in-the-loop.d.ts.map +1 -0
- package/dist/v2/hooks/use-interrupt.d.ts +36 -0
- package/dist/v2/hooks/use-interrupt.d.ts.map +1 -0
- package/dist/v2/hooks/use-katex-styles.d.ts +22 -0
- package/dist/v2/hooks/use-katex-styles.d.ts.map +1 -0
- package/dist/v2/hooks/use-keyboard-height.d.ts +33 -0
- package/dist/v2/hooks/use-keyboard-height.d.ts.map +1 -0
- package/dist/v2/hooks/use-pin-to-send.d.ts +28 -0
- package/dist/v2/hooks/use-pin-to-send.d.ts.map +1 -0
- package/dist/v2/hooks/use-render-activity-message.d.ts +21 -0
- package/dist/v2/hooks/use-render-activity-message.d.ts.map +1 -0
- package/dist/v2/hooks/use-render-custom-messages.d.ts +27 -0
- package/dist/v2/hooks/use-render-custom-messages.d.ts.map +1 -0
- package/dist/v2/hooks/use-render-tool.d.ts +36 -0
- package/dist/v2/hooks/use-render-tool.d.ts.map +1 -0
- package/dist/v2/hooks/use-suggestions.d.ts +26 -0
- package/dist/v2/hooks/use-suggestions.d.ts.map +1 -0
- package/dist/v2/hooks/use-threads.d.ts +42 -0
- package/dist/v2/hooks/use-threads.d.ts.map +1 -0
- package/dist/v2/index.cjs +2 -0
- package/dist/v2/index.cjs.map +1 -0
- package/dist/v2/index.d.cts +9 -0
- package/dist/v2/index.d.mts +9 -0
- package/dist/v2/index.d.ts +9 -0
- package/dist/v2/index.d.ts.map +1 -0
- package/dist/v2/index.mjs +75 -0
- package/dist/v2/index.mjs.map +1 -0
- package/dist/v2/lib/processPartialHtml.d.ts +3 -0
- package/dist/v2/lib/processPartialHtml.d.ts.map +1 -0
- package/dist/v2/lib/shallow-stable.d.ts +7 -0
- package/dist/v2/lib/shallow-stable.d.ts.map +1 -0
- package/dist/v2/lib/transcription-client.d.ts +19 -0
- package/dist/v2/lib/transcription-client.d.ts.map +1 -0
- package/dist/v2/lib/vue-core.d.ts +47 -0
- package/dist/v2/lib/vue-core.d.ts.map +1 -0
- package/dist/v2/providers/CopilotChatConfigurationProvider.types.d.ts +15 -0
- package/dist/v2/providers/CopilotChatConfigurationProvider.types.d.ts.map +1 -0
- package/dist/v2/providers/CopilotChatConfigurationProvider.vue.d.ts +17 -0
- package/dist/v2/providers/CopilotChatConfigurationProvider.vue.d.ts.map +1 -0
- package/dist/v2/providers/CopilotKitProvider.types.d.ts +61 -0
- package/dist/v2/providers/CopilotKitProvider.types.d.ts.map +1 -0
- package/dist/v2/providers/CopilotKitProvider.vue.d.ts +37 -0
- package/dist/v2/providers/CopilotKitProvider.vue.d.ts.map +1 -0
- package/dist/v2/providers/SandboxFunctionsContext.d.ts +4 -0
- package/dist/v2/providers/SandboxFunctionsContext.d.ts.map +1 -0
- package/dist/v2/providers/index.d.ts +13 -0
- package/dist/v2/providers/index.d.ts.map +1 -0
- package/dist/v2/providers/keys.d.ts +17 -0
- package/dist/v2/providers/keys.d.ts.map +1 -0
- package/dist/v2/providers/license-context.d.ts +7 -0
- package/dist/v2/providers/license-context.d.ts.map +1 -0
- package/dist/v2/providers/types.d.ts +38 -0
- package/dist/v2/providers/types.d.ts.map +1 -0
- package/dist/v2/providers/useCopilotChatConfiguration.d.ts +4 -0
- package/dist/v2/providers/useCopilotChatConfiguration.d.ts.map +1 -0
- package/dist/v2/providers/useCopilotKit.d.ts +2 -0
- package/dist/v2/providers/useCopilotKit.d.ts.map +1 -0
- package/dist/v2/providers/useLicenseContext.d.ts +14 -0
- package/dist/v2/providers/useLicenseContext.d.ts.map +1 -0
- package/dist/v2/types/a2ui.d.ts +5 -0
- package/dist/v2/types/a2ui.d.ts.map +1 -0
- package/dist/v2/types/defineToolCallRenderer.d.ts +15 -0
- package/dist/v2/types/defineToolCallRenderer.d.ts.map +1 -0
- package/dist/v2/types/frontend-tool.d.ts +6 -0
- package/dist/v2/types/frontend-tool.d.ts.map +1 -0
- package/dist/v2/types/human-in-the-loop.d.ts +29 -0
- package/dist/v2/types/human-in-the-loop.d.ts.map +1 -0
- package/dist/v2/types/index.d.ts +10 -0
- package/dist/v2/types/index.d.ts.map +1 -0
- package/dist/v2/types/interrupt.d.ts +14 -0
- package/dist/v2/types/interrupt.d.ts.map +1 -0
- package/dist/v2/types/sandbox-function.d.ts +8 -0
- package/dist/v2/types/sandbox-function.d.ts.map +1 -0
- package/dist/v2/types/vue-activity-message-renderer.d.ts +18 -0
- package/dist/v2/types/vue-activity-message-renderer.d.ts.map +1 -0
- package/dist/v2/types/vue-custom-message-renderer.d.ts +19 -0
- package/dist/v2/types/vue-custom-message-renderer.d.ts.map +1 -0
- package/dist/v2/types/vue-tool-call-renderer.d.ts +37 -0
- package/dist/v2/types/vue-tool-call-renderer.d.ts.map +1 -0
- package/env.d.ts +7 -0
- package/eslint.config.mjs +42 -0
- package/package.json +130 -0
- package/scripts/scope-preflight.mjs +100 -0
- package/src/components/copilot-provider/CopilotKit.vue +18 -0
- package/src/components/copilot-provider/index.ts +2 -0
- package/src/components/copilot-provider/types.ts +24 -0
- package/src/hooks/index.ts +9 -0
- package/src/hooks/use-copilot-action.ts +168 -0
- package/src/hooks/use-copilot-readable.ts +75 -0
- package/src/hooks/use-frontend-tool.ts +76 -0
- package/src/index.ts +12 -0
- package/src/styles/globals.css +314 -0
- package/src/v2/__tests__/exports.test.ts +35 -0
- package/src/v2/__tests__/mocks/web-inspector.ts +5 -0
- package/src/v2/__tests__/setup.ts +141 -0
- package/src/v2/__tests__/utils/agents.ts +391 -0
- package/src/v2/__tests__/utils/mount.ts +83 -0
- package/src/v2/__tests__/utils/test-helpers.ts +712 -0
- package/src/v2/components/A2UIMessageRenderer.ts +125 -0
- package/src/v2/components/A2UISurfaceActivityRenderer.vue +186 -0
- package/src/v2/components/CopilotKitInspector.vue +42 -0
- package/src/v2/components/InlineFeatureWarning.vue +35 -0
- package/src/v2/components/LicenseWarningBanner.vue +196 -0
- package/src/v2/components/MCPAppsActivityRenderer.ts +778 -0
- package/src/v2/components/OpenGenerativeUIRenderer.ts +550 -0
- package/src/v2/components/__tests__/A2UIMessageRenderer.test.ts +271 -0
- package/src/v2/components/__tests__/CopilotKitInspector.test.ts +57 -0
- package/src/v2/components/__tests__/MCPAppsActivityRenderer.e2e.test.ts +851 -0
- package/src/v2/components/__tests__/MCPAppsActivityRenderer.test.ts +237 -0
- package/src/v2/components/__tests__/OpenGenerativeUIRenderer.test.ts +516 -0
- package/src/v2/components/a2ui/A2UIBuiltInToolCallRenderer.ts +295 -0
- package/src/v2/components/a2ui/A2UICatalogContext.ts +190 -0
- package/src/v2/components/a2ui/VueSurface.ts +144 -0
- package/src/v2/components/a2ui/adapter.ts +156 -0
- package/src/v2/components/a2ui/catalog.ts +858 -0
- package/src/v2/components/a2ui/index.ts +7 -0
- package/src/v2/components/a2ui/utils.ts +67 -0
- package/src/v2/components/a2ui.ts +30 -0
- package/src/v2/components/chat/CopilotChat.vue +777 -0
- package/src/v2/components/chat/CopilotChatAssistantMessage.vue +891 -0
- package/src/v2/components/chat/CopilotChatAttachmentQueue.vue +411 -0
- package/src/v2/components/chat/CopilotChatAttachmentRenderer.vue +87 -0
- package/src/v2/components/chat/CopilotChatAudioRecorder.vue +269 -0
- package/src/v2/components/chat/CopilotChatInput.vue +1271 -0
- package/src/v2/components/chat/CopilotChatMessageView.vue +476 -0
- package/src/v2/components/chat/CopilotChatReasoningMessage.vue +247 -0
- package/src/v2/components/chat/CopilotChatSuggestionPill.vue +56 -0
- package/src/v2/components/chat/CopilotChatSuggestionView.vue +93 -0
- package/src/v2/components/chat/CopilotChatToggleButton.vue +145 -0
- package/src/v2/components/chat/CopilotChatToggleButtonCloseIcon.ts +17 -0
- package/src/v2/components/chat/CopilotChatToggleButtonOpenIcon.ts +18 -0
- package/src/v2/components/chat/CopilotChatToolCallsView.vue +161 -0
- package/src/v2/components/chat/CopilotChatUserMessage.vue +322 -0
- package/src/v2/components/chat/CopilotChatView.vue +740 -0
- package/src/v2/components/chat/CopilotModalHeader.vue +73 -0
- package/src/v2/components/chat/CopilotModalHeaderCloseButton.ts +38 -0
- package/src/v2/components/chat/CopilotModalHeaderTitle.ts +22 -0
- package/src/v2/components/chat/CopilotPopup.vue +182 -0
- package/src/v2/components/chat/CopilotPopupView.vue +168 -0
- package/src/v2/components/chat/CopilotPopupViewInternal.vue +453 -0
- package/src/v2/components/chat/CopilotPopupWelcomeScreen.vue +140 -0
- package/src/v2/components/chat/CopilotSidebar.vue +178 -0
- package/src/v2/components/chat/CopilotSidebarView.vue +172 -0
- package/src/v2/components/chat/CopilotSidebarViewInternal.vue +366 -0
- package/src/v2/components/chat/CopilotSidebarWelcomeScreen.vue +142 -0
- package/src/v2/components/chat/__tests__/CopilotChat.attachments.test.ts +237 -0
- package/src/v2/components/chat/__tests__/CopilotChat.e2e.test.ts +1240 -0
- package/src/v2/components/chat/__tests__/CopilotChat.licenseWarning.test.ts +138 -0
- package/src/v2/components/chat/__tests__/CopilotChat.onError.test.ts +85 -0
- package/src/v2/components/chat/__tests__/CopilotChat.slots.e2e.test.ts +141 -0
- package/src/v2/components/chat/__tests__/CopilotChat.test.ts +652 -0
- package/src/v2/components/chat/__tests__/CopilotChatActivityRendering.e2e.test.ts +683 -0
- package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.slots.e2e.test.ts +768 -0
- package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.test.ts +1108 -0
- package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.thumbs.test.ts +87 -0
- package/src/v2/components/chat/__tests__/CopilotChatAttachmentQueue.test.ts +277 -0
- package/src/v2/components/chat/__tests__/CopilotChatAttachmentRenderer.test.ts +124 -0
- package/src/v2/components/chat/__tests__/CopilotChatCopyButton.clipboard.test.ts +230 -0
- package/src/v2/components/chat/__tests__/CopilotChatInput.bottomAnchored.test.ts +83 -0
- package/src/v2/components/chat/__tests__/CopilotChatInput.slots.e2e.test.ts +1139 -0
- package/src/v2/components/chat/__tests__/CopilotChatInput.test.ts +1051 -0
- package/src/v2/components/chat/__tests__/CopilotChatMessageView.slots.e2e.test.ts +141 -0
- package/src/v2/components/chat/__tests__/CopilotChatMessageView.test.ts +494 -0
- package/src/v2/components/chat/__tests__/CopilotChatPropsRerender.e2e.test.ts +181 -0
- package/src/v2/components/chat/__tests__/CopilotChatReasoningMessage.test.ts +73 -0
- package/src/v2/components/chat/__tests__/CopilotChatSuggestionPill.test.ts +73 -0
- package/src/v2/components/chat/__tests__/CopilotChatSuggestionView.slots.e2e.test.ts +674 -0
- package/src/v2/components/chat/__tests__/CopilotChatSuggestionView.test.ts +91 -0
- package/src/v2/components/chat/__tests__/CopilotChatToggleButton.test.ts +93 -0
- package/src/v2/components/chat/__tests__/CopilotChatToolCallsView.test.ts +382 -0
- package/src/v2/components/chat/__tests__/CopilotChatToolRendering.e2e.test.ts +1019 -0
- package/src/v2/components/chat/__tests__/CopilotChatToolRerenders.e2e.test.ts +516 -0
- package/src/v2/components/chat/__tests__/CopilotChatUserMessage.slots.e2e.test.ts +701 -0
- package/src/v2/components/chat/__tests__/CopilotChatUserMessage.test.ts +337 -0
- package/src/v2/components/chat/__tests__/CopilotChatView.connectingGate.test.ts +135 -0
- package/src/v2/components/chat/__tests__/CopilotChatView.inputOverlay.test.ts +278 -0
- package/src/v2/components/chat/__tests__/CopilotChatView.onClick.e2e.test.ts +1082 -0
- package/src/v2/components/chat/__tests__/CopilotChatView.pinToSend.test.ts +166 -0
- package/src/v2/components/chat/__tests__/CopilotChatView.slots.e2e.test.ts +1145 -0
- package/src/v2/components/chat/__tests__/CopilotChatView.test.ts +374 -0
- package/src/v2/components/chat/__tests__/CopilotModalHeader.slots.e2e.test.ts +636 -0
- package/src/v2/components/chat/__tests__/CopilotModalHeader.test.ts +112 -0
- package/src/v2/components/chat/__tests__/CopilotPopup.test.ts +58 -0
- package/src/v2/components/chat/__tests__/CopilotPopupView.slots.e2e.test.ts +725 -0
- package/src/v2/components/chat/__tests__/CopilotPopupView.test.ts +112 -0
- package/src/v2/components/chat/__tests__/CopilotSidebar.test.ts +58 -0
- package/src/v2/components/chat/__tests__/CopilotSidebarView.slots.e2e.test.ts +603 -0
- package/src/v2/components/chat/__tests__/CopilotSidebarView.test.ts +214 -0
- package/src/v2/components/chat/__tests__/MCPAppsUiMessage.e2e.test.ts +394 -0
- package/src/v2/components/chat/__tests__/copilot-chat-throttle.test.ts +82 -0
- package/src/v2/components/chat/__tests__/normalize-auto-scroll.test.ts +39 -0
- package/src/v2/components/chat/audioRecorder.ts +15 -0
- package/src/v2/components/chat/index.ts +52 -0
- package/src/v2/components/chat/last-user-message-context.ts +39 -0
- package/src/v2/components/chat/normalize-auto-scroll.ts +17 -0
- package/src/v2/components/chat/types.ts +481 -0
- package/src/v2/components/icons/__tests__/icons.test.ts +86 -0
- package/src/v2/components/icons/index.ts +22 -0
- package/src/v2/components/index.ts +7 -0
- package/src/v2/hooks/__tests__/standard-schema-types.test.ts +149 -0
- package/src/v2/hooks/__tests__/standard-schema.test.ts +315 -0
- package/src/v2/hooks/__tests__/use-agent-context-timing.e2e.test.ts +144 -0
- package/src/v2/hooks/__tests__/use-agent-context.test.ts +271 -0
- package/src/v2/hooks/__tests__/use-agent-error-state.test.ts +64 -0
- package/src/v2/hooks/__tests__/use-agent-stability.test.ts +268 -0
- package/src/v2/hooks/__tests__/use-agent-thread-isolation.test.ts +433 -0
- package/src/v2/hooks/__tests__/use-agent-throttle.test.ts +747 -0
- package/src/v2/hooks/__tests__/use-agent.e2e.test.ts +187 -0
- package/src/v2/hooks/__tests__/use-agent.test.ts +126 -0
- package/src/v2/hooks/__tests__/use-attachments.test.ts +181 -0
- package/src/v2/hooks/__tests__/use-component.test.ts +145 -0
- package/src/v2/hooks/__tests__/use-configure-suggestions.e2e.test.ts +527 -0
- package/src/v2/hooks/__tests__/use-configure-suggestions.test.ts +399 -0
- package/src/v2/hooks/__tests__/use-default-render-tool.test.ts +214 -0
- package/src/v2/hooks/__tests__/use-frontend-tool-available.test.ts +220 -0
- package/src/v2/hooks/__tests__/use-frontend-tool.e2e.test.ts +2320 -0
- package/src/v2/hooks/__tests__/use-frontend-tool.test.ts +648 -0
- package/src/v2/hooks/__tests__/use-human-in-the-loop.e2e.test.ts +1379 -0
- package/src/v2/hooks/__tests__/use-human-in-the-loop.test.ts +282 -0
- package/src/v2/hooks/__tests__/use-interrupt.test.ts +345 -0
- package/src/v2/hooks/__tests__/use-katex-styles.test.ts +69 -0
- package/src/v2/hooks/__tests__/use-keyboard-height.test.ts +199 -0
- package/src/v2/hooks/__tests__/use-pin-to-send.test.ts +363 -0
- package/src/v2/hooks/__tests__/use-render-tool.test.ts +329 -0
- package/src/v2/hooks/__tests__/use-suggestions.e2e.test.ts +397 -0
- package/src/v2/hooks/__tests__/use-suggestions.test.ts +198 -0
- package/src/v2/hooks/__tests__/use-threads.test.ts +1041 -0
- package/src/v2/hooks/__tests__/zod-regression.test.ts +339 -0
- package/src/v2/hooks/index.ts +29 -0
- package/src/v2/hooks/use-agent-context.ts +55 -0
- package/src/v2/hooks/use-agent.ts +345 -0
- package/src/v2/hooks/use-attachments.ts +261 -0
- package/src/v2/hooks/use-capabilities.ts +30 -0
- package/src/v2/hooks/use-component.ts +46 -0
- package/src/v2/hooks/use-configure-suggestions.ts +252 -0
- package/src/v2/hooks/use-default-render-tool.ts +130 -0
- package/src/v2/hooks/use-frontend-tool.ts +68 -0
- package/src/v2/hooks/use-human-in-the-loop.ts +90 -0
- package/src/v2/hooks/use-interrupt.ts +257 -0
- package/src/v2/hooks/use-katex-styles.ts +44 -0
- package/src/v2/hooks/use-keyboard-height.ts +87 -0
- package/src/v2/hooks/use-pin-to-send.ts +160 -0
- package/src/v2/hooks/use-render-activity-message.ts +92 -0
- package/src/v2/hooks/use-render-custom-messages.ts +129 -0
- package/src/v2/hooks/use-render-tool.ts +128 -0
- package/src/v2/hooks/use-suggestions.ts +98 -0
- package/src/v2/hooks/use-threads.ts +208 -0
- package/src/v2/index.ts +11 -0
- package/src/v2/lib/__tests__/processPartialHtml.test.ts +84 -0
- package/src/v2/lib/__tests__/transcription-client.test.ts +65 -0
- package/src/v2/lib/processPartialHtml.ts +21 -0
- package/src/v2/lib/shallow-stable.ts +54 -0
- package/src/v2/lib/transcription-client.ts +151 -0
- package/src/v2/lib/vue-core.ts +161 -0
- package/src/v2/providers/CopilotChatConfigurationProvider.types.ts +15 -0
- package/src/v2/providers/CopilotChatConfigurationProvider.vue +95 -0
- package/src/v2/providers/CopilotKitProvider.types.ts +66 -0
- package/src/v2/providers/CopilotKitProvider.vue +653 -0
- package/src/v2/providers/SandboxFunctionsContext.ts +11 -0
- package/src/v2/providers/__tests__/CopilotChatConfigurationProvider.test.ts +309 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.debug.test.ts +295 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.license.test.ts +110 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.onError.test.ts +67 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.renderCustomMessages.e2e.test.ts +901 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.sandboxFunctions.test.ts +141 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.stability.test.ts +871 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.test.ts +603 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.wildcard.test.ts +104 -0
- package/src/v2/providers/index.ts +21 -0
- package/src/v2/providers/keys.ts +25 -0
- package/src/v2/providers/license-context.ts +16 -0
- package/src/v2/providers/types.ts +40 -0
- package/src/v2/providers/useCopilotChatConfiguration.ts +11 -0
- package/src/v2/providers/useCopilotKit.ts +11 -0
- package/src/v2/providers/useLicenseContext.ts +21 -0
- package/src/v2/types/__tests__/defineToolCallRenderer.test.ts +157 -0
- package/src/v2/types/a2ui.ts +5 -0
- package/src/v2/types/defineToolCallRenderer.ts +32 -0
- package/src/v2/types/frontend-tool.ts +8 -0
- package/src/v2/types/human-in-the-loop.ts +38 -0
- package/src/v2/types/index.ts +9 -0
- package/src/v2/types/interrupt.ts +15 -0
- package/src/v2/types/sandbox-function.ts +8 -0
- package/src/v2/types/vue-activity-message-renderer.ts +22 -0
- package/src/v2/types/vue-custom-message-renderer.ts +24 -0
- package/src/v2/types/vue-tool-call-renderer.ts +44 -0
- package/tsconfig.json +27 -0
- package/vite.config.ts +49 -0
- package/vitest.config.ts +23 -0
|
@@ -0,0 +1,891 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import {
|
|
3
|
+
computed,
|
|
4
|
+
defineComponent,
|
|
5
|
+
getCurrentInstance,
|
|
6
|
+
h,
|
|
7
|
+
onBeforeUnmount,
|
|
8
|
+
onMounted,
|
|
9
|
+
ref,
|
|
10
|
+
} from "vue";
|
|
11
|
+
import type { AssistantMessage, Message } from "@ag-ui/core";
|
|
12
|
+
import { StreamMarkdown } from "streamdown-vue";
|
|
13
|
+
import { useCopilotChatConfiguration } from "../../providers/useCopilotChatConfiguration";
|
|
14
|
+
import { CopilotChatDefaultLabels } from "../../providers/types";
|
|
15
|
+
import {
|
|
16
|
+
IconCheck,
|
|
17
|
+
IconCopy,
|
|
18
|
+
IconDownload,
|
|
19
|
+
IconRefreshCw,
|
|
20
|
+
IconThumbsDown,
|
|
21
|
+
IconThumbsUp,
|
|
22
|
+
IconVolume2,
|
|
23
|
+
} from "../icons";
|
|
24
|
+
import CopilotChatToolCallsView from "./CopilotChatToolCallsView.vue";
|
|
25
|
+
import type {
|
|
26
|
+
CopilotChatAssistantMessageCopyButtonSlotProps,
|
|
27
|
+
CopilotChatAssistantMessageLayoutSlotProps,
|
|
28
|
+
CopilotChatAssistantMessageMessageRendererSlotProps,
|
|
29
|
+
CopilotChatAssistantMessageReadAloudButtonSlotProps,
|
|
30
|
+
CopilotChatAssistantMessageRegenerateButtonSlotProps,
|
|
31
|
+
CopilotChatAssistantMessageThumbsDownButtonSlotProps,
|
|
32
|
+
CopilotChatAssistantMessageThumbsUpButtonSlotProps,
|
|
33
|
+
CopilotChatAssistantMessageToolCallsViewSlotProps,
|
|
34
|
+
CopilotChatAssistantMessageToolbarSlotProps,
|
|
35
|
+
} from "./types";
|
|
36
|
+
import { useKatexStyles } from "../../hooks/use-katex-styles";
|
|
37
|
+
|
|
38
|
+
useKatexStyles();
|
|
39
|
+
|
|
40
|
+
const props = withDefaults(
|
|
41
|
+
defineProps<{
|
|
42
|
+
message: AssistantMessage;
|
|
43
|
+
messages?: Message[];
|
|
44
|
+
isRunning?: boolean;
|
|
45
|
+
toolbarVisible?: boolean;
|
|
46
|
+
}>(),
|
|
47
|
+
{
|
|
48
|
+
messages: () => [],
|
|
49
|
+
isRunning: false,
|
|
50
|
+
toolbarVisible: true,
|
|
51
|
+
},
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
defineSlots<{
|
|
55
|
+
layout?: (props: CopilotChatAssistantMessageLayoutSlotProps) => unknown;
|
|
56
|
+
"message-renderer"?: (
|
|
57
|
+
props: CopilotChatAssistantMessageMessageRendererSlotProps,
|
|
58
|
+
) => unknown;
|
|
59
|
+
toolbar?: (props: CopilotChatAssistantMessageToolbarSlotProps) => unknown;
|
|
60
|
+
"copy-button"?: (
|
|
61
|
+
props: CopilotChatAssistantMessageCopyButtonSlotProps,
|
|
62
|
+
) => unknown;
|
|
63
|
+
"thumbs-up-button"?: (
|
|
64
|
+
props: CopilotChatAssistantMessageThumbsUpButtonSlotProps,
|
|
65
|
+
) => unknown;
|
|
66
|
+
"thumbs-down-button"?: (
|
|
67
|
+
props: CopilotChatAssistantMessageThumbsDownButtonSlotProps,
|
|
68
|
+
) => unknown;
|
|
69
|
+
"read-aloud-button"?: (
|
|
70
|
+
props: CopilotChatAssistantMessageReadAloudButtonSlotProps,
|
|
71
|
+
) => unknown;
|
|
72
|
+
"regenerate-button"?: (
|
|
73
|
+
props: CopilotChatAssistantMessageRegenerateButtonSlotProps,
|
|
74
|
+
) => unknown;
|
|
75
|
+
"tool-calls-view"?: (
|
|
76
|
+
props: CopilotChatAssistantMessageToolCallsViewSlotProps,
|
|
77
|
+
) => unknown;
|
|
78
|
+
"toolbar-items"?: () => unknown;
|
|
79
|
+
[key: string]: ((props: any) => unknown) | undefined;
|
|
80
|
+
}>();
|
|
81
|
+
|
|
82
|
+
const emit = defineEmits<{
|
|
83
|
+
"thumbs-up": [message: AssistantMessage];
|
|
84
|
+
"thumbs-down": [message: AssistantMessage];
|
|
85
|
+
"read-aloud": [message: AssistantMessage];
|
|
86
|
+
regenerate: [message: AssistantMessage];
|
|
87
|
+
}>();
|
|
88
|
+
|
|
89
|
+
const config = useCopilotChatConfiguration();
|
|
90
|
+
const labels = computed(() => config.value?.labels ?? CopilotChatDefaultLabels);
|
|
91
|
+
const instance = getCurrentInstance();
|
|
92
|
+
const copied = ref(false);
|
|
93
|
+
let copiedResetTimeout: ReturnType<typeof setTimeout> | null = null;
|
|
94
|
+
const vnodeProps = computed(
|
|
95
|
+
() => (instance?.vnode.props ?? {}) as Record<string, unknown>,
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
const toolbarButtonClass = [
|
|
99
|
+
"cpk:inline-flex cpk:h-8 cpk:w-8 cpk:items-center cpk:justify-center cpk:rounded-md cpk:p-0",
|
|
100
|
+
"cpk:cursor-pointer cpk:text-[rgb(93,93,93)] cpk:transition-colors cpk:hover:bg-[#E8E8E8]",
|
|
101
|
+
"cpk:hover:text-[rgb(93,93,93)] cpk:dark:text-[rgb(243,243,243)] cpk:dark:hover:bg-[#303030]",
|
|
102
|
+
"cpk:dark:hover:text-[rgb(243,243,243)] cpk:disabled:pointer-events-none cpk:disabled:opacity-50",
|
|
103
|
+
].join(" ");
|
|
104
|
+
|
|
105
|
+
function extractFileNameFromUrl(url: string, fallback: string) {
|
|
106
|
+
try {
|
|
107
|
+
const parsed = new URL(url, "https://copilotkit.local");
|
|
108
|
+
const pathname = parsed.pathname.split("/").filter(Boolean).pop();
|
|
109
|
+
if (pathname) {
|
|
110
|
+
return decodeURIComponent(pathname);
|
|
111
|
+
}
|
|
112
|
+
} catch {
|
|
113
|
+
return fallback;
|
|
114
|
+
}
|
|
115
|
+
return fallback;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function triggerDownload(href: string, fileName: string) {
|
|
119
|
+
if (typeof document === "undefined") {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const anchor = document.createElement("a");
|
|
123
|
+
anchor.href = href;
|
|
124
|
+
anchor.download = fileName;
|
|
125
|
+
anchor.rel = "noopener noreferrer";
|
|
126
|
+
document.body.appendChild(anchor);
|
|
127
|
+
anchor.click();
|
|
128
|
+
document.body.removeChild(anchor);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
type MarkdownTableData = {
|
|
132
|
+
headers: string[];
|
|
133
|
+
rows: string[][];
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
function extractTableData(table: HTMLTableElement): MarkdownTableData {
|
|
137
|
+
const headers = Array.from(table.querySelectorAll("thead th")).map((cell) =>
|
|
138
|
+
(cell.textContent ?? "").trim(),
|
|
139
|
+
);
|
|
140
|
+
const rows = Array.from(table.querySelectorAll("tbody tr")).map((row) =>
|
|
141
|
+
Array.from(row.querySelectorAll("td")).map((cell) =>
|
|
142
|
+
(cell.textContent ?? "").trim(),
|
|
143
|
+
),
|
|
144
|
+
);
|
|
145
|
+
return { headers, rows };
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function toDelimitedTable(
|
|
149
|
+
data: MarkdownTableData,
|
|
150
|
+
delimiter: "," | "\t",
|
|
151
|
+
): string {
|
|
152
|
+
const escapeCell = (value: string): string => {
|
|
153
|
+
const needsQuotes =
|
|
154
|
+
value.includes(delimiter) || value.includes('"') || value.includes("\n");
|
|
155
|
+
const escaped = value.replace(/"/g, '""');
|
|
156
|
+
return needsQuotes ? `"${escaped}"` : escaped;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
const lines: string[] = [];
|
|
160
|
+
if (data.headers.length > 0) {
|
|
161
|
+
lines.push(data.headers.map(escapeCell).join(delimiter));
|
|
162
|
+
}
|
|
163
|
+
for (const row of data.rows) {
|
|
164
|
+
lines.push(row.map(escapeCell).join(delimiter));
|
|
165
|
+
}
|
|
166
|
+
return lines.join("\n");
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function toMarkdownTable(data: MarkdownTableData): string {
|
|
170
|
+
if (data.headers.length === 0) {
|
|
171
|
+
return data.rows.map((row) => `| ${row.join(" | ")} |`).join("\n");
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const separator = `| ${data.headers.map(() => "---").join(" | ")} |`;
|
|
175
|
+
const body = data.rows.map((row) => `| ${row.join(" | ")} |`);
|
|
176
|
+
return [`| ${data.headers.join(" | ")} |`, separator, ...body].join("\n");
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function triggerBlobDownload(
|
|
180
|
+
content: string,
|
|
181
|
+
fileName: string,
|
|
182
|
+
mimeType: string,
|
|
183
|
+
) {
|
|
184
|
+
if (typeof document === "undefined") {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
const blob = new Blob([content], { type: mimeType });
|
|
188
|
+
const url = URL.createObjectURL(blob);
|
|
189
|
+
triggerDownload(url, fileName);
|
|
190
|
+
URL.revokeObjectURL(url);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const MarkdownImage = defineComponent({
|
|
194
|
+
name: "CopilotMarkdownImage",
|
|
195
|
+
inheritAttrs: false,
|
|
196
|
+
props: {
|
|
197
|
+
src: {
|
|
198
|
+
type: String,
|
|
199
|
+
default: "",
|
|
200
|
+
},
|
|
201
|
+
alt: {
|
|
202
|
+
type: String,
|
|
203
|
+
default: "",
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
setup(imageProps, { attrs }) {
|
|
207
|
+
async function handleDownload() {
|
|
208
|
+
if (!imageProps.src) {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const fileName = extractFileNameFromUrl(imageProps.src, "image");
|
|
213
|
+
try {
|
|
214
|
+
const response = await fetch(imageProps.src);
|
|
215
|
+
if (!response.ok) {
|
|
216
|
+
throw new Error("Failed to fetch image");
|
|
217
|
+
}
|
|
218
|
+
const blob = await response.blob();
|
|
219
|
+
const objectUrl = URL.createObjectURL(blob);
|
|
220
|
+
triggerDownload(objectUrl, fileName);
|
|
221
|
+
URL.revokeObjectURL(objectUrl);
|
|
222
|
+
} catch {
|
|
223
|
+
triggerDownload(imageProps.src, fileName);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return () => {
|
|
228
|
+
const imageAttrs = {
|
|
229
|
+
...attrs,
|
|
230
|
+
src: imageProps.src,
|
|
231
|
+
alt: imageProps.alt,
|
|
232
|
+
class: ["cpk:max-w-full cpk:rounded-lg", attrs.class]
|
|
233
|
+
.filter(Boolean)
|
|
234
|
+
.join(" "),
|
|
235
|
+
"data-streamdown": "image",
|
|
236
|
+
} as Record<string, unknown>;
|
|
237
|
+
|
|
238
|
+
delete imageAttrs.className;
|
|
239
|
+
|
|
240
|
+
return h(
|
|
241
|
+
"div",
|
|
242
|
+
{
|
|
243
|
+
class: "cpk:group cpk:relative cpk:my-4 cpk:inline-block",
|
|
244
|
+
"data-streamdown": "image-wrapper",
|
|
245
|
+
},
|
|
246
|
+
[
|
|
247
|
+
h("img", imageAttrs),
|
|
248
|
+
h("div", {
|
|
249
|
+
class:
|
|
250
|
+
"cpk:pointer-events-none cpk:absolute cpk:inset-0 cpk:hidden cpk:rounded-lg cpk:bg-black/10 cpk:group-hover:block",
|
|
251
|
+
}),
|
|
252
|
+
h(
|
|
253
|
+
"button",
|
|
254
|
+
{
|
|
255
|
+
type: "button",
|
|
256
|
+
class:
|
|
257
|
+
"cpk:absolute cpk:right-2 cpk:bottom-2 cpk:flex cpk:h-8 cpk:w-8 cpk:cursor-pointer cpk:items-center cpk:justify-center cpk:rounded-md cpk:border cpk:border-border cpk:bg-background/90 cpk:shadow-sm cpk:backdrop-blur-sm cpk:transition-all cpk:duration-200 cpk:hover:bg-background cpk:opacity-0 cpk:group-hover:opacity-100",
|
|
258
|
+
title: "Download image",
|
|
259
|
+
onClick: handleDownload,
|
|
260
|
+
},
|
|
261
|
+
[h(IconDownload, { class: "cpk:size-[14px]" })],
|
|
262
|
+
),
|
|
263
|
+
],
|
|
264
|
+
);
|
|
265
|
+
};
|
|
266
|
+
},
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
const tableIconButtonClass =
|
|
270
|
+
"cpk:cursor-pointer cpk:p-1 cpk:text-muted-foreground cpk:transition-all cpk:hover:text-foreground cpk:disabled:cursor-not-allowed cpk:disabled:opacity-50";
|
|
271
|
+
const tableMenuClass =
|
|
272
|
+
"cpk:absolute cpk:top-full cpk:right-0 cpk:z-10 cpk:mt-1 cpk:min-w-[120px] cpk:overflow-hidden cpk:rounded-md cpk:border cpk:border-border cpk:bg-background cpk:shadow-lg";
|
|
273
|
+
const tableMenuItemClass =
|
|
274
|
+
"cpk:w-full cpk:px-3 cpk:py-2 cpk:text-left cpk:text-sm cpk:transition-colors cpk:hover:bg-muted/40";
|
|
275
|
+
|
|
276
|
+
const MarkdownTable = defineComponent({
|
|
277
|
+
name: "CopilotMarkdownTable",
|
|
278
|
+
inheritAttrs: false,
|
|
279
|
+
setup(_, { attrs, slots }) {
|
|
280
|
+
const wrapperRef = ref<HTMLElement | null>(null);
|
|
281
|
+
const showCopyMenu = ref(false);
|
|
282
|
+
const showDownloadMenu = ref(false);
|
|
283
|
+
const tableCopied = ref(false);
|
|
284
|
+
let tableCopiedResetTimeout: ReturnType<typeof setTimeout> | null = null;
|
|
285
|
+
|
|
286
|
+
const closeMenus = () => {
|
|
287
|
+
showCopyMenu.value = false;
|
|
288
|
+
showDownloadMenu.value = false;
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
const setTableCopiedStateWithDelay = () => {
|
|
292
|
+
if (tableCopiedResetTimeout) {
|
|
293
|
+
clearTimeout(tableCopiedResetTimeout);
|
|
294
|
+
}
|
|
295
|
+
tableCopied.value = true;
|
|
296
|
+
tableCopiedResetTimeout = setTimeout(() => {
|
|
297
|
+
tableCopied.value = false;
|
|
298
|
+
tableCopiedResetTimeout = null;
|
|
299
|
+
}, 2000);
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
const findTable = (): HTMLTableElement | null => {
|
|
303
|
+
if (!wrapperRef.value) return null;
|
|
304
|
+
return wrapperRef.value.querySelector("table");
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
const getTableData = (): MarkdownTableData | null => {
|
|
308
|
+
const table = findTable();
|
|
309
|
+
if (!table) return null;
|
|
310
|
+
return extractTableData(table);
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
const copyTableAs = async (format: "csv" | "tsv") => {
|
|
314
|
+
const data = getTableData();
|
|
315
|
+
if (!data) return;
|
|
316
|
+
|
|
317
|
+
const delimiter = format === "csv" ? "," : "\t";
|
|
318
|
+
const text = toDelimitedTable(data, delimiter);
|
|
319
|
+
|
|
320
|
+
if (typeof navigator !== "undefined" && navigator.clipboard?.writeText) {
|
|
321
|
+
try {
|
|
322
|
+
await navigator.clipboard.writeText(text);
|
|
323
|
+
} catch {
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
closeMenus();
|
|
329
|
+
setTableCopiedStateWithDelay();
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
const downloadTableAs = (format: "csv" | "markdown") => {
|
|
333
|
+
const data = getTableData();
|
|
334
|
+
if (!data) return;
|
|
335
|
+
|
|
336
|
+
if (format === "csv") {
|
|
337
|
+
triggerBlobDownload(
|
|
338
|
+
toDelimitedTable(data, ","),
|
|
339
|
+
"table.csv",
|
|
340
|
+
"text/csv",
|
|
341
|
+
);
|
|
342
|
+
} else {
|
|
343
|
+
triggerBlobDownload(toMarkdownTable(data), "table.md", "text/markdown");
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
closeMenus();
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
const handleClickOutside = (event: MouseEvent) => {
|
|
350
|
+
if (!wrapperRef.value) return;
|
|
351
|
+
const target = event.target as Node | null;
|
|
352
|
+
if (target && !wrapperRef.value.contains(target)) {
|
|
353
|
+
closeMenus();
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
onMounted(() => {
|
|
358
|
+
if (typeof document !== "undefined") {
|
|
359
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
onBeforeUnmount(() => {
|
|
364
|
+
if (tableCopiedResetTimeout) {
|
|
365
|
+
clearTimeout(tableCopiedResetTimeout);
|
|
366
|
+
}
|
|
367
|
+
if (typeof document !== "undefined") {
|
|
368
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
return () => {
|
|
373
|
+
const tableAttrs = {
|
|
374
|
+
...attrs,
|
|
375
|
+
class: [
|
|
376
|
+
"cpk:w-full cpk:border-collapse cpk:border cpk:border-border",
|
|
377
|
+
attrs.class,
|
|
378
|
+
]
|
|
379
|
+
.filter(Boolean)
|
|
380
|
+
.join(" "),
|
|
381
|
+
"data-streamdown": "table",
|
|
382
|
+
} as Record<string, unknown>;
|
|
383
|
+
|
|
384
|
+
delete tableAttrs.className;
|
|
385
|
+
|
|
386
|
+
return h(
|
|
387
|
+
"div",
|
|
388
|
+
{
|
|
389
|
+
ref: wrapperRef,
|
|
390
|
+
class: "cpk:my-4 cpk:flex cpk:flex-col cpk:space-y-2",
|
|
391
|
+
"data-streamdown": "table-wrapper",
|
|
392
|
+
},
|
|
393
|
+
[
|
|
394
|
+
h(
|
|
395
|
+
"div",
|
|
396
|
+
{ class: "cpk:flex cpk:items-center cpk:justify-end cpk:gap-1" },
|
|
397
|
+
[
|
|
398
|
+
h("div", { class: "cpk:relative" }, [
|
|
399
|
+
h(
|
|
400
|
+
"button",
|
|
401
|
+
{
|
|
402
|
+
type: "button",
|
|
403
|
+
class: tableIconButtonClass,
|
|
404
|
+
title: "Copy table",
|
|
405
|
+
onClick: () => {
|
|
406
|
+
showCopyMenu.value = !showCopyMenu.value;
|
|
407
|
+
showDownloadMenu.value = false;
|
|
408
|
+
},
|
|
409
|
+
},
|
|
410
|
+
[
|
|
411
|
+
tableCopied.value
|
|
412
|
+
? h(IconCheck, { class: "cpk:size-[14px]" })
|
|
413
|
+
: h(IconCopy, { class: "cpk:size-[14px]" }),
|
|
414
|
+
],
|
|
415
|
+
),
|
|
416
|
+
showCopyMenu.value
|
|
417
|
+
? h("div", { class: tableMenuClass }, [
|
|
418
|
+
h(
|
|
419
|
+
"button",
|
|
420
|
+
{
|
|
421
|
+
type: "button",
|
|
422
|
+
class: tableMenuItemClass,
|
|
423
|
+
title: "Copy table as CSV",
|
|
424
|
+
onClick: () => copyTableAs("csv"),
|
|
425
|
+
},
|
|
426
|
+
"CSV",
|
|
427
|
+
),
|
|
428
|
+
h(
|
|
429
|
+
"button",
|
|
430
|
+
{
|
|
431
|
+
type: "button",
|
|
432
|
+
class: tableMenuItemClass,
|
|
433
|
+
title: "Copy table as TSV",
|
|
434
|
+
onClick: () => copyTableAs("tsv"),
|
|
435
|
+
},
|
|
436
|
+
"TSV",
|
|
437
|
+
),
|
|
438
|
+
])
|
|
439
|
+
: null,
|
|
440
|
+
]),
|
|
441
|
+
h("div", { class: "cpk:relative" }, [
|
|
442
|
+
h(
|
|
443
|
+
"button",
|
|
444
|
+
{
|
|
445
|
+
type: "button",
|
|
446
|
+
class: tableIconButtonClass,
|
|
447
|
+
title: "Download table",
|
|
448
|
+
onClick: () => {
|
|
449
|
+
showDownloadMenu.value = !showDownloadMenu.value;
|
|
450
|
+
showCopyMenu.value = false;
|
|
451
|
+
},
|
|
452
|
+
},
|
|
453
|
+
[h(IconDownload, { class: "cpk:size-[14px]" })],
|
|
454
|
+
),
|
|
455
|
+
showDownloadMenu.value
|
|
456
|
+
? h("div", { class: tableMenuClass }, [
|
|
457
|
+
h(
|
|
458
|
+
"button",
|
|
459
|
+
{
|
|
460
|
+
type: "button",
|
|
461
|
+
class: tableMenuItemClass,
|
|
462
|
+
title: "Download table as CSV",
|
|
463
|
+
onClick: () => downloadTableAs("csv"),
|
|
464
|
+
},
|
|
465
|
+
"CSV",
|
|
466
|
+
),
|
|
467
|
+
h(
|
|
468
|
+
"button",
|
|
469
|
+
{
|
|
470
|
+
type: "button",
|
|
471
|
+
class: tableMenuItemClass,
|
|
472
|
+
title: "Download table as Markdown",
|
|
473
|
+
onClick: () => downloadTableAs("markdown"),
|
|
474
|
+
},
|
|
475
|
+
"Markdown",
|
|
476
|
+
),
|
|
477
|
+
])
|
|
478
|
+
: null,
|
|
479
|
+
]),
|
|
480
|
+
],
|
|
481
|
+
),
|
|
482
|
+
h("div", { class: "cpk:overflow-x-auto" }, [
|
|
483
|
+
h("table", tableAttrs, slots.default ? slots.default() : []),
|
|
484
|
+
]),
|
|
485
|
+
],
|
|
486
|
+
);
|
|
487
|
+
};
|
|
488
|
+
},
|
|
489
|
+
});
|
|
490
|
+
|
|
491
|
+
const codeActionButtonClass =
|
|
492
|
+
"cpk:cursor-pointer cpk:p-1 cpk:text-muted-foreground cpk:transition-all cpk:hover:text-foreground cpk:disabled:cursor-not-allowed cpk:disabled:opacity-50";
|
|
493
|
+
|
|
494
|
+
const codeLanguageExtensionMap: Record<string, string> = {
|
|
495
|
+
javascript: "js",
|
|
496
|
+
js: "js",
|
|
497
|
+
typescript: "ts",
|
|
498
|
+
ts: "ts",
|
|
499
|
+
json: "json",
|
|
500
|
+
vue: "vue",
|
|
501
|
+
html: "html",
|
|
502
|
+
css: "css",
|
|
503
|
+
md: "md",
|
|
504
|
+
markdown: "md",
|
|
505
|
+
sh: "sh",
|
|
506
|
+
bash: "sh",
|
|
507
|
+
py: "py",
|
|
508
|
+
python: "py",
|
|
509
|
+
go: "go",
|
|
510
|
+
rust: "rs",
|
|
511
|
+
rs: "rs",
|
|
512
|
+
};
|
|
513
|
+
|
|
514
|
+
const CodeBlockCopyAction = defineComponent({
|
|
515
|
+
name: "CopilotCodeBlockCopyAction",
|
|
516
|
+
props: {
|
|
517
|
+
code: {
|
|
518
|
+
type: String,
|
|
519
|
+
default: "",
|
|
520
|
+
},
|
|
521
|
+
},
|
|
522
|
+
setup(actionProps) {
|
|
523
|
+
const isCopied = ref(false);
|
|
524
|
+
let resetTimeout: ReturnType<typeof setTimeout> | null = null;
|
|
525
|
+
|
|
526
|
+
const handleClick = async () => {
|
|
527
|
+
if (!actionProps.code) return;
|
|
528
|
+
if (typeof navigator !== "undefined" && navigator.clipboard?.writeText) {
|
|
529
|
+
try {
|
|
530
|
+
await navigator.clipboard.writeText(actionProps.code);
|
|
531
|
+
} catch {
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
if (resetTimeout) {
|
|
537
|
+
clearTimeout(resetTimeout);
|
|
538
|
+
}
|
|
539
|
+
isCopied.value = true;
|
|
540
|
+
resetTimeout = setTimeout(() => {
|
|
541
|
+
isCopied.value = false;
|
|
542
|
+
resetTimeout = null;
|
|
543
|
+
}, 2000);
|
|
544
|
+
};
|
|
545
|
+
|
|
546
|
+
onBeforeUnmount(() => {
|
|
547
|
+
if (resetTimeout) {
|
|
548
|
+
clearTimeout(resetTimeout);
|
|
549
|
+
}
|
|
550
|
+
});
|
|
551
|
+
|
|
552
|
+
return () =>
|
|
553
|
+
h(
|
|
554
|
+
"button",
|
|
555
|
+
{
|
|
556
|
+
type: "button",
|
|
557
|
+
class: codeActionButtonClass,
|
|
558
|
+
title: "Copy Code",
|
|
559
|
+
"data-streamdown": "code-block-copy-button",
|
|
560
|
+
onClick: handleClick,
|
|
561
|
+
},
|
|
562
|
+
[
|
|
563
|
+
isCopied.value
|
|
564
|
+
? h(IconCheck, { class: "cpk:size-[14px]" })
|
|
565
|
+
: h(IconCopy, { class: "cpk:size-[14px]" }),
|
|
566
|
+
],
|
|
567
|
+
);
|
|
568
|
+
},
|
|
569
|
+
});
|
|
570
|
+
|
|
571
|
+
const CodeBlockDownloadAction = defineComponent({
|
|
572
|
+
name: "CopilotCodeBlockDownloadAction",
|
|
573
|
+
props: {
|
|
574
|
+
code: {
|
|
575
|
+
type: String,
|
|
576
|
+
default: "",
|
|
577
|
+
},
|
|
578
|
+
language: {
|
|
579
|
+
type: String,
|
|
580
|
+
default: "",
|
|
581
|
+
},
|
|
582
|
+
},
|
|
583
|
+
setup(actionProps) {
|
|
584
|
+
const handleClick = () => {
|
|
585
|
+
if (!actionProps.code) return;
|
|
586
|
+
const extension =
|
|
587
|
+
codeLanguageExtensionMap[actionProps.language.toLowerCase()] ?? "txt";
|
|
588
|
+
triggerBlobDownload(actionProps.code, `file.${extension}`, "text/plain");
|
|
589
|
+
};
|
|
590
|
+
|
|
591
|
+
return () =>
|
|
592
|
+
h(
|
|
593
|
+
"button",
|
|
594
|
+
{
|
|
595
|
+
type: "button",
|
|
596
|
+
class: codeActionButtonClass,
|
|
597
|
+
title: "Download file",
|
|
598
|
+
"data-streamdown": "code-block-download-button",
|
|
599
|
+
onClick: handleClick,
|
|
600
|
+
},
|
|
601
|
+
[h(IconDownload, { class: "cpk:size-[14px]" })],
|
|
602
|
+
);
|
|
603
|
+
},
|
|
604
|
+
});
|
|
605
|
+
|
|
606
|
+
const markdownComponents = {
|
|
607
|
+
img: MarkdownImage,
|
|
608
|
+
table: MarkdownTable,
|
|
609
|
+
};
|
|
610
|
+
|
|
611
|
+
function normalizeContent(content: unknown): string {
|
|
612
|
+
if (!content) {
|
|
613
|
+
return "";
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
if (typeof content === "string") {
|
|
617
|
+
return content;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
if (Array.isArray(content)) {
|
|
621
|
+
const parts = content as Array<{ type?: unknown; text?: unknown }>;
|
|
622
|
+
return parts
|
|
623
|
+
.map((part) => {
|
|
624
|
+
if (
|
|
625
|
+
part &&
|
|
626
|
+
typeof part === "object" &&
|
|
627
|
+
"type" in part &&
|
|
628
|
+
part.type === "text" &&
|
|
629
|
+
typeof part.text === "string"
|
|
630
|
+
) {
|
|
631
|
+
return part.text;
|
|
632
|
+
}
|
|
633
|
+
return "";
|
|
634
|
+
})
|
|
635
|
+
.filter((text) => text.length > 0)
|
|
636
|
+
.join("\n");
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
return "";
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
const normalizedContent = computed(() =>
|
|
643
|
+
normalizeContent(props.message.content),
|
|
644
|
+
);
|
|
645
|
+
const hasContent = computed(() => normalizedContent.value.trim().length > 0);
|
|
646
|
+
function hasListener(listenerName: string) {
|
|
647
|
+
const listener = vnodeProps.value[listenerName];
|
|
648
|
+
if (Array.isArray(listener)) {
|
|
649
|
+
return listener.length > 0;
|
|
650
|
+
}
|
|
651
|
+
return !!listener;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
const hasThumbsUp = computed(() => hasListener("onThumbsUp"));
|
|
655
|
+
const hasThumbsDown = computed(() => hasListener("onThumbsDown"));
|
|
656
|
+
const hasReadAloud = computed(() => hasListener("onReadAloud"));
|
|
657
|
+
const hasRegenerate = computed(() => hasListener("onRegenerate"));
|
|
658
|
+
const isLatestAssistantMessage = computed(
|
|
659
|
+
() => props.messages[props.messages.length - 1]?.id === props.message.id,
|
|
660
|
+
);
|
|
661
|
+
const shouldShowToolbar = computed(
|
|
662
|
+
() =>
|
|
663
|
+
props.toolbarVisible &&
|
|
664
|
+
hasContent.value &&
|
|
665
|
+
!(props.isRunning && isLatestAssistantMessage.value),
|
|
666
|
+
);
|
|
667
|
+
|
|
668
|
+
function resetCopiedStateWithDelay() {
|
|
669
|
+
if (copiedResetTimeout) {
|
|
670
|
+
clearTimeout(copiedResetTimeout);
|
|
671
|
+
}
|
|
672
|
+
copied.value = true;
|
|
673
|
+
copiedResetTimeout = setTimeout(() => {
|
|
674
|
+
copied.value = false;
|
|
675
|
+
copiedResetTimeout = null;
|
|
676
|
+
}, 2000);
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
async function handleCopyMessage() {
|
|
680
|
+
const content = normalizedContent.value;
|
|
681
|
+
if (!content) return;
|
|
682
|
+
|
|
683
|
+
if (
|
|
684
|
+
typeof navigator === "undefined" ||
|
|
685
|
+
typeof navigator.clipboard?.writeText !== "function"
|
|
686
|
+
) {
|
|
687
|
+
return;
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
try {
|
|
691
|
+
await navigator.clipboard.writeText(content);
|
|
692
|
+
resetCopiedStateWithDelay();
|
|
693
|
+
} catch (error) {
|
|
694
|
+
console.error("Failed to copy to clipboard:", error);
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
function handleThumbsUp() {
|
|
699
|
+
emit("thumbs-up", props.message);
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
function handleThumbsDown() {
|
|
703
|
+
emit("thumbs-down", props.message);
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
function handleReadAloud() {
|
|
707
|
+
emit("read-aloud", props.message);
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
function handleRegenerate() {
|
|
711
|
+
emit("regenerate", props.message);
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
onBeforeUnmount(() => {
|
|
715
|
+
if (copiedResetTimeout) {
|
|
716
|
+
clearTimeout(copiedResetTimeout);
|
|
717
|
+
}
|
|
718
|
+
});
|
|
719
|
+
</script>
|
|
720
|
+
|
|
721
|
+
<template>
|
|
722
|
+
<slot
|
|
723
|
+
name="layout"
|
|
724
|
+
:message="message"
|
|
725
|
+
:content="normalizedContent"
|
|
726
|
+
:is-running="isRunning"
|
|
727
|
+
:toolbar-visible="toolbarVisible"
|
|
728
|
+
:should-show-toolbar="shouldShowToolbar"
|
|
729
|
+
:message-renderer="$slots['message-renderer'] ?? (() => null)"
|
|
730
|
+
:toolbar="$slots['toolbar'] ?? (() => null)"
|
|
731
|
+
:copy-button="$slots['copy-button'] ?? (() => null)"
|
|
732
|
+
:thumbs-up-button="$slots['thumbs-up-button'] ?? (() => null)"
|
|
733
|
+
:thumbs-down-button="$slots['thumbs-down-button'] ?? (() => null)"
|
|
734
|
+
:read-aloud-button="$slots['read-aloud-button'] ?? (() => null)"
|
|
735
|
+
:regenerate-button="$slots['regenerate-button'] ?? (() => null)"
|
|
736
|
+
:tool-calls-view="$slots['tool-calls-view'] ?? (() => null)"
|
|
737
|
+
:on-copy="handleCopyMessage"
|
|
738
|
+
:on-thumbs-up="handleThumbsUp"
|
|
739
|
+
:on-thumbs-down="handleThumbsDown"
|
|
740
|
+
:on-read-aloud="handleReadAloud"
|
|
741
|
+
:on-regenerate="handleRegenerate"
|
|
742
|
+
>
|
|
743
|
+
<div
|
|
744
|
+
data-copilotkit
|
|
745
|
+
data-testid="copilot-assistant-message"
|
|
746
|
+
class="cpk:prose cpk:max-w-full cpk:break-words cpk:dark:prose-invert"
|
|
747
|
+
:data-message-id="message.id"
|
|
748
|
+
v-bind="$attrs"
|
|
749
|
+
>
|
|
750
|
+
<slot
|
|
751
|
+
name="message-renderer"
|
|
752
|
+
:message="message"
|
|
753
|
+
:content="normalizedContent"
|
|
754
|
+
>
|
|
755
|
+
<StreamMarkdown
|
|
756
|
+
v-if="hasContent"
|
|
757
|
+
class="copilot-chat-assistant-markdown"
|
|
758
|
+
:content="normalizedContent"
|
|
759
|
+
:components="markdownComponents"
|
|
760
|
+
:code-block-actions="[CodeBlockDownloadAction, CodeBlockCopyAction]"
|
|
761
|
+
:code-block-show-line-numbers="false"
|
|
762
|
+
:code-block-hide-copy="true"
|
|
763
|
+
:code-block-hide-download="true"
|
|
764
|
+
:allowed-link-prefixes="[
|
|
765
|
+
'https://',
|
|
766
|
+
'http://',
|
|
767
|
+
'#',
|
|
768
|
+
'/',
|
|
769
|
+
'./',
|
|
770
|
+
'../',
|
|
771
|
+
]"
|
|
772
|
+
:shiki-theme="{ light: 'github-light', dark: 'github-dark' }"
|
|
773
|
+
/>
|
|
774
|
+
</slot>
|
|
775
|
+
|
|
776
|
+
<slot name="tool-calls-view" :message="message" :messages="messages">
|
|
777
|
+
<CopilotChatToolCallsView :message="message" :messages="messages">
|
|
778
|
+
<template
|
|
779
|
+
v-for="(_, slotName) in $slots"
|
|
780
|
+
:key="slotName"
|
|
781
|
+
#[slotName]="slotProps"
|
|
782
|
+
>
|
|
783
|
+
<slot :name="slotName" v-bind="slotProps" />
|
|
784
|
+
</template>
|
|
785
|
+
</CopilotChatToolCallsView>
|
|
786
|
+
</slot>
|
|
787
|
+
|
|
788
|
+
<slot
|
|
789
|
+
v-if="shouldShowToolbar"
|
|
790
|
+
name="toolbar"
|
|
791
|
+
:message="message"
|
|
792
|
+
:should-show-toolbar="shouldShowToolbar"
|
|
793
|
+
>
|
|
794
|
+
<div
|
|
795
|
+
class="cpk:w-full cpk:bg-transparent cpk:flex cpk:items-center cpk:-ml-[5px] cpk:-mt-[0px]"
|
|
796
|
+
>
|
|
797
|
+
<div class="cpk:flex cpk:items-center cpk:gap-1">
|
|
798
|
+
<slot
|
|
799
|
+
name="copy-button"
|
|
800
|
+
:on-copy="handleCopyMessage"
|
|
801
|
+
:copied="copied"
|
|
802
|
+
:label="labels.assistantMessageToolbarCopyMessageLabel"
|
|
803
|
+
>
|
|
804
|
+
<button
|
|
805
|
+
data-testid="copilot-copy-button"
|
|
806
|
+
type="button"
|
|
807
|
+
:class="toolbarButtonClass"
|
|
808
|
+
:aria-label="labels.assistantMessageToolbarCopyMessageLabel"
|
|
809
|
+
:title="labels.assistantMessageToolbarCopyMessageLabel"
|
|
810
|
+
@click="handleCopyMessage"
|
|
811
|
+
>
|
|
812
|
+
<IconCheck v-if="copied" class="cpk:size-[18px]" />
|
|
813
|
+
<IconCopy v-else class="cpk:size-[18px]" />
|
|
814
|
+
</button>
|
|
815
|
+
</slot>
|
|
816
|
+
|
|
817
|
+
<slot
|
|
818
|
+
v-if="hasThumbsUp"
|
|
819
|
+
name="thumbs-up-button"
|
|
820
|
+
:on-thumbs-up="handleThumbsUp"
|
|
821
|
+
:label="labels.assistantMessageToolbarThumbsUpLabel"
|
|
822
|
+
>
|
|
823
|
+
<button
|
|
824
|
+
type="button"
|
|
825
|
+
:class="toolbarButtonClass"
|
|
826
|
+
:aria-label="labels.assistantMessageToolbarThumbsUpLabel"
|
|
827
|
+
:title="labels.assistantMessageToolbarThumbsUpLabel"
|
|
828
|
+
@click="handleThumbsUp"
|
|
829
|
+
>
|
|
830
|
+
<IconThumbsUp class="cpk:size-[18px]" />
|
|
831
|
+
</button>
|
|
832
|
+
</slot>
|
|
833
|
+
|
|
834
|
+
<slot
|
|
835
|
+
v-if="hasThumbsDown"
|
|
836
|
+
name="thumbs-down-button"
|
|
837
|
+
:on-thumbs-down="handleThumbsDown"
|
|
838
|
+
:label="labels.assistantMessageToolbarThumbsDownLabel"
|
|
839
|
+
>
|
|
840
|
+
<button
|
|
841
|
+
type="button"
|
|
842
|
+
:class="toolbarButtonClass"
|
|
843
|
+
:aria-label="labels.assistantMessageToolbarThumbsDownLabel"
|
|
844
|
+
:title="labels.assistantMessageToolbarThumbsDownLabel"
|
|
845
|
+
@click="handleThumbsDown"
|
|
846
|
+
>
|
|
847
|
+
<IconThumbsDown class="cpk:size-[18px]" />
|
|
848
|
+
</button>
|
|
849
|
+
</slot>
|
|
850
|
+
|
|
851
|
+
<slot
|
|
852
|
+
v-if="hasReadAloud"
|
|
853
|
+
name="read-aloud-button"
|
|
854
|
+
:on-read-aloud="handleReadAloud"
|
|
855
|
+
:label="labels.assistantMessageToolbarReadAloudLabel"
|
|
856
|
+
>
|
|
857
|
+
<button
|
|
858
|
+
type="button"
|
|
859
|
+
:class="toolbarButtonClass"
|
|
860
|
+
:aria-label="labels.assistantMessageToolbarReadAloudLabel"
|
|
861
|
+
:title="labels.assistantMessageToolbarReadAloudLabel"
|
|
862
|
+
@click="handleReadAloud"
|
|
863
|
+
>
|
|
864
|
+
<IconVolume2 class="cpk:size-[20px]" />
|
|
865
|
+
</button>
|
|
866
|
+
</slot>
|
|
867
|
+
|
|
868
|
+
<slot
|
|
869
|
+
v-if="hasRegenerate"
|
|
870
|
+
name="regenerate-button"
|
|
871
|
+
:on-regenerate="handleRegenerate"
|
|
872
|
+
:label="labels.assistantMessageToolbarRegenerateLabel"
|
|
873
|
+
>
|
|
874
|
+
<button
|
|
875
|
+
type="button"
|
|
876
|
+
:class="toolbarButtonClass"
|
|
877
|
+
:aria-label="labels.assistantMessageToolbarRegenerateLabel"
|
|
878
|
+
:title="labels.assistantMessageToolbarRegenerateLabel"
|
|
879
|
+
@click="handleRegenerate"
|
|
880
|
+
>
|
|
881
|
+
<IconRefreshCw class="cpk:size-[18px]" />
|
|
882
|
+
</button>
|
|
883
|
+
</slot>
|
|
884
|
+
|
|
885
|
+
<slot name="toolbar-items" />
|
|
886
|
+
</div>
|
|
887
|
+
</div>
|
|
888
|
+
</slot>
|
|
889
|
+
</div>
|
|
890
|
+
</slot>
|
|
891
|
+
</template>
|