@copilotkit/vue 2.0.0-rc.2 → 2.0.0-rc.21
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/PARITY.md +3 -3
- package/dist/hooks/use-copilot-action.d.ts.map +1 -1
- package/dist/hooks/use-frontend-tool.d.ts +1 -1
- package/dist/hooks/use-frontend-tool.d.ts.map +1 -1
- package/dist/hooks/zod-parameters.d.ts +14 -0
- package/dist/hooks/zod-parameters.d.ts.map +1 -0
- package/dist/index.cjs +1 -73
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +365 -16920
- package/dist/index.mjs.map +1 -1
- package/dist/use-render-activity-message-BAhbpSDh.js +16200 -0
- package/dist/use-render-activity-message-BAhbpSDh.js.map +1 -0
- package/dist/use-render-activity-message-DJ6q1qHV.cjs +114 -0
- package/dist/use-render-activity-message-DJ6q1qHV.cjs.map +1 -0
- package/dist/v2/components/A2UIMessageRenderer.d.ts +14 -0
- package/dist/v2/components/A2UIMessageRenderer.d.ts.map +1 -1
- package/dist/v2/components/A2UISurfaceActivityRenderer.vue.d.ts +10 -3
- package/dist/v2/components/A2UISurfaceActivityRenderer.vue.d.ts.map +1 -1
- package/dist/v2/components/CopilotKitInspector.vue.d.ts +5 -1
- package/dist/v2/components/CopilotKitInspector.vue.d.ts.map +1 -1
- package/dist/v2/components/InlineFeatureWarning.vue.d.ts.map +1 -1
- package/dist/v2/components/LicenseWarningBanner.vue.d.ts +2 -2
- package/dist/v2/components/LicenseWarningBanner.vue.d.ts.map +1 -1
- package/dist/v2/components/MCPAppsActivityRenderer.d.ts.map +1 -1
- package/dist/v2/components/OpenGenerativeUIRenderer.d.ts +13 -59
- package/dist/v2/components/OpenGenerativeUIRenderer.d.ts.map +1 -1
- package/dist/v2/components/a2ui/A2UIBuiltInToolCallRenderer.d.ts +0 -5
- package/dist/v2/components/a2ui/A2UIBuiltInToolCallRenderer.d.ts.map +1 -1
- package/dist/v2/components/a2ui/A2UICatalogContext.d.ts +10 -15
- package/dist/v2/components/a2ui/A2UICatalogContext.d.ts.map +1 -1
- package/dist/v2/components/a2ui/A2UIRecoveryStates.d.ts +14 -130
- package/dist/v2/components/a2ui/A2UIRecoveryStates.d.ts.map +1 -1
- package/dist/v2/components/a2ui/catalog.d.ts.map +1 -1
- package/dist/v2/components/a2ui/utils.d.ts +3 -15
- package/dist/v2/components/a2ui/utils.d.ts.map +1 -1
- package/dist/v2/components/a2ui.d.ts +9 -8
- package/dist/v2/components/a2ui.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChat.vue.d.ts +2 -2
- package/dist/v2/components/chat/CopilotChat.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatAssistantMessage.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatAttachmentQueue.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatAttachmentRenderer.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatAudioRecorder.vue.d.ts +4 -8
- package/dist/v2/components/chat/CopilotChatAudioRecorder.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatFeedbackCommentPopover.vue.d.ts +1 -1
- package/dist/v2/components/chat/CopilotChatFeedbackCommentPopover.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatInput.vue.d.ts +6 -270
- package/dist/v2/components/chat/CopilotChatInput.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatInspectorButton.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatLightbox.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatMessageView.vue.d.ts +1 -1
- package/dist/v2/components/chat/CopilotChatMessageView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatReasoningMessage.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatToolCallGroup.vue.d.ts +1 -1
- package/dist/v2/components/chat/CopilotChatToolCallGroup.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatToolCallItem.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatToolCallsView.vue.d.ts +1 -1
- package/dist/v2/components/chat/CopilotChatToolCallsView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatUserMessage.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatView.vue.d.ts +3 -3
- package/dist/v2/components/chat/CopilotChatView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatWorkSummary.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotModalHeader.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotPopup.vue.d.ts +8 -3
- package/dist/v2/components/chat/CopilotPopup.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotPopupView.vue.d.ts +5 -3
- package/dist/v2/components/chat/CopilotPopupView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotPopupViewInternal.vue.d.ts +5 -3
- package/dist/v2/components/chat/CopilotPopupViewInternal.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotSidebar.vue.d.ts +8 -3
- package/dist/v2/components/chat/CopilotSidebar.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotSidebarView.vue.d.ts +6 -4
- package/dist/v2/components/chat/CopilotSidebarView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotSidebarViewInternal.vue.d.ts +6 -4
- package/dist/v2/components/chat/CopilotSidebarViewInternal.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotThreadsDrawer.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/StreamingMarkdownDefault.vue.d.ts +1 -0
- package/dist/v2/components/chat/StreamingMarkdownDefault.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/audioRecorder.d.ts +3 -4
- package/dist/v2/components/chat/audioRecorder.d.ts.map +1 -1
- package/dist/v2/components/chat/copilotChatToolCallItemRender.d.ts +3 -3
- package/dist/v2/components/chat/copilotChatToolCallItemRender.d.ts.map +1 -1
- package/dist/v2/components/chat/forwarded-slots.d.ts +12 -0
- package/dist/v2/components/chat/forwarded-slots.d.ts.map +1 -0
- package/dist/v2/components/chat/index.d.ts +34 -31
- package/dist/v2/components/chat/index.d.ts.map +1 -1
- package/dist/v2/components/chat/inspector-shortcuts.d.ts +2 -1
- package/dist/v2/components/chat/inspector-shortcuts.d.ts.map +1 -1
- package/dist/v2/components/chat/message-feedback.d.ts +18 -49
- package/dist/v2/components/chat/message-feedback.d.ts.map +1 -1
- package/dist/v2/components/chat/tool-call-display-context.d.ts +4 -19
- package/dist/v2/components/chat/tool-call-display-context.d.ts.map +1 -1
- package/dist/v2/components/chat/tool-call-group-parts.d.ts +7 -20
- package/dist/v2/components/chat/tool-call-group-parts.d.ts.map +1 -1
- package/dist/v2/components/chat/turn-work.d.ts +0 -2
- package/dist/v2/components/chat/turn-work.d.ts.map +1 -1
- package/dist/v2/components/chat/types.d.ts +9 -4
- package/dist/v2/components/chat/types.d.ts.map +1 -1
- package/dist/v2/components/chat/use-chat-labels.d.ts +8 -0
- package/dist/v2/components/chat/use-chat-labels.d.ts.map +1 -0
- package/dist/v2/components/chat/use-copy-feedback.d.ts +11 -0
- package/dist/v2/components/chat/use-copy-feedback.d.ts.map +1 -0
- package/dist/v2/components/chat/use-lightbox.d.ts.map +1 -1
- package/dist/v2/components/icons/index.d.ts +968 -1
- package/dist/v2/components/icons/index.d.ts.map +1 -1
- package/dist/v2/components/ui/CopilotDropdownMenuContent.vue.d.ts +1 -1
- package/dist/v2/components/ui/CopilotDropdownMenuContent.vue.d.ts.map +1 -1
- package/dist/v2/hooks/use-agent-context.d.ts +2 -3
- package/dist/v2/hooks/use-agent-context.d.ts.map +1 -1
- package/dist/v2/hooks/use-agent.d.ts +4 -1
- package/dist/v2/hooks/use-agent.d.ts.map +1 -1
- package/dist/v2/hooks/use-attachments.d.ts +7 -0
- package/dist/v2/hooks/use-attachments.d.ts.map +1 -1
- package/dist/v2/hooks/use-capabilities.d.ts.map +1 -1
- package/dist/v2/hooks/use-component.d.ts +1 -0
- package/dist/v2/hooks/use-component.d.ts.map +1 -1
- package/dist/v2/hooks/use-configure-suggestions.d.ts +4 -9
- package/dist/v2/hooks/use-configure-suggestions.d.ts.map +1 -1
- package/dist/v2/hooks/use-default-render-tool.d.ts.map +1 -1
- package/dist/v2/hooks/use-frontend-tool.d.ts +5 -0
- package/dist/v2/hooks/use-frontend-tool.d.ts.map +1 -1
- package/dist/v2/hooks/use-human-in-the-loop.d.ts +2 -1
- package/dist/v2/hooks/use-human-in-the-loop.d.ts.map +1 -1
- package/dist/v2/hooks/use-interrupt.d.ts +0 -1
- package/dist/v2/hooks/use-interrupt.d.ts.map +1 -1
- package/dist/v2/hooks/use-keyboard-height.d.ts +1 -1
- package/dist/v2/hooks/use-keyboard-height.d.ts.map +1 -1
- package/dist/v2/hooks/use-pin-to-send.d.ts +4 -12
- package/dist/v2/hooks/use-pin-to-send.d.ts.map +1 -1
- package/dist/v2/hooks/use-render-activity-message.d.ts +13 -9
- package/dist/v2/hooks/use-render-activity-message.d.ts.map +1 -1
- package/dist/v2/hooks/use-render-custom-messages.d.ts +5 -7
- package/dist/v2/hooks/use-render-custom-messages.d.ts.map +1 -1
- package/dist/v2/hooks/use-suggestions.d.ts.map +1 -1
- package/dist/v2/hooks/use-threads.d.ts +0 -8
- package/dist/v2/hooks/use-threads.d.ts.map +1 -1
- package/dist/v2/index.cjs +1 -1
- package/dist/v2/index.mjs +197 -200
- package/dist/v2/index.mjs.map +1 -1
- package/dist/v2/lib/processPartialHtml.d.ts +1 -2
- package/dist/v2/lib/processPartialHtml.d.ts.map +1 -1
- package/dist/v2/lib/shallow-stable.d.ts.map +1 -1
- package/dist/v2/lib/vue-core.d.ts +12 -12
- package/dist/v2/lib/vue-core.d.ts.map +1 -1
- package/dist/v2/providers/CopilotChatConfigurationProvider.vue.d.ts.map +1 -1
- package/dist/v2/providers/CopilotKitProvider.types.d.ts +9 -129
- package/dist/v2/providers/CopilotKitProvider.types.d.ts.map +1 -1
- package/dist/v2/providers/CopilotKitProvider.vue.d.ts +9 -10
- package/dist/v2/providers/CopilotKitProvider.vue.d.ts.map +1 -1
- package/dist/v2/providers/chat-configuration-store-key.d.ts +8 -0
- package/dist/v2/providers/chat-configuration-store-key.d.ts.map +1 -0
- package/dist/v2/providers/markdown-renderer.d.ts +4 -2
- package/dist/v2/providers/markdown-renderer.d.ts.map +1 -1
- package/dist/v2/providers/types.d.ts +3 -46
- package/dist/v2/providers/types.d.ts.map +1 -1
- package/dist/v2/providers/use-inspector-thread-override.d.ts +5 -0
- package/dist/v2/providers/use-inspector-thread-override.d.ts.map +1 -1
- package/dist/v2/types/human-in-the-loop.d.ts +8 -29
- package/dist/v2/types/human-in-the-loop.d.ts.map +1 -1
- package/dist/v2/types/interrupt.d.ts +1 -22
- package/dist/v2/types/interrupt.d.ts.map +1 -1
- package/dist/v2/types/vue-activity-message-renderer.d.ts +16 -15
- package/dist/v2/types/vue-activity-message-renderer.d.ts.map +1 -1
- package/dist/v2/types/vue-custom-message-renderer.d.ts +7 -16
- package/dist/v2/types/vue-custom-message-renderer.d.ts.map +1 -1
- package/dist/v2/types/vue-tool-call-renderer.d.ts +16 -35
- package/dist/v2/types/vue-tool-call-renderer.d.ts.map +1 -1
- package/package.json +10 -11
- package/src/__tests__/build-entries.test.ts +27 -0
- package/src/hooks/__tests__/zod-parameters.test.ts +520 -0
- package/src/hooks/use-copilot-action.ts +2 -1
- package/src/hooks/use-frontend-tool.ts +3 -6
- package/src/hooks/zod-parameters.ts +162 -0
- package/src/v2/__tests__/exports.test.ts +10 -0
- package/src/v2/__tests__/mocks/web-inspector.ts +6 -0
- package/src/v2/__tests__/utils/test-helpers.ts +34 -4
- package/src/v2/components/A2UIMessageRenderer.ts +98 -68
- package/src/v2/components/A2UISurfaceActivityRenderer.vue +68 -103
- package/src/v2/components/CopilotKitInspector.vue +104 -51
- package/src/v2/components/InlineFeatureWarning.vue +20 -21
- package/src/v2/components/LicenseWarningBanner.vue +27 -135
- package/src/v2/components/MCPAppsActivityRenderer.ts +75 -201
- package/src/v2/components/OpenGenerativeUIRenderer.ts +122 -446
- package/src/v2/components/__tests__/A2UIMessageRenderer.test.ts +171 -8
- package/src/v2/components/__tests__/CopilotKitInspector.test.ts +42 -0
- package/src/v2/components/__tests__/LicenseWarningBanner.test.ts +60 -0
- package/src/v2/components/__tests__/OpenGenerativeUIRenderer.test.ts +64 -8
- package/src/v2/components/__tests__/OpenGenerativeUIToolRenderer.test.ts +38 -0
- package/src/v2/components/a2ui/A2UIBuiltInToolCallRenderer.ts +2 -7
- package/src/v2/components/a2ui/A2UICatalogContext.ts +27 -185
- package/src/v2/components/a2ui/A2UIRecoveryStates.ts +127 -327
- package/src/v2/components/a2ui/catalog.ts +3 -3
- package/src/v2/components/a2ui/utils.ts +13 -65
- package/src/v2/components/a2ui.ts +15 -22
- package/src/v2/components/chat/CopilotChat.vue +147 -356
- package/src/v2/components/chat/CopilotChatAssistantMessage.vue +19 -43
- package/src/v2/components/chat/CopilotChatAttachmentQueue.vue +36 -55
- package/src/v2/components/chat/CopilotChatAttachmentRenderer.vue +14 -6
- package/src/v2/components/chat/CopilotChatAudioRecorder.vue +19 -246
- package/src/v2/components/chat/CopilotChatFeedbackCommentPopover.vue +2 -2
- package/src/v2/components/chat/CopilotChatInput.vue +108 -436
- package/src/v2/components/chat/CopilotChatInspectorButton.vue +45 -108
- package/src/v2/components/chat/CopilotChatLightbox.vue +10 -31
- package/src/v2/components/chat/CopilotChatMessageView.vue +82 -210
- package/src/v2/components/chat/CopilotChatReasoningMessage.vue +7 -15
- package/src/v2/components/chat/CopilotChatToolCallGroup.vue +63 -71
- package/src/v2/components/chat/CopilotChatToolCallItem.vue +8 -6
- package/src/v2/components/chat/CopilotChatToolCallsView.vue +31 -32
- package/src/v2/components/chat/CopilotChatUserMessage.vue +24 -112
- package/src/v2/components/chat/CopilotChatView.vue +33 -28
- package/src/v2/components/chat/CopilotChatWorkSummary.vue +26 -36
- package/src/v2/components/chat/CopilotModalHeader.vue +11 -23
- package/src/v2/components/chat/CopilotPopup.vue +23 -25
- package/src/v2/components/chat/CopilotPopupView.vue +10 -39
- package/src/v2/components/chat/CopilotPopupViewInternal.vue +35 -131
- package/src/v2/components/chat/CopilotSidebar.vue +23 -25
- package/src/v2/components/chat/CopilotSidebarView.vue +10 -39
- package/src/v2/components/chat/CopilotSidebarViewInternal.vue +38 -59
- package/src/v2/components/chat/CopilotThreadsDrawer.vue +37 -102
- package/src/v2/components/chat/StreamingMarkdownDefault.vue +15 -28
- package/src/v2/components/chat/__tests__/CopilotChat.labels.test.ts +19 -4
- package/src/v2/components/chat/__tests__/CopilotChat.test.ts +12 -10
- package/src/v2/components/chat/__tests__/CopilotChatActivityRendering.e2e.test.ts +26 -9
- package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.learningFeedback.test.ts +5 -5
- package/src/v2/components/chat/__tests__/CopilotChatAttachmentQueue.test.ts +28 -0
- package/src/v2/components/chat/__tests__/CopilotChatInput.test.ts +89 -1
- package/src/v2/components/chat/__tests__/CopilotChatMessageView.test.ts +247 -403
- package/src/v2/components/chat/__tests__/CopilotChatMessageView.toolCallDisplay.test.ts +1 -99
- package/src/v2/components/chat/__tests__/CopilotPopup.test.ts +90 -1
- package/src/v2/components/chat/__tests__/CopilotPopupView.test.ts +19 -0
- package/src/v2/components/chat/__tests__/CopilotSidebar.test.ts +90 -1
- package/src/v2/components/chat/__tests__/CopilotSidebarView.position.test.ts +32 -8
- package/src/v2/components/chat/__tests__/CopilotSidebarView.test.ts +2 -1
- package/src/v2/components/chat/__tests__/StreamingMarkdownDefault.test.ts +54 -0
- package/src/v2/components/chat/audioRecorder.ts +4 -7
- package/src/v2/components/chat/copilotChatToolCallItemRender.ts +24 -89
- package/src/v2/components/chat/forwarded-slots.ts +17 -0
- package/src/v2/components/chat/index.ts +0 -1
- package/src/v2/components/chat/inspector-shortcuts.ts +10 -16
- package/src/v2/components/chat/message-feedback.ts +62 -197
- package/src/v2/components/chat/tool-call-display-context.ts +6 -22
- package/src/v2/components/chat/tool-call-group-parts.ts +47 -108
- package/src/v2/components/chat/turn-work.ts +0 -9
- package/src/v2/components/chat/types.ts +12 -4
- package/src/v2/components/chat/use-chat-labels.ts +16 -0
- package/src/v2/components/chat/use-copy-feedback.ts +21 -0
- package/src/v2/components/chat/use-lightbox.ts +15 -33
- package/src/v2/components/icons/__tests__/icons.test.ts +72 -68
- package/src/v2/components/icons/index.ts +109 -27
- package/src/v2/hooks/__tests__/use-agent-error-state.test.ts +5 -3
- package/src/v2/hooks/__tests__/use-agent-stability.test.ts +25 -4
- package/src/v2/hooks/__tests__/use-agent-throttle.test.ts +5 -1
- package/src/v2/hooks/__tests__/use-agent.test.ts +6 -3
- package/src/v2/hooks/__tests__/use-component.test.ts +21 -0
- package/src/v2/hooks/__tests__/use-configure-suggestions.test.ts +30 -1
- package/src/v2/hooks/__tests__/use-default-render-tool.test.ts +10 -10
- package/src/v2/hooks/__tests__/use-frontend-tool.e2e.test.ts +66 -1
- package/src/v2/hooks/__tests__/use-human-in-the-loop.e2e.test.ts +6 -1
- package/src/v2/hooks/__tests__/use-human-in-the-loop.test.ts +187 -12
- package/src/v2/hooks/__tests__/use-interrupt.test.ts +97 -0
- package/src/v2/hooks/__tests__/use-render-activity-message.test.ts +106 -0
- package/src/v2/hooks/__tests__/use-render-tool.test.ts +3 -6
- package/src/v2/hooks/__tests__/use-threads.test.ts +48 -6
- package/src/v2/hooks/__tests__/zod-regression.test.ts +5 -4
- package/src/v2/hooks/use-agent-context.ts +4 -10
- package/src/v2/hooks/use-agent.ts +86 -290
- package/src/v2/hooks/use-attachments.ts +48 -168
- package/src/v2/hooks/use-capabilities.ts +2 -7
- package/src/v2/hooks/use-component.ts +7 -4
- package/src/v2/hooks/use-configure-suggestions.ts +28 -218
- package/src/v2/hooks/use-default-render-tool.ts +34 -94
- package/src/v2/hooks/use-frontend-tool.ts +10 -10
- package/src/v2/hooks/use-human-in-the-loop.ts +11 -80
- package/src/v2/hooks/use-interrupt.ts +29 -308
- package/src/v2/hooks/use-keyboard-height.ts +17 -40
- package/src/v2/hooks/use-pin-to-send.ts +15 -99
- package/src/v2/hooks/use-render-activity-message.ts +31 -55
- package/src/v2/hooks/use-render-custom-messages.ts +24 -88
- package/src/v2/hooks/use-suggestions.ts +9 -33
- package/src/v2/hooks/use-threads.ts +43 -273
- package/src/v2/lib/__tests__/shallow-stable.test.ts +54 -0
- package/src/v2/lib/__tests__/vue-core-renderers.test.ts +42 -0
- package/src/v2/lib/processPartialHtml.ts +6 -21
- package/src/v2/lib/shallow-stable.ts +2 -16
- package/src/v2/lib/vue-core.ts +69 -78
- package/src/v2/providers/CopilotChatConfigurationProvider.vue +48 -186
- package/src/v2/providers/CopilotKitProvider.types.ts +12 -132
- package/src/v2/providers/CopilotKitProvider.vue +237 -510
- package/src/v2/providers/__tests__/CopilotChatConfigurationProvider.test.ts +22 -2
- package/src/v2/providers/__tests__/CopilotKitProvider.a2ui.test.ts +20 -2
- package/src/v2/providers/__tests__/CopilotKitProvider.config.test.ts +124 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.headersAtSendTime.test.ts +3 -3
- package/src/v2/providers/__tests__/CopilotKitProvider.learning.test.ts +3 -1
- package/src/v2/providers/__tests__/CopilotKitProvider.sandboxFunctions.test.ts +4 -1
- package/src/v2/providers/__tests__/CopilotKitProvider.test.ts +53 -26
- package/src/v2/providers/chat-configuration-store-key.ts +9 -0
- package/src/v2/providers/markdown-renderer.ts +8 -2
- package/src/v2/providers/types.ts +3 -49
- package/src/v2/providers/use-inspector-thread-override.ts +22 -80
- package/src/v2/types/__tests__/defineToolCallRenderer.test.ts +28 -33
- package/src/v2/types/defineToolCallRenderer.ts +5 -4
- package/src/v2/types/human-in-the-loop.ts +8 -32
- package/src/v2/types/interrupt.ts +7 -31
- package/src/v2/types/vue-activity-message-renderer.ts +24 -15
- package/src/v2/types/vue-custom-message-renderer.ts +12 -16
- package/src/v2/types/vue-tool-call-renderer.ts +23 -38
- package/tsconfig.json +0 -1
- package/vite.config.ts +8 -5
- package/vitest.config.ts +12 -7
- package/dist/v2/components/chat/BasicMarkdown.vue.d.ts +0 -9
- package/dist/v2/components/chat/BasicMarkdown.vue.d.ts.map +0 -1
- package/dist/v2/components/chat/normalize-auto-scroll.d.ts +0 -3
- package/dist/v2/components/chat/normalize-auto-scroll.d.ts.map +0 -1
- package/dist/v2/components/chat/tool-call-layout.d.ts +0 -115
- package/dist/v2/components/chat/tool-call-layout.d.ts.map +0 -1
- package/dist/v2/lib/is-mobile-viewport.d.ts +0 -15
- package/dist/v2/lib/is-mobile-viewport.d.ts.map +0 -1
- package/dist/v2/lib/message-feedback.d.ts +0 -33
- package/dist/v2/lib/message-feedback.d.ts.map +0 -1
- package/dist/v2/lib/transcription-client.d.ts +0 -19
- package/dist/v2/lib/transcription-client.d.ts.map +0 -1
- package/src/v2/components/__tests__/A2UICatalogContext.test.ts +0 -63
- package/src/v2/components/a2ui/__tests__/A2UIRecoveryStates.test.ts +0 -175
- package/src/v2/components/chat/BasicMarkdown.vue +0 -160
- package/src/v2/components/chat/__tests__/BasicMarkdown.test.ts +0 -69
- package/src/v2/components/chat/__tests__/normalize-auto-scroll.test.ts +0 -39
- package/src/v2/components/chat/normalize-auto-scroll.ts +0 -17
- package/src/v2/components/chat/tool-call-layout.ts +0 -304
- package/src/v2/lib/__tests__/is-mobile-viewport.test.ts +0 -48
- package/src/v2/lib/__tests__/message-feedback.test.ts +0 -152
- package/src/v2/lib/__tests__/processPartialHtml.test.ts +0 -84
- package/src/v2/lib/__tests__/transcription-client.test.ts +0 -67
- package/src/v2/lib/is-mobile-viewport.ts +0 -23
- package/src/v2/lib/message-feedback.ts +0 -120
- package/src/v2/lib/transcription-client.ts +0 -151
|
@@ -1,147 +1,112 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed,
|
|
3
|
-
import type { VNode } from "vue";
|
|
2
|
+
import { computed, onBeforeUnmount, shallowRef, watch } from "vue";
|
|
4
3
|
import type { ActivityMessage } from "@ag-ui/core";
|
|
5
4
|
import type { A2UITheme } from "../types";
|
|
6
5
|
import type { A2UIOperation } from "./a2ui";
|
|
7
|
-
import { getOperationSurfaceId } from "./a2ui";
|
|
8
6
|
import { useCopilotKit } from "../providers";
|
|
9
7
|
import { MessageProcessor } from "@a2ui/web_core/v0_9";
|
|
10
8
|
import type { SurfaceModel } from "@a2ui/web_core/v0_9";
|
|
9
|
+
import { A2UIOperationApplier } from "@copilotkit/a2ui-renderer/engine";
|
|
10
|
+
import { A2UISurfaceDiagnostics } from "@copilotkit/a2ui-renderer/engine-core";
|
|
11
|
+
import { ɵrunA2UIAction, ɵtoA2UIClientEvent } from "@copilotkit/core";
|
|
12
|
+
import type {
|
|
13
|
+
ɵA2UIActionAgent,
|
|
14
|
+
ɵA2UIActionInterceptor,
|
|
15
|
+
} from "@copilotkit/core";
|
|
11
16
|
import { vueBasicCatalog, A2uiSurface } from "./a2ui/index";
|
|
12
17
|
import type { VueComponentImplementation } from "./a2ui/index";
|
|
13
18
|
|
|
14
|
-
const DEFAULT_SURFACE_ID = "default";
|
|
15
|
-
|
|
16
19
|
const props = defineProps<{
|
|
17
20
|
activityType: string;
|
|
18
|
-
content: { operations: A2UIOperation[] };
|
|
21
|
+
content: { operations: readonly A2UIOperation[] };
|
|
19
22
|
message: ActivityMessage;
|
|
20
|
-
agent?:
|
|
23
|
+
agent?: ɵA2UIActionAgent;
|
|
21
24
|
theme?: A2UITheme;
|
|
22
25
|
catalog?: any;
|
|
26
|
+
/** Intercepts a user action before it reaches the agent. */
|
|
27
|
+
onAction?: ɵA2UIActionInterceptor;
|
|
23
28
|
}>();
|
|
24
29
|
|
|
25
|
-
const
|
|
30
|
+
const emit = defineEmits<{
|
|
31
|
+
/** After each batch of operations was applied. */
|
|
32
|
+
rendered: [];
|
|
33
|
+
}>();
|
|
26
34
|
|
|
27
|
-
|
|
28
|
-
// Use shallowRef to avoid Vue's deep UnwrapRef which strips private class members
|
|
29
|
-
const processorRef =
|
|
30
|
-
shallowRef<MessageProcessor<VueComponentImplementation> | null>(null);
|
|
31
|
-
// Version counter to trigger Vue reactivity on processor state changes
|
|
32
|
-
const version = ref(0);
|
|
33
|
-
// Error state
|
|
34
|
-
const error = ref<string | null>(null);
|
|
35
|
-
// Track last processed operations hash to avoid re-processing
|
|
36
|
-
let lastOpsHash = "";
|
|
35
|
+
const { copilotkit } = useCopilotKit();
|
|
37
36
|
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
type Surface = SurfaceModel<VueComponentImplementation>;
|
|
38
|
+
|
|
39
|
+
// One processor for all surfaces of the activity; the core-shared applier
|
|
40
|
+
// validates the operations and applies only what is new in each snapshot.
|
|
41
|
+
// shallowRef avoids Vue's deep UnwrapRef, which strips private class members.
|
|
42
|
+
let processor: MessageProcessor<VueComponentImplementation> | null = null;
|
|
43
|
+
let applier: A2UIOperationApplier<VueComponentImplementation> | null = null;
|
|
44
|
+
const surfaces = shallowRef<readonly Surface[]>([]);
|
|
45
|
+
const error = shallowRef<string | null>(null);
|
|
46
|
+
const diagnostics =
|
|
47
|
+
process.env.NODE_ENV !== "production"
|
|
48
|
+
? new A2UISurfaceDiagnostics({ warn: (message) => console.warn(message) })
|
|
49
|
+
: null;
|
|
50
|
+
|
|
51
|
+
function getApplier() {
|
|
52
|
+
if (!processor || !applier) {
|
|
40
53
|
const catalog = props.catalog ?? vueBasicCatalog;
|
|
41
|
-
|
|
54
|
+
const created = new MessageProcessor<VueComponentImplementation>(
|
|
42
55
|
[catalog],
|
|
43
|
-
(action
|
|
44
|
-
|
|
45
|
-
|
|
56
|
+
(action) =>
|
|
57
|
+
ɵrunA2UIAction({
|
|
58
|
+
message: ɵtoA2UIClientEvent(action),
|
|
59
|
+
agent: props.agent,
|
|
60
|
+
core: copilotkit.value,
|
|
61
|
+
onAction: props.onAction,
|
|
62
|
+
}),
|
|
46
63
|
);
|
|
64
|
+
processor = created;
|
|
65
|
+
applier = new A2UIOperationApplier(created, catalog.id);
|
|
47
66
|
}
|
|
48
|
-
return
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
async function handleAction(message: unknown) {
|
|
52
|
-
if (!props.agent) return;
|
|
53
|
-
try {
|
|
54
|
-
copilotkit.value.setProperties({
|
|
55
|
-
...copilotkit.value.properties,
|
|
56
|
-
a2uiAction: message,
|
|
57
|
-
});
|
|
58
|
-
await copilotkit.value.runAgent({ agent: props.agent as any });
|
|
59
|
-
} finally {
|
|
60
|
-
const { a2uiAction, ...rest } = copilotkit.value.properties ?? {};
|
|
61
|
-
copilotkit.value.setProperties(rest);
|
|
62
|
-
}
|
|
67
|
+
return applier;
|
|
63
68
|
}
|
|
64
69
|
|
|
65
|
-
function processOperations(operations: A2UIOperation[]) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const hash = JSON.stringify(operations);
|
|
69
|
-
if (hash === lastOpsHash) return;
|
|
70
|
-
lastOpsHash = hash;
|
|
71
|
-
|
|
72
|
-
const processor = getOrCreateProcessor();
|
|
70
|
+
function processOperations(operations: readonly A2UIOperation[]) {
|
|
71
|
+
const current = getApplier();
|
|
73
72
|
try {
|
|
74
|
-
|
|
75
|
-
const grouped = new Map<string, A2UIOperation[]>();
|
|
76
|
-
for (const op of operations) {
|
|
77
|
-
const surfaceId = getOperationSurfaceId(op) ?? DEFAULT_SURFACE_ID;
|
|
78
|
-
if (!grouped.has(surfaceId)) grouped.set(surfaceId, []);
|
|
79
|
-
grouped.get(surfaceId)!.push(op);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// For each surface, skip createSurface if the surface already exists
|
|
83
|
-
for (const [surfaceId, ops] of grouped) {
|
|
84
|
-
const existing = processor.model.getSurface(surfaceId);
|
|
85
|
-
const filtered = existing
|
|
86
|
-
? ops.filter((op) => !(op as any)?.createSurface)
|
|
87
|
-
: ops;
|
|
88
|
-
processor.processMessages(filtered as any);
|
|
89
|
-
}
|
|
73
|
+
surfaces.value = current.apply(operations);
|
|
90
74
|
error.value = null;
|
|
91
75
|
} catch (err) {
|
|
92
76
|
console.warn("[A2UI Vue] processMessages error:", err);
|
|
93
77
|
error.value = err instanceof Error ? err.message : String(err);
|
|
78
|
+
surfaces.value = [];
|
|
79
|
+
return;
|
|
94
80
|
}
|
|
95
|
-
|
|
81
|
+
if (processor) diagnostics?.check(operations, processor.model);
|
|
82
|
+
emit("rendered");
|
|
96
83
|
}
|
|
97
84
|
|
|
98
|
-
//
|
|
85
|
+
// A new catalog needs a new processor, rebuilt from the current operations.
|
|
99
86
|
watch(
|
|
100
|
-
() =>
|
|
87
|
+
() => props.catalog,
|
|
101
88
|
() => {
|
|
102
|
-
|
|
89
|
+
processor = null;
|
|
90
|
+
applier = null;
|
|
91
|
+
processOperations(props.content.operations ?? []);
|
|
103
92
|
},
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
watch(
|
|
96
|
+
() => props.content.operations,
|
|
97
|
+
(operations) => processOperations(operations ?? []),
|
|
104
98
|
{ deep: true, immediate: true },
|
|
105
99
|
);
|
|
106
100
|
|
|
107
101
|
onBeforeUnmount(() => {
|
|
108
|
-
|
|
109
|
-
|
|
102
|
+
diagnostics?.dispose();
|
|
103
|
+
processor = null;
|
|
104
|
+
applier = null;
|
|
110
105
|
});
|
|
111
106
|
|
|
112
107
|
const hasOperations = computed(
|
|
113
108
|
() => (props.content.operations ?? []).length > 0,
|
|
114
109
|
);
|
|
115
|
-
|
|
116
|
-
// Compute the list of surfaces to render
|
|
117
|
-
const surfaceEntries = computed(() => {
|
|
118
|
-
// Touch version to ensure reactivity
|
|
119
|
-
void version.value;
|
|
120
|
-
|
|
121
|
-
if (!processorRef.value) return [];
|
|
122
|
-
|
|
123
|
-
const entries: Array<{
|
|
124
|
-
surfaceId: string;
|
|
125
|
-
surface: SurfaceModel<VueComponentImplementation>;
|
|
126
|
-
}> = [];
|
|
127
|
-
|
|
128
|
-
// Group operations by surface to know which surfaces we expect
|
|
129
|
-
const grouped = new Map<string, A2UIOperation[]>();
|
|
130
|
-
for (const op of props.content.operations ?? []) {
|
|
131
|
-
const surfaceId = getOperationSurfaceId(op) ?? DEFAULT_SURFACE_ID;
|
|
132
|
-
if (!grouped.has(surfaceId)) grouped.set(surfaceId, []);
|
|
133
|
-
grouped.get(surfaceId)!.push(op);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
for (const [surfaceId] of grouped) {
|
|
137
|
-
const surface = processorRef.value.model.getSurface(surfaceId);
|
|
138
|
-
if (surface) {
|
|
139
|
-
entries.push({ surfaceId, surface });
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
return entries;
|
|
144
|
-
});
|
|
145
110
|
</script>
|
|
146
111
|
|
|
147
112
|
<template>
|
|
@@ -160,13 +125,13 @@ const surfaceEntries = computed(() => {
|
|
|
160
125
|
data-testid="a2ui-activity-renderer"
|
|
161
126
|
>
|
|
162
127
|
<div
|
|
163
|
-
v-for="
|
|
164
|
-
:key="
|
|
128
|
+
v-for="surface in surfaces"
|
|
129
|
+
:key="surface.id"
|
|
165
130
|
class="cpk-a2ui-message-surface-host"
|
|
166
|
-
:data-surface-id="
|
|
131
|
+
:data-surface-id="surface.id"
|
|
167
132
|
>
|
|
168
133
|
<div class="a2ui-surface cpk-a2ui-message-surface">
|
|
169
|
-
<A2uiSurface :surface="
|
|
134
|
+
<A2uiSurface :surface="surface" />
|
|
170
135
|
</div>
|
|
171
136
|
</div>
|
|
172
137
|
</div>
|
|
@@ -4,9 +4,9 @@ defineOptions({
|
|
|
4
4
|
inheritAttrs: false,
|
|
5
5
|
});
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import type {
|
|
7
|
+
import { onBeforeUnmount, onMounted, ref, useAttrs, watch } from "vue";
|
|
8
|
+
import { ɵmountInspector } from "@copilotkit/web-inspector/mount";
|
|
9
|
+
import type { ɵInspectorMount } from "@copilotkit/web-inspector/mount";
|
|
10
10
|
import type { CopilotKitCoreVue } from "../lib/vue-core";
|
|
11
11
|
import type { VueInspectorOpenRequest } from "../providers/keys";
|
|
12
12
|
|
|
@@ -15,72 +15,125 @@ const props = defineProps<{
|
|
|
15
15
|
openRequest?: VueInspectorOpenRequest | null;
|
|
16
16
|
}>();
|
|
17
17
|
|
|
18
|
+
const emit = defineEmits<{
|
|
19
|
+
"visibility-change": [visible: boolean];
|
|
20
|
+
}>();
|
|
21
|
+
|
|
18
22
|
const attrs = useAttrs();
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
23
|
+
const host = ref<HTMLSpanElement | null>(null);
|
|
24
|
+
let mount: ɵInspectorMount | null = null;
|
|
25
|
+
let appliedAttributes: Record<string, string> = {};
|
|
26
|
+
const boundListeners = new Map<
|
|
27
|
+
string,
|
|
28
|
+
{ eventName: string; listener: (event: Event) => void }
|
|
29
|
+
>();
|
|
30
|
+
|
|
31
|
+
function isListener(name: string, value: unknown) {
|
|
32
|
+
const isHandler = typeof value === "function" || Array.isArray(value);
|
|
33
|
+
return /^on[A-Z]/.test(name) && isHandler;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** `onCpkInspectorVisibilityChange` listens to `cpk-inspector-visibility-change`, as in Vue. */
|
|
37
|
+
function toEventName(name: string) {
|
|
38
|
+
return name
|
|
39
|
+
.slice(2)
|
|
40
|
+
.replace(/\B([A-Z])/g, "-$1")
|
|
41
|
+
.toLowerCase();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Text attributes and listeners go to the Inspector element (the host is only
|
|
45
|
+
// a mount point), so `data-testid` or `@cpk-inspector-visibility-change`
|
|
46
|
+
// land where callers expect them.
|
|
47
|
+
function toAttributes(source: Record<string, unknown>) {
|
|
48
|
+
const attributes: Record<string, string> = {};
|
|
49
|
+
for (const [name, value] of Object.entries(source)) {
|
|
50
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
51
|
+
attributes[name] = String(value);
|
|
52
|
+
} else if (value === true) {
|
|
53
|
+
attributes[name] = "";
|
|
36
54
|
}
|
|
37
|
-
}
|
|
38
|
-
|
|
55
|
+
}
|
|
56
|
+
return attributes;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function callListener(name: string, event: Event) {
|
|
60
|
+
const handler = attrs[name];
|
|
61
|
+
const handlers = Array.isArray(handler) ? handler : [handler];
|
|
62
|
+
for (const candidate of handlers) {
|
|
63
|
+
if (typeof candidate === "function") candidate(event);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function syncListeners(element: Element) {
|
|
68
|
+
const names = Object.keys(attrs).filter((name) =>
|
|
69
|
+
isListener(name, attrs[name]),
|
|
70
|
+
);
|
|
71
|
+
for (const [name, bound] of boundListeners) {
|
|
72
|
+
if (names.includes(name)) continue;
|
|
73
|
+
element.removeEventListener(bound.eventName, bound.listener);
|
|
74
|
+
boundListeners.delete(name);
|
|
75
|
+
}
|
|
76
|
+
for (const name of names) {
|
|
77
|
+
if (boundListeners.has(name)) continue;
|
|
78
|
+
const bound = {
|
|
79
|
+
eventName: toEventName(name),
|
|
80
|
+
listener: (event: Event) => callListener(name, event),
|
|
81
|
+
};
|
|
82
|
+
element.addEventListener(bound.eventName, bound.listener);
|
|
83
|
+
boundListeners.set(name, bound);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function syncAttributes() {
|
|
88
|
+
const element = mount?.element;
|
|
89
|
+
if (!element) return;
|
|
90
|
+
const next = toAttributes(attrs);
|
|
91
|
+
for (const name of Object.keys(appliedAttributes)) {
|
|
92
|
+
if (!(name in next)) element.removeAttribute(name);
|
|
93
|
+
}
|
|
94
|
+
for (const [name, value] of Object.entries(next)) {
|
|
95
|
+
element.setAttribute(name, value);
|
|
96
|
+
}
|
|
97
|
+
appliedAttributes = next;
|
|
98
|
+
syncListeners(element);
|
|
99
|
+
}
|
|
39
100
|
|
|
40
101
|
onMounted(() => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
})
|
|
54
|
-
.catch((error: unknown) => {
|
|
55
|
-
console.error("Failed to load CopilotKit inspector:", error);
|
|
56
|
-
});
|
|
102
|
+
if (!host.value) return;
|
|
103
|
+
mount = ɵmountInspector(host.value, props.core ?? null, {
|
|
104
|
+
load: () => import("@copilotkit/web-inspector"),
|
|
105
|
+
notificationContext: {
|
|
106
|
+
development: process.env.NODE_ENV === "development",
|
|
107
|
+
framework: "vue",
|
|
108
|
+
sdkVersion,
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
mount.onVisibility((visible) => emit("visibility-change", visible));
|
|
112
|
+
mount.onElement(syncAttributes);
|
|
113
|
+
if (props.openRequest) mount.open(props.openRequest);
|
|
57
114
|
});
|
|
58
115
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
116
|
+
onBeforeUnmount(() => {
|
|
117
|
+
boundListeners.clear();
|
|
118
|
+
mount?.dispose();
|
|
119
|
+
mount = null;
|
|
62
120
|
});
|
|
63
121
|
|
|
64
122
|
watch(
|
|
65
123
|
() => props.core,
|
|
66
|
-
(core) =>
|
|
67
|
-
if (inspector.value) inspector.value.core = core ?? null;
|
|
68
|
-
},
|
|
124
|
+
(core) => mount?.setCore(core ?? null),
|
|
69
125
|
);
|
|
70
126
|
|
|
71
127
|
watch(
|
|
72
128
|
() => props.openRequest,
|
|
73
129
|
(request) => {
|
|
74
|
-
if (request)
|
|
130
|
+
if (request) mount?.open(request);
|
|
75
131
|
},
|
|
76
132
|
);
|
|
133
|
+
|
|
134
|
+
watch(() => ({ ...attrs }), syncAttributes);
|
|
77
135
|
</script>
|
|
78
136
|
|
|
79
137
|
<template>
|
|
80
|
-
<
|
|
81
|
-
:is="inspectorTag"
|
|
82
|
-
v-if="inspectorTag"
|
|
83
|
-
v-bind="attrs"
|
|
84
|
-
v-configure-inspector
|
|
85
|
-
/>
|
|
138
|
+
<span ref="host" style="display: contents" />
|
|
86
139
|
</template>
|
|
@@ -1,35 +1,34 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
|
|
2
|
+
import { computed } from "vue";
|
|
3
|
+
import {
|
|
4
|
+
ɵINLINE_FEATURE_WARNING_STYLE,
|
|
5
|
+
ɵgetInlineFeatureWarningSpec,
|
|
6
|
+
} from "@copilotkit/core";
|
|
7
|
+
import { useChatLabels } from "./chat/use-chat-labels";
|
|
8
|
+
|
|
9
|
+
const props = defineProps<{
|
|
3
10
|
featureName: string;
|
|
4
11
|
}>();
|
|
5
12
|
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
borderRadius: "6px",
|
|
11
|
-
fontSize: "13px",
|
|
12
|
-
color: "#92400e",
|
|
13
|
-
fontFamily:
|
|
14
|
-
"-apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif",
|
|
15
|
-
} as const;
|
|
16
|
-
|
|
17
|
-
const linkStyle = {
|
|
18
|
-
color: "#b45309",
|
|
19
|
-
textDecoration: "underline",
|
|
20
|
-
} as const;
|
|
13
|
+
const labels = useChatLabels();
|
|
14
|
+
const spec = computed(() =>
|
|
15
|
+
ɵgetInlineFeatureWarningSpec(props.featureName, labels.value),
|
|
16
|
+
);
|
|
21
17
|
</script>
|
|
22
18
|
|
|
23
19
|
<template>
|
|
24
|
-
<div
|
|
25
|
-
|
|
20
|
+
<div
|
|
21
|
+
:style="ɵINLINE_FEATURE_WARNING_STYLE.container"
|
|
22
|
+
data-testid="copilot-inline-feature-warning"
|
|
23
|
+
>
|
|
24
|
+
{{ spec.message }}
|
|
26
25
|
<a
|
|
27
|
-
href="
|
|
26
|
+
:href="spec.actionUrl"
|
|
28
27
|
target="_blank"
|
|
29
28
|
rel="noopener noreferrer"
|
|
30
|
-
:style="
|
|
29
|
+
:style="ɵINLINE_FEATURE_WARNING_STYLE.link"
|
|
31
30
|
>
|
|
32
|
-
|
|
31
|
+
{{ spec.actionLabel }}
|
|
33
32
|
</a>
|
|
34
33
|
</div>
|
|
35
34
|
</template>
|
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed, onBeforeUnmount, onMounted } from "vue";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
| "no_license"
|
|
11
|
-
| "expired"
|
|
12
|
-
| "expiring"
|
|
13
|
-
| "invalid"
|
|
14
|
-
| "feature_unlicensed";
|
|
3
|
+
import {
|
|
4
|
+
ɵLICENSE_BANNER_STYLE,
|
|
5
|
+
ɵgetLicenseBannerSpec,
|
|
6
|
+
ɵreserveLicenseBannerOffset,
|
|
7
|
+
} from "@copilotkit/core";
|
|
8
|
+
import type { ɵLicenseBannerType } from "@copilotkit/core";
|
|
9
|
+
import { useChatLabels } from "./chat/use-chat-labels";
|
|
15
10
|
|
|
16
11
|
const props = withDefaults(
|
|
17
12
|
defineProps<{
|
|
18
|
-
type:
|
|
13
|
+
type: ɵLicenseBannerType;
|
|
19
14
|
featureName?: string;
|
|
20
15
|
expiryDate?: string;
|
|
21
16
|
graceRemaining?: number;
|
|
@@ -29,152 +24,49 @@ const props = withDefaults(
|
|
|
29
24
|
},
|
|
30
25
|
);
|
|
31
26
|
|
|
32
|
-
|
|
33
|
-
severity: "info" | "warning" | "critical";
|
|
34
|
-
message: string;
|
|
35
|
-
actionLabel: string;
|
|
36
|
-
actionUrl: string;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const spec = computed<BannerSpec | null>(() => {
|
|
40
|
-
switch (props.type) {
|
|
41
|
-
case "no_license":
|
|
42
|
-
return {
|
|
43
|
-
severity: "info",
|
|
44
|
-
message: "Powered by CopilotKit",
|
|
45
|
-
actionLabel: "Get a license",
|
|
46
|
-
actionUrl: "https://copilotkit.ai/pricing",
|
|
47
|
-
};
|
|
48
|
-
case "feature_unlicensed":
|
|
49
|
-
return {
|
|
50
|
-
severity: "warning",
|
|
51
|
-
message: `⚠ The "${props.featureName ?? ""}" feature requires a CopilotKit license.`,
|
|
52
|
-
actionLabel: "Get a license",
|
|
53
|
-
actionUrl: "https://copilotkit.ai/pricing",
|
|
54
|
-
};
|
|
55
|
-
case "expiring": {
|
|
56
|
-
const days = props.graceRemaining;
|
|
57
|
-
const dayLabel = days === 1 ? "day" : "days";
|
|
58
|
-
return {
|
|
59
|
-
severity: "warning",
|
|
60
|
-
message: `Your CopilotKit license expires in ${days} ${dayLabel}. Please renew.`,
|
|
61
|
-
actionLabel: "Renew",
|
|
62
|
-
actionUrl: "https://dashboard.operations.copilotkit.ai",
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
case "expired":
|
|
66
|
-
return {
|
|
67
|
-
severity: "critical",
|
|
68
|
-
message: `Your CopilotKit license expired${props.expiryDate ? ` on ${props.expiryDate}` : ""}. Please renew at copilotkit.ai/pricing`,
|
|
69
|
-
actionLabel: "Renew now",
|
|
70
|
-
actionUrl: "https://copilotkit.ai/pricing",
|
|
71
|
-
};
|
|
72
|
-
case "invalid":
|
|
73
|
-
return {
|
|
74
|
-
severity: "critical",
|
|
75
|
-
message:
|
|
76
|
-
"Invalid CopilotKit license token. Please check your configuration.",
|
|
77
|
-
actionLabel: "Get a license",
|
|
78
|
-
actionUrl: "https://copilotkit.ai/pricing",
|
|
79
|
-
};
|
|
80
|
-
default:
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
const baseStyle = {
|
|
86
|
-
position: "fixed",
|
|
87
|
-
bottom: "8px",
|
|
88
|
-
left: "50%",
|
|
89
|
-
transform: "translateX(-50%)",
|
|
90
|
-
zIndex: 99999,
|
|
91
|
-
display: "inline-flex",
|
|
92
|
-
alignItems: "center",
|
|
93
|
-
gap: "12px",
|
|
94
|
-
whiteSpace: "nowrap",
|
|
95
|
-
padding: "8px 16px",
|
|
96
|
-
fontSize: "13px",
|
|
97
|
-
fontFamily:
|
|
98
|
-
"-apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif",
|
|
99
|
-
borderRadius: "6px",
|
|
100
|
-
boxShadow: "0 2px 8px rgba(0, 0, 0, 0.15)",
|
|
101
|
-
} as const;
|
|
27
|
+
const labels = useChatLabels();
|
|
102
28
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
case "critical":
|
|
112
|
-
return {
|
|
113
|
-
backgroundColor: "#fef2f2",
|
|
114
|
-
border: "1px solid #fca5a5",
|
|
115
|
-
color: "#991b1b",
|
|
116
|
-
};
|
|
117
|
-
default:
|
|
118
|
-
return {
|
|
119
|
-
backgroundColor: "#eff6ff",
|
|
120
|
-
border: "1px solid #93c5fd",
|
|
121
|
-
color: "#1e40af",
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
});
|
|
29
|
+
// Core picks the text, link, and severity; this component renders them.
|
|
30
|
+
const spec = computed(() =>
|
|
31
|
+
ɵgetLicenseBannerSpec(props.type, labels.value, {
|
|
32
|
+
featureName: props.featureName,
|
|
33
|
+
expiryDate: props.expiryDate,
|
|
34
|
+
graceRemaining: props.graceRemaining,
|
|
35
|
+
}),
|
|
36
|
+
);
|
|
125
37
|
|
|
126
38
|
const containerStyle = computed(() => ({
|
|
127
|
-
|
|
128
|
-
|
|
39
|
+
...ɵLICENSE_BANNER_STYLE.base,
|
|
40
|
+
...ɵLICENSE_BANNER_STYLE.severity[spec.value.severity],
|
|
129
41
|
}));
|
|
130
42
|
|
|
131
43
|
// Publish the banner's reserved bottom offset so the chat input can lift
|
|
132
44
|
// itself above it via padding-bottom: var(--copilotkit-license-banner-offset).
|
|
45
|
+
let releaseOffset: (() => void) | undefined;
|
|
133
46
|
onMounted(() => {
|
|
134
|
-
|
|
135
|
-
document.documentElement.style.setProperty(
|
|
136
|
-
LICENSE_BANNER_OFFSET_VAR,
|
|
137
|
-
`${LICENSE_BANNER_OFFSET_PX}px`,
|
|
138
|
-
);
|
|
47
|
+
releaseOffset = ɵreserveLicenseBannerOffset();
|
|
139
48
|
});
|
|
140
|
-
|
|
141
49
|
onBeforeUnmount(() => {
|
|
142
|
-
|
|
143
|
-
|
|
50
|
+
releaseOffset?.();
|
|
51
|
+
releaseOffset = undefined;
|
|
144
52
|
});
|
|
145
53
|
</script>
|
|
146
54
|
|
|
147
55
|
<template>
|
|
148
|
-
<div
|
|
56
|
+
<div :style="containerStyle" data-testid="copilot-license-banner">
|
|
149
57
|
<span>{{ spec.message }}</span>
|
|
150
|
-
<div
|
|
151
|
-
:style="{
|
|
152
|
-
display: 'flex',
|
|
153
|
-
gap: '8px',
|
|
154
|
-
alignItems: 'center',
|
|
155
|
-
}"
|
|
156
|
-
>
|
|
58
|
+
<div :style="ɵLICENSE_BANNER_STYLE.actions">
|
|
157
59
|
<a
|
|
158
60
|
:href="spec.actionUrl"
|
|
159
61
|
target="_blank"
|
|
160
62
|
rel="noopener noreferrer"
|
|
161
|
-
:style="
|
|
162
|
-
fontWeight: 600,
|
|
163
|
-
textDecoration: 'underline',
|
|
164
|
-
color: 'inherit',
|
|
165
|
-
}"
|
|
63
|
+
:style="ɵLICENSE_BANNER_STYLE.link"
|
|
166
64
|
>
|
|
167
65
|
{{ spec.actionLabel }}
|
|
168
66
|
</a>
|
|
169
67
|
<button
|
|
170
68
|
v-if="props.onDismiss"
|
|
171
|
-
:style="
|
|
172
|
-
background: 'none',
|
|
173
|
-
border: 'none',
|
|
174
|
-
cursor: 'pointer',
|
|
175
|
-
color: 'inherit',
|
|
176
|
-
fontSize: '16px',
|
|
177
|
-
}"
|
|
69
|
+
:style="ɵLICENSE_BANNER_STYLE.dismiss"
|
|
178
70
|
@click="props.onDismiss"
|
|
179
71
|
>
|
|
180
72
|
×
|