@copilotkit/vue 2.0.0-rc.1 → 2.0.0-rc.10
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 +13 -12
- package/README.md +1 -2
- package/dist/components/copilot-provider/CopilotKit.vue.d.ts +3 -1
- package/dist/components/copilot-provider/CopilotKit.vue.d.ts.map +1 -1
- 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 -76
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +384 -14275
- package/dist/index.mjs.map +1 -1
- package/dist/use-render-activity-message-CTR_ziWV.js +18097 -0
- package/dist/use-render-activity-message-CTR_ziWV.js.map +1 -0
- package/dist/use-render-activity-message-Dky9_GRG.cjs +92 -0
- package/dist/use-render-activity-message-Dky9_GRG.cjs.map +1 -0
- package/dist/v2/components/A2UIMessageRenderer.d.ts +7 -0
- package/dist/v2/components/A2UIMessageRenderer.d.ts.map +1 -1
- package/dist/v2/components/A2UISurfaceActivityRenderer.vue.d.ts.map +1 -1
- package/dist/v2/components/LicenseWarningBanner.vue.d.ts.map +1 -1
- package/dist/v2/components/OpenGenerativeUIRenderer.d.ts +13 -45
- package/dist/v2/components/OpenGenerativeUIRenderer.d.ts.map +1 -1
- package/dist/v2/components/a2ui/A2UIBuiltInToolCallRenderer.d.ts +11 -2
- package/dist/v2/components/a2ui/A2UIBuiltInToolCallRenderer.d.ts.map +1 -1
- package/dist/v2/components/a2ui/A2UICatalogContext.d.ts +1 -1
- package/dist/v2/components/a2ui/A2UICatalogContext.d.ts.map +1 -1
- package/dist/v2/components/a2ui/A2UIRecoveryStates.d.ts +144 -0
- package/dist/v2/components/a2ui/A2UIRecoveryStates.d.ts.map +1 -0
- package/dist/v2/components/a2ui.d.ts +3 -7
- package/dist/v2/components/a2ui.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChat.vue.d.ts +1 -0
- package/dist/v2/components/chat/CopilotChat.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatAssistantMessage.vue.d.ts +3 -1
- package/dist/v2/components/chat/CopilotChatAssistantMessage.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatAssistantToolbarButton.vue.d.ts +16 -0
- package/dist/v2/components/chat/CopilotChatAssistantToolbarButton.vue.d.ts.map +1 -0
- 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.map +1 -1
- package/dist/v2/components/chat/CopilotChatFeedbackCommentPopover.vue.d.ts +22 -0
- package/dist/v2/components/chat/CopilotChatFeedbackCommentPopover.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatInput.vue.d.ts +21 -232
- package/dist/v2/components/chat/CopilotChatInput.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatInspectorButton.vue.d.ts +12 -0
- package/dist/v2/components/chat/CopilotChatInspectorButton.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatLightbox.vue.d.ts +22 -0
- package/dist/v2/components/chat/CopilotChatLightbox.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatMessageView.vue.d.ts +20 -0
- 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/CopilotChatSuggestionPill.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatSuggestionView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatToggleButton.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatToolCallGroup.vue.d.ts +32 -0
- package/dist/v2/components/chat/CopilotChatToolCallGroup.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatToolCallItem.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatToolCallsView.vue.d.ts +11 -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 +1 -0
- package/dist/v2/components/chat/CopilotChatView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatWorkSummary.vue.d.ts +5 -0
- package/dist/v2/components/chat/CopilotChatWorkSummary.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotModalHeader.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotModalHeaderCloseButton.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotModalHeaderTitle.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotPopup.vue.d.ts +1 -0
- package/dist/v2/components/chat/CopilotPopup.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotPopupView.vue.d.ts +1 -0
- package/dist/v2/components/chat/CopilotPopupView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotPopupViewInternal.vue.d.ts +1 -0
- package/dist/v2/components/chat/CopilotPopupViewInternal.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotPopupWelcomeScreen.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotSidebar.vue.d.ts +2 -0
- package/dist/v2/components/chat/CopilotSidebar.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotSidebarView.vue.d.ts +2 -0
- package/dist/v2/components/chat/CopilotSidebarView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotSidebarViewInternal.vue.d.ts +2 -0
- package/dist/v2/components/chat/CopilotSidebarViewInternal.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotSidebarWelcomeScreen.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/StreamingMarkdownDefault.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/copilotChatToolCallItemRender.d.ts +0 -1
- package/dist/v2/components/chat/copilotChatToolCallItemRender.d.ts.map +1 -1
- package/dist/v2/components/chat/index.d.ts +17 -1
- package/dist/v2/components/chat/index.d.ts.map +1 -1
- package/dist/v2/components/chat/inspector-shortcuts.d.ts +12 -0
- package/dist/v2/components/chat/inspector-shortcuts.d.ts.map +1 -0
- package/dist/v2/components/chat/message-feedback.d.ts +89 -0
- package/dist/v2/components/chat/message-feedback.d.ts.map +1 -0
- package/dist/v2/components/chat/tool-call-capture.d.ts +39 -0
- package/dist/v2/components/chat/tool-call-capture.d.ts.map +1 -0
- package/dist/v2/components/chat/tool-call-display-context.d.ts +22 -0
- package/dist/v2/components/chat/tool-call-display-context.d.ts.map +1 -0
- package/dist/v2/components/chat/tool-call-group-parts.d.ts +131 -0
- package/dist/v2/components/chat/tool-call-group-parts.d.ts.map +1 -0
- package/dist/v2/components/chat/turn-work.d.ts +33 -0
- package/dist/v2/components/chat/turn-work.d.ts.map +1 -0
- package/dist/v2/components/chat/types.d.ts +104 -5
- 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-lightbox.d.ts +18 -0
- package/dist/v2/components/chat/use-lightbox.d.ts.map +1 -0
- 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 +55 -0
- package/dist/v2/components/ui/CopilotDropdownMenuContent.vue.d.ts.map +1 -0
- package/dist/v2/components/ui/CopilotPopover.vue.d.ts +40 -0
- package/dist/v2/components/ui/CopilotPopover.vue.d.ts.map +1 -0
- package/dist/v2/components/ui/CopilotTooltip.vue.d.ts +37 -0
- package/dist/v2/components/ui/CopilotTooltip.vue.d.ts.map +1 -0
- package/dist/v2/components/ui/dropdown-menu.d.ts +14 -0
- package/dist/v2/components/ui/dropdown-menu.d.ts.map +1 -0
- package/dist/v2/components/ui/floating.d.ts +84 -0
- package/dist/v2/components/ui/floating.d.ts.map +1 -0
- package/dist/v2/components/ui/presence.d.ts +9 -0
- package/dist/v2/components/ui/presence.d.ts.map +1 -0
- package/dist/v2/components/ui/use-id.d.ts +9 -0
- package/dist/v2/components/ui/use-id.d.ts.map +1 -0
- package/dist/v2/hooks/use-default-render-tool.d.ts +6 -0
- 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-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 +4 -0
- package/dist/v2/hooks/use-render-tool.d.ts.map +1 -1
- package/dist/v2/index.cjs +1 -1
- package/dist/v2/index.d.cts +3 -0
- package/dist/v2/index.d.mts +3 -0
- package/dist/v2/index.d.ts +3 -0
- package/dist/v2/index.d.ts.map +1 -1
- package/dist/v2/index.mjs +197 -197
- package/dist/v2/index.mjs.map +1 -1
- package/dist/v2/lib/message-feedback.d.ts +33 -0
- package/dist/v2/lib/message-feedback.d.ts.map +1 -0
- package/dist/v2/lib/processPartialHtml.d.ts +1 -2
- package/dist/v2/lib/processPartialHtml.d.ts.map +1 -1
- package/dist/v2/lib/vue-core.d.ts +0 -1
- 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 +56 -6
- package/dist/v2/providers/CopilotKitProvider.types.d.ts.map +1 -1
- package/dist/v2/providers/CopilotKitProvider.vue.d.ts +6 -2
- package/dist/v2/providers/CopilotKitProvider.vue.d.ts.map +1 -1
- package/dist/v2/providers/index.d.ts +1 -1
- package/dist/v2/providers/index.d.ts.map +1 -1
- package/dist/v2/providers/keys.d.ts +8 -0
- package/dist/v2/providers/keys.d.ts.map +1 -1
- package/dist/v2/providers/types.d.ts +3 -37
- package/dist/v2/providers/types.d.ts.map +1 -1
- package/dist/v2/styles/CopilotKitStyles.d.ts +18 -0
- package/dist/v2/styles/CopilotKitStyles.d.ts.map +1 -0
- package/dist/v2/types/defineToolCallRenderer.d.ts +2 -0
- 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 -28
- package/dist/v2/types/vue-tool-call-renderer.d.ts.map +1 -1
- package/package.json +14 -27
- package/src/__tests__/build-entries.test.ts +27 -0
- package/src/components/copilot-provider/CopilotKit.vue +4 -1
- 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 +4 -2
- package/src/v2/components/A2UIMessageRenderer.ts +56 -68
- package/src/v2/components/A2UISurfaceActivityRenderer.vue +11 -23
- package/src/v2/components/LicenseWarningBanner.vue +31 -15
- package/src/v2/components/OpenGenerativeUIRenderer.ts +51 -373
- package/src/v2/components/__tests__/A2UIBasicCatalogColors.test.ts +8 -9
- package/src/v2/components/__tests__/A2UICatalogContext.test.ts +1 -1
- package/src/v2/components/__tests__/A2UIMessageRenderer.test.ts +63 -36
- package/src/v2/components/__tests__/LicenseWarningBanner.test.ts +20 -0
- package/src/v2/components/__tests__/OpenGenerativeUIRenderer.test.ts +55 -6
- package/src/v2/components/a2ui/A2UIBuiltInToolCallRenderer.ts +15 -258
- package/src/v2/components/a2ui/A2UICatalogContext.ts +10 -102
- package/src/v2/components/a2ui/A2UIRecoveryStates.ts +444 -0
- package/src/v2/components/a2ui/__tests__/A2UIRecoveryStates.test.ts +175 -0
- package/src/v2/components/a2ui.ts +1 -1
- package/src/v2/components/chat/CopilotChat.vue +26 -40
- package/src/v2/components/chat/CopilotChatAssistantMessage.vue +267 -67
- package/src/v2/components/chat/CopilotChatAssistantToolbarButton.vue +46 -0
- package/src/v2/components/chat/CopilotChatAttachmentQueue.vue +150 -173
- package/src/v2/components/chat/CopilotChatAttachmentRenderer.vue +77 -20
- package/src/v2/components/chat/CopilotChatAudioRecorder.vue +2 -2
- package/src/v2/components/chat/CopilotChatFeedbackCommentPopover.vue +240 -0
- package/src/v2/components/chat/CopilotChatInput.vue +250 -191
- package/src/v2/components/chat/CopilotChatInspectorButton.vue +331 -0
- package/src/v2/components/chat/CopilotChatLightbox.vue +105 -0
- package/src/v2/components/chat/CopilotChatMessageView.vue +262 -87
- package/src/v2/components/chat/CopilotChatReasoningMessage.vue +52 -35
- package/src/v2/components/chat/CopilotChatSuggestionPill.vue +5 -14
- package/src/v2/components/chat/CopilotChatSuggestionView.vue +1 -4
- package/src/v2/components/chat/CopilotChatToggleButton.vue +3 -9
- package/src/v2/components/chat/CopilotChatToggleButtonCloseIcon.ts +1 -1
- package/src/v2/components/chat/CopilotChatToggleButtonOpenIcon.ts +1 -1
- package/src/v2/components/chat/CopilotChatToolCallGroup.vue +353 -0
- package/src/v2/components/chat/CopilotChatToolCallItem.vue +24 -14
- package/src/v2/components/chat/CopilotChatToolCallsView.vue +194 -21
- package/src/v2/components/chat/CopilotChatUserMessage.vue +105 -42
- package/src/v2/components/chat/CopilotChatView.vue +37 -42
- package/src/v2/components/chat/CopilotChatWorkSummary.vue +111 -0
- package/src/v2/components/chat/CopilotModalHeader.vue +10 -8
- package/src/v2/components/chat/CopilotModalHeaderCloseButton.ts +7 -6
- package/src/v2/components/chat/CopilotModalHeaderTitle.ts +1 -4
- package/src/v2/components/chat/CopilotPopup.vue +3 -0
- package/src/v2/components/chat/CopilotPopupView.vue +1 -0
- package/src/v2/components/chat/CopilotPopupViewInternal.vue +9 -19
- package/src/v2/components/chat/CopilotPopupWelcomeScreen.vue +5 -8
- package/src/v2/components/chat/CopilotSidebar.vue +5 -0
- package/src/v2/components/chat/CopilotSidebarView.vue +2 -0
- package/src/v2/components/chat/CopilotSidebarViewInternal.vue +24 -17
- package/src/v2/components/chat/CopilotSidebarWelcomeScreen.vue +7 -10
- package/src/v2/components/chat/StreamingMarkdownDefault.vue +3 -5
- package/src/v2/components/chat/__tests__/CopilotChat.labels.test.ts +19 -4
- package/src/v2/components/chat/__tests__/CopilotChatActivityRendering.e2e.test.ts +26 -9
- package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.inspector.test.ts +269 -0
- package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.learningFeedback.test.ts +760 -0
- package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.slots.e2e.test.ts +3 -5
- package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.test.ts +2 -2
- package/src/v2/components/chat/__tests__/CopilotChatInput.addMenu.test.ts +328 -0
- package/src/v2/components/chat/__tests__/CopilotChatInput.slots.e2e.test.ts +6 -3
- package/src/v2/components/chat/__tests__/CopilotChatInput.test.ts +55 -14
- package/src/v2/components/chat/__tests__/CopilotChatLightbox.test.ts +160 -0
- package/src/v2/components/chat/__tests__/CopilotChatMessageView.test.ts +247 -403
- package/src/v2/components/chat/__tests__/CopilotChatMessageView.toolCallDisplay.test.ts +637 -0
- package/src/v2/components/chat/__tests__/CopilotChatSuggestionPill.test.ts +1 -1
- package/src/v2/components/chat/__tests__/CopilotChatSuggestionView.slots.e2e.test.ts +3 -1
- package/src/v2/components/chat/__tests__/CopilotChatToolCallsView.learning.test.ts +75 -0
- package/src/v2/components/chat/__tests__/CopilotChatUserMessage.attachments.test.ts +143 -0
- package/src/v2/components/chat/__tests__/CopilotChatView.inputOverlay.test.ts +5 -4
- package/src/v2/components/chat/__tests__/CopilotChatView.rootWidth.test.ts +7 -33
- package/src/v2/components/chat/__tests__/CopilotModalHeader.slots.e2e.test.ts +1 -1
- package/src/v2/components/chat/__tests__/CopilotPopupView.slots.e2e.test.ts +3 -3
- package/src/v2/components/chat/__tests__/CopilotSidebarView.position.test.ts +126 -0
- package/src/v2/components/chat/__tests__/messageFeedbackDefaults.test.ts +33 -0
- package/src/v2/components/chat/__tests__/modalChatDisplayProps.test.ts +44 -0
- package/src/v2/components/chat/copilotChatToolCallItemRender.ts +3 -19
- package/src/v2/components/chat/index.ts +2 -1
- package/src/v2/components/chat/inspector-shortcuts.ts +34 -0
- package/src/v2/components/chat/message-feedback.ts +291 -0
- package/src/v2/components/chat/tool-call-capture.ts +55 -0
- package/src/v2/components/chat/tool-call-display-context.ts +28 -0
- package/src/v2/components/chat/tool-call-group-parts.ts +251 -0
- package/src/v2/components/chat/turn-work.ts +52 -0
- package/src/v2/components/chat/types.ts +114 -4
- package/src/v2/components/chat/use-chat-labels.ts +16 -0
- package/src/v2/components/chat/use-lightbox.ts +64 -0
- package/src/v2/components/icons/__tests__/icons.test.ts +72 -68
- package/src/v2/components/icons/index.ts +109 -23
- package/src/v2/components/ui/CopilotDropdownMenuContent.vue +465 -0
- package/src/v2/components/ui/CopilotPopover.vue +138 -0
- package/src/v2/components/ui/CopilotTooltip.vue +237 -0
- package/src/v2/components/ui/__tests__/CopilotTooltip.test.ts +168 -0
- package/src/v2/components/ui/dropdown-menu.ts +15 -0
- package/src/v2/components/ui/floating.ts +321 -0
- package/src/v2/components/ui/presence.ts +54 -0
- package/src/v2/components/ui/use-id.ts +16 -0
- package/src/v2/hooks/__tests__/use-frontend-tool.e2e.test.ts +62 -1
- package/src/v2/hooks/__tests__/use-render-activity-message.test.ts +105 -0
- package/src/v2/hooks/__tests__/use-render-tool.test.ts +3 -6
- package/src/v2/hooks/__tests__/zod-regression.test.ts +5 -4
- package/src/v2/hooks/use-default-render-tool.ts +123 -62
- package/src/v2/hooks/use-frontend-tool.ts +10 -10
- package/src/v2/hooks/use-render-activity-message.ts +27 -48
- package/src/v2/hooks/use-render-custom-messages.ts +14 -35
- package/src/v2/hooks/use-render-tool.ts +8 -0
- package/src/v2/index.ts +3 -0
- package/src/v2/lib/__tests__/message-feedback.test.ts +152 -0
- package/src/v2/lib/message-feedback.ts +120 -0
- package/src/v2/lib/processPartialHtml.ts +6 -21
- package/src/v2/lib/vue-core.ts +3 -5
- package/src/v2/providers/CopilotChatConfigurationProvider.vue +29 -2
- package/src/v2/providers/CopilotKitProvider.types.ts +57 -5
- package/src/v2/providers/CopilotKitProvider.vue +177 -114
- package/src/v2/providers/__tests__/CopilotChatConfigurationProvider.openThread.test.ts +69 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.a2ui.test.ts +1 -1
- package/src/v2/providers/__tests__/CopilotKitProvider.headersAtSendTime.test.ts +3 -3
- package/src/v2/providers/__tests__/CopilotKitProvider.learning.test.ts +536 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.test.ts +17 -33
- package/src/v2/providers/index.ts +4 -1
- package/src/v2/providers/keys.ts +12 -0
- package/src/v2/providers/types.ts +3 -38
- package/src/v2/styles/CopilotKitStyles.ts +95 -0
- package/src/v2/styles/__tests__/CopilotKitStyles.client.test.ts +149 -0
- package/src/v2/styles/__tests__/CopilotKitStyles.ssr.test.ts +71 -0
- package/src/v2/types/__tests__/defineToolCallRenderer.test.ts +28 -33
- package/src/v2/types/defineToolCallRenderer.ts +9 -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 -31
- package/vite.config.ts +5 -5
- package/dist/styles.css +0 -2
- 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/lib/transcription-client.d.ts +0 -19
- package/dist/v2/lib/transcription-client.d.ts.map +0 -1
- package/scripts/scope-preflight.mjs +0 -100
- package/src/styles/globals.css +0 -233
- package/src/v2/components/chat/BasicMarkdown.vue +0 -158
- package/src/v2/components/chat/__tests__/BasicMarkdown.test.ts +0 -69
- 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/transcription-client.ts +0 -151
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed, onMounted, ref, useSlots, watch } from "vue";
|
|
3
|
-
import type { Component, FunctionalComponent, VNodeChild } from "vue";
|
|
2
|
+
import { computed, h, onMounted, provide, ref, useSlots, watch } from "vue";
|
|
3
|
+
import type { Component, FunctionalComponent, VNode, VNodeChild } from "vue";
|
|
4
4
|
import type {
|
|
5
5
|
ActivityMessage,
|
|
6
6
|
AssistantMessage,
|
|
@@ -15,6 +15,27 @@ import {
|
|
|
15
15
|
createRowKeyStore,
|
|
16
16
|
resolveRowRenderKeysById,
|
|
17
17
|
} from "@copilotkit/shared";
|
|
18
|
+
import {
|
|
19
|
+
ɵdeduplicateMessages,
|
|
20
|
+
ɵgetToolCallLayouts,
|
|
21
|
+
ɵgetToolCallRendererNames,
|
|
22
|
+
ɵgetTurnWork,
|
|
23
|
+
ɵgetWorkOpenState,
|
|
24
|
+
ɵisTurnWorkOpen,
|
|
25
|
+
ɵisTurnWorking,
|
|
26
|
+
ɵrecordWorkTime,
|
|
27
|
+
ɵresolveActivityRenderer,
|
|
28
|
+
ɵresolveCustomMessageRenderers,
|
|
29
|
+
ɵgetLatestTurnKey,
|
|
30
|
+
} from "@copilotkit/core";
|
|
31
|
+
import type {
|
|
32
|
+
CopilotChatToolCallDisplay,
|
|
33
|
+
ToolCallEntry,
|
|
34
|
+
ɵToolCallDisplayContextValue,
|
|
35
|
+
ɵToolCallLayout,
|
|
36
|
+
ɵTurnWork,
|
|
37
|
+
ɵWorkTime,
|
|
38
|
+
} from "@copilotkit/core";
|
|
18
39
|
import type {
|
|
19
40
|
InterruptRenderProps,
|
|
20
41
|
VueCustomMessageRendererProps,
|
|
@@ -24,6 +45,16 @@ import { useCopilotChatConfiguration } from "../../providers/useCopilotChatConfi
|
|
|
24
45
|
import CopilotChatAssistantMessage from "./CopilotChatAssistantMessage.vue";
|
|
25
46
|
import CopilotChatReasoningMessage from "./CopilotChatReasoningMessage.vue";
|
|
26
47
|
import CopilotChatUserMessage from "./CopilotChatUserMessage.vue";
|
|
48
|
+
import CopilotChatWorkSummary from "./CopilotChatWorkSummary.vue";
|
|
49
|
+
import { CopilotChatCollapsible } from "./tool-call-group-parts";
|
|
50
|
+
import { TurnWorkFold } from "./turn-work";
|
|
51
|
+
import {
|
|
52
|
+
MessageFeedbackScopeKey,
|
|
53
|
+
useLearningFeedbackEnabled,
|
|
54
|
+
} from "./message-feedback";
|
|
55
|
+
import type { MessageFeedbackScope } from "./message-feedback";
|
|
56
|
+
import { ToolCallDisplayContextKey } from "./tool-call-display-context";
|
|
57
|
+
import type { CopilotChatWorkSummarySlotProps } from "./types";
|
|
27
58
|
|
|
28
59
|
interface MessageMetaProps {
|
|
29
60
|
message: Message;
|
|
@@ -56,10 +87,26 @@ const props = withDefaults(
|
|
|
56
87
|
defineProps<{
|
|
57
88
|
messages?: Message[];
|
|
58
89
|
isRunning?: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* How tool calls show. Defaults to `"grouped"`: calls made in a row
|
|
92
|
+
* share one card that opens to a row per call. `"line"` and `"stacked"`
|
|
93
|
+
* group them too; `"turn"` folds a reply's whole working phase into
|
|
94
|
+
* "Worked for 9s" once it's done; `"separate"` gives every call its own
|
|
95
|
+
* card. Calls with a renderer of their own always show on their own.
|
|
96
|
+
*/
|
|
97
|
+
toolCallDisplay?: CopilotChatToolCallDisplay;
|
|
98
|
+
/**
|
|
99
|
+
* While Learning records this chat, the assistant thumbs record ratings
|
|
100
|
+
* and ask for a comment. Set `false` to leave the thumbs to the app's own
|
|
101
|
+
* handlers.
|
|
102
|
+
*/
|
|
103
|
+
messageFeedback?: boolean;
|
|
59
104
|
}>(),
|
|
60
105
|
{
|
|
61
106
|
messages: () => [],
|
|
62
107
|
isRunning: false,
|
|
108
|
+
toolCallDisplay: "grouped",
|
|
109
|
+
messageFeedback: true,
|
|
63
110
|
},
|
|
64
111
|
);
|
|
65
112
|
|
|
@@ -81,6 +128,8 @@ defineSlots<{
|
|
|
81
128
|
"activity-message"?: (props: ActivitySlotProps) => unknown;
|
|
82
129
|
[key: string]: ((props: any) => unknown) | undefined;
|
|
83
130
|
cursor?: () => unknown;
|
|
131
|
+
/** The "Working… / Worked for 9s" line of the `"turn"` tool-call display. */
|
|
132
|
+
"work-summary"?: (props: CopilotChatWorkSummarySlotProps) => unknown;
|
|
84
133
|
"tool-call"?: (props: {
|
|
85
134
|
name: string;
|
|
86
135
|
args: unknown;
|
|
@@ -163,34 +212,148 @@ watch(
|
|
|
163
212
|
{ immediate: true },
|
|
164
213
|
);
|
|
165
214
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
215
|
+
const deduplicatedMessages = computed(() =>
|
|
216
|
+
ɵdeduplicateMessages(props.messages),
|
|
217
|
+
);
|
|
218
|
+
|
|
219
|
+
// Groups of calls can span messages (an agent often sends each call as its
|
|
220
|
+
// own message), so they're laid out here for the whole list and handed to
|
|
221
|
+
// each message's tool calls view through provide/inject.
|
|
222
|
+
const toolCallLayouts = computed<ReadonlyMap<string, ɵToolCallLayout>>(() =>
|
|
223
|
+
props.toolCallDisplay === "separate"
|
|
224
|
+
? new Map()
|
|
225
|
+
: ɵgetToolCallLayouts(
|
|
226
|
+
deduplicatedMessages.value,
|
|
227
|
+
props.messages,
|
|
228
|
+
ɵgetToolCallRendererNames(copilotkit.value.renderToolCalls, {
|
|
229
|
+
slotNames: forwardedSlotNames.value,
|
|
230
|
+
}),
|
|
231
|
+
),
|
|
232
|
+
);
|
|
233
|
+
const learningFeedbackEnabled = useLearningFeedbackEnabled(copilotkit);
|
|
234
|
+
provide(
|
|
235
|
+
MessageFeedbackScopeKey,
|
|
236
|
+
computed<MessageFeedbackScope | null>(() =>
|
|
237
|
+
props.messageFeedback &&
|
|
238
|
+
learningFeedbackEnabled.value &&
|
|
239
|
+
config.value?.agentId !== undefined &&
|
|
240
|
+
config.value?.threadId !== undefined
|
|
241
|
+
? {
|
|
242
|
+
copilotkit: copilotkit.value,
|
|
243
|
+
agentId: config.value.agentId,
|
|
244
|
+
threadId: config.value.threadId,
|
|
245
|
+
}
|
|
246
|
+
: null,
|
|
247
|
+
),
|
|
248
|
+
);
|
|
249
|
+
|
|
250
|
+
const turnWork = computed(() =>
|
|
251
|
+
props.toolCallDisplay === "turn"
|
|
252
|
+
? ɵgetTurnWork(deduplicatedMessages.value, toolCallLayouts.value)
|
|
253
|
+
: undefined,
|
|
254
|
+
);
|
|
255
|
+
const turnByFirstMessage = computed(() => {
|
|
256
|
+
const byFirst = new Map<string, ɵTurnWork>();
|
|
257
|
+
for (const turn of turnWork.value?.values() ?? []) {
|
|
258
|
+
byFirst.set(turn.firstMessageId, turn);
|
|
186
259
|
}
|
|
187
|
-
return
|
|
188
|
-
}
|
|
260
|
+
return byFirst;
|
|
261
|
+
});
|
|
189
262
|
|
|
190
|
-
const
|
|
191
|
-
|
|
263
|
+
const lastRenderedMessage = computed(
|
|
264
|
+
() => deduplicatedMessages.value[deduplicatedMessages.value.length - 1],
|
|
265
|
+
);
|
|
266
|
+
// The latest reply is keyed by the user message it answers (see getTurnWork).
|
|
267
|
+
const latestTurnKey = computed(() =>
|
|
268
|
+
ɵgetLatestTurnKey(deduplicatedMessages.value),
|
|
192
269
|
);
|
|
193
270
|
|
|
271
|
+
// Work shows while the agent is on it and folds once the reply is done,
|
|
272
|
+
// unless the user has opened or closed it themselves.
|
|
273
|
+
const toggledTurns = ref<ReadonlyMap<string, boolean>>(new Map());
|
|
274
|
+
const turnOpenState = computed(() => ({
|
|
275
|
+
toggledTurns: toggledTurns.value,
|
|
276
|
+
isRunning: props.isRunning,
|
|
277
|
+
latestTurnKey: latestTurnKey.value,
|
|
278
|
+
}));
|
|
279
|
+
|
|
280
|
+
// How long the agent worked, for "Worked for 9s". Only known for replies this
|
|
281
|
+
// client watched start from the user's message; a restored thread shows the
|
|
282
|
+
// tool count instead.
|
|
283
|
+
const workTimes = new Map<string, ɵWorkTime>();
|
|
284
|
+
const workTimesVersion = ref(0);
|
|
285
|
+
watch(
|
|
286
|
+
[
|
|
287
|
+
() => props.toolCallDisplay,
|
|
288
|
+
() => props.isRunning,
|
|
289
|
+
latestTurnKey,
|
|
290
|
+
() => lastRenderedMessage.value?.role,
|
|
291
|
+
],
|
|
292
|
+
([display, isRunning, turnKey, lastRole]) => {
|
|
293
|
+
if (display !== "turn") return;
|
|
294
|
+
ɵrecordWorkTime(workTimes, {
|
|
295
|
+
isRunning,
|
|
296
|
+
latestTurnKey: turnKey,
|
|
297
|
+
lastMessageRole: lastRole,
|
|
298
|
+
now: Date.now(),
|
|
299
|
+
});
|
|
300
|
+
workTimesVersion.value++;
|
|
301
|
+
},
|
|
302
|
+
{ immediate: true },
|
|
303
|
+
);
|
|
304
|
+
|
|
305
|
+
// Whether each working-phase message's work, and its text, shows.
|
|
306
|
+
const workOpenState = computed(() =>
|
|
307
|
+
ɵgetWorkOpenState(turnWork.value?.values() ?? [], turnOpenState.value),
|
|
308
|
+
);
|
|
309
|
+
|
|
310
|
+
provide(
|
|
311
|
+
ToolCallDisplayContextKey,
|
|
312
|
+
computed<ɵToolCallDisplayContextValue>(() => ({
|
|
313
|
+
display: props.toolCallDisplay,
|
|
314
|
+
isRunning: props.isRunning,
|
|
315
|
+
layouts: toolCallLayouts.value,
|
|
316
|
+
workOpen: workOpenState.value.workOpen,
|
|
317
|
+
workTextOpen: workOpenState.value.workTextOpen,
|
|
318
|
+
})),
|
|
319
|
+
);
|
|
320
|
+
|
|
321
|
+
/** The `"turn"` display's summary line for a reply, or its slot. */
|
|
322
|
+
const WorkSummaryRow: FunctionalComponent<{
|
|
323
|
+
turnKey: string;
|
|
324
|
+
calls: ToolCallEntry[];
|
|
325
|
+
}> = ({ turnKey, calls }) => {
|
|
326
|
+
void workTimesVersion.value;
|
|
327
|
+
const isWorking = ɵisTurnWorking(turnKey, turnOpenState.value);
|
|
328
|
+
const isOpen = ɵisTurnWorkOpen(turnKey, turnOpenState.value);
|
|
329
|
+
const times = workTimes.get(turnKey);
|
|
330
|
+
const summaryProps: CopilotChatWorkSummarySlotProps = {
|
|
331
|
+
isWorking,
|
|
332
|
+
isOpen,
|
|
333
|
+
calls,
|
|
334
|
+
elapsedMs: times?.elapsedMs,
|
|
335
|
+
workingSince: times?.workingSince,
|
|
336
|
+
onClick: () => {
|
|
337
|
+
toggledTurns.value = new Map(toggledTurns.value).set(turnKey, !isOpen);
|
|
338
|
+
},
|
|
339
|
+
};
|
|
340
|
+
const slot = componentSlots["work-summary"];
|
|
341
|
+
return h(
|
|
342
|
+
CopilotChatCollapsible,
|
|
343
|
+
{ open: isWorking || calls.length > 0 },
|
|
344
|
+
() => [
|
|
345
|
+
h(
|
|
346
|
+
"div",
|
|
347
|
+
{ class: "cpk-message-view-work-summary" },
|
|
348
|
+
slot
|
|
349
|
+
? (slot(summaryProps) as VNode[])
|
|
350
|
+
: [h(CopilotChatWorkSummary, summaryProps)],
|
|
351
|
+
),
|
|
352
|
+
],
|
|
353
|
+
);
|
|
354
|
+
};
|
|
355
|
+
WorkSummaryRow.props = ["turnKey", "calls"];
|
|
356
|
+
|
|
194
357
|
// Stable per-row keys. Backends can re-key a message mid-stream, and keying
|
|
195
358
|
// rows by the canonical id tears the row down on that swap (the HITL chat
|
|
196
359
|
// flash). See @copilotkit/shared row-render-keys for the mechanism.
|
|
@@ -209,8 +372,20 @@ watch(
|
|
|
209
372
|
{ flush: "post" },
|
|
210
373
|
);
|
|
211
374
|
const lastMessage = computed(() => props.messages[props.messages.length - 1]);
|
|
375
|
+
// In the "turn" display the "Working" line at the top of the reply is the
|
|
376
|
+
// progress indicator; before the reply's first message it sits where the
|
|
377
|
+
// cursor would.
|
|
212
378
|
const showCursor = computed(
|
|
213
|
-
() =>
|
|
379
|
+
() =>
|
|
380
|
+
props.isRunning &&
|
|
381
|
+
lastMessage.value?.role !== "reasoning" &&
|
|
382
|
+
props.toolCallDisplay !== "turn",
|
|
383
|
+
);
|
|
384
|
+
const pendingWorkSummary = computed(
|
|
385
|
+
() =>
|
|
386
|
+
props.toolCallDisplay === "turn" &&
|
|
387
|
+
props.isRunning &&
|
|
388
|
+
lastRenderedMessage.value?.role === "user",
|
|
214
389
|
);
|
|
215
390
|
|
|
216
391
|
watch(
|
|
@@ -319,21 +494,12 @@ function resolveCustomMessageRenderer(
|
|
|
319
494
|
return null;
|
|
320
495
|
}
|
|
321
496
|
|
|
322
|
-
|
|
323
|
-
const
|
|
324
|
-
.
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
.sort((a, b) => {
|
|
329
|
-
const aHasAgent = a.agentId !== undefined;
|
|
330
|
-
const bHasAgent = b.agentId !== undefined;
|
|
331
|
-
if (aHasAgent === bHasAgent) return 0;
|
|
332
|
-
return aHasAgent ? -1 : 1;
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
const selected = renderers[0];
|
|
336
|
-
if (!selected?.render) {
|
|
497
|
+
// Try each renderer in order and use the first that has something to draw.
|
|
498
|
+
const selected = ɵresolveCustomMessageRenderers(
|
|
499
|
+
copilotkit.value.renderCustomMessages,
|
|
500
|
+
resolvedAgentId.value,
|
|
501
|
+
).find((renderer) => renderer.render);
|
|
502
|
+
if (!selected) {
|
|
337
503
|
return null;
|
|
338
504
|
}
|
|
339
505
|
|
|
@@ -348,53 +514,43 @@ function resolveActivityRenderer(
|
|
|
348
514
|
): { renderer: Component; props: ActivitySlotProps } | null {
|
|
349
515
|
stateTick.value += 0;
|
|
350
516
|
|
|
351
|
-
const
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
const bScoped = b.agentId !== undefined;
|
|
361
|
-
if (aScoped === bScoped) return 0;
|
|
362
|
-
return aScoped ? -1 : 1;
|
|
363
|
-
})[0];
|
|
364
|
-
|
|
365
|
-
if (!renderer) return null;
|
|
366
|
-
const parsed = renderer.content.safeParse(message.content);
|
|
367
|
-
if (!parsed.success) return null;
|
|
517
|
+
const match = ɵresolveActivityRenderer(
|
|
518
|
+
copilotkit.value.renderActivityMessages,
|
|
519
|
+
{
|
|
520
|
+
activityType: message.activityType,
|
|
521
|
+
agentId: resolvedAgentId.value,
|
|
522
|
+
content: message.content,
|
|
523
|
+
},
|
|
524
|
+
);
|
|
525
|
+
if (!match) return null;
|
|
368
526
|
|
|
369
527
|
return {
|
|
370
|
-
renderer: renderer.render as Component,
|
|
528
|
+
renderer: match.renderer.render as Component,
|
|
371
529
|
props: {
|
|
372
530
|
activityType: message.activityType,
|
|
373
|
-
content:
|
|
531
|
+
content: match.content,
|
|
374
532
|
message,
|
|
375
533
|
agent: resolvedThreadAgent.value,
|
|
376
534
|
},
|
|
377
535
|
};
|
|
378
536
|
}
|
|
379
|
-
|
|
380
|
-
function resolveToolMessage(
|
|
381
|
-
message: Message,
|
|
382
|
-
toolCallId: string,
|
|
383
|
-
): ToolMessage | undefined {
|
|
384
|
-
return props.messages.find(
|
|
385
|
-
(candidate) =>
|
|
386
|
-
candidate.role === "tool" &&
|
|
387
|
-
(candidate as ToolMessage).toolCallId === toolCallId,
|
|
388
|
-
) as ToolMessage | undefined;
|
|
389
|
-
}
|
|
390
537
|
</script>
|
|
391
538
|
|
|
392
539
|
<template>
|
|
393
|
-
<div
|
|
540
|
+
<div
|
|
541
|
+
data-copilotkit
|
|
542
|
+
class="copilotKitMessages cpk-message-view"
|
|
543
|
+
v-bind="$attrs"
|
|
544
|
+
>
|
|
394
545
|
<template
|
|
395
546
|
v-for="message in deduplicatedMessages"
|
|
396
547
|
:key="rowRenderKeys.get(message.id) ?? message.id"
|
|
397
548
|
>
|
|
549
|
+
<WorkSummaryRow
|
|
550
|
+
v-if="turnByFirstMessage.get(message.id)"
|
|
551
|
+
:turn-key="turnByFirstMessage.get(message.id)!.key"
|
|
552
|
+
:calls="turnByFirstMessage.get(message.id)!.calls"
|
|
553
|
+
/>
|
|
398
554
|
<MessageMetaSlot
|
|
399
555
|
v-if="componentSlots['message-before']"
|
|
400
556
|
:render="componentSlots['message-before']"
|
|
@@ -444,19 +600,30 @@ function resolveToolMessage(
|
|
|
444
600
|
</CopilotChatUserMessage>
|
|
445
601
|
</slot>
|
|
446
602
|
|
|
447
|
-
|
|
603
|
+
<!-- Reasoning during a reply's working phase folds away with the work.
|
|
604
|
+
Always wrapped in this display, so reasoning that turns into work
|
|
605
|
+
keeps its node (and its "Thought for" timer) instead of remounting. -->
|
|
606
|
+
<TurnWorkFold
|
|
448
607
|
v-else-if="message.role === 'reasoning'"
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
608
|
+
:open="
|
|
609
|
+
toolCallDisplay === 'turn'
|
|
610
|
+
? (workOpenState.workOpen.get(message.id) ?? true)
|
|
611
|
+
: undefined
|
|
612
|
+
"
|
|
453
613
|
>
|
|
454
|
-
<
|
|
614
|
+
<slot
|
|
615
|
+
name="reasoning-message"
|
|
455
616
|
:message="message"
|
|
456
617
|
:messages="messages"
|
|
457
618
|
:is-running="isRunning"
|
|
458
|
-
|
|
459
|
-
|
|
619
|
+
>
|
|
620
|
+
<CopilotChatReasoningMessage
|
|
621
|
+
:message="message"
|
|
622
|
+
:messages="messages"
|
|
623
|
+
:is-running="isRunning"
|
|
624
|
+
/>
|
|
625
|
+
</slot>
|
|
626
|
+
</TurnWorkFold>
|
|
460
627
|
|
|
461
628
|
<slot
|
|
462
629
|
v-else-if="message.role === 'activity'"
|
|
@@ -504,11 +671,19 @@ function resolveToolMessage(
|
|
|
504
671
|
:cancel="interruptState.cancel"
|
|
505
672
|
/>
|
|
506
673
|
|
|
507
|
-
<
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
674
|
+
<WorkSummaryRow
|
|
675
|
+
v-if="pendingWorkSummary"
|
|
676
|
+
:turn-key="latestTurnKey"
|
|
677
|
+
:calls="[]"
|
|
678
|
+
/>
|
|
679
|
+
|
|
680
|
+
<div v-if="showCursor" class="cpk-message-view-cursor-container">
|
|
681
|
+
<slot name="cursor">
|
|
682
|
+
<div
|
|
683
|
+
class="cpk-message-view-cursor"
|
|
684
|
+
data-testid="copilot-loading-cursor"
|
|
685
|
+
/>
|
|
686
|
+
</slot>
|
|
687
|
+
</div>
|
|
513
688
|
</div>
|
|
514
689
|
</template>
|
|
@@ -3,8 +3,9 @@ import { computed, onBeforeUnmount, ref, watch } from "vue";
|
|
|
3
3
|
import type { Message, ReasoningMessage } from "@ag-ui/core";
|
|
4
4
|
import { IconChevronRight } from "../icons";
|
|
5
5
|
import StreamingMarkdownDefault from "./StreamingMarkdownDefault.vue";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { ɵformatLabel, ɵformatReasoningDuration } from "@copilotkit/core";
|
|
7
|
+
import type { CopilotChatLabels } from "@copilotkit/core";
|
|
8
|
+
import { useChatLabels } from "./use-chat-labels";
|
|
8
9
|
|
|
9
10
|
const props = withDefaults(
|
|
10
11
|
defineProps<{
|
|
@@ -69,13 +70,29 @@ defineSlots<{
|
|
|
69
70
|
}) => unknown;
|
|
70
71
|
}>();
|
|
71
72
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
73
|
+
/** How long the model reasoned, in the chat's labels: "4 seconds", "1m 5s". */
|
|
74
|
+
function formatDuration(labels: Readonly<CopilotChatLabels>, seconds: number) {
|
|
75
|
+
const duration = ɵformatReasoningDuration(seconds);
|
|
76
|
+
switch (duration.unit) {
|
|
77
|
+
case "fewSeconds":
|
|
78
|
+
return labels.reasoningMessageDurationFewSeconds;
|
|
79
|
+
case "seconds":
|
|
80
|
+
return ɵformatLabel(labels.reasoningMessageDurationSeconds, {
|
|
81
|
+
count: duration.seconds,
|
|
82
|
+
});
|
|
83
|
+
case "minutes":
|
|
84
|
+
return ɵformatLabel(
|
|
85
|
+
duration.minutes === 1
|
|
86
|
+
? labels.reasoningMessageDurationMinutesOne
|
|
87
|
+
: labels.reasoningMessageDurationMinutesOther,
|
|
88
|
+
{ count: duration.minutes },
|
|
89
|
+
);
|
|
90
|
+
case "minutesSeconds":
|
|
91
|
+
return ɵformatLabel(labels.reasoningMessageDurationMinutesSeconds, {
|
|
92
|
+
minutes: duration.minutes,
|
|
93
|
+
seconds: duration.seconds,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
79
96
|
}
|
|
80
97
|
|
|
81
98
|
const normalizedContent = computed(() =>
|
|
@@ -133,13 +150,14 @@ onBeforeUnmount(() => {
|
|
|
133
150
|
clearElapsedInterval();
|
|
134
151
|
});
|
|
135
152
|
|
|
136
|
-
const
|
|
153
|
+
const labels = useChatLabels();
|
|
137
154
|
/** `labels.reasoningMessageThinkingLabel` while streaming, then "Thought for …". */
|
|
138
155
|
const label = computed(() =>
|
|
139
156
|
isStreaming.value
|
|
140
|
-
?
|
|
141
|
-
|
|
142
|
-
|
|
157
|
+
? labels.value.reasoningMessageThinkingLabel
|
|
158
|
+
: ɵformatLabel(labels.value.reasoningMessageThoughtForLabel, {
|
|
159
|
+
duration: formatDuration(labels.value, elapsed.value),
|
|
160
|
+
}),
|
|
143
161
|
);
|
|
144
162
|
|
|
145
163
|
function toggleOpen() {
|
|
@@ -150,7 +168,11 @@ function toggleOpen() {
|
|
|
150
168
|
</script>
|
|
151
169
|
|
|
152
170
|
<template>
|
|
153
|
-
<div
|
|
171
|
+
<div
|
|
172
|
+
data-copilotkit
|
|
173
|
+
class="cpk-reasoning-message"
|
|
174
|
+
:data-message-id="message.id"
|
|
175
|
+
>
|
|
154
176
|
<slot
|
|
155
177
|
name="layout"
|
|
156
178
|
:message="message"
|
|
@@ -189,28 +211,22 @@ function toggleOpen() {
|
|
|
189
211
|
>
|
|
190
212
|
<button
|
|
191
213
|
type="button"
|
|
192
|
-
class="cpk
|
|
193
|
-
:class="
|
|
194
|
-
hasContent
|
|
195
|
-
? 'cpk:hover:text-foreground cpk:cursor-pointer'
|
|
196
|
-
: 'cpk:cursor-default'
|
|
197
|
-
"
|
|
214
|
+
class="cpk-reasoning-message-header"
|
|
215
|
+
:class="{ 'cpk-reasoning-message-header-expandable': hasContent }"
|
|
198
216
|
:aria-expanded="hasContent ? isOpen : undefined"
|
|
199
217
|
@click="hasContent ? toggleOpen() : undefined"
|
|
200
218
|
>
|
|
201
|
-
<span class="cpk
|
|
219
|
+
<span class="cpk-reasoning-message-label">{{ label }}</span>
|
|
202
220
|
<span
|
|
203
221
|
v-if="isStreaming && !hasContent"
|
|
204
|
-
class="cpk
|
|
222
|
+
class="cpk-reasoning-message-indicator"
|
|
205
223
|
>
|
|
206
|
-
<span
|
|
207
|
-
class="cpk:w-1.5 cpk:h-1.5 cpk:rounded-full cpk:bg-muted-foreground cpk:animate-pulse"
|
|
208
|
-
/>
|
|
224
|
+
<span class="cpk-reasoning-message-indicator-dot" />
|
|
209
225
|
</span>
|
|
210
226
|
<IconChevronRight
|
|
211
227
|
v-if="hasContent"
|
|
212
|
-
class="cpk
|
|
213
|
-
:class="{ 'cpk
|
|
228
|
+
class="cpk-reasoning-message-chevron"
|
|
229
|
+
:class="{ 'cpk-reasoning-message-chevron-open': isOpen }"
|
|
214
230
|
/>
|
|
215
231
|
</button>
|
|
216
232
|
</slot>
|
|
@@ -225,18 +241,21 @@ function toggleOpen() {
|
|
|
225
241
|
}"
|
|
226
242
|
>
|
|
227
243
|
<div
|
|
228
|
-
class="cpk
|
|
244
|
+
class="cpk-reasoning-message-toggle"
|
|
229
245
|
:style="{ gridTemplateRows: isOpen ? '1fr' : '0fr' }"
|
|
230
246
|
>
|
|
231
|
-
<div class="cpk
|
|
247
|
+
<div class="cpk-reasoning-message-toggle-content">
|
|
232
248
|
<slot
|
|
233
249
|
name="content-view"
|
|
234
250
|
:is-streaming="isStreaming"
|
|
235
251
|
:has-content="hasContent"
|
|
236
252
|
:content="normalizedContent"
|
|
237
253
|
>
|
|
238
|
-
<div
|
|
239
|
-
|
|
254
|
+
<div
|
|
255
|
+
v-if="hasContent || isStreaming"
|
|
256
|
+
class="cpk-reasoning-message-content"
|
|
257
|
+
>
|
|
258
|
+
<div class="cpk-reasoning-message-text">
|
|
240
259
|
<!-- Reasoning content uses the streaming renderer (same as assistant);
|
|
241
260
|
the pluggable provider renderer applies to assistant messages only. -->
|
|
242
261
|
<StreamingMarkdownDefault
|
|
@@ -245,11 +264,9 @@ function toggleOpen() {
|
|
|
245
264
|
/>
|
|
246
265
|
<span
|
|
247
266
|
v-if="isStreaming && hasContent"
|
|
248
|
-
class="cpk
|
|
267
|
+
class="cpk-reasoning-message-cursor"
|
|
249
268
|
>
|
|
250
|
-
<span
|
|
251
|
-
class="cpk:w-2 cpk:h-2 cpk:rounded-full cpk:bg-muted-foreground cpk:animate-pulse-cursor"
|
|
252
|
-
/>
|
|
269
|
+
<span class="cpk-reasoning-message-cursor-dot" />
|
|
253
270
|
</span>
|
|
254
271
|
</div>
|
|
255
272
|
</div>
|
|
@@ -29,27 +29,18 @@ const isDisabled = computed(() => props.isLoading || props.disabled);
|
|
|
29
29
|
:type="type"
|
|
30
30
|
:aria-busy="isLoading ? 'true' : undefined"
|
|
31
31
|
:disabled="isDisabled"
|
|
32
|
-
class="cpk
|
|
32
|
+
class="cpk-suggestion-pill"
|
|
33
33
|
v-bind="$attrs"
|
|
34
34
|
>
|
|
35
|
-
<span
|
|
36
|
-
|
|
37
|
-
class="cpk:flex cpk:h-3.5 cpk:w-3.5 cpk:items-center cpk:justify-center cpk:text-muted-foreground cpk:sm:h-4 cpk:sm:w-4"
|
|
38
|
-
>
|
|
39
|
-
<IconLoader2
|
|
40
|
-
class="cpk:h-3.5 cpk:w-3.5 cpk:animate-spin cpk:sm:h-4 cpk:sm:w-4"
|
|
41
|
-
aria-hidden="true"
|
|
42
|
-
/>
|
|
35
|
+
<span v-if="isLoading" class="cpk-suggestion-pill-icon">
|
|
36
|
+
<IconLoader2 class="cpk-suggestion-pill-spinner" aria-hidden="true" />
|
|
43
37
|
</span>
|
|
44
|
-
<span
|
|
45
|
-
v-else-if="$slots.icon || icon"
|
|
46
|
-
class="cpk:flex cpk:h-3.5 cpk:w-3.5 cpk:items-center cpk:justify-center cpk:text-muted-foreground cpk:sm:h-4 cpk:sm:w-4"
|
|
47
|
-
>
|
|
38
|
+
<span v-else-if="$slots.icon || icon" class="cpk-suggestion-pill-icon">
|
|
48
39
|
<slot name="icon">
|
|
49
40
|
<component :is="icon" />
|
|
50
41
|
</slot>
|
|
51
42
|
</span>
|
|
52
|
-
<span class="cpk
|
|
43
|
+
<span class="cpk-suggestion-pill-label">
|
|
53
44
|
<slot />
|
|
54
45
|
</span>
|
|
55
46
|
</button>
|
|
@@ -32,10 +32,7 @@ const emit = defineEmits<{
|
|
|
32
32
|
|
|
33
33
|
const attrs = useAttrs();
|
|
34
34
|
const loadingSet = computed(() => new Set(props.loadingIndexes));
|
|
35
|
-
const containerClass = computed(() => [
|
|
36
|
-
"cpk:flex cpk:flex-wrap cpk:items-center cpk:gap-1.5 cpk:pl-0 cpk:pr-4 cpk:pointer-events-none cpk:sm:gap-2 cpk:@3xl:px-0",
|
|
37
|
-
attrs.class,
|
|
38
|
-
]);
|
|
35
|
+
const containerClass = computed(() => ["cpk-suggestion-view", attrs.class]);
|
|
39
36
|
const containerAttrs = computed(() => {
|
|
40
37
|
const { class: _className, ...rest } = attrs;
|
|
41
38
|
return rest;
|