@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,214 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { h, nextTick } from "vue";
|
|
3
|
+
import { mount } from "@vue/test-utils";
|
|
4
|
+
import type { Message } from "@ag-ui/core";
|
|
5
|
+
import type { Suggestion } from "@copilotkit/core";
|
|
6
|
+
import CopilotKitProvider from "../../../providers/CopilotKitProvider.vue";
|
|
7
|
+
import { CopilotSidebarView } from "../index";
|
|
8
|
+
|
|
9
|
+
const messages: Message[] = [
|
|
10
|
+
{
|
|
11
|
+
id: "sidebar-user",
|
|
12
|
+
role: "user",
|
|
13
|
+
content: "Hello from the sidebar",
|
|
14
|
+
timestamp: new Date(),
|
|
15
|
+
},
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
const suggestions: Suggestion[] = [
|
|
19
|
+
{ title: "Summarize", message: "Summarize", isLoading: false },
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
const originalResizeObserver = globalThis.ResizeObserver;
|
|
23
|
+
const originalGetBoundingClientRect =
|
|
24
|
+
HTMLElement.prototype.getBoundingClientRect;
|
|
25
|
+
|
|
26
|
+
function mockGetBoundingClientRect() {
|
|
27
|
+
return {
|
|
28
|
+
width: 612,
|
|
29
|
+
height: 400,
|
|
30
|
+
top: 0,
|
|
31
|
+
left: 0,
|
|
32
|
+
bottom: 400,
|
|
33
|
+
right: 612,
|
|
34
|
+
x: 0,
|
|
35
|
+
y: 0,
|
|
36
|
+
toJSON() {
|
|
37
|
+
return {};
|
|
38
|
+
},
|
|
39
|
+
} as DOMRect;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function mountSidebarView(
|
|
43
|
+
props: Record<string, unknown> = {},
|
|
44
|
+
slots: Parameters<typeof h>[2] = {},
|
|
45
|
+
) {
|
|
46
|
+
return mount(CopilotKitProvider, {
|
|
47
|
+
props: { runtimeUrl: "/api/copilotkit" },
|
|
48
|
+
slots: {
|
|
49
|
+
default: () => h(CopilotSidebarView, props, slots),
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
describe("CopilotSidebarView", () => {
|
|
55
|
+
beforeEach(() => {
|
|
56
|
+
vi.stubGlobal(
|
|
57
|
+
"ResizeObserver",
|
|
58
|
+
class ResizeObserver {
|
|
59
|
+
private callback: ResizeObserverCallback;
|
|
60
|
+
|
|
61
|
+
constructor(callback: ResizeObserverCallback) {
|
|
62
|
+
this.callback = callback;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
observe() {
|
|
66
|
+
this.callback([], this as unknown as ResizeObserver);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
disconnect() {}
|
|
70
|
+
},
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
HTMLElement.prototype.getBoundingClientRect = mockGetBoundingClientRect;
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
afterEach(() => {
|
|
77
|
+
if (originalResizeObserver) {
|
|
78
|
+
globalThis.ResizeObserver = originalResizeObserver;
|
|
79
|
+
} else {
|
|
80
|
+
// @ts-expect-error test cleanup for missing ResizeObserver
|
|
81
|
+
delete globalThis.ResizeObserver;
|
|
82
|
+
}
|
|
83
|
+
HTMLElement.prototype.getBoundingClientRect = originalGetBoundingClientRect;
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it("opens by default and applies measured body margin when width is not provided", async () => {
|
|
87
|
+
const wrapper = mountSidebarView();
|
|
88
|
+
await nextTick();
|
|
89
|
+
await nextTick();
|
|
90
|
+
|
|
91
|
+
const sidebar = wrapper.get("[data-copilot-sidebar]");
|
|
92
|
+
expect(sidebar.attributes("aria-hidden")).toBe("false");
|
|
93
|
+
expect(sidebar.attributes("style")).toContain("--sidebar-width: 612px");
|
|
94
|
+
expect(wrapper.html()).toContain("margin-inline-end: 612px");
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it("applies explicit width and renders default header and toggle button", () => {
|
|
98
|
+
const wrapper = mountSidebarView({
|
|
99
|
+
width: 520,
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
expect(wrapper.get("[data-copilot-sidebar]").attributes("style")).toContain(
|
|
103
|
+
"--sidebar-width: 520px",
|
|
104
|
+
);
|
|
105
|
+
expect(wrapper.find("[data-slot='copilot-modal-header']").exists()).toBe(
|
|
106
|
+
true,
|
|
107
|
+
);
|
|
108
|
+
expect(wrapper.find("[data-slot='chat-toggle-button']").exists()).toBe(
|
|
109
|
+
true,
|
|
110
|
+
);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it("replaces default header and toggle button via slots", () => {
|
|
114
|
+
const wrapper = mountSidebarView(
|
|
115
|
+
{},
|
|
116
|
+
{
|
|
117
|
+
header: ({ title }: { title: string }) =>
|
|
118
|
+
h("div", { "data-testid": "custom-header" }, title),
|
|
119
|
+
"toggle-button": ({ toggle }: { toggle: () => void }) =>
|
|
120
|
+
h(
|
|
121
|
+
"button",
|
|
122
|
+
{ "data-testid": "custom-toggle", onClick: toggle },
|
|
123
|
+
"toggle",
|
|
124
|
+
),
|
|
125
|
+
},
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
expect(wrapper.find("[data-testid='custom-header']").exists()).toBe(true);
|
|
129
|
+
expect(wrapper.find("[data-testid='custom-toggle']").exists()).toBe(true);
|
|
130
|
+
expect(wrapper.find("[data-slot='copilot-modal-header']").exists()).toBe(
|
|
131
|
+
false,
|
|
132
|
+
);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it("forwards chat view slots and emitted interactions", async () => {
|
|
136
|
+
const onSelectSuggestion = vi.fn();
|
|
137
|
+
const wrapper = mountSidebarView(
|
|
138
|
+
{
|
|
139
|
+
messages,
|
|
140
|
+
suggestions,
|
|
141
|
+
onSelectSuggestion,
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"message-view": ({ messages: slotMessages }: { messages: Message[] }) =>
|
|
145
|
+
h(
|
|
146
|
+
"div",
|
|
147
|
+
{ "data-testid": "custom-message-view" },
|
|
148
|
+
String(slotMessages.length),
|
|
149
|
+
),
|
|
150
|
+
},
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
expect(wrapper.get("[data-testid='custom-message-view']").text()).toBe("1");
|
|
154
|
+
await wrapper
|
|
155
|
+
.get("[data-testid='copilot-chat-suggestion-pill']")
|
|
156
|
+
.trigger("click");
|
|
157
|
+
expect(onSelectSuggestion).toHaveBeenCalledTimes(1);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it("uses the default chat welcome screen and still forwards welcome sub-slots", () => {
|
|
161
|
+
const wrapper = mountSidebarView(
|
|
162
|
+
{
|
|
163
|
+
messages: [],
|
|
164
|
+
suggestions,
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
"welcome-message": () =>
|
|
168
|
+
h("div", { "data-testid": "custom-welcome-message" }, "Hello"),
|
|
169
|
+
},
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
expect(
|
|
173
|
+
wrapper.find("[data-testid='copilot-sidebar-welcome-screen']").exists(),
|
|
174
|
+
).toBe(false);
|
|
175
|
+
expect(
|
|
176
|
+
wrapper.find("[data-testid='copilot-chat-view-welcome-screen']").exists(),
|
|
177
|
+
).toBe(true);
|
|
178
|
+
expect(wrapper.get("[data-testid='custom-welcome-message']").text()).toBe(
|
|
179
|
+
"Hello",
|
|
180
|
+
);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it("exposes the WelcomeScreen namespaced export", () => {
|
|
184
|
+
expect(CopilotSidebarView.WelcomeScreen).toBeDefined();
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it("renders the namespaced WelcomeScreen component when used explicitly", () => {
|
|
188
|
+
const wrapper = mount(CopilotSidebarView.WelcomeScreen, {
|
|
189
|
+
props: {
|
|
190
|
+
suggestions,
|
|
191
|
+
loadingIndexes: [],
|
|
192
|
+
modelValue: "",
|
|
193
|
+
isRunning: false,
|
|
194
|
+
inputMode: "input",
|
|
195
|
+
inputToolsMenu: [],
|
|
196
|
+
onUpdateModelValue: vi.fn(),
|
|
197
|
+
onSubmitMessage: vi.fn(),
|
|
198
|
+
onStop: vi.fn(),
|
|
199
|
+
onSelectSuggestion: vi.fn(),
|
|
200
|
+
},
|
|
201
|
+
slots: {
|
|
202
|
+
"welcome-message": () =>
|
|
203
|
+
h("div", { "data-testid": "sidebar-welcome-message" }, "Hello"),
|
|
204
|
+
},
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
expect(
|
|
208
|
+
wrapper.find("[data-testid='copilot-sidebar-welcome-screen']").exists(),
|
|
209
|
+
).toBe(true);
|
|
210
|
+
expect(wrapper.get("[data-testid='sidebar-welcome-message']").text()).toBe(
|
|
211
|
+
"Hello",
|
|
212
|
+
);
|
|
213
|
+
});
|
|
214
|
+
});
|
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cleanup,
|
|
3
|
+
fireEvent,
|
|
4
|
+
render,
|
|
5
|
+
screen,
|
|
6
|
+
waitFor,
|
|
7
|
+
} from "@testing-library/vue";
|
|
8
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
9
|
+
import { defineComponent, nextTick } from "vue";
|
|
10
|
+
import {
|
|
11
|
+
activitySnapshotEvent,
|
|
12
|
+
runFinishedEvent,
|
|
13
|
+
runStartedEvent,
|
|
14
|
+
testId,
|
|
15
|
+
} from "../../../__tests__/utils/test-helpers";
|
|
16
|
+
import { AbstractAgent, EventType } from "@ag-ui/client";
|
|
17
|
+
import type { BaseEvent, RunAgentInput, RunAgentResult } from "@ag-ui/client";
|
|
18
|
+
import { Observable, Subject } from "rxjs";
|
|
19
|
+
import { MCPAppsActivityType } from "../../MCPAppsActivityRenderer";
|
|
20
|
+
import CopilotChat from "../CopilotChat.vue";
|
|
21
|
+
import CopilotKitProvider from "../../../providers/CopilotKitProvider.vue";
|
|
22
|
+
import CopilotChatConfigurationProvider from "../../../providers/CopilotChatConfigurationProvider.vue";
|
|
23
|
+
|
|
24
|
+
class MockMCPProxyAgent extends AbstractAgent {
|
|
25
|
+
private readonly subject = new Subject<BaseEvent>();
|
|
26
|
+
private bufferedEvents: BaseEvent[] = [];
|
|
27
|
+
public runAgentCalls: Array<{ input: Partial<RunAgentInput> }> = [];
|
|
28
|
+
public addMessageCalls: Array<{
|
|
29
|
+
id: string;
|
|
30
|
+
role: string;
|
|
31
|
+
content: unknown;
|
|
32
|
+
}> = [];
|
|
33
|
+
private readonly runAgentResponses = new Map<string, unknown>();
|
|
34
|
+
|
|
35
|
+
setRunAgentResponse(method: string, response: unknown): void {
|
|
36
|
+
this.runAgentResponses.set(method, response);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async emit(event: BaseEvent): Promise<void> {
|
|
40
|
+
if (event.type === EventType.RUN_STARTED) {
|
|
41
|
+
this.isRunning = true;
|
|
42
|
+
} else if (
|
|
43
|
+
event.type === EventType.RUN_FINISHED ||
|
|
44
|
+
event.type === EventType.RUN_ERROR
|
|
45
|
+
) {
|
|
46
|
+
this.isRunning = false;
|
|
47
|
+
}
|
|
48
|
+
if (this.subject.observers.length === 0) {
|
|
49
|
+
this.bufferedEvents.push(event);
|
|
50
|
+
} else {
|
|
51
|
+
this.subject.next(event);
|
|
52
|
+
}
|
|
53
|
+
await flushVueUpdates();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
clone(): MockMCPProxyAgent {
|
|
57
|
+
const cloned = new MockMCPProxyAgent();
|
|
58
|
+
cloned.agentId = this.agentId;
|
|
59
|
+
type Internal = {
|
|
60
|
+
subject: Subject<BaseEvent>;
|
|
61
|
+
bufferedEvents: BaseEvent[];
|
|
62
|
+
runAgentCalls: Array<{ input: Partial<RunAgentInput> }>;
|
|
63
|
+
addMessageCalls: Array<{ id: string; role: string; content: unknown }>;
|
|
64
|
+
runAgentResponses: Map<string, unknown>;
|
|
65
|
+
};
|
|
66
|
+
(cloned as unknown as Internal).subject = (
|
|
67
|
+
this as unknown as Internal
|
|
68
|
+
).subject;
|
|
69
|
+
(cloned as unknown as Internal).bufferedEvents = (
|
|
70
|
+
this as unknown as Internal
|
|
71
|
+
).bufferedEvents;
|
|
72
|
+
(cloned as unknown as Internal).runAgentCalls = (
|
|
73
|
+
this as unknown as Internal
|
|
74
|
+
).runAgentCalls;
|
|
75
|
+
(cloned as unknown as Internal).addMessageCalls = (
|
|
76
|
+
this as unknown as Internal
|
|
77
|
+
).addMessageCalls;
|
|
78
|
+
(cloned as unknown as Internal).runAgentResponses = (
|
|
79
|
+
this as unknown as Internal
|
|
80
|
+
).runAgentResponses;
|
|
81
|
+
|
|
82
|
+
const registry = this;
|
|
83
|
+
Object.defineProperty(cloned, "isRunning", {
|
|
84
|
+
get() {
|
|
85
|
+
return registry.isRunning;
|
|
86
|
+
},
|
|
87
|
+
set(v: boolean) {
|
|
88
|
+
registry.isRunning = v;
|
|
89
|
+
},
|
|
90
|
+
configurable: true,
|
|
91
|
+
enumerable: true,
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const proto = MockMCPProxyAgent.prototype;
|
|
95
|
+
cloned.runAgent = async function (
|
|
96
|
+
input?: Partial<RunAgentInput>,
|
|
97
|
+
): Promise<RunAgentResult> {
|
|
98
|
+
const proxiedRequest = input?.forwardedProps?.__proxiedMCPRequest;
|
|
99
|
+
if (proxiedRequest) {
|
|
100
|
+
return registry.runAgent(input);
|
|
101
|
+
}
|
|
102
|
+
return proto.runAgent.call(cloned, input);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
cloned.run = function (input: RunAgentInput): Observable<BaseEvent> {
|
|
106
|
+
return registry.run(input);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const originalAddMessage = cloned.addMessage.bind(cloned);
|
|
110
|
+
cloned.addMessage = function (
|
|
111
|
+
message: Parameters<AbstractAgent["addMessage"]>[0],
|
|
112
|
+
) {
|
|
113
|
+
registry.addMessageCalls.push({
|
|
114
|
+
id: message.id,
|
|
115
|
+
role: message.role,
|
|
116
|
+
content: message.content,
|
|
117
|
+
});
|
|
118
|
+
return originalAddMessage(message);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
return cloned;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
run(_input: RunAgentInput): Observable<BaseEvent> {
|
|
125
|
+
return new Observable<BaseEvent>((observer) => {
|
|
126
|
+
if (this.bufferedEvents.length > 0) {
|
|
127
|
+
for (const event of this.bufferedEvents) {
|
|
128
|
+
observer.next(event);
|
|
129
|
+
}
|
|
130
|
+
this.bufferedEvents = [];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const subscription = this.subject.subscribe(observer);
|
|
134
|
+
return () => subscription.unsubscribe();
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async runAgent(input?: Partial<RunAgentInput>): Promise<RunAgentResult> {
|
|
139
|
+
const proxiedRequest = input?.forwardedProps?.__proxiedMCPRequest as
|
|
140
|
+
| {
|
|
141
|
+
serverHash?: string;
|
|
142
|
+
serverId?: string;
|
|
143
|
+
method: string;
|
|
144
|
+
params?: Record<string, unknown>;
|
|
145
|
+
}
|
|
146
|
+
| undefined;
|
|
147
|
+
|
|
148
|
+
if (proxiedRequest) {
|
|
149
|
+
if (input) {
|
|
150
|
+
this.runAgentCalls.push({ input });
|
|
151
|
+
}
|
|
152
|
+
const method = proxiedRequest.method;
|
|
153
|
+
const response = this.runAgentResponses.get(method);
|
|
154
|
+
if (response !== undefined) {
|
|
155
|
+
return { result: response, newMessages: [] };
|
|
156
|
+
}
|
|
157
|
+
if (method === "resources/read") {
|
|
158
|
+
return {
|
|
159
|
+
result: {
|
|
160
|
+
contents: [
|
|
161
|
+
{
|
|
162
|
+
uri: proxiedRequest.params?.uri,
|
|
163
|
+
mimeType: "text/html",
|
|
164
|
+
text: "<html><body>Test content</body></html>",
|
|
165
|
+
},
|
|
166
|
+
],
|
|
167
|
+
},
|
|
168
|
+
newMessages: [],
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
return { result: {}, newMessages: [] };
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return super.runAgent(input);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
async function flushVueUpdates(): Promise<void> {
|
|
179
|
+
await nextTick();
|
|
180
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
async function setupMCPActivity(
|
|
184
|
+
agent: MockMCPProxyAgent,
|
|
185
|
+
userMessage: string,
|
|
186
|
+
): Promise<HTMLIFrameElement> {
|
|
187
|
+
const threadId = testId("mcp-ui-message-thread");
|
|
188
|
+
const agentId = agent.agentId ?? "mcp-ui-message-agent";
|
|
189
|
+
agent.agentId = agentId;
|
|
190
|
+
agent.setRunAgentResponse("resources/read", {
|
|
191
|
+
contents: [
|
|
192
|
+
{
|
|
193
|
+
uri: "ui://test/app",
|
|
194
|
+
mimeType: "text/html",
|
|
195
|
+
text: "<html><body>App</body></html>",
|
|
196
|
+
},
|
|
197
|
+
],
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
const Host = defineComponent({
|
|
201
|
+
components: {
|
|
202
|
+
CopilotKitProvider,
|
|
203
|
+
CopilotChatConfigurationProvider,
|
|
204
|
+
CopilotChat,
|
|
205
|
+
},
|
|
206
|
+
setup() {
|
|
207
|
+
return {
|
|
208
|
+
agentId,
|
|
209
|
+
threadId,
|
|
210
|
+
agents: { [agentId]: agent },
|
|
211
|
+
};
|
|
212
|
+
},
|
|
213
|
+
template: `
|
|
214
|
+
<CopilotKitProvider runtimeUrl="/api/copilotkit" :agents__unsafe_dev_only="agents">
|
|
215
|
+
<CopilotChatConfigurationProvider :thread-id="threadId" :agent-id="agentId">
|
|
216
|
+
<div style="height: 400px;">
|
|
217
|
+
<CopilotChat :welcome-screen="false" />
|
|
218
|
+
</div>
|
|
219
|
+
</CopilotChatConfigurationProvider>
|
|
220
|
+
</CopilotKitProvider>
|
|
221
|
+
`,
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
render(Host);
|
|
225
|
+
|
|
226
|
+
const input = await screen.findByRole("textbox");
|
|
227
|
+
await fireEvent.update(input, userMessage);
|
|
228
|
+
await fireEvent.keyDown(input, { key: "Enter", code: "Enter" });
|
|
229
|
+
|
|
230
|
+
await waitFor(() => {
|
|
231
|
+
expect(screen.getByText(userMessage)).toBeDefined();
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
await agent.emit(runStartedEvent());
|
|
235
|
+
await agent.emit(
|
|
236
|
+
activitySnapshotEvent({
|
|
237
|
+
messageId: testId("mcp-activity"),
|
|
238
|
+
activityType: MCPAppsActivityType,
|
|
239
|
+
content: {
|
|
240
|
+
resourceUri: "ui://test/app",
|
|
241
|
+
serverHash: "test-hash",
|
|
242
|
+
toolInput: {},
|
|
243
|
+
result: {
|
|
244
|
+
content: [{ type: "text", text: "Tool output" }],
|
|
245
|
+
isError: false,
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
}),
|
|
249
|
+
);
|
|
250
|
+
await agent.emit(runFinishedEvent());
|
|
251
|
+
|
|
252
|
+
let iframe: HTMLIFrameElement | null = null;
|
|
253
|
+
await waitFor(
|
|
254
|
+
() => {
|
|
255
|
+
iframe = document.querySelector("iframe[srcdoc]");
|
|
256
|
+
expect(iframe).not.toBeNull();
|
|
257
|
+
},
|
|
258
|
+
{ timeout: 3000 },
|
|
259
|
+
);
|
|
260
|
+
|
|
261
|
+
const readyEvent = new MessageEvent("message", {
|
|
262
|
+
data: {
|
|
263
|
+
jsonrpc: "2.0",
|
|
264
|
+
method: "ui/notifications/sandbox-proxy-ready",
|
|
265
|
+
},
|
|
266
|
+
source: iframe!.contentWindow,
|
|
267
|
+
origin: "",
|
|
268
|
+
});
|
|
269
|
+
window.dispatchEvent(readyEvent);
|
|
270
|
+
await flushVueUpdates();
|
|
271
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
272
|
+
|
|
273
|
+
return iframe!;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
async function sendUiMessage(
|
|
277
|
+
iframe: HTMLIFrameElement,
|
|
278
|
+
agent: MockMCPProxyAgent,
|
|
279
|
+
params: {
|
|
280
|
+
role?: string;
|
|
281
|
+
content?: Array<{ type: string; text?: string }>;
|
|
282
|
+
followUp?: boolean;
|
|
283
|
+
},
|
|
284
|
+
) {
|
|
285
|
+
const messageEvent = new MessageEvent("message", {
|
|
286
|
+
data: {
|
|
287
|
+
jsonrpc: "2.0",
|
|
288
|
+
id: testId("ui-message-request"),
|
|
289
|
+
method: "ui/message",
|
|
290
|
+
params,
|
|
291
|
+
},
|
|
292
|
+
source: iframe.contentWindow,
|
|
293
|
+
origin: "",
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
window.dispatchEvent(messageEvent);
|
|
297
|
+
await flushVueUpdates();
|
|
298
|
+
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
299
|
+
|
|
300
|
+
// Settle possible follow-up run to avoid leaking queue/running state.
|
|
301
|
+
await agent.emit(runStartedEvent());
|
|
302
|
+
await agent.emit(runFinishedEvent());
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
describe("MCP Apps ui/message followUp behavior", () => {
|
|
306
|
+
beforeEach(() => {
|
|
307
|
+
vi.clearAllMocks();
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
afterEach(() => {
|
|
311
|
+
cleanup();
|
|
312
|
+
document.body.innerHTML = "";
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
it("user-role message: addMessage IS called and runAgent IS invoked", async () => {
|
|
316
|
+
const agent = new MockMCPProxyAgent();
|
|
317
|
+
agent.agentId = "ui-msg-agent-user";
|
|
318
|
+
const iframe = await setupMCPActivity(agent, "User role test");
|
|
319
|
+
|
|
320
|
+
const runSpy = vi.spyOn(agent, "run");
|
|
321
|
+
const before = runSpy.mock.calls.length;
|
|
322
|
+
|
|
323
|
+
await sendUiMessage(iframe, agent, {
|
|
324
|
+
role: "user",
|
|
325
|
+
content: [{ type: "text", text: "Hello from MCP app" }],
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
const added = agent.addMessageCalls.some(
|
|
329
|
+
(message) =>
|
|
330
|
+
message.role === "user" && message.content === "Hello from MCP app",
|
|
331
|
+
);
|
|
332
|
+
expect(added).toBe(true);
|
|
333
|
+
expect(runSpy.mock.calls.length).toBeGreaterThan(before);
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
it("assistant-role message: addMessage IS called but runAgent is NOT invoked", async () => {
|
|
337
|
+
const agent = new MockMCPProxyAgent();
|
|
338
|
+
agent.agentId = "ui-msg-agent-assistant";
|
|
339
|
+
const iframe = await setupMCPActivity(agent, "Assistant role test");
|
|
340
|
+
|
|
341
|
+
const runSpy = vi.spyOn(agent, "run");
|
|
342
|
+
const before = runSpy.mock.calls.length;
|
|
343
|
+
|
|
344
|
+
await sendUiMessage(iframe, agent, {
|
|
345
|
+
role: "assistant",
|
|
346
|
+
content: [{ type: "text", text: "Assistant message from MCP app" }],
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
const added = agent.addMessageCalls.some(
|
|
350
|
+
(message) =>
|
|
351
|
+
message.role === "assistant" &&
|
|
352
|
+
message.content === "Assistant message from MCP app",
|
|
353
|
+
);
|
|
354
|
+
expect(added).toBe(true);
|
|
355
|
+
expect(runSpy.mock.calls.length).toBe(before);
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
it("followUp: false on user-role message: addMessage IS called but runAgent is NOT invoked", async () => {
|
|
359
|
+
const agent = new MockMCPProxyAgent();
|
|
360
|
+
agent.agentId = "ui-msg-agent-user-no-follow-up";
|
|
361
|
+
const iframe = await setupMCPActivity(agent, "No follow-up user role test");
|
|
362
|
+
|
|
363
|
+
const runSpy = vi.spyOn(agent, "run");
|
|
364
|
+
const before = runSpy.mock.calls.length;
|
|
365
|
+
|
|
366
|
+
await sendUiMessage(iframe, agent, {
|
|
367
|
+
role: "user",
|
|
368
|
+
followUp: false,
|
|
369
|
+
content: [{ type: "text", text: "Display-only message" }],
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
expect(runSpy.mock.calls.length).toBe(before);
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
it("followUp: true on assistant-role message: addMessage IS called AND runAgent IS invoked", async () => {
|
|
376
|
+
const agent = new MockMCPProxyAgent();
|
|
377
|
+
agent.agentId = "ui-msg-agent-assistant-follow-up";
|
|
378
|
+
const iframe = await setupMCPActivity(
|
|
379
|
+
agent,
|
|
380
|
+
"Forced follow-up assistant role test",
|
|
381
|
+
);
|
|
382
|
+
|
|
383
|
+
const runSpy = vi.spyOn(agent, "run");
|
|
384
|
+
const before = runSpy.mock.calls.length;
|
|
385
|
+
|
|
386
|
+
await sendUiMessage(iframe, agent, {
|
|
387
|
+
role: "assistant",
|
|
388
|
+
followUp: true,
|
|
389
|
+
content: [{ type: "text", text: "Assistant with follow-up" }],
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
expect(runSpy.mock.calls.length).toBeGreaterThan(before);
|
|
393
|
+
});
|
|
394
|
+
});
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// oxlint-disable typescript/consistent-type-imports
|
|
2
|
+
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
3
|
+
import { defineComponent, h, ref } from "vue";
|
|
4
|
+
import type { AbstractAgent } from "@ag-ui/client";
|
|
5
|
+
import { useAgent } from "../../../hooks/use-agent";
|
|
6
|
+
import { mountWithProvider } from "../../../__tests__/utils/mount";
|
|
7
|
+
import { MockStepwiseAgent } from "../../../__tests__/utils/test-helpers";
|
|
8
|
+
import CopilotChat from "../CopilotChat.vue";
|
|
9
|
+
import type { CopilotPopupProps, CopilotSidebarProps } from "../types";
|
|
10
|
+
|
|
11
|
+
vi.mock("../../../hooks/use-agent", async (importOriginal) => {
|
|
12
|
+
const actual =
|
|
13
|
+
await importOriginal<typeof import("../../../hooks/use-agent")>();
|
|
14
|
+
return {
|
|
15
|
+
...actual,
|
|
16
|
+
useAgent: vi.fn(),
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const mockUseAgent = useAgent as ReturnType<typeof vi.fn>;
|
|
21
|
+
|
|
22
|
+
function createHost(props: Record<string, unknown> = {}) {
|
|
23
|
+
return defineComponent({
|
|
24
|
+
components: { CopilotChat },
|
|
25
|
+
setup() {
|
|
26
|
+
return { props };
|
|
27
|
+
},
|
|
28
|
+
template: `<CopilotChat v-bind="props" :welcome-screen="false" />`,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
describe("CopilotChat throttleMs prop", () => {
|
|
33
|
+
let mockAgent: MockStepwiseAgent;
|
|
34
|
+
|
|
35
|
+
beforeEach(() => {
|
|
36
|
+
mockUseAgent.mockReset();
|
|
37
|
+
mockAgent = new MockStepwiseAgent();
|
|
38
|
+
mockAgent.agentId = "default";
|
|
39
|
+
mockUseAgent.mockReturnValue({ agent: ref(mockAgent) });
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("passes throttleMs prop to useAgent", () => {
|
|
43
|
+
mountWithProvider(() => h(createHost({ throttleMs: 500 })), {
|
|
44
|
+
agents__unsafe_dev_only: { default: mockAgent as AbstractAgent },
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
expect(mockUseAgent).toHaveBeenCalledWith(
|
|
48
|
+
expect.objectContaining({
|
|
49
|
+
throttleMs: expect.any(Object),
|
|
50
|
+
}),
|
|
51
|
+
);
|
|
52
|
+
const throttleArg = mockUseAgent.mock.calls[0]?.[0]?.throttleMs;
|
|
53
|
+
expect(typeof throttleArg).toBe("object");
|
|
54
|
+
expect(throttleArg?.value).toBe(500);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("passes undefined throttleMs when prop is not set", () => {
|
|
58
|
+
mountWithProvider(() => h(createHost()), {
|
|
59
|
+
agents__unsafe_dev_only: { default: mockAgent as AbstractAgent },
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
expect(mockUseAgent).toHaveBeenCalledWith(
|
|
63
|
+
expect.objectContaining({
|
|
64
|
+
throttleMs: expect.any(Object),
|
|
65
|
+
}),
|
|
66
|
+
);
|
|
67
|
+
const throttleArg = mockUseAgent.mock.calls[0]?.[0]?.throttleMs;
|
|
68
|
+
expect(throttleArg?.value).toBeUndefined();
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
describe("throttleMs type inheritance", () => {
|
|
73
|
+
it("CopilotSidebarProps includes throttleMs via CopilotChatProps", () => {
|
|
74
|
+
const sidebarProps: CopilotSidebarProps = { throttleMs: 1000 };
|
|
75
|
+
expect(sidebarProps.throttleMs).toBe(1000);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("CopilotPopupProps includes throttleMs via CopilotChatProps", () => {
|
|
79
|
+
const popupProps: CopilotPopupProps = { throttleMs: 2000 };
|
|
80
|
+
expect(popupProps.throttleMs).toBe(2000);
|
|
81
|
+
});
|
|
82
|
+
});
|