@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,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Integration test for the context timing race condition (CPK-7060).
|
|
3
|
+
*
|
|
4
|
+
* When a useFrontendTool handler calls setState(), the corresponding
|
|
5
|
+
* useAgentContext value is updated asynchronously (React defers useEffect to a
|
|
6
|
+
* later scheduler task). Without yielding before the follow-up agent run,
|
|
7
|
+
* runAgent reads stale context from the store.
|
|
8
|
+
*
|
|
9
|
+
* CopilotKitCoreReact.waitForPendingFrameworkUpdates() fixes this by awaiting a
|
|
10
|
+
* zero-delay timeout, which yields to React's scheduler before reading context.
|
|
11
|
+
*
|
|
12
|
+
* This test uses real React rendering in jsdom so that actual useState +
|
|
13
|
+
* useAgentContext + useFrontendTool lifecycle interactions are exercised.
|
|
14
|
+
*/
|
|
15
|
+
import { defineComponent, ref } from "vue";
|
|
16
|
+
import { screen, fireEvent, waitFor, cleanup } from "@testing-library/vue";
|
|
17
|
+
import { describe, it, expect, afterEach } from "vitest";
|
|
18
|
+
import { z } from "zod";
|
|
19
|
+
import type {
|
|
20
|
+
AgentSubscriber,
|
|
21
|
+
Context,
|
|
22
|
+
RunAgentParameters,
|
|
23
|
+
} from "@ag-ui/client";
|
|
24
|
+
import { useFrontendTool } from "../use-frontend-tool";
|
|
25
|
+
import { useAgentContext } from "../use-agent-context";
|
|
26
|
+
import CopilotChat from "../../components/chat/CopilotChat.vue";
|
|
27
|
+
import {
|
|
28
|
+
MockStepwiseAgent,
|
|
29
|
+
renderWithCopilotKit,
|
|
30
|
+
runStartedEvent,
|
|
31
|
+
runFinishedEvent,
|
|
32
|
+
toolCallChunkEvent,
|
|
33
|
+
testId,
|
|
34
|
+
} from "../../__tests__/utils/test-helpers";
|
|
35
|
+
|
|
36
|
+
afterEach(() => {
|
|
37
|
+
cleanup();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe("useAgentContext timing - follow-up run sees updated context", () => {
|
|
41
|
+
it("follow-up agent run receives context updated by useFrontendTool handler", async () => {
|
|
42
|
+
/**
|
|
43
|
+
* Agent subclass that records the context parameter on every runAgent call.
|
|
44
|
+
* After complete() is called on the subject the Observable completes
|
|
45
|
+
* immediately for subsequent subscriptions, so the follow-up run resolves
|
|
46
|
+
* with no new messages — which is fine; we only need to capture context.
|
|
47
|
+
*/
|
|
48
|
+
class ContextCapturingAgent extends MockStepwiseAgent {
|
|
49
|
+
public contextPerRun: Context[][] = [];
|
|
50
|
+
|
|
51
|
+
override async runAgent(
|
|
52
|
+
parameters: RunAgentParameters = {},
|
|
53
|
+
subscriber?: AgentSubscriber,
|
|
54
|
+
) {
|
|
55
|
+
this.contextPerRun.push(parameters.context ?? []);
|
|
56
|
+
return super.runAgent(parameters, subscriber);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const agent = new ContextCapturingAgent();
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Component that wires React state into useAgentContext and exposes a
|
|
64
|
+
* frontend tool that updates that state.
|
|
65
|
+
*/
|
|
66
|
+
const TestComponent = defineComponent({
|
|
67
|
+
setup() {
|
|
68
|
+
const prefs = ref<{ spicy: boolean }>({ spicy: true });
|
|
69
|
+
|
|
70
|
+
useAgentContext({
|
|
71
|
+
description: "user preferences",
|
|
72
|
+
value: prefs,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
useFrontendTool({
|
|
76
|
+
name: "updatePrefs",
|
|
77
|
+
parameters: z.object({}),
|
|
78
|
+
followUp: true,
|
|
79
|
+
handler: async () => {
|
|
80
|
+
prefs.value = { spicy: false };
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
return {};
|
|
85
|
+
},
|
|
86
|
+
template: `<div />`,
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const Host = defineComponent({
|
|
90
|
+
components: { TestComponent, CopilotChat },
|
|
91
|
+
template: `
|
|
92
|
+
<div>
|
|
93
|
+
<TestComponent />
|
|
94
|
+
<div style="height: 400px;">
|
|
95
|
+
<CopilotChat :welcome-screen="false" />
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
98
|
+
`,
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
renderWithCopilotKit({
|
|
102
|
+
agent,
|
|
103
|
+
children: Host,
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// Submit a user message to start the first agent run
|
|
107
|
+
const input = await screen.findByRole("textbox");
|
|
108
|
+
await fireEvent.update(input, "Update my preferences");
|
|
109
|
+
await fireEvent.keyDown(input, { key: "Enter", code: "Enter" });
|
|
110
|
+
|
|
111
|
+
// Wait for the first runAgent call to arrive
|
|
112
|
+
await waitFor(() => {
|
|
113
|
+
expect(agent.contextPerRun.length).toBeGreaterThanOrEqual(1);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// First run: the agent calls the updatePrefs tool
|
|
117
|
+
const messageId = testId("msg");
|
|
118
|
+
const toolCallId = testId("tc");
|
|
119
|
+
|
|
120
|
+
await agent.emit(runStartedEvent());
|
|
121
|
+
await agent.emit(
|
|
122
|
+
toolCallChunkEvent({
|
|
123
|
+
toolCallId,
|
|
124
|
+
toolCallName: "updatePrefs",
|
|
125
|
+
parentMessageId: messageId,
|
|
126
|
+
delta: "{}",
|
|
127
|
+
}),
|
|
128
|
+
);
|
|
129
|
+
await agent.emit(runFinishedEvent());
|
|
130
|
+
await agent.complete();
|
|
131
|
+
|
|
132
|
+
// Wait for the follow-up run to be triggered by processAgentResult
|
|
133
|
+
await waitFor(() => {
|
|
134
|
+
expect(agent.contextPerRun.length).toBeGreaterThanOrEqual(2);
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
// The follow-up run should see the context updated by the tool handler
|
|
138
|
+
// (spicy: false), not the stale value from before the handler ran (spicy: true).
|
|
139
|
+
const followUpContext = agent.contextPerRun[1];
|
|
140
|
+
expect(followUpContext).toContainEqual(
|
|
141
|
+
expect.objectContaining({ value: '{"spicy":false}' }),
|
|
142
|
+
);
|
|
143
|
+
});
|
|
144
|
+
});
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
|
+
import { defineComponent, h, nextTick, ref } from "vue";
|
|
3
|
+
import { useCopilotKit } from "../../providers/useCopilotKit";
|
|
4
|
+
import { useAgentContext } from "../use-agent-context";
|
|
5
|
+
import { mountWithProvider } from "../../__tests__/utils/mount";
|
|
6
|
+
|
|
7
|
+
function getContextEntries(
|
|
8
|
+
core: ReturnType<typeof useCopilotKit>["copilotkit"]["value"],
|
|
9
|
+
) {
|
|
10
|
+
return Object.values(core.context ?? {});
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
describe("useAgentContext", () => {
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
console.warn = vi.fn();
|
|
16
|
+
console.error = vi.fn();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("adds context on mount and removes on unmount", () => {
|
|
20
|
+
let core:
|
|
21
|
+
| ReturnType<typeof useCopilotKit>["copilotkit"]["value"]
|
|
22
|
+
| undefined;
|
|
23
|
+
|
|
24
|
+
const Child = defineComponent({
|
|
25
|
+
setup() {
|
|
26
|
+
useAgentContext({
|
|
27
|
+
description: "Test context",
|
|
28
|
+
value: { key: "value" },
|
|
29
|
+
});
|
|
30
|
+
return () => h("div", "child");
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const Probe = defineComponent({
|
|
35
|
+
setup() {
|
|
36
|
+
const { copilotkit } = useCopilotKit();
|
|
37
|
+
core = copilotkit.value;
|
|
38
|
+
return () => null;
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const { wrapper } = mountWithProvider(() => h("div", [h(Child), h(Probe)]));
|
|
43
|
+
expect(getContextEntries(core!)).toHaveLength(1);
|
|
44
|
+
|
|
45
|
+
wrapper.unmount();
|
|
46
|
+
expect(getContextEntries(core!)).toHaveLength(0);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("removes context when conditionally unmounted", async () => {
|
|
50
|
+
let core:
|
|
51
|
+
| ReturnType<typeof useCopilotKit>["copilotkit"]["value"]
|
|
52
|
+
| undefined;
|
|
53
|
+
|
|
54
|
+
const ContextUser = defineComponent({
|
|
55
|
+
setup() {
|
|
56
|
+
useAgentContext({ description: "conditional", value: "value" });
|
|
57
|
+
return () => h("div", "context-user");
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const Parent = defineComponent({
|
|
62
|
+
setup() {
|
|
63
|
+
const shown = ref(true);
|
|
64
|
+
const { copilotkit } = useCopilotKit();
|
|
65
|
+
core = copilotkit.value;
|
|
66
|
+
return () =>
|
|
67
|
+
h("div", [
|
|
68
|
+
h(
|
|
69
|
+
"button",
|
|
70
|
+
{
|
|
71
|
+
"data-testid": "toggle",
|
|
72
|
+
onClick: () => (shown.value = !shown.value),
|
|
73
|
+
},
|
|
74
|
+
"toggle",
|
|
75
|
+
),
|
|
76
|
+
shown.value ? h(ContextUser) : null,
|
|
77
|
+
]);
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
const { wrapper } = mountWithProvider(() => h(Parent));
|
|
82
|
+
expect(getContextEntries(core!)).toHaveLength(1);
|
|
83
|
+
|
|
84
|
+
await wrapper.find("[data-testid=toggle]").trigger("click");
|
|
85
|
+
await nextTick();
|
|
86
|
+
|
|
87
|
+
expect(getContextEntries(core!)).toHaveLength(0);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it("does not duplicate context on parent re-render with stable inputs", async () => {
|
|
91
|
+
let core:
|
|
92
|
+
| ReturnType<typeof useCopilotKit>["copilotkit"]["value"]
|
|
93
|
+
| undefined;
|
|
94
|
+
|
|
95
|
+
const Child = defineComponent({
|
|
96
|
+
setup() {
|
|
97
|
+
useAgentContext({
|
|
98
|
+
description: "Stable context",
|
|
99
|
+
value: "stable value",
|
|
100
|
+
});
|
|
101
|
+
return () => h("div", "child");
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
const Parent = defineComponent({
|
|
106
|
+
setup() {
|
|
107
|
+
const counter = ref(0);
|
|
108
|
+
const { copilotkit } = useCopilotKit();
|
|
109
|
+
core = copilotkit.value;
|
|
110
|
+
return () =>
|
|
111
|
+
h("div", [
|
|
112
|
+
h(
|
|
113
|
+
"button",
|
|
114
|
+
{
|
|
115
|
+
"data-testid": "increment",
|
|
116
|
+
onClick: () => (counter.value += 1),
|
|
117
|
+
},
|
|
118
|
+
String(counter.value),
|
|
119
|
+
),
|
|
120
|
+
h(Child),
|
|
121
|
+
]);
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
const { wrapper } = mountWithProvider(() => h(Parent));
|
|
126
|
+
expect(getContextEntries(core!)).toHaveLength(1);
|
|
127
|
+
|
|
128
|
+
await wrapper.find("[data-testid=increment]").trigger("click");
|
|
129
|
+
await wrapper.find("[data-testid=increment]").trigger("click");
|
|
130
|
+
await nextTick();
|
|
131
|
+
|
|
132
|
+
expect(getContextEntries(core!)).toHaveLength(1);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it("re-adds context when description changes", async () => {
|
|
136
|
+
let core:
|
|
137
|
+
| ReturnType<typeof useCopilotKit>["copilotkit"]["value"]
|
|
138
|
+
| undefined;
|
|
139
|
+
const description = ref("first");
|
|
140
|
+
|
|
141
|
+
const Child = defineComponent({
|
|
142
|
+
setup() {
|
|
143
|
+
useAgentContext({ description, value: "same" });
|
|
144
|
+
return () => h("div", "child");
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
const Parent = defineComponent({
|
|
149
|
+
setup() {
|
|
150
|
+
const { copilotkit } = useCopilotKit();
|
|
151
|
+
core = copilotkit.value;
|
|
152
|
+
return () =>
|
|
153
|
+
h(
|
|
154
|
+
"button",
|
|
155
|
+
{
|
|
156
|
+
"data-testid": "update",
|
|
157
|
+
onClick: () => (description.value = "second"),
|
|
158
|
+
},
|
|
159
|
+
"update",
|
|
160
|
+
);
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
const { wrapper } = mountWithProvider(() =>
|
|
165
|
+
h("div", [h(Parent), h(Child)]),
|
|
166
|
+
);
|
|
167
|
+
expect(getContextEntries(core!)[0]?.description).toBe("first");
|
|
168
|
+
|
|
169
|
+
await wrapper.find("[data-testid=update]").trigger("click");
|
|
170
|
+
await nextTick();
|
|
171
|
+
|
|
172
|
+
const entries = getContextEntries(core!);
|
|
173
|
+
expect(entries).toHaveLength(1);
|
|
174
|
+
expect(entries[0]?.description).toBe("second");
|
|
175
|
+
expect(entries[0]?.value).toBe("same");
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it("re-adds context when value changes", async () => {
|
|
179
|
+
let core:
|
|
180
|
+
| ReturnType<typeof useCopilotKit>["copilotkit"]["value"]
|
|
181
|
+
| undefined;
|
|
182
|
+
const value = ref("first");
|
|
183
|
+
|
|
184
|
+
const Child = defineComponent({
|
|
185
|
+
setup() {
|
|
186
|
+
useAgentContext({ description: "fixed", value });
|
|
187
|
+
return () => h("div", "child");
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
const Parent = defineComponent({
|
|
192
|
+
setup() {
|
|
193
|
+
const { copilotkit } = useCopilotKit();
|
|
194
|
+
core = copilotkit.value;
|
|
195
|
+
return () =>
|
|
196
|
+
h(
|
|
197
|
+
"button",
|
|
198
|
+
{
|
|
199
|
+
"data-testid": "update",
|
|
200
|
+
onClick: () => (value.value = "second"),
|
|
201
|
+
},
|
|
202
|
+
"update",
|
|
203
|
+
);
|
|
204
|
+
},
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
const { wrapper } = mountWithProvider(() =>
|
|
208
|
+
h("div", [h(Parent), h(Child)]),
|
|
209
|
+
);
|
|
210
|
+
expect(getContextEntries(core!)[0]?.value).toBe("first");
|
|
211
|
+
|
|
212
|
+
await wrapper.find("[data-testid=update]").trigger("click");
|
|
213
|
+
await nextTick();
|
|
214
|
+
|
|
215
|
+
const entries = getContextEntries(core!);
|
|
216
|
+
expect(entries).toHaveLength(1);
|
|
217
|
+
expect(entries[0]?.description).toBe("fixed");
|
|
218
|
+
expect(entries[0]?.value).toBe("second");
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
it("serializes string values unchanged", () => {
|
|
222
|
+
let core:
|
|
223
|
+
| ReturnType<typeof useCopilotKit>["copilotkit"]["value"]
|
|
224
|
+
| undefined;
|
|
225
|
+
const Child = defineComponent({
|
|
226
|
+
setup() {
|
|
227
|
+
const { copilotkit } = useCopilotKit();
|
|
228
|
+
core = copilotkit.value;
|
|
229
|
+
useAgentContext({ description: "string", value: "plain" });
|
|
230
|
+
return () => null;
|
|
231
|
+
},
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
mountWithProvider(() => h(Child));
|
|
235
|
+
expect(getContextEntries(core!)[0]?.value).toBe("plain");
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
it.each([
|
|
239
|
+
["object", { name: "John", age: 30 }, '{"name":"John","age":30}'],
|
|
240
|
+
["array", [1, 2, 3, "four"], '[1,2,3,"four"]'],
|
|
241
|
+
["number", 42, "42"],
|
|
242
|
+
["boolean", true, "true"],
|
|
243
|
+
["null", null, "null"],
|
|
244
|
+
[
|
|
245
|
+
"nested",
|
|
246
|
+
{
|
|
247
|
+
user: {
|
|
248
|
+
name: "Alice",
|
|
249
|
+
settings: { theme: "dark", notifications: true },
|
|
250
|
+
},
|
|
251
|
+
items: [1, 2, { nested: "value" }],
|
|
252
|
+
},
|
|
253
|
+
'{"user":{"name":"Alice","settings":{"theme":"dark","notifications":true}},"items":[1,2,{"nested":"value"}]}',
|
|
254
|
+
],
|
|
255
|
+
])("serializes %s values", (_name, value, expected) => {
|
|
256
|
+
let core:
|
|
257
|
+
| ReturnType<typeof useCopilotKit>["copilotkit"]["value"]
|
|
258
|
+
| undefined;
|
|
259
|
+
const Child = defineComponent({
|
|
260
|
+
setup() {
|
|
261
|
+
const { copilotkit } = useCopilotKit();
|
|
262
|
+
core = copilotkit.value;
|
|
263
|
+
useAgentContext({ description: "serialized", value: value as never });
|
|
264
|
+
return () => null;
|
|
265
|
+
},
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
mountWithProvider(() => h(Child));
|
|
269
|
+
expect(getContextEntries(core!)[0]?.value).toBe(expected);
|
|
270
|
+
});
|
|
271
|
+
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { defineComponent } from "vue";
|
|
2
|
+
import { render, screen, cleanup } from "@testing-library/vue";
|
|
3
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
|
4
|
+
import CopilotKitProvider from "../../providers/CopilotKitProvider.vue";
|
|
5
|
+
import { useAgent } from "../use-agent";
|
|
6
|
+
|
|
7
|
+
describe("useAgent error state", () => {
|
|
8
|
+
const originalFetch = global.fetch;
|
|
9
|
+
const originalWindow = (globalThis as { window?: unknown }).window;
|
|
10
|
+
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
// Simulate browser environment
|
|
13
|
+
(globalThis as { window?: unknown }).window = {};
|
|
14
|
+
// Mock fetch to reject (simulates runtime unreachable)
|
|
15
|
+
global.fetch = vi.fn().mockRejectedValue(new Error("network failure"));
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
afterEach(() => {
|
|
19
|
+
cleanup();
|
|
20
|
+
vi.restoreAllMocks();
|
|
21
|
+
global.fetch = originalFetch;
|
|
22
|
+
if (originalWindow === undefined) {
|
|
23
|
+
delete (globalThis as { window?: unknown }).window;
|
|
24
|
+
} else {
|
|
25
|
+
(globalThis as { window?: unknown }).window = originalWindow;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("returns a provisional agent instead of throwing when runtime is in error state", async () => {
|
|
30
|
+
const capturedErrors: unknown[] = [];
|
|
31
|
+
|
|
32
|
+
const TestComponent = defineComponent({
|
|
33
|
+
setup() {
|
|
34
|
+
const { agent } = useAgent({ agentId: "nonexistent" });
|
|
35
|
+
return { agent };
|
|
36
|
+
},
|
|
37
|
+
template: `<div data-testid="agent-id">{{ agent.agentId }}</div>`,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const Host = defineComponent({
|
|
41
|
+
components: { CopilotKitProvider, TestComponent },
|
|
42
|
+
template: `
|
|
43
|
+
<CopilotKitProvider runtime-url="http://localhost:59999/nonexistent">
|
|
44
|
+
<TestComponent />
|
|
45
|
+
</CopilotKitProvider>
|
|
46
|
+
`,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
render(Host, {
|
|
50
|
+
global: {
|
|
51
|
+
config: {
|
|
52
|
+
errorHandler: (error) => {
|
|
53
|
+
capturedErrors.push(error);
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// Should render without crashing — agent is provisional
|
|
60
|
+
const el = await screen.findByTestId("agent-id");
|
|
61
|
+
expect(el.textContent).toBe("nonexistent");
|
|
62
|
+
expect(capturedErrors).toEqual([]);
|
|
63
|
+
});
|
|
64
|
+
});
|