@copilotkit/vue 2.0.0-rc.3 → 2.0.0-rc.31
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/CONTRIBUTOR_GUIDE.md +1 -1
- 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-BMTHA_P2.js +15901 -0
- package/dist/use-render-activity-message-BMTHA_P2.js.map +1 -0
- package/dist/use-render-activity-message-CH3beu7z.cjs +113 -0
- package/dist/use-render-activity-message-CH3beu7z.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 +3 -11
- 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 +7 -286
- 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 +4 -4
- 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 +38 -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 +2 -7
- 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-render-tool.d.ts +1 -1
- package/dist/v2/hooks/use-render-tool.d.ts.map +1 -1
- package/dist/v2/hooks/use-suggestions.d.ts.map +1 -1
- package/dist/v2/hooks/use-threads.d.ts +6 -23
- 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 +33 -19
- 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/defineToolCallRenderer.d.ts +1 -1
- package/dist/v2/types/defineToolCallRenderer.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 +12 -13
- package/src/__tests__/build-entries.test.ts +29 -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 +6 -26
- 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 +121 -498
- package/src/v2/components/chat/CopilotChatAssistantMessage.vue +47 -184
- 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 +12 -77
- package/src/v2/components/chat/CopilotChatInput.vue +139 -654
- 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 +96 -274
- package/src/v2/components/chat/CopilotChatReasoningMessage.vue +27 -62
- 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 +123 -161
- 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 +49 -185
- 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 +56 -100
- package/src/v2/components/chat/CopilotThreadsDrawer.vue +43 -105
- 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 +132 -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__/CopilotChatView.pinToSend.test.ts +43 -1
- 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 +25 -90
- 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 +92 -195
- 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 +29 -220
- package/src/v2/hooks/use-default-render-tool.ts +31 -152
- package/src/v2/hooks/use-frontend-tool.ts +15 -25
- 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 +35 -57
- package/src/v2/hooks/use-render-custom-messages.ts +24 -88
- package/src/v2/hooks/use-render-tool.ts +2 -4
- package/src/v2/hooks/use-suggestions.ts +17 -36
- package/src/v2/hooks/use-threads.ts +49 -288
- 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 +90 -85
- package/src/v2/providers/CopilotChatConfigurationProvider.vue +48 -186
- package/src/v2/providers/CopilotKitProvider.types.ts +12 -132
- package/src/v2/providers/CopilotKitProvider.vue +291 -641
- package/src/v2/providers/__tests__/CopilotChatConfigurationProvider.test.ts +22 -2
- package/src/v2/providers/__tests__/CopilotKitProvider.a2ui.test.ts +38 -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 +88 -28
- 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 +7 -6
- 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
package/src/v2/lib/vue-core.ts
CHANGED
|
@@ -5,15 +5,16 @@ import type {
|
|
|
5
5
|
VueCustomMessageRenderer,
|
|
6
6
|
} from "../types";
|
|
7
7
|
import type { InterruptRenderProps } from "../types/interrupt";
|
|
8
|
-
import { CopilotKitCore } from "@copilotkit/core";
|
|
8
|
+
import { CopilotKitCore, ɵRendererRegistry } from "@copilotkit/core";
|
|
9
9
|
import type {
|
|
10
10
|
CopilotKitCoreConfig,
|
|
11
11
|
CopilotKitCoreSubscriber,
|
|
12
12
|
CopilotKitCoreSubscription,
|
|
13
|
+
ɵRendererKind,
|
|
13
14
|
} from "@copilotkit/core";
|
|
14
15
|
|
|
15
16
|
export interface CopilotKitCoreVueConfig extends CopilotKitCoreConfig {
|
|
16
|
-
renderToolCalls?: VueToolCallRenderer
|
|
17
|
+
renderToolCalls?: VueToolCallRenderer[];
|
|
17
18
|
renderActivityMessages?: VueActivityMessageRenderer<unknown>[];
|
|
18
19
|
renderCustomMessages?: VueCustomMessageRenderer[];
|
|
19
20
|
}
|
|
@@ -21,132 +22,140 @@ export interface CopilotKitCoreVueConfig extends CopilotKitCoreConfig {
|
|
|
21
22
|
export interface CopilotKitCoreVueSubscriber extends CopilotKitCoreSubscriber {
|
|
22
23
|
onRenderToolCallsChanged?: (event: {
|
|
23
24
|
copilotkit: CopilotKitCoreVue;
|
|
24
|
-
renderToolCalls: VueToolCallRenderer
|
|
25
|
+
renderToolCalls: VueToolCallRenderer[];
|
|
25
26
|
}) => void | Promise<void>;
|
|
26
27
|
onRenderCustomMessagesChanged?: (event: {
|
|
27
28
|
copilotkit: CopilotKitCoreVue;
|
|
28
29
|
renderCustomMessages: VueCustomMessageRenderer[];
|
|
29
30
|
}) => void | Promise<void>;
|
|
31
|
+
onRenderActivityMessagesChanged?: (event: {
|
|
32
|
+
copilotkit: CopilotKitCoreVue;
|
|
33
|
+
renderActivityMessages: VueActivityMessageRenderer<unknown>[];
|
|
34
|
+
}) => void | Promise<void>;
|
|
30
35
|
onInterruptStateChanged?: (event: {
|
|
31
36
|
copilotkit: CopilotKitCoreVue;
|
|
32
|
-
interruptState: InterruptRenderProps<unknown
|
|
37
|
+
interruptState: InterruptRenderProps<unknown> | null;
|
|
33
38
|
}) => void | Promise<void>;
|
|
34
39
|
}
|
|
35
40
|
|
|
36
41
|
export class CopilotKitCoreVue extends CopilotKitCore {
|
|
37
|
-
private
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
private _renderCustomMessages: VueCustomMessageRenderer[] = [];
|
|
43
|
-
private _renderActivityMessages: VueActivityMessageRenderer<unknown>[] = [];
|
|
44
|
-
private _interruptState: InterruptRenderProps<unknown, unknown> | null = null;
|
|
42
|
+
private readonly _renderers: ɵRendererRegistry<
|
|
43
|
+
VueToolCallRenderer,
|
|
44
|
+
VueActivityMessageRenderer<unknown>,
|
|
45
|
+
VueCustomMessageRenderer
|
|
46
|
+
>;
|
|
45
47
|
|
|
46
48
|
constructor(config: CopilotKitCoreVueConfig) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
this.
|
|
49
|
+
// Tool handlers can change reactive state. `nextTick` lets Vue flush those
|
|
50
|
+
// updates before core starts the follow-up run.
|
|
51
|
+
super({ ...config, ɵwaitForFrameworkUpdates: () => nextTick() });
|
|
52
|
+
this._renderers = new ɵRendererRegistry({
|
|
53
|
+
toolCalls: config.renderToolCalls,
|
|
54
|
+
activity: config.renderActivityMessages,
|
|
55
|
+
custom: config.renderCustomMessages,
|
|
56
|
+
});
|
|
57
|
+
this._renderers.subscribe((kind) => this.notifyRenderersChanged(kind));
|
|
58
|
+
// The props live in core's generic interrupt slot; keep the Vue
|
|
59
|
+
// subscriber event for existing listeners.
|
|
60
|
+
this.ɵsubscribeToInterruptPayload(() => {
|
|
61
|
+
void this.notifySubscribers((subscriber) => {
|
|
62
|
+
const vueSubscriber = subscriber as CopilotKitCoreVueSubscriber;
|
|
63
|
+
return vueSubscriber.onInterruptStateChanged?.({
|
|
64
|
+
copilotkit: this,
|
|
65
|
+
interruptState: this.interruptState,
|
|
66
|
+
});
|
|
67
|
+
}, "Subscriber onInterruptStateChanged error:");
|
|
68
|
+
});
|
|
51
69
|
}
|
|
52
70
|
|
|
53
|
-
get renderCustomMessages()
|
|
54
|
-
return this.
|
|
71
|
+
get renderCustomMessages() {
|
|
72
|
+
return this._renderers.custom;
|
|
55
73
|
}
|
|
56
74
|
|
|
57
|
-
get renderActivityMessages()
|
|
58
|
-
|
|
59
|
-
> {
|
|
60
|
-
return this._renderActivityMessages;
|
|
75
|
+
get renderActivityMessages() {
|
|
76
|
+
return this._renderers.activity;
|
|
61
77
|
}
|
|
62
78
|
|
|
63
79
|
setRenderActivityMessages(
|
|
64
80
|
renderers: VueActivityMessageRenderer<unknown>[],
|
|
65
81
|
): void {
|
|
66
|
-
this.
|
|
82
|
+
this._renderers.setActivity(renderers);
|
|
67
83
|
}
|
|
68
84
|
|
|
69
85
|
setRenderCustomMessages(renderers: VueCustomMessageRenderer[]): void {
|
|
70
|
-
this.
|
|
71
|
-
void this.notifySubscribers((subscriber) => {
|
|
72
|
-
const vueSubscriber = subscriber as CopilotKitCoreVueSubscriber;
|
|
73
|
-
vueSubscriber.onRenderCustomMessagesChanged?.({
|
|
74
|
-
copilotkit: this,
|
|
75
|
-
renderCustomMessages: [...this.renderCustomMessages],
|
|
76
|
-
});
|
|
77
|
-
}, "Subscriber onRenderCustomMessagesChanged error:");
|
|
86
|
+
this._renderers.setCustom(renderers);
|
|
78
87
|
}
|
|
79
88
|
|
|
80
|
-
|
|
81
|
-
|
|
89
|
+
/**
|
|
90
|
+
* The renderers the provider was given, without hook or built-in
|
|
91
|
+
* renderers. Nothing in CopilotKit reads it now; it stays for app code.
|
|
92
|
+
*/
|
|
93
|
+
get propRenderToolCalls() {
|
|
94
|
+
return this._renderers.propToolCalls;
|
|
82
95
|
}
|
|
83
96
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
const merged = new Map<string, VueToolCallRenderer<unknown>>();
|
|
92
|
-
for (const rc of this._renderToolCalls) {
|
|
93
|
-
merged.set(`${rc.agentId ?? ""}:${rc.name}`, rc);
|
|
94
|
-
}
|
|
95
|
-
for (const [key, rc] of this._hookRenderToolCalls) {
|
|
96
|
-
merged.set(key, rc);
|
|
97
|
-
}
|
|
98
|
-
this._cachedMergedRenderToolCalls = Array.from(merged.values());
|
|
99
|
-
return this._cachedMergedRenderToolCalls;
|
|
97
|
+
/**
|
|
98
|
+
* Prop, hook and built-in renderers merged. For one name and agentId, a
|
|
99
|
+
* hook renderer wins over a prop one, and both win over a built-in one.
|
|
100
|
+
*/
|
|
101
|
+
get renderToolCalls() {
|
|
102
|
+
return this._renderers.toolCalls;
|
|
100
103
|
}
|
|
101
104
|
|
|
102
|
-
get interruptState(): InterruptRenderProps<unknown
|
|
103
|
-
return this
|
|
105
|
+
get interruptState(): InterruptRenderProps<unknown> | null {
|
|
106
|
+
return this.ɵinterruptPayload as InterruptRenderProps<unknown> | null;
|
|
104
107
|
}
|
|
105
108
|
|
|
106
|
-
setRenderToolCalls(renderToolCalls: VueToolCallRenderer
|
|
107
|
-
this.
|
|
108
|
-
this._cachedMergedRenderToolCalls = null;
|
|
109
|
-
this._notifyRenderToolCallsChanged();
|
|
109
|
+
setRenderToolCalls(renderToolCalls: VueToolCallRenderer[]): void {
|
|
110
|
+
this._renderers.setPropToolCalls(renderToolCalls);
|
|
110
111
|
}
|
|
111
112
|
|
|
112
|
-
addHookRenderToolCall(entry: VueToolCallRenderer
|
|
113
|
-
|
|
114
|
-
this._hookRenderToolCalls.set(key, entry);
|
|
115
|
-
this._cachedMergedRenderToolCalls = null;
|
|
116
|
-
this._notifyRenderToolCallsChanged();
|
|
113
|
+
addHookRenderToolCall(entry: VueToolCallRenderer): void {
|
|
114
|
+
this._renderers.addHookToolCall(entry);
|
|
117
115
|
}
|
|
118
116
|
|
|
119
117
|
removeHookRenderToolCall(name: string, agentId?: string): void {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
118
|
+
this._renderers.removeHookToolCall(name, agentId);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* @internal Add a renderer for a tool a built-in feature owns (A2UI,
|
|
123
|
+
* generative UI). Prop and hook renderers with the same name and agent win
|
|
124
|
+
* over it, and `setRenderToolCalls` never removes it.
|
|
125
|
+
*
|
|
126
|
+
* @returns A function that removes the renderer.
|
|
127
|
+
*/
|
|
128
|
+
ɵaddBuiltInRenderToolCall(entry: VueToolCallRenderer): () => void {
|
|
129
|
+
return this._renderers.addBuiltInToolCall(entry);
|
|
125
130
|
}
|
|
126
131
|
|
|
127
|
-
private
|
|
132
|
+
private notifyRenderersChanged(kind: ɵRendererKind): void {
|
|
128
133
|
void this.notifySubscribers((subscriber) => {
|
|
129
134
|
const vueSubscriber = subscriber as CopilotKitCoreVueSubscriber;
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
+
switch (kind) {
|
|
136
|
+
case "toolCalls":
|
|
137
|
+
return vueSubscriber.onRenderToolCallsChanged?.({
|
|
138
|
+
copilotkit: this,
|
|
139
|
+
renderToolCalls: [...this.renderToolCalls],
|
|
140
|
+
});
|
|
141
|
+
case "activity":
|
|
142
|
+
return vueSubscriber.onRenderActivityMessagesChanged?.({
|
|
143
|
+
copilotkit: this,
|
|
144
|
+
renderActivityMessages: [...this.renderActivityMessages],
|
|
145
|
+
});
|
|
146
|
+
case "custom":
|
|
147
|
+
return vueSubscriber.onRenderCustomMessagesChanged?.({
|
|
148
|
+
copilotkit: this,
|
|
149
|
+
renderCustomMessages: [...this.renderCustomMessages],
|
|
150
|
+
});
|
|
135
151
|
}
|
|
136
|
-
},
|
|
152
|
+
}, `Subscriber renderer change (${kind}) error:`);
|
|
137
153
|
}
|
|
138
154
|
|
|
139
155
|
setInterruptState(
|
|
140
|
-
interruptState: InterruptRenderProps<unknown
|
|
156
|
+
interruptState: InterruptRenderProps<unknown> | null,
|
|
141
157
|
): void {
|
|
142
|
-
this
|
|
143
|
-
void this.notifySubscribers((subscriber) => {
|
|
144
|
-
const vueSubscriber = subscriber as CopilotKitCoreVueSubscriber;
|
|
145
|
-
vueSubscriber.onInterruptStateChanged?.({
|
|
146
|
-
copilotkit: this,
|
|
147
|
-
interruptState: this._interruptState,
|
|
148
|
-
});
|
|
149
|
-
}, "Subscriber onInterruptStateChanged error:");
|
|
158
|
+
this.ɵsetInterruptPayload(interruptState);
|
|
150
159
|
}
|
|
151
160
|
|
|
152
161
|
subscribe(
|
|
@@ -154,8 +163,4 @@ export class CopilotKitCoreVue extends CopilotKitCore {
|
|
|
154
163
|
): CopilotKitCoreSubscription {
|
|
155
164
|
return super.subscribe(subscriber);
|
|
156
165
|
}
|
|
157
|
-
|
|
158
|
-
async waitForPendingFrameworkUpdates(): Promise<void> {
|
|
159
|
-
await nextTick();
|
|
160
|
-
}
|
|
161
166
|
}
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
computed,
|
|
4
|
+
inject,
|
|
5
|
+
onBeforeUnmount,
|
|
6
|
+
onMounted,
|
|
7
|
+
provide,
|
|
8
|
+
shallowRef,
|
|
9
|
+
watch,
|
|
10
|
+
} from "vue";
|
|
11
|
+
import { ɵChatConfigurationStore } from "@copilotkit/core";
|
|
3
12
|
import type { ComputedRef } from "vue";
|
|
4
|
-
import { DEFAULT_AGENT_ID, randomUUID } from "@copilotkit/shared";
|
|
5
|
-
import type { OpenThreadRegistration } from "@copilotkit/core";
|
|
6
13
|
import { CopilotChatConfigurationKey, CopilotKitKey } from "./keys";
|
|
14
|
+
import { ChatConfigurationStoreKey } from "./chat-configuration-store-key";
|
|
7
15
|
import { CopilotChatDefaultLabels } from "./types";
|
|
8
16
|
import type { CopilotChatConfigurationValue, CopilotChatLabels } from "./types";
|
|
9
17
|
import type { CopilotChatConfigurationProviderProps } from "./CopilotChatConfigurationProvider.types";
|
|
10
18
|
import { useShallowStableRef } from "../lib/shallow-stable";
|
|
11
|
-
import { isMobileViewport } from "../lib/is-mobile-viewport";
|
|
12
19
|
|
|
13
|
-
// Vue normalizes optional Boolean props to `false` when not supplied; declare
|
|
14
|
-
// `undefined` defaults so we can faithfully distinguish "caller passed false"
|
|
15
|
-
// from "caller did not pass the prop", matching React's prop semantics.
|
|
16
20
|
const props = withDefaults(
|
|
17
21
|
defineProps<CopilotChatConfigurationProviderProps>(),
|
|
18
22
|
{
|
|
@@ -25,210 +29,68 @@ const parentConfig = inject<ComputedRef<CopilotChatConfigurationValue> | null>(
|
|
|
25
29
|
CopilotChatConfigurationKey,
|
|
26
30
|
null,
|
|
27
31
|
);
|
|
28
|
-
const parentConfigValue = computed(() => parentConfig?.value ?? null);
|
|
29
32
|
|
|
30
|
-
//
|
|
31
|
-
//
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
// Core owns thread, agent, modal and drawer resolution across the provider
|
|
34
|
+
// chain; this component feeds it props and projects its snapshot.
|
|
35
|
+
const readOptions = () => ({
|
|
36
|
+
agentId: props.agentId,
|
|
37
|
+
threadId: props.threadId,
|
|
38
|
+
hasExplicitThreadId: props.hasExplicitThreadId,
|
|
39
|
+
isModalDefaultOpen: props.isModalDefaultOpen,
|
|
40
|
+
});
|
|
41
|
+
const store = new ɵChatConfigurationStore(
|
|
42
|
+
readOptions(),
|
|
43
|
+
inject(ChatConfigurationStoreKey, null),
|
|
35
44
|
);
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
45
|
+
const snapshot = shallowRef(store.getSnapshot());
|
|
46
|
+
const unsubscribe = store.subscribe(() => {
|
|
47
|
+
snapshot.value = store.getSnapshot();
|
|
48
|
+
});
|
|
49
|
+
watch(readOptions, (options) => store.update(options));
|
|
50
|
+
onBeforeUnmount(() => {
|
|
51
|
+
unsubscribe();
|
|
52
|
+
store.dispose();
|
|
53
|
+
});
|
|
42
54
|
|
|
43
55
|
const stableLabels = useShallowStableRef(computed(() => props.labels));
|
|
44
56
|
|
|
45
57
|
const mergedLabels = computed<CopilotChatLabels>(() => ({
|
|
46
58
|
...CopilotChatDefaultLabels,
|
|
47
|
-
...
|
|
59
|
+
...parentConfig?.value?.labels,
|
|
48
60
|
...stableLabels.value,
|
|
49
61
|
}));
|
|
50
62
|
|
|
51
|
-
const resolvedAgentId = computed(
|
|
52
|
-
() => props.agentId ?? parentConfigValue.value?.agentId ?? DEFAULT_AGENT_ID,
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
const fallbackThreadId = randomUUID();
|
|
56
|
-
const resolvedThreadId = computed(() => {
|
|
57
|
-
if (propIsAuthoritative.value) return props.threadId as string;
|
|
58
|
-
if (activeThreadOverride.value) return activeThreadOverride.value.threadId;
|
|
59
|
-
if (props.threadId) return props.threadId;
|
|
60
|
-
if (parentConfigValue.value?.threadId)
|
|
61
|
-
return parentConfigValue.value.threadId;
|
|
62
|
-
return fallbackThreadId;
|
|
63
|
-
});
|
|
64
|
-
|
|
65
63
|
// Tell Core which Thread this view shows, so captured interactions can link
|
|
66
|
-
// to it.
|
|
67
|
-
// is nothing to register with. Registration starts on mount, so a server
|
|
68
|
-
// render never registers a Thread that it can't unregister.
|
|
64
|
+
// to it. Works without a CopilotKitProvider: then there is nothing to register.
|
|
69
65
|
const copilotKitContext = inject(CopilotKitKey, null);
|
|
70
|
-
let openThread: OpenThreadRegistration | null = null;
|
|
71
66
|
onMounted(() => {
|
|
72
67
|
watch(
|
|
73
|
-
() =>
|
|
74
|
-
(
|
|
68
|
+
() => copilotKitContext?.copilotkit.value,
|
|
69
|
+
(core, _previous, onCleanup) => {
|
|
75
70
|
if (!core) return;
|
|
76
|
-
|
|
77
|
-
agentId,
|
|
78
|
-
threadId: resolvedThreadId.value,
|
|
79
|
-
});
|
|
80
|
-
openThread = registration;
|
|
81
|
-
onCleanup(() => {
|
|
82
|
-
registration.unregister();
|
|
83
|
-
openThread = null;
|
|
84
|
-
});
|
|
71
|
+
onCleanup(store.bindOpenThread(core));
|
|
85
72
|
},
|
|
86
73
|
{ immediate: true },
|
|
87
74
|
);
|
|
88
|
-
watch(resolvedThreadId, (threadId) => openThread?.update(threadId));
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
const resolvedHasExplicitThreadId = computed(() => {
|
|
92
|
-
if (propIsAuthoritative.value) return true;
|
|
93
|
-
const own = activeThreadOverride.value
|
|
94
|
-
? activeThreadOverride.value.explicit
|
|
95
|
-
: props.hasExplicitThreadId !== undefined
|
|
96
|
-
? props.hasExplicitThreadId
|
|
97
|
-
: !!props.threadId;
|
|
98
|
-
return own || !!parentConfigValue.value?.hasExplicitThreadId;
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
const shouldCreateModalState = computed(
|
|
102
|
-
() => props.isModalDefaultOpen !== undefined,
|
|
103
|
-
);
|
|
104
|
-
const resolvedDefaultOpen = computed(() => props.isModalDefaultOpen ?? true);
|
|
105
|
-
|
|
106
|
-
const internalModalOpen = ref<boolean>(
|
|
107
|
-
parentConfigValue.value?.isModalOpen ?? resolvedDefaultOpen.value,
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
function setInternalModalOpen(open: boolean) {
|
|
111
|
-
internalModalOpen.value = open;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const resolvedIsModalOpen = computed(() =>
|
|
115
|
-
shouldCreateModalState.value
|
|
116
|
-
? internalModalOpen.value
|
|
117
|
-
: parentConfigValue.value?.isModalOpen,
|
|
118
|
-
);
|
|
119
|
-
const resolvedSetModalOpen = computed(() =>
|
|
120
|
-
shouldCreateModalState.value
|
|
121
|
-
? setInternalModalOpen
|
|
122
|
-
: parentConfigValue.value?.setModalOpen,
|
|
123
|
-
);
|
|
124
|
-
|
|
125
|
-
function setActiveThreadId(threadId: string, options?: { explicit?: boolean }) {
|
|
126
|
-
if (propIsAuthoritative.value) {
|
|
127
|
-
console.warn(
|
|
128
|
-
"[CopilotKit] Ignoring setActiveThreadId(): threadId is controlled " +
|
|
129
|
-
"via the `threadId` prop on CopilotChatConfigurationProvider.",
|
|
130
|
-
);
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
activeThreadOverride.value = {
|
|
134
|
-
threadId,
|
|
135
|
-
explicit: options?.explicit ?? true,
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
function startNewThread() {
|
|
140
|
-
if (propIsAuthoritative.value) {
|
|
141
|
-
console.warn(
|
|
142
|
-
"[CopilotKit] Ignoring startNewThread(): threadId is controlled via " +
|
|
143
|
-
"the `threadId` prop on CopilotChatConfigurationProvider.",
|
|
144
|
-
);
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
activeThreadOverride.value = { threadId: randomUUID(), explicit: false };
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// Drawer presence + open state. The top-most provider owns the state; a nested
|
|
151
|
-
// provider proxies its parent so the whole chain shares one drawer.
|
|
152
|
-
const ownDrawerOpen = ref(false);
|
|
153
|
-
const ownDrawerCount = ref(0);
|
|
154
|
-
|
|
155
|
-
function ownSetDrawerOpen(open: boolean) {
|
|
156
|
-
ownDrawerOpen.value = open;
|
|
157
|
-
// Mobile mutual-exclusion: opening the drawer closes the chat modal.
|
|
158
|
-
if (open && isMobileViewport()) {
|
|
159
|
-
resolvedSetModalOpen.value?.(false);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
function ownRegisterDrawer(): () => void {
|
|
164
|
-
ownDrawerCount.value += 1;
|
|
165
|
-
return () => {
|
|
166
|
-
ownDrawerCount.value = Math.max(0, ownDrawerCount.value - 1);
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
const resolvedDrawerOpen = computed(() =>
|
|
171
|
-
parentConfigValue.value
|
|
172
|
-
? parentConfigValue.value.drawerOpen
|
|
173
|
-
: ownDrawerOpen.value,
|
|
174
|
-
);
|
|
175
|
-
const resolvedSetDrawerOpen = computed(() =>
|
|
176
|
-
parentConfigValue.value
|
|
177
|
-
? parentConfigValue.value.setDrawerOpen
|
|
178
|
-
: ownSetDrawerOpen,
|
|
179
|
-
);
|
|
180
|
-
const resolvedDrawerRegistered = computed(() =>
|
|
181
|
-
parentConfigValue.value
|
|
182
|
-
? parentConfigValue.value.drawerRegistered
|
|
183
|
-
: ownDrawerCount.value > 0,
|
|
184
|
-
);
|
|
185
|
-
const resolvedRegisterDrawer = computed(() =>
|
|
186
|
-
parentConfigValue.value
|
|
187
|
-
? parentConfigValue.value.registerDrawer
|
|
188
|
-
: ownRegisterDrawer,
|
|
189
|
-
);
|
|
190
|
-
|
|
191
|
-
// Public modal setter (mobile mutual-exclusion, other direction: opening the
|
|
192
|
-
// chat modal closes the drawer). Preserve the contract that it is `undefined`
|
|
193
|
-
// when this provider owns no modal state AND no parent provides one —
|
|
194
|
-
// CopilotChatToggleButton relies on that absence to fall back to its own
|
|
195
|
-
// local open-state. When a real modal setter exists (own `isModalDefaultOpen`
|
|
196
|
-
// state or an inherited parent setter), wrap it so opening the modal on
|
|
197
|
-
// mobile also closes the drawer.
|
|
198
|
-
//
|
|
199
|
-
// Note: this diverges from the React reference (CopilotChatConfigurationProvider.tsx),
|
|
200
|
-
// which keeps `setModalOpen` always-defined and always backed by internal state. We
|
|
201
|
-
// intentionally take the minimal Vue-local fix here — preserving the `undefined`
|
|
202
|
-
// contract CopilotChatToggleButton depends on — rather than also reworking
|
|
203
|
-
// `resolvedIsModalOpen`'s backing, to avoid changing bare-provider modal-open
|
|
204
|
-
// semantics.
|
|
205
|
-
const publicSetModalOpen = computed(() => {
|
|
206
|
-
const base = resolvedSetModalOpen.value; // undefined when no modal state + no parent
|
|
207
|
-
if (!base) return undefined;
|
|
208
|
-
return (open: boolean) => {
|
|
209
|
-
if (open && isMobileViewport()) {
|
|
210
|
-
resolvedSetDrawerOpen.value?.(false);
|
|
211
|
-
}
|
|
212
|
-
base(open);
|
|
213
|
-
};
|
|
214
75
|
});
|
|
215
76
|
|
|
216
77
|
const configurationValue = computed<CopilotChatConfigurationValue>(() => ({
|
|
217
78
|
labels: mergedLabels.value,
|
|
218
|
-
agentId:
|
|
219
|
-
threadId:
|
|
220
|
-
hasExplicitThreadId:
|
|
221
|
-
isModalOpen:
|
|
222
|
-
setModalOpen:
|
|
223
|
-
drawerOpen:
|
|
224
|
-
setDrawerOpen:
|
|
225
|
-
drawerRegistered:
|
|
226
|
-
registerDrawer:
|
|
227
|
-
setActiveThreadId,
|
|
228
|
-
startNewThread,
|
|
79
|
+
agentId: snapshot.value.agentId,
|
|
80
|
+
threadId: snapshot.value.threadId,
|
|
81
|
+
hasExplicitThreadId: snapshot.value.hasExplicitThreadId,
|
|
82
|
+
isModalOpen: snapshot.value.isModalOpen,
|
|
83
|
+
setModalOpen: store.setModalOpen,
|
|
84
|
+
drawerOpen: snapshot.value.drawerOpen,
|
|
85
|
+
setDrawerOpen: store.setDrawerOpen,
|
|
86
|
+
drawerRegistered: snapshot.value.drawerRegistered,
|
|
87
|
+
registerDrawer: store.registerDrawer,
|
|
88
|
+
setActiveThreadId: store.setActiveThreadId,
|
|
89
|
+
startNewThread: store.startNewThread,
|
|
229
90
|
}));
|
|
230
91
|
|
|
231
92
|
provide(CopilotChatConfigurationKey, configurationValue);
|
|
93
|
+
provide(ChatConfigurationStoreKey, store);
|
|
232
94
|
</script>
|
|
233
95
|
|
|
234
96
|
<template>
|