@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,411 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, onBeforeUnmount, ref, watch } from "vue";
|
|
3
|
+
import {
|
|
4
|
+
formatFileSize,
|
|
5
|
+
getDocumentIcon,
|
|
6
|
+
getSourceUrl,
|
|
7
|
+
} from "@copilotkit/shared";
|
|
8
|
+
import type { Attachment } from "@copilotkit/shared";
|
|
9
|
+
import type { CopilotChatAttachmentQueueProps } from "./types";
|
|
10
|
+
|
|
11
|
+
const props = withDefaults(defineProps<CopilotChatAttachmentQueueProps>(), {
|
|
12
|
+
attachments: () => [],
|
|
13
|
+
className: "",
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const emit = defineEmits<{
|
|
17
|
+
"remove-attachment": [id: string];
|
|
18
|
+
}>();
|
|
19
|
+
|
|
20
|
+
const activeLightboxAttachment = ref<Attachment | null>(null);
|
|
21
|
+
const documentBlobUrl = ref<string | null>(null);
|
|
22
|
+
|
|
23
|
+
const isLightboxOpen = computed(() => activeLightboxAttachment.value !== null);
|
|
24
|
+
const isPreviewableDocument = computed(() => {
|
|
25
|
+
const attachment = activeLightboxAttachment.value;
|
|
26
|
+
if (!attachment || attachment.type !== "document") return false;
|
|
27
|
+
const mimeType = attachment.source.mimeType;
|
|
28
|
+
return isPdf(mimeType) || isText(mimeType);
|
|
29
|
+
});
|
|
30
|
+
const decodedTextPreview = computed(() => {
|
|
31
|
+
const attachment = activeLightboxAttachment.value;
|
|
32
|
+
if (!attachment || attachment.type !== "document") return null;
|
|
33
|
+
const mimeType = attachment.source.mimeType;
|
|
34
|
+
if (!isText(mimeType) || attachment.source.type !== "data") return null;
|
|
35
|
+
try {
|
|
36
|
+
return atob(attachment.source.value);
|
|
37
|
+
} catch {
|
|
38
|
+
return attachment.source.value;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
const lightboxDocumentSource = computed(() => {
|
|
42
|
+
const attachment = activeLightboxAttachment.value;
|
|
43
|
+
if (!attachment || attachment.type !== "document") return null;
|
|
44
|
+
if (attachment.source.type === "url") return attachment.source.value;
|
|
45
|
+
return documentBlobUrl.value;
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
watch(
|
|
49
|
+
activeLightboxAttachment,
|
|
50
|
+
(next, previous) => {
|
|
51
|
+
if (documentBlobUrl.value) {
|
|
52
|
+
URL.revokeObjectURL(documentBlobUrl.value);
|
|
53
|
+
documentBlobUrl.value = null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (
|
|
57
|
+
!next ||
|
|
58
|
+
next.type !== "document" ||
|
|
59
|
+
next.source.type !== "data" ||
|
|
60
|
+
typeof window === "undefined"
|
|
61
|
+
) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const mimeType = next.source.mimeType;
|
|
66
|
+
if (!isPdf(mimeType) && !isText(mimeType)) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const blobUrl = createBlobUrl(next.source.value, mimeType);
|
|
71
|
+
documentBlobUrl.value = blobUrl;
|
|
72
|
+
},
|
|
73
|
+
{ immediate: true },
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
watch(isLightboxOpen, (open, _previous, onCleanup) => {
|
|
77
|
+
if (!open || typeof document === "undefined") return;
|
|
78
|
+
|
|
79
|
+
const handleKeydown = (event: KeyboardEvent) => {
|
|
80
|
+
if (event.key === "Escape") {
|
|
81
|
+
closeLightbox();
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
document.addEventListener("keydown", handleKeydown);
|
|
85
|
+
onCleanup(() => {
|
|
86
|
+
document.removeEventListener("keydown", handleKeydown);
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
onBeforeUnmount(() => {
|
|
91
|
+
if (documentBlobUrl.value) {
|
|
92
|
+
URL.revokeObjectURL(documentBlobUrl.value);
|
|
93
|
+
documentBlobUrl.value = null;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
function openLightbox(attachment: Attachment) {
|
|
98
|
+
if (typeof document !== "undefined") {
|
|
99
|
+
const withTransition = document as Document & {
|
|
100
|
+
startViewTransition?: (cb: () => void) => unknown;
|
|
101
|
+
};
|
|
102
|
+
if (typeof withTransition.startViewTransition === "function") {
|
|
103
|
+
withTransition.startViewTransition(() => {
|
|
104
|
+
activeLightboxAttachment.value = attachment;
|
|
105
|
+
});
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
activeLightboxAttachment.value = attachment;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function closeLightbox() {
|
|
113
|
+
activeLightboxAttachment.value = null;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function cardClassName(attachment: Attachment) {
|
|
117
|
+
if (attachment.type === "image" || attachment.type === "video") {
|
|
118
|
+
return "cpk:w-[72px] cpk:h-[72px]";
|
|
119
|
+
}
|
|
120
|
+
if (attachment.type === "audio") {
|
|
121
|
+
return "cpk:min-w-[200px] cpk:max-w-[280px] cpk:flex-col cpk:p-1 cpk:pr-8";
|
|
122
|
+
}
|
|
123
|
+
return "cpk:p-2 cpk:px-3 cpk:pr-8 cpk:max-w-[240px]";
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function isPdf(mimeType: string | undefined): boolean {
|
|
127
|
+
return !!mimeType && mimeType.includes("pdf");
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function isText(mimeType: string | undefined): boolean {
|
|
131
|
+
return !!mimeType && mimeType.startsWith("text/");
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function createBlobUrl(
|
|
135
|
+
base64Value: string,
|
|
136
|
+
mimeType: string | undefined,
|
|
137
|
+
): string | null {
|
|
138
|
+
try {
|
|
139
|
+
const binary = atob(base64Value);
|
|
140
|
+
const bytes = new Uint8Array(binary.length);
|
|
141
|
+
for (let i = 0; i < binary.length; i += 1) {
|
|
142
|
+
bytes[i] = binary.charCodeAt(i);
|
|
143
|
+
}
|
|
144
|
+
const blob = new Blob([bytes], {
|
|
145
|
+
type: mimeType || "application/octet-stream",
|
|
146
|
+
});
|
|
147
|
+
return URL.createObjectURL(blob);
|
|
148
|
+
} catch (error) {
|
|
149
|
+
console.error("[CopilotKit] Failed to decode attachment data:", error);
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
</script>
|
|
154
|
+
|
|
155
|
+
<template>
|
|
156
|
+
<div
|
|
157
|
+
v-if="props.attachments.length > 0"
|
|
158
|
+
class="cpk:flex cpk:flex-wrap cpk:gap-2 cpk:p-2"
|
|
159
|
+
:class="props.className"
|
|
160
|
+
data-testid="copilot-chat-attachment-queue"
|
|
161
|
+
>
|
|
162
|
+
<div
|
|
163
|
+
v-for="attachment in props.attachments"
|
|
164
|
+
:key="attachment.id"
|
|
165
|
+
class="cpk:relative cpk:inline-flex cpk:rounded-lg cpk:overflow-hidden cpk:border cpk:border-border"
|
|
166
|
+
:class="cardClassName(attachment)"
|
|
167
|
+
data-testid="copilot-chat-attachment-item"
|
|
168
|
+
:data-card-type="attachment.type"
|
|
169
|
+
>
|
|
170
|
+
<div
|
|
171
|
+
v-if="attachment.status === 'uploading'"
|
|
172
|
+
class="cpk:absolute cpk:inset-0 cpk:flex cpk:items-center cpk:justify-center cpk:bg-black/40 cpk:z-10"
|
|
173
|
+
data-testid="copilot-chat-attachment-uploading-overlay"
|
|
174
|
+
>
|
|
175
|
+
<div
|
|
176
|
+
class="cpk:w-5 cpk:h-5 cpk:border-2 cpk:border-white cpk:border-t-transparent cpk:rounded-full cpk:animate-spin"
|
|
177
|
+
/>
|
|
178
|
+
</div>
|
|
179
|
+
|
|
180
|
+
<template v-if="attachment.status === 'ready'">
|
|
181
|
+
<button
|
|
182
|
+
v-if="attachment.type === 'image'"
|
|
183
|
+
type="button"
|
|
184
|
+
class="cpk:w-full cpk:h-full cpk:border-none cpk:bg-transparent cpk:p-0 cpk:cursor-pointer"
|
|
185
|
+
data-testid="copilot-chat-attachment-image-button"
|
|
186
|
+
@click="openLightbox(attachment)"
|
|
187
|
+
>
|
|
188
|
+
<img
|
|
189
|
+
:src="getSourceUrl(attachment.source)"
|
|
190
|
+
:alt="attachment.filename || 'Image attachment'"
|
|
191
|
+
class="cpk:w-full cpk:h-full cpk:object-cover"
|
|
192
|
+
data-testid="copilot-chat-attachment-image-thumbnail"
|
|
193
|
+
/>
|
|
194
|
+
</button>
|
|
195
|
+
|
|
196
|
+
<div
|
|
197
|
+
v-else-if="attachment.type === 'video'"
|
|
198
|
+
class="cpk:w-full cpk:h-full cpk:relative"
|
|
199
|
+
>
|
|
200
|
+
<img
|
|
201
|
+
v-if="attachment.thumbnail"
|
|
202
|
+
:src="attachment.thumbnail"
|
|
203
|
+
:alt="attachment.filename || 'Video thumbnail'"
|
|
204
|
+
class="cpk:w-full cpk:h-full cpk:object-cover"
|
|
205
|
+
data-testid="copilot-chat-attachment-video-thumbnail"
|
|
206
|
+
/>
|
|
207
|
+
<video
|
|
208
|
+
v-else
|
|
209
|
+
:src="getSourceUrl(attachment.source)"
|
|
210
|
+
preload="metadata"
|
|
211
|
+
muted
|
|
212
|
+
class="cpk:w-full cpk:h-full cpk:object-cover"
|
|
213
|
+
data-testid="copilot-chat-attachment-video-fallback"
|
|
214
|
+
/>
|
|
215
|
+
<button
|
|
216
|
+
type="button"
|
|
217
|
+
class="cpk:absolute cpk:inset-0 cpk:flex cpk:items-center cpk:justify-center cpk:z-10 cpk:cursor-pointer cpk:bg-black/20 cpk:border-none cpk:p-0"
|
|
218
|
+
aria-label="Play video"
|
|
219
|
+
data-testid="copilot-chat-attachment-video-play"
|
|
220
|
+
@click="openLightbox(attachment)"
|
|
221
|
+
>
|
|
222
|
+
<div
|
|
223
|
+
class="cpk:w-8 cpk:h-8 cpk:rounded-full cpk:bg-black/60 cpk:flex cpk:items-center cpk:justify-center cpk:text-white cpk:text-xs cpk:font-semibold"
|
|
224
|
+
>
|
|
225
|
+
▶
|
|
226
|
+
</div>
|
|
227
|
+
</button>
|
|
228
|
+
</div>
|
|
229
|
+
|
|
230
|
+
<div
|
|
231
|
+
v-else-if="attachment.type === 'audio'"
|
|
232
|
+
class="cpk:flex cpk:flex-col cpk:gap-1 cpk:w-full"
|
|
233
|
+
>
|
|
234
|
+
<audio
|
|
235
|
+
:src="getSourceUrl(attachment.source)"
|
|
236
|
+
controls
|
|
237
|
+
preload="metadata"
|
|
238
|
+
class="cpk:w-full cpk:h-8"
|
|
239
|
+
data-testid="copilot-chat-attachment-audio-player"
|
|
240
|
+
/>
|
|
241
|
+
<span
|
|
242
|
+
v-if="attachment.filename"
|
|
243
|
+
class="cpk:text-xs cpk:font-medium cpk:overflow-hidden cpk:text-ellipsis cpk:whitespace-nowrap"
|
|
244
|
+
>
|
|
245
|
+
{{ attachment.filename }}
|
|
246
|
+
</span>
|
|
247
|
+
</div>
|
|
248
|
+
|
|
249
|
+
<button
|
|
250
|
+
v-else
|
|
251
|
+
type="button"
|
|
252
|
+
class="cpk:flex cpk:items-center cpk:gap-2 cpk:w-full cpk:border-none cpk:bg-transparent cpk:p-0 cpk:text-left"
|
|
253
|
+
:class="
|
|
254
|
+
isPdf(attachment.source.mimeType) ||
|
|
255
|
+
isText(attachment.source.mimeType)
|
|
256
|
+
? 'cpk:cursor-pointer'
|
|
257
|
+
: 'cpk:cursor-default'
|
|
258
|
+
"
|
|
259
|
+
data-testid="copilot-chat-attachment-document-button"
|
|
260
|
+
@click="
|
|
261
|
+
(isPdf(attachment.source.mimeType) ||
|
|
262
|
+
isText(attachment.source.mimeType)) &&
|
|
263
|
+
openLightbox(attachment)
|
|
264
|
+
"
|
|
265
|
+
>
|
|
266
|
+
<div
|
|
267
|
+
class="cpk:w-8 cpk:h-8 cpk:rounded-md cpk:bg-primary cpk:text-primary-foreground cpk:flex cpk:items-center cpk:justify-center cpk:text-[10px] cpk:font-semibold cpk:shrink-0"
|
|
268
|
+
>
|
|
269
|
+
{{ getDocumentIcon(attachment.source.mimeType ?? "") }}
|
|
270
|
+
</div>
|
|
271
|
+
<div class="cpk:flex cpk:flex-col cpk:min-w-0">
|
|
272
|
+
<span
|
|
273
|
+
class="cpk:text-xs cpk:font-medium cpk:break-all cpk:leading-tight"
|
|
274
|
+
data-testid="copilot-chat-attachment-document-filename"
|
|
275
|
+
>
|
|
276
|
+
{{ attachment.filename || "Document" }}
|
|
277
|
+
</span>
|
|
278
|
+
<span
|
|
279
|
+
v-if="attachment.size != null"
|
|
280
|
+
class="cpk:text-[11px] cpk:text-muted-foreground"
|
|
281
|
+
>
|
|
282
|
+
{{ formatFileSize(attachment.size) }}
|
|
283
|
+
</span>
|
|
284
|
+
</div>
|
|
285
|
+
</button>
|
|
286
|
+
</template>
|
|
287
|
+
|
|
288
|
+
<div
|
|
289
|
+
v-else
|
|
290
|
+
class="cpk:w-full cpk:h-full cpk:bg-muted-foreground/20"
|
|
291
|
+
data-testid="copilot-chat-attachment-placeholder"
|
|
292
|
+
/>
|
|
293
|
+
|
|
294
|
+
<button
|
|
295
|
+
type="button"
|
|
296
|
+
class="cpk:absolute cpk:bg-black/60 cpk:text-white cpk:border-none cpk:rounded-full cpk:w-5 cpk:h-5 cpk:flex cpk:items-center cpk:justify-center cpk:cursor-pointer cpk:text-[10px] cpk:z-20 cpk:top-1 cpk:right-1"
|
|
297
|
+
aria-label="Remove attachment"
|
|
298
|
+
@click="emit('remove-attachment', attachment.id)"
|
|
299
|
+
>
|
|
300
|
+
✕
|
|
301
|
+
</button>
|
|
302
|
+
</div>
|
|
303
|
+
</div>
|
|
304
|
+
|
|
305
|
+
<Teleport to="body">
|
|
306
|
+
<div
|
|
307
|
+
v-if="activeLightboxAttachment"
|
|
308
|
+
class="cpk:fixed cpk:inset-0 cpk:z-[9999] cpk:flex cpk:items-center cpk:justify-center cpk:bg-black/80"
|
|
309
|
+
data-testid="copilot-chat-attachment-lightbox"
|
|
310
|
+
@click="closeLightbox"
|
|
311
|
+
>
|
|
312
|
+
<button
|
|
313
|
+
type="button"
|
|
314
|
+
class="cpk:absolute cpk:top-4 cpk:right-4 cpk:text-white cpk:bg-white/10 cpk:hover:bg-white/20 cpk:rounded-full cpk:w-10 cpk:h-10 cpk:flex cpk:items-center cpk:justify-center cpk:cursor-pointer cpk:border-none"
|
|
315
|
+
aria-label="Close preview"
|
|
316
|
+
@click.stop="closeLightbox"
|
|
317
|
+
>
|
|
318
|
+
✕
|
|
319
|
+
</button>
|
|
320
|
+
|
|
321
|
+
<div data-testid="copilot-chat-attachment-lightbox-content" @click.stop>
|
|
322
|
+
<img
|
|
323
|
+
v-if="activeLightboxAttachment.type === 'image'"
|
|
324
|
+
:src="getSourceUrl(activeLightboxAttachment.source)"
|
|
325
|
+
:alt="activeLightboxAttachment.filename || 'Image attachment'"
|
|
326
|
+
class="cpk:max-w-[90vw] cpk:max-h-[90vh] cpk:object-contain cpk:rounded-lg"
|
|
327
|
+
data-testid="copilot-chat-attachment-lightbox-image"
|
|
328
|
+
/>
|
|
329
|
+
|
|
330
|
+
<video
|
|
331
|
+
v-else-if="activeLightboxAttachment.type === 'video'"
|
|
332
|
+
:src="getSourceUrl(activeLightboxAttachment.source)"
|
|
333
|
+
controls
|
|
334
|
+
autoplay
|
|
335
|
+
class="cpk:max-w-[90vw] cpk:max-h-[90vh] cpk:rounded-lg"
|
|
336
|
+
data-testid="copilot-chat-attachment-lightbox-video"
|
|
337
|
+
/>
|
|
338
|
+
|
|
339
|
+
<template v-else-if="activeLightboxAttachment.type === 'document'">
|
|
340
|
+
<iframe
|
|
341
|
+
v-if="
|
|
342
|
+
isPreviewableDocument &&
|
|
343
|
+
isPdf(activeLightboxAttachment.source.mimeType) &&
|
|
344
|
+
lightboxDocumentSource
|
|
345
|
+
"
|
|
346
|
+
:src="lightboxDocumentSource"
|
|
347
|
+
:title="activeLightboxAttachment.filename || 'PDF preview'"
|
|
348
|
+
class="cpk:w-[90vw] cpk:h-[90vh] cpk:max-w-[1000px] cpk:rounded-lg cpk:bg-white"
|
|
349
|
+
data-testid="copilot-chat-attachment-lightbox-document-iframe"
|
|
350
|
+
/>
|
|
351
|
+
|
|
352
|
+
<div
|
|
353
|
+
v-else-if="
|
|
354
|
+
isPreviewableDocument &&
|
|
355
|
+
isText(activeLightboxAttachment.source.mimeType)
|
|
356
|
+
"
|
|
357
|
+
class="cpk:w-[90vw] cpk:max-w-[800px] cpk:max-h-[90vh] cpk:overflow-auto cpk:rounded-lg cpk:bg-white cpk:dark:bg-gray-900 cpk:p-6"
|
|
358
|
+
>
|
|
359
|
+
<pre
|
|
360
|
+
v-if="decodedTextPreview !== null"
|
|
361
|
+
class="cpk:text-sm cpk:whitespace-pre-wrap cpk:wrap-break-word cpk:text-gray-800 cpk:dark:text-gray-200 cpk:font-mono cpk:m-0"
|
|
362
|
+
data-testid="copilot-chat-attachment-lightbox-document-text"
|
|
363
|
+
>{{ decodedTextPreview }}</pre
|
|
364
|
+
>
|
|
365
|
+
<iframe
|
|
366
|
+
v-else-if="lightboxDocumentSource"
|
|
367
|
+
:src="lightboxDocumentSource"
|
|
368
|
+
:title="activeLightboxAttachment.filename || 'Text preview'"
|
|
369
|
+
class="cpk:w-full cpk:h-[80vh] cpk:border-none"
|
|
370
|
+
data-testid="copilot-chat-attachment-lightbox-document-iframe"
|
|
371
|
+
/>
|
|
372
|
+
</div>
|
|
373
|
+
|
|
374
|
+
<div
|
|
375
|
+
v-else
|
|
376
|
+
class="cpk:flex cpk:flex-col cpk:items-center cpk:gap-4 cpk:p-8 cpk:rounded-lg cpk:bg-white cpk:dark:bg-gray-900"
|
|
377
|
+
data-testid="copilot-chat-attachment-lightbox-document-fallback"
|
|
378
|
+
>
|
|
379
|
+
<div
|
|
380
|
+
class="cpk:w-16 cpk:h-16 cpk:rounded-xl cpk:bg-primary cpk:text-primary-foreground cpk:flex cpk:items-center cpk:justify-center cpk:text-xl cpk:font-bold"
|
|
381
|
+
>
|
|
382
|
+
{{
|
|
383
|
+
getDocumentIcon(activeLightboxAttachment.source.mimeType ?? "")
|
|
384
|
+
}}
|
|
385
|
+
</div>
|
|
386
|
+
<div class="cpk:text-center">
|
|
387
|
+
<div
|
|
388
|
+
class="cpk:text-base cpk:font-medium cpk:text-gray-800 cpk:dark:text-gray-200"
|
|
389
|
+
>
|
|
390
|
+
{{ activeLightboxAttachment.filename || "Document" }}
|
|
391
|
+
</div>
|
|
392
|
+
<div
|
|
393
|
+
class="cpk:text-sm cpk:text-gray-500 cpk:dark:text-gray-400 cpk:mt-1"
|
|
394
|
+
>
|
|
395
|
+
{{ activeLightboxAttachment.source.mimeType || "Unknown type" }}
|
|
396
|
+
{{
|
|
397
|
+
activeLightboxAttachment.size != null
|
|
398
|
+
? ` · ${formatFileSize(activeLightboxAttachment.size)}`
|
|
399
|
+
: ""
|
|
400
|
+
}}
|
|
401
|
+
</div>
|
|
402
|
+
</div>
|
|
403
|
+
<div class="cpk:text-xs cpk:text-gray-400 cpk:dark:text-gray-500">
|
|
404
|
+
No preview available for this file type
|
|
405
|
+
</div>
|
|
406
|
+
</div>
|
|
407
|
+
</template>
|
|
408
|
+
</div>
|
|
409
|
+
</div>
|
|
410
|
+
</Teleport>
|
|
411
|
+
</template>
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, ref } from "vue";
|
|
3
|
+
import { getDocumentIcon, getSourceUrl } from "@copilotkit/shared";
|
|
4
|
+
import type { CopilotChatAttachmentRendererProps } from "./types";
|
|
5
|
+
|
|
6
|
+
const props = withDefaults(defineProps<CopilotChatAttachmentRendererProps>(), {
|
|
7
|
+
filename: undefined,
|
|
8
|
+
className: "",
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const imageLoadFailed = ref(false);
|
|
12
|
+
const sourceUrl = computed(() => getSourceUrl(props.source));
|
|
13
|
+
const documentLabel = computed(
|
|
14
|
+
() => props.filename || props.source.mimeType || "Unknown type",
|
|
15
|
+
);
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<template>
|
|
19
|
+
<img
|
|
20
|
+
v-if="props.type === 'image' && !imageLoadFailed"
|
|
21
|
+
:src="sourceUrl"
|
|
22
|
+
alt="Image attachment"
|
|
23
|
+
class="cpk:max-w-full cpk:h-auto cpk:rounded-lg"
|
|
24
|
+
:class="props.className"
|
|
25
|
+
data-testid="copilot-chat-attachment-renderer-image"
|
|
26
|
+
@error="imageLoadFailed = true"
|
|
27
|
+
/>
|
|
28
|
+
<div
|
|
29
|
+
v-else-if="props.type === 'image'"
|
|
30
|
+
class="cpk:flex cpk:flex-col cpk:items-center cpk:justify-center cpk:rounded-lg cpk:bg-muted cpk:p-4 cpk:text-sm cpk:text-muted-foreground"
|
|
31
|
+
:class="props.className"
|
|
32
|
+
data-testid="copilot-chat-attachment-renderer-image-fallback"
|
|
33
|
+
>
|
|
34
|
+
<span>Failed to load image</span>
|
|
35
|
+
</div>
|
|
36
|
+
|
|
37
|
+
<div
|
|
38
|
+
v-else-if="props.type === 'audio'"
|
|
39
|
+
class="cpk:flex cpk:flex-col cpk:gap-1"
|
|
40
|
+
:class="props.className"
|
|
41
|
+
data-testid="copilot-chat-attachment-renderer-audio"
|
|
42
|
+
>
|
|
43
|
+
<audio
|
|
44
|
+
:src="sourceUrl"
|
|
45
|
+
controls
|
|
46
|
+
preload="metadata"
|
|
47
|
+
class="cpk:max-w-[300px] cpk:w-full cpk:h-10"
|
|
48
|
+
/>
|
|
49
|
+
<span
|
|
50
|
+
v-if="props.filename"
|
|
51
|
+
class="cpk:text-xs cpk:text-muted-foreground cpk:truncate cpk:max-w-[300px]"
|
|
52
|
+
data-testid="copilot-chat-attachment-renderer-audio-filename"
|
|
53
|
+
>
|
|
54
|
+
{{ props.filename }}
|
|
55
|
+
</span>
|
|
56
|
+
</div>
|
|
57
|
+
|
|
58
|
+
<video
|
|
59
|
+
v-else-if="props.type === 'video'"
|
|
60
|
+
:src="sourceUrl"
|
|
61
|
+
controls
|
|
62
|
+
preload="metadata"
|
|
63
|
+
class="cpk:max-w-[400px] cpk:w-full cpk:rounded-lg"
|
|
64
|
+
:class="props.className"
|
|
65
|
+
data-testid="copilot-chat-attachment-renderer-video"
|
|
66
|
+
/>
|
|
67
|
+
|
|
68
|
+
<div
|
|
69
|
+
v-else
|
|
70
|
+
class="cpk:inline-flex cpk:items-center cpk:gap-2 cpk:px-3 cpk:py-2 cpk:border cpk:border-border cpk:rounded-lg cpk:bg-muted"
|
|
71
|
+
:class="props.className"
|
|
72
|
+
data-testid="copilot-chat-attachment-renderer-document"
|
|
73
|
+
>
|
|
74
|
+
<span
|
|
75
|
+
class="cpk:text-xs cpk:font-bold cpk:uppercase"
|
|
76
|
+
data-testid="copilot-chat-attachment-renderer-document-icon"
|
|
77
|
+
>
|
|
78
|
+
{{ getDocumentIcon(props.source.mimeType ?? "") }}
|
|
79
|
+
</span>
|
|
80
|
+
<span
|
|
81
|
+
class="cpk:text-sm cpk:text-muted-foreground cpk:truncate"
|
|
82
|
+
data-testid="copilot-chat-attachment-renderer-document-label"
|
|
83
|
+
>
|
|
84
|
+
{{ documentLabel }}
|
|
85
|
+
</span>
|
|
86
|
+
</div>
|
|
87
|
+
</template>
|