@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,141 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { h } from "vue";
|
|
3
|
+
import { mount } from "@vue/test-utils";
|
|
4
|
+
import type { ActivityMessage, AssistantMessage, Message } from "@ag-ui/core";
|
|
5
|
+
import CopilotKitProvider from "../../../providers/CopilotKitProvider.vue";
|
|
6
|
+
import CopilotChatConfigurationProvider from "../../../providers/CopilotChatConfigurationProvider.vue";
|
|
7
|
+
import CopilotChatMessageView from "../CopilotChatMessageView.vue";
|
|
8
|
+
|
|
9
|
+
function mountMessageView(
|
|
10
|
+
messages: Message[],
|
|
11
|
+
slots: Parameters<typeof h>[2] = {},
|
|
12
|
+
) {
|
|
13
|
+
return mount(CopilotKitProvider, {
|
|
14
|
+
props: { runtimeUrl: "/api/copilotkit" },
|
|
15
|
+
slots: {
|
|
16
|
+
default: () =>
|
|
17
|
+
h(
|
|
18
|
+
CopilotChatConfigurationProvider,
|
|
19
|
+
{ threadId: "thread-1", agentId: "default" },
|
|
20
|
+
{
|
|
21
|
+
default: () => h(CopilotChatMessageView, { messages }, slots),
|
|
22
|
+
},
|
|
23
|
+
),
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
describe("CopilotChatMessageView.slots.e2e", () => {
|
|
29
|
+
it("prefers named activity slot over generic activity slot", () => {
|
|
30
|
+
const messages: Message[] = [
|
|
31
|
+
{
|
|
32
|
+
id: "activity-1",
|
|
33
|
+
role: "activity",
|
|
34
|
+
activityType: "search-progress",
|
|
35
|
+
content: { percent: 40 },
|
|
36
|
+
} as ActivityMessage,
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
const wrapper = mountMessageView(messages, {
|
|
40
|
+
"activity-search-progress": () =>
|
|
41
|
+
h("div", { "data-testid": "named-activity-slot" }, "named"),
|
|
42
|
+
"activity-message": () =>
|
|
43
|
+
h("div", { "data-testid": "fallback-activity-slot" }, "fallback"),
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
expect(wrapper.find("[data-testid='named-activity-slot']").exists()).toBe(
|
|
47
|
+
true,
|
|
48
|
+
);
|
|
49
|
+
expect(
|
|
50
|
+
wrapper.find("[data-testid='fallback-activity-slot']").exists(),
|
|
51
|
+
).toBe(false);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("prefers generic activity slot over built-in MCP fallback", () => {
|
|
55
|
+
const messages: Message[] = [
|
|
56
|
+
{
|
|
57
|
+
id: "activity-mcp",
|
|
58
|
+
role: "activity",
|
|
59
|
+
activityType: "mcp-apps",
|
|
60
|
+
content: {
|
|
61
|
+
resourceUri: "ui://server/dashboard",
|
|
62
|
+
serverHash: "abc123",
|
|
63
|
+
result: {},
|
|
64
|
+
},
|
|
65
|
+
} as ActivityMessage,
|
|
66
|
+
];
|
|
67
|
+
|
|
68
|
+
const wrapper = mountMessageView(messages, {
|
|
69
|
+
"activity-message": () =>
|
|
70
|
+
h("div", { "data-testid": "generic-activity-slot" }, "generic"),
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
expect(wrapper.find("[data-testid='generic-activity-slot']").exists()).toBe(
|
|
74
|
+
true,
|
|
75
|
+
);
|
|
76
|
+
expect(wrapper.text()).not.toContain(
|
|
77
|
+
"No agent available to fetch resource",
|
|
78
|
+
);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it("prefers named tool slot over generic tool slot", () => {
|
|
82
|
+
const messages: Message[] = [
|
|
83
|
+
{
|
|
84
|
+
id: "assistant-1",
|
|
85
|
+
role: "assistant",
|
|
86
|
+
content: "",
|
|
87
|
+
toolCalls: [
|
|
88
|
+
{
|
|
89
|
+
id: "tc-1",
|
|
90
|
+
type: "function",
|
|
91
|
+
function: {
|
|
92
|
+
name: "search_docs",
|
|
93
|
+
arguments: JSON.stringify({ query: "slots" }),
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
} as AssistantMessage,
|
|
98
|
+
];
|
|
99
|
+
|
|
100
|
+
const wrapper = mountMessageView(messages, {
|
|
101
|
+
"tool-call-search_docs": ({ status }: { status: string }) =>
|
|
102
|
+
h("div", { "data-testid": "named-tool-slot" }, status),
|
|
103
|
+
"tool-call": () =>
|
|
104
|
+
h("div", { "data-testid": "generic-tool-slot" }, "generic"),
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
expect(wrapper.find("[data-testid='named-tool-slot']").exists()).toBe(true);
|
|
108
|
+
expect(wrapper.find("[data-testid='generic-tool-slot']").exists()).toBe(
|
|
109
|
+
false,
|
|
110
|
+
);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it("renders generic tool slot when named slot is absent", () => {
|
|
114
|
+
const messages: Message[] = [
|
|
115
|
+
{
|
|
116
|
+
id: "assistant-2",
|
|
117
|
+
role: "assistant",
|
|
118
|
+
content: "",
|
|
119
|
+
toolCalls: [
|
|
120
|
+
{
|
|
121
|
+
id: "tc-1",
|
|
122
|
+
type: "function",
|
|
123
|
+
function: {
|
|
124
|
+
name: "unknown_tool",
|
|
125
|
+
arguments: JSON.stringify({ query: "fallback" }),
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
|
+
} as AssistantMessage,
|
|
130
|
+
];
|
|
131
|
+
|
|
132
|
+
const wrapper = mountMessageView(messages, {
|
|
133
|
+
"tool-call": ({ name }: { name: string }) =>
|
|
134
|
+
h("div", { "data-testid": "generic-tool-slot" }, name),
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
expect(wrapper.get("[data-testid='generic-tool-slot']").text()).toBe(
|
|
138
|
+
"unknown_tool",
|
|
139
|
+
);
|
|
140
|
+
});
|
|
141
|
+
});
|
|
@@ -0,0 +1,494 @@
|
|
|
1
|
+
import { defineComponent } from "vue";
|
|
2
|
+
import { render, screen } from "@testing-library/vue";
|
|
3
|
+
import { describe, expect, it } from "vitest";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import type {
|
|
6
|
+
ActivityMessage,
|
|
7
|
+
AssistantMessage,
|
|
8
|
+
Message,
|
|
9
|
+
UserMessage,
|
|
10
|
+
} from "@ag-ui/core";
|
|
11
|
+
import CopilotKitProvider from "../../../providers/CopilotKitProvider.vue";
|
|
12
|
+
import CopilotChatConfigurationProvider from "../../../providers/CopilotChatConfigurationProvider.vue";
|
|
13
|
+
import CopilotChatMessageView from "../CopilotChatMessageView.vue";
|
|
14
|
+
|
|
15
|
+
describe("CopilotChatMessageView activity rendering", () => {
|
|
16
|
+
const agentId = "default";
|
|
17
|
+
const threadId = "thread-test";
|
|
18
|
+
|
|
19
|
+
function renderMessageView({
|
|
20
|
+
messages,
|
|
21
|
+
hostTemplate = `<CopilotChatMessageView :messages="messages" />`,
|
|
22
|
+
}: {
|
|
23
|
+
messages: Message[];
|
|
24
|
+
hostTemplate?: string;
|
|
25
|
+
}) {
|
|
26
|
+
const ActivityRenderer = defineComponent({
|
|
27
|
+
name: "ActivityRenderer",
|
|
28
|
+
props: {
|
|
29
|
+
content: { type: Object, required: true },
|
|
30
|
+
},
|
|
31
|
+
setup(props) {
|
|
32
|
+
return {
|
|
33
|
+
percent: (props.content as { percent: number }).percent,
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
template: `
|
|
37
|
+
<div data-testid="activity-renderer">
|
|
38
|
+
Progress: {{ percent }}%
|
|
39
|
+
</div>
|
|
40
|
+
`,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const Host = defineComponent({
|
|
44
|
+
components: {
|
|
45
|
+
CopilotKitProvider,
|
|
46
|
+
CopilotChatConfigurationProvider,
|
|
47
|
+
CopilotChatMessageView,
|
|
48
|
+
ActivityRenderer,
|
|
49
|
+
},
|
|
50
|
+
setup() {
|
|
51
|
+
return { messages, agentId, threadId };
|
|
52
|
+
},
|
|
53
|
+
template: `
|
|
54
|
+
<CopilotKitProvider runtime-url="/api/copilotkit">
|
|
55
|
+
<CopilotChatConfigurationProvider :agent-id="agentId" :thread-id="threadId">
|
|
56
|
+
${hostTemplate}
|
|
57
|
+
</CopilotChatConfigurationProvider>
|
|
58
|
+
</CopilotKitProvider>
|
|
59
|
+
`,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
return render(Host);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
it("renders activity messages via matching custom renderer", () => {
|
|
66
|
+
const messages: Message[] = [
|
|
67
|
+
{
|
|
68
|
+
id: "act-1",
|
|
69
|
+
role: "activity",
|
|
70
|
+
activityType: "search-progress",
|
|
71
|
+
content: { percent: 42 },
|
|
72
|
+
} as ActivityMessage,
|
|
73
|
+
];
|
|
74
|
+
|
|
75
|
+
const renderers = [
|
|
76
|
+
{
|
|
77
|
+
activityType: "search-progress",
|
|
78
|
+
content: z.object({ percent: z.number() }),
|
|
79
|
+
},
|
|
80
|
+
];
|
|
81
|
+
expect(renderers).toHaveLength(1);
|
|
82
|
+
|
|
83
|
+
renderMessageView({
|
|
84
|
+
messages,
|
|
85
|
+
hostTemplate: `
|
|
86
|
+
<CopilotChatMessageView :messages="messages">
|
|
87
|
+
<template #activity-search-progress="{ content }">
|
|
88
|
+
<ActivityRenderer :content="content" />
|
|
89
|
+
</template>
|
|
90
|
+
</CopilotChatMessageView>
|
|
91
|
+
`,
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
expect(screen.getByTestId("activity-renderer").textContent).toContain("42");
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it("skips rendering when no activity renderer matches", () => {
|
|
98
|
+
const messages: Message[] = [
|
|
99
|
+
{
|
|
100
|
+
id: "act-2",
|
|
101
|
+
role: "activity",
|
|
102
|
+
activityType: "unknown-type",
|
|
103
|
+
content: { message: "should not render" },
|
|
104
|
+
} as ActivityMessage,
|
|
105
|
+
];
|
|
106
|
+
|
|
107
|
+
renderMessageView({
|
|
108
|
+
messages,
|
|
109
|
+
hostTemplate: `<CopilotChatMessageView :messages="messages" />`,
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
expect(screen.queryByTestId("activity-renderer")).toBeNull();
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
describe("CopilotChatMessageView duplicate message deduplication", () => {
|
|
117
|
+
const agentId = "default";
|
|
118
|
+
const threadId = "thread-test";
|
|
119
|
+
|
|
120
|
+
function renderMessageView({ messages }: { messages: Message[] }) {
|
|
121
|
+
const Host = defineComponent({
|
|
122
|
+
components: {
|
|
123
|
+
CopilotKitProvider,
|
|
124
|
+
CopilotChatConfigurationProvider,
|
|
125
|
+
CopilotChatMessageView,
|
|
126
|
+
},
|
|
127
|
+
setup() {
|
|
128
|
+
return { messages, agentId, threadId };
|
|
129
|
+
},
|
|
130
|
+
template: `
|
|
131
|
+
<CopilotKitProvider runtime-url="/api/copilotkit">
|
|
132
|
+
<CopilotChatConfigurationProvider :agent-id="agentId" :thread-id="threadId">
|
|
133
|
+
<CopilotChatMessageView :messages="messages" />
|
|
134
|
+
</CopilotChatConfigurationProvider>
|
|
135
|
+
</CopilotKitProvider>
|
|
136
|
+
`,
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
return render(Host);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
it("preserves assistant text content when later duplicate has empty content (multi-tool-call scenario)", () => {
|
|
143
|
+
const messages: Message[] = [
|
|
144
|
+
{
|
|
145
|
+
id: "user-1",
|
|
146
|
+
role: "user",
|
|
147
|
+
content: "Record a headache",
|
|
148
|
+
} as UserMessage,
|
|
149
|
+
{
|
|
150
|
+
id: "assistant-1",
|
|
151
|
+
role: "assistant",
|
|
152
|
+
content: "Let me record that...",
|
|
153
|
+
} as AssistantMessage,
|
|
154
|
+
{
|
|
155
|
+
id: "assistant-1",
|
|
156
|
+
role: "assistant",
|
|
157
|
+
content: "",
|
|
158
|
+
toolCalls: [
|
|
159
|
+
{
|
|
160
|
+
id: "tc-1",
|
|
161
|
+
type: "function",
|
|
162
|
+
function: { name: "captureData", arguments: "{}" },
|
|
163
|
+
},
|
|
164
|
+
],
|
|
165
|
+
} as AssistantMessage,
|
|
166
|
+
{
|
|
167
|
+
id: "assistant-1",
|
|
168
|
+
role: "assistant",
|
|
169
|
+
content: "",
|
|
170
|
+
toolCalls: [
|
|
171
|
+
{
|
|
172
|
+
id: "tc-1",
|
|
173
|
+
type: "function",
|
|
174
|
+
function: { name: "captureData", arguments: "{}" },
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
id: "tc-2",
|
|
178
|
+
type: "function",
|
|
179
|
+
function: { name: "updateMemory", arguments: "{}" },
|
|
180
|
+
},
|
|
181
|
+
],
|
|
182
|
+
} as AssistantMessage,
|
|
183
|
+
];
|
|
184
|
+
|
|
185
|
+
renderMessageView({ messages });
|
|
186
|
+
|
|
187
|
+
const assistantMessages = screen.getAllByTestId(
|
|
188
|
+
"copilot-assistant-message",
|
|
189
|
+
);
|
|
190
|
+
expect(assistantMessages).toHaveLength(1);
|
|
191
|
+
expect(assistantMessages[0]?.textContent).toContain(
|
|
192
|
+
"Let me record that...",
|
|
193
|
+
);
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
it("uses latest content when all assistant duplicates have non-empty content", () => {
|
|
197
|
+
const messages: Message[] = [
|
|
198
|
+
{
|
|
199
|
+
id: "user-1",
|
|
200
|
+
role: "user",
|
|
201
|
+
content: "Hello",
|
|
202
|
+
} as UserMessage,
|
|
203
|
+
{
|
|
204
|
+
id: "assistant-1",
|
|
205
|
+
role: "assistant",
|
|
206
|
+
content: "Partial response...",
|
|
207
|
+
} as AssistantMessage,
|
|
208
|
+
{
|
|
209
|
+
id: "assistant-1",
|
|
210
|
+
role: "assistant",
|
|
211
|
+
content: "Full response from the assistant.",
|
|
212
|
+
} as AssistantMessage,
|
|
213
|
+
];
|
|
214
|
+
|
|
215
|
+
renderMessageView({ messages });
|
|
216
|
+
|
|
217
|
+
const assistantMessages = screen.getAllByTestId(
|
|
218
|
+
"copilot-assistant-message",
|
|
219
|
+
);
|
|
220
|
+
expect(assistantMessages).toHaveLength(1);
|
|
221
|
+
expect(assistantMessages[0]?.textContent).toContain(
|
|
222
|
+
"Full response from the assistant.",
|
|
223
|
+
);
|
|
224
|
+
|
|
225
|
+
const userMessages = screen.getAllByTestId("copilot-user-message");
|
|
226
|
+
expect(userMessages).toHaveLength(1);
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
it("uses later content when earlier content is empty", () => {
|
|
230
|
+
const messages: Message[] = [
|
|
231
|
+
{
|
|
232
|
+
id: "assistant-1",
|
|
233
|
+
role: "assistant",
|
|
234
|
+
content: "",
|
|
235
|
+
} as AssistantMessage,
|
|
236
|
+
{
|
|
237
|
+
id: "assistant-1",
|
|
238
|
+
role: "assistant",
|
|
239
|
+
content: "Here is the result.",
|
|
240
|
+
} as AssistantMessage,
|
|
241
|
+
];
|
|
242
|
+
|
|
243
|
+
const Host = defineComponent({
|
|
244
|
+
components: {
|
|
245
|
+
CopilotKitProvider,
|
|
246
|
+
CopilotChatConfigurationProvider,
|
|
247
|
+
CopilotChatMessageView,
|
|
248
|
+
},
|
|
249
|
+
setup() {
|
|
250
|
+
return { messages, agentId, threadId };
|
|
251
|
+
},
|
|
252
|
+
template: `
|
|
253
|
+
<CopilotKitProvider runtime-url="/api/copilotkit">
|
|
254
|
+
<CopilotChatConfigurationProvider :agent-id="agentId" :thread-id="threadId">
|
|
255
|
+
<CopilotChatMessageView :messages="messages">
|
|
256
|
+
<template #assistant-message="{ message }">
|
|
257
|
+
<div data-testid="assistant-content">{{ message.content }}</div>
|
|
258
|
+
</template>
|
|
259
|
+
</CopilotChatMessageView>
|
|
260
|
+
</CopilotChatConfigurationProvider>
|
|
261
|
+
</CopilotKitProvider>
|
|
262
|
+
`,
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
render(Host);
|
|
266
|
+
|
|
267
|
+
expect(screen.getByTestId("assistant-content").textContent).toContain(
|
|
268
|
+
"Here is the result.",
|
|
269
|
+
);
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
it("recovers toolCalls when later duplicate has content but undefined toolCalls", () => {
|
|
273
|
+
const messages: Message[] = [
|
|
274
|
+
{
|
|
275
|
+
id: "assistant-1",
|
|
276
|
+
role: "assistant",
|
|
277
|
+
content: "",
|
|
278
|
+
toolCalls: [
|
|
279
|
+
{
|
|
280
|
+
id: "tc-1",
|
|
281
|
+
type: "function",
|
|
282
|
+
function: { name: "captureData", arguments: "{}" },
|
|
283
|
+
},
|
|
284
|
+
],
|
|
285
|
+
} as AssistantMessage,
|
|
286
|
+
{
|
|
287
|
+
id: "assistant-1",
|
|
288
|
+
role: "assistant",
|
|
289
|
+
content: "Here is the result.",
|
|
290
|
+
} as AssistantMessage,
|
|
291
|
+
];
|
|
292
|
+
|
|
293
|
+
const Host = defineComponent({
|
|
294
|
+
components: {
|
|
295
|
+
CopilotKitProvider,
|
|
296
|
+
CopilotChatConfigurationProvider,
|
|
297
|
+
CopilotChatMessageView,
|
|
298
|
+
},
|
|
299
|
+
setup() {
|
|
300
|
+
return { messages, agentId, threadId };
|
|
301
|
+
},
|
|
302
|
+
template: `
|
|
303
|
+
<CopilotKitProvider runtime-url="/api/copilotkit">
|
|
304
|
+
<CopilotChatConfigurationProvider :agent-id="agentId" :thread-id="threadId">
|
|
305
|
+
<CopilotChatMessageView :messages="messages">
|
|
306
|
+
<template #assistant-message="{ message }">
|
|
307
|
+
<div data-testid="assistant-tool-calls-count">{{ message.toolCalls?.length ?? 0 }}</div>
|
|
308
|
+
<div data-testid="assistant-content">{{ message.content }}</div>
|
|
309
|
+
</template>
|
|
310
|
+
</CopilotChatMessageView>
|
|
311
|
+
</CopilotChatConfigurationProvider>
|
|
312
|
+
</CopilotKitProvider>
|
|
313
|
+
`,
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
render(Host);
|
|
317
|
+
|
|
318
|
+
expect(screen.getByTestId("assistant-content").textContent).toContain(
|
|
319
|
+
"Here is the result.",
|
|
320
|
+
);
|
|
321
|
+
expect(screen.getByTestId("assistant-tool-calls-count").textContent).toBe(
|
|
322
|
+
"1",
|
|
323
|
+
);
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
it("keeps empty toolCalls array from later chunk", () => {
|
|
327
|
+
const messages: Message[] = [
|
|
328
|
+
{
|
|
329
|
+
id: "assistant-1",
|
|
330
|
+
role: "assistant",
|
|
331
|
+
content: "",
|
|
332
|
+
toolCalls: [
|
|
333
|
+
{
|
|
334
|
+
id: "tc-1",
|
|
335
|
+
type: "function",
|
|
336
|
+
function: { name: "captureData", arguments: "{}" },
|
|
337
|
+
},
|
|
338
|
+
],
|
|
339
|
+
} as AssistantMessage,
|
|
340
|
+
{
|
|
341
|
+
id: "assistant-1",
|
|
342
|
+
role: "assistant",
|
|
343
|
+
content: "Done.",
|
|
344
|
+
toolCalls: [],
|
|
345
|
+
} as AssistantMessage,
|
|
346
|
+
];
|
|
347
|
+
|
|
348
|
+
const Host = defineComponent({
|
|
349
|
+
components: {
|
|
350
|
+
CopilotKitProvider,
|
|
351
|
+
CopilotChatConfigurationProvider,
|
|
352
|
+
CopilotChatMessageView,
|
|
353
|
+
},
|
|
354
|
+
setup() {
|
|
355
|
+
return { messages, agentId, threadId };
|
|
356
|
+
},
|
|
357
|
+
template: `
|
|
358
|
+
<CopilotKitProvider runtime-url="/api/copilotkit">
|
|
359
|
+
<CopilotChatConfigurationProvider :agent-id="agentId" :thread-id="threadId">
|
|
360
|
+
<CopilotChatMessageView :messages="messages">
|
|
361
|
+
<template #assistant-message="{ message }">
|
|
362
|
+
<div data-testid="assistant-tool-calls-count">{{ message.toolCalls?.length ?? 0 }}</div>
|
|
363
|
+
</template>
|
|
364
|
+
</CopilotChatMessageView>
|
|
365
|
+
</CopilotChatConfigurationProvider>
|
|
366
|
+
</CopilotKitProvider>
|
|
367
|
+
`,
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
render(Host);
|
|
371
|
+
|
|
372
|
+
expect(screen.getByTestId("assistant-tool-calls-count").textContent).toBe(
|
|
373
|
+
"0",
|
|
374
|
+
);
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
it("handles undefined content on both occurrences", () => {
|
|
378
|
+
const messages: Message[] = [
|
|
379
|
+
{
|
|
380
|
+
id: "assistant-1",
|
|
381
|
+
role: "assistant",
|
|
382
|
+
content: undefined,
|
|
383
|
+
} as AssistantMessage,
|
|
384
|
+
{
|
|
385
|
+
id: "assistant-1",
|
|
386
|
+
role: "assistant",
|
|
387
|
+
content: undefined,
|
|
388
|
+
} as AssistantMessage,
|
|
389
|
+
];
|
|
390
|
+
|
|
391
|
+
const Host = defineComponent({
|
|
392
|
+
components: {
|
|
393
|
+
CopilotKitProvider,
|
|
394
|
+
CopilotChatConfigurationProvider,
|
|
395
|
+
CopilotChatMessageView,
|
|
396
|
+
},
|
|
397
|
+
setup() {
|
|
398
|
+
return { messages, agentId, threadId };
|
|
399
|
+
},
|
|
400
|
+
template: `
|
|
401
|
+
<CopilotKitProvider runtime-url="/api/copilotkit">
|
|
402
|
+
<CopilotChatConfigurationProvider :agent-id="agentId" :thread-id="threadId">
|
|
403
|
+
<CopilotChatMessageView :messages="messages">
|
|
404
|
+
<template #assistant-message="{ message }">
|
|
405
|
+
<div data-testid="assistant-content">{{ message.content }}</div>
|
|
406
|
+
</template>
|
|
407
|
+
</CopilotChatMessageView>
|
|
408
|
+
</CopilotChatConfigurationProvider>
|
|
409
|
+
</CopilotKitProvider>
|
|
410
|
+
`,
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
render(Host);
|
|
414
|
+
|
|
415
|
+
expect(screen.getByTestId("assistant-content").textContent).toBe("");
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
it("keeps last entry for non-assistant roles", () => {
|
|
419
|
+
const messages: Message[] = [
|
|
420
|
+
{
|
|
421
|
+
id: "user-1",
|
|
422
|
+
role: "user",
|
|
423
|
+
content: "Hello",
|
|
424
|
+
} as UserMessage,
|
|
425
|
+
{
|
|
426
|
+
id: "user-1",
|
|
427
|
+
role: "user",
|
|
428
|
+
content: "Hello (updated)",
|
|
429
|
+
} as UserMessage,
|
|
430
|
+
];
|
|
431
|
+
|
|
432
|
+
const Host = defineComponent({
|
|
433
|
+
components: {
|
|
434
|
+
CopilotKitProvider,
|
|
435
|
+
CopilotChatConfigurationProvider,
|
|
436
|
+
CopilotChatMessageView,
|
|
437
|
+
},
|
|
438
|
+
setup() {
|
|
439
|
+
return { messages, agentId, threadId };
|
|
440
|
+
},
|
|
441
|
+
template: `
|
|
442
|
+
<CopilotKitProvider runtime-url="/api/copilotkit">
|
|
443
|
+
<CopilotChatConfigurationProvider :agent-id="agentId" :thread-id="threadId">
|
|
444
|
+
<CopilotChatMessageView :messages="messages">
|
|
445
|
+
<template #user-message="{ message }">
|
|
446
|
+
<div data-testid="user-content">{{ message.content }}</div>
|
|
447
|
+
</template>
|
|
448
|
+
</CopilotChatMessageView>
|
|
449
|
+
</CopilotChatConfigurationProvider>
|
|
450
|
+
</CopilotKitProvider>
|
|
451
|
+
`,
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
render(Host);
|
|
455
|
+
|
|
456
|
+
expect(screen.getByTestId("user-content").textContent).toBe(
|
|
457
|
+
"Hello (updated)",
|
|
458
|
+
);
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
it("preserves order of unique messages", () => {
|
|
462
|
+
const messages: Message[] = [
|
|
463
|
+
{
|
|
464
|
+
id: "user-1",
|
|
465
|
+
role: "user",
|
|
466
|
+
content: "First question",
|
|
467
|
+
} as UserMessage,
|
|
468
|
+
{
|
|
469
|
+
id: "assistant-1",
|
|
470
|
+
role: "assistant",
|
|
471
|
+
content: "First answer",
|
|
472
|
+
} as AssistantMessage,
|
|
473
|
+
{
|
|
474
|
+
id: "user-2",
|
|
475
|
+
role: "user",
|
|
476
|
+
content: "Second question",
|
|
477
|
+
} as UserMessage,
|
|
478
|
+
{
|
|
479
|
+
id: "assistant-2",
|
|
480
|
+
role: "assistant",
|
|
481
|
+
content: "Second answer",
|
|
482
|
+
} as AssistantMessage,
|
|
483
|
+
];
|
|
484
|
+
|
|
485
|
+
renderMessageView({ messages });
|
|
486
|
+
|
|
487
|
+
const userMessages = screen.getAllByTestId("copilot-user-message");
|
|
488
|
+
const assistantMessages = screen.getAllByTestId(
|
|
489
|
+
"copilot-assistant-message",
|
|
490
|
+
);
|
|
491
|
+
expect(userMessages).toHaveLength(2);
|
|
492
|
+
expect(assistantMessages).toHaveLength(2);
|
|
493
|
+
});
|
|
494
|
+
});
|