@copilotkit/vue 2.0.0-rc.2 → 2.0.0-rc.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/PARITY.md +3 -3
- package/dist/hooks/use-copilot-action.d.ts.map +1 -1
- package/dist/hooks/use-frontend-tool.d.ts +1 -1
- package/dist/hooks/use-frontend-tool.d.ts.map +1 -1
- package/dist/hooks/zod-parameters.d.ts +14 -0
- package/dist/hooks/zod-parameters.d.ts.map +1 -0
- package/dist/index.cjs +1 -73
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +365 -16920
- package/dist/index.mjs.map +1 -1
- package/dist/use-render-activity-message-BAhbpSDh.js +16200 -0
- package/dist/use-render-activity-message-BAhbpSDh.js.map +1 -0
- package/dist/use-render-activity-message-DJ6q1qHV.cjs +114 -0
- package/dist/use-render-activity-message-DJ6q1qHV.cjs.map +1 -0
- package/dist/v2/components/A2UIMessageRenderer.d.ts +14 -0
- package/dist/v2/components/A2UIMessageRenderer.d.ts.map +1 -1
- package/dist/v2/components/A2UISurfaceActivityRenderer.vue.d.ts +10 -3
- package/dist/v2/components/A2UISurfaceActivityRenderer.vue.d.ts.map +1 -1
- package/dist/v2/components/CopilotKitInspector.vue.d.ts +5 -1
- package/dist/v2/components/CopilotKitInspector.vue.d.ts.map +1 -1
- package/dist/v2/components/InlineFeatureWarning.vue.d.ts.map +1 -1
- package/dist/v2/components/LicenseWarningBanner.vue.d.ts +2 -2
- package/dist/v2/components/LicenseWarningBanner.vue.d.ts.map +1 -1
- package/dist/v2/components/MCPAppsActivityRenderer.d.ts.map +1 -1
- package/dist/v2/components/OpenGenerativeUIRenderer.d.ts +13 -59
- package/dist/v2/components/OpenGenerativeUIRenderer.d.ts.map +1 -1
- package/dist/v2/components/a2ui/A2UIBuiltInToolCallRenderer.d.ts +0 -5
- package/dist/v2/components/a2ui/A2UIBuiltInToolCallRenderer.d.ts.map +1 -1
- package/dist/v2/components/a2ui/A2UICatalogContext.d.ts +10 -15
- package/dist/v2/components/a2ui/A2UICatalogContext.d.ts.map +1 -1
- package/dist/v2/components/a2ui/A2UIRecoveryStates.d.ts +14 -130
- package/dist/v2/components/a2ui/A2UIRecoveryStates.d.ts.map +1 -1
- package/dist/v2/components/a2ui/catalog.d.ts.map +1 -1
- package/dist/v2/components/a2ui/utils.d.ts +3 -15
- package/dist/v2/components/a2ui/utils.d.ts.map +1 -1
- package/dist/v2/components/a2ui.d.ts +9 -8
- package/dist/v2/components/a2ui.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChat.vue.d.ts +2 -2
- package/dist/v2/components/chat/CopilotChat.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatAssistantMessage.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatAttachmentQueue.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatAttachmentRenderer.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatAudioRecorder.vue.d.ts +4 -8
- package/dist/v2/components/chat/CopilotChatAudioRecorder.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatFeedbackCommentPopover.vue.d.ts +1 -1
- package/dist/v2/components/chat/CopilotChatFeedbackCommentPopover.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatInput.vue.d.ts +6 -270
- package/dist/v2/components/chat/CopilotChatInput.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatInspectorButton.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatLightbox.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatMessageView.vue.d.ts +1 -1
- package/dist/v2/components/chat/CopilotChatMessageView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatReasoningMessage.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatToolCallGroup.vue.d.ts +1 -1
- package/dist/v2/components/chat/CopilotChatToolCallGroup.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatToolCallItem.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatToolCallsView.vue.d.ts +1 -1
- package/dist/v2/components/chat/CopilotChatToolCallsView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatUserMessage.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatView.vue.d.ts +3 -3
- package/dist/v2/components/chat/CopilotChatView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatWorkSummary.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotModalHeader.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotPopup.vue.d.ts +8 -3
- package/dist/v2/components/chat/CopilotPopup.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotPopupView.vue.d.ts +5 -3
- package/dist/v2/components/chat/CopilotPopupView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotPopupViewInternal.vue.d.ts +5 -3
- package/dist/v2/components/chat/CopilotPopupViewInternal.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotSidebar.vue.d.ts +8 -3
- package/dist/v2/components/chat/CopilotSidebar.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotSidebarView.vue.d.ts +6 -4
- package/dist/v2/components/chat/CopilotSidebarView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotSidebarViewInternal.vue.d.ts +6 -4
- package/dist/v2/components/chat/CopilotSidebarViewInternal.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotThreadsDrawer.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/StreamingMarkdownDefault.vue.d.ts +1 -0
- package/dist/v2/components/chat/StreamingMarkdownDefault.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/audioRecorder.d.ts +3 -4
- package/dist/v2/components/chat/audioRecorder.d.ts.map +1 -1
- package/dist/v2/components/chat/copilotChatToolCallItemRender.d.ts +3 -3
- package/dist/v2/components/chat/copilotChatToolCallItemRender.d.ts.map +1 -1
- package/dist/v2/components/chat/forwarded-slots.d.ts +12 -0
- package/dist/v2/components/chat/forwarded-slots.d.ts.map +1 -0
- package/dist/v2/components/chat/index.d.ts +34 -31
- package/dist/v2/components/chat/index.d.ts.map +1 -1
- package/dist/v2/components/chat/inspector-shortcuts.d.ts +2 -1
- package/dist/v2/components/chat/inspector-shortcuts.d.ts.map +1 -1
- package/dist/v2/components/chat/message-feedback.d.ts +18 -49
- package/dist/v2/components/chat/message-feedback.d.ts.map +1 -1
- package/dist/v2/components/chat/tool-call-display-context.d.ts +4 -19
- package/dist/v2/components/chat/tool-call-display-context.d.ts.map +1 -1
- package/dist/v2/components/chat/tool-call-group-parts.d.ts +7 -20
- package/dist/v2/components/chat/tool-call-group-parts.d.ts.map +1 -1
- package/dist/v2/components/chat/turn-work.d.ts +0 -2
- package/dist/v2/components/chat/turn-work.d.ts.map +1 -1
- package/dist/v2/components/chat/types.d.ts +9 -4
- package/dist/v2/components/chat/types.d.ts.map +1 -1
- package/dist/v2/components/chat/use-chat-labels.d.ts +8 -0
- package/dist/v2/components/chat/use-chat-labels.d.ts.map +1 -0
- package/dist/v2/components/chat/use-copy-feedback.d.ts +11 -0
- package/dist/v2/components/chat/use-copy-feedback.d.ts.map +1 -0
- package/dist/v2/components/chat/use-lightbox.d.ts.map +1 -1
- package/dist/v2/components/icons/index.d.ts +968 -1
- package/dist/v2/components/icons/index.d.ts.map +1 -1
- package/dist/v2/components/ui/CopilotDropdownMenuContent.vue.d.ts +1 -1
- package/dist/v2/components/ui/CopilotDropdownMenuContent.vue.d.ts.map +1 -1
- package/dist/v2/hooks/use-agent-context.d.ts +2 -3
- package/dist/v2/hooks/use-agent-context.d.ts.map +1 -1
- package/dist/v2/hooks/use-agent.d.ts +4 -1
- package/dist/v2/hooks/use-agent.d.ts.map +1 -1
- package/dist/v2/hooks/use-attachments.d.ts +7 -0
- package/dist/v2/hooks/use-attachments.d.ts.map +1 -1
- package/dist/v2/hooks/use-capabilities.d.ts.map +1 -1
- package/dist/v2/hooks/use-component.d.ts +1 -0
- package/dist/v2/hooks/use-component.d.ts.map +1 -1
- package/dist/v2/hooks/use-configure-suggestions.d.ts +4 -9
- package/dist/v2/hooks/use-configure-suggestions.d.ts.map +1 -1
- package/dist/v2/hooks/use-default-render-tool.d.ts.map +1 -1
- package/dist/v2/hooks/use-frontend-tool.d.ts +5 -0
- package/dist/v2/hooks/use-frontend-tool.d.ts.map +1 -1
- package/dist/v2/hooks/use-human-in-the-loop.d.ts +2 -1
- package/dist/v2/hooks/use-human-in-the-loop.d.ts.map +1 -1
- package/dist/v2/hooks/use-interrupt.d.ts +0 -1
- package/dist/v2/hooks/use-interrupt.d.ts.map +1 -1
- package/dist/v2/hooks/use-keyboard-height.d.ts +1 -1
- package/dist/v2/hooks/use-keyboard-height.d.ts.map +1 -1
- package/dist/v2/hooks/use-pin-to-send.d.ts +4 -12
- package/dist/v2/hooks/use-pin-to-send.d.ts.map +1 -1
- package/dist/v2/hooks/use-render-activity-message.d.ts +13 -9
- package/dist/v2/hooks/use-render-activity-message.d.ts.map +1 -1
- package/dist/v2/hooks/use-render-custom-messages.d.ts +5 -7
- package/dist/v2/hooks/use-render-custom-messages.d.ts.map +1 -1
- package/dist/v2/hooks/use-suggestions.d.ts.map +1 -1
- package/dist/v2/hooks/use-threads.d.ts +0 -8
- package/dist/v2/hooks/use-threads.d.ts.map +1 -1
- package/dist/v2/index.cjs +1 -1
- package/dist/v2/index.mjs +197 -200
- package/dist/v2/index.mjs.map +1 -1
- package/dist/v2/lib/processPartialHtml.d.ts +1 -2
- package/dist/v2/lib/processPartialHtml.d.ts.map +1 -1
- package/dist/v2/lib/shallow-stable.d.ts.map +1 -1
- package/dist/v2/lib/vue-core.d.ts +12 -12
- package/dist/v2/lib/vue-core.d.ts.map +1 -1
- package/dist/v2/providers/CopilotChatConfigurationProvider.vue.d.ts.map +1 -1
- package/dist/v2/providers/CopilotKitProvider.types.d.ts +9 -129
- package/dist/v2/providers/CopilotKitProvider.types.d.ts.map +1 -1
- package/dist/v2/providers/CopilotKitProvider.vue.d.ts +9 -10
- package/dist/v2/providers/CopilotKitProvider.vue.d.ts.map +1 -1
- package/dist/v2/providers/chat-configuration-store-key.d.ts +8 -0
- package/dist/v2/providers/chat-configuration-store-key.d.ts.map +1 -0
- package/dist/v2/providers/markdown-renderer.d.ts +4 -2
- package/dist/v2/providers/markdown-renderer.d.ts.map +1 -1
- package/dist/v2/providers/types.d.ts +3 -46
- package/dist/v2/providers/types.d.ts.map +1 -1
- package/dist/v2/providers/use-inspector-thread-override.d.ts +5 -0
- package/dist/v2/providers/use-inspector-thread-override.d.ts.map +1 -1
- package/dist/v2/types/human-in-the-loop.d.ts +8 -29
- package/dist/v2/types/human-in-the-loop.d.ts.map +1 -1
- package/dist/v2/types/interrupt.d.ts +1 -22
- package/dist/v2/types/interrupt.d.ts.map +1 -1
- package/dist/v2/types/vue-activity-message-renderer.d.ts +16 -15
- package/dist/v2/types/vue-activity-message-renderer.d.ts.map +1 -1
- package/dist/v2/types/vue-custom-message-renderer.d.ts +7 -16
- package/dist/v2/types/vue-custom-message-renderer.d.ts.map +1 -1
- package/dist/v2/types/vue-tool-call-renderer.d.ts +16 -35
- package/dist/v2/types/vue-tool-call-renderer.d.ts.map +1 -1
- package/package.json +10 -11
- package/src/__tests__/build-entries.test.ts +27 -0
- package/src/hooks/__tests__/zod-parameters.test.ts +520 -0
- package/src/hooks/use-copilot-action.ts +2 -1
- package/src/hooks/use-frontend-tool.ts +3 -6
- package/src/hooks/zod-parameters.ts +162 -0
- package/src/v2/__tests__/exports.test.ts +10 -0
- package/src/v2/__tests__/mocks/web-inspector.ts +6 -0
- package/src/v2/__tests__/utils/test-helpers.ts +34 -4
- package/src/v2/components/A2UIMessageRenderer.ts +98 -68
- package/src/v2/components/A2UISurfaceActivityRenderer.vue +68 -103
- package/src/v2/components/CopilotKitInspector.vue +104 -51
- package/src/v2/components/InlineFeatureWarning.vue +20 -21
- package/src/v2/components/LicenseWarningBanner.vue +27 -135
- package/src/v2/components/MCPAppsActivityRenderer.ts +75 -201
- package/src/v2/components/OpenGenerativeUIRenderer.ts +122 -446
- package/src/v2/components/__tests__/A2UIMessageRenderer.test.ts +171 -8
- package/src/v2/components/__tests__/CopilotKitInspector.test.ts +42 -0
- package/src/v2/components/__tests__/LicenseWarningBanner.test.ts +60 -0
- package/src/v2/components/__tests__/OpenGenerativeUIRenderer.test.ts +64 -8
- package/src/v2/components/__tests__/OpenGenerativeUIToolRenderer.test.ts +38 -0
- package/src/v2/components/a2ui/A2UIBuiltInToolCallRenderer.ts +2 -7
- package/src/v2/components/a2ui/A2UICatalogContext.ts +27 -185
- package/src/v2/components/a2ui/A2UIRecoveryStates.ts +127 -327
- package/src/v2/components/a2ui/catalog.ts +3 -3
- package/src/v2/components/a2ui/utils.ts +13 -65
- package/src/v2/components/a2ui.ts +15 -22
- package/src/v2/components/chat/CopilotChat.vue +147 -356
- package/src/v2/components/chat/CopilotChatAssistantMessage.vue +19 -43
- package/src/v2/components/chat/CopilotChatAttachmentQueue.vue +36 -55
- package/src/v2/components/chat/CopilotChatAttachmentRenderer.vue +14 -6
- package/src/v2/components/chat/CopilotChatAudioRecorder.vue +19 -246
- package/src/v2/components/chat/CopilotChatFeedbackCommentPopover.vue +2 -2
- package/src/v2/components/chat/CopilotChatInput.vue +108 -436
- package/src/v2/components/chat/CopilotChatInspectorButton.vue +45 -108
- package/src/v2/components/chat/CopilotChatLightbox.vue +10 -31
- package/src/v2/components/chat/CopilotChatMessageView.vue +82 -210
- package/src/v2/components/chat/CopilotChatReasoningMessage.vue +7 -15
- package/src/v2/components/chat/CopilotChatToolCallGroup.vue +63 -71
- package/src/v2/components/chat/CopilotChatToolCallItem.vue +8 -6
- package/src/v2/components/chat/CopilotChatToolCallsView.vue +31 -32
- package/src/v2/components/chat/CopilotChatUserMessage.vue +24 -112
- package/src/v2/components/chat/CopilotChatView.vue +33 -28
- package/src/v2/components/chat/CopilotChatWorkSummary.vue +26 -36
- package/src/v2/components/chat/CopilotModalHeader.vue +11 -23
- package/src/v2/components/chat/CopilotPopup.vue +23 -25
- package/src/v2/components/chat/CopilotPopupView.vue +10 -39
- package/src/v2/components/chat/CopilotPopupViewInternal.vue +35 -131
- package/src/v2/components/chat/CopilotSidebar.vue +23 -25
- package/src/v2/components/chat/CopilotSidebarView.vue +10 -39
- package/src/v2/components/chat/CopilotSidebarViewInternal.vue +38 -59
- package/src/v2/components/chat/CopilotThreadsDrawer.vue +37 -102
- package/src/v2/components/chat/StreamingMarkdownDefault.vue +15 -28
- package/src/v2/components/chat/__tests__/CopilotChat.labels.test.ts +19 -4
- package/src/v2/components/chat/__tests__/CopilotChat.test.ts +12 -10
- package/src/v2/components/chat/__tests__/CopilotChatActivityRendering.e2e.test.ts +26 -9
- package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.learningFeedback.test.ts +5 -5
- package/src/v2/components/chat/__tests__/CopilotChatAttachmentQueue.test.ts +28 -0
- package/src/v2/components/chat/__tests__/CopilotChatInput.test.ts +89 -1
- package/src/v2/components/chat/__tests__/CopilotChatMessageView.test.ts +247 -403
- package/src/v2/components/chat/__tests__/CopilotChatMessageView.toolCallDisplay.test.ts +1 -99
- package/src/v2/components/chat/__tests__/CopilotPopup.test.ts +90 -1
- package/src/v2/components/chat/__tests__/CopilotPopupView.test.ts +19 -0
- package/src/v2/components/chat/__tests__/CopilotSidebar.test.ts +90 -1
- package/src/v2/components/chat/__tests__/CopilotSidebarView.position.test.ts +32 -8
- package/src/v2/components/chat/__tests__/CopilotSidebarView.test.ts +2 -1
- package/src/v2/components/chat/__tests__/StreamingMarkdownDefault.test.ts +54 -0
- package/src/v2/components/chat/audioRecorder.ts +4 -7
- package/src/v2/components/chat/copilotChatToolCallItemRender.ts +24 -89
- package/src/v2/components/chat/forwarded-slots.ts +17 -0
- package/src/v2/components/chat/index.ts +0 -1
- package/src/v2/components/chat/inspector-shortcuts.ts +10 -16
- package/src/v2/components/chat/message-feedback.ts +62 -197
- package/src/v2/components/chat/tool-call-display-context.ts +6 -22
- package/src/v2/components/chat/tool-call-group-parts.ts +47 -108
- package/src/v2/components/chat/turn-work.ts +0 -9
- package/src/v2/components/chat/types.ts +12 -4
- package/src/v2/components/chat/use-chat-labels.ts +16 -0
- package/src/v2/components/chat/use-copy-feedback.ts +21 -0
- package/src/v2/components/chat/use-lightbox.ts +15 -33
- package/src/v2/components/icons/__tests__/icons.test.ts +72 -68
- package/src/v2/components/icons/index.ts +109 -27
- package/src/v2/hooks/__tests__/use-agent-error-state.test.ts +5 -3
- package/src/v2/hooks/__tests__/use-agent-stability.test.ts +25 -4
- package/src/v2/hooks/__tests__/use-agent-throttle.test.ts +5 -1
- package/src/v2/hooks/__tests__/use-agent.test.ts +6 -3
- package/src/v2/hooks/__tests__/use-component.test.ts +21 -0
- package/src/v2/hooks/__tests__/use-configure-suggestions.test.ts +30 -1
- package/src/v2/hooks/__tests__/use-default-render-tool.test.ts +10 -10
- package/src/v2/hooks/__tests__/use-frontend-tool.e2e.test.ts +66 -1
- package/src/v2/hooks/__tests__/use-human-in-the-loop.e2e.test.ts +6 -1
- package/src/v2/hooks/__tests__/use-human-in-the-loop.test.ts +187 -12
- package/src/v2/hooks/__tests__/use-interrupt.test.ts +97 -0
- package/src/v2/hooks/__tests__/use-render-activity-message.test.ts +106 -0
- package/src/v2/hooks/__tests__/use-render-tool.test.ts +3 -6
- package/src/v2/hooks/__tests__/use-threads.test.ts +48 -6
- package/src/v2/hooks/__tests__/zod-regression.test.ts +5 -4
- package/src/v2/hooks/use-agent-context.ts +4 -10
- package/src/v2/hooks/use-agent.ts +86 -290
- package/src/v2/hooks/use-attachments.ts +48 -168
- package/src/v2/hooks/use-capabilities.ts +2 -7
- package/src/v2/hooks/use-component.ts +7 -4
- package/src/v2/hooks/use-configure-suggestions.ts +28 -218
- package/src/v2/hooks/use-default-render-tool.ts +34 -94
- package/src/v2/hooks/use-frontend-tool.ts +10 -10
- package/src/v2/hooks/use-human-in-the-loop.ts +11 -80
- package/src/v2/hooks/use-interrupt.ts +29 -308
- package/src/v2/hooks/use-keyboard-height.ts +17 -40
- package/src/v2/hooks/use-pin-to-send.ts +15 -99
- package/src/v2/hooks/use-render-activity-message.ts +31 -55
- package/src/v2/hooks/use-render-custom-messages.ts +24 -88
- package/src/v2/hooks/use-suggestions.ts +9 -33
- package/src/v2/hooks/use-threads.ts +43 -273
- package/src/v2/lib/__tests__/shallow-stable.test.ts +54 -0
- package/src/v2/lib/__tests__/vue-core-renderers.test.ts +42 -0
- package/src/v2/lib/processPartialHtml.ts +6 -21
- package/src/v2/lib/shallow-stable.ts +2 -16
- package/src/v2/lib/vue-core.ts +69 -78
- package/src/v2/providers/CopilotChatConfigurationProvider.vue +48 -186
- package/src/v2/providers/CopilotKitProvider.types.ts +12 -132
- package/src/v2/providers/CopilotKitProvider.vue +237 -510
- package/src/v2/providers/__tests__/CopilotChatConfigurationProvider.test.ts +22 -2
- package/src/v2/providers/__tests__/CopilotKitProvider.a2ui.test.ts +20 -2
- package/src/v2/providers/__tests__/CopilotKitProvider.config.test.ts +124 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.headersAtSendTime.test.ts +3 -3
- package/src/v2/providers/__tests__/CopilotKitProvider.learning.test.ts +3 -1
- package/src/v2/providers/__tests__/CopilotKitProvider.sandboxFunctions.test.ts +4 -1
- package/src/v2/providers/__tests__/CopilotKitProvider.test.ts +53 -26
- package/src/v2/providers/chat-configuration-store-key.ts +9 -0
- package/src/v2/providers/markdown-renderer.ts +8 -2
- package/src/v2/providers/types.ts +3 -49
- package/src/v2/providers/use-inspector-thread-override.ts +22 -80
- package/src/v2/types/__tests__/defineToolCallRenderer.test.ts +28 -33
- package/src/v2/types/defineToolCallRenderer.ts +5 -4
- package/src/v2/types/human-in-the-loop.ts +8 -32
- package/src/v2/types/interrupt.ts +7 -31
- package/src/v2/types/vue-activity-message-renderer.ts +24 -15
- package/src/v2/types/vue-custom-message-renderer.ts +12 -16
- package/src/v2/types/vue-tool-call-renderer.ts +23 -38
- package/tsconfig.json +0 -1
- package/vite.config.ts +8 -5
- package/vitest.config.ts +12 -7
- package/dist/v2/components/chat/BasicMarkdown.vue.d.ts +0 -9
- package/dist/v2/components/chat/BasicMarkdown.vue.d.ts.map +0 -1
- package/dist/v2/components/chat/normalize-auto-scroll.d.ts +0 -3
- package/dist/v2/components/chat/normalize-auto-scroll.d.ts.map +0 -1
- package/dist/v2/components/chat/tool-call-layout.d.ts +0 -115
- package/dist/v2/components/chat/tool-call-layout.d.ts.map +0 -1
- package/dist/v2/lib/is-mobile-viewport.d.ts +0 -15
- package/dist/v2/lib/is-mobile-viewport.d.ts.map +0 -1
- package/dist/v2/lib/message-feedback.d.ts +0 -33
- package/dist/v2/lib/message-feedback.d.ts.map +0 -1
- package/dist/v2/lib/transcription-client.d.ts +0 -19
- package/dist/v2/lib/transcription-client.d.ts.map +0 -1
- package/src/v2/components/__tests__/A2UICatalogContext.test.ts +0 -63
- package/src/v2/components/a2ui/__tests__/A2UIRecoveryStates.test.ts +0 -175
- package/src/v2/components/chat/BasicMarkdown.vue +0 -160
- package/src/v2/components/chat/__tests__/BasicMarkdown.test.ts +0 -69
- package/src/v2/components/chat/__tests__/normalize-auto-scroll.test.ts +0 -39
- package/src/v2/components/chat/normalize-auto-scroll.ts +0 -17
- package/src/v2/components/chat/tool-call-layout.ts +0 -304
- package/src/v2/lib/__tests__/is-mobile-viewport.test.ts +0 -48
- package/src/v2/lib/__tests__/message-feedback.test.ts +0 -152
- package/src/v2/lib/__tests__/processPartialHtml.test.ts +0 -84
- package/src/v2/lib/__tests__/transcription-client.test.ts +0 -67
- package/src/v2/lib/is-mobile-viewport.ts +0 -23
- package/src/v2/lib/message-feedback.ts +0 -120
- package/src/v2/lib/transcription-client.ts +0 -151
|
@@ -11,12 +11,7 @@ import type { VueToolCallRenderer } from "../../../types";
|
|
|
11
11
|
import { useDefaultRenderTool } from "../../../hooks/use-default-render-tool";
|
|
12
12
|
import CopilotChatMessageView from "../CopilotChatMessageView.vue";
|
|
13
13
|
import CopilotChatToolCallsView from "../CopilotChatToolCallsView.vue";
|
|
14
|
-
import {
|
|
15
|
-
getToolCallLayouts,
|
|
16
|
-
getToolCallRendererNames,
|
|
17
|
-
getTurnWork,
|
|
18
|
-
} from "../tool-call-layout";
|
|
19
|
-
import type { CopilotChatToolCallDisplay } from "../tool-call-layout";
|
|
14
|
+
import type { CopilotChatToolCallDisplay } from "@copilotkit/core";
|
|
20
15
|
|
|
21
16
|
// Ported from React's CopilotChatMessageView.toolCallDisplay tests.
|
|
22
17
|
|
|
@@ -55,13 +50,6 @@ const weather = defineToolCallRenderer({
|
|
|
55
50
|
render: () => h("div", { "data-testid": "weather-card" }, "Weather"),
|
|
56
51
|
});
|
|
57
52
|
|
|
58
|
-
const names = {
|
|
59
|
-
named: new Set(["weather"]),
|
|
60
|
-
groupedNames: new Set<string>(),
|
|
61
|
-
wildcard: true,
|
|
62
|
-
wildcardGroups: true,
|
|
63
|
-
};
|
|
64
|
-
|
|
65
53
|
interface ViewState {
|
|
66
54
|
messages: Ref<Message[]>;
|
|
67
55
|
isRunning: Ref<boolean>;
|
|
@@ -118,92 +106,6 @@ function renderView(
|
|
|
118
106
|
const firstButton = (element: HTMLElement) =>
|
|
119
107
|
within(element).getAllByRole("button")[0]!;
|
|
120
108
|
|
|
121
|
-
describe("getToolCallLayouts", () => {
|
|
122
|
-
it("groups calls made in a row across messages, owned by the first", () => {
|
|
123
|
-
const messages = [
|
|
124
|
-
question,
|
|
125
|
-
callMessage("a"),
|
|
126
|
-
result("a"),
|
|
127
|
-
callMessage("b"),
|
|
128
|
-
result("b"),
|
|
129
|
-
];
|
|
130
|
-
const layouts = getToolCallLayouts(messages, messages, names);
|
|
131
|
-
|
|
132
|
-
const first = layouts.get("m-a")!.segments;
|
|
133
|
-
expect(first).toHaveLength(1);
|
|
134
|
-
expect(first[0]).toMatchObject({ kind: "group", trailing: true });
|
|
135
|
-
expect(
|
|
136
|
-
first[0]!.kind === "group" && first[0]!.calls.map((c) => c.toolCall.id),
|
|
137
|
-
).toEqual(["a", "b"]);
|
|
138
|
-
expect(layouts.get("m-b")!.segments).toEqual([]);
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
it("starts a new group after text or a call with its own renderer", () => {
|
|
142
|
-
const messages = [
|
|
143
|
-
question,
|
|
144
|
-
callMessage("a"),
|
|
145
|
-
say("t", "Checking more."),
|
|
146
|
-
callMessage("b"),
|
|
147
|
-
callMessage("w", "weather"),
|
|
148
|
-
callMessage("c"),
|
|
149
|
-
];
|
|
150
|
-
const layouts = getToolCallLayouts(messages, messages, names);
|
|
151
|
-
const kinds = ["m-a", "m-b", "m-w", "m-c"].map((id) =>
|
|
152
|
-
layouts.get(id)!.segments.map((segment) => segment.kind),
|
|
153
|
-
);
|
|
154
|
-
expect(kinds).toEqual([["group"], ["group"], ["call"], ["group"]]);
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
it("changes its signature when a result arrives for a call it holds", () => {
|
|
158
|
-
const before = [question, callMessage("a"), callMessage("b")];
|
|
159
|
-
const after = [...before, result("b")];
|
|
160
|
-
const signature = (messages: Message[]) =>
|
|
161
|
-
getToolCallLayouts(messages, messages, names).get("m-a")!.signature;
|
|
162
|
-
expect(signature(after)).not.toBe(signature(before));
|
|
163
|
-
});
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
describe("getTurnWork", () => {
|
|
167
|
-
it("treats everything up to the last call as work, and the rest as the reply", () => {
|
|
168
|
-
const messages = [
|
|
169
|
-
question,
|
|
170
|
-
say("t1", "Looking."),
|
|
171
|
-
callMessage("a"),
|
|
172
|
-
result("a"),
|
|
173
|
-
say("t2", "The answer."),
|
|
174
|
-
];
|
|
175
|
-
const layouts = getToolCallLayouts(messages, messages, names);
|
|
176
|
-
const turn = getTurnWork(messages, layouts).get("u1")!;
|
|
177
|
-
expect([...turn.workMessageIds]).toEqual(["t1", "m-a"]);
|
|
178
|
-
expect(turn.firstMessageId).toBe("t1");
|
|
179
|
-
expect(turn.calls).toHaveLength(1);
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
describe("getToolCallRendererNames", () => {
|
|
184
|
-
const renderers = [
|
|
185
|
-
{ name: "*", group: true },
|
|
186
|
-
{ name: "search", group: true },
|
|
187
|
-
];
|
|
188
|
-
|
|
189
|
-
it("reads the renderers' group opt-in", () => {
|
|
190
|
-
const result = getToolCallRendererNames(renderers);
|
|
191
|
-
expect([...result.groupedNames]).toEqual(["search"]);
|
|
192
|
-
expect(result.wildcardGroups).toBe(true);
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
it("never groups calls a tool-call slot draws", () => {
|
|
196
|
-
const named = getToolCallRendererNames(renderers, ["tool-call-search"]);
|
|
197
|
-
expect(named.named.has("search")).toBe(true);
|
|
198
|
-
expect(named.groupedNames.has("search")).toBe(false);
|
|
199
|
-
expect(named.wildcardGroups).toBe(true);
|
|
200
|
-
|
|
201
|
-
const wildcard = getToolCallRendererNames(renderers, ["tool-call"]);
|
|
202
|
-
expect(wildcard.groupedNames.size).toBe(0);
|
|
203
|
-
expect(wildcard.wildcardGroups).toBe(false);
|
|
204
|
-
});
|
|
205
|
-
});
|
|
206
|
-
|
|
207
109
|
describe("CopilotChatMessageView toolCallDisplay", () => {
|
|
208
110
|
const burst = [
|
|
209
111
|
question,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { h } from "vue";
|
|
2
|
+
import { h, nextTick } from "vue";
|
|
3
3
|
import { mount } from "@vue/test-utils";
|
|
4
4
|
import CopilotKitProvider from "../../../providers/CopilotKitProvider.vue";
|
|
5
5
|
import { StateCapturingAgent } from "../../../__tests__/utils/agents";
|
|
6
|
+
import { mountWithProvider } from "../../../__tests__/utils/mount";
|
|
6
7
|
import CopilotPopup from "../CopilotPopup.vue";
|
|
7
8
|
|
|
8
9
|
function mountPopup(
|
|
@@ -55,4 +56,92 @@ describe("CopilotPopup", () => {
|
|
|
55
56
|
).toBe(true);
|
|
56
57
|
expect(wrapper.find("[data-copilot-popup]").exists()).toBe(false);
|
|
57
58
|
});
|
|
59
|
+
|
|
60
|
+
it("forwards the scroll-view slot to the chat view", () => {
|
|
61
|
+
const wrapper = mountPopup(
|
|
62
|
+
{ welcomeScreen: false },
|
|
63
|
+
{
|
|
64
|
+
"scroll-view": ({ messages }: { messages: unknown[] }) =>
|
|
65
|
+
h(
|
|
66
|
+
"div",
|
|
67
|
+
{ "data-testid": "custom-popup-scroll-view" },
|
|
68
|
+
String(messages.length),
|
|
69
|
+
),
|
|
70
|
+
},
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
expect(wrapper.get("[data-testid='custom-popup-scroll-view']").text()).toBe(
|
|
74
|
+
"0",
|
|
75
|
+
);
|
|
76
|
+
expect(
|
|
77
|
+
wrapper.find("[data-testid='copilot-chat-view-scroll']").exists(),
|
|
78
|
+
).toBe(false);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it("forwards the interrupt slot to the chat view", async () => {
|
|
82
|
+
const { wrapper, getCore } = mountWithProvider(
|
|
83
|
+
() =>
|
|
84
|
+
h(
|
|
85
|
+
CopilotPopup,
|
|
86
|
+
{ welcomeScreen: false },
|
|
87
|
+
{
|
|
88
|
+
interrupt: ({ event }: { event: { value: string } }) =>
|
|
89
|
+
h("div", { "data-testid": "popup-interrupt" }, event.value),
|
|
90
|
+
},
|
|
91
|
+
),
|
|
92
|
+
{
|
|
93
|
+
runtimeUrl: undefined,
|
|
94
|
+
agents__unsafe_dev_only: { default: new StateCapturingAgent() },
|
|
95
|
+
},
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
getCore().setInterruptState({
|
|
99
|
+
event: { name: "on_interrupt", value: "slot-forwarded" },
|
|
100
|
+
result: null,
|
|
101
|
+
resolve: () => undefined,
|
|
102
|
+
});
|
|
103
|
+
await nextTick();
|
|
104
|
+
|
|
105
|
+
expect(wrapper.get("[data-testid='popup-interrupt']").text()).toBe(
|
|
106
|
+
"slot-forwarded",
|
|
107
|
+
);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it("forwards the assistant-message slot to the message view", () => {
|
|
111
|
+
const agent = new StateCapturingAgent();
|
|
112
|
+
agent.setMessages([
|
|
113
|
+
{ id: "assistant-1", role: "assistant", content: "Hello from the agent" },
|
|
114
|
+
]);
|
|
115
|
+
|
|
116
|
+
const { wrapper } = mountWithProvider(
|
|
117
|
+
() =>
|
|
118
|
+
h(
|
|
119
|
+
CopilotPopup,
|
|
120
|
+
{ welcomeScreen: false },
|
|
121
|
+
{
|
|
122
|
+
"assistant-message": ({
|
|
123
|
+
message,
|
|
124
|
+
}: {
|
|
125
|
+
message: { content: string };
|
|
126
|
+
}) =>
|
|
127
|
+
h(
|
|
128
|
+
"div",
|
|
129
|
+
{ "data-testid": "popup-assistant-message" },
|
|
130
|
+
message.content,
|
|
131
|
+
),
|
|
132
|
+
},
|
|
133
|
+
),
|
|
134
|
+
{
|
|
135
|
+
runtimeUrl: undefined,
|
|
136
|
+
agents__unsafe_dev_only: { default: agent },
|
|
137
|
+
},
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
expect(wrapper.get("[data-testid='popup-assistant-message']").text()).toBe(
|
|
141
|
+
"Hello from the agent",
|
|
142
|
+
);
|
|
143
|
+
expect(
|
|
144
|
+
wrapper.find("[data-testid='copilot-assistant-message']").exists(),
|
|
145
|
+
).toBe(false);
|
|
146
|
+
});
|
|
58
147
|
});
|
|
@@ -115,6 +115,25 @@ describe("CopilotPopupView", () => {
|
|
|
115
115
|
expect(reopened.find("[data-copilot-popup]").exists()).toBe(false);
|
|
116
116
|
});
|
|
117
117
|
|
|
118
|
+
it("stays open for a pointer down in a chat popover outside the panel", async () => {
|
|
119
|
+
const wrapper = mountPopupView({ clickOutsideToClose: true });
|
|
120
|
+
// Popovers, such as a reply rating's comment, render in a portal.
|
|
121
|
+
const popover = document.createElement("div");
|
|
122
|
+
popover.setAttribute("data-copilotkit-popover", "");
|
|
123
|
+
const field = document.createElement("textarea");
|
|
124
|
+
popover.append(field);
|
|
125
|
+
document.body.append(popover);
|
|
126
|
+
|
|
127
|
+
field.dispatchEvent(new Event("pointerdown", { bubbles: true }));
|
|
128
|
+
await nextTick();
|
|
129
|
+
vi.advanceTimersByTime(200);
|
|
130
|
+
await nextTick();
|
|
131
|
+
|
|
132
|
+
expect(wrapper.find("[data-copilot-popup]").exists()).toBe(true);
|
|
133
|
+
popover.remove();
|
|
134
|
+
wrapper.unmount();
|
|
135
|
+
});
|
|
136
|
+
|
|
118
137
|
it("ignores outside-close detection when the toggle button is clicked and supports custom slots", async () => {
|
|
119
138
|
const wrapper = mountPopupView(
|
|
120
139
|
{
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { h } from "vue";
|
|
2
|
+
import { h, nextTick } from "vue";
|
|
3
3
|
import { mount } from "@vue/test-utils";
|
|
4
4
|
import CopilotKitProvider from "../../../providers/CopilotKitProvider.vue";
|
|
5
5
|
import { StateCapturingAgent } from "../../../__tests__/utils/agents";
|
|
6
|
+
import { mountWithProvider } from "../../../__tests__/utils/mount";
|
|
6
7
|
import CopilotSidebar from "../CopilotSidebar.vue";
|
|
7
8
|
|
|
8
9
|
function mountSidebar(
|
|
@@ -55,4 +56,92 @@ describe("CopilotSidebar", () => {
|
|
|
55
56
|
).toBe(true);
|
|
56
57
|
expect(wrapper.find("[data-copilot-sidebar]").exists()).toBe(false);
|
|
57
58
|
});
|
|
59
|
+
|
|
60
|
+
it("forwards the scroll-view slot to the chat view", () => {
|
|
61
|
+
const wrapper = mountSidebar(
|
|
62
|
+
{ welcomeScreen: false },
|
|
63
|
+
{
|
|
64
|
+
"scroll-view": ({ messages }: { messages: unknown[] }) =>
|
|
65
|
+
h(
|
|
66
|
+
"div",
|
|
67
|
+
{ "data-testid": "custom-sidebar-scroll-view" },
|
|
68
|
+
String(messages.length),
|
|
69
|
+
),
|
|
70
|
+
},
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
expect(
|
|
74
|
+
wrapper.get("[data-testid='custom-sidebar-scroll-view']").text(),
|
|
75
|
+
).toBe("0");
|
|
76
|
+
expect(
|
|
77
|
+
wrapper.find("[data-testid='copilot-chat-view-scroll']").exists(),
|
|
78
|
+
).toBe(false);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it("forwards the interrupt slot to the chat view", async () => {
|
|
82
|
+
const { wrapper, getCore } = mountWithProvider(
|
|
83
|
+
() =>
|
|
84
|
+
h(
|
|
85
|
+
CopilotSidebar,
|
|
86
|
+
{ welcomeScreen: false },
|
|
87
|
+
{
|
|
88
|
+
interrupt: ({ event }: { event: { value: string } }) =>
|
|
89
|
+
h("div", { "data-testid": "sidebar-interrupt" }, event.value),
|
|
90
|
+
},
|
|
91
|
+
),
|
|
92
|
+
{
|
|
93
|
+
runtimeUrl: undefined,
|
|
94
|
+
agents__unsafe_dev_only: { default: new StateCapturingAgent() },
|
|
95
|
+
},
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
getCore().setInterruptState({
|
|
99
|
+
event: { name: "on_interrupt", value: "slot-forwarded" },
|
|
100
|
+
result: null,
|
|
101
|
+
resolve: () => undefined,
|
|
102
|
+
});
|
|
103
|
+
await nextTick();
|
|
104
|
+
|
|
105
|
+
expect(wrapper.get("[data-testid='sidebar-interrupt']").text()).toBe(
|
|
106
|
+
"slot-forwarded",
|
|
107
|
+
);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it("forwards the assistant-message slot to the message view", () => {
|
|
111
|
+
const agent = new StateCapturingAgent();
|
|
112
|
+
agent.setMessages([
|
|
113
|
+
{ id: "assistant-1", role: "assistant", content: "Hello from the agent" },
|
|
114
|
+
]);
|
|
115
|
+
|
|
116
|
+
const { wrapper } = mountWithProvider(
|
|
117
|
+
() =>
|
|
118
|
+
h(
|
|
119
|
+
CopilotSidebar,
|
|
120
|
+
{ welcomeScreen: false },
|
|
121
|
+
{
|
|
122
|
+
"assistant-message": ({
|
|
123
|
+
message,
|
|
124
|
+
}: {
|
|
125
|
+
message: { content: string };
|
|
126
|
+
}) =>
|
|
127
|
+
h(
|
|
128
|
+
"div",
|
|
129
|
+
{ "data-testid": "sidebar-assistant-message" },
|
|
130
|
+
message.content,
|
|
131
|
+
),
|
|
132
|
+
},
|
|
133
|
+
),
|
|
134
|
+
{
|
|
135
|
+
runtimeUrl: undefined,
|
|
136
|
+
agents__unsafe_dev_only: { default: agent },
|
|
137
|
+
},
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
expect(
|
|
141
|
+
wrapper.get("[data-testid='sidebar-assistant-message']").text(),
|
|
142
|
+
).toBe("Hello from the agent");
|
|
143
|
+
expect(
|
|
144
|
+
wrapper.find("[data-testid='copilot-assistant-message']").exists(),
|
|
145
|
+
).toBe(false);
|
|
146
|
+
});
|
|
58
147
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
1
|
+
import { afterEach, describe, expect, it } from "vitest";
|
|
2
2
|
import { h } from "vue";
|
|
3
3
|
import { mount } from "@vue/test-utils";
|
|
4
4
|
import type { Message } from "@ag-ui/core";
|
|
@@ -22,21 +22,31 @@ function cssRule(selector: string): string {
|
|
|
22
22
|
return stylesheet.slice(body, stylesheet.indexOf("}", body));
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
/** Mounted sidebars. Only one docked sidebar may own the page margin. */
|
|
26
|
+
const mounted: { unmount: () => void }[] = [];
|
|
27
|
+
afterEach(() => {
|
|
28
|
+
for (const wrapper of mounted.splice(0)) wrapper.unmount();
|
|
29
|
+
});
|
|
30
|
+
|
|
25
31
|
function mountSidebarView(props: Record<string, unknown> = {}) {
|
|
26
|
-
|
|
32
|
+
const wrapper = mount(CopilotKitProvider, {
|
|
27
33
|
props: { runtimeUrl: "/api/copilotkit" },
|
|
28
34
|
slots: {
|
|
29
35
|
default: () =>
|
|
30
36
|
h(CopilotSidebarView, { messages: sampleMessages, ...props }),
|
|
31
37
|
},
|
|
32
38
|
});
|
|
39
|
+
mounted.push(wrapper);
|
|
40
|
+
return wrapper;
|
|
33
41
|
}
|
|
34
42
|
|
|
35
43
|
function mountSidebar(props: Record<string, unknown> = {}) {
|
|
36
|
-
|
|
44
|
+
const wrapper = mount(CopilotKitProvider, {
|
|
37
45
|
props: { agents__unsafe_dev_only: { default: new StateCapturingAgent() } },
|
|
38
46
|
slots: { default: () => h(CopilotSidebar, props) },
|
|
39
47
|
});
|
|
48
|
+
mounted.push(wrapper);
|
|
49
|
+
return wrapper;
|
|
40
50
|
}
|
|
41
51
|
|
|
42
52
|
describe("CopilotSidebarView position prop", () => {
|
|
@@ -87,12 +97,26 @@ describe("CopilotSidebarView position prop", () => {
|
|
|
87
97
|
});
|
|
88
98
|
|
|
89
99
|
it("makes room for the sidebar on the edge it docks to", () => {
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
expect(
|
|
100
|
+
const body = document.body.style;
|
|
101
|
+
mountSidebarView({ position: "left", width: 400 });
|
|
102
|
+
expect(body.marginInlineStart).toBe("400px");
|
|
103
|
+
expect(body.marginInlineEnd).toBe("");
|
|
104
|
+
mounted.pop()?.unmount();
|
|
105
|
+
|
|
106
|
+
mountSidebarView({ width: 400 });
|
|
107
|
+
expect(body.marginInlineEnd).toBe("400px");
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it("gives the page its own margins back on unmount", () => {
|
|
111
|
+
const body = document.body.style;
|
|
112
|
+
body.marginInlineEnd = "16px";
|
|
113
|
+
mountSidebarView({ width: 400 });
|
|
114
|
+
expect(body.marginInlineEnd).toBe("400px");
|
|
115
|
+
|
|
116
|
+
mounted.pop()?.unmount();
|
|
93
117
|
|
|
94
|
-
|
|
95
|
-
|
|
118
|
+
expect(body.marginInlineEnd).toBe("16px");
|
|
119
|
+
body.marginInlineEnd = "";
|
|
96
120
|
});
|
|
97
121
|
});
|
|
98
122
|
|
|
@@ -91,7 +91,8 @@ describe("CopilotSidebarView", () => {
|
|
|
91
91
|
const sidebar = wrapper.get("[data-copilot-sidebar]");
|
|
92
92
|
expect(sidebar.attributes("aria-hidden")).toBe("false");
|
|
93
93
|
expect(sidebar.attributes("style")).toContain("--sidebar-width: 612px");
|
|
94
|
-
expect(
|
|
94
|
+
expect(document.body.style.marginInlineEnd).toBe("612px");
|
|
95
|
+
wrapper.unmount();
|
|
95
96
|
});
|
|
96
97
|
|
|
97
98
|
it("applies explicit width and renders default header and toggle button", () => {
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { render, fireEvent } from "@testing-library/vue";
|
|
3
|
+
import StreamingMarkdownDefault from "../StreamingMarkdownDefault.vue";
|
|
4
|
+
|
|
5
|
+
function renderDefault(props: Record<string, unknown>) {
|
|
6
|
+
return render(StreamingMarkdownDefault, { props }).container;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
describe("StreamingMarkdownDefault (vue)", () => {
|
|
10
|
+
it("renders nothing for empty content", () => {
|
|
11
|
+
expect(renderDefault({ content: "" }).innerHTML).toBe("<!--v-if-->");
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("renders fenced code with the shared code block class", () => {
|
|
15
|
+
const pre = renderDefault({ content: "```ts\nx\n```" }).querySelector(
|
|
16
|
+
"pre",
|
|
17
|
+
);
|
|
18
|
+
expect(pre?.classList.contains("cpk-markdown-code-block")).toBe(true);
|
|
19
|
+
expect(pre?.querySelector("code")?.getAttribute("data-code-info")).toBe(
|
|
20
|
+
"ts",
|
|
21
|
+
);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("shows the caret only while streaming", () => {
|
|
25
|
+
const caret = "[data-streaming-markdown-caret]";
|
|
26
|
+
expect(
|
|
27
|
+
renderDefault({ content: "Hi", isStreaming: true }).querySelector(caret),
|
|
28
|
+
).not.toBeNull();
|
|
29
|
+
expect(renderDefault({ content: "Hi" }).querySelector(caret)).toBeNull();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("passes link and citation clicks to the callbacks", async () => {
|
|
33
|
+
const calls: string[] = [];
|
|
34
|
+
const container = renderDefault({
|
|
35
|
+
content:
|
|
36
|
+
"[link](https://example.com) cite [^ref]\n\n[^ref]: Ref https://example.org",
|
|
37
|
+
onLinkClick: (event: MouseEvent, url: string) => {
|
|
38
|
+
event.preventDefault();
|
|
39
|
+
calls.push(`link:${url}`);
|
|
40
|
+
},
|
|
41
|
+
onCitationClick: (event: MouseEvent, citation: { id: string }) => {
|
|
42
|
+
event.preventDefault();
|
|
43
|
+
calls.push(`cite:${citation.id}`);
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
await fireEvent.click(
|
|
47
|
+
container.querySelector('a[href="https://example.com"]')!,
|
|
48
|
+
);
|
|
49
|
+
await fireEvent.click(
|
|
50
|
+
container.querySelector('sup a[role="doc-noteref"]')!,
|
|
51
|
+
);
|
|
52
|
+
expect(calls).toEqual(["link:https://example.com", "cite:ref"]);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ɵAudioRecorderState } from "@copilotkit/core";
|
|
2
2
|
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
this.name = "AudioRecorderError";
|
|
7
|
-
}
|
|
8
|
-
}
|
|
3
|
+
export type AudioRecorderState = ɵAudioRecorderState;
|
|
4
|
+
|
|
5
|
+
export { ɵAudioRecorderError as AudioRecorderError } from "@copilotkit/core";
|
|
9
6
|
|
|
10
7
|
export interface CopilotChatAudioRecorderRef {
|
|
11
8
|
state: AudioRecorderState;
|
|
@@ -1,112 +1,46 @@
|
|
|
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(
|
|
@@ -114,14 +48,15 @@ export function getToolCallMemoDeps(
|
|
|
114
48
|
messages: Message[],
|
|
115
49
|
executingToolCallIds: ReadonlySet<string>,
|
|
116
50
|
renderToolCalls: readonly VueToolCallRenderer<unknown>[],
|
|
117
|
-
agentId: string =
|
|
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";
|