@copilotkit/vue 2.0.0-rc.1 → 2.0.0-rc.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/PARITY.md +13 -12
- package/README.md +1 -2
- package/dist/components/copilot-provider/CopilotKit.vue.d.ts +3 -1
- package/dist/components/copilot-provider/CopilotKit.vue.d.ts.map +1 -1
- package/dist/hooks/use-copilot-action.d.ts.map +1 -1
- package/dist/hooks/use-frontend-tool.d.ts +1 -1
- package/dist/hooks/use-frontend-tool.d.ts.map +1 -1
- package/dist/hooks/zod-parameters.d.ts +14 -0
- package/dist/hooks/zod-parameters.d.ts.map +1 -0
- package/dist/index.cjs +1 -76
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +384 -14275
- package/dist/index.mjs.map +1 -1
- package/dist/use-render-activity-message-CTR_ziWV.js +18097 -0
- package/dist/use-render-activity-message-CTR_ziWV.js.map +1 -0
- package/dist/use-render-activity-message-Dky9_GRG.cjs +92 -0
- package/dist/use-render-activity-message-Dky9_GRG.cjs.map +1 -0
- package/dist/v2/components/A2UIMessageRenderer.d.ts +7 -0
- package/dist/v2/components/A2UIMessageRenderer.d.ts.map +1 -1
- package/dist/v2/components/A2UISurfaceActivityRenderer.vue.d.ts.map +1 -1
- package/dist/v2/components/LicenseWarningBanner.vue.d.ts.map +1 -1
- package/dist/v2/components/OpenGenerativeUIRenderer.d.ts +13 -45
- package/dist/v2/components/OpenGenerativeUIRenderer.d.ts.map +1 -1
- package/dist/v2/components/a2ui/A2UIBuiltInToolCallRenderer.d.ts +11 -2
- package/dist/v2/components/a2ui/A2UIBuiltInToolCallRenderer.d.ts.map +1 -1
- package/dist/v2/components/a2ui/A2UICatalogContext.d.ts +1 -1
- package/dist/v2/components/a2ui/A2UICatalogContext.d.ts.map +1 -1
- package/dist/v2/components/a2ui/A2UIRecoveryStates.d.ts +144 -0
- package/dist/v2/components/a2ui/A2UIRecoveryStates.d.ts.map +1 -0
- package/dist/v2/components/a2ui.d.ts +3 -7
- package/dist/v2/components/a2ui.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChat.vue.d.ts +1 -0
- package/dist/v2/components/chat/CopilotChat.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatAssistantMessage.vue.d.ts +3 -1
- package/dist/v2/components/chat/CopilotChatAssistantMessage.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatAssistantToolbarButton.vue.d.ts +16 -0
- package/dist/v2/components/chat/CopilotChatAssistantToolbarButton.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatAttachmentQueue.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatAttachmentRenderer.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatAudioRecorder.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatFeedbackCommentPopover.vue.d.ts +22 -0
- package/dist/v2/components/chat/CopilotChatFeedbackCommentPopover.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatInput.vue.d.ts +21 -232
- package/dist/v2/components/chat/CopilotChatInput.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatInspectorButton.vue.d.ts +12 -0
- package/dist/v2/components/chat/CopilotChatInspectorButton.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatLightbox.vue.d.ts +22 -0
- package/dist/v2/components/chat/CopilotChatLightbox.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatMessageView.vue.d.ts +20 -0
- package/dist/v2/components/chat/CopilotChatMessageView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatReasoningMessage.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatSuggestionPill.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatSuggestionView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatToggleButton.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatToolCallGroup.vue.d.ts +32 -0
- package/dist/v2/components/chat/CopilotChatToolCallGroup.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatToolCallItem.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatToolCallsView.vue.d.ts +11 -1
- package/dist/v2/components/chat/CopilotChatToolCallsView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatUserMessage.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatView.vue.d.ts +1 -0
- package/dist/v2/components/chat/CopilotChatView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatWorkSummary.vue.d.ts +5 -0
- package/dist/v2/components/chat/CopilotChatWorkSummary.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotModalHeader.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotModalHeaderCloseButton.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotModalHeaderTitle.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotPopup.vue.d.ts +1 -0
- package/dist/v2/components/chat/CopilotPopup.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotPopupView.vue.d.ts +1 -0
- package/dist/v2/components/chat/CopilotPopupView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotPopupViewInternal.vue.d.ts +1 -0
- package/dist/v2/components/chat/CopilotPopupViewInternal.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotPopupWelcomeScreen.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotSidebar.vue.d.ts +2 -0
- package/dist/v2/components/chat/CopilotSidebar.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotSidebarView.vue.d.ts +2 -0
- package/dist/v2/components/chat/CopilotSidebarView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotSidebarViewInternal.vue.d.ts +2 -0
- package/dist/v2/components/chat/CopilotSidebarViewInternal.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotSidebarWelcomeScreen.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/StreamingMarkdownDefault.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/copilotChatToolCallItemRender.d.ts +0 -1
- package/dist/v2/components/chat/copilotChatToolCallItemRender.d.ts.map +1 -1
- package/dist/v2/components/chat/index.d.ts +17 -1
- package/dist/v2/components/chat/index.d.ts.map +1 -1
- package/dist/v2/components/chat/inspector-shortcuts.d.ts +12 -0
- package/dist/v2/components/chat/inspector-shortcuts.d.ts.map +1 -0
- package/dist/v2/components/chat/message-feedback.d.ts +89 -0
- package/dist/v2/components/chat/message-feedback.d.ts.map +1 -0
- package/dist/v2/components/chat/tool-call-capture.d.ts +39 -0
- package/dist/v2/components/chat/tool-call-capture.d.ts.map +1 -0
- package/dist/v2/components/chat/tool-call-display-context.d.ts +22 -0
- package/dist/v2/components/chat/tool-call-display-context.d.ts.map +1 -0
- package/dist/v2/components/chat/tool-call-group-parts.d.ts +131 -0
- package/dist/v2/components/chat/tool-call-group-parts.d.ts.map +1 -0
- package/dist/v2/components/chat/turn-work.d.ts +33 -0
- package/dist/v2/components/chat/turn-work.d.ts.map +1 -0
- package/dist/v2/components/chat/types.d.ts +104 -5
- package/dist/v2/components/chat/types.d.ts.map +1 -1
- package/dist/v2/components/chat/use-chat-labels.d.ts +8 -0
- package/dist/v2/components/chat/use-chat-labels.d.ts.map +1 -0
- package/dist/v2/components/chat/use-lightbox.d.ts +18 -0
- package/dist/v2/components/chat/use-lightbox.d.ts.map +1 -0
- package/dist/v2/components/icons/index.d.ts +968 -1
- package/dist/v2/components/icons/index.d.ts.map +1 -1
- package/dist/v2/components/ui/CopilotDropdownMenuContent.vue.d.ts +55 -0
- package/dist/v2/components/ui/CopilotDropdownMenuContent.vue.d.ts.map +1 -0
- package/dist/v2/components/ui/CopilotPopover.vue.d.ts +40 -0
- package/dist/v2/components/ui/CopilotPopover.vue.d.ts.map +1 -0
- package/dist/v2/components/ui/CopilotTooltip.vue.d.ts +37 -0
- package/dist/v2/components/ui/CopilotTooltip.vue.d.ts.map +1 -0
- package/dist/v2/components/ui/dropdown-menu.d.ts +14 -0
- package/dist/v2/components/ui/dropdown-menu.d.ts.map +1 -0
- package/dist/v2/components/ui/floating.d.ts +84 -0
- package/dist/v2/components/ui/floating.d.ts.map +1 -0
- package/dist/v2/components/ui/presence.d.ts +9 -0
- package/dist/v2/components/ui/presence.d.ts.map +1 -0
- package/dist/v2/components/ui/use-id.d.ts +9 -0
- package/dist/v2/components/ui/use-id.d.ts.map +1 -0
- package/dist/v2/hooks/use-default-render-tool.d.ts +6 -0
- package/dist/v2/hooks/use-default-render-tool.d.ts.map +1 -1
- package/dist/v2/hooks/use-frontend-tool.d.ts +5 -0
- package/dist/v2/hooks/use-frontend-tool.d.ts.map +1 -1
- package/dist/v2/hooks/use-render-activity-message.d.ts +13 -9
- package/dist/v2/hooks/use-render-activity-message.d.ts.map +1 -1
- package/dist/v2/hooks/use-render-custom-messages.d.ts +5 -7
- package/dist/v2/hooks/use-render-custom-messages.d.ts.map +1 -1
- package/dist/v2/hooks/use-render-tool.d.ts +4 -0
- package/dist/v2/hooks/use-render-tool.d.ts.map +1 -1
- package/dist/v2/index.cjs +1 -1
- package/dist/v2/index.d.cts +3 -0
- package/dist/v2/index.d.mts +3 -0
- package/dist/v2/index.d.ts +3 -0
- package/dist/v2/index.d.ts.map +1 -1
- package/dist/v2/index.mjs +197 -197
- package/dist/v2/index.mjs.map +1 -1
- package/dist/v2/lib/message-feedback.d.ts +33 -0
- package/dist/v2/lib/message-feedback.d.ts.map +1 -0
- package/dist/v2/lib/processPartialHtml.d.ts +1 -2
- package/dist/v2/lib/processPartialHtml.d.ts.map +1 -1
- package/dist/v2/lib/vue-core.d.ts +0 -1
- package/dist/v2/lib/vue-core.d.ts.map +1 -1
- package/dist/v2/providers/CopilotChatConfigurationProvider.vue.d.ts.map +1 -1
- package/dist/v2/providers/CopilotKitProvider.types.d.ts +56 -6
- package/dist/v2/providers/CopilotKitProvider.types.d.ts.map +1 -1
- package/dist/v2/providers/CopilotKitProvider.vue.d.ts +6 -2
- package/dist/v2/providers/CopilotKitProvider.vue.d.ts.map +1 -1
- package/dist/v2/providers/index.d.ts +1 -1
- package/dist/v2/providers/index.d.ts.map +1 -1
- package/dist/v2/providers/keys.d.ts +8 -0
- package/dist/v2/providers/keys.d.ts.map +1 -1
- package/dist/v2/providers/types.d.ts +3 -37
- package/dist/v2/providers/types.d.ts.map +1 -1
- package/dist/v2/styles/CopilotKitStyles.d.ts +18 -0
- package/dist/v2/styles/CopilotKitStyles.d.ts.map +1 -0
- package/dist/v2/types/defineToolCallRenderer.d.ts +2 -0
- package/dist/v2/types/defineToolCallRenderer.d.ts.map +1 -1
- package/dist/v2/types/human-in-the-loop.d.ts +8 -29
- package/dist/v2/types/human-in-the-loop.d.ts.map +1 -1
- package/dist/v2/types/interrupt.d.ts +1 -22
- package/dist/v2/types/interrupt.d.ts.map +1 -1
- package/dist/v2/types/vue-activity-message-renderer.d.ts +16 -15
- package/dist/v2/types/vue-activity-message-renderer.d.ts.map +1 -1
- package/dist/v2/types/vue-custom-message-renderer.d.ts +7 -16
- package/dist/v2/types/vue-custom-message-renderer.d.ts.map +1 -1
- package/dist/v2/types/vue-tool-call-renderer.d.ts +16 -28
- package/dist/v2/types/vue-tool-call-renderer.d.ts.map +1 -1
- package/package.json +14 -27
- package/src/__tests__/build-entries.test.ts +27 -0
- package/src/components/copilot-provider/CopilotKit.vue +4 -1
- package/src/hooks/__tests__/zod-parameters.test.ts +520 -0
- package/src/hooks/use-copilot-action.ts +2 -1
- package/src/hooks/use-frontend-tool.ts +3 -6
- package/src/hooks/zod-parameters.ts +162 -0
- package/src/v2/__tests__/exports.test.ts +4 -2
- package/src/v2/components/A2UIMessageRenderer.ts +56 -68
- package/src/v2/components/A2UISurfaceActivityRenderer.vue +11 -23
- package/src/v2/components/LicenseWarningBanner.vue +31 -15
- package/src/v2/components/OpenGenerativeUIRenderer.ts +51 -373
- package/src/v2/components/__tests__/A2UIBasicCatalogColors.test.ts +8 -9
- package/src/v2/components/__tests__/A2UICatalogContext.test.ts +1 -1
- package/src/v2/components/__tests__/A2UIMessageRenderer.test.ts +63 -36
- package/src/v2/components/__tests__/LicenseWarningBanner.test.ts +20 -0
- package/src/v2/components/__tests__/OpenGenerativeUIRenderer.test.ts +55 -6
- package/src/v2/components/a2ui/A2UIBuiltInToolCallRenderer.ts +15 -258
- package/src/v2/components/a2ui/A2UICatalogContext.ts +10 -102
- package/src/v2/components/a2ui/A2UIRecoveryStates.ts +444 -0
- package/src/v2/components/a2ui/__tests__/A2UIRecoveryStates.test.ts +175 -0
- package/src/v2/components/a2ui.ts +1 -1
- package/src/v2/components/chat/CopilotChat.vue +26 -40
- package/src/v2/components/chat/CopilotChatAssistantMessage.vue +267 -67
- package/src/v2/components/chat/CopilotChatAssistantToolbarButton.vue +46 -0
- package/src/v2/components/chat/CopilotChatAttachmentQueue.vue +150 -173
- package/src/v2/components/chat/CopilotChatAttachmentRenderer.vue +77 -20
- package/src/v2/components/chat/CopilotChatAudioRecorder.vue +2 -2
- package/src/v2/components/chat/CopilotChatFeedbackCommentPopover.vue +240 -0
- package/src/v2/components/chat/CopilotChatInput.vue +250 -191
- package/src/v2/components/chat/CopilotChatInspectorButton.vue +331 -0
- package/src/v2/components/chat/CopilotChatLightbox.vue +105 -0
- package/src/v2/components/chat/CopilotChatMessageView.vue +262 -87
- package/src/v2/components/chat/CopilotChatReasoningMessage.vue +52 -35
- package/src/v2/components/chat/CopilotChatSuggestionPill.vue +5 -14
- package/src/v2/components/chat/CopilotChatSuggestionView.vue +1 -4
- package/src/v2/components/chat/CopilotChatToggleButton.vue +3 -9
- package/src/v2/components/chat/CopilotChatToggleButtonCloseIcon.ts +1 -1
- package/src/v2/components/chat/CopilotChatToggleButtonOpenIcon.ts +1 -1
- package/src/v2/components/chat/CopilotChatToolCallGroup.vue +353 -0
- package/src/v2/components/chat/CopilotChatToolCallItem.vue +24 -14
- package/src/v2/components/chat/CopilotChatToolCallsView.vue +194 -21
- package/src/v2/components/chat/CopilotChatUserMessage.vue +105 -42
- package/src/v2/components/chat/CopilotChatView.vue +37 -42
- package/src/v2/components/chat/CopilotChatWorkSummary.vue +111 -0
- package/src/v2/components/chat/CopilotModalHeader.vue +10 -8
- package/src/v2/components/chat/CopilotModalHeaderCloseButton.ts +7 -6
- package/src/v2/components/chat/CopilotModalHeaderTitle.ts +1 -4
- package/src/v2/components/chat/CopilotPopup.vue +3 -0
- package/src/v2/components/chat/CopilotPopupView.vue +1 -0
- package/src/v2/components/chat/CopilotPopupViewInternal.vue +9 -19
- package/src/v2/components/chat/CopilotPopupWelcomeScreen.vue +5 -8
- package/src/v2/components/chat/CopilotSidebar.vue +5 -0
- package/src/v2/components/chat/CopilotSidebarView.vue +2 -0
- package/src/v2/components/chat/CopilotSidebarViewInternal.vue +24 -17
- package/src/v2/components/chat/CopilotSidebarWelcomeScreen.vue +7 -10
- package/src/v2/components/chat/StreamingMarkdownDefault.vue +3 -5
- package/src/v2/components/chat/__tests__/CopilotChat.labels.test.ts +19 -4
- package/src/v2/components/chat/__tests__/CopilotChatActivityRendering.e2e.test.ts +26 -9
- package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.inspector.test.ts +269 -0
- package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.learningFeedback.test.ts +760 -0
- package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.slots.e2e.test.ts +3 -5
- package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.test.ts +2 -2
- package/src/v2/components/chat/__tests__/CopilotChatInput.addMenu.test.ts +328 -0
- package/src/v2/components/chat/__tests__/CopilotChatInput.slots.e2e.test.ts +6 -3
- package/src/v2/components/chat/__tests__/CopilotChatInput.test.ts +55 -14
- package/src/v2/components/chat/__tests__/CopilotChatLightbox.test.ts +160 -0
- package/src/v2/components/chat/__tests__/CopilotChatMessageView.test.ts +247 -403
- package/src/v2/components/chat/__tests__/CopilotChatMessageView.toolCallDisplay.test.ts +637 -0
- package/src/v2/components/chat/__tests__/CopilotChatSuggestionPill.test.ts +1 -1
- package/src/v2/components/chat/__tests__/CopilotChatSuggestionView.slots.e2e.test.ts +3 -1
- package/src/v2/components/chat/__tests__/CopilotChatToolCallsView.learning.test.ts +75 -0
- package/src/v2/components/chat/__tests__/CopilotChatUserMessage.attachments.test.ts +143 -0
- package/src/v2/components/chat/__tests__/CopilotChatView.inputOverlay.test.ts +5 -4
- package/src/v2/components/chat/__tests__/CopilotChatView.rootWidth.test.ts +7 -33
- package/src/v2/components/chat/__tests__/CopilotModalHeader.slots.e2e.test.ts +1 -1
- package/src/v2/components/chat/__tests__/CopilotPopupView.slots.e2e.test.ts +3 -3
- package/src/v2/components/chat/__tests__/CopilotSidebarView.position.test.ts +126 -0
- package/src/v2/components/chat/__tests__/messageFeedbackDefaults.test.ts +33 -0
- package/src/v2/components/chat/__tests__/modalChatDisplayProps.test.ts +44 -0
- package/src/v2/components/chat/copilotChatToolCallItemRender.ts +3 -19
- package/src/v2/components/chat/index.ts +2 -1
- package/src/v2/components/chat/inspector-shortcuts.ts +34 -0
- package/src/v2/components/chat/message-feedback.ts +291 -0
- package/src/v2/components/chat/tool-call-capture.ts +55 -0
- package/src/v2/components/chat/tool-call-display-context.ts +28 -0
- package/src/v2/components/chat/tool-call-group-parts.ts +251 -0
- package/src/v2/components/chat/turn-work.ts +52 -0
- package/src/v2/components/chat/types.ts +114 -4
- package/src/v2/components/chat/use-chat-labels.ts +16 -0
- package/src/v2/components/chat/use-lightbox.ts +64 -0
- package/src/v2/components/icons/__tests__/icons.test.ts +72 -68
- package/src/v2/components/icons/index.ts +109 -23
- package/src/v2/components/ui/CopilotDropdownMenuContent.vue +465 -0
- package/src/v2/components/ui/CopilotPopover.vue +138 -0
- package/src/v2/components/ui/CopilotTooltip.vue +237 -0
- package/src/v2/components/ui/__tests__/CopilotTooltip.test.ts +168 -0
- package/src/v2/components/ui/dropdown-menu.ts +15 -0
- package/src/v2/components/ui/floating.ts +321 -0
- package/src/v2/components/ui/presence.ts +54 -0
- package/src/v2/components/ui/use-id.ts +16 -0
- package/src/v2/hooks/__tests__/use-frontend-tool.e2e.test.ts +62 -1
- package/src/v2/hooks/__tests__/use-render-activity-message.test.ts +105 -0
- package/src/v2/hooks/__tests__/use-render-tool.test.ts +3 -6
- package/src/v2/hooks/__tests__/zod-regression.test.ts +5 -4
- package/src/v2/hooks/use-default-render-tool.ts +123 -62
- package/src/v2/hooks/use-frontend-tool.ts +10 -10
- package/src/v2/hooks/use-render-activity-message.ts +27 -48
- package/src/v2/hooks/use-render-custom-messages.ts +14 -35
- package/src/v2/hooks/use-render-tool.ts +8 -0
- package/src/v2/index.ts +3 -0
- package/src/v2/lib/__tests__/message-feedback.test.ts +152 -0
- package/src/v2/lib/message-feedback.ts +120 -0
- package/src/v2/lib/processPartialHtml.ts +6 -21
- package/src/v2/lib/vue-core.ts +3 -5
- package/src/v2/providers/CopilotChatConfigurationProvider.vue +29 -2
- package/src/v2/providers/CopilotKitProvider.types.ts +57 -5
- package/src/v2/providers/CopilotKitProvider.vue +177 -114
- package/src/v2/providers/__tests__/CopilotChatConfigurationProvider.openThread.test.ts +69 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.a2ui.test.ts +1 -1
- package/src/v2/providers/__tests__/CopilotKitProvider.headersAtSendTime.test.ts +3 -3
- package/src/v2/providers/__tests__/CopilotKitProvider.learning.test.ts +536 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.test.ts +17 -33
- package/src/v2/providers/index.ts +4 -1
- package/src/v2/providers/keys.ts +12 -0
- package/src/v2/providers/types.ts +3 -38
- package/src/v2/styles/CopilotKitStyles.ts +95 -0
- package/src/v2/styles/__tests__/CopilotKitStyles.client.test.ts +149 -0
- package/src/v2/styles/__tests__/CopilotKitStyles.ssr.test.ts +71 -0
- package/src/v2/types/__tests__/defineToolCallRenderer.test.ts +28 -33
- package/src/v2/types/defineToolCallRenderer.ts +9 -4
- package/src/v2/types/human-in-the-loop.ts +8 -32
- package/src/v2/types/interrupt.ts +7 -31
- package/src/v2/types/vue-activity-message-renderer.ts +24 -15
- package/src/v2/types/vue-custom-message-renderer.ts +12 -16
- package/src/v2/types/vue-tool-call-renderer.ts +23 -31
- package/vite.config.ts +5 -5
- package/dist/styles.css +0 -2
- package/dist/v2/components/chat/BasicMarkdown.vue.d.ts +0 -9
- package/dist/v2/components/chat/BasicMarkdown.vue.d.ts.map +0 -1
- package/dist/v2/lib/transcription-client.d.ts +0 -19
- package/dist/v2/lib/transcription-client.d.ts.map +0 -1
- package/scripts/scope-preflight.mjs +0 -100
- package/src/styles/globals.css +0 -233
- package/src/v2/components/chat/BasicMarkdown.vue +0 -158
- package/src/v2/components/chat/__tests__/BasicMarkdown.test.ts +0 -69
- package/src/v2/lib/__tests__/processPartialHtml.test.ts +0 -84
- package/src/v2/lib/__tests__/transcription-client.test.ts +0 -67
- package/src/v2/lib/transcription-client.ts +0 -151
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import {
|
|
2
|
+
computed,
|
|
3
|
+
defineComponent,
|
|
4
|
+
getCurrentInstance,
|
|
5
|
+
h,
|
|
6
|
+
inject,
|
|
7
|
+
onActivated,
|
|
8
|
+
onDeactivated,
|
|
9
|
+
onUnmounted,
|
|
10
|
+
shallowRef,
|
|
11
|
+
} from "vue";
|
|
12
|
+
import type { AppContext, ShallowRef } from "vue";
|
|
13
|
+
import { stylesheet } from "@copilotkit/core/styles";
|
|
14
|
+
import { CopilotStyleOptionsKey } from "../providers/keys";
|
|
15
|
+
import type { CopilotStyleOptions } from "../providers/keys";
|
|
16
|
+
|
|
17
|
+
interface StylesInstance {
|
|
18
|
+
enabled: () => boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// The mounted instances of each app, in setup order. Keyed by app, so on the
|
|
22
|
+
// server each request's app has its own list.
|
|
23
|
+
const instancesByApp = new WeakMap<
|
|
24
|
+
AppContext,
|
|
25
|
+
ShallowRef<readonly StylesInstance[]>
|
|
26
|
+
>();
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Renders the CSS for CopilotKit's UI, so apps never import a stylesheet.
|
|
30
|
+
* `CopilotChat` (and so `CopilotPopup` and `CopilotSidebar`) renders it for
|
|
31
|
+
* you. Render it yourself only when you build a layout from the chat parts
|
|
32
|
+
* without `CopilotChat`.
|
|
33
|
+
*
|
|
34
|
+
* The `<style>` tag renders in place, so it is in the server HTML and the page
|
|
35
|
+
* is styled before it hydrates. Only the first instance in the app renders the
|
|
36
|
+
* tag, so a page with many chats has one copy. When that instance unmounts, the
|
|
37
|
+
* next one renders the tag in the same update. The server and the client set
|
|
38
|
+
* up instances in the same order, so hydration matches.
|
|
39
|
+
*
|
|
40
|
+
* Renders nothing when `CopilotKitProvider` has `:inject-styles="false"`.
|
|
41
|
+
*/
|
|
42
|
+
export const CopilotKitStyles = defineComponent({
|
|
43
|
+
name: "CopilotKitStyles",
|
|
44
|
+
setup() {
|
|
45
|
+
const options = inject(
|
|
46
|
+
CopilotStyleOptionsKey,
|
|
47
|
+
() => computed<CopilotStyleOptions>(() => ({ inject: true })),
|
|
48
|
+
true,
|
|
49
|
+
);
|
|
50
|
+
const appContext = getCurrentInstance()!.appContext;
|
|
51
|
+
let instances = instancesByApp.get(appContext);
|
|
52
|
+
if (!instances) {
|
|
53
|
+
instances = shallowRef([]);
|
|
54
|
+
instancesByApp.set(appContext, instances);
|
|
55
|
+
}
|
|
56
|
+
const list = instances;
|
|
57
|
+
const self: StylesInstance = { enabled: () => options.value.inject };
|
|
58
|
+
|
|
59
|
+
const add = () => {
|
|
60
|
+
if (!list.value.includes(self)) {
|
|
61
|
+
list.value = [...list.value, self];
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const remove = () => {
|
|
65
|
+
list.value = list.value.filter((instance) => instance !== self);
|
|
66
|
+
};
|
|
67
|
+
add();
|
|
68
|
+
onUnmounted(remove);
|
|
69
|
+
// A deactivated <KeepAlive> child is out of the document, so it can't
|
|
70
|
+
// hold the tag.
|
|
71
|
+
onDeactivated(remove);
|
|
72
|
+
onActivated(add);
|
|
73
|
+
|
|
74
|
+
const rendersTag = computed(
|
|
75
|
+
() => list.value.find((instance) => instance.enabled()) === self,
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
return () => {
|
|
79
|
+
if (!rendersTag.value) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
const { nonce } = options.value;
|
|
83
|
+
return h("style", {
|
|
84
|
+
"data-copilotkit-styles": "",
|
|
85
|
+
nonce,
|
|
86
|
+
// Browsers hide a nonce from the DOM, so hydration would see a
|
|
87
|
+
// mismatch that isn't one.
|
|
88
|
+
"data-allow-mismatch": nonce ? "attribute" : undefined,
|
|
89
|
+
// innerHTML, not a text child: the server would escape `>` in a text
|
|
90
|
+
// child, and inside <style> that breaks the CSS.
|
|
91
|
+
innerHTML: stylesheet,
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
},
|
|
95
|
+
});
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
createApp,
|
|
4
|
+
createSSRApp,
|
|
5
|
+
defineComponent,
|
|
6
|
+
h,
|
|
7
|
+
nextTick,
|
|
8
|
+
ref,
|
|
9
|
+
} from "vue";
|
|
10
|
+
import type { Component } from "vue";
|
|
11
|
+
import { renderToString } from "vue/server-renderer";
|
|
12
|
+
import { mount } from "@vue/test-utils";
|
|
13
|
+
import type { VueWrapper } from "@vue/test-utils";
|
|
14
|
+
import { stylesheet } from "@copilotkit/core/styles";
|
|
15
|
+
import CopilotKitProvider from "../../providers/CopilotKitProvider.vue";
|
|
16
|
+
import { StateCapturingAgent } from "../../__tests__/utils/agents";
|
|
17
|
+
import CopilotChat from "../../components/chat/CopilotChat.vue";
|
|
18
|
+
import CopilotKitV1 from "../../../components/copilot-provider/CopilotKit.vue";
|
|
19
|
+
import { CopilotKitStyles } from "../CopilotKitStyles";
|
|
20
|
+
|
|
21
|
+
const styleTags = () =>
|
|
22
|
+
document.querySelectorAll("style[data-copilotkit-styles]");
|
|
23
|
+
|
|
24
|
+
let wrapper: VueWrapper | undefined;
|
|
25
|
+
|
|
26
|
+
afterEach(() => {
|
|
27
|
+
wrapper?.unmount();
|
|
28
|
+
wrapper = undefined;
|
|
29
|
+
document.body.innerHTML = "";
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
function mountWithProvider(
|
|
33
|
+
children: () => unknown,
|
|
34
|
+
providerProps: Record<string, unknown> = {},
|
|
35
|
+
provider: Component = CopilotKitProvider as Component,
|
|
36
|
+
) {
|
|
37
|
+
wrapper = mount(provider, {
|
|
38
|
+
attachTo: document.body,
|
|
39
|
+
props: {
|
|
40
|
+
agents__unsafe_dev_only: { default: new StateCapturingAgent() },
|
|
41
|
+
...providerProps,
|
|
42
|
+
},
|
|
43
|
+
slots: { default: children },
|
|
44
|
+
});
|
|
45
|
+
return wrapper;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
describe("CopilotKitStyles in the browser", () => {
|
|
49
|
+
it("is rendered by CopilotChat, so apps don't import a stylesheet", () => {
|
|
50
|
+
mountWithProvider(() => h(CopilotChat, { welcomeScreen: false }));
|
|
51
|
+
|
|
52
|
+
const tags = styleTags();
|
|
53
|
+
expect(tags).toHaveLength(1);
|
|
54
|
+
expect(tags[0]!.textContent).toBe(stylesheet);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("keeps one copy for many chats, and keeps it while any chat is mounted", async () => {
|
|
58
|
+
const showFirst = ref(true);
|
|
59
|
+
const showSecond = ref(true);
|
|
60
|
+
mountWithProvider(() => [
|
|
61
|
+
showFirst.value ? h(CopilotChat, { welcomeScreen: false }) : null,
|
|
62
|
+
showSecond.value ? h(CopilotChat, { welcomeScreen: false }) : null,
|
|
63
|
+
]);
|
|
64
|
+
expect(styleTags()).toHaveLength(1);
|
|
65
|
+
|
|
66
|
+
// The first chat owns the tag. Unmounting it hands the tag on.
|
|
67
|
+
showFirst.value = false;
|
|
68
|
+
await nextTick();
|
|
69
|
+
expect(styleTags()).toHaveLength(1);
|
|
70
|
+
|
|
71
|
+
showFirst.value = true;
|
|
72
|
+
await nextTick();
|
|
73
|
+
expect(styleTags()).toHaveLength(1);
|
|
74
|
+
|
|
75
|
+
showFirst.value = false;
|
|
76
|
+
showSecond.value = false;
|
|
77
|
+
await nextTick();
|
|
78
|
+
expect(styleTags()).toHaveLength(0);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it("adds the CSP nonce to the style tag", () => {
|
|
82
|
+
mountWithProvider(() => h(CopilotKitStyles), { nonce: "abc123" });
|
|
83
|
+
|
|
84
|
+
const tags = styleTags();
|
|
85
|
+
expect(tags).toHaveLength(1);
|
|
86
|
+
expect(tags[0]!.getAttribute("nonce")).toBe("abc123");
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it("adds no style tag when the app loads styles.css itself", () => {
|
|
90
|
+
mountWithProvider(() => h(CopilotChat, { welcomeScreen: false }), {
|
|
91
|
+
injectStyles: false,
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
expect(styleTags()).toHaveLength(0);
|
|
95
|
+
expect(document.querySelectorAll("style")).toHaveLength(0);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it("injects through the v1 CopilotKit provider by default", () => {
|
|
99
|
+
mountWithProvider(() => h(CopilotKitStyles), {}, CopilotKitV1 as Component);
|
|
100
|
+
|
|
101
|
+
expect(styleTags()).toHaveLength(1);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it("injects without a provider", () => {
|
|
105
|
+
wrapper = mount(CopilotKitStyles, { attachTo: document.body });
|
|
106
|
+
|
|
107
|
+
expect(styleTags()).toHaveLength(1);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it("hydrates the server-rendered tag without a mismatch", async () => {
|
|
111
|
+
const Page = defineComponent({
|
|
112
|
+
render: () =>
|
|
113
|
+
h(
|
|
114
|
+
CopilotKitProvider as Component,
|
|
115
|
+
{ agents__unsafe_dev_only: { default: new StateCapturingAgent() } },
|
|
116
|
+
{ default: () => [h(CopilotKitStyles), h(CopilotKitStyles)] },
|
|
117
|
+
),
|
|
118
|
+
});
|
|
119
|
+
const container = document.createElement("div");
|
|
120
|
+
container.innerHTML = await renderToString(createSSRApp(Page));
|
|
121
|
+
document.body.appendChild(container);
|
|
122
|
+
const serverTag = styleTags()[0];
|
|
123
|
+
const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
|
|
124
|
+
const error = vi.spyOn(console, "error").mockImplementation(() => {});
|
|
125
|
+
|
|
126
|
+
const app = createSSRApp(Page);
|
|
127
|
+
app.mount(container);
|
|
128
|
+
await nextTick();
|
|
129
|
+
|
|
130
|
+
const mismatches = [...warn.mock.calls, ...error.mock.calls].filter(
|
|
131
|
+
(args) => String(args[0]).includes("Hydration"),
|
|
132
|
+
);
|
|
133
|
+
expect(mismatches).toEqual([]);
|
|
134
|
+
expect(styleTags()).toHaveLength(1);
|
|
135
|
+
expect(styleTags()[0]).toBe(serverTag);
|
|
136
|
+
app.unmount();
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it("gives separate apps on one page their own copy", () => {
|
|
140
|
+
const first = createApp({ render: () => h(CopilotKitStyles) });
|
|
141
|
+
const second = createApp({ render: () => h(CopilotKitStyles) });
|
|
142
|
+
first.mount(document.body.appendChild(document.createElement("div")));
|
|
143
|
+
second.mount(document.body.appendChild(document.createElement("div")));
|
|
144
|
+
|
|
145
|
+
expect(styleTags()).toHaveLength(2);
|
|
146
|
+
first.unmount();
|
|
147
|
+
second.unmount();
|
|
148
|
+
});
|
|
149
|
+
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// @vitest-environment node
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import { createSSRApp, h } from "vue";
|
|
4
|
+
import type { Component } from "vue";
|
|
5
|
+
import { renderToString } from "vue/server-renderer";
|
|
6
|
+
import { stylesheet } from "@copilotkit/core/styles";
|
|
7
|
+
import CopilotKitProvider from "../../providers/CopilotKitProvider.vue";
|
|
8
|
+
import { StateCapturingAgent } from "../../__tests__/utils/agents";
|
|
9
|
+
import { CopilotKitStyles } from "../CopilotKitStyles";
|
|
10
|
+
|
|
11
|
+
function renderPage(
|
|
12
|
+
children: () => unknown[],
|
|
13
|
+
providerProps: Record<string, unknown> = {},
|
|
14
|
+
): Promise<string> {
|
|
15
|
+
const app = createSSRApp({
|
|
16
|
+
render: () =>
|
|
17
|
+
h(
|
|
18
|
+
CopilotKitProvider as Component,
|
|
19
|
+
{
|
|
20
|
+
agents__unsafe_dev_only: { default: new StateCapturingAgent() },
|
|
21
|
+
...providerProps,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
default: children,
|
|
25
|
+
},
|
|
26
|
+
),
|
|
27
|
+
});
|
|
28
|
+
return renderToString(app);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
describe("CopilotKitStyles on the server", () => {
|
|
32
|
+
it("puts one copy of the stylesheet in the server HTML", async () => {
|
|
33
|
+
const html = await renderPage(() => [
|
|
34
|
+
h(CopilotKitStyles),
|
|
35
|
+
h(CopilotKitStyles),
|
|
36
|
+
]);
|
|
37
|
+
|
|
38
|
+
const tags = html.match(/<style[^>]*>/g) ?? [];
|
|
39
|
+
expect(tags).toHaveLength(1);
|
|
40
|
+
expect(tags[0]).toContain("data-copilotkit-styles");
|
|
41
|
+
// Unescaped, so selectors such as `a > b` still work.
|
|
42
|
+
expect(html).toContain(`>${stylesheet}</style>`);
|
|
43
|
+
expect(stylesheet).toContain(".cpk-suggestion-pill)");
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("gives each server-rendered app its own copy", async () => {
|
|
47
|
+
const first = await renderPage(() => [h(CopilotKitStyles)]);
|
|
48
|
+
const second = await renderPage(() => [h(CopilotKitStyles)]);
|
|
49
|
+
|
|
50
|
+
expect(first).toContain("<style");
|
|
51
|
+
expect(second).toContain("<style");
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("adds the CSP nonce to the style tag when the app passes one", async () => {
|
|
55
|
+
const html = await renderPage(() => [h(CopilotKitStyles)], {
|
|
56
|
+
nonce: "abc123",
|
|
57
|
+
});
|
|
58
|
+
const tags = html.match(/<style[^>]*>/g) ?? [];
|
|
59
|
+
|
|
60
|
+
expect(tags).toHaveLength(1);
|
|
61
|
+
expect(tags[0]).toContain('nonce="abc123"');
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("adds no style tag when the app loads styles.css itself", async () => {
|
|
65
|
+
const html = await renderPage(() => [h(CopilotKitStyles)], {
|
|
66
|
+
injectStyles: false,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
expect(html).not.toContain("<style");
|
|
70
|
+
});
|
|
71
|
+
});
|
|
@@ -2,11 +2,30 @@ import { describe, it, expect } from "vitest";
|
|
|
2
2
|
import { defineComponent, h } from "vue";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { ToolCallStatus } from "@copilotkit/core";
|
|
5
|
+
import type { VNode } from "vue";
|
|
5
6
|
import { defineToolCallRenderer } from "../defineToolCallRenderer";
|
|
6
|
-
import type {
|
|
7
|
+
import type {
|
|
8
|
+
VueToolCallRenderer,
|
|
9
|
+
VueToolCallRendererRenderProps,
|
|
10
|
+
} from "../vue-tool-call-renderer";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Calls a renderer built from a render function. `render` is typed as a
|
|
14
|
+
* function or a component, and TypeScript cannot tell which one this test
|
|
15
|
+
* passed, so the narrowing cast lives here once.
|
|
16
|
+
*/
|
|
17
|
+
function callRender<T>(
|
|
18
|
+
renderer: VueToolCallRenderer<T>,
|
|
19
|
+
props: VueToolCallRendererRenderProps<T>,
|
|
20
|
+
) {
|
|
21
|
+
const render = renderer.render as (
|
|
22
|
+
props: VueToolCallRendererRenderProps<T>,
|
|
23
|
+
) => VNode;
|
|
24
|
+
return render(props);
|
|
25
|
+
}
|
|
7
26
|
|
|
8
27
|
describe("defineToolCallRenderer", () => {
|
|
9
|
-
it("defaults wildcard args to
|
|
28
|
+
it("defaults wildcard args to a schema that accepts any value and preserves runtime tool name", () => {
|
|
10
29
|
const wildcardRenderer = defineToolCallRenderer({
|
|
11
30
|
name: "*",
|
|
12
31
|
render: ({ name, args, status }) =>
|
|
@@ -18,19 +37,11 @@ describe("defineToolCallRenderer", () => {
|
|
|
18
37
|
});
|
|
19
38
|
|
|
20
39
|
expect(wildcardRenderer.name).toBe("*");
|
|
21
|
-
expect(
|
|
22
|
-
true,
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
const rendered = (
|
|
26
|
-
wildcardRenderer.render as (props: {
|
|
27
|
-
name: string;
|
|
28
|
-
toolCallId: string;
|
|
29
|
-
args: Record<string, unknown>;
|
|
30
|
-
status: ToolCallStatus;
|
|
31
|
-
result: string | undefined;
|
|
32
|
-
}) => ReturnType<typeof h>
|
|
33
|
-
)({
|
|
40
|
+
expect(
|
|
41
|
+
wildcardRenderer.args["~standard"].validate({ anything: true }),
|
|
42
|
+
).toEqual({ value: { anything: true } });
|
|
43
|
+
|
|
44
|
+
const rendered = callRender(wildcardRenderer, {
|
|
34
45
|
name: "customTool",
|
|
35
46
|
toolCallId: "tc-wildcard-1",
|
|
36
47
|
args: { x: 1 },
|
|
@@ -53,15 +64,7 @@ describe("defineToolCallRenderer", () => {
|
|
|
53
64
|
),
|
|
54
65
|
});
|
|
55
66
|
|
|
56
|
-
const rendered = (
|
|
57
|
-
wildcardRenderer.render as (props: {
|
|
58
|
-
name: string;
|
|
59
|
-
toolCallId: string;
|
|
60
|
-
args: Record<string, unknown>;
|
|
61
|
-
status: ToolCallStatus;
|
|
62
|
-
result: string | undefined;
|
|
63
|
-
}) => ReturnType<typeof h>
|
|
64
|
-
)({
|
|
67
|
+
const rendered = callRender(wildcardRenderer, {
|
|
65
68
|
name: "customTool",
|
|
66
69
|
toolCallId: "tc-123",
|
|
67
70
|
args: {},
|
|
@@ -136,15 +139,7 @@ describe("defineToolCallRenderer", () => {
|
|
|
136
139
|
},
|
|
137
140
|
});
|
|
138
141
|
|
|
139
|
-
const rendered = (
|
|
140
|
-
typedRenderer.render as (props: {
|
|
141
|
-
name: string;
|
|
142
|
-
toolCallId: string;
|
|
143
|
-
args: { location: string; units?: "celsius" | "fahrenheit" };
|
|
144
|
-
status: ToolCallStatus;
|
|
145
|
-
result: string | undefined;
|
|
146
|
-
}) => ReturnType<typeof h>
|
|
147
|
-
)({
|
|
142
|
+
const rendered = callRender(typedRenderer, {
|
|
148
143
|
name: "get_weather",
|
|
149
144
|
toolCallId: "tc-weather-1",
|
|
150
145
|
args: { location: "Paris", units: "celsius" },
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ɵanySchema } from "@copilotkit/shared";
|
|
2
2
|
import type { StandardSchemaV1, InferSchemaOutput } from "@copilotkit/shared";
|
|
3
3
|
import type { VueToolCallRenderer } from "./vue-tool-call-renderer";
|
|
4
4
|
import type { VueToolCallRendererRenderFn } from "./vue-tool-call-renderer";
|
|
@@ -7,6 +7,7 @@ export function defineToolCallRenderer(def: {
|
|
|
7
7
|
name: "*";
|
|
8
8
|
render: VueToolCallRendererRenderFn<unknown>;
|
|
9
9
|
agentId?: string;
|
|
10
|
+
group?: boolean;
|
|
10
11
|
}): VueToolCallRenderer<unknown>;
|
|
11
12
|
|
|
12
13
|
export function defineToolCallRenderer<S extends StandardSchemaV1>(def: {
|
|
@@ -14,6 +15,7 @@ export function defineToolCallRenderer<S extends StandardSchemaV1>(def: {
|
|
|
14
15
|
args: S;
|
|
15
16
|
render: VueToolCallRendererRenderFn<InferSchemaOutput<S>>;
|
|
16
17
|
agentId?: string;
|
|
18
|
+
group?: boolean;
|
|
17
19
|
}): VueToolCallRenderer<InferSchemaOutput<S>>;
|
|
18
20
|
|
|
19
21
|
export function defineToolCallRenderer<S extends StandardSchemaV1>(def: {
|
|
@@ -21,12 +23,15 @@ export function defineToolCallRenderer<S extends StandardSchemaV1>(def: {
|
|
|
21
23
|
args?: S;
|
|
22
24
|
render: VueToolCallRendererRenderFn<unknown>;
|
|
23
25
|
agentId?: string;
|
|
26
|
+
group?: boolean;
|
|
24
27
|
}): VueToolCallRenderer<unknown> {
|
|
25
|
-
|
|
28
|
+
// Only a "*" renderer may leave out `args`; it accepts any arguments.
|
|
29
|
+
const args = def.args ?? ɵanySchema;
|
|
26
30
|
return {
|
|
27
31
|
name: def.name,
|
|
28
|
-
args
|
|
29
|
-
render: def.render
|
|
32
|
+
args,
|
|
33
|
+
render: def.render,
|
|
30
34
|
...(def.agentId ? { agentId: def.agentId } : {}),
|
|
35
|
+
...(def.group ? { group: true } : {}),
|
|
31
36
|
};
|
|
32
37
|
}
|
|
@@ -1,37 +1,13 @@
|
|
|
1
|
-
import type { FrontendTool,
|
|
1
|
+
import type { FrontendTool, HumanInTheLoopRenderProps } from "@copilotkit/core";
|
|
2
2
|
import type { Component, VNodeChild } from "vue";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
status: ToolCallStatus.InProgress;
|
|
12
|
-
result: undefined;
|
|
13
|
-
respond: undefined;
|
|
14
|
-
}
|
|
15
|
-
| {
|
|
16
|
-
name: string;
|
|
17
|
-
description: string;
|
|
18
|
-
toolCallId: string;
|
|
19
|
-
agentId?: string;
|
|
20
|
-
args: T;
|
|
21
|
-
status: ToolCallStatus.Executing;
|
|
22
|
-
result: undefined;
|
|
23
|
-
respond: (result: unknown) => Promise<void>;
|
|
24
|
-
}
|
|
25
|
-
| {
|
|
26
|
-
name: string;
|
|
27
|
-
description: string;
|
|
28
|
-
toolCallId: string;
|
|
29
|
-
agentId?: string;
|
|
30
|
-
args: T;
|
|
31
|
-
status: ToolCallStatus.Complete;
|
|
32
|
-
result: string;
|
|
33
|
-
respond: undefined;
|
|
34
|
-
};
|
|
4
|
+
/**
|
|
5
|
+
* Props a Vue human-in-the-loop renderer receives. Same as core's
|
|
6
|
+
* `HumanInTheLoopRenderProps`.
|
|
7
|
+
*
|
|
8
|
+
* @typeParam T - The shape of the tool arguments.
|
|
9
|
+
*/
|
|
10
|
+
export type VueHumanInTheLoopRenderProps<T> = HumanInTheLoopRenderProps<T>;
|
|
35
11
|
|
|
36
12
|
export type VueHumanInTheLoopRenderFn<T> =
|
|
37
13
|
| ((props: VueHumanInTheLoopRenderProps<T>) => VNodeChild)
|
|
@@ -1,31 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export type InterruptResolveFn = (
|
|
9
|
-
payload?: unknown,
|
|
10
|
-
interruptId?: string,
|
|
11
|
-
) => Promise<RunAgentResult | void>;
|
|
12
|
-
export type InterruptCancelFn = (
|
|
13
|
-
interruptId?: string,
|
|
14
|
-
) => Promise<RunAgentResult | void>;
|
|
15
|
-
|
|
16
|
-
export interface InterruptHandlerProps<TValue = unknown> {
|
|
17
|
-
event: InterruptEvent<TValue>;
|
|
18
|
-
interrupt: Interrupt | null;
|
|
19
|
-
interrupts: Interrupt[];
|
|
20
|
-
resolve: InterruptResolveFn;
|
|
21
|
-
cancel: InterruptCancelFn;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface InterruptRenderProps<TValue = unknown, TResult = unknown> {
|
|
25
|
-
event: InterruptEvent<TValue>;
|
|
26
|
-
interrupt: Interrupt | null;
|
|
27
|
-
interrupts: Interrupt[];
|
|
28
|
-
result: TResult;
|
|
29
|
-
resolve: InterruptResolveFn;
|
|
30
|
-
cancel: InterruptCancelFn;
|
|
31
|
-
}
|
|
1
|
+
export type {
|
|
2
|
+
InterruptEvent,
|
|
3
|
+
InterruptResolveFn,
|
|
4
|
+
InterruptCancelFn,
|
|
5
|
+
InterruptHandlerProps,
|
|
6
|
+
InterruptRenderProps,
|
|
7
|
+
} from "@copilotkit/core";
|
|
@@ -1,22 +1,31 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type {
|
|
2
|
+
ActivityMessageRenderProps,
|
|
3
|
+
ActivityMessageRendererDef,
|
|
4
|
+
} from "@copilotkit/core";
|
|
4
5
|
import type { Component, VNodeChild } from "vue";
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Props a Vue activity message renderer receives. Same as core's
|
|
9
|
+
* `ActivityMessageRenderProps`.
|
|
10
|
+
*
|
|
11
|
+
* @typeParam TActivityContent - The shape of the activity content.
|
|
12
|
+
*/
|
|
13
|
+
export type VueActivityMessageRendererProps<TActivityContent> =
|
|
14
|
+
ActivityMessageRenderProps<TActivityContent>;
|
|
12
15
|
|
|
13
16
|
export type VueActivityMessageRendererRenderFn<TActivityContent> =
|
|
14
17
|
| ((props: VueActivityMessageRendererProps<TActivityContent>) => VNodeChild)
|
|
15
18
|
| Component<VueActivityMessageRendererProps<TActivityContent>>;
|
|
16
19
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
/**
|
|
21
|
+
* A Vue activity message renderer registration. `content` takes any
|
|
22
|
+
* Standard Schema (zod, valibot, arktype, and so on). The chat validates the
|
|
23
|
+
* activity content with it and passes the result to `render`.
|
|
24
|
+
*
|
|
25
|
+
* @typeParam TActivityContent - The shape of the activity content.
|
|
26
|
+
*/
|
|
27
|
+
export type VueActivityMessageRenderer<TActivityContent> =
|
|
28
|
+
ActivityMessageRendererDef<
|
|
29
|
+
TActivityContent,
|
|
30
|
+
VueActivityMessageRendererRenderFn<TActivityContent>
|
|
31
|
+
>;
|
|
@@ -1,24 +1,20 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
CustomMessageRendererDef,
|
|
3
|
+
CustomMessageRendererPosition,
|
|
4
|
+
CustomMessageRenderProps,
|
|
5
|
+
} from "@copilotkit/core";
|
|
2
6
|
import type { Component, VNodeChild } from "vue";
|
|
3
7
|
|
|
4
|
-
|
|
8
|
+
/** Where a custom message renderer draws. Same as core's type. */
|
|
9
|
+
export type VueCustomMessageRendererPosition = CustomMessageRendererPosition;
|
|
5
10
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
position: VueCustomMessageRendererPosition;
|
|
9
|
-
runId: string;
|
|
10
|
-
messageIndex: number;
|
|
11
|
-
messageIndexInRun: number;
|
|
12
|
-
numberOfMessagesInRun: number;
|
|
13
|
-
agentId: string;
|
|
14
|
-
stateSnapshot: unknown;
|
|
15
|
-
}
|
|
11
|
+
/** Props a Vue custom message renderer receives. Same as core's type. */
|
|
12
|
+
export type VueCustomMessageRendererProps = CustomMessageRenderProps;
|
|
16
13
|
|
|
17
14
|
export type VueCustomMessageRendererRenderFn =
|
|
18
15
|
| ((props: VueCustomMessageRendererProps) => VNodeChild)
|
|
19
16
|
| Component<VueCustomMessageRendererProps>;
|
|
20
17
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
18
|
+
/** A Vue custom message renderer registration. */
|
|
19
|
+
export type VueCustomMessageRenderer =
|
|
20
|
+
CustomMessageRendererDef<VueCustomMessageRendererRenderFn>;
|
|
@@ -1,32 +1,16 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type {
|
|
2
|
+
ToolCallRenderProps,
|
|
3
|
+
ToolCallRendererDef,
|
|
4
|
+
} from "@copilotkit/core";
|
|
3
5
|
import type { Component, VNodeChild } from "vue";
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
|
-
* Props passed to a Vue tool call render function.
|
|
8
|
+
* Props passed to a Vue tool call render function. Same as core's
|
|
9
|
+
* `ToolCallRenderProps`.
|
|
10
|
+
*
|
|
11
|
+
* @typeParam T - The shape of the tool arguments.
|
|
7
12
|
*/
|
|
8
|
-
export type VueToolCallRendererRenderProps<T> =
|
|
9
|
-
| {
|
|
10
|
-
name: string;
|
|
11
|
-
toolCallId: string;
|
|
12
|
-
args: Partial<T>;
|
|
13
|
-
status: ToolCallStatus.InProgress;
|
|
14
|
-
result: undefined;
|
|
15
|
-
}
|
|
16
|
-
| {
|
|
17
|
-
name: string;
|
|
18
|
-
toolCallId: string;
|
|
19
|
-
args: T;
|
|
20
|
-
status: ToolCallStatus.Executing;
|
|
21
|
-
result: undefined;
|
|
22
|
-
}
|
|
23
|
-
| {
|
|
24
|
-
name: string;
|
|
25
|
-
toolCallId: string;
|
|
26
|
-
args: T;
|
|
27
|
-
status: ToolCallStatus.Complete;
|
|
28
|
-
result: string;
|
|
29
|
-
};
|
|
13
|
+
export type VueToolCallRendererRenderProps<T> = ToolCallRenderProps<T>;
|
|
30
14
|
|
|
31
15
|
/**
|
|
32
16
|
* Vue component or render function for tool call rendering.
|
|
@@ -36,9 +20,17 @@ export type VueToolCallRendererRenderFn<T> =
|
|
|
36
20
|
| ((props: VueToolCallRendererRenderProps<T>) => VNodeChild)
|
|
37
21
|
| Component<VueToolCallRendererRenderProps<T>>;
|
|
38
22
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
23
|
+
type VueToolCallRendererDef<T> = ToolCallRendererDef<
|
|
24
|
+
T,
|
|
25
|
+
VueToolCallRendererRenderFn<T>
|
|
26
|
+
>;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* A Vue tool call renderer registration: core's `ToolCallRendererDef` with a
|
|
30
|
+
* Vue render function. `args` is required here. Use `defineToolCallRenderer`
|
|
31
|
+
* to build one; it fills in `args` for a `"*"` renderer that has no schema.
|
|
32
|
+
*
|
|
33
|
+
* @typeParam T - The shape of the tool arguments.
|
|
34
|
+
*/
|
|
35
|
+
export type VueToolCallRenderer<T = unknown> = VueToolCallRendererDef<T> &
|
|
36
|
+
Required<Pick<VueToolCallRendererDef<T>, "args">>;
|