@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,138 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { defineComponent, h, provide, ref } from "vue";
|
|
3
|
+
import { render, cleanup } from "@testing-library/vue";
|
|
4
|
+
import CopilotKitProvider from "../../../providers/CopilotKitProvider.vue";
|
|
5
|
+
import CopilotChatConfigurationProvider from "../../../providers/CopilotChatConfigurationProvider.vue";
|
|
6
|
+
import {
|
|
7
|
+
LicenseContextKey,
|
|
8
|
+
type LicenseContextValue,
|
|
9
|
+
} from "../../../providers/license-context";
|
|
10
|
+
import { StateCapturingAgent } from "../../../__tests__/utils/agents";
|
|
11
|
+
import CopilotChat from "../CopilotChat.vue";
|
|
12
|
+
import CopilotSidebar from "../CopilotSidebar.vue";
|
|
13
|
+
import CopilotPopup from "../CopilotPopup.vue";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Vue parity tests for the inline feature warning surfaces on
|
|
17
|
+
* `CopilotChat`, `CopilotSidebar`, and `CopilotPopup`. Mirrors the React
|
|
18
|
+
* inline warning + console.warn behavior at:
|
|
19
|
+
* packages/react-core/src/v2/components/chat/CopilotChat.tsx
|
|
20
|
+
* packages/react-core/src/v2/components/chat/CopilotSidebar.tsx
|
|
21
|
+
* packages/react-core/src/v2/components/chat/CopilotPopup.tsx
|
|
22
|
+
*
|
|
23
|
+
* The default `createLicenseContextValue(null)` is permissive
|
|
24
|
+
* (`checkFeature` always returns true), so the inline warning is never
|
|
25
|
+
* rendered in the default path. We test both the default path
|
|
26
|
+
* (no warning) and an explicit gated path (warning rendered + console
|
|
27
|
+
* warned) by overriding the injected license context.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
function makeLicenseRef(licensed: boolean) {
|
|
31
|
+
const value: LicenseContextValue = {
|
|
32
|
+
status: null,
|
|
33
|
+
license: null,
|
|
34
|
+
checkFeature: () => licensed,
|
|
35
|
+
getLimit: () => null,
|
|
36
|
+
};
|
|
37
|
+
return ref(value);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function mountWith(opts: {
|
|
41
|
+
licensed: boolean;
|
|
42
|
+
component: typeof CopilotChat | typeof CopilotSidebar | typeof CopilotPopup;
|
|
43
|
+
}) {
|
|
44
|
+
// The CopilotKitProvider re-`provide`s `LicenseContextKey` with the
|
|
45
|
+
// permissive default. To override it for these tests, install our custom
|
|
46
|
+
// license ref on a wrapper rendered *inside* the provider.
|
|
47
|
+
const LicenseOverride = defineComponent({
|
|
48
|
+
setup(_, { slots }) {
|
|
49
|
+
provide(LicenseContextKey, makeLicenseRef(opts.licensed));
|
|
50
|
+
return () => slots.default?.();
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const Host = defineComponent({
|
|
55
|
+
setup() {
|
|
56
|
+
return () =>
|
|
57
|
+
h(
|
|
58
|
+
CopilotKitProvider,
|
|
59
|
+
{ agents__unsafe_dev_only: { default: new StateCapturingAgent() } },
|
|
60
|
+
{
|
|
61
|
+
default: () =>
|
|
62
|
+
h(LicenseOverride, null, {
|
|
63
|
+
default: () =>
|
|
64
|
+
h(
|
|
65
|
+
CopilotChatConfigurationProvider,
|
|
66
|
+
{ threadId: "test-thread" },
|
|
67
|
+
{
|
|
68
|
+
default: () => h(opts.component),
|
|
69
|
+
},
|
|
70
|
+
),
|
|
71
|
+
}),
|
|
72
|
+
},
|
|
73
|
+
);
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
return render(Host);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
let warnSpy: ReturnType<typeof vi.spyOn>;
|
|
80
|
+
|
|
81
|
+
beforeEach(() => {
|
|
82
|
+
warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
afterEach(() => {
|
|
86
|
+
cleanup();
|
|
87
|
+
vi.restoreAllMocks();
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
describe("CopilotChat license inline warning", () => {
|
|
91
|
+
it("does not render an inline warning under the default permissive license context", () => {
|
|
92
|
+
const view = mountWith({ licensed: true, component: CopilotChat });
|
|
93
|
+
expect(view.queryByTestId("copilot-inline-feature-warning")).toBeNull();
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('renders the "Chat" inline warning and console-warns when chat is unlicensed', () => {
|
|
97
|
+
const view = mountWith({ licensed: false, component: CopilotChat });
|
|
98
|
+
const warning = view.getByTestId("copilot-inline-feature-warning");
|
|
99
|
+
expect(warning.textContent).toContain("Chat");
|
|
100
|
+
expect(warnSpy).toHaveBeenCalledWith(
|
|
101
|
+
'[CopilotKit] Warning: "chat" feature is not licensed. Visit copilotkit.ai/pricing',
|
|
102
|
+
);
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
describe("CopilotSidebar license inline warning", () => {
|
|
107
|
+
it("does not render an inline warning under the default permissive license context", () => {
|
|
108
|
+
const view = mountWith({ licensed: true, component: CopilotSidebar });
|
|
109
|
+
expect(view.queryByTestId("copilot-inline-feature-warning")).toBeNull();
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it('renders the "Sidebar" inline warning and console-warns when sidebar is unlicensed', () => {
|
|
113
|
+
const view = mountWith({ licensed: false, component: CopilotSidebar });
|
|
114
|
+
const warnings = view.getAllByTestId("copilot-inline-feature-warning");
|
|
115
|
+
// Sidebar wraps CopilotChat, so the wrapper warning + the chat warning
|
|
116
|
+
// both render. The sidebar warning is emitted first in DOM order.
|
|
117
|
+
expect(warnings[0]?.textContent).toContain("Sidebar");
|
|
118
|
+
expect(warnSpy).toHaveBeenCalledWith(
|
|
119
|
+
'[CopilotKit] Warning: "sidebar" feature is not licensed. Visit copilotkit.ai/pricing',
|
|
120
|
+
);
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
describe("CopilotPopup license inline warning", () => {
|
|
125
|
+
it("does not render an inline warning under the default permissive license context", () => {
|
|
126
|
+
const view = mountWith({ licensed: true, component: CopilotPopup });
|
|
127
|
+
expect(view.queryByTestId("copilot-inline-feature-warning")).toBeNull();
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('renders the "Popup" inline warning and console-warns when popup is unlicensed', () => {
|
|
131
|
+
const view = mountWith({ licensed: false, component: CopilotPopup });
|
|
132
|
+
const warnings = view.getAllByTestId("copilot-inline-feature-warning");
|
|
133
|
+
expect(warnings[0]?.textContent).toContain("Popup");
|
|
134
|
+
expect(warnSpy).toHaveBeenCalledWith(
|
|
135
|
+
'[CopilotKit] Warning: "popup" feature is not licensed. Visit copilotkit.ai/pricing',
|
|
136
|
+
);
|
|
137
|
+
});
|
|
138
|
+
});
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from "vitest";
|
|
2
|
+
import { defineComponent } from "vue";
|
|
3
|
+
import { CopilotKitCoreErrorCode } from "@copilotkit/core";
|
|
4
|
+
import type { BaseEvent, RunAgentInput } from "@ag-ui/client";
|
|
5
|
+
import { Observable, EMPTY } from "rxjs";
|
|
6
|
+
import {
|
|
7
|
+
MockStepwiseAgent,
|
|
8
|
+
renderWithCopilotKit,
|
|
9
|
+
} from "../../../__tests__/utils/test-helpers";
|
|
10
|
+
import CopilotChat from "../CopilotChat.vue";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Mock agent whose connect() always fails
|
|
14
|
+
*/
|
|
15
|
+
class FailingConnectAgent extends MockStepwiseAgent {
|
|
16
|
+
override run(input: RunAgentInput): Observable<BaseEvent> {
|
|
17
|
+
return super.run(input);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
override connect(_input: RunAgentInput): Observable<BaseEvent> {
|
|
21
|
+
return new Observable((subscriber) => {
|
|
22
|
+
subscriber.error(new Error("connect failed"));
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Mock agent whose connect() succeeds (returns empty observable)
|
|
29
|
+
*/
|
|
30
|
+
class HealthyConnectAgent extends MockStepwiseAgent {
|
|
31
|
+
override run(input: RunAgentInput): Observable<BaseEvent> {
|
|
32
|
+
return super.run(input);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
override connect(_input: RunAgentInput): Observable<BaseEvent> {
|
|
36
|
+
return EMPTY;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function createHost(chatOnError: (event: unknown) => void) {
|
|
41
|
+
return defineComponent({
|
|
42
|
+
components: { CopilotChat },
|
|
43
|
+
setup() {
|
|
44
|
+
return { chatOnError };
|
|
45
|
+
},
|
|
46
|
+
template: `
|
|
47
|
+
<CopilotChat :welcome-screen="false" :on-error="chatOnError" />
|
|
48
|
+
`,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
describe("CopilotChat onError", () => {
|
|
53
|
+
it("connectAgent failure fires onError on CopilotChat and does not crash", async () => {
|
|
54
|
+
const agent = new FailingConnectAgent();
|
|
55
|
+
const chatOnError = vi.fn();
|
|
56
|
+
|
|
57
|
+
renderWithCopilotKit({
|
|
58
|
+
agent,
|
|
59
|
+
children: createHost(chatOnError),
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// Wait for the connectAgent error to propagate
|
|
63
|
+
await vi.waitFor(() => {
|
|
64
|
+
expect(chatOnError).toHaveBeenCalled();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// Check that AGENT_CONNECT_FAILED is among the errors
|
|
68
|
+
const allCodes = chatOnError.mock.calls.map((call) => call[0].code);
|
|
69
|
+
expect(allCodes).toContain(CopilotKitCoreErrorCode.AGENT_CONNECT_FAILED);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("onError on CopilotChat does not fire for a healthy agent", async () => {
|
|
73
|
+
const agent = new HealthyConnectAgent();
|
|
74
|
+
const chatOnError = vi.fn();
|
|
75
|
+
|
|
76
|
+
renderWithCopilotKit({
|
|
77
|
+
agent,
|
|
78
|
+
children: createHost(chatOnError),
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// No errors should fire for a healthy agent
|
|
82
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
83
|
+
expect(chatOnError).not.toHaveBeenCalled();
|
|
84
|
+
});
|
|
85
|
+
});
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { flushPromises } from "@vue/test-utils";
|
|
3
|
+
import { h } from "vue";
|
|
4
|
+
import CopilotChat from "../CopilotChat.vue";
|
|
5
|
+
import { renderWithCopilotKit } from "../../../__tests__/utils/mount";
|
|
6
|
+
import { StateCapturingAgent } from "../../../__tests__/utils/agents";
|
|
7
|
+
import { getThreadClone } from "../../../hooks/use-agent";
|
|
8
|
+
|
|
9
|
+
describe("CopilotChat.slots.e2e", () => {
|
|
10
|
+
it("supports full chat-view override with callback payload", async () => {
|
|
11
|
+
const agent = new StateCapturingAgent([], "default");
|
|
12
|
+
const onSubmitSpy = vi.fn();
|
|
13
|
+
|
|
14
|
+
const { wrapper, getCore } = renderWithCopilotKit(
|
|
15
|
+
() =>
|
|
16
|
+
h(
|
|
17
|
+
CopilotChat,
|
|
18
|
+
{
|
|
19
|
+
welcomeScreen: false,
|
|
20
|
+
onSubmitMessage: onSubmitSpy,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"chat-view": ({ messages, isRunning, onSubmitMessage }: any) =>
|
|
24
|
+
h("div", { "data-testid": "custom-chat-view" }, [
|
|
25
|
+
h("span", { "data-testid": "slot-running" }, String(isRunning)),
|
|
26
|
+
h(
|
|
27
|
+
"span",
|
|
28
|
+
{ "data-testid": "slot-message-count" },
|
|
29
|
+
String(messages.length),
|
|
30
|
+
),
|
|
31
|
+
h(
|
|
32
|
+
"button",
|
|
33
|
+
{
|
|
34
|
+
"data-testid": "slot-submit",
|
|
35
|
+
onClick: () => void onSubmitMessage("From custom slot"),
|
|
36
|
+
},
|
|
37
|
+
"submit",
|
|
38
|
+
),
|
|
39
|
+
]),
|
|
40
|
+
},
|
|
41
|
+
),
|
|
42
|
+
{ agents: { default: agent } },
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
expect(wrapper.find("[data-testid='custom-chat-view']").exists()).toBe(
|
|
46
|
+
true,
|
|
47
|
+
);
|
|
48
|
+
expect(wrapper.get("[data-testid='slot-message-count']").text()).toBe("0");
|
|
49
|
+
|
|
50
|
+
await wrapper.get("[data-testid='slot-submit']").trigger("click");
|
|
51
|
+
await flushPromises();
|
|
52
|
+
|
|
53
|
+
expect(onSubmitSpy).toHaveBeenCalledWith("From custom slot");
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("forwards message-view and welcome-message slots", async () => {
|
|
57
|
+
const agent = new StateCapturingAgent([], "default");
|
|
58
|
+
|
|
59
|
+
const { wrapper } = renderWithCopilotKit(
|
|
60
|
+
() =>
|
|
61
|
+
h(
|
|
62
|
+
CopilotChat,
|
|
63
|
+
{
|
|
64
|
+
welcomeScreen: false,
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"message-view": ({ messages }: any) =>
|
|
68
|
+
h(
|
|
69
|
+
"div",
|
|
70
|
+
{ "data-testid": "custom-message-view" },
|
|
71
|
+
String(messages.length),
|
|
72
|
+
),
|
|
73
|
+
"welcome-message": () =>
|
|
74
|
+
h(
|
|
75
|
+
"div",
|
|
76
|
+
{ "data-testid": "custom-welcome-message" },
|
|
77
|
+
"Welcome slot",
|
|
78
|
+
),
|
|
79
|
+
},
|
|
80
|
+
),
|
|
81
|
+
{ agents: { default: agent } },
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
expect(wrapper.get("[data-testid='custom-message-view']").text()).toBe("0");
|
|
85
|
+
|
|
86
|
+
const welcome = renderWithCopilotKit(
|
|
87
|
+
() =>
|
|
88
|
+
h(
|
|
89
|
+
CopilotChat,
|
|
90
|
+
{ welcomeScreen: true },
|
|
91
|
+
{
|
|
92
|
+
"welcome-message": () =>
|
|
93
|
+
h(
|
|
94
|
+
"div",
|
|
95
|
+
{ "data-testid": "custom-welcome-message" },
|
|
96
|
+
"Welcome slot",
|
|
97
|
+
),
|
|
98
|
+
},
|
|
99
|
+
),
|
|
100
|
+
{ agents: { default: new StateCapturingAgent([], "default") } },
|
|
101
|
+
);
|
|
102
|
+
expect(
|
|
103
|
+
welcome.wrapper.find("[data-testid='custom-welcome-message']").exists(),
|
|
104
|
+
).toBe(true);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it("resolves explicit agentId and threadId props over inherited config", async () => {
|
|
108
|
+
const defaultAgent = new StateCapturingAgent([], "default");
|
|
109
|
+
const customAgent = new StateCapturingAgent([], "custom-agent");
|
|
110
|
+
|
|
111
|
+
const { wrapper, getCore } = renderWithCopilotKit(
|
|
112
|
+
() =>
|
|
113
|
+
h(CopilotChat, {
|
|
114
|
+
agentId: "custom-agent",
|
|
115
|
+
threadId: "explicit-thread",
|
|
116
|
+
welcomeScreen: false,
|
|
117
|
+
}),
|
|
118
|
+
{
|
|
119
|
+
agents: {
|
|
120
|
+
default: defaultAgent,
|
|
121
|
+
"custom-agent": customAgent,
|
|
122
|
+
},
|
|
123
|
+
configProps: {
|
|
124
|
+
agentId: "default",
|
|
125
|
+
threadId: "inherited-thread",
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
const textarea = wrapper.get("textarea");
|
|
131
|
+
await textarea.setValue("hello");
|
|
132
|
+
await textarea.trigger("keydown", { key: "Enter" });
|
|
133
|
+
await flushPromises();
|
|
134
|
+
|
|
135
|
+
const registryAgent = getCore().getAgent("custom-agent");
|
|
136
|
+
const resolvedAgent = getThreadClone(registryAgent, "explicit-thread");
|
|
137
|
+
expect(defaultAgent.messages).toHaveLength(0);
|
|
138
|
+
expect(resolvedAgent?.threadId).toBe("explicit-thread");
|
|
139
|
+
expect(resolvedAgent?.messages.some((m) => m.role === "user")).toBe(true);
|
|
140
|
+
});
|
|
141
|
+
});
|