@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,391 @@
|
|
|
1
|
+
import { AbstractAgent, EventType } from "@ag-ui/client";
|
|
2
|
+
import type {
|
|
3
|
+
AgentSubscriber,
|
|
4
|
+
BaseEvent,
|
|
5
|
+
Message,
|
|
6
|
+
RunAgentInput,
|
|
7
|
+
RunAgentParameters,
|
|
8
|
+
RunAgentResult,
|
|
9
|
+
} from "@ag-ui/client";
|
|
10
|
+
import type { Suggestion } from "@copilotkit/core";
|
|
11
|
+
import { randomUUID } from "@copilotkit/shared";
|
|
12
|
+
|
|
13
|
+
export function toolCallMessage(
|
|
14
|
+
toolCallName: string,
|
|
15
|
+
args: unknown = {},
|
|
16
|
+
id?: string,
|
|
17
|
+
): Message {
|
|
18
|
+
return {
|
|
19
|
+
id: id ?? randomUUID(),
|
|
20
|
+
role: "assistant",
|
|
21
|
+
content: "",
|
|
22
|
+
toolCalls: [
|
|
23
|
+
{
|
|
24
|
+
id: randomUUID(),
|
|
25
|
+
type: "function",
|
|
26
|
+
function: {
|
|
27
|
+
name: toolCallName,
|
|
28
|
+
arguments: JSON.stringify(args),
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
} as Message;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export class StateCapturingAgent extends AbstractAgent {
|
|
36
|
+
public lastRunInput: RunAgentInput | undefined;
|
|
37
|
+
private outcomes: RunAgentResult[];
|
|
38
|
+
|
|
39
|
+
constructor(outcomes: RunAgentResult[] = [], agentId = "default") {
|
|
40
|
+
super({ agentId });
|
|
41
|
+
this.outcomes = [...outcomes];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
run(): any {
|
|
45
|
+
throw new Error("StateCapturingAgent.run() should not be used in tests");
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
enqueueOutcome(outcome: RunAgentResult): void {
|
|
49
|
+
this.outcomes.push(outcome);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
override clone(): StateCapturingAgent {
|
|
53
|
+
const cloned = new StateCapturingAgent(
|
|
54
|
+
this.outcomes,
|
|
55
|
+
this.agentId ?? "default",
|
|
56
|
+
);
|
|
57
|
+
cloned.threadId = this.threadId;
|
|
58
|
+
cloned.messages = JSON.parse(JSON.stringify(this.messages));
|
|
59
|
+
cloned.state = JSON.parse(JSON.stringify(this.state));
|
|
60
|
+
cloned.isRunning = this.isRunning;
|
|
61
|
+
cloned.lastRunInput = this.lastRunInput
|
|
62
|
+
? JSON.parse(JSON.stringify(this.lastRunInput))
|
|
63
|
+
: undefined;
|
|
64
|
+
return cloned;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
override async runAgent(
|
|
68
|
+
parameters: RunAgentParameters = {},
|
|
69
|
+
subscriber?: AgentSubscriber,
|
|
70
|
+
): Promise<RunAgentResult> {
|
|
71
|
+
const input = this.prepareRunAgentInput(parameters);
|
|
72
|
+
this.lastRunInput = input;
|
|
73
|
+
|
|
74
|
+
this.isRunning = true;
|
|
75
|
+
await subscriber?.onRunInitialized?.({
|
|
76
|
+
agent: this,
|
|
77
|
+
messages: this.messages,
|
|
78
|
+
state: this.state,
|
|
79
|
+
input,
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const outcome = this.outcomes.shift() ?? { newMessages: [] };
|
|
83
|
+
|
|
84
|
+
if (outcome.newMessages.length > 0) {
|
|
85
|
+
for (const msg of outcome.newMessages) {
|
|
86
|
+
this.addMessage(msg);
|
|
87
|
+
}
|
|
88
|
+
await subscriber?.onMessagesChanged?.({
|
|
89
|
+
agent: this,
|
|
90
|
+
messages: this.messages,
|
|
91
|
+
state: this.state,
|
|
92
|
+
input,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
await subscriber?.onRunFinalized?.({
|
|
97
|
+
agent: this,
|
|
98
|
+
messages: this.messages,
|
|
99
|
+
state: this.state,
|
|
100
|
+
input,
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
this.isRunning = false;
|
|
104
|
+
return outcome;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
override async connectAgent(
|
|
108
|
+
_parameters: RunAgentParameters = {},
|
|
109
|
+
_subscriber?: AgentSubscriber,
|
|
110
|
+
): Promise<RunAgentResult> {
|
|
111
|
+
return { newMessages: [] };
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export class SuggestionsProviderAgent extends AbstractAgent {
|
|
116
|
+
constructor(
|
|
117
|
+
private responses: Suggestion[],
|
|
118
|
+
agentId = "default",
|
|
119
|
+
) {
|
|
120
|
+
super({ agentId });
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
setResponses(responses: Suggestion[]): void {
|
|
124
|
+
this.responses = responses;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
run(): any {
|
|
128
|
+
throw new Error(
|
|
129
|
+
"SuggestionsProviderAgent.run() should not be used in tests",
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
override clone(): SuggestionsProviderAgent {
|
|
134
|
+
const cloned = new SuggestionsProviderAgent(
|
|
135
|
+
this.responses,
|
|
136
|
+
this.agentId ?? "default",
|
|
137
|
+
);
|
|
138
|
+
cloned.threadId = this.threadId;
|
|
139
|
+
cloned.messages = JSON.parse(JSON.stringify(this.messages));
|
|
140
|
+
cloned.state = JSON.parse(JSON.stringify(this.state));
|
|
141
|
+
cloned.isRunning = this.isRunning;
|
|
142
|
+
return cloned;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
override async runAgent(
|
|
146
|
+
parameters: RunAgentParameters = {},
|
|
147
|
+
subscriber?: AgentSubscriber,
|
|
148
|
+
): Promise<RunAgentResult> {
|
|
149
|
+
const input = this.prepareRunAgentInput(parameters);
|
|
150
|
+
this.isRunning = true;
|
|
151
|
+
|
|
152
|
+
await subscriber?.onRunInitialized?.({
|
|
153
|
+
agent: this,
|
|
154
|
+
messages: this.messages,
|
|
155
|
+
state: this.state,
|
|
156
|
+
input,
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
const suggestionMessage: Message = {
|
|
160
|
+
id: randomUUID(),
|
|
161
|
+
role: "assistant",
|
|
162
|
+
content: "",
|
|
163
|
+
toolCalls: [
|
|
164
|
+
{
|
|
165
|
+
id: randomUUID(),
|
|
166
|
+
type: "function",
|
|
167
|
+
function: {
|
|
168
|
+
name: "copilotkitSuggest",
|
|
169
|
+
arguments: JSON.stringify({ suggestions: this.responses }),
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
],
|
|
173
|
+
} as Message;
|
|
174
|
+
|
|
175
|
+
this.addMessage(suggestionMessage);
|
|
176
|
+
|
|
177
|
+
await subscriber?.onMessagesChanged?.({
|
|
178
|
+
agent: this,
|
|
179
|
+
messages: this.messages,
|
|
180
|
+
state: this.state,
|
|
181
|
+
input,
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
await subscriber?.onRunFinalized?.({
|
|
185
|
+
agent: this,
|
|
186
|
+
messages: this.messages,
|
|
187
|
+
state: this.state,
|
|
188
|
+
input,
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
this.isRunning = false;
|
|
192
|
+
return { newMessages: [suggestionMessage], result: undefined };
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export class SequencedRunAgent extends AbstractAgent {
|
|
197
|
+
private handlers: Array<
|
|
198
|
+
(input: RunAgentInput) => Promise<RunAgentResult> | RunAgentResult
|
|
199
|
+
>;
|
|
200
|
+
|
|
201
|
+
constructor(
|
|
202
|
+
handlers: Array<
|
|
203
|
+
(input: RunAgentInput) => Promise<RunAgentResult> | RunAgentResult
|
|
204
|
+
>,
|
|
205
|
+
agentId = "default",
|
|
206
|
+
) {
|
|
207
|
+
super({ agentId });
|
|
208
|
+
this.handlers = [...handlers];
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
run(): any {
|
|
212
|
+
throw new Error("SequencedRunAgent.run() should not be used in tests");
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
override clone(): SequencedRunAgent {
|
|
216
|
+
const cloned = new SequencedRunAgent(
|
|
217
|
+
this.handlers,
|
|
218
|
+
this.agentId ?? "default",
|
|
219
|
+
);
|
|
220
|
+
cloned.threadId = this.threadId;
|
|
221
|
+
cloned.messages = JSON.parse(JSON.stringify(this.messages));
|
|
222
|
+
cloned.state = JSON.parse(JSON.stringify(this.state));
|
|
223
|
+
cloned.isRunning = this.isRunning;
|
|
224
|
+
return cloned;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
override async runAgent(
|
|
228
|
+
parameters: RunAgentParameters = {},
|
|
229
|
+
subscriber?: AgentSubscriber,
|
|
230
|
+
): Promise<RunAgentResult> {
|
|
231
|
+
const input = this.prepareRunAgentInput(parameters);
|
|
232
|
+
this.isRunning = true;
|
|
233
|
+
|
|
234
|
+
await subscriber?.onRunInitialized?.({
|
|
235
|
+
agent: this,
|
|
236
|
+
messages: this.messages,
|
|
237
|
+
state: this.state,
|
|
238
|
+
input,
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
const fn = this.handlers.shift();
|
|
242
|
+
const outcome = fn ? await fn(input) : { newMessages: [] };
|
|
243
|
+
|
|
244
|
+
for (const msg of outcome.newMessages) {
|
|
245
|
+
this.addMessage(msg);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
await subscriber?.onMessagesChanged?.({
|
|
249
|
+
agent: this,
|
|
250
|
+
messages: this.messages,
|
|
251
|
+
state: this.state,
|
|
252
|
+
input,
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
await subscriber?.onRunFinalized?.({
|
|
256
|
+
agent: this,
|
|
257
|
+
messages: this.messages,
|
|
258
|
+
state: this.state,
|
|
259
|
+
input,
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
this.isRunning = false;
|
|
263
|
+
return outcome;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export class MockStepwiseAgent extends AbstractAgent {
|
|
268
|
+
private readonly streamSubscribers = new Set<{
|
|
269
|
+
next?: (event: BaseEvent) => void;
|
|
270
|
+
error?: (error: unknown) => void;
|
|
271
|
+
complete?: () => void;
|
|
272
|
+
}>();
|
|
273
|
+
|
|
274
|
+
emit(event: BaseEvent): void {
|
|
275
|
+
if (event.type === EventType.RUN_STARTED) {
|
|
276
|
+
this.isRunning = true;
|
|
277
|
+
} else if (
|
|
278
|
+
event.type === EventType.RUN_FINISHED ||
|
|
279
|
+
event.type === EventType.RUN_ERROR
|
|
280
|
+
) {
|
|
281
|
+
this.isRunning = false;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
for (const subscriber of this.streamSubscribers) {
|
|
285
|
+
subscriber.next?.(event);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
complete(): void {
|
|
290
|
+
this.isRunning = false;
|
|
291
|
+
for (const subscriber of this.streamSubscribers) {
|
|
292
|
+
subscriber.complete?.();
|
|
293
|
+
}
|
|
294
|
+
this.streamSubscribers.clear();
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
override clone(): MockStepwiseAgent {
|
|
298
|
+
const cloned = new (this.constructor as new () => MockStepwiseAgent)();
|
|
299
|
+
cloned.agentId = this.agentId;
|
|
300
|
+
(
|
|
301
|
+
cloned as unknown as {
|
|
302
|
+
streamSubscribers: Set<{
|
|
303
|
+
next?: (event: BaseEvent) => void;
|
|
304
|
+
error?: (error: unknown) => void;
|
|
305
|
+
complete?: () => void;
|
|
306
|
+
}>;
|
|
307
|
+
}
|
|
308
|
+
).streamSubscribers = this.streamSubscribers;
|
|
309
|
+
return cloned;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
override run(_input: RunAgentInput): any {
|
|
313
|
+
return {
|
|
314
|
+
subscribe: (observer: {
|
|
315
|
+
next?: (event: BaseEvent) => void;
|
|
316
|
+
error?: (error: unknown) => void;
|
|
317
|
+
complete?: () => void;
|
|
318
|
+
}) => {
|
|
319
|
+
this.streamSubscribers.add(observer);
|
|
320
|
+
return {
|
|
321
|
+
unsubscribe: () => {
|
|
322
|
+
this.streamSubscribers.delete(observer);
|
|
323
|
+
},
|
|
324
|
+
};
|
|
325
|
+
},
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
export class MockMCPProxyAgent extends MockStepwiseAgent {
|
|
331
|
+
public runAgentCalls: Array<{ input: Partial<RunAgentInput> }> = [];
|
|
332
|
+
private readonly runAgentResponses = new Map<string, unknown>();
|
|
333
|
+
|
|
334
|
+
setRunAgentResponse(method: string, response: unknown): void {
|
|
335
|
+
this.runAgentResponses.set(method, response);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
override async runAgent(
|
|
339
|
+
input?: Partial<RunAgentInput>,
|
|
340
|
+
): Promise<RunAgentResult> {
|
|
341
|
+
const proxiedRequest = input?.forwardedProps?.__proxiedMCPRequest as
|
|
342
|
+
| {
|
|
343
|
+
serverHash?: string;
|
|
344
|
+
serverId?: string;
|
|
345
|
+
method: string;
|
|
346
|
+
params?: Record<string, unknown>;
|
|
347
|
+
}
|
|
348
|
+
| undefined;
|
|
349
|
+
|
|
350
|
+
if (!proxiedRequest) {
|
|
351
|
+
return super.runAgent(input);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
if (input) {
|
|
355
|
+
this.runAgentCalls.push({ input });
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
const method = proxiedRequest.method;
|
|
359
|
+
const response = this.runAgentResponses.get(method);
|
|
360
|
+
if (response !== undefined) {
|
|
361
|
+
return { result: response, newMessages: [] };
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
if (method === "resources/read") {
|
|
365
|
+
return {
|
|
366
|
+
result: {
|
|
367
|
+
contents: [
|
|
368
|
+
{
|
|
369
|
+
uri: proxiedRequest.params?.uri,
|
|
370
|
+
mimeType: "text/html",
|
|
371
|
+
text: "<html><body>Test content</body></html>",
|
|
372
|
+
},
|
|
373
|
+
],
|
|
374
|
+
},
|
|
375
|
+
newMessages: [],
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
if (method === "tools/call") {
|
|
380
|
+
return {
|
|
381
|
+
result: {
|
|
382
|
+
content: [{ type: "text", text: "Tool call result" }],
|
|
383
|
+
isError: false,
|
|
384
|
+
},
|
|
385
|
+
newMessages: [],
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
return { result: {}, newMessages: [] };
|
|
390
|
+
}
|
|
391
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { mount } from "@vue/test-utils";
|
|
2
|
+
import type { VueWrapper } from "@vue/test-utils";
|
|
3
|
+
import { defineComponent, h } from "vue";
|
|
4
|
+
import type { VNode } from "vue";
|
|
5
|
+
import type { AbstractAgent } from "@ag-ui/client";
|
|
6
|
+
import CopilotKitProvider from "../../providers/CopilotKitProvider.vue";
|
|
7
|
+
import CopilotChatConfigurationProvider from "../../providers/CopilotChatConfigurationProvider.vue";
|
|
8
|
+
import { useCopilotKit } from "../../providers/useCopilotKit";
|
|
9
|
+
import type { CopilotKitCoreVue } from "../../lib/vue-core";
|
|
10
|
+
|
|
11
|
+
export function mountWithProvider(
|
|
12
|
+
content: () => VNode,
|
|
13
|
+
props: Record<string, unknown> = {},
|
|
14
|
+
): { wrapper: VueWrapper; getCore: () => CopilotKitCoreVue } {
|
|
15
|
+
let core: CopilotKitCoreVue | undefined;
|
|
16
|
+
|
|
17
|
+
const Probe = defineComponent({
|
|
18
|
+
setup() {
|
|
19
|
+
const { copilotkit } = useCopilotKit();
|
|
20
|
+
core = copilotkit.value;
|
|
21
|
+
return () => null;
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const wrapper = mount(CopilotKitProvider, {
|
|
26
|
+
props: {
|
|
27
|
+
runtimeUrl: "/api/copilotkit",
|
|
28
|
+
...props,
|
|
29
|
+
},
|
|
30
|
+
slots: {
|
|
31
|
+
default: () => h("div", [content(), h(Probe)]),
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
wrapper,
|
|
37
|
+
getCore: () => {
|
|
38
|
+
if (!core) {
|
|
39
|
+
throw new Error("CopilotKit core not available from provider mount");
|
|
40
|
+
}
|
|
41
|
+
return core;
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function renderWithCopilotKit(
|
|
47
|
+
content: () => VNode,
|
|
48
|
+
options: {
|
|
49
|
+
agent?: AbstractAgent;
|
|
50
|
+
agentId?: string;
|
|
51
|
+
threadId?: string;
|
|
52
|
+
providerProps?: Record<string, unknown>;
|
|
53
|
+
configProps?: Record<string, unknown>;
|
|
54
|
+
agents?: Record<string, AbstractAgent>;
|
|
55
|
+
} = {},
|
|
56
|
+
): { wrapper: VueWrapper; getCore: () => CopilotKitCoreVue } {
|
|
57
|
+
const providerProps = options.providerProps ?? {};
|
|
58
|
+
const resolvedAgentId = options.agentId ?? "default";
|
|
59
|
+
const resolvedThreadId = options.threadId ?? "test-thread";
|
|
60
|
+
const resolvedAgents =
|
|
61
|
+
options.agents ??
|
|
62
|
+
(options.agent ? { [resolvedAgentId]: options.agent } : undefined);
|
|
63
|
+
// Default `hasExplicitThreadId: false` so the implicit wrapping does not
|
|
64
|
+
// force callers into "caller picked this thread" mode. Tests that want
|
|
65
|
+
// explicit-thread semantics (e.g. `/connect` gating, welcome suppression)
|
|
66
|
+
// override `configProps` to set `hasExplicitThreadId: true`.
|
|
67
|
+
const configProps = options.configProps ?? {
|
|
68
|
+
threadId: resolvedThreadId,
|
|
69
|
+
agentId: resolvedAgentId,
|
|
70
|
+
hasExplicitThreadId: false,
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
return mountWithProvider(
|
|
74
|
+
() =>
|
|
75
|
+
h(CopilotChatConfigurationProvider, configProps, {
|
|
76
|
+
default: () => content(),
|
|
77
|
+
}),
|
|
78
|
+
{
|
|
79
|
+
agents__unsafe_dev_only: resolvedAgents,
|
|
80
|
+
...providerProps,
|
|
81
|
+
},
|
|
82
|
+
);
|
|
83
|
+
}
|