@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
|
@@ -1,17 +1,25 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
1
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
2
|
import { defineComponent, h, ref } from "vue";
|
|
3
|
-
import { render, waitFor } from "@testing-library/vue";
|
|
3
|
+
import { fireEvent, render, waitFor } from "@testing-library/vue";
|
|
4
|
+
import type { ɵA2UIActionInterceptor } from "@copilotkit/core";
|
|
4
5
|
import { createA2UIMessageRenderer } from "../A2UIMessageRenderer";
|
|
5
6
|
import { CopilotKitKey } from "../../providers/keys";
|
|
6
7
|
|
|
7
|
-
function copilotKitProvide(
|
|
8
|
+
function copilotKitProvide(
|
|
9
|
+
onRunAgent: (properties: Record<string, unknown>) => void = () => undefined,
|
|
10
|
+
) {
|
|
11
|
+
const copilotkit = {
|
|
12
|
+
properties: {} as Record<string, unknown>,
|
|
13
|
+
setProperties(properties: Record<string, unknown>) {
|
|
14
|
+
copilotkit.properties = properties;
|
|
15
|
+
},
|
|
16
|
+
runAgent: async () => {
|
|
17
|
+
onRunAgent(copilotkit.properties);
|
|
18
|
+
},
|
|
19
|
+
};
|
|
8
20
|
return {
|
|
9
21
|
[CopilotKitKey as symbol]: {
|
|
10
|
-
copilotkit: ref(
|
|
11
|
-
properties: {},
|
|
12
|
-
setProperties: () => undefined,
|
|
13
|
-
runAgent: async () => undefined,
|
|
14
|
-
}),
|
|
22
|
+
copilotkit: ref(copilotkit),
|
|
15
23
|
executingToolCallIds: ref(new Set()),
|
|
16
24
|
a2uiTheme: ref({}),
|
|
17
25
|
a2uiCatalog: ref(undefined),
|
|
@@ -22,6 +30,10 @@ function copilotKitProvide() {
|
|
|
22
30
|
}
|
|
23
31
|
|
|
24
32
|
describe("createA2UIMessageRenderer", () => {
|
|
33
|
+
afterEach(() => {
|
|
34
|
+
vi.useRealTimers();
|
|
35
|
+
});
|
|
36
|
+
|
|
25
37
|
const renderLifecycle = (
|
|
26
38
|
content: Record<string, unknown>,
|
|
27
39
|
options: Partial<Parameters<typeof createA2UIMessageRenderer>[0]> = {},
|
|
@@ -46,6 +58,43 @@ describe("createA2UIMessageRenderer", () => {
|
|
|
46
58
|
expect(container.textContent).toContain("~97 tokens");
|
|
47
59
|
});
|
|
48
60
|
|
|
61
|
+
it("keeps an early retry looking like building until showAfterMs passes", async () => {
|
|
62
|
+
vi.useFakeTimers();
|
|
63
|
+
const { container } = renderLifecycle(
|
|
64
|
+
{ status: "retrying", attempt: 1, maxAttempts: 3 },
|
|
65
|
+
{ recovery: { showAfterMs: 2000 } },
|
|
66
|
+
);
|
|
67
|
+
expect(container.textContent).toContain("Building interface");
|
|
68
|
+
await vi.advanceTimersByTimeAsync(2000);
|
|
69
|
+
expect(container.textContent).toContain(
|
|
70
|
+
"Retrying generation… (1/3 attempts)",
|
|
71
|
+
);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("shows retry validation issues unless debugExposure is hidden", () => {
|
|
75
|
+
const retry = {
|
|
76
|
+
status: "retrying",
|
|
77
|
+
attempt: 2,
|
|
78
|
+
errors: [{ code: "missing_required_prop" }],
|
|
79
|
+
};
|
|
80
|
+
const shown = renderLifecycle(retry);
|
|
81
|
+
expect(shown.container.querySelector("details summary")?.textContent).toBe(
|
|
82
|
+
"validation issues",
|
|
83
|
+
);
|
|
84
|
+
expect(shown.container.textContent).toContain("missing_required_prop");
|
|
85
|
+
const hidden = renderLifecycle(retry, {
|
|
86
|
+
recovery: { debugExposure: "hidden" },
|
|
87
|
+
});
|
|
88
|
+
expect(hidden.container.querySelector("details")).toBeNull();
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it("shows collapsed developer details on failure by default", () => {
|
|
92
|
+
const { container } = renderLifecycle({ status: "failed", error: "boom" });
|
|
93
|
+
const details = container.querySelector("details");
|
|
94
|
+
expect(details?.hasAttribute("open")).toBe(false);
|
|
95
|
+
expect(details?.textContent).toContain("boom");
|
|
96
|
+
});
|
|
97
|
+
|
|
49
98
|
it("shows the retry state for status 'retrying'", () => {
|
|
50
99
|
const { container } = renderLifecycle({
|
|
51
100
|
status: "retrying",
|
|
@@ -295,4 +344,118 @@ describe("createA2UIMessageRenderer", () => {
|
|
|
295
344
|
expect(container.querySelector("[data-surface-id='s2']")).not.toBeNull();
|
|
296
345
|
});
|
|
297
346
|
});
|
|
347
|
+
|
|
348
|
+
const buttonContent = {
|
|
349
|
+
a2ui_operations: [
|
|
350
|
+
{
|
|
351
|
+
version: "v0.9",
|
|
352
|
+
createSurface: {
|
|
353
|
+
surfaceId: "form",
|
|
354
|
+
catalogId: "https://a2ui.org/specification/v0_9/basic_catalog.json",
|
|
355
|
+
},
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
version: "v0.9",
|
|
359
|
+
updateComponents: {
|
|
360
|
+
surfaceId: "form",
|
|
361
|
+
components: [
|
|
362
|
+
{
|
|
363
|
+
id: "root",
|
|
364
|
+
component: "Button",
|
|
365
|
+
child: "label",
|
|
366
|
+
action: { event: { name: "confirm", context: { n: 1 } } },
|
|
367
|
+
},
|
|
368
|
+
{ id: "label", component: "Text", text: "Confirm" },
|
|
369
|
+
],
|
|
370
|
+
},
|
|
371
|
+
},
|
|
372
|
+
],
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
/** Renders the button surface, clicks it, and returns what reached the agent. */
|
|
376
|
+
async function clickButton(onAction?: ɵA2UIActionInterceptor) {
|
|
377
|
+
const forwarded: Record<string, unknown>[] = [];
|
|
378
|
+
const renderer = createA2UIMessageRenderer({ theme: {}, onAction });
|
|
379
|
+
const { findByRole } = render(renderer.render, {
|
|
380
|
+
props: {
|
|
381
|
+
activityType: "a2ui-surface",
|
|
382
|
+
content: buttonContent,
|
|
383
|
+
message: {},
|
|
384
|
+
agent: { agentId: "a" },
|
|
385
|
+
},
|
|
386
|
+
global: {
|
|
387
|
+
provide: copilotKitProvide((properties) =>
|
|
388
|
+
forwarded.push({ ...properties }),
|
|
389
|
+
),
|
|
390
|
+
},
|
|
391
|
+
});
|
|
392
|
+
await fireEvent.click(await findByRole("button", { hidden: true }));
|
|
393
|
+
return forwarded;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
it("forwards a button click to the agent wrapped as an A2UI userAction envelope", async () => {
|
|
397
|
+
const forwarded = await clickButton();
|
|
398
|
+
await waitFor(() => expect(forwarded).toHaveLength(1));
|
|
399
|
+
expect(forwarded[0]).toEqual({
|
|
400
|
+
a2uiAction: {
|
|
401
|
+
userAction: {
|
|
402
|
+
name: "confirm",
|
|
403
|
+
surfaceId: "form",
|
|
404
|
+
sourceComponentId: "root",
|
|
405
|
+
context: { n: 1 },
|
|
406
|
+
timestamp: expect.any(String),
|
|
407
|
+
},
|
|
408
|
+
},
|
|
409
|
+
});
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
it("does not run the agent when onAction handles the action", async () => {
|
|
413
|
+
const onAction = vi.fn<ɵA2UIActionInterceptor>(() => null);
|
|
414
|
+
const forwarded = await clickButton(onAction);
|
|
415
|
+
await waitFor(() => expect(onAction).toHaveBeenCalledOnce());
|
|
416
|
+
expect(forwarded).toEqual([]);
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
it("keeps the loader over the hidden surface until the surface can paint", async () => {
|
|
420
|
+
const renderer = createA2UIMessageRenderer({ theme: {} });
|
|
421
|
+
const createOnly = {
|
|
422
|
+
a2ui_operations: [buttonContent.a2ui_operations[0]],
|
|
423
|
+
};
|
|
424
|
+
const mounted = render(renderer.render, {
|
|
425
|
+
props: {
|
|
426
|
+
activityType: "a2ui-surface",
|
|
427
|
+
content: { status: "building", progressTokens: 120 },
|
|
428
|
+
message: {},
|
|
429
|
+
agent: {},
|
|
430
|
+
},
|
|
431
|
+
global: { provide: copilotKitProvide() },
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
await mounted.rerender({
|
|
435
|
+
activityType: "a2ui-surface",
|
|
436
|
+
content: createOnly,
|
|
437
|
+
message: {},
|
|
438
|
+
agent: {},
|
|
439
|
+
});
|
|
440
|
+
// A surface without components cannot paint: the loader stays on top.
|
|
441
|
+
expect(mounted.container.textContent).toContain("~120 tokens");
|
|
442
|
+
expect(
|
|
443
|
+
mounted.container.querySelector(
|
|
444
|
+
"[aria-hidden='true'] [data-testid='a2ui-activity-renderer']",
|
|
445
|
+
),
|
|
446
|
+
).not.toBeNull();
|
|
447
|
+
|
|
448
|
+
await mounted.rerender({
|
|
449
|
+
activityType: "a2ui-surface",
|
|
450
|
+
content: buttonContent,
|
|
451
|
+
message: {},
|
|
452
|
+
agent: {},
|
|
453
|
+
});
|
|
454
|
+
await waitFor(() => {
|
|
455
|
+
expect(mounted.container.textContent).not.toContain("Building interface");
|
|
456
|
+
expect(
|
|
457
|
+
mounted.container.querySelector("[aria-hidden='true']"),
|
|
458
|
+
).toBeNull();
|
|
459
|
+
});
|
|
460
|
+
});
|
|
298
461
|
});
|
|
@@ -62,6 +62,48 @@ describe("CopilotKitInspector", () => {
|
|
|
62
62
|
);
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
+
it("forwards event listeners to the web inspector element", async () => {
|
|
66
|
+
const onVisibility = vi.fn();
|
|
67
|
+
const wrapper = mount(CopilotKitInspector, {
|
|
68
|
+
attrs: { onCpkInspectorVisibilityChange: onVisibility },
|
|
69
|
+
});
|
|
70
|
+
await settleInspectorLoad();
|
|
71
|
+
|
|
72
|
+
const event = new CustomEvent("cpk-inspector-visibility-change", {
|
|
73
|
+
detail: { visible: false },
|
|
74
|
+
});
|
|
75
|
+
wrapper.get("cpk-web-inspector").element.dispatchEvent(event);
|
|
76
|
+
|
|
77
|
+
expect(onVisibility).toHaveBeenCalledWith(event);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it("opens a request made before the web inspector module resolves", async () => {
|
|
81
|
+
const wrapper = mount(CopilotKitInspector);
|
|
82
|
+
const openRequest = { messageId: "message-early" };
|
|
83
|
+
await wrapper.setProps({ openRequest });
|
|
84
|
+
|
|
85
|
+
await settleInspectorLoad();
|
|
86
|
+
|
|
87
|
+
const inspector = wrapper.get("cpk-web-inspector")
|
|
88
|
+
.element as HTMLElement & {
|
|
89
|
+
openInspector: ReturnType<typeof vi.fn>;
|
|
90
|
+
};
|
|
91
|
+
expect(inspector.openInspector).toHaveBeenCalledExactlyOnceWith(
|
|
92
|
+
"message_toolbar",
|
|
93
|
+
openRequest,
|
|
94
|
+
);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it("emits Inspector visibility and removes the element on unmount", async () => {
|
|
98
|
+
const wrapper = mount(CopilotKitInspector, { attachTo: document.body });
|
|
99
|
+
await settleInspectorLoad();
|
|
100
|
+
expect(wrapper.emitted("visibility-change")).toEqual([[true]]);
|
|
101
|
+
|
|
102
|
+
wrapper.unmount();
|
|
103
|
+
|
|
104
|
+
expect(document.querySelector("cpk-web-inspector")).toBeNull();
|
|
105
|
+
});
|
|
106
|
+
|
|
65
107
|
it("forwards Inspector open requests to the mounted element", async () => {
|
|
66
108
|
const openRequest = { messageId: "message-1" };
|
|
67
109
|
const wrapper = mount(CopilotKitInspector, {
|
|
@@ -1,7 +1,24 @@
|
|
|
1
1
|
import { mount } from "@vue/test-utils";
|
|
2
2
|
import { describe, expect, it, vi } from "vitest";
|
|
3
|
+
import { defineComponent, h } from "vue";
|
|
4
|
+
import type { CopilotChatLabels } from "@copilotkit/core";
|
|
5
|
+
import CopilotChatConfigurationProvider from "../../providers/CopilotChatConfigurationProvider.vue";
|
|
6
|
+
import InlineFeatureWarning from "../InlineFeatureWarning.vue";
|
|
3
7
|
import LicenseWarningBanner from "../LicenseWarningBanner.vue";
|
|
4
8
|
|
|
9
|
+
/** Mounts `child` inside a chat configuration with `labels`. */
|
|
10
|
+
function mountWithLabels(
|
|
11
|
+
labels: Partial<CopilotChatLabels>,
|
|
12
|
+
child: () => ReturnType<typeof h>,
|
|
13
|
+
) {
|
|
14
|
+
const Host = defineComponent({
|
|
15
|
+
setup: () => () =>
|
|
16
|
+
h(CopilotChatConfigurationProvider, { labels }, { default: child }),
|
|
17
|
+
});
|
|
18
|
+
return mount(Host);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// The banner text rules are covered next to core's ɵgetLicenseBannerSpec.
|
|
5
22
|
describe("LicenseWarningBanner", () => {
|
|
6
23
|
it("reactively renders and invokes the optional dismiss callback", async () => {
|
|
7
24
|
const onDismiss = vi.fn();
|
|
@@ -20,4 +37,47 @@ describe("LicenseWarningBanner", () => {
|
|
|
20
37
|
|
|
21
38
|
expect(wrapper.find("button").exists()).toBe(false);
|
|
22
39
|
});
|
|
40
|
+
|
|
41
|
+
it("shows the core spec's text and link", () => {
|
|
42
|
+
const wrapper = mount(LicenseWarningBanner, {
|
|
43
|
+
props: { type: "expiring", graceRemaining: 1 },
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
expect(wrapper.get("span").text()).toBe(
|
|
47
|
+
"Your CopilotKit license expires in 1 day. Please renew.",
|
|
48
|
+
);
|
|
49
|
+
expect(wrapper.get("a").attributes("href")).toBe(
|
|
50
|
+
"https://dashboard.operations.copilotkit.ai",
|
|
51
|
+
);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("uses the configured chat labels", () => {
|
|
55
|
+
const wrapper = mountWithLabels(
|
|
56
|
+
{ licenseInvalidText: "Token ungültig" },
|
|
57
|
+
() => h(LicenseWarningBanner, { type: "invalid" }),
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
expect(wrapper.get("span").text()).toBe("Token ungültig");
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
describe("InlineFeatureWarning", () => {
|
|
65
|
+
it("shows the default feature-unlicensed label", () => {
|
|
66
|
+
const wrapper = mount(InlineFeatureWarning, {
|
|
67
|
+
props: { featureName: "Chat" },
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
expect(wrapper.text()).toContain(
|
|
71
|
+
'⚠ The "Chat" feature requires a CopilotKit license.',
|
|
72
|
+
);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("uses the configured feature-unlicensed label", () => {
|
|
76
|
+
const wrapper = mountWithLabels(
|
|
77
|
+
{ licenseFeatureUnlicensedText: "{feature} braucht eine Lizenz." },
|
|
78
|
+
() => h(InlineFeatureWarning, { featureName: "Chat" }),
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
expect(wrapper.text()).toContain("Chat braucht eine Lizenz.");
|
|
82
|
+
});
|
|
23
83
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import type * as CoreModule from "@copilotkit/core";
|
|
2
3
|
import { render } from "@testing-library/vue";
|
|
3
4
|
import { ref } from "vue";
|
|
4
5
|
import type { Ref } from "vue";
|
|
@@ -37,12 +38,25 @@ const mockCreate = vi.fn<MockCreateFn>(() => ({
|
|
|
37
38
|
destroy: mockDestroy,
|
|
38
39
|
}));
|
|
39
40
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
// Run the real core controller against a fake websandbox
|
|
42
|
+
vi.mock("@copilotkit/core", async (importOriginal) => {
|
|
43
|
+
const actual = await importOriginal<typeof CoreModule>();
|
|
44
|
+
class TestOpenGenerativeUIController
|
|
45
|
+
extends actual.ɵOpenGenerativeUIController
|
|
46
|
+
{
|
|
47
|
+
constructor() {
|
|
48
|
+
super({
|
|
49
|
+
loadWebsandbox: async () => ({
|
|
50
|
+
create: (localApi, options) => mockCreate(localApi, options),
|
|
51
|
+
}),
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
...actual,
|
|
57
|
+
ɵOpenGenerativeUIController: TestOpenGenerativeUIController,
|
|
58
|
+
};
|
|
59
|
+
});
|
|
46
60
|
|
|
47
61
|
async function flushImport() {
|
|
48
62
|
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
@@ -86,16 +100,23 @@ describe("OpenGenerativeUIRenderer", () => {
|
|
|
86
100
|
vi.restoreAllMocks();
|
|
87
101
|
});
|
|
88
102
|
|
|
89
|
-
it("
|
|
103
|
+
it("shows the progress overlay with a spinner while generating", async () => {
|
|
90
104
|
const { getByTestId, queryByTestId } = renderRenderer({
|
|
91
105
|
initialHeight: 300,
|
|
92
106
|
});
|
|
93
107
|
await flushImport();
|
|
94
|
-
expect(getByTestId("open-generative-ui-
|
|
108
|
+
expect(getByTestId("open-generative-ui-spinner")).not.toBeNull();
|
|
95
109
|
expect(queryByTestId("open-generative-ui-final-sandbox")).toBeNull();
|
|
96
110
|
expect(mockCreate).not.toHaveBeenCalled();
|
|
97
111
|
});
|
|
98
112
|
|
|
113
|
+
it("shows no spinner or overlay once generation is done", async () => {
|
|
114
|
+
const { queryByTestId } = renderRenderer({ generating: false });
|
|
115
|
+
await flushImport();
|
|
116
|
+
expect(queryByTestId("open-generative-ui-progress-overlay")).toBeNull();
|
|
117
|
+
expect(queryByTestId("open-generative-ui-spinner")).toBeNull();
|
|
118
|
+
});
|
|
119
|
+
|
|
99
120
|
it("creates final sandbox when html is complete", async () => {
|
|
100
121
|
renderRenderer({
|
|
101
122
|
html: ["<head></head><body><p>Hello</p></body>"],
|
|
@@ -178,6 +199,41 @@ describe("OpenGenerativeUIRenderer", () => {
|
|
|
178
199
|
expect(options.frameContent).toContain("v2");
|
|
179
200
|
});
|
|
180
201
|
|
|
202
|
+
it("sizes the container to the height the final sandbox reports", async () => {
|
|
203
|
+
const iframe = document.createElement("iframe");
|
|
204
|
+
mockCreate.mockImplementationOnce((_localApi, options) => {
|
|
205
|
+
(options.frameContainer as HTMLElement).appendChild(iframe);
|
|
206
|
+
return {
|
|
207
|
+
iframe,
|
|
208
|
+
promise: Promise.resolve(),
|
|
209
|
+
run: mockRun,
|
|
210
|
+
destroy: mockDestroy,
|
|
211
|
+
};
|
|
212
|
+
});
|
|
213
|
+
const { getByTestId } = renderRenderer({
|
|
214
|
+
initialHeight: 150,
|
|
215
|
+
html: ["<body><p>Chart</p></body>"],
|
|
216
|
+
htmlComplete: true,
|
|
217
|
+
generating: false,
|
|
218
|
+
});
|
|
219
|
+
await flushImport();
|
|
220
|
+
expect(getByTestId("open-generative-ui-renderer").style.height).toBe(
|
|
221
|
+
"150px",
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
window.dispatchEvent(
|
|
225
|
+
new MessageEvent("message", {
|
|
226
|
+
source: iframe.contentWindow,
|
|
227
|
+
data: { type: "__ck_resize", height: 420 },
|
|
228
|
+
}),
|
|
229
|
+
);
|
|
230
|
+
await flushImport();
|
|
231
|
+
|
|
232
|
+
expect(getByTestId("open-generative-ui-renderer").style.height).toBe(
|
|
233
|
+
"420px",
|
|
234
|
+
);
|
|
235
|
+
});
|
|
236
|
+
|
|
181
237
|
it("destroys sandbox on unmount", async () => {
|
|
182
238
|
const mounted = renderRenderer({
|
|
183
239
|
html: ["<head></head><body>bye</body>"],
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { render } from "@testing-library/vue";
|
|
3
|
+
import { ToolCallStatus } from "@copilotkit/core";
|
|
4
|
+
import { OpenGenerativeUIToolRenderer } from "../OpenGenerativeUIRenderer";
|
|
5
|
+
|
|
6
|
+
function toolProps(messages: string[], status = ToolCallStatus.InProgress) {
|
|
7
|
+
return {
|
|
8
|
+
name: "generateSandboxedUi",
|
|
9
|
+
args: { placeholderMessages: [...messages] },
|
|
10
|
+
status,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
describe("OpenGenerativeUIToolRenderer", () => {
|
|
15
|
+
beforeEach(() => vi.useFakeTimers());
|
|
16
|
+
afterEach(() => vi.useRealTimers());
|
|
17
|
+
|
|
18
|
+
it("keeps rotating while streamed snapshots repeat the same messages", async () => {
|
|
19
|
+
const view = render(OpenGenerativeUIToolRenderer, {
|
|
20
|
+
props: toolProps(["Sketching", "Styling"]),
|
|
21
|
+
});
|
|
22
|
+
expect(view.container.textContent).toBe("Styling");
|
|
23
|
+
|
|
24
|
+
await vi.advanceTimersByTimeAsync(4000);
|
|
25
|
+
await view.rerender(toolProps(["Sketching", "Styling"]));
|
|
26
|
+
await vi.advanceTimersByTimeAsync(1000);
|
|
27
|
+
|
|
28
|
+
expect(view.container.textContent).toBe("Sketching");
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("renders nothing once the tool call is complete", async () => {
|
|
32
|
+
const view = render(OpenGenerativeUIToolRenderer, {
|
|
33
|
+
props: toolProps(["Sketching"]),
|
|
34
|
+
});
|
|
35
|
+
await view.rerender(toolProps(["Sketching"], ToolCallStatus.Complete));
|
|
36
|
+
expect(view.container.textContent).toBe("");
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import { watch } from "vue";
|
|
2
2
|
import type { ShallowRef } from "vue";
|
|
3
|
-
import
|
|
3
|
+
import * as z from "zod";
|
|
4
|
+
import { ɵRENDER_A2UI_TOOL_NAME as RENDER_A2UI_TOOL_NAME } from "@copilotkit/core";
|
|
4
5
|
import type { CopilotKitCoreVue } from "../../lib/vue-core";
|
|
5
6
|
import { defineToolCallRenderer } from "../../types/defineToolCallRenderer";
|
|
6
7
|
|
|
7
|
-
/**
|
|
8
|
-
* Tool name used by the dynamic A2UI generation secondary LLM.
|
|
9
|
-
* This renderer is auto-registered when A2UI is enabled.
|
|
10
|
-
*/
|
|
11
|
-
export const RENDER_A2UI_TOOL_NAME = "render_a2ui";
|
|
12
|
-
|
|
13
8
|
/**
|
|
14
9
|
* Registers a no-op renderer for the `render_a2ui` tool call so its raw
|
|
15
10
|
* streamed args are never surfaced in the transcript, as React does.
|