@copilotkit/vue 2.0.0-rc.0 → 2.0.0-rc.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/PARITY.md +13 -12
- package/README.md +1 -2
- package/dist/components/copilot-provider/CopilotKit.vue.d.ts +3 -1
- package/dist/components/copilot-provider/CopilotKit.vue.d.ts.map +1 -1
- package/dist/hooks/use-copilot-action.d.ts.map +1 -1
- package/dist/hooks/use-frontend-tool.d.ts +1 -1
- package/dist/hooks/use-frontend-tool.d.ts.map +1 -1
- package/dist/hooks/zod-parameters.d.ts +14 -0
- package/dist/hooks/zod-parameters.d.ts.map +1 -0
- package/dist/index.cjs +1 -76
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +384 -14275
- package/dist/index.mjs.map +1 -1
- package/dist/use-render-activity-message-CTR_ziWV.js +18097 -0
- package/dist/use-render-activity-message-CTR_ziWV.js.map +1 -0
- package/dist/use-render-activity-message-Dky9_GRG.cjs +92 -0
- package/dist/use-render-activity-message-Dky9_GRG.cjs.map +1 -0
- package/dist/v2/components/A2UIMessageRenderer.d.ts +7 -0
- package/dist/v2/components/A2UIMessageRenderer.d.ts.map +1 -1
- package/dist/v2/components/A2UISurfaceActivityRenderer.vue.d.ts.map +1 -1
- package/dist/v2/components/LicenseWarningBanner.vue.d.ts.map +1 -1
- package/dist/v2/components/OpenGenerativeUIRenderer.d.ts +13 -45
- package/dist/v2/components/OpenGenerativeUIRenderer.d.ts.map +1 -1
- package/dist/v2/components/a2ui/A2UIBuiltInToolCallRenderer.d.ts +11 -2
- package/dist/v2/components/a2ui/A2UIBuiltInToolCallRenderer.d.ts.map +1 -1
- package/dist/v2/components/a2ui/A2UICatalogContext.d.ts +1 -1
- package/dist/v2/components/a2ui/A2UICatalogContext.d.ts.map +1 -1
- package/dist/v2/components/a2ui/A2UIRecoveryStates.d.ts +144 -0
- package/dist/v2/components/a2ui/A2UIRecoveryStates.d.ts.map +1 -0
- package/dist/v2/components/a2ui.d.ts +3 -7
- package/dist/v2/components/a2ui.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChat.vue.d.ts +1 -0
- package/dist/v2/components/chat/CopilotChat.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatAssistantMessage.vue.d.ts +3 -1
- package/dist/v2/components/chat/CopilotChatAssistantMessage.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatAssistantToolbarButton.vue.d.ts +16 -0
- package/dist/v2/components/chat/CopilotChatAssistantToolbarButton.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatAttachmentQueue.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatAttachmentRenderer.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatAudioRecorder.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatFeedbackCommentPopover.vue.d.ts +22 -0
- package/dist/v2/components/chat/CopilotChatFeedbackCommentPopover.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatInput.vue.d.ts +21 -232
- package/dist/v2/components/chat/CopilotChatInput.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatInspectorButton.vue.d.ts +12 -0
- package/dist/v2/components/chat/CopilotChatInspectorButton.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatLightbox.vue.d.ts +22 -0
- package/dist/v2/components/chat/CopilotChatLightbox.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatMessageView.vue.d.ts +20 -0
- package/dist/v2/components/chat/CopilotChatMessageView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatReasoningMessage.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatSuggestionPill.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatSuggestionView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatToggleButton.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatToolCallGroup.vue.d.ts +32 -0
- package/dist/v2/components/chat/CopilotChatToolCallGroup.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatToolCallItem.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatToolCallsView.vue.d.ts +11 -1
- package/dist/v2/components/chat/CopilotChatToolCallsView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatUserMessage.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatView.vue.d.ts +1 -0
- package/dist/v2/components/chat/CopilotChatView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatWorkSummary.vue.d.ts +5 -0
- package/dist/v2/components/chat/CopilotChatWorkSummary.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotModalHeader.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotModalHeaderCloseButton.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotModalHeaderTitle.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotPopup.vue.d.ts +1 -0
- package/dist/v2/components/chat/CopilotPopup.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotPopupView.vue.d.ts +1 -0
- package/dist/v2/components/chat/CopilotPopupView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotPopupViewInternal.vue.d.ts +1 -0
- package/dist/v2/components/chat/CopilotPopupViewInternal.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotPopupWelcomeScreen.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotSidebar.vue.d.ts +2 -0
- package/dist/v2/components/chat/CopilotSidebar.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotSidebarView.vue.d.ts +2 -0
- package/dist/v2/components/chat/CopilotSidebarView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotSidebarViewInternal.vue.d.ts +2 -0
- package/dist/v2/components/chat/CopilotSidebarViewInternal.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotSidebarWelcomeScreen.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/StreamingMarkdownDefault.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/copilotChatToolCallItemRender.d.ts +0 -1
- package/dist/v2/components/chat/copilotChatToolCallItemRender.d.ts.map +1 -1
- package/dist/v2/components/chat/index.d.ts +17 -1
- package/dist/v2/components/chat/index.d.ts.map +1 -1
- package/dist/v2/components/chat/inspector-shortcuts.d.ts +12 -0
- package/dist/v2/components/chat/inspector-shortcuts.d.ts.map +1 -0
- package/dist/v2/components/chat/message-feedback.d.ts +89 -0
- package/dist/v2/components/chat/message-feedback.d.ts.map +1 -0
- package/dist/v2/components/chat/tool-call-capture.d.ts +39 -0
- package/dist/v2/components/chat/tool-call-capture.d.ts.map +1 -0
- package/dist/v2/components/chat/tool-call-display-context.d.ts +22 -0
- package/dist/v2/components/chat/tool-call-display-context.d.ts.map +1 -0
- package/dist/v2/components/chat/tool-call-group-parts.d.ts +131 -0
- package/dist/v2/components/chat/tool-call-group-parts.d.ts.map +1 -0
- package/dist/v2/components/chat/turn-work.d.ts +33 -0
- package/dist/v2/components/chat/turn-work.d.ts.map +1 -0
- package/dist/v2/components/chat/types.d.ts +104 -5
- package/dist/v2/components/chat/types.d.ts.map +1 -1
- package/dist/v2/components/chat/use-chat-labels.d.ts +8 -0
- package/dist/v2/components/chat/use-chat-labels.d.ts.map +1 -0
- package/dist/v2/components/chat/use-lightbox.d.ts +18 -0
- package/dist/v2/components/chat/use-lightbox.d.ts.map +1 -0
- package/dist/v2/components/icons/index.d.ts +968 -1
- package/dist/v2/components/icons/index.d.ts.map +1 -1
- package/dist/v2/components/ui/CopilotDropdownMenuContent.vue.d.ts +55 -0
- package/dist/v2/components/ui/CopilotDropdownMenuContent.vue.d.ts.map +1 -0
- package/dist/v2/components/ui/CopilotPopover.vue.d.ts +40 -0
- package/dist/v2/components/ui/CopilotPopover.vue.d.ts.map +1 -0
- package/dist/v2/components/ui/CopilotTooltip.vue.d.ts +37 -0
- package/dist/v2/components/ui/CopilotTooltip.vue.d.ts.map +1 -0
- package/dist/v2/components/ui/dropdown-menu.d.ts +14 -0
- package/dist/v2/components/ui/dropdown-menu.d.ts.map +1 -0
- package/dist/v2/components/ui/floating.d.ts +84 -0
- package/dist/v2/components/ui/floating.d.ts.map +1 -0
- package/dist/v2/components/ui/presence.d.ts +9 -0
- package/dist/v2/components/ui/presence.d.ts.map +1 -0
- package/dist/v2/components/ui/use-id.d.ts +9 -0
- package/dist/v2/components/ui/use-id.d.ts.map +1 -0
- package/dist/v2/hooks/use-default-render-tool.d.ts +6 -0
- package/dist/v2/hooks/use-default-render-tool.d.ts.map +1 -1
- package/dist/v2/hooks/use-frontend-tool.d.ts +5 -0
- package/dist/v2/hooks/use-frontend-tool.d.ts.map +1 -1
- package/dist/v2/hooks/use-render-activity-message.d.ts +13 -9
- package/dist/v2/hooks/use-render-activity-message.d.ts.map +1 -1
- package/dist/v2/hooks/use-render-custom-messages.d.ts +5 -7
- package/dist/v2/hooks/use-render-custom-messages.d.ts.map +1 -1
- package/dist/v2/hooks/use-render-tool.d.ts +4 -0
- package/dist/v2/hooks/use-render-tool.d.ts.map +1 -1
- package/dist/v2/index.cjs +1 -1
- package/dist/v2/index.d.cts +3 -0
- package/dist/v2/index.d.mts +3 -0
- package/dist/v2/index.d.ts +3 -0
- package/dist/v2/index.d.ts.map +1 -1
- package/dist/v2/index.mjs +197 -197
- package/dist/v2/index.mjs.map +1 -1
- package/dist/v2/lib/message-feedback.d.ts +33 -0
- package/dist/v2/lib/message-feedback.d.ts.map +1 -0
- package/dist/v2/lib/processPartialHtml.d.ts +1 -2
- package/dist/v2/lib/processPartialHtml.d.ts.map +1 -1
- package/dist/v2/lib/vue-core.d.ts +0 -1
- package/dist/v2/lib/vue-core.d.ts.map +1 -1
- package/dist/v2/providers/CopilotChatConfigurationProvider.vue.d.ts.map +1 -1
- package/dist/v2/providers/CopilotKitProvider.types.d.ts +56 -6
- package/dist/v2/providers/CopilotKitProvider.types.d.ts.map +1 -1
- package/dist/v2/providers/CopilotKitProvider.vue.d.ts +6 -2
- package/dist/v2/providers/CopilotKitProvider.vue.d.ts.map +1 -1
- package/dist/v2/providers/index.d.ts +1 -1
- package/dist/v2/providers/index.d.ts.map +1 -1
- package/dist/v2/providers/keys.d.ts +8 -0
- package/dist/v2/providers/keys.d.ts.map +1 -1
- package/dist/v2/providers/types.d.ts +3 -37
- package/dist/v2/providers/types.d.ts.map +1 -1
- package/dist/v2/styles/CopilotKitStyles.d.ts +18 -0
- package/dist/v2/styles/CopilotKitStyles.d.ts.map +1 -0
- package/dist/v2/types/defineToolCallRenderer.d.ts +2 -0
- package/dist/v2/types/defineToolCallRenderer.d.ts.map +1 -1
- package/dist/v2/types/human-in-the-loop.d.ts +8 -29
- package/dist/v2/types/human-in-the-loop.d.ts.map +1 -1
- package/dist/v2/types/interrupt.d.ts +1 -22
- package/dist/v2/types/interrupt.d.ts.map +1 -1
- package/dist/v2/types/vue-activity-message-renderer.d.ts +16 -15
- package/dist/v2/types/vue-activity-message-renderer.d.ts.map +1 -1
- package/dist/v2/types/vue-custom-message-renderer.d.ts +7 -16
- package/dist/v2/types/vue-custom-message-renderer.d.ts.map +1 -1
- package/dist/v2/types/vue-tool-call-renderer.d.ts +16 -28
- package/dist/v2/types/vue-tool-call-renderer.d.ts.map +1 -1
- package/package.json +14 -27
- package/src/__tests__/build-entries.test.ts +27 -0
- package/src/components/copilot-provider/CopilotKit.vue +4 -1
- package/src/hooks/__tests__/zod-parameters.test.ts +520 -0
- package/src/hooks/use-copilot-action.ts +2 -1
- package/src/hooks/use-frontend-tool.ts +3 -6
- package/src/hooks/zod-parameters.ts +162 -0
- package/src/v2/__tests__/exports.test.ts +4 -2
- package/src/v2/components/A2UIMessageRenderer.ts +56 -68
- package/src/v2/components/A2UISurfaceActivityRenderer.vue +11 -23
- package/src/v2/components/LicenseWarningBanner.vue +31 -15
- package/src/v2/components/OpenGenerativeUIRenderer.ts +51 -373
- package/src/v2/components/__tests__/A2UIBasicCatalogColors.test.ts +8 -9
- package/src/v2/components/__tests__/A2UICatalogContext.test.ts +1 -1
- package/src/v2/components/__tests__/A2UIMessageRenderer.test.ts +63 -36
- package/src/v2/components/__tests__/LicenseWarningBanner.test.ts +20 -0
- package/src/v2/components/__tests__/OpenGenerativeUIRenderer.test.ts +55 -6
- package/src/v2/components/a2ui/A2UIBuiltInToolCallRenderer.ts +15 -258
- package/src/v2/components/a2ui/A2UICatalogContext.ts +10 -102
- package/src/v2/components/a2ui/A2UIRecoveryStates.ts +444 -0
- package/src/v2/components/a2ui/__tests__/A2UIRecoveryStates.test.ts +175 -0
- package/src/v2/components/a2ui.ts +1 -1
- package/src/v2/components/chat/CopilotChat.vue +26 -40
- package/src/v2/components/chat/CopilotChatAssistantMessage.vue +267 -67
- package/src/v2/components/chat/CopilotChatAssistantToolbarButton.vue +46 -0
- package/src/v2/components/chat/CopilotChatAttachmentQueue.vue +150 -173
- package/src/v2/components/chat/CopilotChatAttachmentRenderer.vue +77 -20
- package/src/v2/components/chat/CopilotChatAudioRecorder.vue +2 -2
- package/src/v2/components/chat/CopilotChatFeedbackCommentPopover.vue +240 -0
- package/src/v2/components/chat/CopilotChatInput.vue +250 -191
- package/src/v2/components/chat/CopilotChatInspectorButton.vue +331 -0
- package/src/v2/components/chat/CopilotChatLightbox.vue +105 -0
- package/src/v2/components/chat/CopilotChatMessageView.vue +262 -87
- package/src/v2/components/chat/CopilotChatReasoningMessage.vue +52 -35
- package/src/v2/components/chat/CopilotChatSuggestionPill.vue +5 -14
- package/src/v2/components/chat/CopilotChatSuggestionView.vue +1 -4
- package/src/v2/components/chat/CopilotChatToggleButton.vue +3 -9
- package/src/v2/components/chat/CopilotChatToggleButtonCloseIcon.ts +1 -1
- package/src/v2/components/chat/CopilotChatToggleButtonOpenIcon.ts +1 -1
- package/src/v2/components/chat/CopilotChatToolCallGroup.vue +353 -0
- package/src/v2/components/chat/CopilotChatToolCallItem.vue +24 -14
- package/src/v2/components/chat/CopilotChatToolCallsView.vue +194 -21
- package/src/v2/components/chat/CopilotChatUserMessage.vue +105 -42
- package/src/v2/components/chat/CopilotChatView.vue +37 -42
- package/src/v2/components/chat/CopilotChatWorkSummary.vue +111 -0
- package/src/v2/components/chat/CopilotModalHeader.vue +10 -8
- package/src/v2/components/chat/CopilotModalHeaderCloseButton.ts +7 -6
- package/src/v2/components/chat/CopilotModalHeaderTitle.ts +1 -4
- package/src/v2/components/chat/CopilotPopup.vue +3 -0
- package/src/v2/components/chat/CopilotPopupView.vue +1 -0
- package/src/v2/components/chat/CopilotPopupViewInternal.vue +9 -19
- package/src/v2/components/chat/CopilotPopupWelcomeScreen.vue +5 -8
- package/src/v2/components/chat/CopilotSidebar.vue +5 -0
- package/src/v2/components/chat/CopilotSidebarView.vue +2 -0
- package/src/v2/components/chat/CopilotSidebarViewInternal.vue +24 -17
- package/src/v2/components/chat/CopilotSidebarWelcomeScreen.vue +7 -10
- package/src/v2/components/chat/StreamingMarkdownDefault.vue +3 -5
- package/src/v2/components/chat/__tests__/CopilotChat.labels.test.ts +19 -4
- package/src/v2/components/chat/__tests__/CopilotChatActivityRendering.e2e.test.ts +26 -9
- package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.inspector.test.ts +269 -0
- package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.learningFeedback.test.ts +760 -0
- package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.slots.e2e.test.ts +3 -5
- package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.test.ts +2 -2
- package/src/v2/components/chat/__tests__/CopilotChatInput.addMenu.test.ts +328 -0
- package/src/v2/components/chat/__tests__/CopilotChatInput.slots.e2e.test.ts +6 -3
- package/src/v2/components/chat/__tests__/CopilotChatInput.test.ts +55 -14
- package/src/v2/components/chat/__tests__/CopilotChatLightbox.test.ts +160 -0
- package/src/v2/components/chat/__tests__/CopilotChatMessageView.test.ts +247 -403
- package/src/v2/components/chat/__tests__/CopilotChatMessageView.toolCallDisplay.test.ts +637 -0
- package/src/v2/components/chat/__tests__/CopilotChatSuggestionPill.test.ts +1 -1
- package/src/v2/components/chat/__tests__/CopilotChatSuggestionView.slots.e2e.test.ts +3 -1
- package/src/v2/components/chat/__tests__/CopilotChatToolCallsView.learning.test.ts +75 -0
- package/src/v2/components/chat/__tests__/CopilotChatUserMessage.attachments.test.ts +143 -0
- package/src/v2/components/chat/__tests__/CopilotChatView.inputOverlay.test.ts +5 -4
- package/src/v2/components/chat/__tests__/CopilotChatView.rootWidth.test.ts +7 -33
- package/src/v2/components/chat/__tests__/CopilotModalHeader.slots.e2e.test.ts +1 -1
- package/src/v2/components/chat/__tests__/CopilotPopupView.slots.e2e.test.ts +3 -3
- package/src/v2/components/chat/__tests__/CopilotSidebarView.position.test.ts +126 -0
- package/src/v2/components/chat/__tests__/messageFeedbackDefaults.test.ts +33 -0
- package/src/v2/components/chat/__tests__/modalChatDisplayProps.test.ts +44 -0
- package/src/v2/components/chat/copilotChatToolCallItemRender.ts +3 -19
- package/src/v2/components/chat/index.ts +2 -1
- package/src/v2/components/chat/inspector-shortcuts.ts +34 -0
- package/src/v2/components/chat/message-feedback.ts +291 -0
- package/src/v2/components/chat/tool-call-capture.ts +55 -0
- package/src/v2/components/chat/tool-call-display-context.ts +28 -0
- package/src/v2/components/chat/tool-call-group-parts.ts +251 -0
- package/src/v2/components/chat/turn-work.ts +52 -0
- package/src/v2/components/chat/types.ts +114 -4
- package/src/v2/components/chat/use-chat-labels.ts +16 -0
- package/src/v2/components/chat/use-lightbox.ts +64 -0
- package/src/v2/components/icons/__tests__/icons.test.ts +72 -68
- package/src/v2/components/icons/index.ts +109 -23
- package/src/v2/components/ui/CopilotDropdownMenuContent.vue +465 -0
- package/src/v2/components/ui/CopilotPopover.vue +138 -0
- package/src/v2/components/ui/CopilotTooltip.vue +237 -0
- package/src/v2/components/ui/__tests__/CopilotTooltip.test.ts +168 -0
- package/src/v2/components/ui/dropdown-menu.ts +15 -0
- package/src/v2/components/ui/floating.ts +321 -0
- package/src/v2/components/ui/presence.ts +54 -0
- package/src/v2/components/ui/use-id.ts +16 -0
- package/src/v2/hooks/__tests__/use-frontend-tool.e2e.test.ts +62 -1
- package/src/v2/hooks/__tests__/use-render-activity-message.test.ts +105 -0
- package/src/v2/hooks/__tests__/use-render-tool.test.ts +3 -6
- package/src/v2/hooks/__tests__/zod-regression.test.ts +5 -4
- package/src/v2/hooks/use-default-render-tool.ts +123 -62
- package/src/v2/hooks/use-frontend-tool.ts +10 -10
- package/src/v2/hooks/use-render-activity-message.ts +27 -48
- package/src/v2/hooks/use-render-custom-messages.ts +14 -35
- package/src/v2/hooks/use-render-tool.ts +8 -0
- package/src/v2/index.ts +3 -0
- package/src/v2/lib/__tests__/message-feedback.test.ts +152 -0
- package/src/v2/lib/message-feedback.ts +120 -0
- package/src/v2/lib/processPartialHtml.ts +6 -21
- package/src/v2/lib/vue-core.ts +3 -5
- package/src/v2/providers/CopilotChatConfigurationProvider.vue +29 -2
- package/src/v2/providers/CopilotKitProvider.types.ts +57 -5
- package/src/v2/providers/CopilotKitProvider.vue +177 -114
- package/src/v2/providers/__tests__/CopilotChatConfigurationProvider.openThread.test.ts +69 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.a2ui.test.ts +1 -1
- package/src/v2/providers/__tests__/CopilotKitProvider.headersAtSendTime.test.ts +3 -3
- package/src/v2/providers/__tests__/CopilotKitProvider.learning.test.ts +536 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.test.ts +17 -33
- package/src/v2/providers/index.ts +4 -1
- package/src/v2/providers/keys.ts +12 -0
- package/src/v2/providers/types.ts +3 -38
- package/src/v2/styles/CopilotKitStyles.ts +95 -0
- package/src/v2/styles/__tests__/CopilotKitStyles.client.test.ts +149 -0
- package/src/v2/styles/__tests__/CopilotKitStyles.ssr.test.ts +71 -0
- package/src/v2/types/__tests__/defineToolCallRenderer.test.ts +28 -33
- package/src/v2/types/defineToolCallRenderer.ts +9 -4
- package/src/v2/types/human-in-the-loop.ts +8 -32
- package/src/v2/types/interrupt.ts +7 -31
- package/src/v2/types/vue-activity-message-renderer.ts +24 -15
- package/src/v2/types/vue-custom-message-renderer.ts +12 -16
- package/src/v2/types/vue-tool-call-renderer.ts +23 -31
- package/vite.config.ts +5 -5
- package/dist/styles.css +0 -2
- package/dist/v2/components/chat/BasicMarkdown.vue.d.ts +0 -9
- package/dist/v2/components/chat/BasicMarkdown.vue.d.ts.map +0 -1
- package/dist/v2/lib/transcription-client.d.ts +0 -19
- package/dist/v2/lib/transcription-client.d.ts.map +0 -1
- package/scripts/scope-preflight.mjs +0 -100
- package/src/styles/globals.css +0 -233
- package/src/v2/components/chat/BasicMarkdown.vue +0 -158
- package/src/v2/components/chat/__tests__/BasicMarkdown.test.ts +0 -69
- package/src/v2/lib/__tests__/processPartialHtml.test.ts +0 -84
- package/src/v2/lib/__tests__/transcription-client.test.ts +0 -67
- package/src/v2/lib/transcription-client.ts +0 -151
|
@@ -1,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));
|
|
@@ -178,6 +192,41 @@ describe("OpenGenerativeUIRenderer", () => {
|
|
|
178
192
|
expect(options.frameContent).toContain("v2");
|
|
179
193
|
});
|
|
180
194
|
|
|
195
|
+
it("sizes the container to the height the final sandbox reports", async () => {
|
|
196
|
+
const iframe = document.createElement("iframe");
|
|
197
|
+
mockCreate.mockImplementationOnce((_localApi, options) => {
|
|
198
|
+
(options.frameContainer as HTMLElement).appendChild(iframe);
|
|
199
|
+
return {
|
|
200
|
+
iframe,
|
|
201
|
+
promise: Promise.resolve(),
|
|
202
|
+
run: mockRun,
|
|
203
|
+
destroy: mockDestroy,
|
|
204
|
+
};
|
|
205
|
+
});
|
|
206
|
+
const { getByTestId } = renderRenderer({
|
|
207
|
+
initialHeight: 150,
|
|
208
|
+
html: ["<body><p>Chart</p></body>"],
|
|
209
|
+
htmlComplete: true,
|
|
210
|
+
generating: false,
|
|
211
|
+
});
|
|
212
|
+
await flushImport();
|
|
213
|
+
expect(getByTestId("open-generative-ui-renderer").style.height).toBe(
|
|
214
|
+
"150px",
|
|
215
|
+
);
|
|
216
|
+
|
|
217
|
+
window.dispatchEvent(
|
|
218
|
+
new MessageEvent("message", {
|
|
219
|
+
source: iframe.contentWindow,
|
|
220
|
+
data: { type: "__ck_resize", height: 420 },
|
|
221
|
+
}),
|
|
222
|
+
);
|
|
223
|
+
await flushImport();
|
|
224
|
+
|
|
225
|
+
expect(getByTestId("open-generative-ui-renderer").style.height).toBe(
|
|
226
|
+
"420px",
|
|
227
|
+
);
|
|
228
|
+
});
|
|
229
|
+
|
|
181
230
|
it("destroys sandbox on unmount", async () => {
|
|
182
231
|
const mounted = renderRenderer({
|
|
183
232
|
html: ["<head></head><body>bye</body>"],
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { watch } from "vue";
|
|
2
2
|
import type { ShallowRef } from "vue";
|
|
3
|
-
import
|
|
4
|
-
import type { ToolCallStatus } from "@copilotkit/core";
|
|
3
|
+
import * as z from "zod";
|
|
5
4
|
import type { CopilotKitCoreVue } from "../../lib/vue-core";
|
|
6
5
|
import { defineToolCallRenderer } from "../../types/defineToolCallRenderer";
|
|
7
6
|
|
|
@@ -12,8 +11,17 @@ import { defineToolCallRenderer } from "../../types/defineToolCallRenderer";
|
|
|
12
11
|
export const RENDER_A2UI_TOOL_NAME = "render_a2ui";
|
|
13
12
|
|
|
14
13
|
/**
|
|
15
|
-
* Registers
|
|
16
|
-
*
|
|
14
|
+
* Registers a no-op renderer for the `render_a2ui` tool call so its raw
|
|
15
|
+
* streamed args are never surfaced in the transcript, as React does.
|
|
16
|
+
*
|
|
17
|
+
* The generation skeleton / retry / failure UX is not owned here: the A2UI
|
|
18
|
+
* middleware drives the whole lifecycle on the `a2ui-surface` activity (one
|
|
19
|
+
* stable messageId, building → retrying → failed → painted), rendered in place
|
|
20
|
+
* by `createA2UIMessageRenderer`. A skeleton per tool call would duplicate on
|
|
21
|
+
* retries and multi-call generations and linger after the surface painted.
|
|
22
|
+
*
|
|
23
|
+
* The renderer is registered via the props-based `setRenderToolCalls`
|
|
24
|
+
* mechanism (not `useRenderTool`).
|
|
17
25
|
*
|
|
18
26
|
* This ensures user-registered `useRenderTool({ name: "render_a2ui", ... })`
|
|
19
27
|
* hooks automatically override the built-in, since the merge logic in
|
|
@@ -33,23 +41,8 @@ export function registerA2UIBuiltInToolCallRenderer(
|
|
|
33
41
|
const renderer = defineToolCallRenderer({
|
|
34
42
|
name: RENDER_A2UI_TOOL_NAME,
|
|
35
43
|
args: z.any(),
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
args: parameters,
|
|
39
|
-
}: {
|
|
40
|
-
status: ToolCallStatus;
|
|
41
|
-
args: unknown;
|
|
42
|
-
[key: string]: unknown;
|
|
43
|
-
}): VNodeChild => {
|
|
44
|
-
if (status === "complete") return null;
|
|
45
|
-
const params = parameters as Record<string, unknown>;
|
|
46
|
-
// Hide skeleton once the A2UI surface has enough data to render.
|
|
47
|
-
const items = params?.items;
|
|
48
|
-
if (Array.isArray(items) && items.length > 0) return null;
|
|
49
|
-
const components = params?.components;
|
|
50
|
-
if (Array.isArray(components) && components.length > 2) return null;
|
|
51
|
-
return renderA2UIProgressIndicator(parameters);
|
|
52
|
-
},
|
|
44
|
+
// Render nothing: the a2ui-surface activity owns all generation UX.
|
|
45
|
+
render: () => null,
|
|
53
46
|
});
|
|
54
47
|
|
|
55
48
|
// Register via props-based mechanism so useRenderTool hooks take priority
|
|
@@ -64,244 +57,8 @@ export function registerA2UIBuiltInToolCallRenderer(
|
|
|
64
57
|
core.setRenderToolCalls(
|
|
65
58
|
current.filter((rc) => rc.name !== RENDER_A2UI_TOOL_NAME),
|
|
66
59
|
);
|
|
67
|
-
progressState.clear();
|
|
68
60
|
});
|
|
69
61
|
},
|
|
70
62
|
{ immediate: true },
|
|
71
63
|
);
|
|
72
64
|
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Vue render-function equivalent of the React A2UIProgressIndicator.
|
|
76
|
-
* Shows a skeleton wireframe that progressively reveals as tokens stream in.
|
|
77
|
-
*/
|
|
78
|
-
const progressState = new Map<
|
|
79
|
-
string,
|
|
80
|
-
{ lastTime: number; lastTokens: number }
|
|
81
|
-
>();
|
|
82
|
-
|
|
83
|
-
function renderA2UIProgressIndicator(parameters: unknown): VNodeChild {
|
|
84
|
-
const params = parameters as Record<string, unknown> | null | undefined;
|
|
85
|
-
const key = typeof params?.name === "string" ? params.name : "__default__";
|
|
86
|
-
let state = progressState.get(key);
|
|
87
|
-
if (!state) {
|
|
88
|
-
state = { lastTime: 0, lastTokens: 0 };
|
|
89
|
-
progressState.set(key, state);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const now = Date.now();
|
|
93
|
-
let tokens = state.lastTokens;
|
|
94
|
-
if (now - state.lastTime > 200) {
|
|
95
|
-
const chars = JSON.stringify(parameters ?? {}).length;
|
|
96
|
-
tokens = Math.round(chars / 4);
|
|
97
|
-
state.lastTime = now;
|
|
98
|
-
state.lastTokens = tokens;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const phase = tokens < 50 ? 0 : tokens < 200 ? 1 : tokens < 400 ? 2 : 3;
|
|
102
|
-
|
|
103
|
-
const dot = () =>
|
|
104
|
-
h("div", {
|
|
105
|
-
style: {
|
|
106
|
-
width: "7px",
|
|
107
|
-
height: "7px",
|
|
108
|
-
borderRadius: "50%",
|
|
109
|
-
backgroundColor: "#d4d4d8",
|
|
110
|
-
flexShrink: 0,
|
|
111
|
-
},
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
const spacer = () => h("div", { style: { width: "12px" } });
|
|
115
|
-
|
|
116
|
-
const bar = (
|
|
117
|
-
w: number,
|
|
118
|
-
ht: number,
|
|
119
|
-
bg: string,
|
|
120
|
-
anim?: number,
|
|
121
|
-
opacity?: number,
|
|
122
|
-
transition?: string,
|
|
123
|
-
) =>
|
|
124
|
-
h("div", {
|
|
125
|
-
style: {
|
|
126
|
-
width: `${w}px`,
|
|
127
|
-
height: `${ht}px`,
|
|
128
|
-
borderRadius: "9999px",
|
|
129
|
-
backgroundColor: bg,
|
|
130
|
-
...(anim !== undefined
|
|
131
|
-
? {
|
|
132
|
-
animation: `cpk-a2ui-fade 2.4s ease-in-out ${anim}s infinite`,
|
|
133
|
-
}
|
|
134
|
-
: {}),
|
|
135
|
-
...(opacity !== undefined ? { opacity } : {}),
|
|
136
|
-
...(transition ? { transition } : {}),
|
|
137
|
-
},
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
const row = (show: boolean, delay: number, children: VNodeChild[]) =>
|
|
141
|
-
h(
|
|
142
|
-
"div",
|
|
143
|
-
{
|
|
144
|
-
style: {
|
|
145
|
-
display: "flex",
|
|
146
|
-
alignItems: "center",
|
|
147
|
-
gap: "6px",
|
|
148
|
-
opacity: show ? 1 : 0,
|
|
149
|
-
transition: `opacity 0.4s ${delay}s`,
|
|
150
|
-
},
|
|
151
|
-
},
|
|
152
|
-
children,
|
|
153
|
-
);
|
|
154
|
-
|
|
155
|
-
return h("div", { style: { margin: "12px 0", maxWidth: "320px" } }, [
|
|
156
|
-
h(
|
|
157
|
-
"div",
|
|
158
|
-
{
|
|
159
|
-
style: {
|
|
160
|
-
position: "relative",
|
|
161
|
-
overflow: "hidden",
|
|
162
|
-
borderRadius: "12px",
|
|
163
|
-
border: "1px solid rgba(228,228,231,0.8)",
|
|
164
|
-
backgroundColor: "#fff",
|
|
165
|
-
boxShadow: "0 1px 2px rgba(0,0,0,0.04)",
|
|
166
|
-
padding: "16px 18px 14px",
|
|
167
|
-
},
|
|
168
|
-
},
|
|
169
|
-
[
|
|
170
|
-
// Top bar
|
|
171
|
-
h(
|
|
172
|
-
"div",
|
|
173
|
-
{
|
|
174
|
-
style: {
|
|
175
|
-
display: "flex",
|
|
176
|
-
alignItems: "center",
|
|
177
|
-
gap: "8px",
|
|
178
|
-
marginBottom: "12px",
|
|
179
|
-
},
|
|
180
|
-
},
|
|
181
|
-
[
|
|
182
|
-
h("div", { style: { display: "flex", gap: "4px" } }, [
|
|
183
|
-
dot(),
|
|
184
|
-
dot(),
|
|
185
|
-
dot(),
|
|
186
|
-
]),
|
|
187
|
-
bar(
|
|
188
|
-
64,
|
|
189
|
-
6,
|
|
190
|
-
"#e4e4e7",
|
|
191
|
-
undefined,
|
|
192
|
-
phase >= 1 ? 1 : 0.4,
|
|
193
|
-
"opacity 0.5s",
|
|
194
|
-
),
|
|
195
|
-
],
|
|
196
|
-
),
|
|
197
|
-
// Skeleton lines
|
|
198
|
-
h("div", { style: { display: "grid", gap: "7px" } }, [
|
|
199
|
-
row(phase >= 0, 0, [
|
|
200
|
-
bar(36, 7, "rgba(147,197,253,0.7)", 0),
|
|
201
|
-
bar(80, 7, "rgba(219,234,254,0.8)", 0.2),
|
|
202
|
-
]),
|
|
203
|
-
row(phase >= 0, 0.1, [
|
|
204
|
-
spacer(),
|
|
205
|
-
dot(),
|
|
206
|
-
bar(100, 7, "rgba(24,24,27,0.2)", 0.3),
|
|
207
|
-
]),
|
|
208
|
-
row(phase >= 1, 0.15, [
|
|
209
|
-
spacer(),
|
|
210
|
-
bar(48, 7, "rgba(24,24,27,0.15)", 0.1),
|
|
211
|
-
bar(40, 7, "rgba(153,246,228,0.6)", 0.5),
|
|
212
|
-
bar(56, 7, "rgba(147,197,253,0.6)", 0.3),
|
|
213
|
-
]),
|
|
214
|
-
row(phase >= 1, 0.2, [
|
|
215
|
-
spacer(),
|
|
216
|
-
dot(),
|
|
217
|
-
bar(60, 7, "rgba(24,24,27,0.15)", 0.4),
|
|
218
|
-
]),
|
|
219
|
-
row(phase >= 2, 0.25, [
|
|
220
|
-
bar(40, 7, "rgba(153,246,228,0.5)", 0.2),
|
|
221
|
-
dot(),
|
|
222
|
-
bar(48, 7, "rgba(24,24,27,0.15)", 0.6),
|
|
223
|
-
bar(64, 7, "rgba(147,197,253,0.5)", 0.1),
|
|
224
|
-
]),
|
|
225
|
-
row(phase >= 2, 0.3, [
|
|
226
|
-
bar(36, 7, "rgba(147,197,253,0.6)", 0.5),
|
|
227
|
-
bar(36, 7, "rgba(24,24,27,0.12)", 0.7),
|
|
228
|
-
]),
|
|
229
|
-
row(phase >= 3, 0.35, [
|
|
230
|
-
dot(),
|
|
231
|
-
bar(44, 7, "rgba(24,24,27,0.18)", 0.3),
|
|
232
|
-
dot(),
|
|
233
|
-
bar(56, 7, "rgba(153,246,228,0.5)", 0.8),
|
|
234
|
-
bar(48, 7, "rgba(147,197,253,0.5)", 0.4),
|
|
235
|
-
]),
|
|
236
|
-
]),
|
|
237
|
-
// Shimmer
|
|
238
|
-
h("div", {
|
|
239
|
-
style: {
|
|
240
|
-
pointerEvents: "none",
|
|
241
|
-
position: "absolute",
|
|
242
|
-
inset: "0",
|
|
243
|
-
background:
|
|
244
|
-
"linear-gradient(105deg, transparent 0%, transparent 40%, rgba(255,255,255,0.6) 50%, transparent 60%, transparent 100%)",
|
|
245
|
-
backgroundSize: "250% 100%",
|
|
246
|
-
animation: "cpk-a2ui-sweep 3s ease-in-out infinite",
|
|
247
|
-
},
|
|
248
|
-
}),
|
|
249
|
-
],
|
|
250
|
-
),
|
|
251
|
-
// Label
|
|
252
|
-
h(
|
|
253
|
-
"div",
|
|
254
|
-
{
|
|
255
|
-
style: {
|
|
256
|
-
display: "flex",
|
|
257
|
-
alignItems: "center",
|
|
258
|
-
justifyContent: "center",
|
|
259
|
-
gap: "8px",
|
|
260
|
-
marginTop: "8px",
|
|
261
|
-
},
|
|
262
|
-
},
|
|
263
|
-
[
|
|
264
|
-
h(
|
|
265
|
-
"span",
|
|
266
|
-
{
|
|
267
|
-
style: {
|
|
268
|
-
fontSize: "12px",
|
|
269
|
-
color: "#a1a1aa",
|
|
270
|
-
letterSpacing: "0.025em",
|
|
271
|
-
},
|
|
272
|
-
},
|
|
273
|
-
"Building interface",
|
|
274
|
-
),
|
|
275
|
-
...(tokens > 0
|
|
276
|
-
? [
|
|
277
|
-
h(
|
|
278
|
-
"span",
|
|
279
|
-
{
|
|
280
|
-
style: {
|
|
281
|
-
fontSize: "11px",
|
|
282
|
-
color: "#d4d4d8",
|
|
283
|
-
fontVariantNumeric: "tabular-nums",
|
|
284
|
-
},
|
|
285
|
-
},
|
|
286
|
-
`~${tokens.toLocaleString()} tokens`,
|
|
287
|
-
),
|
|
288
|
-
]
|
|
289
|
-
: []),
|
|
290
|
-
],
|
|
291
|
-
),
|
|
292
|
-
// Keyframe styles
|
|
293
|
-
h(
|
|
294
|
-
"style",
|
|
295
|
-
`
|
|
296
|
-
@keyframes cpk-a2ui-fade {
|
|
297
|
-
0%, 100% { opacity: 1; }
|
|
298
|
-
50% { opacity: 0.5; }
|
|
299
|
-
}
|
|
300
|
-
@keyframes cpk-a2ui-sweep {
|
|
301
|
-
0% { background-position: 250% 0; }
|
|
302
|
-
100% { background-position: -250% 0; }
|
|
303
|
-
}
|
|
304
|
-
`,
|
|
305
|
-
),
|
|
306
|
-
]);
|
|
307
|
-
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { computed, watch } from "vue";
|
|
2
2
|
import type { ShallowRef } from "vue";
|
|
3
3
|
import type { Catalog, ComponentApi } from "@a2ui/web_core/v0_9";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
A2UI_SCHEMA_CONTEXT_DESCRIPTION,
|
|
6
|
+
buildCatalogContextValue as buildContextValue,
|
|
7
|
+
extractCatalogComponentSchemas,
|
|
8
|
+
} from "@copilotkit/a2ui-renderer/catalog-schema";
|
|
5
9
|
import {
|
|
6
10
|
A2UI_DEFAULT_GENERATION_GUIDELINES,
|
|
7
11
|
A2UI_DEFAULT_DESIGN_GUIDELINES,
|
|
@@ -9,22 +13,9 @@ import {
|
|
|
9
13
|
import type { CopilotKitCoreVue } from "../../lib/vue-core";
|
|
10
14
|
import { vueBasicCatalog } from "./catalog";
|
|
11
15
|
|
|
12
|
-
/**
|
|
13
|
-
* Context description used to identify the A2UI component schema in
|
|
14
|
-
* RunAgentInput.context. Must match the constant in @ag-ui/a2ui-middleware
|
|
15
|
-
* so the middleware can overwrite a frontend-provided schema with a
|
|
16
|
-
* server-side one.
|
|
17
|
-
*
|
|
18
|
-
* Duplicated from @copilotkit/a2ui-renderer/catalog-utils to avoid pulling
|
|
19
|
-
* in React dependencies.
|
|
20
|
-
*/
|
|
21
|
-
const A2UI_SCHEMA_CONTEXT_DESCRIPTION =
|
|
22
|
-
"A2UI Component Schema — available components for generating UI surfaces. " +
|
|
23
|
-
"Use these component names and properties when creating A2UI operations.";
|
|
24
|
-
|
|
25
16
|
/**
|
|
26
17
|
* Build a context string describing the available A2UI catalog.
|
|
27
|
-
*
|
|
18
|
+
* Defaults to the Vue basic catalog.
|
|
28
19
|
*
|
|
29
20
|
* When `options.includeSchema` is `false`, custom components are listed by name
|
|
30
21
|
* only and their JSON schemas are omitted.
|
|
@@ -33,92 +24,7 @@ export function buildCatalogContextValue(
|
|
|
33
24
|
catalog?: Catalog<ComponentApi>,
|
|
34
25
|
options?: { includeSchema?: boolean },
|
|
35
26
|
): string {
|
|
36
|
-
|
|
37
|
-
const BASIC_CATALOG_ID =
|
|
38
|
-
"https://a2ui.org/specification/v0_9/basic_catalog.json";
|
|
39
|
-
const lines: string[] = [];
|
|
40
|
-
lines.push("Available A2UI catalog:");
|
|
41
|
-
|
|
42
|
-
if (resolved.id === BASIC_CATALOG_ID) {
|
|
43
|
-
lines.push(`- ${resolved.id} (basic catalog)`);
|
|
44
|
-
return lines.join("\n");
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Check if the resolved catalog extends the basic catalog
|
|
48
|
-
let isSuperset = true;
|
|
49
|
-
for (const name of vueBasicCatalog.components.keys()) {
|
|
50
|
-
if (!resolved.components.has(name)) {
|
|
51
|
-
isSuperset = false;
|
|
52
|
-
break;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// Identify custom components (not in basic catalog)
|
|
57
|
-
const customNames: string[] = [];
|
|
58
|
-
for (const name of resolved.components.keys()) {
|
|
59
|
-
if (!vueBasicCatalog.components.has(name)) {
|
|
60
|
-
customNames.push(name);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
lines.push(`- ${resolved.id}`);
|
|
65
|
-
if (isSuperset) {
|
|
66
|
-
lines.push(
|
|
67
|
-
" Extends the basic catalog with all standard components plus:",
|
|
68
|
-
);
|
|
69
|
-
} else {
|
|
70
|
-
lines.push(" Custom catalog (does NOT include all basic components).");
|
|
71
|
-
lines.push(" Custom components:");
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
for (const name of customNames) {
|
|
75
|
-
const comp = resolved.components.get(name);
|
|
76
|
-
if (!comp) continue;
|
|
77
|
-
if (options?.includeSchema === false) {
|
|
78
|
-
lines.push(` - ${name}`);
|
|
79
|
-
continue;
|
|
80
|
-
}
|
|
81
|
-
const jsonSchema = zodToJsonSchema(comp.schema);
|
|
82
|
-
lines.push(` - ${name}:`);
|
|
83
|
-
lines.push(
|
|
84
|
-
` ${JSON.stringify(jsonSchema, null, 2).split("\n").join("\n ")}`,
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return lines.join("\n");
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Extract component schemas from a catalog in A2UI v0.9 inline format.
|
|
93
|
-
* Vue-native equivalent of extractCatalogComponentSchemas.
|
|
94
|
-
*/
|
|
95
|
-
function extractCatalogComponentSchemas(catalog?: Catalog<ComponentApi>): {
|
|
96
|
-
catalogId: string;
|
|
97
|
-
components: Record<string, Record<string, unknown>>;
|
|
98
|
-
} {
|
|
99
|
-
const resolved = catalog ?? vueBasicCatalog;
|
|
100
|
-
const components: Record<string, Record<string, unknown>> = {};
|
|
101
|
-
|
|
102
|
-
for (const [name, comp] of resolved.components) {
|
|
103
|
-
const zodSchema = zodToJsonSchema(comp.schema, {
|
|
104
|
-
target: "jsonSchema2019-09",
|
|
105
|
-
}) as { properties?: Record<string, unknown>; required?: string[] };
|
|
106
|
-
|
|
107
|
-
components[name] = {
|
|
108
|
-
allOf: [
|
|
109
|
-
{ $ref: "common_types.json#/$defs/ComponentCommon" },
|
|
110
|
-
{
|
|
111
|
-
properties: {
|
|
112
|
-
component: { const: name },
|
|
113
|
-
...zodSchema.properties,
|
|
114
|
-
},
|
|
115
|
-
required: ["component", ...(zodSchema.required ?? [])],
|
|
116
|
-
},
|
|
117
|
-
],
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return { catalogId: resolved.id, components };
|
|
27
|
+
return buildContextValue(catalog ?? vueBasicCatalog, options);
|
|
122
28
|
}
|
|
123
29
|
|
|
124
30
|
/**
|
|
@@ -165,7 +71,9 @@ export function registerA2UICatalogContext(
|
|
|
165
71
|
// Register schema + generation/design guidelines
|
|
166
72
|
const schemaValue = computed(() => {
|
|
167
73
|
if (!options.includeSchema()) return null;
|
|
168
|
-
return JSON.stringify(
|
|
74
|
+
return JSON.stringify(
|
|
75
|
+
extractCatalogComponentSchemas(options.catalog() ?? vueBasicCatalog),
|
|
76
|
+
);
|
|
169
77
|
});
|
|
170
78
|
|
|
171
79
|
watch(
|