@copilotkit/vue 2.0.0-rc.3 → 2.0.0-rc.30
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-BZJ33B_r.cjs +113 -0
- package/dist/use-render-activity-message-BZJ33B_r.cjs.map +1 -0
- package/dist/use-render-activity-message-DrR407LQ.js +15901 -0
- package/dist/use-render-activity-message-DrR407LQ.js.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
|
@@ -10,8 +10,14 @@
|
|
|
10
10
|
* a custom wildcard renderer draws whatever it draws.
|
|
11
11
|
*/
|
|
12
12
|
import { computed, provide, ref } from "vue";
|
|
13
|
+
import {
|
|
14
|
+
ɵformatLabel,
|
|
15
|
+
ɵformatToolNames,
|
|
16
|
+
ɵgetToolCallGroupState,
|
|
17
|
+
ɵformatCountLabel,
|
|
18
|
+
} from "@copilotkit/core";
|
|
19
|
+
import type { ToolCallEntry } from "@copilotkit/core";
|
|
13
20
|
import { useCopilotId } from "../ui/use-id";
|
|
14
|
-
import type { ToolCallEntry } from "./tool-call-layout";
|
|
15
21
|
import { ToolCallGroupContextKey } from "./tool-call-display-context";
|
|
16
22
|
import type { ToolCallGroupContextValue } from "./tool-call-display-context";
|
|
17
23
|
import {
|
|
@@ -19,13 +25,9 @@ import {
|
|
|
19
25
|
ToolCallChevron,
|
|
20
26
|
ToolCallFailedCount,
|
|
21
27
|
ToolCallStatusIcon,
|
|
22
|
-
|
|
23
|
-
entryStatus,
|
|
24
|
-
pluralize,
|
|
25
|
-
statusLabels,
|
|
26
|
-
toolNames,
|
|
28
|
+
toolCallStatusLabel,
|
|
27
29
|
} from "./tool-call-group-parts";
|
|
28
|
-
import
|
|
30
|
+
import { useChatLabels } from "./use-chat-labels";
|
|
29
31
|
import type { CopilotChatToolCallGroupAppearance } from "./types";
|
|
30
32
|
|
|
31
33
|
const props = withDefaults(
|
|
@@ -49,46 +51,22 @@ defineSlots<{
|
|
|
49
51
|
call(props: { call: ToolCallEntry }): unknown;
|
|
50
52
|
}>();
|
|
51
53
|
|
|
54
|
+
const labels = useChatLabels();
|
|
52
55
|
const open = ref(false);
|
|
53
56
|
const bodyId = useCopilotId("cpk-tool-call-group");
|
|
54
57
|
const toggle = () => {
|
|
55
58
|
open.value = !open.value;
|
|
56
59
|
};
|
|
57
60
|
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
// running, so the latest call stays the subject (or the label flickers).
|
|
61
|
-
const current = computed(() =>
|
|
62
|
-
props.isActive
|
|
63
|
-
? (props.calls.find((call) => !call.toolMessage) ?? latest.value)
|
|
64
|
-
: undefined,
|
|
65
|
-
);
|
|
66
|
-
const preview = computed(() =>
|
|
67
|
-
current.value ? entryPreview(current.value) : undefined,
|
|
68
|
-
);
|
|
69
|
-
const done = computed(
|
|
70
|
-
() => props.calls.filter((call) => call.toolMessage).length,
|
|
71
|
-
);
|
|
72
|
-
const statuses = computed(() =>
|
|
73
|
-
props.calls.map((call) => entryStatus(call, props.isActive)),
|
|
74
|
-
);
|
|
75
|
-
const failedIds = computed(
|
|
76
|
-
() =>
|
|
77
|
-
new Set(
|
|
78
|
-
props.calls
|
|
79
|
-
.filter((_, index) => statuses.value[index] === "failed")
|
|
80
|
-
.map((call) => call.toolCall.id),
|
|
81
|
-
),
|
|
82
|
-
);
|
|
83
|
-
const status = computed<ToolCallStatusName>(() =>
|
|
84
|
-
current.value
|
|
85
|
-
? "running"
|
|
86
|
-
: failedIds.value.size > 0
|
|
87
|
-
? "failed"
|
|
88
|
-
: statuses.value.includes("stopped")
|
|
89
|
-
? "stopped"
|
|
90
|
-
: "done",
|
|
61
|
+
const state = computed(() =>
|
|
62
|
+
ɵgetToolCallGroupState(props.calls, props.isActive, open.value),
|
|
91
63
|
);
|
|
64
|
+
const latest = computed(() => state.value.latest);
|
|
65
|
+
const current = computed(() => state.value.current);
|
|
66
|
+
const preview = computed(() => state.value.preview);
|
|
67
|
+
const done = computed(() => state.value.done);
|
|
68
|
+
const failedIds = computed(() => state.value.failedIds);
|
|
69
|
+
const status = computed(() => state.value.status);
|
|
92
70
|
const single = computed(
|
|
93
71
|
() =>
|
|
94
72
|
props.appearance === "line" && props.calls.length === 1 && !current.value,
|
|
@@ -99,19 +77,31 @@ provide(
|
|
|
99
77
|
computed<ToolCallGroupContextValue>(() => ({
|
|
100
78
|
appearance: props.appearance,
|
|
101
79
|
failedIds: failedIds.value,
|
|
80
|
+
statusById: state.value.statusById,
|
|
102
81
|
active: props.isActive,
|
|
103
82
|
})),
|
|
104
83
|
);
|
|
105
84
|
|
|
106
85
|
// Stack: a lone call is the top card of a stack with nothing behind it yet.
|
|
107
|
-
const behind = computed(() =>
|
|
108
|
-
|
|
86
|
+
const behind = computed(() => state.value.behind);
|
|
87
|
+
const latestStatus = computed(() => state.value.latestStatus);
|
|
88
|
+
const latestPreview = computed(() => state.value.latestPreview);
|
|
89
|
+
const runningLabel = computed(() =>
|
|
90
|
+
current.value
|
|
91
|
+
? ɵformatLabel(labels.value.toolCallRunningLabel, {
|
|
92
|
+
name: current.value.toolCall.function.name,
|
|
93
|
+
})
|
|
94
|
+
: "",
|
|
109
95
|
);
|
|
110
|
-
const
|
|
111
|
-
|
|
96
|
+
const usedToolsLabel = computed(() =>
|
|
97
|
+
ɵformatCountLabel(props.calls.length, {
|
|
98
|
+
one: labels.value.toolCallUsedToolsOne,
|
|
99
|
+
other: labels.value.toolCallUsedToolsOther,
|
|
100
|
+
}),
|
|
112
101
|
);
|
|
113
|
-
const
|
|
114
|
-
|
|
102
|
+
const toolNames = computed(() => ɵformatToolNames(props.calls));
|
|
103
|
+
const latestStatusLabel = computed(() =>
|
|
104
|
+
toolCallStatusLabel(labels.value, latestStatus.value),
|
|
115
105
|
);
|
|
116
106
|
const layer = "cpk-tool-call-group-stack-layer";
|
|
117
107
|
</script>
|
|
@@ -144,20 +134,18 @@ const layer = "cpk-tool-call-group-stack-layer";
|
|
|
144
134
|
@click="toggle"
|
|
145
135
|
>
|
|
146
136
|
<template v-if="current">
|
|
147
|
-
<span class="cpk-tool-call-group-running cpk-shimmer"
|
|
148
|
-
|
|
149
|
-
>
|
|
137
|
+
<span class="cpk-tool-call-group-running cpk-shimmer">{{
|
|
138
|
+
runningLabel
|
|
139
|
+
}}</span>
|
|
150
140
|
<span v-if="preview" class="cpk-tool-call-group-preview">{{
|
|
151
141
|
preview
|
|
152
142
|
}}</span>
|
|
153
143
|
</template>
|
|
154
144
|
<template v-else>
|
|
155
|
-
<span class="cpk-tool-call-group-line-summary"
|
|
156
|
-
|
|
157
|
-
>
|
|
158
|
-
<span class="cpk-tool-call-group-line-names">{{
|
|
159
|
-
toolNames(calls)
|
|
145
|
+
<span class="cpk-tool-call-group-line-summary">{{
|
|
146
|
+
usedToolsLabel
|
|
160
147
|
}}</span>
|
|
148
|
+
<span class="cpk-tool-call-group-line-names">{{ toolNames }}</span>
|
|
161
149
|
<ToolCallFailedCount :calls="calls" />
|
|
162
150
|
</template>
|
|
163
151
|
<ToolCallChevron :open="open" />
|
|
@@ -206,10 +194,15 @@ const layer = "cpk-tool-call-group-stack-layer";
|
|
|
206
194
|
@click="toggle"
|
|
207
195
|
>
|
|
208
196
|
<template v-if="open">
|
|
209
|
-
{{
|
|
197
|
+
{{
|
|
198
|
+
ɵformatCountLabel(calls.length, {
|
|
199
|
+
one: labels.toolCallToolCallCountOne,
|
|
200
|
+
other: labels.toolCallToolCallCountOther,
|
|
201
|
+
})
|
|
202
|
+
}}
|
|
210
203
|
<ToolCallFailedCount :calls="calls" />
|
|
211
204
|
<span class="cpk-tool-call-group-stack-collapse">
|
|
212
|
-
|
|
205
|
+
{{ labels.toolCallCollapseLabel }}
|
|
213
206
|
<ToolCallChevron
|
|
214
207
|
:open="true"
|
|
215
208
|
class="cpk-tool-call-group-stack-collapse-icon"
|
|
@@ -236,13 +229,16 @@ const layer = "cpk-tool-call-group-stack-layer";
|
|
|
236
229
|
>
|
|
237
230
|
<!-- The status icon is decorative, so say the status. -->
|
|
238
231
|
<span class="cpk-tool-call-group-stack-status">{{
|
|
239
|
-
|
|
232
|
+
latestStatusLabel
|
|
240
233
|
}}</span>
|
|
241
234
|
</span>
|
|
242
235
|
<span class="cpk-tool-call-group-stack-meta">
|
|
243
236
|
<ToolCallFailedCount :calls="calls" />
|
|
244
237
|
<span class="cpk-tool-call-group-stack-count">{{
|
|
245
|
-
|
|
238
|
+
ɵformatCountLabel(calls.length, {
|
|
239
|
+
one: labels.toolCallCallCountOne,
|
|
240
|
+
other: labels.toolCallCallCountOther,
|
|
241
|
+
})
|
|
246
242
|
}}</span>
|
|
247
243
|
<ToolCallChevron
|
|
248
244
|
:open="false"
|
|
@@ -255,9 +251,7 @@ const layer = "cpk-tool-call-group-stack-layer";
|
|
|
255
251
|
call change ("read_file: Running", then "read_file: Done"); the
|
|
256
252
|
button only names it. -->
|
|
257
253
|
<span aria-live="polite" class="cpk-tool-call-group-stack-live">{{
|
|
258
|
-
open
|
|
259
|
-
? ""
|
|
260
|
-
: `${latest.toolCall.function.name}: ${statusLabels[latestStatus]}`
|
|
254
|
+
open ? "" : `${latest.toolCall.function.name}: ${latestStatusLabel}`
|
|
261
255
|
}}</span>
|
|
262
256
|
</div>
|
|
263
257
|
<!-- Each call gets the collapsed stack's card, easing out of the stack. -->
|
|
@@ -292,28 +286,26 @@ const layer = "cpk-tool-call-group-stack-layer";
|
|
|
292
286
|
>
|
|
293
287
|
<ToolCallStatusIcon :status="status" />
|
|
294
288
|
<template v-if="current">
|
|
295
|
-
<span class="cpk-tool-call-group-running cpk-shimmer"
|
|
296
|
-
|
|
297
|
-
>
|
|
289
|
+
<span class="cpk-tool-call-group-running cpk-shimmer">{{
|
|
290
|
+
runningLabel
|
|
291
|
+
}}</span>
|
|
298
292
|
<span v-if="preview" class="cpk-tool-call-group-preview">{{
|
|
299
293
|
preview
|
|
300
294
|
}}</span>
|
|
301
295
|
</template>
|
|
302
296
|
<template v-else>
|
|
303
|
-
<span class="cpk-tool-call-group-card-summary"
|
|
304
|
-
|
|
305
|
-
>
|
|
306
|
-
<span class="cpk-tool-call-group-card-names">{{
|
|
307
|
-
toolNames(calls)
|
|
297
|
+
<span class="cpk-tool-call-group-card-summary">{{
|
|
298
|
+
usedToolsLabel
|
|
308
299
|
}}</span>
|
|
300
|
+
<span class="cpk-tool-call-group-card-names">{{ toolNames }}</span>
|
|
309
301
|
</template>
|
|
310
302
|
<span class="cpk-tool-call-group-card-meta">
|
|
311
303
|
<ToolCallFailedCount v-if="status === 'failed'" :calls="calls" />
|
|
312
304
|
<span v-else class="cpk-tool-call-group-card-status">{{
|
|
313
305
|
status !== "running"
|
|
314
|
-
?
|
|
306
|
+
? toolCallStatusLabel(labels, status)
|
|
315
307
|
: done > 0
|
|
316
|
-
?
|
|
308
|
+
? ɵformatLabel(labels.toolCallDoneCountLabel, { count: done })
|
|
317
309
|
: ""
|
|
318
310
|
}}</span>
|
|
319
311
|
<ToolCallChevron :open="open" />
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import type { Message, ToolCall } from "@ag-ui/core";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
ɵresolveToolCallAgentId,
|
|
5
|
+
ɵresolveToolCallRenderer,
|
|
6
|
+
} from "@copilotkit/core";
|
|
4
7
|
import { useCopilotKit } from "../../providers/useCopilotKit";
|
|
5
8
|
import { useCopilotChatConfiguration } from "../../providers/useCopilotChatConfiguration";
|
|
6
9
|
import type { CopilotChatToolCallRenderSlotProps } from "./types";
|
|
7
10
|
import {
|
|
8
|
-
getCoreRenderConfig,
|
|
9
11
|
getCoreRenderProps,
|
|
10
12
|
getToolCallMemoDeps,
|
|
11
13
|
getToolCallRenderProps,
|
|
@@ -54,16 +56,16 @@ function getCoreProps() {
|
|
|
54
56
|
}
|
|
55
57
|
|
|
56
58
|
function getRenderConfig() {
|
|
57
|
-
const agentId = config.value?.agentId
|
|
58
|
-
return
|
|
59
|
-
props.toolCall,
|
|
59
|
+
const agentId = ɵresolveToolCallAgentId(config.value?.agentId, undefined);
|
|
60
|
+
return ɵresolveToolCallRenderer(
|
|
60
61
|
copilotkit.value.renderToolCalls,
|
|
62
|
+
props.toolCall.function.name,
|
|
61
63
|
agentId,
|
|
62
64
|
);
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
function getMemoDeps() {
|
|
66
|
-
const agentId = config.value?.agentId
|
|
68
|
+
const agentId = ɵresolveToolCallAgentId(config.value?.agentId, undefined);
|
|
67
69
|
return getToolCallMemoDeps(
|
|
68
70
|
props.toolCall,
|
|
69
71
|
props.messages,
|
|
@@ -3,9 +3,18 @@ import { computed, defineComponent, h, inject, provide, useSlots } from "vue";
|
|
|
3
3
|
import type { PropType } from "vue";
|
|
4
4
|
import type { Slots, VNode } from "vue";
|
|
5
5
|
import type { AssistantMessage, Message } from "@ag-ui/core";
|
|
6
|
+
import {
|
|
7
|
+
ɵgetToolCallGroupState,
|
|
8
|
+
ɵgetToolCallLayouts,
|
|
9
|
+
ɵgetToolCallRendererNames,
|
|
10
|
+
ɵtoolCallAppearance,
|
|
11
|
+
} from "@copilotkit/core";
|
|
12
|
+
import type {
|
|
13
|
+
CopilotChatToolCallDisplay,
|
|
14
|
+
ToolCallEntry,
|
|
15
|
+
} from "@copilotkit/core";
|
|
6
16
|
import { useCopilotKit } from "../../providers/useCopilotKit";
|
|
7
17
|
import type {
|
|
8
|
-
CopilotChatToolCallGroupAppearance,
|
|
9
18
|
CopilotChatToolCallRenderSlotProps,
|
|
10
19
|
CopilotChatToolCallsGroupSlotProps,
|
|
11
20
|
} from "./types";
|
|
@@ -17,14 +26,6 @@ import {
|
|
|
17
26
|
ToolCallGroupContextKey,
|
|
18
27
|
} from "./tool-call-display-context";
|
|
19
28
|
import type { ToolCallGroupContextValue } from "./tool-call-display-context";
|
|
20
|
-
import {
|
|
21
|
-
getToolCallLayouts,
|
|
22
|
-
getToolCallRendererNames,
|
|
23
|
-
} from "./tool-call-layout";
|
|
24
|
-
import type {
|
|
25
|
-
CopilotChatToolCallDisplay,
|
|
26
|
-
ToolCallEntry,
|
|
27
|
-
} from "./tool-call-layout";
|
|
28
29
|
|
|
29
30
|
const props = withDefaults(
|
|
30
31
|
defineProps<{
|
|
@@ -54,14 +55,6 @@ defineSlots<{
|
|
|
54
55
|
|
|
55
56
|
type ToolCallSlotName = "tool-call" | `tool-call-${string}`;
|
|
56
57
|
|
|
57
|
-
const appearances: Partial<
|
|
58
|
-
Record<CopilotChatToolCallDisplay, CopilotChatToolCallGroupAppearance>
|
|
59
|
-
> = {
|
|
60
|
-
grouped: "card",
|
|
61
|
-
line: "line",
|
|
62
|
-
stacked: "stack",
|
|
63
|
-
};
|
|
64
|
-
|
|
65
58
|
const componentSlots = useSlots() as Slots;
|
|
66
59
|
const { copilotkit } = useCopilotKit();
|
|
67
60
|
const context = inject(ToolCallDisplayContextKey, null);
|
|
@@ -84,13 +77,15 @@ const layout = computed(() => {
|
|
|
84
77
|
if (display.value === "separate") return undefined;
|
|
85
78
|
const viewLayout = context?.value.layouts.get(props.message.id);
|
|
86
79
|
if (viewLayout) return viewLayout;
|
|
87
|
-
const rendererNames =
|
|
80
|
+
const rendererNames = ɵgetToolCallRendererNames(
|
|
88
81
|
copilotkit.value.renderToolCalls,
|
|
89
|
-
getToolCallSlotNames(),
|
|
90
|
-
);
|
|
91
|
-
return getToolCallLayouts([props.message], props.messages, rendererNames).get(
|
|
92
|
-
props.message.id,
|
|
82
|
+
{ slotNames: getToolCallSlotNames() },
|
|
93
83
|
);
|
|
84
|
+
return ɵgetToolCallLayouts(
|
|
85
|
+
[props.message],
|
|
86
|
+
props.messages,
|
|
87
|
+
rendererNames,
|
|
88
|
+
).get(props.message.id);
|
|
94
89
|
});
|
|
95
90
|
|
|
96
91
|
// Whether the agent may still finish a trailing group's calls. Without a
|
|
@@ -99,7 +94,7 @@ const layout = computed(() => {
|
|
|
99
94
|
const groupActive = (trailing: boolean) =>
|
|
100
95
|
trailing && (context ? context.value.isRunning : true);
|
|
101
96
|
|
|
102
|
-
const appearance = computed(() =>
|
|
97
|
+
const appearance = computed(() => ɵtoolCallAppearance(display.value) ?? "card");
|
|
103
98
|
|
|
104
99
|
const workOpen = computed(() => context?.value.workOpen.get(props.message.id));
|
|
105
100
|
|
|
@@ -115,15 +110,19 @@ const TurnRows = defineComponent({
|
|
|
115
110
|
setup(rowProps, { slots }) {
|
|
116
111
|
provide(
|
|
117
112
|
ToolCallGroupContextKey,
|
|
118
|
-
computed<ToolCallGroupContextValue>(() =>
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
rowProps.
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
113
|
+
computed<ToolCallGroupContextValue>(() => {
|
|
114
|
+
const { failedIds, statusById } = ɵgetToolCallGroupState(
|
|
115
|
+
rowProps.calls,
|
|
116
|
+
rowProps.active,
|
|
117
|
+
false,
|
|
118
|
+
);
|
|
119
|
+
return {
|
|
120
|
+
appearance: "line",
|
|
121
|
+
failedIds,
|
|
122
|
+
statusById,
|
|
123
|
+
active: rowProps.active,
|
|
124
|
+
};
|
|
125
|
+
}),
|
|
127
126
|
);
|
|
128
127
|
return () => slots.default?.();
|
|
129
128
|
},
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed
|
|
2
|
+
import { computed } from "vue";
|
|
3
3
|
import type { UserMessage } from "@ag-ui/core";
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} from "@copilotkit/
|
|
4
|
+
import {
|
|
5
|
+
ɵflattenUserMessageContent,
|
|
6
|
+
ɵgetBranchNavState,
|
|
7
|
+
ɵgetUserMessageMediaFilename,
|
|
8
|
+
ɵgetUserMessageMediaParts,
|
|
9
|
+
} from "@copilotkit/core";
|
|
10
10
|
import { useCopilotChatConfiguration } from "../../providers/useCopilotChatConfiguration";
|
|
11
11
|
import { CopilotChatDefaultLabels } from "../../providers/types";
|
|
12
12
|
import {
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
} from "../icons";
|
|
19
19
|
import CopilotTooltip from "../ui/CopilotTooltip.vue";
|
|
20
20
|
import CopilotChatAttachmentRenderer from "./CopilotChatAttachmentRenderer.vue";
|
|
21
|
+
import { useCopyFeedback } from "./use-copy-feedback";
|
|
21
22
|
import type {
|
|
22
23
|
CopilotChatUserMessageBranchNavigationSlotProps,
|
|
23
24
|
CopilotChatUserMessageCopyButtonSlotProps,
|
|
@@ -66,117 +67,34 @@ const emit = defineEmits<{
|
|
|
66
67
|
|
|
67
68
|
const config = useCopilotChatConfiguration();
|
|
68
69
|
const labels = computed(() => config.value?.labels ?? CopilotChatDefaultLabels);
|
|
69
|
-
const copied =
|
|
70
|
-
let copiedResetTimeout: ReturnType<typeof setTimeout> | null = null;
|
|
70
|
+
const { copied, copy } = useCopyFeedback();
|
|
71
71
|
|
|
72
72
|
// Styles live in @copilotkit/core (ui/button.css, user-message.css).
|
|
73
73
|
const toolbarButtonClass =
|
|
74
74
|
"cpk-button cpk-button-assistant-message-toolbar cpk-button-size-default";
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (typeof content === "string") {
|
|
82
|
-
return content;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return content
|
|
86
|
-
.map((part) => {
|
|
87
|
-
if (
|
|
88
|
-
part &&
|
|
89
|
-
typeof part === "object" &&
|
|
90
|
-
"type" in part &&
|
|
91
|
-
(part as { type?: unknown }).type === "text" &&
|
|
92
|
-
typeof (part as { text?: unknown }).text === "string"
|
|
93
|
-
) {
|
|
94
|
-
return (part as { text: string }).text;
|
|
95
|
-
}
|
|
96
|
-
return "";
|
|
97
|
-
})
|
|
98
|
-
.filter((text) => text.length > 0)
|
|
99
|
-
.join("\n");
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
type MediaPart =
|
|
103
|
-
| ImageInputPart
|
|
104
|
-
| AudioInputPart
|
|
105
|
-
| VideoInputPart
|
|
106
|
-
| DocumentInputPart;
|
|
107
|
-
|
|
108
|
-
function getMediaParts(content: UserMessage["content"]): MediaPart[] {
|
|
109
|
-
if (!content || typeof content === "string") return [];
|
|
110
|
-
return content.filter(
|
|
111
|
-
(part): part is MediaPart =>
|
|
112
|
-
part.type === "image" ||
|
|
113
|
-
part.type === "audio" ||
|
|
114
|
-
part.type === "video" ||
|
|
115
|
-
part.type === "document",
|
|
116
|
-
);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function getFilename(part: MediaPart): string | undefined {
|
|
120
|
-
const meta = part.metadata;
|
|
121
|
-
if (
|
|
122
|
-
meta != null &&
|
|
123
|
-
typeof meta === "object" &&
|
|
124
|
-
"filename" in meta &&
|
|
125
|
-
typeof meta.filename === "string"
|
|
126
|
-
) {
|
|
127
|
-
return meta.filename;
|
|
128
|
-
}
|
|
129
|
-
return undefined;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
const mediaParts = computed(() => getMediaParts(props.message.content));
|
|
76
|
+
const mediaParts = computed(() =>
|
|
77
|
+
ɵgetUserMessageMediaParts(props.message.content),
|
|
78
|
+
);
|
|
133
79
|
|
|
134
80
|
const flattenedContent = computed(() =>
|
|
135
|
-
|
|
81
|
+
ɵflattenUserMessageContent(props.message.content),
|
|
136
82
|
);
|
|
137
83
|
const isMultiline = computed(() => flattenedContent.value.includes("\n"));
|
|
138
84
|
const hasEditAction = computed(() => typeof props.onEditMessage === "function");
|
|
139
|
-
const
|
|
140
|
-
(
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
() => showBranchNavigation.value && props.branchIndex > 0,
|
|
146
|
-
);
|
|
147
|
-
const canGoNext = computed(
|
|
148
|
-
() =>
|
|
149
|
-
showBranchNavigation.value &&
|
|
150
|
-
props.branchIndex < props.numberOfBranches - 1,
|
|
85
|
+
const branchNav = computed(() =>
|
|
86
|
+
ɵgetBranchNavState({
|
|
87
|
+
branchIndex: props.branchIndex,
|
|
88
|
+
numberOfBranches: props.numberOfBranches,
|
|
89
|
+
canSwitch: typeof props.onSwitchToBranch === "function",
|
|
90
|
+
}),
|
|
151
91
|
);
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
clearTimeout(copiedResetTimeout);
|
|
156
|
-
}
|
|
157
|
-
copied.value = true;
|
|
158
|
-
copiedResetTimeout = setTimeout(() => {
|
|
159
|
-
copied.value = false;
|
|
160
|
-
copiedResetTimeout = null;
|
|
161
|
-
}, 2000);
|
|
162
|
-
}
|
|
92
|
+
const showBranchNavigation = computed(() => branchNav.value.show);
|
|
93
|
+
const canGoPrev = computed(() => branchNav.value.canGoPrev);
|
|
94
|
+
const canGoNext = computed(() => branchNav.value.canGoNext);
|
|
163
95
|
|
|
164
96
|
async function handleCopyMessage() {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
if (
|
|
168
|
-
typeof navigator === "undefined" ||
|
|
169
|
-
typeof navigator.clipboard?.writeText !== "function"
|
|
170
|
-
) {
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
try {
|
|
175
|
-
await navigator.clipboard.writeText(flattenedContent.value);
|
|
176
|
-
resetCopiedStateWithDelay();
|
|
177
|
-
} catch (error) {
|
|
178
|
-
console.error("Failed to copy to clipboard:", error);
|
|
179
|
-
}
|
|
97
|
+
await copy(flattenedContent.value);
|
|
180
98
|
}
|
|
181
99
|
|
|
182
100
|
function handleEditMessage() {
|
|
@@ -212,12 +130,6 @@ function goNext() {
|
|
|
212
130
|
}
|
|
213
131
|
switchToBranch(props.branchIndex + 1);
|
|
214
132
|
}
|
|
215
|
-
|
|
216
|
-
onBeforeUnmount(() => {
|
|
217
|
-
if (copiedResetTimeout) {
|
|
218
|
-
clearTimeout(copiedResetTimeout);
|
|
219
|
-
}
|
|
220
|
-
});
|
|
221
133
|
</script>
|
|
222
134
|
|
|
223
135
|
<template>
|
|
@@ -255,7 +167,7 @@ onBeforeUnmount(() => {
|
|
|
255
167
|
:key="index"
|
|
256
168
|
:type="part.type"
|
|
257
169
|
:source="part.source"
|
|
258
|
-
:filename="
|
|
170
|
+
:filename="ɵgetUserMessageMediaFilename(part)"
|
|
259
171
|
/>
|
|
260
172
|
</div>
|
|
261
173
|
|