@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,397 @@
|
|
|
1
|
+
import { defineComponent, onUnmounted } from "vue";
|
|
2
|
+
import { screen, fireEvent, waitFor, cleanup } from "@testing-library/vue";
|
|
3
|
+
import { DEFAULT_AGENT_ID } from "@copilotkit/shared";
|
|
4
|
+
import { describe, it, expect, afterEach } from "vitest";
|
|
5
|
+
import { renderWithCopilotKit } from "../../__tests__/utils/test-helpers";
|
|
6
|
+
import { useSuggestions } from "../use-suggestions";
|
|
7
|
+
import { useCopilotKit } from "../../providers/useCopilotKit";
|
|
8
|
+
import { SuggestionsProviderAgent } from "../../__tests__/utils/agents";
|
|
9
|
+
|
|
10
|
+
const TestHarness = defineComponent({
|
|
11
|
+
setup() {
|
|
12
|
+
const { suggestions, isLoading, reloadSuggestions, clearSuggestions } =
|
|
13
|
+
useSuggestions();
|
|
14
|
+
const { copilotkit } = useCopilotKit();
|
|
15
|
+
|
|
16
|
+
const configId = copilotkit.value.addSuggestionsConfig({
|
|
17
|
+
instructions: "Return deterministic suggestions",
|
|
18
|
+
providerAgentId: DEFAULT_AGENT_ID,
|
|
19
|
+
consumerAgentId: DEFAULT_AGENT_ID,
|
|
20
|
+
available: "always",
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
onUnmounted(() => {
|
|
24
|
+
copilotkit.value.removeSuggestionsConfig(configId);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const handleReload = () => {
|
|
28
|
+
reloadSuggestions();
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const handleClear = () => {
|
|
32
|
+
clearSuggestions();
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
suggestions,
|
|
37
|
+
isLoading,
|
|
38
|
+
handleReload,
|
|
39
|
+
handleClear,
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
template: `
|
|
43
|
+
<div>
|
|
44
|
+
<div data-testid="suggestions-count">{{ suggestions.length }}</div>
|
|
45
|
+
<div data-testid="suggestions-json">{{ JSON.stringify(suggestions) }}</div>
|
|
46
|
+
<div data-testid="suggestions-loading">{{ isLoading ? "loading" : "idle" }}</div>
|
|
47
|
+
<button data-testid="reload-suggestions" @click="handleReload">Reload</button>
|
|
48
|
+
<button data-testid="clear-suggestions" @click="handleClear">Clear</button>
|
|
49
|
+
</div>
|
|
50
|
+
`,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
afterEach(() => {
|
|
54
|
+
cleanup();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
describe("useSuggestions E2E", () => {
|
|
58
|
+
describe("Basic functionality", () => {
|
|
59
|
+
it("tracks suggestions stream and loading state", async () => {
|
|
60
|
+
const agent = new SuggestionsProviderAgent([
|
|
61
|
+
{ title: "Option A", message: "Take path A", isLoading: false },
|
|
62
|
+
{ title: "Option B", message: "Take path B", isLoading: false },
|
|
63
|
+
]);
|
|
64
|
+
|
|
65
|
+
const ui = renderWithCopilotKit({
|
|
66
|
+
agent,
|
|
67
|
+
children: TestHarness,
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
expect(screen.getByTestId("suggestions-count").textContent).toBe("0");
|
|
71
|
+
expect(screen.getByTestId("suggestions-loading").textContent).toBe(
|
|
72
|
+
"idle",
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
await fireEvent.click(screen.getByTestId("reload-suggestions"));
|
|
76
|
+
|
|
77
|
+
await waitFor(() => {
|
|
78
|
+
expect(screen.getByTestId("suggestions-loading").textContent).toBe(
|
|
79
|
+
"loading",
|
|
80
|
+
);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
await waitFor(() => {
|
|
84
|
+
expect(screen.getByTestId("suggestions-count").textContent).toBe("2");
|
|
85
|
+
expect(screen.getByTestId("suggestions-loading").textContent).toBe(
|
|
86
|
+
"idle",
|
|
87
|
+
);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
expect(screen.getByTestId("suggestions-json").textContent).toContain(
|
|
91
|
+
"Option A",
|
|
92
|
+
);
|
|
93
|
+
expect(screen.getByTestId("suggestions-json").textContent).toContain(
|
|
94
|
+
"Option B",
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
await fireEvent.click(screen.getByTestId("clear-suggestions"));
|
|
98
|
+
|
|
99
|
+
await waitFor(() => {
|
|
100
|
+
expect(screen.getByTestId("suggestions-count").textContent).toBe("0");
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
expect(screen.getByTestId("suggestions-loading").textContent).toBe(
|
|
104
|
+
"idle",
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
ui.unmount();
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it("starts with no suggestions and idle state", () => {
|
|
111
|
+
const agent = new SuggestionsProviderAgent([]);
|
|
112
|
+
|
|
113
|
+
renderWithCopilotKit({
|
|
114
|
+
agent,
|
|
115
|
+
children: TestHarness,
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
expect(screen.getByTestId("suggestions-count").textContent).toBe("0");
|
|
119
|
+
expect(screen.getByTestId("suggestions-loading").textContent).toBe(
|
|
120
|
+
"idle",
|
|
121
|
+
);
|
|
122
|
+
expect(screen.getByTestId("suggestions-json").textContent).toBe("[]");
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it("handles single suggestion", async () => {
|
|
126
|
+
const agent = new SuggestionsProviderAgent([
|
|
127
|
+
{ title: "Only Option", message: "The only way", isLoading: false },
|
|
128
|
+
]);
|
|
129
|
+
|
|
130
|
+
renderWithCopilotKit({
|
|
131
|
+
agent,
|
|
132
|
+
children: TestHarness,
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
await fireEvent.click(screen.getByTestId("reload-suggestions"));
|
|
136
|
+
|
|
137
|
+
await waitFor(() => {
|
|
138
|
+
expect(screen.getByTestId("suggestions-count").textContent).toBe("1");
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
const json = screen.getByTestId("suggestions-json").textContent;
|
|
142
|
+
expect(json).toContain("Only Option");
|
|
143
|
+
expect(json).toContain("The only way");
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it("handles many suggestions", async () => {
|
|
147
|
+
const agent = new SuggestionsProviderAgent([
|
|
148
|
+
{ title: "Option 1", message: "First choice", isLoading: false },
|
|
149
|
+
{ title: "Option 2", message: "Second choice", isLoading: false },
|
|
150
|
+
{ title: "Option 3", message: "Third choice", isLoading: false },
|
|
151
|
+
{ title: "Option 4", message: "Fourth choice", isLoading: false },
|
|
152
|
+
{ title: "Option 5", message: "Fifth choice", isLoading: false },
|
|
153
|
+
]);
|
|
154
|
+
|
|
155
|
+
renderWithCopilotKit({
|
|
156
|
+
agent,
|
|
157
|
+
children: TestHarness,
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
await fireEvent.click(screen.getByTestId("reload-suggestions"));
|
|
161
|
+
|
|
162
|
+
await waitFor(() => {
|
|
163
|
+
expect(screen.getByTestId("suggestions-count").textContent).toBe("5");
|
|
164
|
+
expect(screen.getByTestId("suggestions-loading").textContent).toBe(
|
|
165
|
+
"idle",
|
|
166
|
+
);
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
describe("Loading state transitions", () => {
|
|
172
|
+
it("transitions from idle -> loading -> idle correctly", async () => {
|
|
173
|
+
const agent = new SuggestionsProviderAgent([
|
|
174
|
+
{ title: "Test", message: "Message", isLoading: false },
|
|
175
|
+
]);
|
|
176
|
+
|
|
177
|
+
renderWithCopilotKit({ agent, children: TestHarness });
|
|
178
|
+
|
|
179
|
+
expect(screen.getByTestId("suggestions-loading").textContent).toBe(
|
|
180
|
+
"idle",
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
await fireEvent.click(screen.getByTestId("reload-suggestions"));
|
|
184
|
+
|
|
185
|
+
await waitFor(() => {
|
|
186
|
+
expect(screen.getByTestId("suggestions-loading").textContent).toBe(
|
|
187
|
+
"loading",
|
|
188
|
+
);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
await waitFor(() => {
|
|
192
|
+
expect(screen.getByTestId("suggestions-loading").textContent).toBe(
|
|
193
|
+
"idle",
|
|
194
|
+
);
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
it("stays in loading state during multiple reloads", async () => {
|
|
199
|
+
const agent = new SuggestionsProviderAgent([
|
|
200
|
+
{ title: "Test", message: "Message", isLoading: false },
|
|
201
|
+
]);
|
|
202
|
+
|
|
203
|
+
renderWithCopilotKit({ agent, children: TestHarness });
|
|
204
|
+
|
|
205
|
+
await fireEvent.click(screen.getByTestId("reload-suggestions"));
|
|
206
|
+
await fireEvent.click(screen.getByTestId("reload-suggestions"));
|
|
207
|
+
|
|
208
|
+
await waitFor(() => {
|
|
209
|
+
expect(screen.getByTestId("suggestions-loading").textContent).toBe(
|
|
210
|
+
"loading",
|
|
211
|
+
);
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
await waitFor(() => {
|
|
215
|
+
expect(screen.getByTestId("suggestions-loading").textContent).toBe(
|
|
216
|
+
"idle",
|
|
217
|
+
);
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
describe("Clear functionality", () => {
|
|
223
|
+
it("clears suggestions immediately without loading state", async () => {
|
|
224
|
+
const agent = new SuggestionsProviderAgent([
|
|
225
|
+
{ title: "Option A", message: "Message A", isLoading: false },
|
|
226
|
+
{ title: "Option B", message: "Message B", isLoading: false },
|
|
227
|
+
]);
|
|
228
|
+
|
|
229
|
+
renderWithCopilotKit({ agent, children: TestHarness });
|
|
230
|
+
|
|
231
|
+
await fireEvent.click(screen.getByTestId("reload-suggestions"));
|
|
232
|
+
|
|
233
|
+
await waitFor(() => {
|
|
234
|
+
expect(screen.getByTestId("suggestions-count").textContent).toBe("2");
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
await fireEvent.click(screen.getByTestId("clear-suggestions"));
|
|
238
|
+
|
|
239
|
+
await waitFor(() => {
|
|
240
|
+
expect(screen.getByTestId("suggestions-count").textContent).toBe("0");
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
expect(screen.getByTestId("suggestions-loading").textContent).toBe(
|
|
244
|
+
"idle",
|
|
245
|
+
);
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
it("can clear suggestions while loading", async () => {
|
|
249
|
+
const agent = new SuggestionsProviderAgent([
|
|
250
|
+
{ title: "Option A", message: "Message A", isLoading: false },
|
|
251
|
+
]);
|
|
252
|
+
|
|
253
|
+
renderWithCopilotKit({ agent, children: TestHarness });
|
|
254
|
+
|
|
255
|
+
await fireEvent.click(screen.getByTestId("reload-suggestions"));
|
|
256
|
+
|
|
257
|
+
await waitFor(() => {
|
|
258
|
+
expect(screen.getByTestId("suggestions-loading").textContent).toBe(
|
|
259
|
+
"loading",
|
|
260
|
+
);
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
await fireEvent.click(screen.getByTestId("clear-suggestions"));
|
|
264
|
+
|
|
265
|
+
await waitFor(() => {
|
|
266
|
+
expect(screen.getByTestId("suggestions-count").textContent).toBe("0");
|
|
267
|
+
expect(screen.getByTestId("suggestions-loading").textContent).toBe(
|
|
268
|
+
"idle",
|
|
269
|
+
);
|
|
270
|
+
});
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
it("clearing empty suggestions does not cause errors", async () => {
|
|
274
|
+
const agent = new SuggestionsProviderAgent([]);
|
|
275
|
+
|
|
276
|
+
renderWithCopilotKit({ agent, children: TestHarness });
|
|
277
|
+
|
|
278
|
+
expect(screen.getByTestId("suggestions-count").textContent).toBe("0");
|
|
279
|
+
|
|
280
|
+
await fireEvent.click(screen.getByTestId("clear-suggestions"));
|
|
281
|
+
|
|
282
|
+
await waitFor(() => {
|
|
283
|
+
expect(screen.getByTestId("suggestions-count").textContent).toBe("0");
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
expect(screen.getByTestId("suggestions-loading").textContent).toBe(
|
|
287
|
+
"idle",
|
|
288
|
+
);
|
|
289
|
+
});
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
describe("Reload functionality", () => {
|
|
293
|
+
it("can reload to get fresh suggestions", async () => {
|
|
294
|
+
const agent = new SuggestionsProviderAgent([
|
|
295
|
+
{ title: "Option A", message: "Message A", isLoading: false },
|
|
296
|
+
]);
|
|
297
|
+
|
|
298
|
+
renderWithCopilotKit({ agent, children: TestHarness });
|
|
299
|
+
|
|
300
|
+
await fireEvent.click(screen.getByTestId("reload-suggestions"));
|
|
301
|
+
|
|
302
|
+
await waitFor(() => {
|
|
303
|
+
expect(screen.getByTestId("suggestions-count").textContent).toBe("1");
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
await fireEvent.click(screen.getByTestId("clear-suggestions"));
|
|
307
|
+
|
|
308
|
+
await waitFor(() => {
|
|
309
|
+
expect(screen.getByTestId("suggestions-count").textContent).toBe("0");
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
await fireEvent.click(screen.getByTestId("reload-suggestions"));
|
|
313
|
+
|
|
314
|
+
await waitFor(() => {
|
|
315
|
+
expect(screen.getByTestId("suggestions-count").textContent).toBe("1");
|
|
316
|
+
expect(screen.getByTestId("suggestions-loading").textContent).toBe(
|
|
317
|
+
"idle",
|
|
318
|
+
);
|
|
319
|
+
});
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
it("reload when already has suggestions replaces them", async () => {
|
|
323
|
+
const agent = new SuggestionsProviderAgent([
|
|
324
|
+
{ title: "Option A", message: "Message A", isLoading: false },
|
|
325
|
+
{ title: "Option B", message: "Message B", isLoading: false },
|
|
326
|
+
]);
|
|
327
|
+
|
|
328
|
+
renderWithCopilotKit({ agent, children: TestHarness });
|
|
329
|
+
|
|
330
|
+
await fireEvent.click(screen.getByTestId("reload-suggestions"));
|
|
331
|
+
|
|
332
|
+
await waitFor(() => {
|
|
333
|
+
expect(screen.getByTestId("suggestions-count").textContent).toBe("2");
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
await fireEvent.click(screen.getByTestId("reload-suggestions"));
|
|
337
|
+
|
|
338
|
+
await waitFor(() => {
|
|
339
|
+
expect(screen.getByTestId("suggestions-loading").textContent).toBe(
|
|
340
|
+
"loading",
|
|
341
|
+
);
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
await waitFor(() => {
|
|
345
|
+
expect(screen.getByTestId("suggestions-count").textContent).toBe("2");
|
|
346
|
+
expect(screen.getByTestId("suggestions-loading").textContent).toBe(
|
|
347
|
+
"idle",
|
|
348
|
+
);
|
|
349
|
+
});
|
|
350
|
+
});
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
describe("Edge cases", () => {
|
|
354
|
+
it("handles empty suggestions from agent", async () => {
|
|
355
|
+
const agent = new SuggestionsProviderAgent([]);
|
|
356
|
+
|
|
357
|
+
renderWithCopilotKit({ agent, children: TestHarness });
|
|
358
|
+
|
|
359
|
+
await fireEvent.click(screen.getByTestId("reload-suggestions"));
|
|
360
|
+
|
|
361
|
+
await waitFor(() => {
|
|
362
|
+
expect(screen.getByTestId("suggestions-loading").textContent).toBe(
|
|
363
|
+
"idle",
|
|
364
|
+
);
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
expect(screen.getByTestId("suggestions-count").textContent).toBe("0");
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
it("handles suggestions with special characters", async () => {
|
|
371
|
+
const agent = new SuggestionsProviderAgent([
|
|
372
|
+
{
|
|
373
|
+
title: 'Option with "quotes"',
|
|
374
|
+
message: "Message with 'quotes'",
|
|
375
|
+
isLoading: false,
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
title: "Option with\nnewlines",
|
|
379
|
+
message: "Message\nwith\nnewlines",
|
|
380
|
+
isLoading: false,
|
|
381
|
+
},
|
|
382
|
+
]);
|
|
383
|
+
|
|
384
|
+
renderWithCopilotKit({ agent, children: TestHarness });
|
|
385
|
+
|
|
386
|
+
await fireEvent.click(screen.getByTestId("reload-suggestions"));
|
|
387
|
+
|
|
388
|
+
await waitFor(() => {
|
|
389
|
+
expect(screen.getByTestId("suggestions-count").textContent).toBe("2");
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
const json = screen.getByTestId("suggestions-json").textContent;
|
|
393
|
+
expect(json).toContain("quotes");
|
|
394
|
+
expect(json).toContain("newlines");
|
|
395
|
+
});
|
|
396
|
+
});
|
|
397
|
+
});
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
|
+
import { defineComponent, h, nextTick } from "vue";
|
|
3
|
+
import { DEFAULT_AGENT_ID } from "@copilotkit/shared";
|
|
4
|
+
import type { AbstractAgent } from "@ag-ui/client";
|
|
5
|
+
import { useSuggestions } from "../use-suggestions";
|
|
6
|
+
import { useCopilotKit } from "../../providers/useCopilotKit";
|
|
7
|
+
import { mountWithProvider } from "../../__tests__/utils/mount";
|
|
8
|
+
import { SuggestionsProviderAgent } from "../../__tests__/utils/agents";
|
|
9
|
+
|
|
10
|
+
describe("useSuggestions", () => {
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
console.warn = vi.fn();
|
|
13
|
+
console.error = vi.fn();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
function makeHarness() {
|
|
17
|
+
return defineComponent({
|
|
18
|
+
setup() {
|
|
19
|
+
const { suggestions, isLoading, reloadSuggestions, clearSuggestions } =
|
|
20
|
+
useSuggestions();
|
|
21
|
+
const { copilotkit } = useCopilotKit();
|
|
22
|
+
|
|
23
|
+
const configId = copilotkit.value.addSuggestionsConfig({
|
|
24
|
+
instructions: "Return deterministic suggestions",
|
|
25
|
+
providerAgentId: DEFAULT_AGENT_ID,
|
|
26
|
+
consumerAgentId: DEFAULT_AGENT_ID,
|
|
27
|
+
available: "always",
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const reload = () => reloadSuggestions();
|
|
31
|
+
const clear = () => clearSuggestions();
|
|
32
|
+
|
|
33
|
+
return () =>
|
|
34
|
+
h("div", [
|
|
35
|
+
h(
|
|
36
|
+
"span",
|
|
37
|
+
{ "data-testid": "count" },
|
|
38
|
+
String(suggestions.value.length),
|
|
39
|
+
),
|
|
40
|
+
h(
|
|
41
|
+
"span",
|
|
42
|
+
{ "data-testid": "loading" },
|
|
43
|
+
isLoading.value ? "loading" : "idle",
|
|
44
|
+
),
|
|
45
|
+
h(
|
|
46
|
+
"span",
|
|
47
|
+
{ "data-testid": "json" },
|
|
48
|
+
JSON.stringify(suggestions.value),
|
|
49
|
+
),
|
|
50
|
+
h("button", { "data-testid": "reload", onClick: reload }, "reload"),
|
|
51
|
+
h("button", { "data-testid": "clear", onClick: clear }, "clear"),
|
|
52
|
+
h(
|
|
53
|
+
"button",
|
|
54
|
+
{
|
|
55
|
+
"data-testid": "remove-config",
|
|
56
|
+
onClick: () =>
|
|
57
|
+
copilotkit.value.removeSuggestionsConfig(configId),
|
|
58
|
+
},
|
|
59
|
+
"remove",
|
|
60
|
+
),
|
|
61
|
+
]);
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
it("starts empty and idle", () => {
|
|
67
|
+
const agent = new SuggestionsProviderAgent([], DEFAULT_AGENT_ID);
|
|
68
|
+
const Harness = makeHarness();
|
|
69
|
+
|
|
70
|
+
const { wrapper } = mountWithProvider(() => h(Harness), {
|
|
71
|
+
agents__unsafe_dev_only: {
|
|
72
|
+
[DEFAULT_AGENT_ID]: agent as unknown as AbstractAgent,
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
expect(wrapper.find("[data-testid=count]").text()).toBe("0");
|
|
77
|
+
expect(wrapper.find("[data-testid=loading]").text()).toBe("idle");
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it("tracks loading lifecycle on reload", async () => {
|
|
81
|
+
const agent = new SuggestionsProviderAgent(
|
|
82
|
+
[
|
|
83
|
+
{ title: "Option A", message: "Take path A", isLoading: false },
|
|
84
|
+
{ title: "Option B", message: "Take path B", isLoading: false },
|
|
85
|
+
],
|
|
86
|
+
DEFAULT_AGENT_ID,
|
|
87
|
+
);
|
|
88
|
+
const Harness = makeHarness();
|
|
89
|
+
|
|
90
|
+
const { wrapper } = mountWithProvider(() => h(Harness), {
|
|
91
|
+
agents__unsafe_dev_only: {
|
|
92
|
+
[DEFAULT_AGENT_ID]: agent as unknown as AbstractAgent,
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
await wrapper.find("[data-testid=reload]").trigger("click");
|
|
97
|
+
await nextTick();
|
|
98
|
+
expect(wrapper.find("[data-testid=loading]").text()).toBe("loading");
|
|
99
|
+
|
|
100
|
+
await nextTick();
|
|
101
|
+
await nextTick();
|
|
102
|
+
expect(wrapper.find("[data-testid=loading]").text()).toBe("idle");
|
|
103
|
+
expect(wrapper.find("[data-testid=count]").text()).toBe("2");
|
|
104
|
+
expect(wrapper.find("[data-testid=json]").text()).toContain("Option A");
|
|
105
|
+
expect(wrapper.find("[data-testid=json]").text()).toContain("Option B");
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it("clears suggestions immediately and stays idle", async () => {
|
|
109
|
+
const agent = new SuggestionsProviderAgent(
|
|
110
|
+
[{ title: "Option A", message: "Take path A", isLoading: false }],
|
|
111
|
+
DEFAULT_AGENT_ID,
|
|
112
|
+
);
|
|
113
|
+
const Harness = makeHarness();
|
|
114
|
+
|
|
115
|
+
const { wrapper } = mountWithProvider(() => h(Harness), {
|
|
116
|
+
agents__unsafe_dev_only: {
|
|
117
|
+
[DEFAULT_AGENT_ID]: agent as unknown as AbstractAgent,
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
await wrapper.find("[data-testid=reload]").trigger("click");
|
|
122
|
+
await nextTick();
|
|
123
|
+
await nextTick();
|
|
124
|
+
|
|
125
|
+
expect(wrapper.find("[data-testid=count]").text()).toBe("1");
|
|
126
|
+
|
|
127
|
+
await wrapper.find("[data-testid=clear]").trigger("click");
|
|
128
|
+
await nextTick();
|
|
129
|
+
|
|
130
|
+
expect(wrapper.find("[data-testid=count]").text()).toBe("0");
|
|
131
|
+
expect(wrapper.find("[data-testid=loading]").text()).toBe("idle");
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it("supports reload after clear and special characters", async () => {
|
|
135
|
+
const agent = new SuggestionsProviderAgent(
|
|
136
|
+
[
|
|
137
|
+
{
|
|
138
|
+
title: 'Option with "quotes"',
|
|
139
|
+
message: "Message with 'quotes'",
|
|
140
|
+
isLoading: false,
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
title: "Option with\nnewlines",
|
|
144
|
+
message: "Message\nwith\nnewlines",
|
|
145
|
+
isLoading: false,
|
|
146
|
+
},
|
|
147
|
+
],
|
|
148
|
+
DEFAULT_AGENT_ID,
|
|
149
|
+
);
|
|
150
|
+
const Harness = makeHarness();
|
|
151
|
+
|
|
152
|
+
const { wrapper } = mountWithProvider(() => h(Harness), {
|
|
153
|
+
agents__unsafe_dev_only: {
|
|
154
|
+
[DEFAULT_AGENT_ID]: agent as unknown as AbstractAgent,
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
await wrapper.find("[data-testid=reload]").trigger("click");
|
|
159
|
+
await nextTick();
|
|
160
|
+
await nextTick();
|
|
161
|
+
|
|
162
|
+
expect(wrapper.find("[data-testid=count]").text()).toBe("2");
|
|
163
|
+
expect(wrapper.find("[data-testid=json]").text()).toContain("quotes");
|
|
164
|
+
expect(wrapper.find("[data-testid=json]").text()).toContain("newlines");
|
|
165
|
+
|
|
166
|
+
await wrapper.find("[data-testid=clear]").trigger("click");
|
|
167
|
+
await nextTick();
|
|
168
|
+
expect(wrapper.find("[data-testid=count]").text()).toBe("0");
|
|
169
|
+
|
|
170
|
+
await wrapper.find("[data-testid=reload]").trigger("click");
|
|
171
|
+
await nextTick();
|
|
172
|
+
await nextTick();
|
|
173
|
+
expect(wrapper.find("[data-testid=count]").text()).toBe("2");
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
it("handles multiple reload requests without leaving loading state stuck", async () => {
|
|
177
|
+
const agent = new SuggestionsProviderAgent(
|
|
178
|
+
[{ title: "Option", message: "Message", isLoading: false }],
|
|
179
|
+
DEFAULT_AGENT_ID,
|
|
180
|
+
);
|
|
181
|
+
const Harness = makeHarness();
|
|
182
|
+
|
|
183
|
+
const { wrapper } = mountWithProvider(() => h(Harness), {
|
|
184
|
+
agents__unsafe_dev_only: {
|
|
185
|
+
[DEFAULT_AGENT_ID]: agent as unknown as AbstractAgent,
|
|
186
|
+
},
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
await wrapper.find("[data-testid=reload]").trigger("click");
|
|
190
|
+
await wrapper.find("[data-testid=reload]").trigger("click");
|
|
191
|
+
await nextTick();
|
|
192
|
+
|
|
193
|
+
expect(wrapper.find("[data-testid=loading]").text()).toBe("loading");
|
|
194
|
+
await nextTick();
|
|
195
|
+
await nextTick();
|
|
196
|
+
expect(wrapper.find("[data-testid=loading]").text()).toBe("idle");
|
|
197
|
+
});
|
|
198
|
+
});
|