@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,603 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
|
2
|
+
import { mount } from "@vue/test-utils";
|
|
3
|
+
import { defineComponent, h, nextTick, ref, watchEffect } from "vue";
|
|
4
|
+
import type {
|
|
5
|
+
CopilotKitCoreSubscriber,
|
|
6
|
+
FrontendToolHandlerContext,
|
|
7
|
+
} from "@copilotkit/core";
|
|
8
|
+
import { CopilotKitCoreRuntimeConnectionStatus } from "@copilotkit/core";
|
|
9
|
+
import { defineWebInspector } from "@copilotkit/web-inspector";
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
import CopilotKitProvider from "../CopilotKitProvider.vue";
|
|
12
|
+
import { useCopilotKit } from "../useCopilotKit";
|
|
13
|
+
import type { VueFrontendTool } from "../../types";
|
|
14
|
+
import type { VueHumanInTheLoop } from "../../types";
|
|
15
|
+
import { mountWithProvider } from "../../__tests__/utils/mount";
|
|
16
|
+
import { StateCapturingAgent } from "../../__tests__/utils/agents";
|
|
17
|
+
|
|
18
|
+
type CopilotKitCoreContextValue = ReturnType<
|
|
19
|
+
typeof useCopilotKit
|
|
20
|
+
>["copilotkit"]["value"];
|
|
21
|
+
|
|
22
|
+
interface CopilotKitCoreTestAccess {
|
|
23
|
+
notifySubscribers: (
|
|
24
|
+
handler: (subscriber: CopilotKitCoreSubscriber) => void | Promise<void>,
|
|
25
|
+
errorMessage: string,
|
|
26
|
+
) => Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
describe("CopilotKitProvider", () => {
|
|
30
|
+
let consoleErrorSpy: ReturnType<typeof vi.spyOn>;
|
|
31
|
+
let consoleWarnSpy: ReturnType<typeof vi.spyOn>;
|
|
32
|
+
|
|
33
|
+
beforeEach(() => {
|
|
34
|
+
consoleErrorSpy = vi.spyOn(console, "error").mockImplementation(() => {});
|
|
35
|
+
consoleWarnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
|
|
36
|
+
vi.mocked(defineWebInspector).mockClear();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
afterEach(() => {
|
|
40
|
+
consoleErrorSpy.mockRestore();
|
|
41
|
+
consoleWarnSpy.mockRestore();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
describe("Basic functionality", () => {
|
|
45
|
+
it("provides context to children", () => {
|
|
46
|
+
const Child = defineComponent({
|
|
47
|
+
setup() {
|
|
48
|
+
const { copilotkit } = useCopilotKit();
|
|
49
|
+
return () =>
|
|
50
|
+
h(
|
|
51
|
+
"span",
|
|
52
|
+
{ "data-testid": "has-copilotkit" },
|
|
53
|
+
copilotkit.value ? "yes" : "no",
|
|
54
|
+
);
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const wrapper = mount(CopilotKitProvider, {
|
|
59
|
+
props: { runtimeUrl: "/api/copilotkit" },
|
|
60
|
+
slots: { default: () => h(Child) },
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
expect(wrapper.find("[data-testid=has-copilotkit]").text()).toBe("yes");
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("throws when useCopilotKit used outside provider", () => {
|
|
67
|
+
const OutOfContext = defineComponent({
|
|
68
|
+
setup() {
|
|
69
|
+
useCopilotKit();
|
|
70
|
+
return () => h("div");
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
expect(() => mount(OutOfContext)).toThrow(
|
|
74
|
+
"useCopilotKit must be used within CopilotKitProvider",
|
|
75
|
+
);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("warns when runtime props transition from valid to invalid", async () => {
|
|
79
|
+
const wrapper = mount(CopilotKitProvider, {
|
|
80
|
+
props: { runtimeUrl: "/api/copilotkit" },
|
|
81
|
+
slots: { default: () => h("div", "test") },
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
await wrapper.setProps({ runtimeUrl: undefined });
|
|
85
|
+
await nextTick();
|
|
86
|
+
|
|
87
|
+
expect(consoleWarnSpy).toHaveBeenCalledWith(
|
|
88
|
+
expect.stringContaining(
|
|
89
|
+
"Missing required prop: 'runtimeUrl' or 'publicApiKey' or 'publicLicenseKey'",
|
|
90
|
+
),
|
|
91
|
+
);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it("supports function-valued headers and refreshes runtime headers", async () => {
|
|
95
|
+
const authToken = ref("initial");
|
|
96
|
+
const { getCore } = mountWithProvider(() => h("div"), {
|
|
97
|
+
runtimeUrl: "/api/copilotkit",
|
|
98
|
+
headers: () => ({
|
|
99
|
+
Authorization: `Bearer ${authToken.value}`,
|
|
100
|
+
}),
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
expect(getCore().headers).toMatchObject({
|
|
104
|
+
Authorization: "Bearer initial",
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
authToken.value = "updated";
|
|
108
|
+
await nextTick();
|
|
109
|
+
await nextTick();
|
|
110
|
+
|
|
111
|
+
expect(getCore().headers).toMatchObject({
|
|
112
|
+
Authorization: "Bearer updated",
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it("does not multiply runtime invalidations across multiple useCopilotKit consumers", async () => {
|
|
117
|
+
const mockAgent = new StateCapturingAgent([], "default");
|
|
118
|
+
let coreRef: CopilotKitCoreContextValue | null = null;
|
|
119
|
+
|
|
120
|
+
const Probe = defineComponent({
|
|
121
|
+
setup() {
|
|
122
|
+
const { copilotkit } = useCopilotKit();
|
|
123
|
+
coreRef = copilotkit.value;
|
|
124
|
+
return () => null;
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
const Consumer = defineComponent({
|
|
129
|
+
props: {
|
|
130
|
+
testId: {
|
|
131
|
+
type: String,
|
|
132
|
+
required: true,
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
setup(props) {
|
|
136
|
+
const { copilotkit } = useCopilotKit();
|
|
137
|
+
const count = ref(0);
|
|
138
|
+
watchEffect(() => {
|
|
139
|
+
void copilotkit.value.runtimeConnectionStatus;
|
|
140
|
+
count.value += 1;
|
|
141
|
+
});
|
|
142
|
+
return () =>
|
|
143
|
+
h("span", { "data-testid": props.testId }, String(count.value));
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
const wrapper = mount(CopilotKitProvider, {
|
|
148
|
+
props: {
|
|
149
|
+
agents__unsafe_dev_only: { default: mockAgent },
|
|
150
|
+
},
|
|
151
|
+
slots: {
|
|
152
|
+
default: () =>
|
|
153
|
+
h("div", [
|
|
154
|
+
h(Consumer, { testId: "consumer-a" }),
|
|
155
|
+
h(Consumer, { testId: "consumer-b" }),
|
|
156
|
+
h(Probe),
|
|
157
|
+
]),
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
await nextTick();
|
|
162
|
+
expect(wrapper.find("[data-testid=consumer-a]").text()).toBe("1");
|
|
163
|
+
expect(wrapper.find("[data-testid=consumer-b]").text()).toBe("1");
|
|
164
|
+
expect(coreRef).toBeTruthy();
|
|
165
|
+
if (!coreRef) {
|
|
166
|
+
throw new Error("CopilotKit core reference is missing");
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
await (coreRef as unknown as CopilotKitCoreTestAccess).notifySubscribers(
|
|
170
|
+
(subscriber) =>
|
|
171
|
+
subscriber.onRuntimeConnectionStatusChanged?.({
|
|
172
|
+
copilotkit: coreRef,
|
|
173
|
+
status: CopilotKitCoreRuntimeConnectionStatus.Connected,
|
|
174
|
+
}),
|
|
175
|
+
"test runtime event",
|
|
176
|
+
);
|
|
177
|
+
await nextTick();
|
|
178
|
+
|
|
179
|
+
expect(wrapper.find("[data-testid=consumer-a]").text()).toBe("2");
|
|
180
|
+
expect(wrapper.find("[data-testid=consumer-b]").text()).toBe("2");
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it("treats selfManagedAgents as local agents for runtime validation", () => {
|
|
184
|
+
const selfManagedAgent = new StateCapturingAgent([], "default");
|
|
185
|
+
|
|
186
|
+
mount(CopilotKitProvider, {
|
|
187
|
+
props: {
|
|
188
|
+
runtimeUrl: undefined,
|
|
189
|
+
selfManagedAgents: { default: selfManagedAgent },
|
|
190
|
+
},
|
|
191
|
+
slots: { default: () => h("div", "test") },
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
expect(consoleWarnSpy).not.toHaveBeenCalledWith(
|
|
195
|
+
expect.stringContaining(
|
|
196
|
+
"Missing required prop: 'runtimeUrl' or 'publicApiKey' or 'publicLicenseKey'",
|
|
197
|
+
),
|
|
198
|
+
);
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
it("registers selfManagedAgents with CopilotKitCore", () => {
|
|
202
|
+
const selfManagedAgent = new StateCapturingAgent([], "default");
|
|
203
|
+
selfManagedAgent.state = { source: "self-managed" };
|
|
204
|
+
|
|
205
|
+
const { getCore } = mountWithProvider(() => h("div"), {
|
|
206
|
+
runtimeUrl: undefined,
|
|
207
|
+
selfManagedAgents: { default: selfManagedAgent },
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
expect(getCore().getAgent("default")?.state).toEqual({
|
|
211
|
+
source: "self-managed",
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it("prefers selfManagedAgents over agents__unsafe_dev_only for the same id", () => {
|
|
216
|
+
const unsafeAgent = new StateCapturingAgent([], "shared");
|
|
217
|
+
const selfManagedAgent = new StateCapturingAgent([], "shared");
|
|
218
|
+
unsafeAgent.state = { source: "unsafe" };
|
|
219
|
+
selfManagedAgent.state = { source: "self-managed" };
|
|
220
|
+
|
|
221
|
+
const { getCore } = mountWithProvider(() => h("div"), {
|
|
222
|
+
agents__unsafe_dev_only: { shared: unsafeAgent },
|
|
223
|
+
selfManagedAgents: { shared: selfManagedAgent },
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
expect(getCore().getAgent("shared")?.state).toEqual({
|
|
227
|
+
source: "self-managed",
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
it("exposes a2ui theme through provider context", () => {
|
|
232
|
+
const Child = defineComponent({
|
|
233
|
+
setup() {
|
|
234
|
+
const { a2uiTheme } = useCopilotKit();
|
|
235
|
+
return () =>
|
|
236
|
+
h(
|
|
237
|
+
"span",
|
|
238
|
+
{ "data-testid": "a2ui-theme" },
|
|
239
|
+
String(
|
|
240
|
+
(a2uiTheme.value as { mode?: string } | undefined)?.mode ??
|
|
241
|
+
"missing",
|
|
242
|
+
),
|
|
243
|
+
);
|
|
244
|
+
},
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
const wrapper = mount(CopilotKitProvider, {
|
|
248
|
+
props: {
|
|
249
|
+
runtimeUrl: "/api/copilotkit",
|
|
250
|
+
a2ui: {
|
|
251
|
+
theme: { mode: "storybook" },
|
|
252
|
+
},
|
|
253
|
+
},
|
|
254
|
+
slots: { default: () => h(Child) },
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
expect(wrapper.find("[data-testid=a2ui-theme]").text()).toBe("storybook");
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
describe("frontendTools prop", () => {
|
|
262
|
+
it("registers frontend tools with CopilotKitCore", () => {
|
|
263
|
+
const mockHandler = vi.fn();
|
|
264
|
+
const frontendTools: VueFrontendTool[] = [
|
|
265
|
+
{
|
|
266
|
+
name: "testTool",
|
|
267
|
+
description: "A test tool",
|
|
268
|
+
parameters: z.object({ input: z.string() }),
|
|
269
|
+
handler: mockHandler,
|
|
270
|
+
},
|
|
271
|
+
];
|
|
272
|
+
|
|
273
|
+
const { getCore } = mountWithProvider(() => h("div"), { frontendTools });
|
|
274
|
+
const tool = getCore().getTool({ toolName: "testTool" });
|
|
275
|
+
expect(tool).toBeDefined();
|
|
276
|
+
expect(tool?.name).toBe("testTool");
|
|
277
|
+
expect(tool?.handler).toBe(mockHandler);
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
it("includes render components from frontend tools", () => {
|
|
281
|
+
const TestComponent = defineComponent({
|
|
282
|
+
setup() {
|
|
283
|
+
return () => h("div", "Test");
|
|
284
|
+
},
|
|
285
|
+
});
|
|
286
|
+
const frontendTools: VueFrontendTool[] = [
|
|
287
|
+
{
|
|
288
|
+
name: "renderTool",
|
|
289
|
+
description: "A tool with render",
|
|
290
|
+
parameters: z.object({ input: z.string() }),
|
|
291
|
+
render: TestComponent,
|
|
292
|
+
},
|
|
293
|
+
];
|
|
294
|
+
|
|
295
|
+
const { getCore } = mountWithProvider(() => h("div"), { frontendTools });
|
|
296
|
+
const renderTool = getCore().renderToolCalls.find(
|
|
297
|
+
(rc) => rc.name === "renderTool",
|
|
298
|
+
);
|
|
299
|
+
expect(renderTool).toBeDefined();
|
|
300
|
+
expect(renderTool?.render).toStrictEqual(TestComponent);
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
it("does not scope frontendTools-derived render entries by agentId", () => {
|
|
304
|
+
const TestComponent = defineComponent({
|
|
305
|
+
setup() {
|
|
306
|
+
return () => h("div", "Test");
|
|
307
|
+
},
|
|
308
|
+
});
|
|
309
|
+
const frontendTools: VueFrontendTool[] = [
|
|
310
|
+
{
|
|
311
|
+
name: "agentRenderTool",
|
|
312
|
+
description: "A tool with render and agentId",
|
|
313
|
+
parameters: z.object({ input: z.string() }),
|
|
314
|
+
render: TestComponent,
|
|
315
|
+
agentId: "specific-agent",
|
|
316
|
+
},
|
|
317
|
+
];
|
|
318
|
+
|
|
319
|
+
const { getCore } = mountWithProvider(() => h("div"), { frontendTools });
|
|
320
|
+
const renderTool = getCore().renderToolCalls.find(
|
|
321
|
+
(rc) => rc.name === "agentRenderTool",
|
|
322
|
+
);
|
|
323
|
+
|
|
324
|
+
expect(renderTool).toBeDefined();
|
|
325
|
+
expect(renderTool?.agentId).toBeUndefined();
|
|
326
|
+
});
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
describe("humanInTheLoop prop", () => {
|
|
330
|
+
it("processes humanInTheLoop tools and creates handlers", () => {
|
|
331
|
+
const TestComponent = defineComponent({
|
|
332
|
+
setup() {
|
|
333
|
+
return () => h("div", "Test");
|
|
334
|
+
},
|
|
335
|
+
});
|
|
336
|
+
const humanInTheLoop: VueHumanInTheLoop[] = [
|
|
337
|
+
{
|
|
338
|
+
name: "approvalTool",
|
|
339
|
+
description: "Requires human approval",
|
|
340
|
+
parameters: z.object({ question: z.string() }),
|
|
341
|
+
render: TestComponent,
|
|
342
|
+
},
|
|
343
|
+
];
|
|
344
|
+
|
|
345
|
+
const { getCore } = mountWithProvider(() => h("div"), { humanInTheLoop });
|
|
346
|
+
const tool = getCore().getTool({ toolName: "approvalTool" });
|
|
347
|
+
expect(tool).toBeDefined();
|
|
348
|
+
expect(tool?.handler).toBeDefined();
|
|
349
|
+
|
|
350
|
+
const renderTool = getCore().renderToolCalls.find(
|
|
351
|
+
(rc) => rc.name === "approvalTool",
|
|
352
|
+
);
|
|
353
|
+
expect(renderTool).toBeDefined();
|
|
354
|
+
expect(renderTool?.render).toStrictEqual(TestComponent);
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
it("creates placeholder handlers for humanInTheLoop tools", async () => {
|
|
358
|
+
const TestComponent = defineComponent({
|
|
359
|
+
setup() {
|
|
360
|
+
return () => h("div", "Test");
|
|
361
|
+
},
|
|
362
|
+
});
|
|
363
|
+
const humanInTheLoop: VueHumanInTheLoop[] = [
|
|
364
|
+
{
|
|
365
|
+
name: "interactiveTool",
|
|
366
|
+
description: "Interactive tool",
|
|
367
|
+
parameters: z.object({ data: z.string() }),
|
|
368
|
+
render: TestComponent,
|
|
369
|
+
},
|
|
370
|
+
];
|
|
371
|
+
|
|
372
|
+
const { getCore } = mountWithProvider(() => h("div"), { humanInTheLoop });
|
|
373
|
+
const handler = getCore().getTool({
|
|
374
|
+
toolName: "interactiveTool",
|
|
375
|
+
})?.handler;
|
|
376
|
+
expect(handler).toBeDefined();
|
|
377
|
+
|
|
378
|
+
const result = await handler!(
|
|
379
|
+
{ data: "test" },
|
|
380
|
+
{} as unknown as FrontendToolHandlerContext,
|
|
381
|
+
);
|
|
382
|
+
expect(result).toBeUndefined();
|
|
383
|
+
expect(consoleWarnSpy).toHaveBeenCalledWith(
|
|
384
|
+
expect.stringContaining(
|
|
385
|
+
"Human-in-the-loop tool 'interactiveTool' called",
|
|
386
|
+
),
|
|
387
|
+
);
|
|
388
|
+
});
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
describe("Combined tools functionality", () => {
|
|
392
|
+
it("registers both frontendTools and humanInTheLoop tools", () => {
|
|
393
|
+
const TestComponent = defineComponent({
|
|
394
|
+
setup() {
|
|
395
|
+
return () => h("div", "Test");
|
|
396
|
+
},
|
|
397
|
+
});
|
|
398
|
+
const frontendTools: VueFrontendTool[] = [
|
|
399
|
+
{
|
|
400
|
+
name: "frontendTool",
|
|
401
|
+
description: "Frontend tool",
|
|
402
|
+
handler: vi.fn(),
|
|
403
|
+
},
|
|
404
|
+
];
|
|
405
|
+
const humanInTheLoop: VueHumanInTheLoop[] = [
|
|
406
|
+
{ name: "humanTool", description: "Human tool", render: TestComponent },
|
|
407
|
+
];
|
|
408
|
+
|
|
409
|
+
const { getCore } = mountWithProvider(() => h("div"), {
|
|
410
|
+
frontendTools,
|
|
411
|
+
humanInTheLoop,
|
|
412
|
+
});
|
|
413
|
+
expect(getCore().getTool({ toolName: "frontendTool" })).toBeDefined();
|
|
414
|
+
expect(getCore().getTool({ toolName: "humanTool" })).toBeDefined();
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
it("handles agentId in frontend tools", () => {
|
|
418
|
+
const frontendTools: VueFrontendTool[] = [
|
|
419
|
+
{
|
|
420
|
+
name: "globalTool",
|
|
421
|
+
description: "Global tool",
|
|
422
|
+
handler: vi.fn(),
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
name: "agentSpecificTool",
|
|
426
|
+
description: "Agent specific tool",
|
|
427
|
+
handler: vi.fn(),
|
|
428
|
+
agentId: "specificAgent",
|
|
429
|
+
},
|
|
430
|
+
];
|
|
431
|
+
|
|
432
|
+
const { getCore } = mountWithProvider(() => h("div"), { frontendTools });
|
|
433
|
+
const globalTool = getCore().getTool({ toolName: "globalTool" });
|
|
434
|
+
const agentTool = getCore().getTool({
|
|
435
|
+
toolName: "agentSpecificTool",
|
|
436
|
+
agentId: "specificAgent",
|
|
437
|
+
});
|
|
438
|
+
|
|
439
|
+
expect(globalTool).toBeDefined();
|
|
440
|
+
expect(globalTool?.agentId).toBeUndefined();
|
|
441
|
+
expect(agentTool).toBeDefined();
|
|
442
|
+
expect(agentTool?.agentId).toBe("specificAgent");
|
|
443
|
+
});
|
|
444
|
+
|
|
445
|
+
it("combines render components from all sources", () => {
|
|
446
|
+
const TestComponent1 = defineComponent({
|
|
447
|
+
setup() {
|
|
448
|
+
return () => h("div", "Test1");
|
|
449
|
+
},
|
|
450
|
+
});
|
|
451
|
+
const TestComponent2 = defineComponent({
|
|
452
|
+
setup() {
|
|
453
|
+
return () => h("div", "Test2");
|
|
454
|
+
},
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
const frontendTools: VueFrontendTool[] = [
|
|
458
|
+
{
|
|
459
|
+
name: "frontendRenderTool",
|
|
460
|
+
description: "Frontend render tool",
|
|
461
|
+
parameters: z.object({ a: z.string() }),
|
|
462
|
+
render: TestComponent1,
|
|
463
|
+
},
|
|
464
|
+
];
|
|
465
|
+
const humanInTheLoop: VueHumanInTheLoop[] = [
|
|
466
|
+
{
|
|
467
|
+
name: "humanRenderTool",
|
|
468
|
+
description: "Human render tool",
|
|
469
|
+
parameters: z.object({ b: z.string() }),
|
|
470
|
+
render: TestComponent2,
|
|
471
|
+
},
|
|
472
|
+
];
|
|
473
|
+
|
|
474
|
+
const { getCore } = mountWithProvider(() => h("div"), {
|
|
475
|
+
frontendTools,
|
|
476
|
+
humanInTheLoop,
|
|
477
|
+
});
|
|
478
|
+
|
|
479
|
+
const frontendRenderTool = getCore().renderToolCalls.find(
|
|
480
|
+
(rc) => rc.name === "frontendRenderTool",
|
|
481
|
+
);
|
|
482
|
+
const humanRenderTool = getCore().renderToolCalls.find(
|
|
483
|
+
(rc) => rc.name === "humanRenderTool",
|
|
484
|
+
);
|
|
485
|
+
|
|
486
|
+
expect(frontendRenderTool).toBeDefined();
|
|
487
|
+
expect(humanRenderTool).toBeDefined();
|
|
488
|
+
expect(frontendRenderTool?.render).toStrictEqual(TestComponent1);
|
|
489
|
+
expect(humanRenderTool?.render).toStrictEqual(TestComponent2);
|
|
490
|
+
});
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
describe("Edge cases", () => {
|
|
494
|
+
it("handles empty arrays for tools", () => {
|
|
495
|
+
const { getCore } = mountWithProvider(() => h("div"), {
|
|
496
|
+
frontendTools: [],
|
|
497
|
+
humanInTheLoop: [],
|
|
498
|
+
});
|
|
499
|
+
|
|
500
|
+
expect(getCore().tools).toHaveLength(0);
|
|
501
|
+
expect(getCore().renderToolCalls).toHaveLength(0);
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
it("handles tools without render components", () => {
|
|
505
|
+
const frontendTools: VueFrontendTool[] = [
|
|
506
|
+
{
|
|
507
|
+
name: "noRenderTool",
|
|
508
|
+
description: "Tool without render",
|
|
509
|
+
handler: vi.fn(),
|
|
510
|
+
},
|
|
511
|
+
];
|
|
512
|
+
|
|
513
|
+
const { getCore } = mountWithProvider(() => h("div"), { frontendTools });
|
|
514
|
+
expect(getCore().getTool({ toolName: "noRenderTool" })).toBeDefined();
|
|
515
|
+
const noRenderTool = getCore().renderToolCalls.find(
|
|
516
|
+
(rc) => rc.name === "noRenderTool",
|
|
517
|
+
);
|
|
518
|
+
expect(noRenderTool).toBeUndefined();
|
|
519
|
+
});
|
|
520
|
+
|
|
521
|
+
it("handles humanInTheLoop tools with followUp flag", () => {
|
|
522
|
+
const TestComponent = defineComponent({
|
|
523
|
+
setup() {
|
|
524
|
+
return () => h("div", "Test");
|
|
525
|
+
},
|
|
526
|
+
});
|
|
527
|
+
const humanInTheLoop: VueHumanInTheLoop[] = [
|
|
528
|
+
{
|
|
529
|
+
name: "followUpTool",
|
|
530
|
+
description: "Tool with followUp",
|
|
531
|
+
parameters: z.object({ a: z.string() }),
|
|
532
|
+
followUp: false,
|
|
533
|
+
render: TestComponent,
|
|
534
|
+
},
|
|
535
|
+
];
|
|
536
|
+
|
|
537
|
+
const { getCore } = mountWithProvider(() => h("div"), { humanInTheLoop });
|
|
538
|
+
const tool = getCore().getTool({ toolName: "followUpTool" });
|
|
539
|
+
expect(tool?.followUp).toBe(false);
|
|
540
|
+
});
|
|
541
|
+
|
|
542
|
+
it("renders inspector when showDevConsole is true", async () => {
|
|
543
|
+
const wrapper = mount(CopilotKitProvider, {
|
|
544
|
+
props: {
|
|
545
|
+
runtimeUrl: "/api/copilotkit",
|
|
546
|
+
showDevConsole: true,
|
|
547
|
+
},
|
|
548
|
+
slots: {
|
|
549
|
+
default: () => h("div", "test"),
|
|
550
|
+
},
|
|
551
|
+
});
|
|
552
|
+
|
|
553
|
+
await nextTick();
|
|
554
|
+
await vi.dynamicImportSettled();
|
|
555
|
+
await nextTick();
|
|
556
|
+
|
|
557
|
+
expect(wrapper.find("cpk-web-inspector").exists()).toBe(true);
|
|
558
|
+
expect(defineWebInspector).toHaveBeenCalledTimes(1);
|
|
559
|
+
});
|
|
560
|
+
|
|
561
|
+
it("renders inspector on localhost when showDevConsole is auto", async () => {
|
|
562
|
+
const wrapper = mount(CopilotKitProvider, {
|
|
563
|
+
props: {
|
|
564
|
+
runtimeUrl: "/api/copilotkit",
|
|
565
|
+
showDevConsole: "auto",
|
|
566
|
+
},
|
|
567
|
+
slots: {
|
|
568
|
+
default: () => h("div", "test"),
|
|
569
|
+
},
|
|
570
|
+
});
|
|
571
|
+
|
|
572
|
+
await nextTick();
|
|
573
|
+
await vi.dynamicImportSettled();
|
|
574
|
+
await nextTick();
|
|
575
|
+
|
|
576
|
+
const shouldRenderOnThisHost = new Set(["localhost", "127.0.0.1"]).has(
|
|
577
|
+
window.location.hostname,
|
|
578
|
+
);
|
|
579
|
+
|
|
580
|
+
expect(wrapper.find("cpk-web-inspector").exists()).toBe(
|
|
581
|
+
shouldRenderOnThisHost,
|
|
582
|
+
);
|
|
583
|
+
});
|
|
584
|
+
|
|
585
|
+
it("does not render inspector when showDevConsole is false", async () => {
|
|
586
|
+
const wrapper = mount(CopilotKitProvider, {
|
|
587
|
+
props: {
|
|
588
|
+
runtimeUrl: "/api/copilotkit",
|
|
589
|
+
showDevConsole: false,
|
|
590
|
+
},
|
|
591
|
+
slots: {
|
|
592
|
+
default: () => h("div", "test"),
|
|
593
|
+
},
|
|
594
|
+
});
|
|
595
|
+
|
|
596
|
+
await nextTick();
|
|
597
|
+
await vi.dynamicImportSettled();
|
|
598
|
+
await nextTick();
|
|
599
|
+
|
|
600
|
+
expect(wrapper.find("cpk-web-inspector").exists()).toBe(false);
|
|
601
|
+
});
|
|
602
|
+
});
|
|
603
|
+
});
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from "vitest";
|
|
2
|
+
import { defineComponent, h } from "vue";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import type { VueFrontendTool, VueHumanInTheLoop } from "../../types";
|
|
5
|
+
import { mountWithProvider } from "../../__tests__/utils/mount";
|
|
6
|
+
|
|
7
|
+
describe("CopilotKitProvider wildcard behavior", () => {
|
|
8
|
+
it("registers wildcard frontend tool", () => {
|
|
9
|
+
const wildcardHandler = vi.fn();
|
|
10
|
+
const frontendTools: VueFrontendTool[] = [
|
|
11
|
+
{
|
|
12
|
+
name: "*",
|
|
13
|
+
description: "Fallback tool",
|
|
14
|
+
handler: wildcardHandler,
|
|
15
|
+
},
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
const { getCore } = mountWithProvider(() => h("div"), { frontendTools });
|
|
19
|
+
const retrievedTool = getCore().getTool({ toolName: "*" });
|
|
20
|
+
|
|
21
|
+
expect(retrievedTool).toBeDefined();
|
|
22
|
+
expect(retrievedTool?.name).toBe("*");
|
|
23
|
+
expect(retrievedTool?.handler).toBe(wildcardHandler);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("registers wildcard alongside specific tool", () => {
|
|
27
|
+
const frontendTools: VueFrontendTool[] = [
|
|
28
|
+
{ name: "specific", handler: vi.fn() },
|
|
29
|
+
{ name: "*", handler: vi.fn() },
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
const { getCore } = mountWithProvider(() => h("div"), { frontendTools });
|
|
33
|
+
|
|
34
|
+
expect(getCore().getTool({ toolName: "specific" })).toBeDefined();
|
|
35
|
+
expect(getCore().getTool({ toolName: "*" })).toBeDefined();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("registers wildcard with render in renderToolCalls", () => {
|
|
39
|
+
const WildcardRender = defineComponent({
|
|
40
|
+
setup() {
|
|
41
|
+
return () => h("div", "Wildcard");
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const frontendTools: VueFrontendTool[] = [
|
|
46
|
+
{
|
|
47
|
+
name: "*",
|
|
48
|
+
description: "Fallback with render",
|
|
49
|
+
parameters: z.object({ toolName: z.string(), args: z.unknown() }),
|
|
50
|
+
render: WildcardRender,
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
const { getCore } = mountWithProvider(() => h("div"), { frontendTools });
|
|
55
|
+
const wildcardRender = getCore().renderToolCalls.find(
|
|
56
|
+
(rc) => rc.name === "*",
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
expect(wildcardRender).toBeDefined();
|
|
60
|
+
expect(wildcardRender?.render).toStrictEqual(WildcardRender);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("supports wildcard with agentId", () => {
|
|
64
|
+
const frontendTools: VueFrontendTool[] = [
|
|
65
|
+
{
|
|
66
|
+
name: "*",
|
|
67
|
+
handler: vi.fn(),
|
|
68
|
+
agentId: "agent-1",
|
|
69
|
+
},
|
|
70
|
+
];
|
|
71
|
+
|
|
72
|
+
const { getCore } = mountWithProvider(() => h("div"), { frontendTools });
|
|
73
|
+
const wildcard = getCore().getTool({ toolName: "*", agentId: "agent-1" });
|
|
74
|
+
|
|
75
|
+
expect(wildcard).toBeDefined();
|
|
76
|
+
expect(wildcard?.agentId).toBe("agent-1");
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("supports wildcard in humanInTheLoop", () => {
|
|
80
|
+
const WildcardComponent = defineComponent({
|
|
81
|
+
setup() {
|
|
82
|
+
return () => h("div", "Wildcard HITL");
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const humanInTheLoop: VueHumanInTheLoop[] = [
|
|
87
|
+
{
|
|
88
|
+
name: "*",
|
|
89
|
+
description: "Fallback interaction",
|
|
90
|
+
parameters: z.object({ toolName: z.string(), args: z.unknown() }),
|
|
91
|
+
render: WildcardComponent,
|
|
92
|
+
},
|
|
93
|
+
];
|
|
94
|
+
|
|
95
|
+
const { getCore } = mountWithProvider(() => h("div"), { humanInTheLoop });
|
|
96
|
+
|
|
97
|
+
expect(getCore().getTool({ toolName: "*" })).toBeDefined();
|
|
98
|
+
const wildcardRender = getCore().renderToolCalls.find(
|
|
99
|
+
(rc) => rc.name === "*",
|
|
100
|
+
);
|
|
101
|
+
expect(wildcardRender).toBeDefined();
|
|
102
|
+
expect(wildcardRender?.render).toStrictEqual(WildcardComponent);
|
|
103
|
+
});
|
|
104
|
+
});
|