@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,295 @@
|
|
|
1
|
+
import { h, watch, type VNodeChild } from "vue";
|
|
2
|
+
import type { ShallowRef } from "vue";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import type { ToolCallStatus } from "@copilotkit/core";
|
|
5
|
+
import type { CopilotKitCoreVue } from "../../lib/vue-core";
|
|
6
|
+
import { defineToolCallRenderer } from "../../types/defineToolCallRenderer";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Tool name used by the dynamic A2UI generation secondary LLM.
|
|
10
|
+
* This renderer is auto-registered when A2UI is enabled.
|
|
11
|
+
*/
|
|
12
|
+
export const RENDER_A2UI_TOOL_NAME = "render_a2ui";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Registers the built-in `render_a2ui` tool call renderer via the props-based
|
|
16
|
+
* `setRenderToolCalls` mechanism (not `useRenderTool`).
|
|
17
|
+
*
|
|
18
|
+
* This ensures user-registered `useRenderTool({ name: "render_a2ui", ... })`
|
|
19
|
+
* hooks automatically override the built-in, since the merge logic in
|
|
20
|
+
* vue-core.ts gives hook-based entries priority over prop-based entries.
|
|
21
|
+
*
|
|
22
|
+
* Call from the provider's setup function and pass a cleanup callback.
|
|
23
|
+
*/
|
|
24
|
+
export function registerA2UIBuiltInToolCallRenderer(
|
|
25
|
+
copilotkit: ShallowRef<CopilotKitCoreVue>,
|
|
26
|
+
enabled: () => boolean,
|
|
27
|
+
): void {
|
|
28
|
+
watch(
|
|
29
|
+
[() => copilotkit.value, enabled],
|
|
30
|
+
([core, isEnabled], _prev, onCleanup) => {
|
|
31
|
+
if (!isEnabled) return;
|
|
32
|
+
|
|
33
|
+
const renderer = defineToolCallRenderer({
|
|
34
|
+
name: RENDER_A2UI_TOOL_NAME,
|
|
35
|
+
args: z.any(),
|
|
36
|
+
render: ({ status, args: parameters }: {
|
|
37
|
+
status: ToolCallStatus;
|
|
38
|
+
args: unknown;
|
|
39
|
+
[key: string]: unknown;
|
|
40
|
+
}): VNodeChild => {
|
|
41
|
+
if (status === "complete") return null;
|
|
42
|
+
const params = parameters as Record<string, unknown>;
|
|
43
|
+
// Hide skeleton once the A2UI surface has enough data to render.
|
|
44
|
+
const items = params?.items;
|
|
45
|
+
if (Array.isArray(items) && items.length > 0) return null;
|
|
46
|
+
const components = params?.components;
|
|
47
|
+
if (Array.isArray(components) && components.length > 2) return null;
|
|
48
|
+
return renderA2UIProgressIndicator(parameters);
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// Register via props-based mechanism so useRenderTool hooks take priority
|
|
53
|
+
const existing = core.propRenderToolCalls;
|
|
54
|
+
core.setRenderToolCalls([
|
|
55
|
+
...existing.filter(
|
|
56
|
+
(rc) => rc.name !== RENDER_A2UI_TOOL_NAME,
|
|
57
|
+
),
|
|
58
|
+
renderer,
|
|
59
|
+
]);
|
|
60
|
+
|
|
61
|
+
onCleanup(() => {
|
|
62
|
+
const current = core.propRenderToolCalls;
|
|
63
|
+
core.setRenderToolCalls(
|
|
64
|
+
current.filter(
|
|
65
|
+
(rc) => rc.name !== RENDER_A2UI_TOOL_NAME,
|
|
66
|
+
),
|
|
67
|
+
);
|
|
68
|
+
progressState.clear();
|
|
69
|
+
});
|
|
70
|
+
},
|
|
71
|
+
{ immediate: true },
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Vue render-function equivalent of the React A2UIProgressIndicator.
|
|
77
|
+
* Shows a skeleton wireframe that progressively reveals as tokens stream in.
|
|
78
|
+
*/
|
|
79
|
+
const progressState = new Map<string, { lastTime: number; lastTokens: number }>();
|
|
80
|
+
|
|
81
|
+
function renderA2UIProgressIndicator(parameters: unknown): VNodeChild {
|
|
82
|
+
const params = parameters as Record<string, unknown> | null | undefined;
|
|
83
|
+
const key = typeof params?.name === "string" ? params.name : "__default__";
|
|
84
|
+
let state = progressState.get(key);
|
|
85
|
+
if (!state) {
|
|
86
|
+
state = { lastTime: 0, lastTokens: 0 };
|
|
87
|
+
progressState.set(key, state);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const now = Date.now();
|
|
91
|
+
let tokens = state.lastTokens;
|
|
92
|
+
if (now - state.lastTime > 200) {
|
|
93
|
+
const chars = JSON.stringify(parameters ?? {}).length;
|
|
94
|
+
tokens = Math.round(chars / 4);
|
|
95
|
+
state.lastTime = now;
|
|
96
|
+
state.lastTokens = tokens;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const phase = tokens < 50 ? 0 : tokens < 200 ? 1 : tokens < 400 ? 2 : 3;
|
|
100
|
+
|
|
101
|
+
const dot = () =>
|
|
102
|
+
h("div", {
|
|
103
|
+
style: {
|
|
104
|
+
width: "7px",
|
|
105
|
+
height: "7px",
|
|
106
|
+
borderRadius: "50%",
|
|
107
|
+
backgroundColor: "#d4d4d8",
|
|
108
|
+
flexShrink: 0,
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
const spacer = () => h("div", { style: { width: "12px" } });
|
|
113
|
+
|
|
114
|
+
const bar = (
|
|
115
|
+
w: number,
|
|
116
|
+
ht: number,
|
|
117
|
+
bg: string,
|
|
118
|
+
anim?: number,
|
|
119
|
+
opacity?: number,
|
|
120
|
+
transition?: string,
|
|
121
|
+
) =>
|
|
122
|
+
h("div", {
|
|
123
|
+
style: {
|
|
124
|
+
width: `${w}px`,
|
|
125
|
+
height: `${ht}px`,
|
|
126
|
+
borderRadius: "9999px",
|
|
127
|
+
backgroundColor: bg,
|
|
128
|
+
...(anim !== undefined
|
|
129
|
+
? {
|
|
130
|
+
animation: `cpk-a2ui-fade 2.4s ease-in-out ${anim}s infinite`,
|
|
131
|
+
}
|
|
132
|
+
: {}),
|
|
133
|
+
...(opacity !== undefined ? { opacity } : {}),
|
|
134
|
+
...(transition ? { transition } : {}),
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
const row = (show: boolean, delay: number, children: VNodeChild[]) =>
|
|
139
|
+
h(
|
|
140
|
+
"div",
|
|
141
|
+
{
|
|
142
|
+
style: {
|
|
143
|
+
display: "flex",
|
|
144
|
+
alignItems: "center",
|
|
145
|
+
gap: "6px",
|
|
146
|
+
opacity: show ? 1 : 0,
|
|
147
|
+
transition: `opacity 0.4s ${delay}s`,
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
children,
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
return h("div", { style: { margin: "12px 0", maxWidth: "320px" } }, [
|
|
154
|
+
h(
|
|
155
|
+
"div",
|
|
156
|
+
{
|
|
157
|
+
style: {
|
|
158
|
+
position: "relative",
|
|
159
|
+
overflow: "hidden",
|
|
160
|
+
borderRadius: "12px",
|
|
161
|
+
border: "1px solid rgba(228,228,231,0.8)",
|
|
162
|
+
backgroundColor: "#fff",
|
|
163
|
+
boxShadow: "0 1px 2px rgba(0,0,0,0.04)",
|
|
164
|
+
padding: "16px 18px 14px",
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
[
|
|
168
|
+
// Top bar
|
|
169
|
+
h(
|
|
170
|
+
"div",
|
|
171
|
+
{
|
|
172
|
+
style: {
|
|
173
|
+
display: "flex",
|
|
174
|
+
alignItems: "center",
|
|
175
|
+
gap: "8px",
|
|
176
|
+
marginBottom: "12px",
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
[
|
|
180
|
+
h("div", { style: { display: "flex", gap: "4px" } }, [
|
|
181
|
+
dot(),
|
|
182
|
+
dot(),
|
|
183
|
+
dot(),
|
|
184
|
+
]),
|
|
185
|
+
bar(64, 6, "#e4e4e7", undefined, phase >= 1 ? 1 : 0.4, "opacity 0.5s"),
|
|
186
|
+
],
|
|
187
|
+
),
|
|
188
|
+
// Skeleton lines
|
|
189
|
+
h("div", { style: { display: "grid", gap: "7px" } }, [
|
|
190
|
+
row(phase >= 0, 0, [
|
|
191
|
+
bar(36, 7, "rgba(147,197,253,0.7)", 0),
|
|
192
|
+
bar(80, 7, "rgba(219,234,254,0.8)", 0.2),
|
|
193
|
+
]),
|
|
194
|
+
row(phase >= 0, 0.1, [
|
|
195
|
+
spacer(),
|
|
196
|
+
dot(),
|
|
197
|
+
bar(100, 7, "rgba(24,24,27,0.2)", 0.3),
|
|
198
|
+
]),
|
|
199
|
+
row(phase >= 1, 0.15, [
|
|
200
|
+
spacer(),
|
|
201
|
+
bar(48, 7, "rgba(24,24,27,0.15)", 0.1),
|
|
202
|
+
bar(40, 7, "rgba(153,246,228,0.6)", 0.5),
|
|
203
|
+
bar(56, 7, "rgba(147,197,253,0.6)", 0.3),
|
|
204
|
+
]),
|
|
205
|
+
row(phase >= 1, 0.2, [
|
|
206
|
+
spacer(),
|
|
207
|
+
dot(),
|
|
208
|
+
bar(60, 7, "rgba(24,24,27,0.15)", 0.4),
|
|
209
|
+
]),
|
|
210
|
+
row(phase >= 2, 0.25, [
|
|
211
|
+
bar(40, 7, "rgba(153,246,228,0.5)", 0.2),
|
|
212
|
+
dot(),
|
|
213
|
+
bar(48, 7, "rgba(24,24,27,0.15)", 0.6),
|
|
214
|
+
bar(64, 7, "rgba(147,197,253,0.5)", 0.1),
|
|
215
|
+
]),
|
|
216
|
+
row(phase >= 2, 0.3, [
|
|
217
|
+
bar(36, 7, "rgba(147,197,253,0.6)", 0.5),
|
|
218
|
+
bar(36, 7, "rgba(24,24,27,0.12)", 0.7),
|
|
219
|
+
]),
|
|
220
|
+
row(phase >= 3, 0.35, [
|
|
221
|
+
dot(),
|
|
222
|
+
bar(44, 7, "rgba(24,24,27,0.18)", 0.3),
|
|
223
|
+
dot(),
|
|
224
|
+
bar(56, 7, "rgba(153,246,228,0.5)", 0.8),
|
|
225
|
+
bar(48, 7, "rgba(147,197,253,0.5)", 0.4),
|
|
226
|
+
]),
|
|
227
|
+
]),
|
|
228
|
+
// Shimmer
|
|
229
|
+
h("div", {
|
|
230
|
+
style: {
|
|
231
|
+
pointerEvents: "none",
|
|
232
|
+
position: "absolute",
|
|
233
|
+
inset: "0",
|
|
234
|
+
background:
|
|
235
|
+
"linear-gradient(105deg, transparent 0%, transparent 40%, rgba(255,255,255,0.6) 50%, transparent 60%, transparent 100%)",
|
|
236
|
+
backgroundSize: "250% 100%",
|
|
237
|
+
animation: "cpk-a2ui-sweep 3s ease-in-out infinite",
|
|
238
|
+
},
|
|
239
|
+
}),
|
|
240
|
+
],
|
|
241
|
+
),
|
|
242
|
+
// Label
|
|
243
|
+
h(
|
|
244
|
+
"div",
|
|
245
|
+
{
|
|
246
|
+
style: {
|
|
247
|
+
display: "flex",
|
|
248
|
+
alignItems: "center",
|
|
249
|
+
justifyContent: "center",
|
|
250
|
+
gap: "8px",
|
|
251
|
+
marginTop: "8px",
|
|
252
|
+
},
|
|
253
|
+
},
|
|
254
|
+
[
|
|
255
|
+
h(
|
|
256
|
+
"span",
|
|
257
|
+
{
|
|
258
|
+
style: {
|
|
259
|
+
fontSize: "12px",
|
|
260
|
+
color: "#a1a1aa",
|
|
261
|
+
letterSpacing: "0.025em",
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
"Building interface",
|
|
265
|
+
),
|
|
266
|
+
...(tokens > 0
|
|
267
|
+
? [
|
|
268
|
+
h(
|
|
269
|
+
"span",
|
|
270
|
+
{
|
|
271
|
+
style: {
|
|
272
|
+
fontSize: "11px",
|
|
273
|
+
color: "#d4d4d8",
|
|
274
|
+
fontVariantNumeric: "tabular-nums",
|
|
275
|
+
},
|
|
276
|
+
},
|
|
277
|
+
`~${tokens.toLocaleString()} tokens`,
|
|
278
|
+
),
|
|
279
|
+
]
|
|
280
|
+
: []),
|
|
281
|
+
],
|
|
282
|
+
),
|
|
283
|
+
// Keyframe styles
|
|
284
|
+
h("style", `
|
|
285
|
+
@keyframes cpk-a2ui-fade {
|
|
286
|
+
0%, 100% { opacity: 1; }
|
|
287
|
+
50% { opacity: 0.5; }
|
|
288
|
+
}
|
|
289
|
+
@keyframes cpk-a2ui-sweep {
|
|
290
|
+
0% { background-position: 250% 0; }
|
|
291
|
+
100% { background-position: -250% 0; }
|
|
292
|
+
}
|
|
293
|
+
`),
|
|
294
|
+
]);
|
|
295
|
+
}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { computed, watch } from "vue";
|
|
2
|
+
import type { ShallowRef } from "vue";
|
|
3
|
+
import type { Catalog, ComponentApi } from "@a2ui/web_core/v0_9";
|
|
4
|
+
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
5
|
+
import {
|
|
6
|
+
A2UI_DEFAULT_GENERATION_GUIDELINES,
|
|
7
|
+
A2UI_DEFAULT_DESIGN_GUIDELINES,
|
|
8
|
+
} from "@copilotkit/shared";
|
|
9
|
+
import type { CopilotKitCoreVue } from "../../lib/vue-core";
|
|
10
|
+
import { vueBasicCatalog } from "./catalog";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Context description used to identify the A2UI component schema in
|
|
14
|
+
* RunAgentInput.context. Must match the constant in @ag-ui/a2ui-middleware
|
|
15
|
+
* so the middleware can overwrite a frontend-provided schema with a
|
|
16
|
+
* server-side one.
|
|
17
|
+
*
|
|
18
|
+
* Duplicated from @copilotkit/a2ui-renderer/catalog-utils to avoid pulling
|
|
19
|
+
* in React dependencies.
|
|
20
|
+
*/
|
|
21
|
+
const A2UI_SCHEMA_CONTEXT_DESCRIPTION =
|
|
22
|
+
"A2UI Component Schema — available components for generating UI surfaces. " +
|
|
23
|
+
"Use these component names and properties when creating A2UI operations.";
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Build a context string describing the available A2UI catalog.
|
|
27
|
+
* Vue-native equivalent of buildCatalogContextValue from a2ui-renderer.
|
|
28
|
+
*/
|
|
29
|
+
function buildCatalogContextValue(catalog?: Catalog<ComponentApi>): string {
|
|
30
|
+
const resolved = catalog ?? vueBasicCatalog;
|
|
31
|
+
const BASIC_CATALOG_ID =
|
|
32
|
+
"https://a2ui.org/specification/v0_9/basic_catalog.json";
|
|
33
|
+
const lines: string[] = [];
|
|
34
|
+
lines.push("Available A2UI catalog:");
|
|
35
|
+
|
|
36
|
+
if (resolved.id === BASIC_CATALOG_ID) {
|
|
37
|
+
lines.push(`- ${resolved.id} (basic catalog)`);
|
|
38
|
+
return lines.join("\n");
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Check if the resolved catalog extends the basic catalog
|
|
42
|
+
let isSuperset = true;
|
|
43
|
+
for (const name of vueBasicCatalog.components.keys()) {
|
|
44
|
+
if (!resolved.components.has(name)) {
|
|
45
|
+
isSuperset = false;
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Identify custom components (not in basic catalog)
|
|
51
|
+
const customNames: string[] = [];
|
|
52
|
+
for (const name of resolved.components.keys()) {
|
|
53
|
+
if (!vueBasicCatalog.components.has(name)) {
|
|
54
|
+
customNames.push(name);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
lines.push(`- ${resolved.id}`);
|
|
59
|
+
if (isSuperset) {
|
|
60
|
+
lines.push(
|
|
61
|
+
" Extends the basic catalog with all standard components plus:",
|
|
62
|
+
);
|
|
63
|
+
} else {
|
|
64
|
+
lines.push(" Custom catalog (does NOT include all basic components).");
|
|
65
|
+
lines.push(" Custom components:");
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
for (const name of customNames) {
|
|
69
|
+
const comp = resolved.components.get(name);
|
|
70
|
+
if (!comp) continue;
|
|
71
|
+
const jsonSchema = zodToJsonSchema(comp.schema);
|
|
72
|
+
lines.push(` - ${name}:`);
|
|
73
|
+
lines.push(
|
|
74
|
+
` ${JSON.stringify(jsonSchema, null, 2).split("\n").join("\n ")}`,
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return lines.join("\n");
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Extract component schemas from a catalog in A2UI v0.9 inline format.
|
|
83
|
+
* Vue-native equivalent of extractCatalogComponentSchemas.
|
|
84
|
+
*/
|
|
85
|
+
function extractCatalogComponentSchemas(
|
|
86
|
+
catalog?: Catalog<ComponentApi>,
|
|
87
|
+
): { catalogId: string; components: Record<string, Record<string, unknown>> } {
|
|
88
|
+
const resolved = catalog ?? vueBasicCatalog;
|
|
89
|
+
const components: Record<string, Record<string, unknown>> = {};
|
|
90
|
+
|
|
91
|
+
for (const [name, comp] of resolved.components) {
|
|
92
|
+
const zodSchema = zodToJsonSchema(comp.schema, {
|
|
93
|
+
target: "jsonSchema2019-09",
|
|
94
|
+
}) as { properties?: Record<string, unknown>; required?: string[] };
|
|
95
|
+
|
|
96
|
+
components[name] = {
|
|
97
|
+
allOf: [
|
|
98
|
+
{ $ref: "common_types.json#/$defs/ComponentCommon" },
|
|
99
|
+
{
|
|
100
|
+
properties: {
|
|
101
|
+
component: { const: name },
|
|
102
|
+
...(zodSchema.properties ?? {}),
|
|
103
|
+
},
|
|
104
|
+
required: ["component", ...(zodSchema.required ?? [])],
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return { catalogId: resolved.id, components };
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Registers agent context describing the available A2UI catalog, component
|
|
115
|
+
* schemas, and generation/design guidelines.
|
|
116
|
+
*
|
|
117
|
+
* Vue-native equivalent of React's `<A2UICatalogContext>` component.
|
|
118
|
+
* Call from the provider's setup function.
|
|
119
|
+
*/
|
|
120
|
+
export function registerA2UICatalogContext(
|
|
121
|
+
copilotkit: ShallowRef<CopilotKitCoreVue>,
|
|
122
|
+
options: {
|
|
123
|
+
enabled: () => boolean;
|
|
124
|
+
catalog: () => Catalog<ComponentApi> | undefined;
|
|
125
|
+
includeSchema: () => boolean;
|
|
126
|
+
},
|
|
127
|
+
): void {
|
|
128
|
+
const contextValue = computed(() =>
|
|
129
|
+
buildCatalogContextValue(options.catalog()),
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
// Register catalog capabilities context
|
|
133
|
+
watch(
|
|
134
|
+
[() => copilotkit.value, options.enabled, contextValue],
|
|
135
|
+
([core, isEnabled, value], _prev, onCleanup) => {
|
|
136
|
+
if (!isEnabled) return;
|
|
137
|
+
const id = core.addContext({
|
|
138
|
+
description:
|
|
139
|
+
"A2UI catalog capabilities: available catalog IDs and " +
|
|
140
|
+
"custom component definitions the client can render.",
|
|
141
|
+
value,
|
|
142
|
+
});
|
|
143
|
+
onCleanup(() => core.removeContext(id));
|
|
144
|
+
},
|
|
145
|
+
{ immediate: true },
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
// Register schema + generation/design guidelines
|
|
149
|
+
const schemaValue = computed(() => {
|
|
150
|
+
if (!options.includeSchema()) return null;
|
|
151
|
+
return JSON.stringify(
|
|
152
|
+
extractCatalogComponentSchemas(options.catalog()),
|
|
153
|
+
);
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
watch(
|
|
157
|
+
[() => copilotkit.value, options.enabled, schemaValue],
|
|
158
|
+
([core, isEnabled, schema], _prev, onCleanup) => {
|
|
159
|
+
if (!isEnabled || !schema) return;
|
|
160
|
+
const ids: string[] = [];
|
|
161
|
+
ids.push(
|
|
162
|
+
core.addContext({
|
|
163
|
+
description: A2UI_SCHEMA_CONTEXT_DESCRIPTION,
|
|
164
|
+
value: schema,
|
|
165
|
+
}),
|
|
166
|
+
);
|
|
167
|
+
ids.push(
|
|
168
|
+
core.addContext({
|
|
169
|
+
description:
|
|
170
|
+
"A2UI generation guidelines — protocol rules, tool arguments, " +
|
|
171
|
+
"path rules, data model format, and " +
|
|
172
|
+
"form/two-way-binding instructions.",
|
|
173
|
+
value: A2UI_DEFAULT_GENERATION_GUIDELINES,
|
|
174
|
+
}),
|
|
175
|
+
);
|
|
176
|
+
ids.push(
|
|
177
|
+
core.addContext({
|
|
178
|
+
description:
|
|
179
|
+
"A2UI design guidelines — visual design rules, component " +
|
|
180
|
+
"hierarchy tips, and action handler patterns.",
|
|
181
|
+
value: A2UI_DEFAULT_DESIGN_GUIDELINES,
|
|
182
|
+
}),
|
|
183
|
+
);
|
|
184
|
+
onCleanup(() => {
|
|
185
|
+
for (const id of ids) core.removeContext(id);
|
|
186
|
+
});
|
|
187
|
+
},
|
|
188
|
+
{ immediate: true },
|
|
189
|
+
);
|
|
190
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vue-native A2UI Surface renderer.
|
|
3
|
+
*
|
|
4
|
+
* Replaces the React island pattern with Vue components that use
|
|
5
|
+
* @a2ui/web_core's framework-agnostic primitives directly.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
defineComponent,
|
|
10
|
+
h,
|
|
11
|
+
ref,
|
|
12
|
+
onUnmounted,
|
|
13
|
+
type PropType,
|
|
14
|
+
type VNode,
|
|
15
|
+
} from "vue";
|
|
16
|
+
import {
|
|
17
|
+
ComponentContext,
|
|
18
|
+
type SurfaceModel,
|
|
19
|
+
type ComponentModel,
|
|
20
|
+
} from "@a2ui/web_core/v0_9";
|
|
21
|
+
import type { VueComponentImplementation } from "./adapter";
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* DeferredChild — Vue equivalent of the React DeferredChild.
|
|
25
|
+
* Subscribes to component create/delete events and renders the
|
|
26
|
+
* appropriate catalog component via the GenericBinder adapter.
|
|
27
|
+
*/
|
|
28
|
+
const DeferredChild = defineComponent({
|
|
29
|
+
name: "A2UIDeferredChild",
|
|
30
|
+
props: {
|
|
31
|
+
surface: {
|
|
32
|
+
type: Object as PropType<SurfaceModel<VueComponentImplementation>>,
|
|
33
|
+
required: true,
|
|
34
|
+
},
|
|
35
|
+
id: { type: String, required: true },
|
|
36
|
+
basePath: { type: String, required: true },
|
|
37
|
+
},
|
|
38
|
+
setup(props) {
|
|
39
|
+
// Reactive trigger — incremented when the component is created/deleted
|
|
40
|
+
const version = ref(0);
|
|
41
|
+
|
|
42
|
+
const sub1 = props.surface.componentsModel.onCreated.subscribe(
|
|
43
|
+
(comp: ComponentModel) => {
|
|
44
|
+
if (comp.id === props.id) {
|
|
45
|
+
version.value++;
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
);
|
|
49
|
+
const sub2 = props.surface.componentsModel.onDeleted.subscribe(
|
|
50
|
+
(delId: string) => {
|
|
51
|
+
if (delId === props.id) {
|
|
52
|
+
version.value++;
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
onUnmounted(() => {
|
|
58
|
+
sub1.unsubscribe();
|
|
59
|
+
sub2.unsubscribe();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
function buildChild(childId: string, specificPath?: string): VNode {
|
|
63
|
+
const path = specificPath || props.basePath;
|
|
64
|
+
return h(DeferredChild, {
|
|
65
|
+
key: `${childId}-${path}`,
|
|
66
|
+
surface: props.surface,
|
|
67
|
+
id: childId,
|
|
68
|
+
basePath: path,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return () => {
|
|
73
|
+
// Touch version to ensure reactivity
|
|
74
|
+
void version.value;
|
|
75
|
+
|
|
76
|
+
const componentModel = props.surface.componentsModel.get(props.id);
|
|
77
|
+
|
|
78
|
+
if (!componentModel) {
|
|
79
|
+
// Shimmer placeholder while component isn't yet available
|
|
80
|
+
return h("div", {
|
|
81
|
+
style: {
|
|
82
|
+
padding: "12px 16px",
|
|
83
|
+
borderRadius: "8px",
|
|
84
|
+
background:
|
|
85
|
+
"linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%)",
|
|
86
|
+
backgroundSize: "200% 100%",
|
|
87
|
+
animation: "a2ui-shimmer 1.5s ease-in-out infinite",
|
|
88
|
+
minHeight: "2rem",
|
|
89
|
+
},
|
|
90
|
+
innerHTML: `<style>@keyframes a2ui-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }</style>`,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const compImpl = props.surface.catalog.components.get(
|
|
95
|
+
componentModel.type,
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
if (!compImpl) {
|
|
99
|
+
return h(
|
|
100
|
+
"div",
|
|
101
|
+
{ style: { color: "red" } },
|
|
102
|
+
`Unknown component: ${componentModel.type}`,
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Create context for this component
|
|
107
|
+
const context = new ComponentContext(
|
|
108
|
+
props.surface,
|
|
109
|
+
props.id,
|
|
110
|
+
props.basePath,
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
// Render the catalog component's Vue wrapper (created by createVueComponent)
|
|
114
|
+
return h(compImpl.render, {
|
|
115
|
+
context,
|
|
116
|
+
buildChild,
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* A2uiSurface — renders the root of a single A2UI surface.
|
|
124
|
+
* The root component always has ID 'root' and base path '/'.
|
|
125
|
+
*/
|
|
126
|
+
export const A2uiSurface = defineComponent({
|
|
127
|
+
name: "A2uiSurface",
|
|
128
|
+
props: {
|
|
129
|
+
surface: {
|
|
130
|
+
type: Object as PropType<SurfaceModel<VueComponentImplementation>>,
|
|
131
|
+
required: true,
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
setup(props) {
|
|
135
|
+
return () =>
|
|
136
|
+
h(DeferredChild, {
|
|
137
|
+
surface: props.surface,
|
|
138
|
+
id: "root",
|
|
139
|
+
basePath: "/",
|
|
140
|
+
});
|
|
141
|
+
},
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
export { DeferredChild };
|