@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,527 @@
|
|
|
1
|
+
import { defineComponent, reactive, ref } from "vue";
|
|
2
|
+
import { fireEvent, screen, waitFor, cleanup } from "@testing-library/vue";
|
|
3
|
+
import { describe, it, expect, afterEach } from "vitest";
|
|
4
|
+
import { DEFAULT_AGENT_ID } from "@copilotkit/shared";
|
|
5
|
+
import type { AbstractAgent } from "@ag-ui/client";
|
|
6
|
+
import { useConfigureSuggestions } from "../use-configure-suggestions";
|
|
7
|
+
import { useSuggestions } from "../use-suggestions";
|
|
8
|
+
import { useCopilotKit } from "../../providers/useCopilotKit";
|
|
9
|
+
import {
|
|
10
|
+
renderWithCopilotKit,
|
|
11
|
+
MockStepwiseAgent,
|
|
12
|
+
runStartedEvent,
|
|
13
|
+
runFinishedEvent,
|
|
14
|
+
} from "../../__tests__/utils/test-helpers";
|
|
15
|
+
import {
|
|
16
|
+
SuggestionsProviderAgent,
|
|
17
|
+
StateCapturingAgent,
|
|
18
|
+
} from "../../__tests__/utils/agents";
|
|
19
|
+
|
|
20
|
+
afterEach(() => {
|
|
21
|
+
cleanup();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
class ImmediateSuggestionsProviderAgent extends SuggestionsProviderAgent {
|
|
25
|
+
constructor(responses: any[]) {
|
|
26
|
+
super(responses, DEFAULT_AGENT_ID);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
describe("useConfigureSuggestions", () => {
|
|
31
|
+
it("registers suggestions config and surfaces generated suggestions", async () => {
|
|
32
|
+
const agent = new ImmediateSuggestionsProviderAgent([
|
|
33
|
+
{ title: "Option A", message: "Take path A", isLoading: false },
|
|
34
|
+
{ title: "Option B", message: "Take path B", isLoading: false },
|
|
35
|
+
]);
|
|
36
|
+
|
|
37
|
+
const TestHarness = defineComponent({
|
|
38
|
+
setup() {
|
|
39
|
+
useConfigureSuggestions({
|
|
40
|
+
instructions: "Return deterministic suggestions",
|
|
41
|
+
providerAgentId: DEFAULT_AGENT_ID,
|
|
42
|
+
available: "always",
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const { suggestions, isLoading, reloadSuggestions } = useSuggestions();
|
|
46
|
+
return { suggestions, isLoading, reloadSuggestions };
|
|
47
|
+
},
|
|
48
|
+
template: `
|
|
49
|
+
<div>
|
|
50
|
+
<div data-testid="suggestions-count">{{ suggestions.length }}</div>
|
|
51
|
+
<div data-testid="suggestions-json">{{ JSON.stringify(suggestions) }}</div>
|
|
52
|
+
<div data-testid="suggestions-loading">{{ isLoading ? "loading" : "idle" }}</div>
|
|
53
|
+
<button data-testid="reload-suggestions" @click="reloadSuggestions">Reload</button>
|
|
54
|
+
</div>
|
|
55
|
+
`,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
renderWithCopilotKit({ agent, children: TestHarness });
|
|
59
|
+
|
|
60
|
+
await waitFor(() => {
|
|
61
|
+
expect(screen.getByTestId("suggestions-count").textContent).toBe("2");
|
|
62
|
+
expect(screen.getByTestId("suggestions-loading").textContent).toBe(
|
|
63
|
+
"idle",
|
|
64
|
+
);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
describe("global suggestions coverage", () => {
|
|
70
|
+
it("applies updates across all agents when consumerAgentId is undefined", async () => {
|
|
71
|
+
const alpha = new StateCapturingAgent([{ newMessages: [] }], "alpha");
|
|
72
|
+
const beta = new StateCapturingAgent([{ newMessages: [] }], "beta");
|
|
73
|
+
const config = reactive<any>({
|
|
74
|
+
suggestions: [{ title: "Global v1", message: "Global v1" }],
|
|
75
|
+
consumerAgentId: undefined,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const Harness = defineComponent({
|
|
79
|
+
setup() {
|
|
80
|
+
useConfigureSuggestions(config);
|
|
81
|
+
const { suggestions: alphaSuggestions } = useSuggestions({
|
|
82
|
+
agentId: "alpha",
|
|
83
|
+
});
|
|
84
|
+
const { suggestions: betaSuggestions } = useSuggestions({
|
|
85
|
+
agentId: "beta",
|
|
86
|
+
});
|
|
87
|
+
const updateGlobal = () => {
|
|
88
|
+
config.suggestions = [{ title: "Global v2", message: "Global v2" }];
|
|
89
|
+
};
|
|
90
|
+
return { alphaSuggestions, betaSuggestions, updateGlobal };
|
|
91
|
+
},
|
|
92
|
+
template: `
|
|
93
|
+
<div>
|
|
94
|
+
<div data-testid="alpha-json">{{ JSON.stringify(alphaSuggestions) }}</div>
|
|
95
|
+
<div data-testid="beta-json">{{ JSON.stringify(betaSuggestions) }}</div>
|
|
96
|
+
<button data-testid="update-global" @click="updateGlobal">Update Global Suggestions</button>
|
|
97
|
+
</div>
|
|
98
|
+
`,
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
renderWithCopilotKit({
|
|
102
|
+
agents: {
|
|
103
|
+
alpha: alpha as unknown as AbstractAgent,
|
|
104
|
+
beta: beta as unknown as AbstractAgent,
|
|
105
|
+
},
|
|
106
|
+
agentId: "alpha",
|
|
107
|
+
children: Harness,
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
expect(screen.getByTestId("alpha-json").textContent).toContain("Global v1");
|
|
111
|
+
expect(screen.getByTestId("beta-json").textContent).toContain("Global v1");
|
|
112
|
+
|
|
113
|
+
await fireEvent.click(screen.getByTestId("update-global"));
|
|
114
|
+
|
|
115
|
+
await waitFor(() => {
|
|
116
|
+
expect(screen.getByTestId("alpha-json").textContent).toContain(
|
|
117
|
+
"Global v2",
|
|
118
|
+
);
|
|
119
|
+
expect(screen.getByTestId("beta-json").textContent).toContain(
|
|
120
|
+
"Global v2",
|
|
121
|
+
);
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it("applies updates across all agents when consumerAgentId is '*'", async () => {
|
|
126
|
+
const alpha = new StateCapturingAgent([{ newMessages: [] }], "alpha");
|
|
127
|
+
const beta = new StateCapturingAgent([{ newMessages: [] }], "beta");
|
|
128
|
+
const config = reactive<any>({
|
|
129
|
+
suggestions: [{ title: "Global v1", message: "Global v1" }],
|
|
130
|
+
consumerAgentId: "*",
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
const Harness = defineComponent({
|
|
134
|
+
setup() {
|
|
135
|
+
useConfigureSuggestions(config);
|
|
136
|
+
const { suggestions: alphaSuggestions } = useSuggestions({
|
|
137
|
+
agentId: "alpha",
|
|
138
|
+
});
|
|
139
|
+
const { suggestions: betaSuggestions } = useSuggestions({
|
|
140
|
+
agentId: "beta",
|
|
141
|
+
});
|
|
142
|
+
const updateGlobal = () => {
|
|
143
|
+
config.suggestions = [{ title: "Global v2", message: "Global v2" }];
|
|
144
|
+
};
|
|
145
|
+
return { alphaSuggestions, betaSuggestions, updateGlobal };
|
|
146
|
+
},
|
|
147
|
+
template: `
|
|
148
|
+
<div>
|
|
149
|
+
<div data-testid="alpha-json">{{ JSON.stringify(alphaSuggestions) }}</div>
|
|
150
|
+
<div data-testid="beta-json">{{ JSON.stringify(betaSuggestions) }}</div>
|
|
151
|
+
<button data-testid="update-global" @click="updateGlobal">Update Global Suggestions</button>
|
|
152
|
+
</div>
|
|
153
|
+
`,
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
renderWithCopilotKit({
|
|
157
|
+
agents: {
|
|
158
|
+
alpha: alpha as unknown as AbstractAgent,
|
|
159
|
+
beta: beta as unknown as AbstractAgent,
|
|
160
|
+
},
|
|
161
|
+
agentId: "alpha",
|
|
162
|
+
children: Harness,
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
await fireEvent.click(screen.getByTestId("update-global"));
|
|
166
|
+
|
|
167
|
+
await waitFor(() => {
|
|
168
|
+
expect(screen.getByTestId("alpha-json").textContent).toContain(
|
|
169
|
+
"Global v2",
|
|
170
|
+
);
|
|
171
|
+
expect(screen.getByTestId("beta-json").textContent).toContain(
|
|
172
|
+
"Global v2",
|
|
173
|
+
);
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
describe("dynamic suggestions with MockAgent", () => {
|
|
179
|
+
it("reloads streaming suggestions when instructions change", async () => {
|
|
180
|
+
const provider = new ImmediateSuggestionsProviderAgent([
|
|
181
|
+
{ title: "Alpha", message: "Alpha", isLoading: false },
|
|
182
|
+
]);
|
|
183
|
+
const topic = ref("Alpha");
|
|
184
|
+
|
|
185
|
+
const Harness = defineComponent({
|
|
186
|
+
setup() {
|
|
187
|
+
useConfigureSuggestions(
|
|
188
|
+
{
|
|
189
|
+
instructions: `Offer choices about ${topic.value}`,
|
|
190
|
+
providerAgentId: DEFAULT_AGENT_ID,
|
|
191
|
+
consumerAgentId: DEFAULT_AGENT_ID,
|
|
192
|
+
available: "always",
|
|
193
|
+
},
|
|
194
|
+
[topic],
|
|
195
|
+
);
|
|
196
|
+
|
|
197
|
+
const { suggestions, reloadSuggestions } = useSuggestions();
|
|
198
|
+
const nextTopic = () => {
|
|
199
|
+
topic.value = "Beta";
|
|
200
|
+
provider.setResponses([
|
|
201
|
+
{ title: "Beta", message: "Beta", isLoading: false },
|
|
202
|
+
]);
|
|
203
|
+
};
|
|
204
|
+
return { suggestions, reloadSuggestions, nextTopic };
|
|
205
|
+
},
|
|
206
|
+
template: `
|
|
207
|
+
<div>
|
|
208
|
+
<div data-testid="dynamic-json">{{ JSON.stringify(suggestions) }}</div>
|
|
209
|
+
<button data-testid="dynamic-reload" @click="reloadSuggestions">Reload Dynamic</button>
|
|
210
|
+
<button data-testid="dynamic-topic" @click="nextTopic">Next Topic</button>
|
|
211
|
+
</div>
|
|
212
|
+
`,
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
renderWithCopilotKit({ agent: provider, children: Harness });
|
|
216
|
+
|
|
217
|
+
await fireEvent.click(screen.getByTestId("dynamic-reload"));
|
|
218
|
+
await waitFor(() => {
|
|
219
|
+
expect(screen.getByTestId("dynamic-json").textContent).toContain("Alpha");
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
await fireEvent.click(screen.getByTestId("dynamic-topic"));
|
|
223
|
+
await fireEvent.click(screen.getByTestId("dynamic-reload"));
|
|
224
|
+
|
|
225
|
+
await waitFor(() => {
|
|
226
|
+
expect(screen.getByTestId("dynamic-json").textContent).toContain("Beta");
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
describe("static suggestions defaults", () => {
|
|
232
|
+
it("shows static suggestions only before the first message", async () => {
|
|
233
|
+
const agent = new MockStepwiseAgent();
|
|
234
|
+
|
|
235
|
+
const Harness = defineComponent({
|
|
236
|
+
setup() {
|
|
237
|
+
useConfigureSuggestions({
|
|
238
|
+
suggestions: [{ title: "Static A", message: "First static" }],
|
|
239
|
+
});
|
|
240
|
+
const { suggestions, reloadSuggestions } = useSuggestions();
|
|
241
|
+
const { copilotkit } = useCopilotKit();
|
|
242
|
+
|
|
243
|
+
const addMessage = () => {
|
|
244
|
+
const current = copilotkit.value.getAgent(DEFAULT_AGENT_ID);
|
|
245
|
+
current?.addMessage({
|
|
246
|
+
id: "u1",
|
|
247
|
+
role: "user",
|
|
248
|
+
content: "User message",
|
|
249
|
+
} as any);
|
|
250
|
+
reloadSuggestions();
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
return { suggestions, reloadSuggestions, addMessage };
|
|
254
|
+
},
|
|
255
|
+
template: `
|
|
256
|
+
<div>
|
|
257
|
+
<div data-testid="suggestions-json">{{ JSON.stringify(suggestions) }}</div>
|
|
258
|
+
<button data-testid="reload-suggestions" @click="reloadSuggestions">Reload</button>
|
|
259
|
+
<button data-testid="add-message" @click="addMessage">Add message</button>
|
|
260
|
+
</div>
|
|
261
|
+
`,
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
renderWithCopilotKit({ agent, children: Harness });
|
|
265
|
+
|
|
266
|
+
await fireEvent.click(screen.getByTestId("reload-suggestions"));
|
|
267
|
+
await waitFor(() => {
|
|
268
|
+
expect(screen.getByTestId("suggestions-json").textContent).toContain(
|
|
269
|
+
"Static A",
|
|
270
|
+
);
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
await fireEvent.click(screen.getByTestId("add-message"));
|
|
274
|
+
await waitFor(() => {
|
|
275
|
+
expect(screen.getByTestId("suggestions-json").textContent).toContain(
|
|
276
|
+
"[]",
|
|
277
|
+
);
|
|
278
|
+
});
|
|
279
|
+
});
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
describe("suggestions lifecycle during runs", () => {
|
|
283
|
+
it("clears suggestions immediately when the agent run starts", async () => {
|
|
284
|
+
const agent = new MockStepwiseAgent();
|
|
285
|
+
|
|
286
|
+
const Harness = defineComponent({
|
|
287
|
+
setup() {
|
|
288
|
+
useConfigureSuggestions({
|
|
289
|
+
suggestions: [{ title: "First static", message: "First static" }],
|
|
290
|
+
});
|
|
291
|
+
const { suggestions, reloadSuggestions } = useSuggestions();
|
|
292
|
+
const { copilotkit } = useCopilotKit();
|
|
293
|
+
|
|
294
|
+
const runAgent = () => {
|
|
295
|
+
const current = copilotkit.value.getAgent(DEFAULT_AGENT_ID);
|
|
296
|
+
if (current) {
|
|
297
|
+
current.addMessage({
|
|
298
|
+
id: "u-run",
|
|
299
|
+
role: "user",
|
|
300
|
+
content: "Initiating run",
|
|
301
|
+
} as any);
|
|
302
|
+
void copilotkit.value.runAgent({ agent: current });
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
return { suggestions, reloadSuggestions, runAgent };
|
|
307
|
+
},
|
|
308
|
+
template: `
|
|
309
|
+
<div>
|
|
310
|
+
<div data-testid="suggestions-json">{{ JSON.stringify(suggestions) }}</div>
|
|
311
|
+
<button data-testid="reload-suggestions" @click="reloadSuggestions">Reload</button>
|
|
312
|
+
<button data-testid="run-agent" @click="runAgent">Run</button>
|
|
313
|
+
</div>
|
|
314
|
+
`,
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
renderWithCopilotKit({ agent, children: Harness });
|
|
318
|
+
|
|
319
|
+
await fireEvent.click(screen.getByTestId("reload-suggestions"));
|
|
320
|
+
await waitFor(() => {
|
|
321
|
+
expect(screen.getByTestId("suggestions-json").textContent).toContain(
|
|
322
|
+
"First static",
|
|
323
|
+
);
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
await fireEvent.click(screen.getByTestId("run-agent"));
|
|
327
|
+
agent.emit(runStartedEvent());
|
|
328
|
+
|
|
329
|
+
await waitFor(() => {
|
|
330
|
+
expect(screen.getByTestId("suggestions-json").textContent).toContain(
|
|
331
|
+
"[]",
|
|
332
|
+
);
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
agent.emit(runFinishedEvent());
|
|
336
|
+
agent.complete();
|
|
337
|
+
});
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
describe("useConfigureSuggestions dependencies", () => {
|
|
341
|
+
it("reloads suggestions when the provided config changes", async () => {
|
|
342
|
+
const provider = new ImmediateSuggestionsProviderAgent([
|
|
343
|
+
{ title: "Version 0", message: "Version 0", isLoading: false },
|
|
344
|
+
]);
|
|
345
|
+
const version = ref(0);
|
|
346
|
+
|
|
347
|
+
const Harness = defineComponent({
|
|
348
|
+
setup() {
|
|
349
|
+
const config = reactive({
|
|
350
|
+
instructions: "Versioned suggestions",
|
|
351
|
+
providerAgentId: DEFAULT_AGENT_ID,
|
|
352
|
+
consumerAgentId: DEFAULT_AGENT_ID,
|
|
353
|
+
available: "always" as const,
|
|
354
|
+
version,
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
useConfigureSuggestions(config, [version]);
|
|
358
|
+
const { suggestions } = useSuggestions();
|
|
359
|
+
|
|
360
|
+
const bump = () => {
|
|
361
|
+
version.value += 1;
|
|
362
|
+
provider.setResponses([
|
|
363
|
+
{
|
|
364
|
+
title: `Version ${version.value}`,
|
|
365
|
+
message: `Version ${version.value}`,
|
|
366
|
+
isLoading: false,
|
|
367
|
+
},
|
|
368
|
+
]);
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
return { suggestions, bump };
|
|
372
|
+
},
|
|
373
|
+
template: `
|
|
374
|
+
<div>
|
|
375
|
+
<div data-testid="suggestions-json">{{ JSON.stringify(suggestions) }}</div>
|
|
376
|
+
<button data-testid="bump" @click="bump">Bump</button>
|
|
377
|
+
</div>
|
|
378
|
+
`,
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
renderWithCopilotKit({ agent: provider, children: Harness });
|
|
382
|
+
|
|
383
|
+
await waitFor(() => {
|
|
384
|
+
expect(screen.getByTestId("suggestions-json").textContent).toContain(
|
|
385
|
+
"Version 0",
|
|
386
|
+
);
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
await fireEvent.click(screen.getByTestId("bump"));
|
|
390
|
+
|
|
391
|
+
await waitFor(() => {
|
|
392
|
+
expect(screen.getByTestId("suggestions-json").textContent).toContain(
|
|
393
|
+
"Version 1",
|
|
394
|
+
);
|
|
395
|
+
});
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
it("reloads suggestions when optional dependencies change", async () => {
|
|
399
|
+
const provider = new ImmediateSuggestionsProviderAgent([
|
|
400
|
+
{ title: "Initial", message: "Initial", isLoading: false },
|
|
401
|
+
]);
|
|
402
|
+
const version = ref(0);
|
|
403
|
+
|
|
404
|
+
const Harness = defineComponent({
|
|
405
|
+
setup() {
|
|
406
|
+
const configRef = ref({
|
|
407
|
+
suggestions: [{ title: "Version 0", message: "Version 0" }],
|
|
408
|
+
});
|
|
409
|
+
|
|
410
|
+
useConfigureSuggestions(configRef.value, [version]);
|
|
411
|
+
const { suggestions } = useSuggestions();
|
|
412
|
+
|
|
413
|
+
const bump = () => {
|
|
414
|
+
version.value += 1;
|
|
415
|
+
configRef.value.suggestions = [
|
|
416
|
+
{
|
|
417
|
+
title: `Version ${version.value}`,
|
|
418
|
+
message: `Version ${version.value}`,
|
|
419
|
+
},
|
|
420
|
+
];
|
|
421
|
+
provider.setResponses([
|
|
422
|
+
{
|
|
423
|
+
title: `Version ${version.value}`,
|
|
424
|
+
message: `Version ${version.value}`,
|
|
425
|
+
isLoading: false,
|
|
426
|
+
},
|
|
427
|
+
]);
|
|
428
|
+
};
|
|
429
|
+
|
|
430
|
+
return { suggestions, bump };
|
|
431
|
+
},
|
|
432
|
+
template: `
|
|
433
|
+
<div>
|
|
434
|
+
<div data-testid="suggestions-json">{{ JSON.stringify(suggestions) }}</div>
|
|
435
|
+
<button data-testid="bump" @click="bump">Bump</button>
|
|
436
|
+
</div>
|
|
437
|
+
`,
|
|
438
|
+
});
|
|
439
|
+
|
|
440
|
+
renderWithCopilotKit({ agent: provider, children: Harness });
|
|
441
|
+
|
|
442
|
+
await fireEvent.click(screen.getByTestId("bump"));
|
|
443
|
+
|
|
444
|
+
await waitFor(() => {
|
|
445
|
+
expect(screen.getByTestId("suggestions-json").textContent).toContain(
|
|
446
|
+
"Version 1",
|
|
447
|
+
);
|
|
448
|
+
});
|
|
449
|
+
});
|
|
450
|
+
|
|
451
|
+
it("defers reloads while a run is in progress and applies them afterward", async () => {
|
|
452
|
+
const agent = new MockStepwiseAgent();
|
|
453
|
+
const label = ref("Initial");
|
|
454
|
+
|
|
455
|
+
const Harness = defineComponent({
|
|
456
|
+
setup() {
|
|
457
|
+
const config = reactive({
|
|
458
|
+
suggestions: [{ title: label.value, message: label.value }],
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
useConfigureSuggestions(config, [label]);
|
|
462
|
+
|
|
463
|
+
const { copilotkit } = useCopilotKit();
|
|
464
|
+
const { suggestions } = useSuggestions();
|
|
465
|
+
|
|
466
|
+
const startRun = () => {
|
|
467
|
+
const current = copilotkit.value.getAgent(DEFAULT_AGENT_ID);
|
|
468
|
+
if (current) {
|
|
469
|
+
void copilotkit.value.runAgent({ agent: current });
|
|
470
|
+
}
|
|
471
|
+
};
|
|
472
|
+
const emitStart = async () => {
|
|
473
|
+
const current = copilotkit.value.getAgent(DEFAULT_AGENT_ID);
|
|
474
|
+
if (current instanceof MockStepwiseAgent) {
|
|
475
|
+
await current.emit(runStartedEvent());
|
|
476
|
+
}
|
|
477
|
+
};
|
|
478
|
+
const emitFinish = async () => {
|
|
479
|
+
const current = copilotkit.value.getAgent(DEFAULT_AGENT_ID);
|
|
480
|
+
if (current instanceof MockStepwiseAgent) {
|
|
481
|
+
await current.emit(runFinishedEvent());
|
|
482
|
+
await current.complete();
|
|
483
|
+
}
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
const updateLabel = () => {
|
|
487
|
+
label.value = "Deferred";
|
|
488
|
+
config.suggestions = [{ title: label.value, message: label.value }];
|
|
489
|
+
};
|
|
490
|
+
|
|
491
|
+
return { suggestions, startRun, emitStart, emitFinish, updateLabel };
|
|
492
|
+
},
|
|
493
|
+
template: `
|
|
494
|
+
<div>
|
|
495
|
+
<div data-testid="suggestions-json">{{ JSON.stringify(suggestions) }}</div>
|
|
496
|
+
<button data-testid="start-run" @click="startRun">Start Run</button>
|
|
497
|
+
<button data-testid="emit-start" @click="emitStart">Emit Start</button>
|
|
498
|
+
<button data-testid="emit-finish" @click="emitFinish">Emit Finish</button>
|
|
499
|
+
<button data-testid="update-label" @click="updateLabel">Update Label</button>
|
|
500
|
+
</div>
|
|
501
|
+
`,
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
renderWithCopilotKit({ agent, children: Harness });
|
|
505
|
+
|
|
506
|
+
await waitFor(() => {
|
|
507
|
+
expect(screen.getByTestId("suggestions-json").textContent).toContain(
|
|
508
|
+
"Initial",
|
|
509
|
+
);
|
|
510
|
+
});
|
|
511
|
+
|
|
512
|
+
await fireEvent.click(screen.getByTestId("start-run"));
|
|
513
|
+
await fireEvent.click(screen.getByTestId("emit-start"));
|
|
514
|
+
|
|
515
|
+
await fireEvent.click(screen.getByTestId("update-label"));
|
|
516
|
+
|
|
517
|
+
expect(screen.getByTestId("suggestions-json").textContent).toContain("[]");
|
|
518
|
+
|
|
519
|
+
await fireEvent.click(screen.getByTestId("emit-finish"));
|
|
520
|
+
|
|
521
|
+
await waitFor(() => {
|
|
522
|
+
expect(screen.getByTestId("suggestions-json").textContent).toContain(
|
|
523
|
+
"Deferred",
|
|
524
|
+
);
|
|
525
|
+
});
|
|
526
|
+
});
|
|
527
|
+
});
|