@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,652 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { defineComponent, h, nextTick } from "vue";
|
|
3
|
+
import { flushPromises, mount } from "@vue/test-utils";
|
|
4
|
+
import { CopilotKitCoreErrorCode } from "@copilotkit/core";
|
|
5
|
+
import CopilotKitProvider from "../../../providers/CopilotKitProvider.vue";
|
|
6
|
+
import CopilotChatConfigurationProvider from "../../../providers/CopilotChatConfigurationProvider.vue";
|
|
7
|
+
import { StateCapturingAgent } from "../../../__tests__/utils/agents";
|
|
8
|
+
import { useCopilotKit } from "../../../providers/useCopilotKit";
|
|
9
|
+
import { CopilotKitCoreVue } from "../../../lib/vue-core";
|
|
10
|
+
import CopilotChat from "../CopilotChat.vue";
|
|
11
|
+
import CopilotChatView from "../CopilotChatView.vue";
|
|
12
|
+
import { getThreadClone } from "../../../hooks/use-agent";
|
|
13
|
+
|
|
14
|
+
function mountChat(
|
|
15
|
+
props: Record<string, unknown> = {},
|
|
16
|
+
options: {
|
|
17
|
+
agents?: Record<string, StateCapturingAgent>;
|
|
18
|
+
providerThreadId?: string;
|
|
19
|
+
providerProps?: Record<string, unknown>;
|
|
20
|
+
slots?: Record<string, unknown>;
|
|
21
|
+
} = {},
|
|
22
|
+
) {
|
|
23
|
+
const agents = options.agents ?? { default: new StateCapturingAgent() };
|
|
24
|
+
|
|
25
|
+
return mount(CopilotKitProvider, {
|
|
26
|
+
props: {
|
|
27
|
+
agents__unsafe_dev_only: agents,
|
|
28
|
+
...options.providerProps,
|
|
29
|
+
},
|
|
30
|
+
slots: {
|
|
31
|
+
default: () =>
|
|
32
|
+
options.providerThreadId
|
|
33
|
+
? h(
|
|
34
|
+
CopilotChatConfigurationProvider,
|
|
35
|
+
{ threadId: options.providerThreadId },
|
|
36
|
+
{
|
|
37
|
+
default: () => h(CopilotChat, props, options.slots),
|
|
38
|
+
},
|
|
39
|
+
)
|
|
40
|
+
: h(CopilotChat, props, options.slots),
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function MediaRecorderMock() {}
|
|
46
|
+
|
|
47
|
+
describe("CopilotChat", () => {
|
|
48
|
+
const originalMediaRecorder = globalThis.MediaRecorder;
|
|
49
|
+
const originalFetch = globalThis.fetch;
|
|
50
|
+
let consoleErrorSpy: ReturnType<typeof vi.spyOn>;
|
|
51
|
+
|
|
52
|
+
interface CopilotKitCoreTestAccess {
|
|
53
|
+
notifySubscribers: (
|
|
54
|
+
handler: (subscriber: {
|
|
55
|
+
onError?: (event: {
|
|
56
|
+
copilotkit: CopilotKitCoreVue;
|
|
57
|
+
error: Error;
|
|
58
|
+
code: CopilotKitCoreErrorCode;
|
|
59
|
+
context: Record<string, any>;
|
|
60
|
+
}) => void | Promise<void>;
|
|
61
|
+
}) => void | Promise<void>,
|
|
62
|
+
errorMessage: string,
|
|
63
|
+
) => Promise<void>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
beforeEach(() => {
|
|
67
|
+
globalThis.MediaRecorder =
|
|
68
|
+
MediaRecorderMock as unknown as typeof MediaRecorder;
|
|
69
|
+
consoleErrorSpy = vi.spyOn(console, "error").mockImplementation(() => {});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
afterEach(() => {
|
|
73
|
+
vi.restoreAllMocks();
|
|
74
|
+
globalThis.fetch = originalFetch;
|
|
75
|
+
if (originalMediaRecorder) {
|
|
76
|
+
globalThis.MediaRecorder = originalMediaRecorder;
|
|
77
|
+
} else {
|
|
78
|
+
// @ts-expect-error test cleanup
|
|
79
|
+
delete globalThis.MediaRecorder;
|
|
80
|
+
}
|
|
81
|
+
consoleErrorSpy.mockRestore();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it("renders customized labels from props", async () => {
|
|
85
|
+
const wrapper = mountChat({
|
|
86
|
+
labels: {
|
|
87
|
+
chatInputPlaceholder: "Custom placeholder text...",
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
await nextTick();
|
|
92
|
+
expect(wrapper.find("textarea").attributes("placeholder")).toBe(
|
|
93
|
+
"Custom placeholder text...",
|
|
94
|
+
);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it("submits a user message and runs the resolved agent", async () => {
|
|
98
|
+
const agent = new StateCapturingAgent();
|
|
99
|
+
const runAgent = vi.spyOn(CopilotKitCoreVue.prototype, "runAgent");
|
|
100
|
+
const wrapper = mountChat({}, { agents: { default: agent } });
|
|
101
|
+
await flushPromises();
|
|
102
|
+
|
|
103
|
+
const chat = wrapper.findComponent(CopilotChat);
|
|
104
|
+
await chat
|
|
105
|
+
.findComponent(CopilotChatView)
|
|
106
|
+
.vm.$emit("submit-message", "Hello");
|
|
107
|
+
await flushPromises();
|
|
108
|
+
|
|
109
|
+
expect(chat.emitted("submit-message")).toEqual([["Hello"]]);
|
|
110
|
+
expect(runAgent).toHaveBeenCalledTimes(1);
|
|
111
|
+
expect(runAgent).toHaveBeenCalledWith(
|
|
112
|
+
expect.objectContaining({
|
|
113
|
+
agent: expect.objectContaining({ agentId: "default" }),
|
|
114
|
+
}),
|
|
115
|
+
);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it("uses the explicit agentId and threadId over inherited configuration", async () => {
|
|
119
|
+
const defaultAgent = new StateCapturingAgent([], "default");
|
|
120
|
+
const customAgent = new StateCapturingAgent([], "custom-agent");
|
|
121
|
+
let core:
|
|
122
|
+
| ReturnType<typeof useCopilotKit>["copilotkit"]["value"]
|
|
123
|
+
| undefined;
|
|
124
|
+
const Probe = defineComponent({
|
|
125
|
+
setup() {
|
|
126
|
+
const { copilotkit } = useCopilotKit();
|
|
127
|
+
core = copilotkit.value;
|
|
128
|
+
return () => null;
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
const wrapper = mount(CopilotKitProvider, {
|
|
132
|
+
props: {
|
|
133
|
+
agents__unsafe_dev_only: {
|
|
134
|
+
default: defaultAgent,
|
|
135
|
+
"custom-agent": customAgent,
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
slots: {
|
|
139
|
+
default: () =>
|
|
140
|
+
h(
|
|
141
|
+
CopilotChatConfigurationProvider,
|
|
142
|
+
{ threadId: "provider-thread" },
|
|
143
|
+
{
|
|
144
|
+
default: () =>
|
|
145
|
+
h("div", [
|
|
146
|
+
h(
|
|
147
|
+
CopilotChat,
|
|
148
|
+
{
|
|
149
|
+
agentId: "custom-agent",
|
|
150
|
+
threadId: "explicit-thread",
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
"chat-view": (slotProps: {
|
|
154
|
+
onSubmitMessage: (value: string) => Promise<void>;
|
|
155
|
+
}) =>
|
|
156
|
+
h(
|
|
157
|
+
"button",
|
|
158
|
+
{
|
|
159
|
+
"data-testid": "submit-via-slot",
|
|
160
|
+
onClick: () =>
|
|
161
|
+
void slotProps.onSubmitMessage(
|
|
162
|
+
"From custom agent",
|
|
163
|
+
),
|
|
164
|
+
},
|
|
165
|
+
"submit",
|
|
166
|
+
),
|
|
167
|
+
},
|
|
168
|
+
),
|
|
169
|
+
h(Probe),
|
|
170
|
+
]),
|
|
171
|
+
},
|
|
172
|
+
),
|
|
173
|
+
},
|
|
174
|
+
});
|
|
175
|
+
await flushPromises();
|
|
176
|
+
|
|
177
|
+
await wrapper.get("[data-testid='submit-via-slot']").trigger("click");
|
|
178
|
+
await flushPromises();
|
|
179
|
+
|
|
180
|
+
const registryAgent = core?.getAgent("custom-agent");
|
|
181
|
+
const resolvedAgent = getThreadClone(registryAgent, "explicit-thread");
|
|
182
|
+
expect(resolvedAgent?.threadId).toBe("explicit-thread");
|
|
183
|
+
expect(resolvedAgent?.messages.some((m) => m.role === "user")).toBe(true);
|
|
184
|
+
expect(defaultAgent.messages).toHaveLength(0);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it("does not invoke stop handlers when no active run is available", async () => {
|
|
188
|
+
const agent = new StateCapturingAgent();
|
|
189
|
+
|
|
190
|
+
let core:
|
|
191
|
+
| ReturnType<typeof useCopilotKit>["copilotkit"]["value"]
|
|
192
|
+
| undefined;
|
|
193
|
+
const Probe = defineComponent({
|
|
194
|
+
setup() {
|
|
195
|
+
const { copilotkit } = useCopilotKit();
|
|
196
|
+
core = copilotkit.value;
|
|
197
|
+
return () => null;
|
|
198
|
+
},
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
const wrapper = mount(CopilotKitProvider, {
|
|
202
|
+
props: {
|
|
203
|
+
agents__unsafe_dev_only: { default: agent },
|
|
204
|
+
},
|
|
205
|
+
slots: {
|
|
206
|
+
default: () =>
|
|
207
|
+
h("div", [
|
|
208
|
+
h(
|
|
209
|
+
CopilotChatConfigurationProvider,
|
|
210
|
+
{ threadId: "stop-thread" },
|
|
211
|
+
{
|
|
212
|
+
default: () =>
|
|
213
|
+
h(CopilotChat, null, {
|
|
214
|
+
"chat-view": (slotProps: { onStop?: () => void }) =>
|
|
215
|
+
h(
|
|
216
|
+
"button",
|
|
217
|
+
{
|
|
218
|
+
"data-testid": "stop-via-slot",
|
|
219
|
+
onClick: () => slotProps.onStop?.(),
|
|
220
|
+
},
|
|
221
|
+
"stop",
|
|
222
|
+
),
|
|
223
|
+
}),
|
|
224
|
+
},
|
|
225
|
+
),
|
|
226
|
+
h(Probe),
|
|
227
|
+
]),
|
|
228
|
+
},
|
|
229
|
+
});
|
|
230
|
+
await flushPromises();
|
|
231
|
+
|
|
232
|
+
const registryAgent = core?.getAgent("default");
|
|
233
|
+
const resolvedAgent = getThreadClone(registryAgent, "stop-thread");
|
|
234
|
+
const abortRun = vi.fn();
|
|
235
|
+
if (registryAgent) {
|
|
236
|
+
registryAgent.abortRun = abortRun;
|
|
237
|
+
}
|
|
238
|
+
if (resolvedAgent) {
|
|
239
|
+
resolvedAgent.abortRun = abortRun;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const stopAgent = vi.spyOn(core!, "stopAgent").mockImplementation(() => {
|
|
243
|
+
throw new Error("stop failed");
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
await wrapper.get("[data-testid='stop-via-slot']").trigger("click");
|
|
247
|
+
|
|
248
|
+
expect(stopAgent).toHaveBeenCalledTimes(0);
|
|
249
|
+
expect(abortRun).toHaveBeenCalledTimes(0);
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
it("transcribes audio through the runtime helper and updates the input value", async () => {
|
|
253
|
+
const onFinishTranscribeWithAudio = vi.fn().mockResolvedValue(undefined);
|
|
254
|
+
vi.spyOn(
|
|
255
|
+
CopilotKitCoreVue.prototype,
|
|
256
|
+
"audioFileTranscriptionEnabled",
|
|
257
|
+
"get",
|
|
258
|
+
).mockReturnValue(true);
|
|
259
|
+
|
|
260
|
+
const wrapper = mountChat(
|
|
261
|
+
{
|
|
262
|
+
onFinishTranscribeWithAudio,
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
slots: {
|
|
266
|
+
"chat-view": (slotProps: {
|
|
267
|
+
inputValue?: string;
|
|
268
|
+
onFinishTranscribeWithAudio?: (audioBlob: Blob) => Promise<void>;
|
|
269
|
+
}) =>
|
|
270
|
+
h("div", [
|
|
271
|
+
h("button", {
|
|
272
|
+
"data-testid": "transcribe-via-slot",
|
|
273
|
+
onClick: () =>
|
|
274
|
+
void slotProps.onFinishTranscribeWithAudio?.(
|
|
275
|
+
new Blob(["audio"], { type: "audio/webm" }),
|
|
276
|
+
),
|
|
277
|
+
}),
|
|
278
|
+
h(
|
|
279
|
+
"div",
|
|
280
|
+
{ "data-testid": "input-value" },
|
|
281
|
+
slotProps.inputValue ?? "",
|
|
282
|
+
),
|
|
283
|
+
]),
|
|
284
|
+
},
|
|
285
|
+
},
|
|
286
|
+
);
|
|
287
|
+
|
|
288
|
+
await wrapper.get("[data-testid='transcribe-via-slot']").trigger("click");
|
|
289
|
+
await flushPromises();
|
|
290
|
+
await nextTick();
|
|
291
|
+
|
|
292
|
+
expect(onFinishTranscribeWithAudio).toHaveBeenCalledTimes(1);
|
|
293
|
+
expect(wrapper.get("[data-testid='input-value']").text()).toBe("");
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
it("does not reconnect in a loop when connectAgent mutates agent state", async () => {
|
|
297
|
+
const agent = new StateCapturingAgent();
|
|
298
|
+
const connectAgent = vi
|
|
299
|
+
.spyOn(CopilotKitCoreVue.prototype, "connectAgent")
|
|
300
|
+
.mockImplementation(async ({ agent: connectedAgent }) => {
|
|
301
|
+
connectedAgent.setMessages([]);
|
|
302
|
+
connectedAgent.setState({});
|
|
303
|
+
return { newMessages: [] } as Awaited<
|
|
304
|
+
ReturnType<CopilotKitCoreVue["connectAgent"]>
|
|
305
|
+
>;
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
const Host = defineComponent({
|
|
309
|
+
components: { CopilotKitProvider, CopilotChat },
|
|
310
|
+
data() {
|
|
311
|
+
return {
|
|
312
|
+
threadId: "thread-a",
|
|
313
|
+
};
|
|
314
|
+
},
|
|
315
|
+
template: `
|
|
316
|
+
<CopilotKitProvider runtime-url="/api/copilotkit" :agents__unsafe_dev_only="{ default: agent }">
|
|
317
|
+
<CopilotChat :thread-id="threadId" />
|
|
318
|
+
</CopilotKitProvider>
|
|
319
|
+
`,
|
|
320
|
+
setup() {
|
|
321
|
+
return { agent };
|
|
322
|
+
},
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
const wrapper = mount(Host);
|
|
326
|
+
await flushPromises();
|
|
327
|
+
|
|
328
|
+
expect(connectAgent).toHaveBeenCalledTimes(1);
|
|
329
|
+
|
|
330
|
+
wrapper.vm.threadId = "thread-b";
|
|
331
|
+
await flushPromises();
|
|
332
|
+
|
|
333
|
+
expect(connectAgent).toHaveBeenCalledTimes(2);
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
it("filters chat onError to the resolved agent", async () => {
|
|
337
|
+
let core:
|
|
338
|
+
| ReturnType<typeof useCopilotKit>["copilotkit"]["value"]
|
|
339
|
+
| undefined;
|
|
340
|
+
const onError = vi.fn();
|
|
341
|
+
const Probe = defineComponent({
|
|
342
|
+
setup() {
|
|
343
|
+
const { copilotkit } = useCopilotKit();
|
|
344
|
+
core = copilotkit.value;
|
|
345
|
+
return () => null;
|
|
346
|
+
},
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
mount(CopilotKitProvider, {
|
|
350
|
+
props: {
|
|
351
|
+
agents__unsafe_dev_only: {
|
|
352
|
+
default: new StateCapturingAgent([], "default"),
|
|
353
|
+
},
|
|
354
|
+
},
|
|
355
|
+
slots: {
|
|
356
|
+
default: () =>
|
|
357
|
+
h("div", [
|
|
358
|
+
h(CopilotChat, { welcomeScreen: false, onError }),
|
|
359
|
+
h(Probe),
|
|
360
|
+
]),
|
|
361
|
+
},
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
await (core as unknown as CopilotKitCoreTestAccess).notifySubscribers(
|
|
365
|
+
(subscriber) =>
|
|
366
|
+
subscriber.onError?.({
|
|
367
|
+
copilotkit: core!,
|
|
368
|
+
error: new Error("wrong agent"),
|
|
369
|
+
code: CopilotKitCoreErrorCode.AGENT_RUN_FAILED,
|
|
370
|
+
context: { agentId: "other-agent" },
|
|
371
|
+
}),
|
|
372
|
+
"test chat onError",
|
|
373
|
+
);
|
|
374
|
+
|
|
375
|
+
await nextTick();
|
|
376
|
+
expect(onError).not.toHaveBeenCalled();
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
it("fires provider and chat onError for the same matching error", async () => {
|
|
380
|
+
let core:
|
|
381
|
+
| ReturnType<typeof useCopilotKit>["copilotkit"]["value"]
|
|
382
|
+
| undefined;
|
|
383
|
+
const providerOnError = vi.fn();
|
|
384
|
+
const chatOnError = vi.fn();
|
|
385
|
+
const Probe = defineComponent({
|
|
386
|
+
setup() {
|
|
387
|
+
const { copilotkit } = useCopilotKit();
|
|
388
|
+
core = copilotkit.value;
|
|
389
|
+
return () => null;
|
|
390
|
+
},
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
mount(CopilotKitProvider, {
|
|
394
|
+
props: {
|
|
395
|
+
agents__unsafe_dev_only: {
|
|
396
|
+
default: new StateCapturingAgent([], "default"),
|
|
397
|
+
},
|
|
398
|
+
onError: providerOnError,
|
|
399
|
+
},
|
|
400
|
+
slots: {
|
|
401
|
+
default: () =>
|
|
402
|
+
h("div", [
|
|
403
|
+
h(CopilotChat, { welcomeScreen: false, onError: chatOnError }),
|
|
404
|
+
h(Probe),
|
|
405
|
+
]),
|
|
406
|
+
},
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
await (core as unknown as CopilotKitCoreTestAccess).notifySubscribers(
|
|
410
|
+
(subscriber) =>
|
|
411
|
+
subscriber.onError?.({
|
|
412
|
+
copilotkit: core!,
|
|
413
|
+
error: new Error("matching agent"),
|
|
414
|
+
code: CopilotKitCoreErrorCode.AGENT_RUN_FAILED,
|
|
415
|
+
context: { agentId: "default" },
|
|
416
|
+
}),
|
|
417
|
+
"test chat onError",
|
|
418
|
+
);
|
|
419
|
+
|
|
420
|
+
await nextTick();
|
|
421
|
+
|
|
422
|
+
expect(providerOnError).toHaveBeenCalledTimes(1);
|
|
423
|
+
expect(chatOnError).toHaveBeenCalledTimes(1);
|
|
424
|
+
expect(chatOnError.mock.calls[0][0].code).toBe(
|
|
425
|
+
CopilotKitCoreErrorCode.AGENT_RUN_FAILED,
|
|
426
|
+
);
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
it("forwards the interrupt slot through CopilotChat", async () => {
|
|
430
|
+
let core:
|
|
431
|
+
| ReturnType<typeof useCopilotKit>["copilotkit"]["value"]
|
|
432
|
+
| undefined;
|
|
433
|
+
const Probe = defineComponent({
|
|
434
|
+
setup() {
|
|
435
|
+
const { copilotkit } = useCopilotKit();
|
|
436
|
+
core = copilotkit.value;
|
|
437
|
+
return () => null;
|
|
438
|
+
},
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
const wrapper = mount(CopilotKitProvider, {
|
|
442
|
+
props: {
|
|
443
|
+
agents__unsafe_dev_only: {
|
|
444
|
+
default: new StateCapturingAgent([], "default"),
|
|
445
|
+
},
|
|
446
|
+
},
|
|
447
|
+
slots: {
|
|
448
|
+
default: () =>
|
|
449
|
+
h("div", [
|
|
450
|
+
h(
|
|
451
|
+
CopilotChat,
|
|
452
|
+
{ welcomeScreen: false },
|
|
453
|
+
{
|
|
454
|
+
interrupt: ({ event }: { event: { value: string } }) =>
|
|
455
|
+
h("div", { "data-testid": "chat-interrupt" }, event.value),
|
|
456
|
+
},
|
|
457
|
+
),
|
|
458
|
+
h(Probe),
|
|
459
|
+
]),
|
|
460
|
+
},
|
|
461
|
+
});
|
|
462
|
+
|
|
463
|
+
core?.setInterruptState({
|
|
464
|
+
event: { name: "on_interrupt", value: "slot-forwarded" },
|
|
465
|
+
result: null,
|
|
466
|
+
resolve: () => undefined,
|
|
467
|
+
});
|
|
468
|
+
await nextTick();
|
|
469
|
+
|
|
470
|
+
expect(wrapper.get("[data-testid=chat-interrupt]").text()).toBe(
|
|
471
|
+
"slot-forwarded",
|
|
472
|
+
);
|
|
473
|
+
});
|
|
474
|
+
|
|
475
|
+
it("calls connectAgent for local agents even without a runtimeUrl", async () => {
|
|
476
|
+
const agent = new StateCapturingAgent();
|
|
477
|
+
const connectAgent = vi
|
|
478
|
+
.spyOn(CopilotKitCoreVue.prototype, "connectAgent")
|
|
479
|
+
.mockImplementation(async () => {
|
|
480
|
+
return { newMessages: [] } as Awaited<
|
|
481
|
+
ReturnType<CopilotKitCoreVue["connectAgent"]>
|
|
482
|
+
>;
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
mountChat({ threadId: "local-thread" }, { agents: { default: agent } });
|
|
486
|
+
await flushPromises();
|
|
487
|
+
|
|
488
|
+
expect(connectAgent).toHaveBeenCalledTimes(1);
|
|
489
|
+
expect(connectAgent).toHaveBeenCalledWith(
|
|
490
|
+
expect.objectContaining({
|
|
491
|
+
agent: expect.objectContaining({
|
|
492
|
+
agentId: "default",
|
|
493
|
+
threadId: "local-thread",
|
|
494
|
+
}),
|
|
495
|
+
}),
|
|
496
|
+
);
|
|
497
|
+
});
|
|
498
|
+
|
|
499
|
+
it("does not crash when a local agent connect() throws AGUIConnectNotImplementedError", async () => {
|
|
500
|
+
// Provide an explicit threadId so the new connect-gating logic actually
|
|
501
|
+
// exercises the connectAgent call path. Without one, /connect is skipped
|
|
502
|
+
// entirely (locally-minted UUID would 404), and this test would become
|
|
503
|
+
// a silent no-op.
|
|
504
|
+
const agent = new StateCapturingAgent();
|
|
505
|
+
|
|
506
|
+
mountChat({ threadId: "explicit-thread" }, { agents: { default: agent } });
|
|
507
|
+
await flushPromises();
|
|
508
|
+
|
|
509
|
+
expect(agent.threadId).toBeDefined();
|
|
510
|
+
});
|
|
511
|
+
|
|
512
|
+
describe("connect-gating (ENT-314)", () => {
|
|
513
|
+
it("does not call connectAgent when no threadId is supplied", async () => {
|
|
514
|
+
// Locally-minted UUID has never been seen by the backend; calling
|
|
515
|
+
// /connect against it would always 404. Skip the call entirely.
|
|
516
|
+
const agent = new StateCapturingAgent();
|
|
517
|
+
const connectAgent = vi.spyOn(
|
|
518
|
+
CopilotKitCoreVue.prototype,
|
|
519
|
+
"connectAgent",
|
|
520
|
+
);
|
|
521
|
+
|
|
522
|
+
mountChat({ welcomeScreen: false }, { agents: { default: agent } });
|
|
523
|
+
await flushPromises();
|
|
524
|
+
|
|
525
|
+
expect(connectAgent).not.toHaveBeenCalled();
|
|
526
|
+
});
|
|
527
|
+
|
|
528
|
+
it("calls connectAgent when threadId is supplied via props", async () => {
|
|
529
|
+
const agent = new StateCapturingAgent();
|
|
530
|
+
const connectAgent = vi.spyOn(
|
|
531
|
+
CopilotKitCoreVue.prototype,
|
|
532
|
+
"connectAgent",
|
|
533
|
+
);
|
|
534
|
+
|
|
535
|
+
mountChat(
|
|
536
|
+
{ welcomeScreen: false, threadId: "user-thread-abc" },
|
|
537
|
+
{ agents: { default: agent } },
|
|
538
|
+
);
|
|
539
|
+
await flushPromises();
|
|
540
|
+
|
|
541
|
+
expect(connectAgent).toHaveBeenCalled();
|
|
542
|
+
});
|
|
543
|
+
|
|
544
|
+
it("calls connectAgent when threadId is supplied via configuration provider", async () => {
|
|
545
|
+
const agent = new StateCapturingAgent();
|
|
546
|
+
const connectAgent = vi.spyOn(
|
|
547
|
+
CopilotKitCoreVue.prototype,
|
|
548
|
+
"connectAgent",
|
|
549
|
+
);
|
|
550
|
+
|
|
551
|
+
mountChat(
|
|
552
|
+
{ welcomeScreen: false },
|
|
553
|
+
{
|
|
554
|
+
agents: { default: agent },
|
|
555
|
+
providerThreadId: "config-thread-xyz",
|
|
556
|
+
},
|
|
557
|
+
);
|
|
558
|
+
await flushPromises();
|
|
559
|
+
|
|
560
|
+
expect(connectAgent).toHaveBeenCalled();
|
|
561
|
+
});
|
|
562
|
+
|
|
563
|
+
it("does not call connectAgent when configuration provider supplies threadId with hasExplicitThreadId=false", async () => {
|
|
564
|
+
// Mirrors the "auto-minted UUID leaking down" scenario where a parent
|
|
565
|
+
// provider supplies a threadId but flags it as non-explicit. This is
|
|
566
|
+
// the Vue equivalent of React's CopilotKit → ThreadsProvider → UUID
|
|
567
|
+
// chain and must NOT trigger /connect.
|
|
568
|
+
const agent = new StateCapturingAgent();
|
|
569
|
+
const connectAgent = vi.spyOn(
|
|
570
|
+
CopilotKitCoreVue.prototype,
|
|
571
|
+
"connectAgent",
|
|
572
|
+
);
|
|
573
|
+
|
|
574
|
+
mount(CopilotKitProvider, {
|
|
575
|
+
props: {
|
|
576
|
+
agents__unsafe_dev_only: { default: agent },
|
|
577
|
+
},
|
|
578
|
+
slots: {
|
|
579
|
+
default: () =>
|
|
580
|
+
h(
|
|
581
|
+
CopilotChatConfigurationProvider,
|
|
582
|
+
{
|
|
583
|
+
threadId: "auto-minted-uuid",
|
|
584
|
+
hasExplicitThreadId: false,
|
|
585
|
+
},
|
|
586
|
+
{
|
|
587
|
+
default: () => h(CopilotChat, { welcomeScreen: false }),
|
|
588
|
+
},
|
|
589
|
+
),
|
|
590
|
+
},
|
|
591
|
+
});
|
|
592
|
+
await flushPromises();
|
|
593
|
+
|
|
594
|
+
expect(connectAgent).not.toHaveBeenCalled();
|
|
595
|
+
});
|
|
596
|
+
|
|
597
|
+
it("flips isConnecting from true to false once connectAgent resolves (raf-deferred)", async () => {
|
|
598
|
+
// Capture isConnecting via the chat-view slot before and after the
|
|
599
|
+
// connect promise settles. The raf defer is handled in jsdom because
|
|
600
|
+
// requestAnimationFrame is polyfilled by the environment.
|
|
601
|
+
const agent = new StateCapturingAgent();
|
|
602
|
+
vi.spyOn(CopilotKitCoreVue.prototype, "connectAgent").mockImplementation(
|
|
603
|
+
async () => {
|
|
604
|
+
return { newMessages: [] } as Awaited<
|
|
605
|
+
ReturnType<CopilotKitCoreVue["connectAgent"]>
|
|
606
|
+
>;
|
|
607
|
+
},
|
|
608
|
+
);
|
|
609
|
+
|
|
610
|
+
const observed: Array<boolean | undefined> = [];
|
|
611
|
+
|
|
612
|
+
const Recorder = defineComponent({
|
|
613
|
+
props: {
|
|
614
|
+
isConnecting: { type: Boolean, default: undefined },
|
|
615
|
+
},
|
|
616
|
+
setup(slotProps) {
|
|
617
|
+
return () => {
|
|
618
|
+
observed.push(slotProps.isConnecting);
|
|
619
|
+
return null;
|
|
620
|
+
};
|
|
621
|
+
},
|
|
622
|
+
});
|
|
623
|
+
|
|
624
|
+
mount(CopilotKitProvider, {
|
|
625
|
+
props: {
|
|
626
|
+
agents__unsafe_dev_only: { default: agent },
|
|
627
|
+
},
|
|
628
|
+
slots: {
|
|
629
|
+
default: () =>
|
|
630
|
+
h(
|
|
631
|
+
CopilotChat,
|
|
632
|
+
{ welcomeScreen: false, threadId: "explicit-thread" },
|
|
633
|
+
{
|
|
634
|
+
"chat-view": (slotProps: { isConnecting?: boolean }) =>
|
|
635
|
+
h(Recorder, { isConnecting: slotProps.isConnecting }),
|
|
636
|
+
},
|
|
637
|
+
),
|
|
638
|
+
},
|
|
639
|
+
});
|
|
640
|
+
|
|
641
|
+
await flushPromises();
|
|
642
|
+
// Wait one extra microtask + macrotask so raf callbacks fire.
|
|
643
|
+
await new Promise((resolve) => setTimeout(resolve, 32));
|
|
644
|
+
await nextTick();
|
|
645
|
+
|
|
646
|
+
// Initial render should have observed isConnecting=true at least once,
|
|
647
|
+
// and the latest observation should be false.
|
|
648
|
+
expect(observed.some((value) => value === true)).toBe(true);
|
|
649
|
+
expect(observed[observed.length - 1]).toBe(false);
|
|
650
|
+
});
|
|
651
|
+
});
|
|
652
|
+
});
|