@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
|
@@ -1,127 +1,62 @@
|
|
|
1
|
-
import type { Message, ToolCall
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import type { Message, ToolCall } from "@ag-ui/core";
|
|
2
|
+
import {
|
|
3
|
+
ɵbuildToolCallRenderProps,
|
|
4
|
+
ɵfindToolMessage,
|
|
5
|
+
ɵresolveToolCallAgentId,
|
|
6
|
+
ɵresolveToolCallRenderer,
|
|
7
|
+
} from "@copilotkit/core";
|
|
6
8
|
import type { CopilotChatToolCallRenderSlotProps } from "./types";
|
|
7
9
|
import type {
|
|
8
10
|
VueToolCallRenderer,
|
|
9
11
|
VueToolCallRendererRenderProps,
|
|
10
12
|
} from "../../types";
|
|
11
13
|
|
|
12
|
-
export function findToolMessage(
|
|
13
|
-
messages: Message[],
|
|
14
|
-
toolCallId: string,
|
|
15
|
-
): ToolMessage | undefined {
|
|
16
|
-
return messages.find(
|
|
17
|
-
(message) =>
|
|
18
|
-
message.role === "tool" &&
|
|
19
|
-
(message as ToolMessage).toolCallId === toolCallId,
|
|
20
|
-
) as ToolMessage | undefined;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
14
|
export function getToolCallSlotName(toolName: string): `tool-call-${string}` {
|
|
24
15
|
return `tool-call-${toolName}`;
|
|
25
16
|
}
|
|
26
17
|
|
|
27
|
-
|
|
28
|
-
toolCall: ToolCall,
|
|
29
|
-
renderToolCalls: readonly VueToolCallRenderer<unknown>[],
|
|
30
|
-
agentId: string,
|
|
31
|
-
): VueToolCallRenderer<unknown> | undefined {
|
|
32
|
-
const exactMatches = renderToolCalls.filter(
|
|
33
|
-
(renderConfig) => renderConfig.name === toolCall.function.name,
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
return (
|
|
37
|
-
exactMatches.find((renderConfig) => renderConfig.agentId === agentId) ??
|
|
38
|
-
exactMatches.find((renderConfig) => !renderConfig.agentId) ??
|
|
39
|
-
exactMatches[0] ??
|
|
40
|
-
renderToolCalls.find((renderConfig) => renderConfig.name === "*")
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
|
|
18
|
+
/** Props for a `tool-call` / `tool-call-<name>` slot. */
|
|
44
19
|
export function getToolCallRenderProps(
|
|
45
20
|
toolCall: ToolCall,
|
|
46
21
|
messages: Message[],
|
|
47
22
|
executingToolCallIds: ReadonlySet<string>,
|
|
48
23
|
): CopilotChatToolCallRenderSlotProps {
|
|
49
|
-
const toolMessage =
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
if (toolMessage) {
|
|
53
|
-
return {
|
|
54
|
-
name: toolCall.function.name,
|
|
55
|
-
args: parsedArgs,
|
|
56
|
-
status: ToolCallStatus.Complete,
|
|
57
|
-
result: contentToText(toolMessage.content),
|
|
58
|
-
toolCall,
|
|
59
|
-
toolMessage,
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const isExecuting = executingToolCallIds.has(toolCall.id);
|
|
64
|
-
return {
|
|
65
|
-
name: toolCall.function.name,
|
|
66
|
-
args: parsedArgs,
|
|
67
|
-
status: isExecuting ? ToolCallStatus.Executing : ToolCallStatus.InProgress,
|
|
68
|
-
result: undefined,
|
|
24
|
+
const toolMessage = ɵfindToolMessage(messages, toolCall.id);
|
|
25
|
+
const { name, args, status, result } = ɵbuildToolCallRenderProps(
|
|
69
26
|
toolCall,
|
|
70
|
-
toolMessage
|
|
71
|
-
|
|
27
|
+
toolMessage,
|
|
28
|
+
{ isExecuting: executingToolCallIds.has(toolCall.id) },
|
|
29
|
+
);
|
|
30
|
+
return { name, args, status, result, toolCall, toolMessage };
|
|
72
31
|
}
|
|
73
32
|
|
|
33
|
+
/** Props for a registered renderer's `render`. */
|
|
74
34
|
export function getCoreRenderProps(
|
|
75
35
|
toolCall: ToolCall,
|
|
76
36
|
messages: Message[],
|
|
77
37
|
executingToolCallIds: ReadonlySet<string>,
|
|
78
38
|
): VueToolCallRendererRenderProps<unknown> {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
name: toolCall.function.name,
|
|
85
|
-
toolCallId: toolCall.id,
|
|
86
|
-
args: parsedArgs,
|
|
87
|
-
status: ToolCallStatus.Complete,
|
|
88
|
-
result: contentToText(toolMessage.content),
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const isExecuting = executingToolCallIds.has(toolCall.id);
|
|
93
|
-
if (isExecuting) {
|
|
94
|
-
return {
|
|
95
|
-
name: toolCall.function.name,
|
|
96
|
-
toolCallId: toolCall.id,
|
|
97
|
-
args: parsedArgs,
|
|
98
|
-
status: ToolCallStatus.Executing,
|
|
99
|
-
result: undefined,
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return {
|
|
104
|
-
name: toolCall.function.name,
|
|
105
|
-
toolCallId: toolCall.id,
|
|
106
|
-
args: parsedArgs && typeof parsedArgs === "object" ? parsedArgs : {},
|
|
107
|
-
status: ToolCallStatus.InProgress,
|
|
108
|
-
result: undefined,
|
|
109
|
-
};
|
|
39
|
+
return ɵbuildToolCallRenderProps(
|
|
40
|
+
toolCall,
|
|
41
|
+
ɵfindToolMessage(messages, toolCall.id),
|
|
42
|
+
{ isExecuting: executingToolCallIds.has(toolCall.id) },
|
|
43
|
+
);
|
|
110
44
|
}
|
|
111
45
|
|
|
112
46
|
export function getToolCallMemoDeps(
|
|
113
47
|
toolCall: ToolCall,
|
|
114
48
|
messages: Message[],
|
|
115
49
|
executingToolCallIds: ReadonlySet<string>,
|
|
116
|
-
renderToolCalls: readonly VueToolCallRenderer
|
|
117
|
-
agentId: string =
|
|
50
|
+
renderToolCalls: readonly VueToolCallRenderer[],
|
|
51
|
+
agentId: string = ɵresolveToolCallAgentId(undefined, undefined),
|
|
118
52
|
): unknown[] {
|
|
119
53
|
return [
|
|
120
54
|
toolCall.id,
|
|
121
55
|
toolCall.function.name,
|
|
122
56
|
toolCall.function.arguments,
|
|
123
|
-
|
|
57
|
+
ɵfindToolMessage(messages, toolCall.id)?.content,
|
|
124
58
|
executingToolCallIds.has(toolCall.id),
|
|
125
|
-
|
|
59
|
+
ɵresolveToolCallRenderer(renderToolCalls, toolCall.function.name, agentId)
|
|
60
|
+
?.render,
|
|
126
61
|
];
|
|
127
62
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Slots } from "vue";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Returns the names of the slots that a wrapper passes on to the component it
|
|
5
|
+
* wraps: every slot in `slots` except the ones in `ownSlots`, which the
|
|
6
|
+
* wrapper renders itself.
|
|
7
|
+
*
|
|
8
|
+
* CopilotChat passes every slot except `chat-view` to CopilotChatView.
|
|
9
|
+
* CopilotSidebar, CopilotPopup, and their view components use this rule at
|
|
10
|
+
* each layer, so a slot that works on CopilotChat also works on them.
|
|
11
|
+
*/
|
|
12
|
+
export function forwardedSlotNames(
|
|
13
|
+
slots: Slots,
|
|
14
|
+
ownSlots: readonly string[] = [],
|
|
15
|
+
): string[] {
|
|
16
|
+
return Object.keys(slots).filter((name) => !ownSlots.includes(name));
|
|
17
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export * from "./types";
|
|
2
|
-
export { default as BasicMarkdown } from "./BasicMarkdown.vue";
|
|
3
2
|
export { default as StreamingMarkdownDefault } from "./StreamingMarkdownDefault.vue";
|
|
4
3
|
export { default as CopilotChatAssistantMessage } from "./CopilotChatAssistantMessage.vue";
|
|
5
4
|
export { default as CopilotChatAudioRecorder } from "./CopilotChatAudioRecorder.vue";
|
|
@@ -1,34 +1,28 @@
|
|
|
1
|
+
import { ɵinspectorShortcuts } from "@copilotkit/core";
|
|
1
2
|
import { onBeforeUnmount, readonly, ref } from "vue";
|
|
2
3
|
import type { Ref } from "vue";
|
|
3
4
|
|
|
4
|
-
// Page-lifetime preference, shared by every message and chat. Deliberately
|
|
5
|
-
// avoid sessionStorage: it survives reloads, while this preference must not.
|
|
6
|
-
let shortcutsHidden = false;
|
|
7
|
-
const listeners = new Set<() => void>();
|
|
8
|
-
|
|
9
5
|
/**
|
|
10
6
|
* Whether the user hid the Inspector buttons in the message toolbars ("Hide
|
|
11
|
-
* this icon"), until the page reloads.
|
|
7
|
+
* this icon"), until the page reloads. Core's `ɵinspectorShortcuts` holds
|
|
8
|
+
* the page-lifetime preference.
|
|
12
9
|
* @internal
|
|
13
10
|
*/
|
|
14
11
|
export function useInspectorShortcutsHidden(): Readonly<Ref<boolean>> {
|
|
15
|
-
const hidden = ref(
|
|
16
|
-
const
|
|
17
|
-
hidden.value =
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
onBeforeUnmount(() => listeners.delete(listener));
|
|
12
|
+
const hidden = ref(ɵinspectorShortcuts.hidden);
|
|
13
|
+
const unsubscribe = ɵinspectorShortcuts.subscribe(() => {
|
|
14
|
+
hidden.value = ɵinspectorShortcuts.hidden;
|
|
15
|
+
});
|
|
16
|
+
onBeforeUnmount(unsubscribe);
|
|
21
17
|
return readonly(hidden);
|
|
22
18
|
}
|
|
23
19
|
|
|
24
20
|
/** Hides the Inspector buttons of every message until the page reloads. */
|
|
25
21
|
export function hideInspectorShortcuts(): void {
|
|
26
|
-
|
|
27
|
-
listeners.forEach((listener) => listener());
|
|
22
|
+
ɵinspectorShortcuts.hide();
|
|
28
23
|
}
|
|
29
24
|
|
|
30
25
|
/** @internal Shows the buttons again, so each test starts fresh. */
|
|
31
26
|
export function ɵresetInspectorShortcuts(): void {
|
|
32
|
-
|
|
33
|
-
listeners.forEach((listener) => listener());
|
|
27
|
+
ɵinspectorShortcuts.reset();
|
|
34
28
|
}
|
|
@@ -1,23 +1,30 @@
|
|
|
1
1
|
import type { AssistantMessage } from "@ag-ui/core";
|
|
2
2
|
import type { CopilotKitCore } from "@copilotkit/core";
|
|
3
|
-
import { computed, inject, onBeforeUnmount, ref, shallowRef, watch } from "vue";
|
|
4
|
-
import type { ComputedRef, InjectionKey, Ref } from "vue";
|
|
5
3
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
ɵFeedbackCommentController,
|
|
5
|
+
ɵgetMessageFeedbackControls,
|
|
6
|
+
ɵisLearningFeedbackEnabled,
|
|
7
|
+
ɵsubscribeToLearningFeedbackEnabled,
|
|
8
|
+
ɵsubscribeToMessageFeedback,
|
|
9
|
+
} from "@copilotkit/core";
|
|
10
|
+
import type {
|
|
11
|
+
ɵMessageFeedbackControls,
|
|
12
|
+
ɵMessageFeedbackScope,
|
|
13
|
+
} from "@copilotkit/core";
|
|
14
|
+
import { computed, inject, onBeforeUnmount, ref, shallowRef, watch } from "vue";
|
|
10
15
|
import type {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
16
|
+
ComputedRef,
|
|
17
|
+
InjectionKey,
|
|
18
|
+
Ref,
|
|
19
|
+
ShallowRef,
|
|
20
|
+
WritableComputedRef,
|
|
21
|
+
} from "vue";
|
|
14
22
|
|
|
15
23
|
/** The chat whose assistant messages collect feedback for Learning. */
|
|
16
|
-
export
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
24
|
+
export type MessageFeedbackScope = ɵMessageFeedbackScope;
|
|
25
|
+
|
|
26
|
+
/** Current feedback for one assistant message, and how to change it. */
|
|
27
|
+
export type MessageFeedbackControls = ɵMessageFeedbackControls;
|
|
21
28
|
|
|
22
29
|
/**
|
|
23
30
|
* Provided by the message view while Learning is on for this chat. Assistant
|
|
@@ -29,68 +36,27 @@ export const MessageFeedbackScopeKey: InjectionKey<
|
|
|
29
36
|
Ref<MessageFeedbackScope | null>
|
|
30
37
|
> = Symbol("CopilotMessageFeedbackScope");
|
|
31
38
|
|
|
32
|
-
// Cores that captured since Learning was configured, for chats that mount
|
|
33
|
-
// while capture reconnects or is stopped. A Core leaves when its config goes.
|
|
34
|
-
const capturedCores = new WeakSet<CopilotKitCore>();
|
|
35
|
-
|
|
36
|
-
const rememberCapture = (copilotkit: CopilotKitCore) => {
|
|
37
|
-
if (capturedCores.has(copilotkit)) return;
|
|
38
|
-
capturedCores.add(copilotkit);
|
|
39
|
-
const unsubscribe = copilotkit.ɵsubscribeToLearningConfigured(() => {
|
|
40
|
-
if (copilotkit.ɵlearningConfigured) return;
|
|
41
|
-
capturedCores.delete(copilotkit);
|
|
42
|
-
unsubscribe();
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
|
|
46
39
|
/**
|
|
47
|
-
* Whether the thumbs record feedback for Learning.
|
|
48
|
-
*
|
|
49
|
-
* capture reconnects or is stopped, so the buttons do not flicker. Ratings
|
|
50
|
-
* given meanwhile still show but, like any Trajectory event, are not sent.
|
|
40
|
+
* Whether the thumbs record feedback for Learning. See core's
|
|
41
|
+
* `ɵisLearningFeedbackEnabled` for the rules.
|
|
51
42
|
* @internal
|
|
52
43
|
*/
|
|
53
44
|
export function useLearningFeedbackEnabled(
|
|
54
45
|
copilotkit: Ref<CopilotKitCore>,
|
|
55
46
|
): ComputedRef<boolean> {
|
|
56
|
-
const
|
|
57
|
-
const capturing = ref(false);
|
|
58
|
-
|
|
47
|
+
const enabled = ref(false);
|
|
59
48
|
watch(
|
|
60
49
|
copilotkit,
|
|
61
50
|
(core, _previous, onCleanup) => {
|
|
62
51
|
const read = () => {
|
|
63
|
-
|
|
64
|
-
capturing.value = core.trajectoryId !== null;
|
|
65
|
-
if (capturing.value) rememberCapture(core);
|
|
52
|
+
enabled.value = ɵisLearningFeedbackEnabled(core);
|
|
66
53
|
};
|
|
67
54
|
read();
|
|
68
|
-
|
|
69
|
-
const subscription = core.subscribe({ onTrajectoryChanged: read });
|
|
70
|
-
onCleanup(() => {
|
|
71
|
-
unsubscribeConfigured();
|
|
72
|
-
subscription.unsubscribe();
|
|
73
|
-
});
|
|
55
|
+
onCleanup(ɵsubscribeToLearningFeedbackEnabled(core, read));
|
|
74
56
|
},
|
|
75
57
|
{ immediate: true },
|
|
76
58
|
);
|
|
77
|
-
|
|
78
|
-
return computed(
|
|
79
|
-
() =>
|
|
80
|
-
configured.value &&
|
|
81
|
-
(capturing.value || capturedCores.has(copilotkit.value)),
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/** Current feedback for one assistant message, and how to change it. */
|
|
86
|
-
export interface MessageFeedbackControls {
|
|
87
|
-
readonly feedback: MessageFeedback | undefined;
|
|
88
|
-
/** Gives `rating`; a different rating than before starts without a comment. */
|
|
89
|
-
readonly rate: (rating: MessageFeedbackRating) => void;
|
|
90
|
-
/** Removes the rating and its comment. */
|
|
91
|
-
readonly clear: () => void;
|
|
92
|
-
/** Sets the current rating's comment; an empty one removes it. */
|
|
93
|
-
readonly comment: (comment: string) => void;
|
|
59
|
+
return computed(() => enabled.value);
|
|
94
60
|
}
|
|
95
61
|
|
|
96
62
|
/** Feedback controls for `message`, or `null` when this chat collects none. */
|
|
@@ -106,7 +72,7 @@ export function useMessageFeedback(
|
|
|
106
72
|
(current, _previous, onCleanup) => {
|
|
107
73
|
if (!current) return;
|
|
108
74
|
onCleanup(
|
|
109
|
-
|
|
75
|
+
ɵsubscribeToMessageFeedback(current.agentId, current.threadId, () => {
|
|
110
76
|
version.value++;
|
|
111
77
|
}),
|
|
112
78
|
);
|
|
@@ -118,174 +84,105 @@ export function useMessageFeedback(
|
|
|
118
84
|
const current = scope.value;
|
|
119
85
|
if (!current) return null;
|
|
120
86
|
void version.value;
|
|
121
|
-
|
|
122
|
-
const feedback = getMessageFeedback(
|
|
123
|
-
current.agentId,
|
|
124
|
-
current.threadId,
|
|
125
|
-
target.id,
|
|
126
|
-
);
|
|
127
|
-
const save = (next: MessageFeedback | null) =>
|
|
128
|
-
setMessageFeedback({ ...current, message: target, feedback: next });
|
|
129
|
-
return {
|
|
130
|
-
feedback,
|
|
131
|
-
rate: (rating) => {
|
|
132
|
-
if (feedback?.rating !== rating) save({ rating });
|
|
133
|
-
},
|
|
134
|
-
clear: () => {
|
|
135
|
-
if (feedback) save(null);
|
|
136
|
-
},
|
|
137
|
-
comment: (comment) => {
|
|
138
|
-
if (feedback) save({ rating: feedback.rating, comment });
|
|
139
|
-
},
|
|
140
|
-
};
|
|
87
|
+
return ɵgetMessageFeedbackControls(current, message.value);
|
|
141
88
|
});
|
|
142
89
|
}
|
|
143
90
|
|
|
144
|
-
/**
|
|
145
|
-
* How long the pointer may be away from the rating and its comment before the
|
|
146
|
-
* comment closes: enough to cross the gap between them, short enough that
|
|
147
|
-
* passing over a rating does not leave it open.
|
|
148
|
-
*/
|
|
149
|
-
export const FEEDBACK_COMMENT_CLOSE_DELAY_MS = 150;
|
|
150
|
-
|
|
151
91
|
/** The comment popover of one rated message: when it shows and what it holds. */
|
|
152
92
|
export interface FeedbackComment {
|
|
153
|
-
readonly open:
|
|
93
|
+
readonly open: ComputedRef<boolean>;
|
|
154
94
|
/** The comment being edited. */
|
|
155
|
-
readonly draft:
|
|
95
|
+
readonly draft: WritableComputedRef<string>;
|
|
156
96
|
/** Grows each time the field should take focus: after a keyboard rating. */
|
|
157
|
-
readonly focusRequest:
|
|
97
|
+
readonly focusRequest: ComputedRef<number>;
|
|
158
98
|
/** Whether a focus request waits; reading it answers the request. */
|
|
159
99
|
readonly takeFocusRequest: () => boolean;
|
|
160
100
|
/** The comment field, for moving focus into it. */
|
|
161
|
-
readonly input:
|
|
101
|
+
readonly input: ShallowRef<HTMLInputElement | null>;
|
|
162
102
|
/** Opens with `comment` in the field. */
|
|
163
|
-
readonly show:
|
|
103
|
+
readonly show: ɵFeedbackCommentController["show"];
|
|
164
104
|
/** The pointer or focus reached the rating or the popover. */
|
|
165
|
-
readonly enter:
|
|
105
|
+
readonly enter: ɵFeedbackCommentController["enter"];
|
|
166
106
|
/**
|
|
167
107
|
* It left them: close soon, unless the user is editing the comment or, when
|
|
168
108
|
* focus left, the pointer is still on the rating or the popover.
|
|
169
109
|
*/
|
|
170
|
-
readonly leave:
|
|
110
|
+
readonly leave: ɵFeedbackCommentController["leave"];
|
|
171
111
|
/** Tracks whether focus is in the comment form. */
|
|
172
112
|
readonly setEditing: (editing: boolean) => void;
|
|
173
113
|
/** Closes, saving a changed comment unless `save` is false. */
|
|
174
|
-
readonly close:
|
|
114
|
+
readonly close: ɵFeedbackCommentController["close"];
|
|
175
115
|
/** Moves focus back to the thumb without opening the comment again. */
|
|
176
116
|
readonly returnFocus: (target: HTMLElement | null) => void;
|
|
117
|
+
/** The chosen thumb the popover points at. */
|
|
118
|
+
readonly anchor: ComputedRef<HTMLElement | null>;
|
|
119
|
+
/** A thumb click; returns whether the app's handler should run. */
|
|
120
|
+
readonly rate: ɵFeedbackCommentController["rate"];
|
|
121
|
+
/** The attributes and handlers of one thumb. */
|
|
122
|
+
readonly thumb: ɵFeedbackCommentController["thumb"];
|
|
123
|
+
/** Points at the chosen thumb when the click gave no element. */
|
|
124
|
+
readonly findAnchor: ɵFeedbackCommentController["findAnchor"];
|
|
125
|
+
/** Closes a comment whose rating changed or whose toolbar hid. */
|
|
126
|
+
readonly sync: ɵFeedbackCommentController["sync"];
|
|
127
|
+
/** Moves focus into the field when a keyboard rating asked for it. */
|
|
128
|
+
readonly focusField: ɵFeedbackCommentController["focusField"];
|
|
129
|
+
/** Saves, closes, and returns focus to the thumb. */
|
|
130
|
+
readonly submit: ɵFeedbackCommentController["submit"];
|
|
131
|
+
/** Escape in the popover; returns whether to stop the event. */
|
|
132
|
+
readonly popoverEscape: ɵFeedbackCommentController["popoverEscape"];
|
|
133
|
+
/** Tab out of the popover, back into the page's order. */
|
|
134
|
+
readonly popoverKeyDown: ɵFeedbackCommentController["popoverKeyDown"];
|
|
135
|
+
/** Focus left the comment form. */
|
|
136
|
+
readonly popoverFocusLeave: ɵFeedbackCommentController["popoverFocusLeave"];
|
|
177
137
|
}
|
|
178
138
|
|
|
179
139
|
/**
|
|
180
|
-
* Drives the comment popover of a rated message
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
* It opens when a rating is given and whenever the pointer or keyboard focus
|
|
184
|
-
* reaches the chosen thumb, with the saved comment in the field. It closes by
|
|
185
|
-
* itself shortly after the pointer leaves the thumb and the popover, unless
|
|
186
|
-
* focus is in the field: then it stays until focus moves away, Enter, or
|
|
187
|
-
* Escape. Closing saves a changed comment; Escape, a click on a thumb, and
|
|
188
|
-
* removing the rating discard it.
|
|
140
|
+
* Drives the comment popover of a rated message with core's
|
|
141
|
+
* `ɵFeedbackCommentController`, which holds the open and close rules.
|
|
189
142
|
* @internal
|
|
190
143
|
*/
|
|
191
144
|
export function useFeedbackComment(
|
|
192
145
|
controls: Ref<MessageFeedbackControls | null>,
|
|
193
146
|
): FeedbackComment {
|
|
194
|
-
const open = ref(false);
|
|
195
|
-
const draft = ref("");
|
|
196
|
-
const focusRequest = ref(0);
|
|
197
147
|
const input = shallowRef<HTMLInputElement | null>(null);
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
const takeFocusRequest = () => {
|
|
208
|
-
const waiting = focusWaiting;
|
|
209
|
-
focusWaiting = false;
|
|
210
|
-
return waiting;
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
const cancelClose = () => {
|
|
214
|
-
if (timer === undefined) return;
|
|
215
|
-
clearTimeout(timer);
|
|
216
|
-
timer = undefined;
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
const savedComment = () => controls.value?.feedback?.comment ?? "";
|
|
220
|
-
|
|
221
|
-
const close = ({ save = true }: { save?: boolean } = {}) => {
|
|
222
|
-
cancelClose();
|
|
223
|
-
focusWaiting = false;
|
|
224
|
-
pointerOver = false;
|
|
225
|
-
if (!open.value) return;
|
|
226
|
-
const current = controls.value;
|
|
227
|
-
if (save && current?.feedback && draft.value.trim() !== savedComment())
|
|
228
|
-
current.comment(draft.value);
|
|
229
|
-
editing = false;
|
|
230
|
-
open.value = false;
|
|
231
|
-
};
|
|
232
|
-
|
|
233
|
-
const show = ({ comment, focus }: { comment: string; focus: boolean }) => {
|
|
234
|
-
cancelClose();
|
|
235
|
-
draft.value = comment;
|
|
236
|
-
if (focus) {
|
|
237
|
-
focusWaiting = true;
|
|
238
|
-
focusRequest.value++;
|
|
239
|
-
}
|
|
240
|
-
open.value = true;
|
|
241
|
-
};
|
|
242
|
-
|
|
148
|
+
const controller = new ɵFeedbackCommentController({
|
|
149
|
+
getControls: () => controls.value,
|
|
150
|
+
getInput: () => input.value,
|
|
151
|
+
});
|
|
152
|
+
const state = shallowRef(controller.getSnapshot());
|
|
153
|
+
const unsubscribe = controller.subscribe(() => {
|
|
154
|
+
state.value = controller.getSnapshot();
|
|
155
|
+
});
|
|
243
156
|
// A message that unmounts (scrolled out of a virtual list) keeps its edit.
|
|
244
157
|
onBeforeUnmount(() => {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
if (
|
|
248
|
-
open.value &&
|
|
249
|
-
current?.feedback &&
|
|
250
|
-
draft.value.trim() !== savedComment()
|
|
251
|
-
)
|
|
252
|
-
current.comment(draft.value);
|
|
158
|
+
controller.dispose();
|
|
159
|
+
unsubscribe();
|
|
253
160
|
});
|
|
254
161
|
|
|
255
162
|
return {
|
|
256
|
-
open,
|
|
257
|
-
draft
|
|
258
|
-
|
|
259
|
-
|
|
163
|
+
open: computed(() => state.value.open),
|
|
164
|
+
draft: computed({
|
|
165
|
+
get: () => state.value.draft,
|
|
166
|
+
set: controller.setDraft,
|
|
167
|
+
}),
|
|
168
|
+
focusRequest: computed(() => state.value.focusRequest),
|
|
169
|
+
takeFocusRequest: controller.takeFocusRequest,
|
|
260
170
|
input,
|
|
261
|
-
show,
|
|
262
|
-
enter:
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
},
|
|
278
|
-
setEditing: (value) => {
|
|
279
|
-
editing = value;
|
|
280
|
-
},
|
|
281
|
-
close,
|
|
282
|
-
returnFocus: (target) => {
|
|
283
|
-
returning = true;
|
|
284
|
-
try {
|
|
285
|
-
target?.focus();
|
|
286
|
-
} finally {
|
|
287
|
-
returning = false;
|
|
288
|
-
}
|
|
289
|
-
},
|
|
171
|
+
show: controller.show,
|
|
172
|
+
enter: controller.enter,
|
|
173
|
+
leave: controller.leave,
|
|
174
|
+
setEditing: controller.setEditing,
|
|
175
|
+
close: controller.close,
|
|
176
|
+
returnFocus: controller.returnFocus,
|
|
177
|
+
anchor: computed(() => state.value.anchor),
|
|
178
|
+
rate: controller.rate,
|
|
179
|
+
thumb: controller.thumb,
|
|
180
|
+
findAnchor: controller.findAnchor,
|
|
181
|
+
sync: controller.sync,
|
|
182
|
+
focusField: controller.focusField,
|
|
183
|
+
submit: controller.submit,
|
|
184
|
+
popoverEscape: controller.popoverEscape,
|
|
185
|
+
popoverKeyDown: controller.popoverKeyDown,
|
|
186
|
+
popoverFocusLeave: controller.popoverFocusLeave,
|
|
290
187
|
};
|
|
291
188
|
}
|
|
@@ -1,34 +1,16 @@
|
|
|
1
1
|
import type { ComputedRef, InjectionKey } from "vue";
|
|
2
2
|
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from "
|
|
3
|
+
ɵToolCallDisplayContextValue,
|
|
4
|
+
ɵToolCallRowStatus,
|
|
5
|
+
} from "@copilotkit/core";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Provided by the message view so each message's tool calls follow the view's
|
|
9
9
|
* `toolCallDisplay` without every layer passing it along.
|
|
10
10
|
* @internal
|
|
11
11
|
*/
|
|
12
|
-
export interface ToolCallDisplayContextValue {
|
|
13
|
-
display: CopilotChatToolCallDisplay;
|
|
14
|
-
isRunning: boolean;
|
|
15
|
-
/** Each assistant message's tool calls, laid out across the whole list. */
|
|
16
|
-
layouts: ReadonlyMap<string, ToolCallLayout>;
|
|
17
|
-
/**
|
|
18
|
-
* `"turn"` display: for each message in a reply's working phase, whether
|
|
19
|
-
* that work is showing. Messages not in here are the reply itself.
|
|
20
|
-
*/
|
|
21
|
-
workOpen: ReadonlyMap<string, boolean>;
|
|
22
|
-
/**
|
|
23
|
-
* Like `workOpen`, for the messages' text: text that ends the reply stays
|
|
24
|
-
* out of it even when its message also calls a tool.
|
|
25
|
-
*/
|
|
26
|
-
workTextOpen: ReadonlyMap<string, boolean>;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/** @internal */
|
|
30
12
|
export const ToolCallDisplayContextKey: InjectionKey<
|
|
31
|
-
ComputedRef
|
|
13
|
+
ComputedRef<ɵToolCallDisplayContextValue>
|
|
32
14
|
> = Symbol("CopilotChatToolCallDisplay");
|
|
33
15
|
|
|
34
16
|
/**
|
|
@@ -39,6 +21,8 @@ export const ToolCallDisplayContextKey: InjectionKey<
|
|
|
39
21
|
export interface ToolCallGroupContextValue {
|
|
40
22
|
appearance: "card" | "line" | "stack";
|
|
41
23
|
failedIds: ReadonlySet<string>;
|
|
24
|
+
/** Each call's row status, by call id. */
|
|
25
|
+
statusById: ReadonlyMap<string, ɵToolCallRowStatus>;
|
|
42
26
|
/** The agent may still finish the group's calls; see `isActive`. */
|
|
43
27
|
active: boolean;
|
|
44
28
|
}
|