@copilotkit/vue 1.57.1
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/AGENTS.md +50 -0
- package/CHANGELOG.md +13 -0
- package/PARITY.md +434 -0
- package/README.md +396 -0
- package/dist/components/copilot-provider/CopilotKit.vue.d.ts +20 -0
- package/dist/components/copilot-provider/CopilotKit.vue.d.ts.map +1 -0
- package/dist/components/copilot-provider/index.d.ts +3 -0
- package/dist/components/copilot-provider/index.d.ts.map +1 -0
- package/dist/components/copilot-provider/types.d.ts +22 -0
- package/dist/components/copilot-provider/types.d.ts.map +1 -0
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/use-copilot-action.d.ts +27 -0
- package/dist/hooks/use-copilot-action.d.ts.map +1 -0
- package/dist/hooks/use-copilot-readable.d.ts +20 -0
- package/dist/hooks/use-copilot-readable.d.ts.map +1 -0
- package/dist/hooks/use-frontend-tool.d.ts +21 -0
- package/dist/hooks/use-frontend-tool.d.ts.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +10 -0
- package/dist/index.d.mts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +252 -0
- package/dist/index.mjs.map +1 -0
- package/dist/styles.css +2 -0
- package/dist/use-render-activity-message-BRL1Rpl-.cjs +85 -0
- package/dist/use-render-activity-message-BRL1Rpl-.cjs.map +1 -0
- package/dist/use-render-activity-message-CqtxiFSs.js +8927 -0
- package/dist/use-render-activity-message-CqtxiFSs.js.map +1 -0
- package/dist/v2/components/A2UIMessageRenderer.d.ts +9 -0
- package/dist/v2/components/A2UIMessageRenderer.d.ts.map +1 -0
- package/dist/v2/components/A2UISurfaceActivityRenderer.vue.d.ts +16 -0
- package/dist/v2/components/A2UISurfaceActivityRenderer.vue.d.ts.map +1 -0
- package/dist/v2/components/CopilotKitInspector.vue.d.ts +7 -0
- package/dist/v2/components/CopilotKitInspector.vue.d.ts.map +1 -0
- package/dist/v2/components/InlineFeatureWarning.vue.d.ts +6 -0
- package/dist/v2/components/InlineFeatureWarning.vue.d.ts.map +1 -0
- package/dist/v2/components/LicenseWarningBanner.vue.d.ts +18 -0
- package/dist/v2/components/LicenseWarningBanner.vue.d.ts.map +1 -0
- package/dist/v2/components/MCPAppsActivityRenderer.d.ts +88 -0
- package/dist/v2/components/MCPAppsActivityRenderer.d.ts.map +1 -0
- package/dist/v2/components/OpenGenerativeUIRenderer.d.ts +154 -0
- package/dist/v2/components/OpenGenerativeUIRenderer.d.ts.map +1 -0
- package/dist/v2/components/a2ui/A2UIBuiltInToolCallRenderer.d.ts +19 -0
- package/dist/v2/components/a2ui/A2UIBuiltInToolCallRenderer.d.ts.map +1 -0
- package/dist/v2/components/a2ui/A2UICatalogContext.d.ts +16 -0
- package/dist/v2/components/a2ui/A2UICatalogContext.d.ts.map +1 -0
- package/dist/v2/components/a2ui/VueSurface.d.ts +62 -0
- package/dist/v2/components/a2ui/VueSurface.d.ts.map +1 -0
- package/dist/v2/components/a2ui/adapter.d.ts +38 -0
- package/dist/v2/components/a2ui/adapter.d.ts.map +1 -0
- package/dist/v2/components/a2ui/catalog.d.ts +29 -0
- package/dist/v2/components/a2ui/catalog.d.ts.map +1 -0
- package/dist/v2/components/a2ui/index.d.ts +5 -0
- package/dist/v2/components/a2ui/index.d.ts.map +1 -0
- package/dist/v2/components/a2ui/utils.d.ts +18 -0
- package/dist/v2/components/a2ui/utils.d.ts.map +1 -0
- package/dist/v2/components/a2ui.d.ts +12 -0
- package/dist/v2/components/a2ui.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChat.vue.d.ts +50 -0
- package/dist/v2/components/chat/CopilotChat.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatAssistantMessage.vue.d.ts +164 -0
- package/dist/v2/components/chat/CopilotChatAssistantMessage.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatAttachmentQueue.vue.d.ts +12 -0
- package/dist/v2/components/chat/CopilotChatAttachmentQueue.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatAttachmentRenderer.vue.d.ts +7 -0
- package/dist/v2/components/chat/CopilotChatAttachmentRenderer.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatAudioRecorder.vue.d.ts +12 -0
- package/dist/v2/components/chat/CopilotChatAudioRecorder.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatInput.vue.d.ts +290 -0
- package/dist/v2/components/chat/CopilotChatInput.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatMessageView.vue.d.ts +72 -0
- package/dist/v2/components/chat/CopilotChatMessageView.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatReasoningMessage.vue.d.ts +65 -0
- package/dist/v2/components/chat/CopilotChatReasoningMessage.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatSuggestionPill.vue.d.ts +27 -0
- package/dist/v2/components/chat/CopilotChatSuggestionPill.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatSuggestionView.vue.d.ts +26 -0
- package/dist/v2/components/chat/CopilotChatSuggestionView.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatToggleButton.vue.d.ts +17 -0
- package/dist/v2/components/chat/CopilotChatToggleButton.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatToggleButtonCloseIcon.d.ts +5 -0
- package/dist/v2/components/chat/CopilotChatToggleButtonCloseIcon.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatToggleButtonOpenIcon.d.ts +5 -0
- package/dist/v2/components/chat/CopilotChatToggleButtonOpenIcon.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatToolCallsView.vue.d.ts +21 -0
- package/dist/v2/components/chat/CopilotChatToolCallsView.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatUserMessage.vue.d.ts +34 -0
- package/dist/v2/components/chat/CopilotChatUserMessage.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatView.vue.d.ts +106 -0
- package/dist/v2/components/chat/CopilotChatView.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotModalHeader.vue.d.ts +15 -0
- package/dist/v2/components/chat/CopilotModalHeader.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotModalHeaderCloseButton.d.ts +5 -0
- package/dist/v2/components/chat/CopilotModalHeaderCloseButton.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotModalHeaderTitle.d.ts +5 -0
- package/dist/v2/components/chat/CopilotModalHeaderTitle.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotPopup.vue.d.ts +50 -0
- package/dist/v2/components/chat/CopilotPopup.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotPopupView.vue.d.ts +55 -0
- package/dist/v2/components/chat/CopilotPopupView.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotPopupViewInternal.vue.d.ts +55 -0
- package/dist/v2/components/chat/CopilotPopupViewInternal.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotPopupWelcomeScreen.vue.d.ts +28 -0
- package/dist/v2/components/chat/CopilotPopupWelcomeScreen.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotSidebar.vue.d.ts +48 -0
- package/dist/v2/components/chat/CopilotSidebar.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotSidebarView.vue.d.ts +62 -0
- package/dist/v2/components/chat/CopilotSidebarView.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotSidebarViewInternal.vue.d.ts +53 -0
- package/dist/v2/components/chat/CopilotSidebarViewInternal.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotSidebarWelcomeScreen.vue.d.ts +28 -0
- package/dist/v2/components/chat/CopilotSidebarWelcomeScreen.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/audioRecorder.d.ts +11 -0
- package/dist/v2/components/chat/audioRecorder.d.ts.map +1 -0
- package/dist/v2/components/chat/index.d.ts +682 -0
- package/dist/v2/components/chat/index.d.ts.map +1 -0
- package/dist/v2/components/chat/last-user-message-context.d.ts +29 -0
- package/dist/v2/components/chat/last-user-message-context.d.ts.map +1 -0
- package/dist/v2/components/chat/normalize-auto-scroll.d.ts +3 -0
- package/dist/v2/components/chat/normalize-auto-scroll.d.ts.map +1 -0
- package/dist/v2/components/chat/types.d.ts +380 -0
- package/dist/v2/components/chat/types.d.ts.map +1 -0
- package/dist/v2/components/icons/index.d.ts +2 -0
- package/dist/v2/components/icons/index.d.ts.map +1 -0
- package/dist/v2/components/index.d.ts +8 -0
- package/dist/v2/components/index.d.ts.map +1 -0
- package/dist/v2/hooks/index.d.ts +24 -0
- package/dist/v2/hooks/index.d.ts.map +1 -0
- package/dist/v2/hooks/use-agent-context.d.ts +24 -0
- package/dist/v2/hooks/use-agent-context.d.ts.map +1 -0
- package/dist/v2/hooks/use-agent.d.ts +53 -0
- package/dist/v2/hooks/use-agent.d.ts.map +1 -0
- package/dist/v2/hooks/use-attachments.d.ts +21 -0
- package/dist/v2/hooks/use-attachments.d.ts.map +1 -0
- package/dist/v2/hooks/use-capabilities.d.ts +16 -0
- package/dist/v2/hooks/use-capabilities.d.ts.map +1 -0
- package/dist/v2/hooks/use-component.d.ts +13 -0
- package/dist/v2/hooks/use-component.d.ts.map +1 -0
- package/dist/v2/hooks/use-configure-suggestions.d.ts +24 -0
- package/dist/v2/hooks/use-configure-suggestions.d.ts.map +1 -0
- package/dist/v2/hooks/use-default-render-tool.d.ts +14 -0
- package/dist/v2/hooks/use-default-render-tool.d.ts.map +1 -0
- package/dist/v2/hooks/use-frontend-tool.d.ts +19 -0
- package/dist/v2/hooks/use-frontend-tool.d.ts.map +1 -0
- package/dist/v2/hooks/use-human-in-the-loop.d.ts +19 -0
- package/dist/v2/hooks/use-human-in-the-loop.d.ts.map +1 -0
- package/dist/v2/hooks/use-interrupt.d.ts +36 -0
- package/dist/v2/hooks/use-interrupt.d.ts.map +1 -0
- package/dist/v2/hooks/use-katex-styles.d.ts +22 -0
- package/dist/v2/hooks/use-katex-styles.d.ts.map +1 -0
- package/dist/v2/hooks/use-keyboard-height.d.ts +33 -0
- package/dist/v2/hooks/use-keyboard-height.d.ts.map +1 -0
- package/dist/v2/hooks/use-pin-to-send.d.ts +28 -0
- package/dist/v2/hooks/use-pin-to-send.d.ts.map +1 -0
- package/dist/v2/hooks/use-render-activity-message.d.ts +21 -0
- package/dist/v2/hooks/use-render-activity-message.d.ts.map +1 -0
- package/dist/v2/hooks/use-render-custom-messages.d.ts +27 -0
- package/dist/v2/hooks/use-render-custom-messages.d.ts.map +1 -0
- package/dist/v2/hooks/use-render-tool.d.ts +36 -0
- package/dist/v2/hooks/use-render-tool.d.ts.map +1 -0
- package/dist/v2/hooks/use-suggestions.d.ts +26 -0
- package/dist/v2/hooks/use-suggestions.d.ts.map +1 -0
- package/dist/v2/hooks/use-threads.d.ts +42 -0
- package/dist/v2/hooks/use-threads.d.ts.map +1 -0
- package/dist/v2/index.cjs +2 -0
- package/dist/v2/index.cjs.map +1 -0
- package/dist/v2/index.d.cts +9 -0
- package/dist/v2/index.d.mts +9 -0
- package/dist/v2/index.d.ts +9 -0
- package/dist/v2/index.d.ts.map +1 -0
- package/dist/v2/index.mjs +75 -0
- package/dist/v2/index.mjs.map +1 -0
- package/dist/v2/lib/processPartialHtml.d.ts +3 -0
- package/dist/v2/lib/processPartialHtml.d.ts.map +1 -0
- package/dist/v2/lib/shallow-stable.d.ts +7 -0
- package/dist/v2/lib/shallow-stable.d.ts.map +1 -0
- package/dist/v2/lib/transcription-client.d.ts +19 -0
- package/dist/v2/lib/transcription-client.d.ts.map +1 -0
- package/dist/v2/lib/vue-core.d.ts +47 -0
- package/dist/v2/lib/vue-core.d.ts.map +1 -0
- package/dist/v2/providers/CopilotChatConfigurationProvider.types.d.ts +15 -0
- package/dist/v2/providers/CopilotChatConfigurationProvider.types.d.ts.map +1 -0
- package/dist/v2/providers/CopilotChatConfigurationProvider.vue.d.ts +17 -0
- package/dist/v2/providers/CopilotChatConfigurationProvider.vue.d.ts.map +1 -0
- package/dist/v2/providers/CopilotKitProvider.types.d.ts +61 -0
- package/dist/v2/providers/CopilotKitProvider.types.d.ts.map +1 -0
- package/dist/v2/providers/CopilotKitProvider.vue.d.ts +37 -0
- package/dist/v2/providers/CopilotKitProvider.vue.d.ts.map +1 -0
- package/dist/v2/providers/SandboxFunctionsContext.d.ts +4 -0
- package/dist/v2/providers/SandboxFunctionsContext.d.ts.map +1 -0
- package/dist/v2/providers/index.d.ts +13 -0
- package/dist/v2/providers/index.d.ts.map +1 -0
- package/dist/v2/providers/keys.d.ts +17 -0
- package/dist/v2/providers/keys.d.ts.map +1 -0
- package/dist/v2/providers/license-context.d.ts +7 -0
- package/dist/v2/providers/license-context.d.ts.map +1 -0
- package/dist/v2/providers/types.d.ts +38 -0
- package/dist/v2/providers/types.d.ts.map +1 -0
- package/dist/v2/providers/useCopilotChatConfiguration.d.ts +4 -0
- package/dist/v2/providers/useCopilotChatConfiguration.d.ts.map +1 -0
- package/dist/v2/providers/useCopilotKit.d.ts +2 -0
- package/dist/v2/providers/useCopilotKit.d.ts.map +1 -0
- package/dist/v2/providers/useLicenseContext.d.ts +14 -0
- package/dist/v2/providers/useLicenseContext.d.ts.map +1 -0
- package/dist/v2/types/a2ui.d.ts +5 -0
- package/dist/v2/types/a2ui.d.ts.map +1 -0
- package/dist/v2/types/defineToolCallRenderer.d.ts +15 -0
- package/dist/v2/types/defineToolCallRenderer.d.ts.map +1 -0
- package/dist/v2/types/frontend-tool.d.ts +6 -0
- package/dist/v2/types/frontend-tool.d.ts.map +1 -0
- package/dist/v2/types/human-in-the-loop.d.ts +29 -0
- package/dist/v2/types/human-in-the-loop.d.ts.map +1 -0
- package/dist/v2/types/index.d.ts +10 -0
- package/dist/v2/types/index.d.ts.map +1 -0
- package/dist/v2/types/interrupt.d.ts +14 -0
- package/dist/v2/types/interrupt.d.ts.map +1 -0
- package/dist/v2/types/sandbox-function.d.ts +8 -0
- package/dist/v2/types/sandbox-function.d.ts.map +1 -0
- package/dist/v2/types/vue-activity-message-renderer.d.ts +18 -0
- package/dist/v2/types/vue-activity-message-renderer.d.ts.map +1 -0
- package/dist/v2/types/vue-custom-message-renderer.d.ts +19 -0
- package/dist/v2/types/vue-custom-message-renderer.d.ts.map +1 -0
- package/dist/v2/types/vue-tool-call-renderer.d.ts +37 -0
- package/dist/v2/types/vue-tool-call-renderer.d.ts.map +1 -0
- package/env.d.ts +7 -0
- package/eslint.config.mjs +42 -0
- package/package.json +130 -0
- package/scripts/scope-preflight.mjs +100 -0
- package/src/components/copilot-provider/CopilotKit.vue +18 -0
- package/src/components/copilot-provider/index.ts +2 -0
- package/src/components/copilot-provider/types.ts +24 -0
- package/src/hooks/index.ts +9 -0
- package/src/hooks/use-copilot-action.ts +168 -0
- package/src/hooks/use-copilot-readable.ts +75 -0
- package/src/hooks/use-frontend-tool.ts +76 -0
- package/src/index.ts +12 -0
- package/src/styles/globals.css +314 -0
- package/src/v2/__tests__/exports.test.ts +35 -0
- package/src/v2/__tests__/mocks/web-inspector.ts +5 -0
- package/src/v2/__tests__/setup.ts +141 -0
- package/src/v2/__tests__/utils/agents.ts +391 -0
- package/src/v2/__tests__/utils/mount.ts +83 -0
- package/src/v2/__tests__/utils/test-helpers.ts +712 -0
- package/src/v2/components/A2UIMessageRenderer.ts +125 -0
- package/src/v2/components/A2UISurfaceActivityRenderer.vue +186 -0
- package/src/v2/components/CopilotKitInspector.vue +42 -0
- package/src/v2/components/InlineFeatureWarning.vue +35 -0
- package/src/v2/components/LicenseWarningBanner.vue +196 -0
- package/src/v2/components/MCPAppsActivityRenderer.ts +778 -0
- package/src/v2/components/OpenGenerativeUIRenderer.ts +550 -0
- package/src/v2/components/__tests__/A2UIMessageRenderer.test.ts +271 -0
- package/src/v2/components/__tests__/CopilotKitInspector.test.ts +57 -0
- package/src/v2/components/__tests__/MCPAppsActivityRenderer.e2e.test.ts +851 -0
- package/src/v2/components/__tests__/MCPAppsActivityRenderer.test.ts +237 -0
- package/src/v2/components/__tests__/OpenGenerativeUIRenderer.test.ts +516 -0
- package/src/v2/components/a2ui/A2UIBuiltInToolCallRenderer.ts +295 -0
- package/src/v2/components/a2ui/A2UICatalogContext.ts +190 -0
- package/src/v2/components/a2ui/VueSurface.ts +144 -0
- package/src/v2/components/a2ui/adapter.ts +156 -0
- package/src/v2/components/a2ui/catalog.ts +858 -0
- package/src/v2/components/a2ui/index.ts +7 -0
- package/src/v2/components/a2ui/utils.ts +67 -0
- package/src/v2/components/a2ui.ts +30 -0
- package/src/v2/components/chat/CopilotChat.vue +777 -0
- package/src/v2/components/chat/CopilotChatAssistantMessage.vue +891 -0
- package/src/v2/components/chat/CopilotChatAttachmentQueue.vue +411 -0
- package/src/v2/components/chat/CopilotChatAttachmentRenderer.vue +87 -0
- package/src/v2/components/chat/CopilotChatAudioRecorder.vue +269 -0
- package/src/v2/components/chat/CopilotChatInput.vue +1271 -0
- package/src/v2/components/chat/CopilotChatMessageView.vue +476 -0
- package/src/v2/components/chat/CopilotChatReasoningMessage.vue +247 -0
- package/src/v2/components/chat/CopilotChatSuggestionPill.vue +56 -0
- package/src/v2/components/chat/CopilotChatSuggestionView.vue +93 -0
- package/src/v2/components/chat/CopilotChatToggleButton.vue +145 -0
- package/src/v2/components/chat/CopilotChatToggleButtonCloseIcon.ts +17 -0
- package/src/v2/components/chat/CopilotChatToggleButtonOpenIcon.ts +18 -0
- package/src/v2/components/chat/CopilotChatToolCallsView.vue +161 -0
- package/src/v2/components/chat/CopilotChatUserMessage.vue +322 -0
- package/src/v2/components/chat/CopilotChatView.vue +740 -0
- package/src/v2/components/chat/CopilotModalHeader.vue +73 -0
- package/src/v2/components/chat/CopilotModalHeaderCloseButton.ts +38 -0
- package/src/v2/components/chat/CopilotModalHeaderTitle.ts +22 -0
- package/src/v2/components/chat/CopilotPopup.vue +182 -0
- package/src/v2/components/chat/CopilotPopupView.vue +168 -0
- package/src/v2/components/chat/CopilotPopupViewInternal.vue +453 -0
- package/src/v2/components/chat/CopilotPopupWelcomeScreen.vue +140 -0
- package/src/v2/components/chat/CopilotSidebar.vue +178 -0
- package/src/v2/components/chat/CopilotSidebarView.vue +172 -0
- package/src/v2/components/chat/CopilotSidebarViewInternal.vue +366 -0
- package/src/v2/components/chat/CopilotSidebarWelcomeScreen.vue +142 -0
- package/src/v2/components/chat/__tests__/CopilotChat.attachments.test.ts +237 -0
- package/src/v2/components/chat/__tests__/CopilotChat.e2e.test.ts +1240 -0
- package/src/v2/components/chat/__tests__/CopilotChat.licenseWarning.test.ts +138 -0
- package/src/v2/components/chat/__tests__/CopilotChat.onError.test.ts +85 -0
- package/src/v2/components/chat/__tests__/CopilotChat.slots.e2e.test.ts +141 -0
- package/src/v2/components/chat/__tests__/CopilotChat.test.ts +652 -0
- package/src/v2/components/chat/__tests__/CopilotChatActivityRendering.e2e.test.ts +683 -0
- package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.slots.e2e.test.ts +768 -0
- package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.test.ts +1108 -0
- package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.thumbs.test.ts +87 -0
- package/src/v2/components/chat/__tests__/CopilotChatAttachmentQueue.test.ts +277 -0
- package/src/v2/components/chat/__tests__/CopilotChatAttachmentRenderer.test.ts +124 -0
- package/src/v2/components/chat/__tests__/CopilotChatCopyButton.clipboard.test.ts +230 -0
- package/src/v2/components/chat/__tests__/CopilotChatInput.bottomAnchored.test.ts +83 -0
- package/src/v2/components/chat/__tests__/CopilotChatInput.slots.e2e.test.ts +1139 -0
- package/src/v2/components/chat/__tests__/CopilotChatInput.test.ts +1051 -0
- package/src/v2/components/chat/__tests__/CopilotChatMessageView.slots.e2e.test.ts +141 -0
- package/src/v2/components/chat/__tests__/CopilotChatMessageView.test.ts +494 -0
- package/src/v2/components/chat/__tests__/CopilotChatPropsRerender.e2e.test.ts +181 -0
- package/src/v2/components/chat/__tests__/CopilotChatReasoningMessage.test.ts +73 -0
- package/src/v2/components/chat/__tests__/CopilotChatSuggestionPill.test.ts +73 -0
- package/src/v2/components/chat/__tests__/CopilotChatSuggestionView.slots.e2e.test.ts +674 -0
- package/src/v2/components/chat/__tests__/CopilotChatSuggestionView.test.ts +91 -0
- package/src/v2/components/chat/__tests__/CopilotChatToggleButton.test.ts +93 -0
- package/src/v2/components/chat/__tests__/CopilotChatToolCallsView.test.ts +382 -0
- package/src/v2/components/chat/__tests__/CopilotChatToolRendering.e2e.test.ts +1019 -0
- package/src/v2/components/chat/__tests__/CopilotChatToolRerenders.e2e.test.ts +516 -0
- package/src/v2/components/chat/__tests__/CopilotChatUserMessage.slots.e2e.test.ts +701 -0
- package/src/v2/components/chat/__tests__/CopilotChatUserMessage.test.ts +337 -0
- package/src/v2/components/chat/__tests__/CopilotChatView.connectingGate.test.ts +135 -0
- package/src/v2/components/chat/__tests__/CopilotChatView.inputOverlay.test.ts +278 -0
- package/src/v2/components/chat/__tests__/CopilotChatView.onClick.e2e.test.ts +1082 -0
- package/src/v2/components/chat/__tests__/CopilotChatView.pinToSend.test.ts +166 -0
- package/src/v2/components/chat/__tests__/CopilotChatView.slots.e2e.test.ts +1145 -0
- package/src/v2/components/chat/__tests__/CopilotChatView.test.ts +374 -0
- package/src/v2/components/chat/__tests__/CopilotModalHeader.slots.e2e.test.ts +636 -0
- package/src/v2/components/chat/__tests__/CopilotModalHeader.test.ts +112 -0
- package/src/v2/components/chat/__tests__/CopilotPopup.test.ts +58 -0
- package/src/v2/components/chat/__tests__/CopilotPopupView.slots.e2e.test.ts +725 -0
- package/src/v2/components/chat/__tests__/CopilotPopupView.test.ts +112 -0
- package/src/v2/components/chat/__tests__/CopilotSidebar.test.ts +58 -0
- package/src/v2/components/chat/__tests__/CopilotSidebarView.slots.e2e.test.ts +603 -0
- package/src/v2/components/chat/__tests__/CopilotSidebarView.test.ts +214 -0
- package/src/v2/components/chat/__tests__/MCPAppsUiMessage.e2e.test.ts +394 -0
- package/src/v2/components/chat/__tests__/copilot-chat-throttle.test.ts +82 -0
- package/src/v2/components/chat/__tests__/normalize-auto-scroll.test.ts +39 -0
- package/src/v2/components/chat/audioRecorder.ts +15 -0
- package/src/v2/components/chat/index.ts +52 -0
- package/src/v2/components/chat/last-user-message-context.ts +39 -0
- package/src/v2/components/chat/normalize-auto-scroll.ts +17 -0
- package/src/v2/components/chat/types.ts +481 -0
- package/src/v2/components/icons/__tests__/icons.test.ts +86 -0
- package/src/v2/components/icons/index.ts +22 -0
- package/src/v2/components/index.ts +7 -0
- package/src/v2/hooks/__tests__/standard-schema-types.test.ts +149 -0
- package/src/v2/hooks/__tests__/standard-schema.test.ts +315 -0
- package/src/v2/hooks/__tests__/use-agent-context-timing.e2e.test.ts +144 -0
- package/src/v2/hooks/__tests__/use-agent-context.test.ts +271 -0
- package/src/v2/hooks/__tests__/use-agent-error-state.test.ts +64 -0
- package/src/v2/hooks/__tests__/use-agent-stability.test.ts +268 -0
- package/src/v2/hooks/__tests__/use-agent-thread-isolation.test.ts +433 -0
- package/src/v2/hooks/__tests__/use-agent-throttle.test.ts +747 -0
- package/src/v2/hooks/__tests__/use-agent.e2e.test.ts +187 -0
- package/src/v2/hooks/__tests__/use-agent.test.ts +126 -0
- package/src/v2/hooks/__tests__/use-attachments.test.ts +181 -0
- package/src/v2/hooks/__tests__/use-component.test.ts +145 -0
- package/src/v2/hooks/__tests__/use-configure-suggestions.e2e.test.ts +527 -0
- package/src/v2/hooks/__tests__/use-configure-suggestions.test.ts +399 -0
- package/src/v2/hooks/__tests__/use-default-render-tool.test.ts +214 -0
- package/src/v2/hooks/__tests__/use-frontend-tool-available.test.ts +220 -0
- package/src/v2/hooks/__tests__/use-frontend-tool.e2e.test.ts +2320 -0
- package/src/v2/hooks/__tests__/use-frontend-tool.test.ts +648 -0
- package/src/v2/hooks/__tests__/use-human-in-the-loop.e2e.test.ts +1379 -0
- package/src/v2/hooks/__tests__/use-human-in-the-loop.test.ts +282 -0
- package/src/v2/hooks/__tests__/use-interrupt.test.ts +345 -0
- package/src/v2/hooks/__tests__/use-katex-styles.test.ts +69 -0
- package/src/v2/hooks/__tests__/use-keyboard-height.test.ts +199 -0
- package/src/v2/hooks/__tests__/use-pin-to-send.test.ts +363 -0
- package/src/v2/hooks/__tests__/use-render-tool.test.ts +329 -0
- package/src/v2/hooks/__tests__/use-suggestions.e2e.test.ts +397 -0
- package/src/v2/hooks/__tests__/use-suggestions.test.ts +198 -0
- package/src/v2/hooks/__tests__/use-threads.test.ts +1041 -0
- package/src/v2/hooks/__tests__/zod-regression.test.ts +339 -0
- package/src/v2/hooks/index.ts +29 -0
- package/src/v2/hooks/use-agent-context.ts +55 -0
- package/src/v2/hooks/use-agent.ts +345 -0
- package/src/v2/hooks/use-attachments.ts +261 -0
- package/src/v2/hooks/use-capabilities.ts +30 -0
- package/src/v2/hooks/use-component.ts +46 -0
- package/src/v2/hooks/use-configure-suggestions.ts +252 -0
- package/src/v2/hooks/use-default-render-tool.ts +130 -0
- package/src/v2/hooks/use-frontend-tool.ts +68 -0
- package/src/v2/hooks/use-human-in-the-loop.ts +90 -0
- package/src/v2/hooks/use-interrupt.ts +257 -0
- package/src/v2/hooks/use-katex-styles.ts +44 -0
- package/src/v2/hooks/use-keyboard-height.ts +87 -0
- package/src/v2/hooks/use-pin-to-send.ts +160 -0
- package/src/v2/hooks/use-render-activity-message.ts +92 -0
- package/src/v2/hooks/use-render-custom-messages.ts +129 -0
- package/src/v2/hooks/use-render-tool.ts +128 -0
- package/src/v2/hooks/use-suggestions.ts +98 -0
- package/src/v2/hooks/use-threads.ts +208 -0
- package/src/v2/index.ts +11 -0
- package/src/v2/lib/__tests__/processPartialHtml.test.ts +84 -0
- package/src/v2/lib/__tests__/transcription-client.test.ts +65 -0
- package/src/v2/lib/processPartialHtml.ts +21 -0
- package/src/v2/lib/shallow-stable.ts +54 -0
- package/src/v2/lib/transcription-client.ts +151 -0
- package/src/v2/lib/vue-core.ts +161 -0
- package/src/v2/providers/CopilotChatConfigurationProvider.types.ts +15 -0
- package/src/v2/providers/CopilotChatConfigurationProvider.vue +95 -0
- package/src/v2/providers/CopilotKitProvider.types.ts +66 -0
- package/src/v2/providers/CopilotKitProvider.vue +653 -0
- package/src/v2/providers/SandboxFunctionsContext.ts +11 -0
- package/src/v2/providers/__tests__/CopilotChatConfigurationProvider.test.ts +309 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.debug.test.ts +295 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.license.test.ts +110 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.onError.test.ts +67 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.renderCustomMessages.e2e.test.ts +901 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.sandboxFunctions.test.ts +141 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.stability.test.ts +871 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.test.ts +603 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.wildcard.test.ts +104 -0
- package/src/v2/providers/index.ts +21 -0
- package/src/v2/providers/keys.ts +25 -0
- package/src/v2/providers/license-context.ts +16 -0
- package/src/v2/providers/types.ts +40 -0
- package/src/v2/providers/useCopilotChatConfiguration.ts +11 -0
- package/src/v2/providers/useCopilotKit.ts +11 -0
- package/src/v2/providers/useLicenseContext.ts +21 -0
- package/src/v2/types/__tests__/defineToolCallRenderer.test.ts +157 -0
- package/src/v2/types/a2ui.ts +5 -0
- package/src/v2/types/defineToolCallRenderer.ts +32 -0
- package/src/v2/types/frontend-tool.ts +8 -0
- package/src/v2/types/human-in-the-loop.ts +38 -0
- package/src/v2/types/index.ts +9 -0
- package/src/v2/types/interrupt.ts +15 -0
- package/src/v2/types/sandbox-function.ts +8 -0
- package/src/v2/types/vue-activity-message-renderer.ts +22 -0
- package/src/v2/types/vue-custom-message-renderer.ts +24 -0
- package/src/v2/types/vue-tool-call-renderer.ts +44 -0
- package/tsconfig.json +27 -0
- package/vite.config.ts +49 -0
- package/vitest.config.ts +23 -0
|
@@ -0,0 +1,550 @@
|
|
|
1
|
+
import {
|
|
2
|
+
computed,
|
|
3
|
+
defineComponent,
|
|
4
|
+
h,
|
|
5
|
+
onBeforeUnmount,
|
|
6
|
+
ref,
|
|
7
|
+
watch,
|
|
8
|
+
type PropType,
|
|
9
|
+
} from "vue";
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
import { ToolCallStatus } from "@copilotkit/core";
|
|
12
|
+
import {
|
|
13
|
+
processPartialHtml,
|
|
14
|
+
extractCompleteStyles,
|
|
15
|
+
} from "../lib/processPartialHtml";
|
|
16
|
+
import { useSandboxFunctions } from "../providers/SandboxFunctionsContext";
|
|
17
|
+
|
|
18
|
+
export const OpenGenerativeUIActivityType = "open-generative-ui";
|
|
19
|
+
|
|
20
|
+
export const OpenGenerativeUIContentSchema = z.object({
|
|
21
|
+
initialHeight: z.number().optional(),
|
|
22
|
+
generating: z.boolean().optional(),
|
|
23
|
+
css: z.string().optional(),
|
|
24
|
+
cssComplete: z.boolean().optional(),
|
|
25
|
+
html: z.array(z.string()).optional(),
|
|
26
|
+
htmlComplete: z.boolean().optional(),
|
|
27
|
+
jsFunctions: z.string().optional(),
|
|
28
|
+
jsFunctionsComplete: z.boolean().optional(),
|
|
29
|
+
jsExpressions: z.array(z.string()).optional(),
|
|
30
|
+
jsExpressionsComplete: z.boolean().optional(),
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export type OpenGenerativeUIContent = z.infer<
|
|
34
|
+
typeof OpenGenerativeUIContentSchema
|
|
35
|
+
>;
|
|
36
|
+
|
|
37
|
+
export const GenerateSandboxedUiArgsSchema = z.object({
|
|
38
|
+
initialHeight: z.number().optional(),
|
|
39
|
+
placeholderMessages: z.array(z.string()).optional(),
|
|
40
|
+
css: z.string().optional(),
|
|
41
|
+
html: z.string().optional(),
|
|
42
|
+
jsFunctions: z.string().optional(),
|
|
43
|
+
jsExpressions: z.array(z.string()).optional(),
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
export type GenerateSandboxedUiArgs = z.infer<
|
|
47
|
+
typeof GenerateSandboxedUiArgsSchema
|
|
48
|
+
>;
|
|
49
|
+
|
|
50
|
+
function shouldFlushImmediately(
|
|
51
|
+
previous: OpenGenerativeUIContent | null,
|
|
52
|
+
next: OpenGenerativeUIContent,
|
|
53
|
+
): boolean {
|
|
54
|
+
if (next.cssComplete && (!previous || !previous.cssComplete)) return true;
|
|
55
|
+
if (next.htmlComplete) return true;
|
|
56
|
+
if (next.generating === false) return true;
|
|
57
|
+
if (next.jsFunctions && (!previous || !previous.jsFunctions)) return true;
|
|
58
|
+
if (
|
|
59
|
+
(next.jsExpressions?.length ?? 0) > (previous?.jsExpressions?.length ?? 0)
|
|
60
|
+
)
|
|
61
|
+
return true;
|
|
62
|
+
if (next.html?.length && (!previous || !previous.html?.length)) return true;
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function ensureHead(html: string): string {
|
|
67
|
+
if (/<head[\s>]/i.test(html)) return html;
|
|
68
|
+
return `<head></head>${html}`;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function injectCssIntoHtml(html: string, css: string): string {
|
|
72
|
+
const headCloseIdx = html.indexOf("</head>");
|
|
73
|
+
if (headCloseIdx !== -1) {
|
|
74
|
+
return (
|
|
75
|
+
html.slice(0, headCloseIdx) +
|
|
76
|
+
`<style>${css}</style>` +
|
|
77
|
+
html.slice(headCloseIdx)
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
return `<head><style>${css}</style></head>${html}`;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
type SandboxInstance = {
|
|
84
|
+
iframe: HTMLIFrameElement;
|
|
85
|
+
promise: Promise<unknown>;
|
|
86
|
+
run: (code: string | Function) => Promise<unknown>;
|
|
87
|
+
destroy: () => void;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
type WebsandboxModule = {
|
|
91
|
+
create: (
|
|
92
|
+
localApi: Record<string, unknown>,
|
|
93
|
+
options: {
|
|
94
|
+
frameContainer: HTMLElement;
|
|
95
|
+
frameContent: string;
|
|
96
|
+
allowAdditionalAttributes: string;
|
|
97
|
+
},
|
|
98
|
+
) => SandboxInstance;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
async function loadWebsandbox(): Promise<WebsandboxModule> {
|
|
102
|
+
const mod = (await import("@jetbrains/websandbox")) as any;
|
|
103
|
+
return (mod.default?.default ?? mod.default) as WebsandboxModule;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export const OpenGenerativeUIRenderer = defineComponent({
|
|
107
|
+
name: "OpenGenerativeUIRenderer",
|
|
108
|
+
props: {
|
|
109
|
+
content: {
|
|
110
|
+
type: Object as PropType<OpenGenerativeUIContent>,
|
|
111
|
+
required: true,
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
setup(props) {
|
|
115
|
+
const sandboxFunctions = useSandboxFunctions();
|
|
116
|
+
const containerRef = ref<HTMLElement | null>(null);
|
|
117
|
+
const throttledContent = ref<OpenGenerativeUIContent>(props.content);
|
|
118
|
+
const latestContent = ref<OpenGenerativeUIContent>(props.content);
|
|
119
|
+
const throttleTimer = ref<number | null>(null);
|
|
120
|
+
const sandboxRef = ref<SandboxInstance | null>(null);
|
|
121
|
+
const previewSandboxRef = ref<SandboxInstance | null>(null);
|
|
122
|
+
const sandboxReady = ref(false);
|
|
123
|
+
const previewReady = ref(false);
|
|
124
|
+
const executedExpressionIndex = ref(0);
|
|
125
|
+
const jsFunctionsInjected = ref(false);
|
|
126
|
+
const pendingQueue = ref<string[]>([]);
|
|
127
|
+
|
|
128
|
+
const localApi = computed(() => {
|
|
129
|
+
const api: Record<string, unknown> = {};
|
|
130
|
+
for (const fn of sandboxFunctions.value) {
|
|
131
|
+
api[fn.name] = fn.handler;
|
|
132
|
+
}
|
|
133
|
+
return api;
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
watch(
|
|
137
|
+
() => props.content,
|
|
138
|
+
(next) => {
|
|
139
|
+
latestContent.value = next;
|
|
140
|
+
if (shouldFlushImmediately(throttledContent.value, next)) {
|
|
141
|
+
if (throttleTimer.value !== null) {
|
|
142
|
+
window.clearTimeout(throttleTimer.value);
|
|
143
|
+
throttleTimer.value = null;
|
|
144
|
+
}
|
|
145
|
+
throttledContent.value = next;
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
if (throttleTimer.value === null) {
|
|
149
|
+
throttleTimer.value = window.setTimeout(() => {
|
|
150
|
+
throttledContent.value = latestContent.value;
|
|
151
|
+
throttleTimer.value = null;
|
|
152
|
+
}, 1000);
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
{ immediate: true },
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
onBeforeUnmount(() => {
|
|
159
|
+
if (throttleTimer.value !== null) {
|
|
160
|
+
window.clearTimeout(throttleTimer.value);
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
const partialHtml = computed(() => {
|
|
165
|
+
if (throttledContent.value.htmlComplete) return undefined;
|
|
166
|
+
if (!throttledContent.value.html?.length) return undefined;
|
|
167
|
+
return throttledContent.value.html.join("");
|
|
168
|
+
});
|
|
169
|
+
const previewBody = computed(() =>
|
|
170
|
+
partialHtml.value ? processPartialHtml(partialHtml.value) : undefined,
|
|
171
|
+
);
|
|
172
|
+
const previewStyles = computed(() =>
|
|
173
|
+
partialHtml.value ? extractCompleteStyles(partialHtml.value) : "",
|
|
174
|
+
);
|
|
175
|
+
const fullHtml = computed(() =>
|
|
176
|
+
throttledContent.value.htmlComplete && throttledContent.value.html?.length
|
|
177
|
+
? throttledContent.value.html.join("")
|
|
178
|
+
: undefined,
|
|
179
|
+
);
|
|
180
|
+
const css = computed(() =>
|
|
181
|
+
throttledContent.value.cssComplete
|
|
182
|
+
? throttledContent.value.css
|
|
183
|
+
: undefined,
|
|
184
|
+
);
|
|
185
|
+
const hasPreview = computed(
|
|
186
|
+
() =>
|
|
187
|
+
!!throttledContent.value.cssComplete &&
|
|
188
|
+
!!previewBody.value &&
|
|
189
|
+
previewBody.value.trim().length > 0,
|
|
190
|
+
);
|
|
191
|
+
const hasVisibleSandbox = computed(
|
|
192
|
+
() => !!fullHtml.value || hasPreview.value,
|
|
193
|
+
);
|
|
194
|
+
const resolvedHeight = computed(
|
|
195
|
+
() => `${throttledContent.value.initialHeight ?? 200}px`,
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
const destroyPreview = () => {
|
|
199
|
+
if (previewSandboxRef.value) {
|
|
200
|
+
previewSandboxRef.value.destroy();
|
|
201
|
+
previewSandboxRef.value = null;
|
|
202
|
+
}
|
|
203
|
+
previewReady.value = false;
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
const destroyFinal = () => {
|
|
207
|
+
if (sandboxRef.value) {
|
|
208
|
+
sandboxRef.value.destroy();
|
|
209
|
+
sandboxRef.value = null;
|
|
210
|
+
}
|
|
211
|
+
sandboxReady.value = false;
|
|
212
|
+
pendingQueue.value = [];
|
|
213
|
+
executedExpressionIndex.value = 0;
|
|
214
|
+
jsFunctionsInjected.value = false;
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
watch(
|
|
218
|
+
[
|
|
219
|
+
hasPreview,
|
|
220
|
+
fullHtml,
|
|
221
|
+
css,
|
|
222
|
+
previewBody,
|
|
223
|
+
previewStyles,
|
|
224
|
+
() => containerRef.value,
|
|
225
|
+
],
|
|
226
|
+
async ([previewVisible, htmlComplete], _previous, onCleanup) => {
|
|
227
|
+
if (!previewVisible || htmlComplete || !containerRef.value) return;
|
|
228
|
+
if (previewSandboxRef.value) return;
|
|
229
|
+
|
|
230
|
+
let cancelled = false;
|
|
231
|
+
try {
|
|
232
|
+
const Websandbox = await loadWebsandbox();
|
|
233
|
+
if (cancelled || !containerRef.value) return;
|
|
234
|
+
|
|
235
|
+
const sandbox = Websandbox.create(
|
|
236
|
+
{},
|
|
237
|
+
{
|
|
238
|
+
frameContainer: containerRef.value,
|
|
239
|
+
frameContent: "<head></head><body></body>",
|
|
240
|
+
allowAdditionalAttributes: "",
|
|
241
|
+
},
|
|
242
|
+
);
|
|
243
|
+
previewSandboxRef.value = sandbox;
|
|
244
|
+
sandbox.iframe.setAttribute(
|
|
245
|
+
"data-testid",
|
|
246
|
+
"open-generative-ui-preview-sandbox",
|
|
247
|
+
);
|
|
248
|
+
sandbox.iframe.style.width = "100%";
|
|
249
|
+
sandbox.iframe.style.height = "100%";
|
|
250
|
+
sandbox.iframe.style.border = "none";
|
|
251
|
+
sandbox.iframe.style.backgroundColor = "transparent";
|
|
252
|
+
|
|
253
|
+
sandbox.promise.then(() => {
|
|
254
|
+
if (cancelled || !previewSandboxRef.value) return;
|
|
255
|
+
previewReady.value = true;
|
|
256
|
+
void sandbox.run(
|
|
257
|
+
"var s=document.createElement('style');s.textContent='html, body { overflow: hidden !important; }';document.head.appendChild(s);",
|
|
258
|
+
);
|
|
259
|
+
});
|
|
260
|
+
} catch (error) {
|
|
261
|
+
console.error(
|
|
262
|
+
"[OpenGenerativeUI] Failed to load sandbox module:",
|
|
263
|
+
error,
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
onCleanup(() => {
|
|
268
|
+
cancelled = true;
|
|
269
|
+
});
|
|
270
|
+
},
|
|
271
|
+
{ immediate: true },
|
|
272
|
+
);
|
|
273
|
+
|
|
274
|
+
watch(
|
|
275
|
+
[previewBody, previewStyles, css, previewReady],
|
|
276
|
+
([body, styles, cssText, ready]) => {
|
|
277
|
+
if (!previewSandboxRef.value || !ready) return;
|
|
278
|
+
const headParts: string[] = [];
|
|
279
|
+
if (cssText) headParts.push(`<style>${cssText}</style>`);
|
|
280
|
+
if (styles) headParts.push(styles);
|
|
281
|
+
if (headParts.length) {
|
|
282
|
+
void previewSandboxRef.value.run(
|
|
283
|
+
`document.head.innerHTML = ${JSON.stringify(headParts.join(""))}`,
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
if (body) {
|
|
287
|
+
void previewSandboxRef.value.run(
|
|
288
|
+
`document.body.innerHTML = ${JSON.stringify(body)}`,
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
},
|
|
292
|
+
{ immediate: true },
|
|
293
|
+
);
|
|
294
|
+
|
|
295
|
+
watch(
|
|
296
|
+
[fullHtml, css, localApi, () => containerRef.value],
|
|
297
|
+
async ([html, cssText, api], _previous, onCleanup) => {
|
|
298
|
+
destroyFinal();
|
|
299
|
+
if (!html || !containerRef.value) return;
|
|
300
|
+
destroyPreview();
|
|
301
|
+
|
|
302
|
+
let cancelled = false;
|
|
303
|
+
try {
|
|
304
|
+
const Websandbox = await loadWebsandbox();
|
|
305
|
+
if (cancelled || !containerRef.value) return;
|
|
306
|
+
const htmlWithHead = ensureHead(html);
|
|
307
|
+
const htmlWithCss = cssText
|
|
308
|
+
? injectCssIntoHtml(htmlWithHead, cssText)
|
|
309
|
+
: htmlWithHead;
|
|
310
|
+
const sandbox = Websandbox.create(api, {
|
|
311
|
+
frameContainer: containerRef.value,
|
|
312
|
+
frameContent: htmlWithCss,
|
|
313
|
+
allowAdditionalAttributes: "",
|
|
314
|
+
});
|
|
315
|
+
sandboxRef.value = sandbox;
|
|
316
|
+
sandbox.iframe.setAttribute(
|
|
317
|
+
"data-testid",
|
|
318
|
+
"open-generative-ui-final-sandbox",
|
|
319
|
+
);
|
|
320
|
+
sandbox.iframe.style.width = "100%";
|
|
321
|
+
sandbox.iframe.style.height = "100%";
|
|
322
|
+
sandbox.iframe.style.border = "none";
|
|
323
|
+
sandbox.iframe.style.backgroundColor = "transparent";
|
|
324
|
+
|
|
325
|
+
sandbox.promise.then(() => {
|
|
326
|
+
if (cancelled || !sandboxRef.value) return;
|
|
327
|
+
sandboxReady.value = true;
|
|
328
|
+
void sandbox.run(
|
|
329
|
+
"var s=document.createElement('style');s.textContent='html, body { overflow: hidden !important; }';document.head.appendChild(s);",
|
|
330
|
+
);
|
|
331
|
+
const functionsCode = throttledContent.value.jsFunctions;
|
|
332
|
+
if (functionsCode && !jsFunctionsInjected.value) {
|
|
333
|
+
jsFunctionsInjected.value = true;
|
|
334
|
+
pendingQueue.value.unshift(functionsCode);
|
|
335
|
+
}
|
|
336
|
+
const expressions = throttledContent.value.jsExpressions;
|
|
337
|
+
if (expressions?.length) {
|
|
338
|
+
const startIndex = executedExpressionIndex.value;
|
|
339
|
+
if (startIndex < expressions.length) {
|
|
340
|
+
pendingQueue.value.push(...expressions.slice(startIndex));
|
|
341
|
+
executedExpressionIndex.value = expressions.length;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
const queue = [...pendingQueue.value];
|
|
345
|
+
pendingQueue.value = [];
|
|
346
|
+
for (const code of queue) {
|
|
347
|
+
void sandbox.run(code);
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
} catch (error) {
|
|
351
|
+
console.error(
|
|
352
|
+
"[OpenGenerativeUI] Failed to load sandbox module:",
|
|
353
|
+
error,
|
|
354
|
+
);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
onCleanup(() => {
|
|
358
|
+
cancelled = true;
|
|
359
|
+
});
|
|
360
|
+
},
|
|
361
|
+
{ immediate: true },
|
|
362
|
+
);
|
|
363
|
+
|
|
364
|
+
watch(
|
|
365
|
+
() => throttledContent.value.jsFunctions,
|
|
366
|
+
(functionsCode) => {
|
|
367
|
+
if (!functionsCode || jsFunctionsInjected.value) return;
|
|
368
|
+
jsFunctionsInjected.value = true;
|
|
369
|
+
if (sandboxReady.value && sandboxRef.value) {
|
|
370
|
+
void sandboxRef.value.run(functionsCode);
|
|
371
|
+
} else {
|
|
372
|
+
pendingQueue.value.push(functionsCode);
|
|
373
|
+
}
|
|
374
|
+
},
|
|
375
|
+
);
|
|
376
|
+
|
|
377
|
+
watch(
|
|
378
|
+
() => throttledContent.value.jsExpressions,
|
|
379
|
+
(expressions) => {
|
|
380
|
+
if (!expressions?.length) return;
|
|
381
|
+
const startIndex = executedExpressionIndex.value;
|
|
382
|
+
if (startIndex >= expressions.length) return;
|
|
383
|
+
const newExpressions = expressions.slice(startIndex);
|
|
384
|
+
executedExpressionIndex.value = expressions.length;
|
|
385
|
+
if (sandboxReady.value && sandboxRef.value) {
|
|
386
|
+
for (const expression of newExpressions) {
|
|
387
|
+
void sandboxRef.value.run(expression);
|
|
388
|
+
}
|
|
389
|
+
} else {
|
|
390
|
+
pendingQueue.value.push(...newExpressions);
|
|
391
|
+
}
|
|
392
|
+
},
|
|
393
|
+
{ deep: true },
|
|
394
|
+
);
|
|
395
|
+
|
|
396
|
+
const isGenerating = computed(
|
|
397
|
+
() => throttledContent.value.generating !== false,
|
|
398
|
+
);
|
|
399
|
+
watch(
|
|
400
|
+
[hasPreview, fullHtml],
|
|
401
|
+
([previewVisible, html]) => {
|
|
402
|
+
if (html) destroyPreview();
|
|
403
|
+
if (!previewVisible) destroyPreview();
|
|
404
|
+
},
|
|
405
|
+
{ immediate: true },
|
|
406
|
+
);
|
|
407
|
+
|
|
408
|
+
onBeforeUnmount(() => {
|
|
409
|
+
if (throttleTimer.value !== null) {
|
|
410
|
+
window.clearTimeout(throttleTimer.value);
|
|
411
|
+
}
|
|
412
|
+
destroyPreview();
|
|
413
|
+
destroyFinal();
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
return () =>
|
|
417
|
+
h(
|
|
418
|
+
"div",
|
|
419
|
+
{
|
|
420
|
+
ref: containerRef,
|
|
421
|
+
"data-testid": "open-generative-ui-renderer",
|
|
422
|
+
style: {
|
|
423
|
+
position: "relative",
|
|
424
|
+
width: "100%",
|
|
425
|
+
height: resolvedHeight.value,
|
|
426
|
+
borderRadius: "8px",
|
|
427
|
+
backgroundColor: hasVisibleSandbox.value
|
|
428
|
+
? "transparent"
|
|
429
|
+
: "#f5f5f5",
|
|
430
|
+
border: hasVisibleSandbox.value ? "none" : "1px solid #e0e0e0",
|
|
431
|
+
overflow: "hidden",
|
|
432
|
+
display: hasVisibleSandbox.value ? "block" : "flex",
|
|
433
|
+
alignItems: hasVisibleSandbox.value ? undefined : "center",
|
|
434
|
+
justifyContent: hasVisibleSandbox.value ? undefined : "center",
|
|
435
|
+
},
|
|
436
|
+
},
|
|
437
|
+
[
|
|
438
|
+
!hasVisibleSandbox.value
|
|
439
|
+
? h("div", { "data-testid": "open-generative-ui-placeholder" }, [
|
|
440
|
+
h(
|
|
441
|
+
"svg",
|
|
442
|
+
{
|
|
443
|
+
width: "48",
|
|
444
|
+
height: "48",
|
|
445
|
+
viewBox: "0 0 24 24",
|
|
446
|
+
fill: "none",
|
|
447
|
+
style: { animation: "ck-spin 1s linear infinite" },
|
|
448
|
+
},
|
|
449
|
+
[
|
|
450
|
+
h("circle", {
|
|
451
|
+
cx: "12",
|
|
452
|
+
cy: "12",
|
|
453
|
+
r: "10",
|
|
454
|
+
stroke: "#e0e0e0",
|
|
455
|
+
"stroke-width": "3",
|
|
456
|
+
}),
|
|
457
|
+
h("path", {
|
|
458
|
+
d: "M12 2a10 10 0 0 1 10 10",
|
|
459
|
+
stroke: "#999",
|
|
460
|
+
"stroke-width": "3",
|
|
461
|
+
"stroke-linecap": "round",
|
|
462
|
+
}),
|
|
463
|
+
],
|
|
464
|
+
),
|
|
465
|
+
h(
|
|
466
|
+
"style",
|
|
467
|
+
"@keyframes ck-spin { to { transform: rotate(360deg) } }",
|
|
468
|
+
),
|
|
469
|
+
])
|
|
470
|
+
: null,
|
|
471
|
+
isGenerating.value
|
|
472
|
+
? h("div", {
|
|
473
|
+
"data-testid": "open-generative-ui-progress-overlay",
|
|
474
|
+
style: {
|
|
475
|
+
position: "absolute",
|
|
476
|
+
inset: 0,
|
|
477
|
+
backgroundColor: "rgba(255,255,255,0.45)",
|
|
478
|
+
},
|
|
479
|
+
})
|
|
480
|
+
: null,
|
|
481
|
+
],
|
|
482
|
+
);
|
|
483
|
+
},
|
|
484
|
+
});
|
|
485
|
+
|
|
486
|
+
export const OpenGenerativeUIActivityRenderer = defineComponent({
|
|
487
|
+
name: "OpenGenerativeUIActivityRenderer",
|
|
488
|
+
props: {
|
|
489
|
+
activityType: { type: String, required: true },
|
|
490
|
+
content: {
|
|
491
|
+
type: Object as PropType<OpenGenerativeUIContent>,
|
|
492
|
+
required: true,
|
|
493
|
+
},
|
|
494
|
+
message: { type: Object as PropType<unknown>, required: true },
|
|
495
|
+
agent: {
|
|
496
|
+
type: Object as PropType<unknown>,
|
|
497
|
+
required: false,
|
|
498
|
+
default: undefined,
|
|
499
|
+
},
|
|
500
|
+
},
|
|
501
|
+
setup(props) {
|
|
502
|
+
return () => h(OpenGenerativeUIRenderer, { content: props.content });
|
|
503
|
+
},
|
|
504
|
+
});
|
|
505
|
+
|
|
506
|
+
export const OpenGenerativeUIToolRenderer = defineComponent({
|
|
507
|
+
name: "OpenGenerativeUIToolRenderer",
|
|
508
|
+
props: {
|
|
509
|
+
name: { type: String, required: true },
|
|
510
|
+
args: {
|
|
511
|
+
type: Object as PropType<Partial<GenerateSandboxedUiArgs>>,
|
|
512
|
+
required: true,
|
|
513
|
+
},
|
|
514
|
+
status: { type: String as PropType<ToolCallStatus>, required: true },
|
|
515
|
+
result: { type: String as PropType<string | undefined>, required: false },
|
|
516
|
+
},
|
|
517
|
+
setup(props) {
|
|
518
|
+
const visibleMessageIndex = ref(0);
|
|
519
|
+
|
|
520
|
+
watch(
|
|
521
|
+
() => props.args.placeholderMessages,
|
|
522
|
+
(messages, _, onCleanup) => {
|
|
523
|
+
if (!messages?.length || props.status === ToolCallStatus.Complete)
|
|
524
|
+
return;
|
|
525
|
+
visibleMessageIndex.value = Math.max(messages.length - 1, 0);
|
|
526
|
+
const timer = window.setInterval(() => {
|
|
527
|
+
visibleMessageIndex.value =
|
|
528
|
+
(visibleMessageIndex.value + 1) % Math.max(messages.length, 1);
|
|
529
|
+
}, 5000);
|
|
530
|
+
onCleanup(() => window.clearInterval(timer));
|
|
531
|
+
},
|
|
532
|
+
{ immediate: true },
|
|
533
|
+
);
|
|
534
|
+
|
|
535
|
+
return () => {
|
|
536
|
+
if (props.status === ToolCallStatus.Complete) return null;
|
|
537
|
+
const messages = props.args.placeholderMessages;
|
|
538
|
+
if (!messages?.length) return null;
|
|
539
|
+
const currentMessage = messages[visibleMessageIndex.value] ?? messages[0];
|
|
540
|
+
return h(
|
|
541
|
+
"div",
|
|
542
|
+
{
|
|
543
|
+
style: { padding: "8px 12px", color: "#999", fontSize: "14px" },
|
|
544
|
+
"data-testid": "open-generative-ui-tool-placeholder",
|
|
545
|
+
},
|
|
546
|
+
currentMessage,
|
|
547
|
+
);
|
|
548
|
+
};
|
|
549
|
+
},
|
|
550
|
+
});
|