@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,65 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { TranscriptionErrorCode } from "@copilotkit/shared";
|
|
3
|
+
import type { TranscriptionError } from "../transcription-client";
|
|
4
|
+
import { transcribeAudio } from "../transcription-client";
|
|
5
|
+
import type { CopilotKitCoreVue } from "../vue-core";
|
|
6
|
+
|
|
7
|
+
describe("transcription-client", () => {
|
|
8
|
+
const originalFetch = globalThis.fetch;
|
|
9
|
+
|
|
10
|
+
afterEach(() => {
|
|
11
|
+
globalThis.fetch = originalFetch;
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("transcribes audio in REST mode", async () => {
|
|
15
|
+
globalThis.fetch = vi.fn().mockResolvedValue({
|
|
16
|
+
ok: true,
|
|
17
|
+
json: async () => ({
|
|
18
|
+
text: "Transcribed text",
|
|
19
|
+
size: 12,
|
|
20
|
+
type: "audio/webm",
|
|
21
|
+
}),
|
|
22
|
+
} satisfies Partial<Response>) as typeof fetch;
|
|
23
|
+
|
|
24
|
+
const result = await transcribeAudio(
|
|
25
|
+
{
|
|
26
|
+
runtimeUrl: "/api/copilotkit",
|
|
27
|
+
runtimeTransport: "rest",
|
|
28
|
+
headers: {},
|
|
29
|
+
} as CopilotKitCoreVue,
|
|
30
|
+
new Blob(["audio"], { type: "audio/webm" }),
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
expect(globalThis.fetch).toHaveBeenCalledTimes(1);
|
|
34
|
+
expect(result.text).toBe("Transcribed text");
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("maps structured error responses to TranscriptionError", async () => {
|
|
38
|
+
globalThis.fetch = vi.fn().mockResolvedValue({
|
|
39
|
+
ok: false,
|
|
40
|
+
status: 429,
|
|
41
|
+
statusText: "Too Many Requests",
|
|
42
|
+
json: async () => ({
|
|
43
|
+
error: TranscriptionErrorCode.RATE_LIMITED,
|
|
44
|
+
message: "Rate limited",
|
|
45
|
+
retryable: true,
|
|
46
|
+
}),
|
|
47
|
+
} satisfies Partial<Response>) as typeof fetch;
|
|
48
|
+
|
|
49
|
+
await expect(
|
|
50
|
+
transcribeAudio(
|
|
51
|
+
{
|
|
52
|
+
runtimeUrl: "/api/copilotkit",
|
|
53
|
+
runtimeTransport: "rest",
|
|
54
|
+
headers: {},
|
|
55
|
+
} as CopilotKitCoreVue,
|
|
56
|
+
new Blob(["audio"], { type: "audio/webm" }),
|
|
57
|
+
),
|
|
58
|
+
).rejects.toMatchObject({
|
|
59
|
+
info: {
|
|
60
|
+
code: TranscriptionErrorCode.RATE_LIMITED,
|
|
61
|
+
retryable: true,
|
|
62
|
+
},
|
|
63
|
+
} satisfies Partial<TranscriptionError>);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export function extractCompleteStyles(html: string): string {
|
|
2
|
+
const matches = html.match(/<style\b[^>]*>[\s\S]*?<\/style>/gi);
|
|
3
|
+
return matches ? matches.join("") : "";
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export function processPartialHtml(html: string): string {
|
|
7
|
+
let result = html;
|
|
8
|
+
|
|
9
|
+
result = result.replace(/<[^>]*$/, "");
|
|
10
|
+
result = result.replace(/<(style|script|head)\b[^>]*>[\s\S]*?<\/\1>/gi, "");
|
|
11
|
+
result = result.replace(/<(style|script|head)\b[^>]*>[\s\S]*$/gi, "");
|
|
12
|
+
result = result.replace(/&[a-zA-Z0-9#]*$/, "");
|
|
13
|
+
|
|
14
|
+
const bodyMatch = result.match(/<body[^>]*>([\s\S]*)/i);
|
|
15
|
+
if (bodyMatch) {
|
|
16
|
+
result = bodyMatch[1]!;
|
|
17
|
+
result = result.replace(/<\/body>[\s\S]*/i, "");
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { shallowRef, toValue, watch } from "vue";
|
|
2
|
+
import type { MaybeRefOrGetter, ShallowRef } from "vue";
|
|
3
|
+
|
|
4
|
+
function shallowEqualObjects(
|
|
5
|
+
first: Record<string, unknown>,
|
|
6
|
+
second: Record<string, unknown>,
|
|
7
|
+
): boolean {
|
|
8
|
+
const firstKeys = Object.keys(first);
|
|
9
|
+
const secondKeys = Object.keys(second);
|
|
10
|
+
if (firstKeys.length !== secondKeys.length) return false;
|
|
11
|
+
|
|
12
|
+
for (const key of firstKeys) {
|
|
13
|
+
if (first[key] !== second[key]) return false;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function isPlainObject(value: unknown): value is Record<string, unknown> {
|
|
20
|
+
return (
|
|
21
|
+
value !== null &&
|
|
22
|
+
typeof value === "object" &&
|
|
23
|
+
Object.prototype.toString.call(value) === "[object Object]"
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Keeps reference identity stable for shallow-equal plain-object inputs.
|
|
29
|
+
* Non-plain objects keep strict reference equality semantics.
|
|
30
|
+
*/
|
|
31
|
+
export function useShallowStableRef<T>(
|
|
32
|
+
value: MaybeRefOrGetter<T>,
|
|
33
|
+
): Readonly<ShallowRef<T>> {
|
|
34
|
+
const stable = shallowRef(toValue(value)) as ShallowRef<T>;
|
|
35
|
+
|
|
36
|
+
watch(
|
|
37
|
+
() => toValue(value),
|
|
38
|
+
(next) => {
|
|
39
|
+
const previous = stable.value;
|
|
40
|
+
if (previous === next) return;
|
|
41
|
+
|
|
42
|
+
if (isPlainObject(previous) && isPlainObject(next)) {
|
|
43
|
+
if (shallowEqualObjects(previous, next)) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
stable.value = next;
|
|
49
|
+
},
|
|
50
|
+
{ immediate: true },
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
return stable;
|
|
54
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import type { CopilotKitCoreVue } from "./vue-core";
|
|
2
|
+
import { TranscriptionErrorCode } from "@copilotkit/shared";
|
|
3
|
+
import type { TranscriptionErrorResponse } from "@copilotkit/shared";
|
|
4
|
+
|
|
5
|
+
export interface TranscriptionResult {
|
|
6
|
+
text: string;
|
|
7
|
+
size: number;
|
|
8
|
+
type: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface TranscriptionErrorInfo {
|
|
12
|
+
code: TranscriptionErrorCode;
|
|
13
|
+
message: string;
|
|
14
|
+
retryable: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { TranscriptionErrorCode };
|
|
18
|
+
|
|
19
|
+
async function blobToBase64(blob: Blob): Promise<string> {
|
|
20
|
+
return await new Promise((resolve, reject) => {
|
|
21
|
+
const reader = new FileReader();
|
|
22
|
+
reader.onloadend = () => {
|
|
23
|
+
const result = reader.result as string;
|
|
24
|
+
resolve(result.split(",")[1] ?? "");
|
|
25
|
+
};
|
|
26
|
+
reader.addEventListener("error", () =>
|
|
27
|
+
reject(new Error("Failed to read audio data")),
|
|
28
|
+
);
|
|
29
|
+
reader.readAsDataURL(blob);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function isTranscriptionErrorResponse(
|
|
34
|
+
data: unknown,
|
|
35
|
+
): data is TranscriptionErrorResponse {
|
|
36
|
+
return (
|
|
37
|
+
typeof data === "object" &&
|
|
38
|
+
data !== null &&
|
|
39
|
+
"error" in data &&
|
|
40
|
+
"message" in data &&
|
|
41
|
+
typeof (data as TranscriptionErrorResponse).error === "string" &&
|
|
42
|
+
typeof (data as TranscriptionErrorResponse).message === "string"
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function parseTranscriptionError(
|
|
47
|
+
response: TranscriptionErrorResponse,
|
|
48
|
+
): TranscriptionErrorInfo {
|
|
49
|
+
return {
|
|
50
|
+
code: response.error,
|
|
51
|
+
message: response.message,
|
|
52
|
+
retryable: response.retryable ?? false,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export class TranscriptionError extends Error {
|
|
57
|
+
public readonly info: TranscriptionErrorInfo;
|
|
58
|
+
|
|
59
|
+
constructor(info: TranscriptionErrorInfo) {
|
|
60
|
+
super(info.message);
|
|
61
|
+
this.name = "TranscriptionError";
|
|
62
|
+
this.info = info;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export async function transcribeAudio(
|
|
67
|
+
core: CopilotKitCoreVue,
|
|
68
|
+
audioBlob: Blob,
|
|
69
|
+
filename: string = "recording.webm",
|
|
70
|
+
): Promise<TranscriptionResult> {
|
|
71
|
+
const runtimeUrl = core.runtimeUrl;
|
|
72
|
+
if (!runtimeUrl) {
|
|
73
|
+
throw new TranscriptionError({
|
|
74
|
+
code: TranscriptionErrorCode.INVALID_REQUEST,
|
|
75
|
+
message: "Runtime URL is not configured",
|
|
76
|
+
retryable: false,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const headers: Record<string, string> = { ...core.headers };
|
|
81
|
+
let response: Response;
|
|
82
|
+
|
|
83
|
+
try {
|
|
84
|
+
if (core.runtimeTransport === "single") {
|
|
85
|
+
const base64Audio = await blobToBase64(audioBlob);
|
|
86
|
+
|
|
87
|
+
headers["Content-Type"] = "application/json";
|
|
88
|
+
|
|
89
|
+
response = await fetch(runtimeUrl, {
|
|
90
|
+
method: "POST",
|
|
91
|
+
headers,
|
|
92
|
+
body: JSON.stringify({
|
|
93
|
+
method: "transcribe",
|
|
94
|
+
body: {
|
|
95
|
+
audio: base64Audio,
|
|
96
|
+
mimeType: audioBlob.type || "audio/webm",
|
|
97
|
+
filename,
|
|
98
|
+
},
|
|
99
|
+
}),
|
|
100
|
+
});
|
|
101
|
+
} else {
|
|
102
|
+
delete headers["Content-Type"];
|
|
103
|
+
|
|
104
|
+
const formData = new FormData();
|
|
105
|
+
formData.append("audio", audioBlob, filename);
|
|
106
|
+
|
|
107
|
+
response = await fetch(`${runtimeUrl}/transcribe`, {
|
|
108
|
+
method: "POST",
|
|
109
|
+
headers,
|
|
110
|
+
body: formData,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
} catch (error) {
|
|
114
|
+
throw new TranscriptionError({
|
|
115
|
+
code: TranscriptionErrorCode.NETWORK_ERROR,
|
|
116
|
+
message:
|
|
117
|
+
error instanceof Error ? error.message : "Network request failed",
|
|
118
|
+
retryable: true,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (!response.ok) {
|
|
123
|
+
let errorData: unknown;
|
|
124
|
+
try {
|
|
125
|
+
errorData = await response.json();
|
|
126
|
+
} catch {
|
|
127
|
+
throw new TranscriptionError({
|
|
128
|
+
code: TranscriptionErrorCode.PROVIDER_ERROR,
|
|
129
|
+
message: `HTTP ${response.status}: ${response.statusText}`,
|
|
130
|
+
retryable: response.status >= 500,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (isTranscriptionErrorResponse(errorData)) {
|
|
135
|
+
throw new TranscriptionError(parseTranscriptionError(errorData));
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
throw new TranscriptionError({
|
|
139
|
+
code: TranscriptionErrorCode.PROVIDER_ERROR,
|
|
140
|
+
message:
|
|
141
|
+
typeof errorData === "object" &&
|
|
142
|
+
errorData !== null &&
|
|
143
|
+
"message" in errorData
|
|
144
|
+
? String((errorData as { message: unknown }).message)
|
|
145
|
+
: "Transcription failed",
|
|
146
|
+
retryable: response.status >= 500,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return (await response.json()) as TranscriptionResult;
|
|
151
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { nextTick } from "vue";
|
|
2
|
+
import type {
|
|
3
|
+
VueActivityMessageRenderer,
|
|
4
|
+
VueToolCallRenderer,
|
|
5
|
+
VueCustomMessageRenderer,
|
|
6
|
+
} from "../types";
|
|
7
|
+
import type { InterruptRenderProps } from "../types/interrupt";
|
|
8
|
+
import { CopilotKitCore } from "@copilotkit/core";
|
|
9
|
+
import type {
|
|
10
|
+
CopilotKitCoreConfig,
|
|
11
|
+
CopilotKitCoreSubscriber,
|
|
12
|
+
CopilotKitCoreSubscription,
|
|
13
|
+
} from "@copilotkit/core";
|
|
14
|
+
|
|
15
|
+
export interface CopilotKitCoreVueConfig extends CopilotKitCoreConfig {
|
|
16
|
+
renderToolCalls?: VueToolCallRenderer<unknown>[];
|
|
17
|
+
renderActivityMessages?: VueActivityMessageRenderer<unknown>[];
|
|
18
|
+
renderCustomMessages?: VueCustomMessageRenderer[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface CopilotKitCoreVueSubscriber extends CopilotKitCoreSubscriber {
|
|
22
|
+
onRenderToolCallsChanged?: (event: {
|
|
23
|
+
copilotkit: CopilotKitCoreVue;
|
|
24
|
+
renderToolCalls: VueToolCallRenderer<unknown>[];
|
|
25
|
+
}) => void | Promise<void>;
|
|
26
|
+
onRenderCustomMessagesChanged?: (event: {
|
|
27
|
+
copilotkit: CopilotKitCoreVue;
|
|
28
|
+
renderCustomMessages: VueCustomMessageRenderer[];
|
|
29
|
+
}) => void | Promise<void>;
|
|
30
|
+
onInterruptStateChanged?: (event: {
|
|
31
|
+
copilotkit: CopilotKitCoreVue;
|
|
32
|
+
interruptState: InterruptRenderProps<unknown, unknown> | null;
|
|
33
|
+
}) => void | Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export class CopilotKitCoreVue extends CopilotKitCore {
|
|
37
|
+
private _renderToolCalls: VueToolCallRenderer<unknown>[] = [];
|
|
38
|
+
private _hookRenderToolCalls: Map<string, VueToolCallRenderer<unknown>> =
|
|
39
|
+
new Map();
|
|
40
|
+
private _cachedMergedRenderToolCalls: VueToolCallRenderer<unknown>[] | null =
|
|
41
|
+
null;
|
|
42
|
+
private _renderCustomMessages: VueCustomMessageRenderer[] = [];
|
|
43
|
+
private _renderActivityMessages: VueActivityMessageRenderer<unknown>[] = [];
|
|
44
|
+
private _interruptState: InterruptRenderProps<unknown, unknown> | null = null;
|
|
45
|
+
|
|
46
|
+
constructor(config: CopilotKitCoreVueConfig) {
|
|
47
|
+
super(config);
|
|
48
|
+
this._renderToolCalls = config.renderToolCalls ?? [];
|
|
49
|
+
this._renderCustomMessages = config.renderCustomMessages ?? [];
|
|
50
|
+
this._renderActivityMessages = config.renderActivityMessages ?? [];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
get renderCustomMessages(): Readonly<VueCustomMessageRenderer[]> {
|
|
54
|
+
return this._renderCustomMessages;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
get renderActivityMessages(): Readonly<
|
|
58
|
+
VueActivityMessageRenderer<unknown>[]
|
|
59
|
+
> {
|
|
60
|
+
return this._renderActivityMessages;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
setRenderActivityMessages(
|
|
64
|
+
renderers: VueActivityMessageRenderer<unknown>[],
|
|
65
|
+
): void {
|
|
66
|
+
this._renderActivityMessages = [...renderers];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
setRenderCustomMessages(renderers: VueCustomMessageRenderer[]): void {
|
|
70
|
+
this._renderCustomMessages = [...renderers];
|
|
71
|
+
void this.notifySubscribers((subscriber) => {
|
|
72
|
+
const vueSubscriber = subscriber as CopilotKitCoreVueSubscriber;
|
|
73
|
+
vueSubscriber.onRenderCustomMessagesChanged?.({
|
|
74
|
+
copilotkit: this,
|
|
75
|
+
renderCustomMessages: [...this.renderCustomMessages],
|
|
76
|
+
});
|
|
77
|
+
}, "Subscriber onRenderCustomMessagesChanged error:");
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
get propRenderToolCalls(): Readonly<VueToolCallRenderer<unknown>[]> {
|
|
81
|
+
return this._renderToolCalls;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
get renderToolCalls(): Readonly<VueToolCallRenderer<unknown>[]> {
|
|
85
|
+
if (this._hookRenderToolCalls.size === 0) {
|
|
86
|
+
return this._renderToolCalls;
|
|
87
|
+
}
|
|
88
|
+
if (this._cachedMergedRenderToolCalls) {
|
|
89
|
+
return this._cachedMergedRenderToolCalls;
|
|
90
|
+
}
|
|
91
|
+
const merged = new Map<string, VueToolCallRenderer<unknown>>();
|
|
92
|
+
for (const rc of this._renderToolCalls) {
|
|
93
|
+
merged.set(`${rc.agentId ?? ""}:${rc.name}`, rc);
|
|
94
|
+
}
|
|
95
|
+
for (const [key, rc] of this._hookRenderToolCalls) {
|
|
96
|
+
merged.set(key, rc);
|
|
97
|
+
}
|
|
98
|
+
this._cachedMergedRenderToolCalls = Array.from(merged.values());
|
|
99
|
+
return this._cachedMergedRenderToolCalls;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
get interruptState(): InterruptRenderProps<unknown, unknown> | null {
|
|
103
|
+
return this._interruptState;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
setRenderToolCalls(renderToolCalls: VueToolCallRenderer<unknown>[]): void {
|
|
107
|
+
this._renderToolCalls = [...renderToolCalls];
|
|
108
|
+
this._cachedMergedRenderToolCalls = null;
|
|
109
|
+
this._notifyRenderToolCallsChanged();
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
addHookRenderToolCall(entry: VueToolCallRenderer<unknown>): void {
|
|
113
|
+
const key = `${entry.agentId ?? ""}:${entry.name}`;
|
|
114
|
+
this._hookRenderToolCalls.set(key, entry);
|
|
115
|
+
this._cachedMergedRenderToolCalls = null;
|
|
116
|
+
this._notifyRenderToolCallsChanged();
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
removeHookRenderToolCall(name: string, agentId?: string): void {
|
|
120
|
+
const key = `${agentId ?? ""}:${name}`;
|
|
121
|
+
if (this._hookRenderToolCalls.delete(key)) {
|
|
122
|
+
this._cachedMergedRenderToolCalls = null;
|
|
123
|
+
this._notifyRenderToolCallsChanged();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
private _notifyRenderToolCallsChanged(): void {
|
|
128
|
+
void this.notifySubscribers((subscriber) => {
|
|
129
|
+
const vueSubscriber = subscriber as CopilotKitCoreVueSubscriber;
|
|
130
|
+
if (vueSubscriber.onRenderToolCallsChanged) {
|
|
131
|
+
vueSubscriber.onRenderToolCallsChanged({
|
|
132
|
+
copilotkit: this,
|
|
133
|
+
renderToolCalls: [...this.renderToolCalls],
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}, "Subscriber onRenderToolCallsChanged error:");
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
setInterruptState(
|
|
140
|
+
interruptState: InterruptRenderProps<unknown, unknown> | null,
|
|
141
|
+
): void {
|
|
142
|
+
this._interruptState = interruptState;
|
|
143
|
+
void this.notifySubscribers((subscriber) => {
|
|
144
|
+
const vueSubscriber = subscriber as CopilotKitCoreVueSubscriber;
|
|
145
|
+
vueSubscriber.onInterruptStateChanged?.({
|
|
146
|
+
copilotkit: this,
|
|
147
|
+
interruptState: this._interruptState,
|
|
148
|
+
});
|
|
149
|
+
}, "Subscriber onInterruptStateChanged error:");
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
subscribe(
|
|
153
|
+
subscriber: CopilotKitCoreVueSubscriber,
|
|
154
|
+
): CopilotKitCoreSubscription {
|
|
155
|
+
return super.subscribe(subscriber);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
async waitForPendingFrameworkUpdates(): Promise<void> {
|
|
159
|
+
await nextTick();
|
|
160
|
+
}
|
|
161
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CopilotChatLabels } from "./types";
|
|
2
|
+
|
|
3
|
+
export interface CopilotChatConfigurationProviderProps {
|
|
4
|
+
labels?: Partial<CopilotChatLabels>;
|
|
5
|
+
agentId?: string;
|
|
6
|
+
threadId?: string;
|
|
7
|
+
/**
|
|
8
|
+
* Lets internal wrappers (e.g. a v1-style `CopilotKit` bridge that pipes a
|
|
9
|
+
* locally minted UUID through as `threadId`) declare that the supplied
|
|
10
|
+
* `threadId` is NOT a caller choice. When omitted, the provider infers
|
|
11
|
+
* explicitness from whether the `threadId` prop itself was supplied.
|
|
12
|
+
*/
|
|
13
|
+
hasExplicitThreadId?: boolean;
|
|
14
|
+
isModalDefaultOpen?: boolean;
|
|
15
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, inject, provide, ref } from "vue";
|
|
3
|
+
import type { ComputedRef } from "vue";
|
|
4
|
+
import { DEFAULT_AGENT_ID, randomUUID } from "@copilotkit/shared";
|
|
5
|
+
import { CopilotChatConfigurationKey } from "./keys";
|
|
6
|
+
import { CopilotChatDefaultLabels } from "./types";
|
|
7
|
+
import type { CopilotChatConfigurationValue, CopilotChatLabels } from "./types";
|
|
8
|
+
import type { CopilotChatConfigurationProviderProps } from "./CopilotChatConfigurationProvider.types";
|
|
9
|
+
import { useShallowStableRef } from "../lib/shallow-stable";
|
|
10
|
+
|
|
11
|
+
// Vue normalizes optional Boolean props to `false` when not supplied; declare
|
|
12
|
+
// `undefined` defaults so we can faithfully distinguish "caller passed false"
|
|
13
|
+
// from "caller did not pass the prop", matching React's prop semantics.
|
|
14
|
+
const props = withDefaults(
|
|
15
|
+
defineProps<CopilotChatConfigurationProviderProps>(),
|
|
16
|
+
{
|
|
17
|
+
hasExplicitThreadId: undefined,
|
|
18
|
+
isModalDefaultOpen: undefined,
|
|
19
|
+
},
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
const parentConfig = inject<ComputedRef<CopilotChatConfigurationValue> | null>(
|
|
23
|
+
CopilotChatConfigurationKey,
|
|
24
|
+
null,
|
|
25
|
+
);
|
|
26
|
+
const parentConfigValue = computed(() => parentConfig?.value ?? null);
|
|
27
|
+
const stableLabels = useShallowStableRef(computed(() => props.labels));
|
|
28
|
+
|
|
29
|
+
const mergedLabels = computed<CopilotChatLabels>(() => ({
|
|
30
|
+
...CopilotChatDefaultLabels,
|
|
31
|
+
...parentConfigValue.value?.labels,
|
|
32
|
+
...stableLabels.value,
|
|
33
|
+
}));
|
|
34
|
+
|
|
35
|
+
const resolvedAgentId = computed(
|
|
36
|
+
() => props.agentId ?? parentConfigValue.value?.agentId ?? DEFAULT_AGENT_ID,
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const fallbackThreadId = randomUUID();
|
|
40
|
+
const resolvedThreadId = computed(() => {
|
|
41
|
+
if (props.threadId) return props.threadId;
|
|
42
|
+
if (parentConfigValue.value?.threadId)
|
|
43
|
+
return parentConfigValue.value.threadId;
|
|
44
|
+
return fallbackThreadId;
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const resolvedHasExplicitThreadId = computed(() => {
|
|
48
|
+
const ownExplicit =
|
|
49
|
+
props.hasExplicitThreadId !== undefined
|
|
50
|
+
? props.hasExplicitThreadId
|
|
51
|
+
: !!props.threadId;
|
|
52
|
+
return ownExplicit || !!parentConfigValue.value?.hasExplicitThreadId;
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const shouldCreateModalState = computed(
|
|
56
|
+
() => props.isModalDefaultOpen !== undefined,
|
|
57
|
+
);
|
|
58
|
+
const resolvedDefaultOpen = computed(
|
|
59
|
+
() => props.isModalDefaultOpen ?? true,
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
const internalModalOpen = ref<boolean>(
|
|
63
|
+
parentConfigValue.value?.isModalOpen ?? resolvedDefaultOpen.value,
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
function setInternalModalOpen(open: boolean) {
|
|
67
|
+
internalModalOpen.value = open;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const resolvedIsModalOpen = computed(() =>
|
|
71
|
+
shouldCreateModalState.value
|
|
72
|
+
? internalModalOpen.value
|
|
73
|
+
: parentConfigValue.value?.isModalOpen,
|
|
74
|
+
);
|
|
75
|
+
const resolvedSetModalOpen = computed(() =>
|
|
76
|
+
shouldCreateModalState.value
|
|
77
|
+
? setInternalModalOpen
|
|
78
|
+
: parentConfigValue.value?.setModalOpen,
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
const configurationValue = computed<CopilotChatConfigurationValue>(() => ({
|
|
82
|
+
labels: mergedLabels.value,
|
|
83
|
+
agentId: resolvedAgentId.value,
|
|
84
|
+
threadId: resolvedThreadId.value,
|
|
85
|
+
hasExplicitThreadId: resolvedHasExplicitThreadId.value,
|
|
86
|
+
isModalOpen: resolvedIsModalOpen.value,
|
|
87
|
+
setModalOpen: resolvedSetModalOpen.value,
|
|
88
|
+
}));
|
|
89
|
+
|
|
90
|
+
provide(CopilotChatConfigurationKey, configurationValue);
|
|
91
|
+
</script>
|
|
92
|
+
|
|
93
|
+
<template>
|
|
94
|
+
<slot />
|
|
95
|
+
</template>
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { AbstractAgent } from "@ag-ui/client";
|
|
2
|
+
import type { CopilotKitCoreErrorCode } from "@copilotkit/core";
|
|
3
|
+
import type { DebugConfig } from "@copilotkit/shared";
|
|
4
|
+
import type {
|
|
5
|
+
A2UITheme,
|
|
6
|
+
SandboxFunction,
|
|
7
|
+
VueActivityMessageRenderer,
|
|
8
|
+
VueCustomMessageRenderer,
|
|
9
|
+
VueFrontendTool,
|
|
10
|
+
VueHumanInTheLoop,
|
|
11
|
+
VueToolCallRenderer,
|
|
12
|
+
} from "../types";
|
|
13
|
+
import type { Component } from "vue";
|
|
14
|
+
|
|
15
|
+
export interface CopilotKitProviderProps {
|
|
16
|
+
runtimeUrl?: string;
|
|
17
|
+
headers?: Record<string, string> | (() => Record<string, string>);
|
|
18
|
+
credentials?: RequestCredentials;
|
|
19
|
+
defaultThrottleMs?: number;
|
|
20
|
+
publicApiKey?: string;
|
|
21
|
+
publicLicenseKey?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Signed license token for offline verification of premium features.
|
|
24
|
+
* Obtain from https://cloud.copilotkit.ai.
|
|
25
|
+
*/
|
|
26
|
+
licenseToken?: string;
|
|
27
|
+
properties?: Record<string, unknown>;
|
|
28
|
+
useSingleEndpoint?: boolean;
|
|
29
|
+
agents__unsafe_dev_only?: Record<string, AbstractAgent>;
|
|
30
|
+
selfManagedAgents?: Record<string, AbstractAgent>;
|
|
31
|
+
renderToolCalls?: VueToolCallRenderer<any>[];
|
|
32
|
+
renderActivityMessages?: VueActivityMessageRenderer<unknown>[];
|
|
33
|
+
renderCustomMessages?: VueCustomMessageRenderer[];
|
|
34
|
+
frontendTools?: VueFrontendTool[];
|
|
35
|
+
humanInTheLoop?: VueHumanInTheLoop[];
|
|
36
|
+
openGenerativeUI?: {
|
|
37
|
+
sandboxFunctions?: SandboxFunction[];
|
|
38
|
+
designSkill?: string;
|
|
39
|
+
};
|
|
40
|
+
showDevConsole?: boolean | "auto";
|
|
41
|
+
onError?: (event: {
|
|
42
|
+
error: Error;
|
|
43
|
+
code: CopilotKitCoreErrorCode;
|
|
44
|
+
context: Record<string, any>;
|
|
45
|
+
}) => void | Promise<void>;
|
|
46
|
+
a2ui?: {
|
|
47
|
+
theme?: A2UITheme;
|
|
48
|
+
catalog?: any;
|
|
49
|
+
loadingComponent?: Component;
|
|
50
|
+
includeSchema?: boolean;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Default anchor corner for the inspector button and window.
|
|
54
|
+
* Only used on first load before the user drags to a custom position.
|
|
55
|
+
* Defaults to `{ horizontal: "right", vertical: "top" }`.
|
|
56
|
+
*/
|
|
57
|
+
inspectorDefaultAnchor?: { horizontal: "left" | "right"; vertical: "top" | "bottom" };
|
|
58
|
+
/**
|
|
59
|
+
* Enable debug logging for the client-side event pipeline.
|
|
60
|
+
*
|
|
61
|
+
* Accepts:
|
|
62
|
+
* - `true` / `false` to toggle events + lifecycle logging (verbose off).
|
|
63
|
+
* - `{ events?: boolean; lifecycle?: boolean; verbose?: boolean }` for granular control.
|
|
64
|
+
*/
|
|
65
|
+
debug?: DebugConfig;
|
|
66
|
+
}
|