@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,282 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
|
+
import { defineComponent, h, nextTick, ref } from "vue";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import type { AbstractAgent } from "@ag-ui/client";
|
|
5
|
+
import { useHumanInTheLoop } from "../use-human-in-the-loop";
|
|
6
|
+
import { mountWithProvider } from "../../__tests__/utils/mount";
|
|
7
|
+
import { StateCapturingAgent } from "../../__tests__/utils/agents";
|
|
8
|
+
|
|
9
|
+
describe("useHumanInTheLoop", () => {
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
console.warn = vi.fn();
|
|
12
|
+
console.error = vi.fn();
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("resolves handler promise only via respond", async () => {
|
|
16
|
+
const RenderComp = defineComponent({
|
|
17
|
+
props: ["status", "respond"],
|
|
18
|
+
setup() {
|
|
19
|
+
return () => h("div");
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const tool = {
|
|
24
|
+
name: "approveTool",
|
|
25
|
+
description: "Approve",
|
|
26
|
+
parameters: z.object({ question: z.string() }),
|
|
27
|
+
render: RenderComp,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const Child = defineComponent({
|
|
31
|
+
setup() {
|
|
32
|
+
useHumanInTheLoop(tool);
|
|
33
|
+
return () => null;
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const { getCore } = mountWithProvider(() => h(Child), {
|
|
38
|
+
agents__unsafe_dev_only: {
|
|
39
|
+
"test-agent": new StateCapturingAgent(
|
|
40
|
+
[],
|
|
41
|
+
"test-agent",
|
|
42
|
+
) as unknown as AbstractAgent,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const registeredTool = getCore().getTool({ toolName: "approveTool" });
|
|
47
|
+
const renderer = getCore().renderToolCalls.find(
|
|
48
|
+
(rc) => rc.name === "approveTool",
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
expect(registeredTool?.handler).toBeDefined();
|
|
52
|
+
expect(renderer).toBeDefined();
|
|
53
|
+
|
|
54
|
+
const pending = registeredTool!.handler!(
|
|
55
|
+
{ question: "Proceed?" },
|
|
56
|
+
{} as never,
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
const executingVNode = renderer!.render({
|
|
60
|
+
name: "approveTool",
|
|
61
|
+
args: { question: "Proceed?" },
|
|
62
|
+
status: "executing",
|
|
63
|
+
result: undefined,
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
const respond = (
|
|
67
|
+
executingVNode as { props?: { respond?: (result: unknown) => void } }
|
|
68
|
+
)?.props?.respond;
|
|
69
|
+
expect(typeof respond).toBe("function");
|
|
70
|
+
|
|
71
|
+
respond?.({ approved: true });
|
|
72
|
+
|
|
73
|
+
await expect(pending).resolves.toEqual({ approved: true });
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("keeps HITL registrations isolated", async () => {
|
|
77
|
+
const RenderComp = defineComponent({
|
|
78
|
+
props: ["respond"],
|
|
79
|
+
setup() {
|
|
80
|
+
return () => h("div");
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
const ToolA = {
|
|
85
|
+
name: "toolA",
|
|
86
|
+
parameters: z.object({}),
|
|
87
|
+
render: RenderComp,
|
|
88
|
+
};
|
|
89
|
+
const ToolB = {
|
|
90
|
+
name: "toolB",
|
|
91
|
+
parameters: z.object({}),
|
|
92
|
+
render: RenderComp,
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const Child = defineComponent({
|
|
96
|
+
setup() {
|
|
97
|
+
useHumanInTheLoop(ToolA);
|
|
98
|
+
useHumanInTheLoop(ToolB);
|
|
99
|
+
return () => null;
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
const { getCore } = mountWithProvider(() => h(Child));
|
|
104
|
+
const toolA = getCore().getTool({ toolName: "toolA" });
|
|
105
|
+
const toolB = getCore().getTool({ toolName: "toolB" });
|
|
106
|
+
const renderA = getCore().renderToolCalls.find((rc) => rc.name === "toolA");
|
|
107
|
+
const renderB = getCore().renderToolCalls.find((rc) => rc.name === "toolB");
|
|
108
|
+
|
|
109
|
+
const pA = toolA!.handler!({}, {} as never);
|
|
110
|
+
const pB = toolB!.handler!({}, {} as never);
|
|
111
|
+
|
|
112
|
+
const respondA = (
|
|
113
|
+
renderA!.render({
|
|
114
|
+
name: "toolA",
|
|
115
|
+
args: {},
|
|
116
|
+
status: "executing",
|
|
117
|
+
result: undefined,
|
|
118
|
+
}) as {
|
|
119
|
+
props?: { respond?: (result: unknown) => void };
|
|
120
|
+
}
|
|
121
|
+
).props?.respond;
|
|
122
|
+
const respondB = (
|
|
123
|
+
renderB!.render({
|
|
124
|
+
name: "toolB",
|
|
125
|
+
args: {},
|
|
126
|
+
status: "executing",
|
|
127
|
+
result: undefined,
|
|
128
|
+
}) as {
|
|
129
|
+
props?: { respond?: (result: unknown) => void };
|
|
130
|
+
}
|
|
131
|
+
).props?.respond;
|
|
132
|
+
|
|
133
|
+
respondA?.("A");
|
|
134
|
+
respondB?.("B");
|
|
135
|
+
|
|
136
|
+
await expect(pA).resolves.toBe("A");
|
|
137
|
+
await expect(pB).resolves.toBe("B");
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it("only exposes respond during executing status", () => {
|
|
141
|
+
const RenderComp = defineComponent({
|
|
142
|
+
props: ["respond"],
|
|
143
|
+
setup() {
|
|
144
|
+
return () => h("div");
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
const Child = defineComponent({
|
|
149
|
+
setup() {
|
|
150
|
+
useHumanInTheLoop({
|
|
151
|
+
name: "approveTool",
|
|
152
|
+
parameters: z.object({}),
|
|
153
|
+
render: RenderComp,
|
|
154
|
+
});
|
|
155
|
+
return () => null;
|
|
156
|
+
},
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
const { getCore } = mountWithProvider(() => h(Child));
|
|
160
|
+
const renderer = getCore().renderToolCalls.find(
|
|
161
|
+
(rc) => rc.name === "approveTool",
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
const inProgress = renderer!.render({
|
|
165
|
+
name: "approveTool",
|
|
166
|
+
args: {},
|
|
167
|
+
status: "inProgress",
|
|
168
|
+
result: undefined,
|
|
169
|
+
}) as {
|
|
170
|
+
props?: { respond?: unknown };
|
|
171
|
+
};
|
|
172
|
+
const executing = renderer!.render({
|
|
173
|
+
name: "approveTool",
|
|
174
|
+
args: {},
|
|
175
|
+
status: "executing",
|
|
176
|
+
result: undefined,
|
|
177
|
+
}) as {
|
|
178
|
+
props?: { respond?: unknown };
|
|
179
|
+
};
|
|
180
|
+
const complete = renderer!.render({
|
|
181
|
+
name: "approveTool",
|
|
182
|
+
args: {},
|
|
183
|
+
status: "complete",
|
|
184
|
+
result: "ok",
|
|
185
|
+
}) as {
|
|
186
|
+
props?: { respond?: unknown };
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
expect(inProgress.props?.respond).toBeUndefined();
|
|
190
|
+
expect(typeof executing.props?.respond).toBe("function");
|
|
191
|
+
expect(complete.props?.respond).toBeUndefined();
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it("cleans up tool and renderer on unmount", async () => {
|
|
195
|
+
const RenderComp = defineComponent({
|
|
196
|
+
setup() {
|
|
197
|
+
return () => h("div");
|
|
198
|
+
},
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
const Parent = defineComponent({
|
|
202
|
+
setup() {
|
|
203
|
+
const shown = ref(true);
|
|
204
|
+
return () =>
|
|
205
|
+
h("div", [
|
|
206
|
+
h(
|
|
207
|
+
"button",
|
|
208
|
+
{
|
|
209
|
+
"data-testid": "toggle",
|
|
210
|
+
onClick: () => (shown.value = !shown.value),
|
|
211
|
+
},
|
|
212
|
+
"toggle",
|
|
213
|
+
),
|
|
214
|
+
shown.value
|
|
215
|
+
? h(
|
|
216
|
+
defineComponent({
|
|
217
|
+
setup() {
|
|
218
|
+
useHumanInTheLoop({
|
|
219
|
+
name: "cleanupTool",
|
|
220
|
+
parameters: z.object({}),
|
|
221
|
+
render: RenderComp,
|
|
222
|
+
});
|
|
223
|
+
return () => null;
|
|
224
|
+
},
|
|
225
|
+
}),
|
|
226
|
+
)
|
|
227
|
+
: null,
|
|
228
|
+
]);
|
|
229
|
+
},
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
const { wrapper, getCore } = mountWithProvider(() => h(Parent));
|
|
233
|
+
await nextTick();
|
|
234
|
+
|
|
235
|
+
expect(getCore().getTool({ toolName: "cleanupTool" })).toBeDefined();
|
|
236
|
+
expect(
|
|
237
|
+
getCore().renderToolCalls.find((rc) => rc.name === "cleanupTool"),
|
|
238
|
+
).toBeDefined();
|
|
239
|
+
|
|
240
|
+
await wrapper.find("[data-testid=toggle]").trigger("click");
|
|
241
|
+
await nextTick();
|
|
242
|
+
|
|
243
|
+
expect(getCore().getTool({ toolName: "cleanupTool" })).toBeUndefined();
|
|
244
|
+
expect(
|
|
245
|
+
getCore().renderToolCalls.find((rc) => rc.name === "cleanupTool"),
|
|
246
|
+
).toBeUndefined();
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
it("re-registers when deps change", async () => {
|
|
250
|
+
const RenderComp = defineComponent({
|
|
251
|
+
setup() {
|
|
252
|
+
return () => h("div");
|
|
253
|
+
},
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
const version = ref(0);
|
|
257
|
+
const Child = defineComponent({
|
|
258
|
+
setup() {
|
|
259
|
+
useHumanInTheLoop(
|
|
260
|
+
{ name: "depHitl", parameters: z.object({}), render: RenderComp },
|
|
261
|
+
[version],
|
|
262
|
+
);
|
|
263
|
+
return () =>
|
|
264
|
+
h(
|
|
265
|
+
"button",
|
|
266
|
+
{ "data-testid": "bump", onClick: () => (version.value += 1) },
|
|
267
|
+
"bump",
|
|
268
|
+
);
|
|
269
|
+
},
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
const { wrapper, getCore } = mountWithProvider(() => h(Child));
|
|
273
|
+
const addToolSpy = vi.spyOn(getCore(), "addTool");
|
|
274
|
+
|
|
275
|
+
await wrapper.find("[data-testid=bump]").trigger("click");
|
|
276
|
+
await nextTick();
|
|
277
|
+
|
|
278
|
+
expect(addToolSpy).toHaveBeenCalled();
|
|
279
|
+
expect(getCore().getTool({ toolName: "depHitl" })).toBeDefined();
|
|
280
|
+
addToolSpy.mockRestore();
|
|
281
|
+
});
|
|
282
|
+
});
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
import { mount } from "@vue/test-utils";
|
|
2
|
+
import { computed, defineComponent, h, nextTick } from "vue";
|
|
3
|
+
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
4
|
+
import { useCopilotKit } from "../../providers/useCopilotKit";
|
|
5
|
+
import { useAgent } from "../use-agent";
|
|
6
|
+
import { useInterrupt } from "../use-interrupt";
|
|
7
|
+
|
|
8
|
+
vi.mock("../../providers/useCopilotKit", () => ({
|
|
9
|
+
useCopilotKit: vi.fn(),
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
vi.mock("../use-agent", () => ({
|
|
13
|
+
useAgent: vi.fn(),
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
const mockUseCopilotKit = useCopilotKit as ReturnType<typeof vi.fn>;
|
|
17
|
+
const mockUseAgent = useAgent as ReturnType<typeof vi.fn>;
|
|
18
|
+
|
|
19
|
+
type SubscriptionHandlers = {
|
|
20
|
+
onCustomEvent?: (payload: {
|
|
21
|
+
event: { name: string; value: unknown };
|
|
22
|
+
}) => void;
|
|
23
|
+
onRunStartedEvent?: () => void;
|
|
24
|
+
onRunFinalized?: () => void;
|
|
25
|
+
onRunFailed?: () => void;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
describe("useInterrupt", () => {
|
|
29
|
+
let runAgentMock: ReturnType<typeof vi.fn>;
|
|
30
|
+
let setInterruptStateMock: ReturnType<typeof vi.fn>;
|
|
31
|
+
let unsubscribeMock: ReturnType<typeof vi.fn>;
|
|
32
|
+
let subscribeMock: ReturnType<typeof vi.fn>;
|
|
33
|
+
let handlers: SubscriptionHandlers;
|
|
34
|
+
let mockAgent: Record<string, unknown>;
|
|
35
|
+
let coreState: {
|
|
36
|
+
runAgent: ReturnType<typeof vi.fn>;
|
|
37
|
+
setInterruptState: ReturnType<typeof vi.fn>;
|
|
38
|
+
interruptState: unknown;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
beforeEach(() => {
|
|
42
|
+
runAgentMock = vi.fn().mockResolvedValue(undefined);
|
|
43
|
+
unsubscribeMock = vi.fn();
|
|
44
|
+
handlers = {};
|
|
45
|
+
|
|
46
|
+
subscribeMock = vi.fn((nextHandlers: SubscriptionHandlers) => {
|
|
47
|
+
handlers = nextHandlers;
|
|
48
|
+
return { unsubscribe: unsubscribeMock };
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
mockAgent = {
|
|
52
|
+
subscribe: subscribeMock,
|
|
53
|
+
id: "test-agent",
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
coreState = {
|
|
57
|
+
runAgent: runAgentMock,
|
|
58
|
+
setInterruptState: vi.fn((value: unknown) => {
|
|
59
|
+
coreState.interruptState = value;
|
|
60
|
+
}),
|
|
61
|
+
interruptState: null,
|
|
62
|
+
};
|
|
63
|
+
setInterruptStateMock = coreState.setInterruptState;
|
|
64
|
+
|
|
65
|
+
mockUseCopilotKit.mockReturnValue({
|
|
66
|
+
copilotkit: {
|
|
67
|
+
value: coreState,
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
mockUseAgent.mockReturnValue({
|
|
72
|
+
agent: computed(() => mockAgent),
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
function mountHarness(
|
|
77
|
+
options: {
|
|
78
|
+
enabled?: (event: { name: string; value: unknown }) => boolean;
|
|
79
|
+
handler?: (props: {
|
|
80
|
+
event: { name: string; value: unknown };
|
|
81
|
+
resolve: (response: unknown) => void;
|
|
82
|
+
}) => unknown;
|
|
83
|
+
renderInChat?: boolean;
|
|
84
|
+
} = {},
|
|
85
|
+
) {
|
|
86
|
+
const Harness = defineComponent({
|
|
87
|
+
setup() {
|
|
88
|
+
const interrupt = useInterrupt({
|
|
89
|
+
enabled: options.enabled,
|
|
90
|
+
handler: options.handler,
|
|
91
|
+
renderInChat: options.renderInChat,
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
return () => {
|
|
95
|
+
const payload = interrupt.slotProps.value;
|
|
96
|
+
if (!payload) {
|
|
97
|
+
return h("div", { "data-testid": "interrupt-state" }, "idle");
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return h(
|
|
101
|
+
"button",
|
|
102
|
+
{
|
|
103
|
+
"data-testid": "interrupt-state",
|
|
104
|
+
onClick: () =>
|
|
105
|
+
payload.resolve({
|
|
106
|
+
approved: true,
|
|
107
|
+
value: payload.event.value,
|
|
108
|
+
}),
|
|
109
|
+
},
|
|
110
|
+
`${String(payload.result ?? "no-result")}:${String(payload.event.value)}`,
|
|
111
|
+
);
|
|
112
|
+
};
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
return mount(Harness);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function emitInterrupt(value: unknown) {
|
|
120
|
+
handlers.onCustomEvent?.({
|
|
121
|
+
event: { name: "on_interrupt", value },
|
|
122
|
+
});
|
|
123
|
+
handlers.onRunFinalized?.();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
it("subscribes on mount and unsubscribes on unmount", () => {
|
|
127
|
+
const wrapper = mountHarness({ renderInChat: false });
|
|
128
|
+
|
|
129
|
+
expect(subscribeMock).toHaveBeenCalledTimes(1);
|
|
130
|
+
expect(handlers.onCustomEvent).toBeTypeOf("function");
|
|
131
|
+
expect(handlers.onRunStartedEvent).toBeTypeOf("function");
|
|
132
|
+
expect(handlers.onRunFinalized).toBeTypeOf("function");
|
|
133
|
+
expect(handlers.onRunFailed).toBeTypeOf("function");
|
|
134
|
+
|
|
135
|
+
wrapper.unmount();
|
|
136
|
+
expect(unsubscribeMock).toHaveBeenCalledTimes(1);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it("ignores non-interrupt custom events", () => {
|
|
140
|
+
const wrapper = mountHarness({ renderInChat: false });
|
|
141
|
+
|
|
142
|
+
handlers.onCustomEvent?.({
|
|
143
|
+
event: { name: "not_interrupt", value: "x" },
|
|
144
|
+
});
|
|
145
|
+
handlers.onRunFinalized?.();
|
|
146
|
+
|
|
147
|
+
expect(wrapper.get("[data-testid=interrupt-state]").text()).toBe("idle");
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it("renders interrupt only after run finalized", async () => {
|
|
151
|
+
const wrapper = mountHarness({ renderInChat: false });
|
|
152
|
+
|
|
153
|
+
handlers.onCustomEvent?.({
|
|
154
|
+
event: { name: "on_interrupt", value: "pending" },
|
|
155
|
+
});
|
|
156
|
+
await nextTick();
|
|
157
|
+
expect(wrapper.get("[data-testid=interrupt-state]").text()).toBe("idle");
|
|
158
|
+
|
|
159
|
+
handlers.onRunFinalized?.();
|
|
160
|
+
await nextTick();
|
|
161
|
+
expect(wrapper.get("[data-testid=interrupt-state]").text()).toContain(
|
|
162
|
+
"pending",
|
|
163
|
+
);
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it("clears pending interrupt on run start", async () => {
|
|
167
|
+
const wrapper = mountHarness({ renderInChat: false });
|
|
168
|
+
|
|
169
|
+
emitInterrupt("first");
|
|
170
|
+
await nextTick();
|
|
171
|
+
expect(wrapper.get("[data-testid=interrupt-state]").text()).toContain(
|
|
172
|
+
"first",
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
handlers.onRunStartedEvent?.();
|
|
176
|
+
await nextTick();
|
|
177
|
+
expect(wrapper.get("[data-testid=interrupt-state]").text()).toBe("idle");
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it("resolve clears UI and resumes agent with response payload", async () => {
|
|
181
|
+
const wrapper = mountHarness({ renderInChat: false });
|
|
182
|
+
|
|
183
|
+
emitInterrupt("approve-me");
|
|
184
|
+
await nextTick();
|
|
185
|
+
await wrapper.get("[data-testid=interrupt-state]").trigger("click");
|
|
186
|
+
await nextTick();
|
|
187
|
+
|
|
188
|
+
expect(wrapper.get("[data-testid=interrupt-state]").text()).toBe("idle");
|
|
189
|
+
expect(runAgentMock).toHaveBeenCalledWith({
|
|
190
|
+
agent: mockAgent,
|
|
191
|
+
forwardedProps: {
|
|
192
|
+
command: {
|
|
193
|
+
resume: { approved: true, value: "approve-me" },
|
|
194
|
+
interruptEvent: "approve-me",
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
it("does not render and does not run handler when enabled returns false", async () => {
|
|
201
|
+
const handler = vi.fn(() => "should-not-run");
|
|
202
|
+
const wrapper = mountHarness({
|
|
203
|
+
renderInChat: false,
|
|
204
|
+
enabled: () => false,
|
|
205
|
+
handler,
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
emitInterrupt("blocked");
|
|
209
|
+
await nextTick();
|
|
210
|
+
|
|
211
|
+
expect(wrapper.get("[data-testid=interrupt-state]").text()).toBe("idle");
|
|
212
|
+
expect(handler).not.toHaveBeenCalled();
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it("renders with null result when no handler is provided", async () => {
|
|
216
|
+
const wrapper = mountHarness({ renderInChat: false });
|
|
217
|
+
|
|
218
|
+
emitInterrupt("no-handler");
|
|
219
|
+
await nextTick();
|
|
220
|
+
|
|
221
|
+
expect(wrapper.get("[data-testid=interrupt-state]").text()).toContain(
|
|
222
|
+
"no-result:no-handler",
|
|
223
|
+
);
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
it("uses sync handler result in render", async () => {
|
|
227
|
+
const wrapper = mountHarness({
|
|
228
|
+
renderInChat: false,
|
|
229
|
+
handler: ({ event }) => `handled:${String(event.value)}`,
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
emitInterrupt("sync");
|
|
233
|
+
await nextTick();
|
|
234
|
+
|
|
235
|
+
expect(wrapper.get("[data-testid=interrupt-state]").text()).toContain(
|
|
236
|
+
"handled:sync",
|
|
237
|
+
);
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
it("uses async handler resolved value in render", async () => {
|
|
241
|
+
const wrapper = mountHarness({
|
|
242
|
+
renderInChat: false,
|
|
243
|
+
handler: ({ event }) => Promise.resolve(`async:${String(event.value)}`),
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
emitInterrupt("value");
|
|
247
|
+
await Promise.resolve();
|
|
248
|
+
await Promise.resolve();
|
|
249
|
+
await nextTick();
|
|
250
|
+
|
|
251
|
+
expect(wrapper.get("[data-testid=interrupt-state]").text()).toContain(
|
|
252
|
+
"async:value",
|
|
253
|
+
);
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
it("falls back to null result when async handler rejects", async () => {
|
|
257
|
+
const wrapper = mountHarness({
|
|
258
|
+
renderInChat: false,
|
|
259
|
+
handler: () => Promise.reject(new Error("boom")),
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
emitInterrupt("reject");
|
|
263
|
+
await Promise.resolve();
|
|
264
|
+
await Promise.resolve();
|
|
265
|
+
await nextTick();
|
|
266
|
+
|
|
267
|
+
expect(wrapper.get("[data-testid=interrupt-state]").text()).toContain(
|
|
268
|
+
"no-result:reject",
|
|
269
|
+
);
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
it("accepts thenable handler results (non-native Promise)", async () => {
|
|
273
|
+
const wrapper = mountHarness({
|
|
274
|
+
renderInChat: false,
|
|
275
|
+
handler: () => Promise.resolve("thenable-ok"),
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
emitInterrupt("thenable");
|
|
279
|
+
await Promise.resolve();
|
|
280
|
+
await Promise.resolve();
|
|
281
|
+
await nextTick();
|
|
282
|
+
|
|
283
|
+
expect(wrapper.get("[data-testid=interrupt-state]").text()).toContain(
|
|
284
|
+
"thenable-ok:thenable",
|
|
285
|
+
);
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
it("publishes interrupt element to chat by default and clears on unmount", async () => {
|
|
289
|
+
const wrapper = mountHarness();
|
|
290
|
+
|
|
291
|
+
emitInterrupt("chat");
|
|
292
|
+
await nextTick();
|
|
293
|
+
|
|
294
|
+
expect(setInterruptStateMock).toHaveBeenCalled();
|
|
295
|
+
expect(setInterruptStateMock.mock.calls.at(-1)?.[0]).toMatchObject({
|
|
296
|
+
event: { name: "on_interrupt", value: "chat" },
|
|
297
|
+
result: null,
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
wrapper.unmount();
|
|
301
|
+
expect(setInterruptStateMock.mock.calls.at(-1)?.[0]).toBeNull();
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
it("does not publish to chat and returns manual element when renderInChat is false", async () => {
|
|
305
|
+
const wrapper = mountHarness({ renderInChat: false });
|
|
306
|
+
|
|
307
|
+
emitInterrupt("manual");
|
|
308
|
+
await nextTick();
|
|
309
|
+
|
|
310
|
+
expect(wrapper.get("[data-testid=interrupt-state]").text()).toContain(
|
|
311
|
+
"manual",
|
|
312
|
+
);
|
|
313
|
+
expect(setInterruptStateMock).not.toHaveBeenCalled();
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
it("discards local interrupt when run fails before finalize", async () => {
|
|
317
|
+
const wrapper = mountHarness({ renderInChat: false });
|
|
318
|
+
|
|
319
|
+
handlers.onCustomEvent?.({
|
|
320
|
+
event: { name: "on_interrupt", value: "lost" },
|
|
321
|
+
});
|
|
322
|
+
handlers.onRunFailed?.();
|
|
323
|
+
handlers.onRunFinalized?.();
|
|
324
|
+
await nextTick();
|
|
325
|
+
|
|
326
|
+
expect(wrapper.get("[data-testid=interrupt-state]").text()).toBe("idle");
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
it("keeps the latest interrupt when multiple interrupts arrive within one run", async () => {
|
|
330
|
+
const wrapper = mountHarness({ renderInChat: false });
|
|
331
|
+
|
|
332
|
+
handlers.onCustomEvent?.({
|
|
333
|
+
event: { name: "on_interrupt", value: "first" },
|
|
334
|
+
});
|
|
335
|
+
handlers.onCustomEvent?.({
|
|
336
|
+
event: { name: "on_interrupt", value: "second" },
|
|
337
|
+
});
|
|
338
|
+
handlers.onRunFinalized?.();
|
|
339
|
+
await nextTick();
|
|
340
|
+
|
|
341
|
+
expect(wrapper.get("[data-testid=interrupt-state]").text()).toContain(
|
|
342
|
+
"second",
|
|
343
|
+
);
|
|
344
|
+
});
|
|
345
|
+
});
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { defineComponent, h, nextTick } from "vue";
|
|
3
|
+
import { render } from "@testing-library/vue";
|
|
4
|
+
|
|
5
|
+
// Mock the katex CSS import globally so the dynamic import resolves cleanly
|
|
6
|
+
// in the test environment.
|
|
7
|
+
vi.mock("katex/dist/katex.min.css", () => ({}));
|
|
8
|
+
|
|
9
|
+
describe("useKatexStyles", () => {
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
// Reset module state (the singleton `injected` flag) between tests so
|
|
12
|
+
// each case can exercise the dynamic-import branch.
|
|
13
|
+
vi.resetModules();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
async function loadHook() {
|
|
17
|
+
const mod = await import("../use-katex-styles");
|
|
18
|
+
return mod.useKatexStyles;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function mountWith(hook: () => void) {
|
|
22
|
+
return render(
|
|
23
|
+
defineComponent({
|
|
24
|
+
setup() {
|
|
25
|
+
hook();
|
|
26
|
+
return () => h("div");
|
|
27
|
+
},
|
|
28
|
+
}),
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
it("renders without error (dynamic import succeeds)", async () => {
|
|
33
|
+
const useKatexStyles = await loadHook();
|
|
34
|
+
|
|
35
|
+
expect(() => {
|
|
36
|
+
mountWith(useKatexStyles);
|
|
37
|
+
}).not.toThrow();
|
|
38
|
+
await nextTick();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("does not throw when katex CSS import fails", async () => {
|
|
42
|
+
vi.doMock("katex/dist/katex.min.css", () => {
|
|
43
|
+
throw new Error("CSS not found");
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const useKatexStyles = await loadHook();
|
|
47
|
+
|
|
48
|
+
expect(() => {
|
|
49
|
+
mountWith(useKatexStyles);
|
|
50
|
+
}).not.toThrow();
|
|
51
|
+
await nextTick();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("does not use a static katex CSS import in the component", async () => {
|
|
55
|
+
// Regression guard: ensure the static import doesn't creep back.
|
|
56
|
+
const fs = await import("fs");
|
|
57
|
+
const path = await import("path");
|
|
58
|
+
const componentPath = path.resolve(
|
|
59
|
+
__dirname,
|
|
60
|
+
"../../components/chat/CopilotChatAssistantMessage.vue",
|
|
61
|
+
);
|
|
62
|
+
const source = fs.readFileSync(componentPath, "utf-8");
|
|
63
|
+
|
|
64
|
+
// Should NOT have a static import of katex CSS anywhere in the SFC.
|
|
65
|
+
expect(source).not.toMatch(/import\s+['"]katex\/dist\/katex\.min\.css['"]/);
|
|
66
|
+
// Should use the composable instead.
|
|
67
|
+
expect(source).toMatch(/useKatexStyles/);
|
|
68
|
+
});
|
|
69
|
+
});
|