@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,129 @@
|
|
|
1
|
+
import type { Component, VNodeChild } from "vue";
|
|
2
|
+
import type { Message } from "@ag-ui/core";
|
|
3
|
+
import { DEFAULT_AGENT_ID } from "@copilotkit/shared";
|
|
4
|
+
import { useCopilotKit } from "../providers/useCopilotKit";
|
|
5
|
+
import { useCopilotChatConfiguration } from "../providers/useCopilotChatConfiguration";
|
|
6
|
+
import type {
|
|
7
|
+
VueCustomMessageRendererPosition,
|
|
8
|
+
VueCustomMessageRendererProps,
|
|
9
|
+
} from "../types";
|
|
10
|
+
|
|
11
|
+
interface UseRenderCustomMessagesParams {
|
|
12
|
+
message: Message;
|
|
13
|
+
position: VueCustomMessageRendererPosition;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface CustomMessageRendererResult {
|
|
17
|
+
renderer:
|
|
18
|
+
| Component<VueCustomMessageRendererProps>
|
|
19
|
+
| ((props: VueCustomMessageRendererProps) => VNodeChild);
|
|
20
|
+
props: VueCustomMessageRendererProps;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Returns a function that resolves the appropriate custom message renderer for
|
|
25
|
+
* a given message and position.
|
|
26
|
+
*
|
|
27
|
+
* Matches the React `useRenderCustomMessages` API: filters registered
|
|
28
|
+
* renderers by the current agent, preferring agent-scoped renderers over
|
|
29
|
+
* global ones, and computes the full renderer props (runId, indices, state
|
|
30
|
+
* snapshot).
|
|
31
|
+
*
|
|
32
|
+
* The returned function yields `null` if no chat configuration is available
|
|
33
|
+
* (i.e. when called outside a `CopilotChat` component tree) or if no
|
|
34
|
+
* matching renderer is found.
|
|
35
|
+
*/
|
|
36
|
+
export function useRenderCustomMessages() {
|
|
37
|
+
const { copilotkit } = useCopilotKit();
|
|
38
|
+
const config = useCopilotChatConfiguration();
|
|
39
|
+
|
|
40
|
+
return function renderCustomMessage(
|
|
41
|
+
params: UseRenderCustomMessagesParams,
|
|
42
|
+
): CustomMessageRendererResult | null {
|
|
43
|
+
const configValue = config.value;
|
|
44
|
+
if (!configValue) return null;
|
|
45
|
+
|
|
46
|
+
const agentId = configValue.agentId || DEFAULT_AGENT_ID;
|
|
47
|
+
const { threadId } = configValue;
|
|
48
|
+
const core = copilotkit.value;
|
|
49
|
+
|
|
50
|
+
const customMessageRenderers = [...core.renderCustomMessages]
|
|
51
|
+
.filter(
|
|
52
|
+
(renderer) =>
|
|
53
|
+
renderer.agentId === undefined || renderer.agentId === agentId,
|
|
54
|
+
)
|
|
55
|
+
.sort((a, b) => {
|
|
56
|
+
const aHasAgent = a.agentId !== undefined;
|
|
57
|
+
const bHasAgent = b.agentId !== undefined;
|
|
58
|
+
if (aHasAgent === bHasAgent) return 0;
|
|
59
|
+
return aHasAgent ? -1 : 1;
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
if (!customMessageRenderers.length) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const { message, position } = params;
|
|
67
|
+
const resolvedRunId =
|
|
68
|
+
core.getRunIdForMessage(agentId, threadId, message.id) ??
|
|
69
|
+
core.getRunIdsForThread(agentId, threadId).slice(-1)[0];
|
|
70
|
+
const runId = resolvedRunId ?? `missing-run-id:${message.id}`;
|
|
71
|
+
const agent = core.getAgent(agentId);
|
|
72
|
+
if (!agent) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const messagesIdsInRun = resolvedRunId
|
|
77
|
+
? agent.messages
|
|
78
|
+
.filter(
|
|
79
|
+
(msg) =>
|
|
80
|
+
core.getRunIdForMessage(agentId, threadId, msg.id) ===
|
|
81
|
+
resolvedRunId,
|
|
82
|
+
)
|
|
83
|
+
.map((msg) => msg.id)
|
|
84
|
+
: [message.id];
|
|
85
|
+
|
|
86
|
+
const rawMessageIndex = agent.messages.findIndex(
|
|
87
|
+
(msg) => msg.id === message.id,
|
|
88
|
+
);
|
|
89
|
+
if (rawMessageIndex < 0) {
|
|
90
|
+
console.warn(
|
|
91
|
+
`[CopilotKit] useRenderCustomMessages: message "${message.id}" ` +
|
|
92
|
+
`not found in agent "${agentId}" messages`,
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
const messageIndex = Math.max(0, rawMessageIndex);
|
|
96
|
+
const messageIndexInRun = resolvedRunId
|
|
97
|
+
? Math.max(messagesIdsInRun.indexOf(message.id), 0)
|
|
98
|
+
: 0;
|
|
99
|
+
const numberOfMessagesInRun = resolvedRunId ? messagesIdsInRun.length : 1;
|
|
100
|
+
const stateSnapshot = resolvedRunId
|
|
101
|
+
? core.getStateByRun(agentId, threadId, resolvedRunId)
|
|
102
|
+
: undefined;
|
|
103
|
+
|
|
104
|
+
const props: CustomMessageRendererResult["props"] = {
|
|
105
|
+
message,
|
|
106
|
+
position,
|
|
107
|
+
runId,
|
|
108
|
+
messageIndex,
|
|
109
|
+
messageIndexInRun,
|
|
110
|
+
numberOfMessagesInRun,
|
|
111
|
+
agentId,
|
|
112
|
+
stateSnapshot,
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
// Iterate renderers like React: try each one and use the first that
|
|
116
|
+
// returns a non-null render function.
|
|
117
|
+
for (const candidate of customMessageRenderers) {
|
|
118
|
+
if (!candidate.render) {
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
renderer: candidate.render as CustomMessageRendererResult["renderer"],
|
|
123
|
+
props,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return null;
|
|
128
|
+
};
|
|
129
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { h, watch } from "vue";
|
|
2
|
+
import type { Component, WatchSource, VNodeChild } from "vue";
|
|
3
|
+
import type { StandardSchemaV1, InferSchemaOutput } from "@copilotkit/shared";
|
|
4
|
+
import { useCopilotKit } from "../providers/useCopilotKit";
|
|
5
|
+
import { defineToolCallRenderer } from "../types/defineToolCallRenderer";
|
|
6
|
+
import type {
|
|
7
|
+
VueToolCallRenderer,
|
|
8
|
+
VueToolCallRendererRenderProps,
|
|
9
|
+
} from "../types";
|
|
10
|
+
|
|
11
|
+
const EMPTY_DEPS: WatchSource<unknown>[] = [];
|
|
12
|
+
|
|
13
|
+
export interface RenderToolInProgressProps<S extends StandardSchemaV1> {
|
|
14
|
+
name: string;
|
|
15
|
+
toolCallId: string;
|
|
16
|
+
parameters: Partial<InferSchemaOutput<S>>;
|
|
17
|
+
status: "inProgress";
|
|
18
|
+
result: undefined;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface RenderToolExecutingProps<S extends StandardSchemaV1> {
|
|
22
|
+
name: string;
|
|
23
|
+
toolCallId: string;
|
|
24
|
+
parameters: InferSchemaOutput<S>;
|
|
25
|
+
status: "executing";
|
|
26
|
+
result: undefined;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface RenderToolCompleteProps<S extends StandardSchemaV1> {
|
|
30
|
+
name: string;
|
|
31
|
+
toolCallId: string;
|
|
32
|
+
parameters: InferSchemaOutput<S>;
|
|
33
|
+
status: "complete";
|
|
34
|
+
result: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export type RenderToolProps<S extends StandardSchemaV1> =
|
|
38
|
+
| RenderToolInProgressProps<S>
|
|
39
|
+
| RenderToolExecutingProps<S>
|
|
40
|
+
| RenderToolCompleteProps<S>;
|
|
41
|
+
|
|
42
|
+
type RenderToolConfig<S extends StandardSchemaV1> = {
|
|
43
|
+
name: string;
|
|
44
|
+
parameters?: S;
|
|
45
|
+
render:
|
|
46
|
+
| ((props: RenderToolProps<S>) => VNodeChild)
|
|
47
|
+
| Component<RenderToolProps<S>>;
|
|
48
|
+
agentId?: string;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export function useRenderTool(
|
|
52
|
+
config: {
|
|
53
|
+
name: "*";
|
|
54
|
+
render: ((props: any) => VNodeChild) | Component<any>;
|
|
55
|
+
agentId?: string;
|
|
56
|
+
},
|
|
57
|
+
deps?: WatchSource<unknown>[],
|
|
58
|
+
): void;
|
|
59
|
+
|
|
60
|
+
export function useRenderTool<S extends StandardSchemaV1>(
|
|
61
|
+
config: {
|
|
62
|
+
name: string;
|
|
63
|
+
parameters: S;
|
|
64
|
+
render:
|
|
65
|
+
| ((props: RenderToolProps<S>) => VNodeChild)
|
|
66
|
+
| Component<RenderToolProps<S>>;
|
|
67
|
+
agentId?: string;
|
|
68
|
+
},
|
|
69
|
+
deps?: WatchSource<unknown>[],
|
|
70
|
+
): void;
|
|
71
|
+
|
|
72
|
+
export function useRenderTool<S extends StandardSchemaV1>(
|
|
73
|
+
config: RenderToolConfig<S>,
|
|
74
|
+
deps?: WatchSource<unknown>[],
|
|
75
|
+
): void {
|
|
76
|
+
const { copilotkit } = useCopilotKit();
|
|
77
|
+
const extraDeps = deps ?? EMPTY_DEPS;
|
|
78
|
+
|
|
79
|
+
watch(
|
|
80
|
+
[
|
|
81
|
+
() => copilotkit.value,
|
|
82
|
+
() => config.name,
|
|
83
|
+
() => config.agentId,
|
|
84
|
+
() => extraDeps.length,
|
|
85
|
+
...extraDeps,
|
|
86
|
+
],
|
|
87
|
+
() => {
|
|
88
|
+
const renderTool = (props: RenderToolProps<S>): VNodeChild => {
|
|
89
|
+
if (typeof config.render === "function") {
|
|
90
|
+
return (config.render as (props: RenderToolProps<S>) => VNodeChild)(
|
|
91
|
+
props,
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
return h(config.render, props);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const renderer =
|
|
98
|
+
config.name === "*" && !config.parameters
|
|
99
|
+
? defineToolCallRenderer({
|
|
100
|
+
name: "*",
|
|
101
|
+
render: (props: VueToolCallRendererRenderProps<unknown>) =>
|
|
102
|
+
renderTool({
|
|
103
|
+
...props,
|
|
104
|
+
parameters: props.args,
|
|
105
|
+
} as RenderToolProps<S>),
|
|
106
|
+
...(config.agentId ? { agentId: config.agentId } : {}),
|
|
107
|
+
})
|
|
108
|
+
: defineToolCallRenderer({
|
|
109
|
+
name: config.name,
|
|
110
|
+
args: config.parameters!,
|
|
111
|
+
render: (
|
|
112
|
+
props: VueToolCallRendererRenderProps<InferSchemaOutput<S>>,
|
|
113
|
+
) =>
|
|
114
|
+
renderTool({
|
|
115
|
+
...props,
|
|
116
|
+
parameters: props.args,
|
|
117
|
+
} as RenderToolProps<S>),
|
|
118
|
+
...(config.agentId ? { agentId: config.agentId } : {}),
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
copilotkit.value.addHookRenderToolCall(
|
|
122
|
+
renderer as VueToolCallRenderer<unknown>,
|
|
123
|
+
);
|
|
124
|
+
// Intentionally no cleanup removal to preserve renderers for chat history.
|
|
125
|
+
},
|
|
126
|
+
{ immediate: true },
|
|
127
|
+
);
|
|
128
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { computed, ref, toValue, watch } from "vue";
|
|
2
|
+
import type { MaybeRefOrGetter, Ref } from "vue";
|
|
3
|
+
import type { Suggestion } from "@copilotkit/core";
|
|
4
|
+
import { useCopilotKit } from "../providers/useCopilotKit";
|
|
5
|
+
import { useCopilotChatConfiguration } from "../providers/useCopilotChatConfiguration";
|
|
6
|
+
import { DEFAULT_AGENT_ID } from "@copilotkit/shared";
|
|
7
|
+
|
|
8
|
+
export interface UseSuggestionsOptions {
|
|
9
|
+
agentId?: MaybeRefOrGetter<string | undefined>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface UseSuggestionsResult {
|
|
13
|
+
suggestions: Ref<Suggestion[]>;
|
|
14
|
+
isLoading: Ref<boolean>;
|
|
15
|
+
reloadSuggestions: () => void;
|
|
16
|
+
clearSuggestions: () => void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Provides reactive access to agent suggestions.
|
|
21
|
+
*
|
|
22
|
+
* It tracks suggestion updates for the resolved agent and exposes helpers to
|
|
23
|
+
* reload or clear suggestions.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* const { suggestions, isLoading, reloadSuggestions } = useSuggestions({
|
|
28
|
+
* agentId: "default",
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export function useSuggestions(
|
|
33
|
+
options: UseSuggestionsOptions = {},
|
|
34
|
+
): UseSuggestionsResult {
|
|
35
|
+
const { copilotkit } = useCopilotKit();
|
|
36
|
+
const config = useCopilotChatConfiguration();
|
|
37
|
+
const resolvedAgentId = computed(
|
|
38
|
+
() => toValue(options.agentId) ?? config.value?.agentId ?? DEFAULT_AGENT_ID,
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const suggestions = ref<Suggestion[]>([]);
|
|
42
|
+
const isLoading = ref(false);
|
|
43
|
+
|
|
44
|
+
const initState = () => {
|
|
45
|
+
const result = copilotkit.value.getSuggestions(resolvedAgentId.value);
|
|
46
|
+
suggestions.value = result.suggestions;
|
|
47
|
+
isLoading.value = result.isLoading;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
watch([() => copilotkit.value, resolvedAgentId], () => initState(), {
|
|
51
|
+
immediate: true,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
watch(
|
|
55
|
+
[() => copilotkit.value, resolvedAgentId],
|
|
56
|
+
(_newValues, _old, onCleanup) => {
|
|
57
|
+
const core = copilotkit.value;
|
|
58
|
+
const agentId = resolvedAgentId.value;
|
|
59
|
+
const sub = core.subscribe({
|
|
60
|
+
onSuggestionsChanged: ({ agentId: changedAgentId, suggestions: s }) => {
|
|
61
|
+
if (changedAgentId !== agentId) return;
|
|
62
|
+
suggestions.value = s;
|
|
63
|
+
const result = core.getSuggestions(agentId);
|
|
64
|
+
isLoading.value = result.isLoading;
|
|
65
|
+
},
|
|
66
|
+
onSuggestionsStartedLoading: ({ agentId: changedAgentId }) => {
|
|
67
|
+
if (changedAgentId !== agentId) return;
|
|
68
|
+
isLoading.value = true;
|
|
69
|
+
},
|
|
70
|
+
onSuggestionsFinishedLoading: ({ agentId: changedAgentId }) => {
|
|
71
|
+
if (changedAgentId !== agentId) return;
|
|
72
|
+
isLoading.value = false;
|
|
73
|
+
},
|
|
74
|
+
onSuggestionsConfigChanged: () => {
|
|
75
|
+
const result = core.getSuggestions(agentId);
|
|
76
|
+
suggestions.value = result.suggestions;
|
|
77
|
+
isLoading.value = result.isLoading;
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
onCleanup(() => sub.unsubscribe());
|
|
81
|
+
},
|
|
82
|
+
{ immediate: true },
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
const reloadSuggestions = () => {
|
|
86
|
+
copilotkit.value.reloadSuggestions(resolvedAgentId.value);
|
|
87
|
+
};
|
|
88
|
+
const clearSuggestions = () => {
|
|
89
|
+
copilotkit.value.clearSuggestions(resolvedAgentId.value);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
suggestions,
|
|
94
|
+
isLoading,
|
|
95
|
+
reloadSuggestions,
|
|
96
|
+
clearSuggestions,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { computed, onScopeDispose, ref, toValue, watch } from "vue";
|
|
2
|
+
import type { MaybeRefOrGetter, Ref } from "vue";
|
|
3
|
+
import {
|
|
4
|
+
CopilotKitCoreRuntimeConnectionStatus,
|
|
5
|
+
ɵcreateThreadStore,
|
|
6
|
+
ɵselectHasNextPage,
|
|
7
|
+
ɵselectIsFetchingNextPage,
|
|
8
|
+
ɵselectThreads,
|
|
9
|
+
ɵselectThreadsError,
|
|
10
|
+
ɵselectThreadsIsLoading,
|
|
11
|
+
} from "@copilotkit/core";
|
|
12
|
+
import type { ɵThreadRuntimeContext, ɵThreadStore } from "@copilotkit/core";
|
|
13
|
+
import { useCopilotKit } from "../providers/useCopilotKit";
|
|
14
|
+
|
|
15
|
+
export interface Thread {
|
|
16
|
+
id: string;
|
|
17
|
+
agentId: string;
|
|
18
|
+
name: string | null;
|
|
19
|
+
archived: boolean;
|
|
20
|
+
createdAt: string;
|
|
21
|
+
updatedAt: string;
|
|
22
|
+
/**
|
|
23
|
+
* ISO-8601 timestamp of the most recent agent run on this thread. Absent
|
|
24
|
+
* when the thread has never been run. Prefer this over `updatedAt` for
|
|
25
|
+
* user-facing "last activity" displays — it is not bumped by metadata-only
|
|
26
|
+
* actions like rename or archive.
|
|
27
|
+
*/
|
|
28
|
+
lastRunAt?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface UseThreadsInput {
|
|
32
|
+
agentId: MaybeRefOrGetter<string>;
|
|
33
|
+
includeArchived?: MaybeRefOrGetter<boolean | undefined>;
|
|
34
|
+
limit?: MaybeRefOrGetter<number | undefined>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface UseThreadsResult {
|
|
38
|
+
threads: Ref<Thread[]>;
|
|
39
|
+
isLoading: Ref<boolean>;
|
|
40
|
+
error: Ref<Error | null>;
|
|
41
|
+
hasMoreThreads: Ref<boolean>;
|
|
42
|
+
isFetchingMoreThreads: Ref<boolean>;
|
|
43
|
+
fetchMoreThreads: () => void;
|
|
44
|
+
renameThread: (threadId: string, name: string) => Promise<void>;
|
|
45
|
+
archiveThread: (threadId: string) => Promise<void>;
|
|
46
|
+
deleteThread: (threadId: string) => Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function bindThreadStoreSelector<T>(
|
|
50
|
+
store: ɵThreadStore,
|
|
51
|
+
selector: (state: ReturnType<ɵThreadStore["getState"]>) => T,
|
|
52
|
+
target: Ref<T>,
|
|
53
|
+
): void {
|
|
54
|
+
target.value = selector(store.getState());
|
|
55
|
+
const subscription = store.select(selector).subscribe(() => {
|
|
56
|
+
target.value = selector(store.getState());
|
|
57
|
+
});
|
|
58
|
+
onScopeDispose(() => subscription.unsubscribe());
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Vue composable for listing and managing Intelligence platform threads.
|
|
63
|
+
*
|
|
64
|
+
* The hook fetches threads for the runtime-authenticated user and the given
|
|
65
|
+
* `agentId`, then keeps the result in sync via the core thread store's realtime
|
|
66
|
+
* channel when available. Inputs accept refs/computeds to make thread context
|
|
67
|
+
* changes reactive.
|
|
68
|
+
*/
|
|
69
|
+
export function useThreads(input: UseThreadsInput): UseThreadsResult {
|
|
70
|
+
const { copilotkit } = useCopilotKit();
|
|
71
|
+
const store = ɵcreateThreadStore({
|
|
72
|
+
fetch: globalThis.fetch,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const resolvedAgentId = computed(() => toValue(input.agentId));
|
|
76
|
+
const resolvedIncludeArchived = computed(() =>
|
|
77
|
+
toValue(input.includeArchived),
|
|
78
|
+
);
|
|
79
|
+
const resolvedLimit = computed(() => toValue(input.limit));
|
|
80
|
+
const headersKey = computed(() =>
|
|
81
|
+
JSON.stringify(
|
|
82
|
+
Object.entries(copilotkit.value.headers ?? {}).sort(([left], [right]) =>
|
|
83
|
+
left.localeCompare(right),
|
|
84
|
+
),
|
|
85
|
+
),
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
const threads = ref<Thread[]>([]);
|
|
89
|
+
const storeIsLoading = ref(false);
|
|
90
|
+
const storeError = ref<Error | null>(null);
|
|
91
|
+
const hasMoreThreads = ref(false);
|
|
92
|
+
const isFetchingMoreThreads = ref(false);
|
|
93
|
+
|
|
94
|
+
bindThreadStoreSelector(store, ɵselectThreads, threads as Ref<Thread[]>);
|
|
95
|
+
bindThreadStoreSelector(store, ɵselectThreadsIsLoading, storeIsLoading);
|
|
96
|
+
bindThreadStoreSelector(store, ɵselectThreadsError, storeError);
|
|
97
|
+
bindThreadStoreSelector(store, ɵselectHasNextPage, hasMoreThreads);
|
|
98
|
+
bindThreadStoreSelector(
|
|
99
|
+
store,
|
|
100
|
+
ɵselectIsFetchingNextPage,
|
|
101
|
+
isFetchingMoreThreads,
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
store.start();
|
|
105
|
+
onScopeDispose(() => {
|
|
106
|
+
store.stop();
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// Tracks whether we've dispatched the first real context to the store.
|
|
110
|
+
// The store itself starts with `isLoading: false`, so before we dispatch
|
|
111
|
+
// consumers would otherwise see an empty, non-loading state (empty-list
|
|
112
|
+
// flash). While runtimeUrl is set and we haven't dispatched yet, we
|
|
113
|
+
// synthesize `isLoading: true` so the UI keeps its loading indicator until
|
|
114
|
+
// the first fetch is in flight (at which point the store's own
|
|
115
|
+
// isLoading takes over).
|
|
116
|
+
const hasDispatchedContext = ref(false);
|
|
117
|
+
|
|
118
|
+
// Defer setting the context until the runtime reports Connected. Before
|
|
119
|
+
// `/info` resolves we don't know `intelligence.wsUrl`, so dispatching the
|
|
120
|
+
// context early would issue a list fetch with `wsUrl: undefined`, then a
|
|
121
|
+
// second list fetch (and a `/threads/subscribe`) once the flag lands.
|
|
122
|
+
// Waiting lets the hook issue just one `/threads?…` + one `/threads/subscribe`.
|
|
123
|
+
//
|
|
124
|
+
// When `runtimeUrl` is absent we dispatch `null` to clear the store. For
|
|
125
|
+
// transient states (Disconnected/Connecting/Error with a URL still set) we
|
|
126
|
+
// leave the previously-dispatched context in place — any in-flight
|
|
127
|
+
// realtime subscription or cached thread list stays usable while the
|
|
128
|
+
// runtime recovers, and we don't re-trigger a fetch storm on transitions.
|
|
129
|
+
watch(
|
|
130
|
+
[
|
|
131
|
+
() => copilotkit.value.runtimeUrl,
|
|
132
|
+
() => copilotkit.value.runtimeConnectionStatus,
|
|
133
|
+
headersKey,
|
|
134
|
+
() => copilotkit.value.intelligence?.wsUrl,
|
|
135
|
+
resolvedAgentId,
|
|
136
|
+
resolvedIncludeArchived,
|
|
137
|
+
resolvedLimit,
|
|
138
|
+
],
|
|
139
|
+
([runtimeUrl, runtimeStatus, , wsUrl, agentId, includeArchived, limit]) => {
|
|
140
|
+
if (!runtimeUrl) {
|
|
141
|
+
store.setContext(null);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (runtimeStatus !== CopilotKitCoreRuntimeConnectionStatus.Connected) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const context: ɵThreadRuntimeContext = {
|
|
150
|
+
runtimeUrl,
|
|
151
|
+
headers: { ...copilotkit.value.headers },
|
|
152
|
+
wsUrl,
|
|
153
|
+
agentId,
|
|
154
|
+
includeArchived,
|
|
155
|
+
limit,
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
store.setContext(context);
|
|
159
|
+
hasDispatchedContext.value = true;
|
|
160
|
+
},
|
|
161
|
+
{ immediate: true },
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
const runtimeError = computed<Error | null>(() =>
|
|
165
|
+
copilotkit.value.runtimeUrl
|
|
166
|
+
? null
|
|
167
|
+
: new Error("Runtime URL is not configured"),
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
const preConnectLoading = computed(
|
|
171
|
+
() => !!copilotkit.value.runtimeUrl && !hasDispatchedContext.value,
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
const isLoading = computed(() =>
|
|
175
|
+
runtimeError.value
|
|
176
|
+
? false
|
|
177
|
+
: preConnectLoading.value || storeIsLoading.value,
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
const error = computed<Error | null>(
|
|
181
|
+
() => runtimeError.value ?? storeError.value,
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
return {
|
|
185
|
+
threads: computed(() =>
|
|
186
|
+
threads.value.map(
|
|
187
|
+
({ id, agentId, name, archived, createdAt, updatedAt, lastRunAt }) => ({
|
|
188
|
+
id,
|
|
189
|
+
agentId,
|
|
190
|
+
name,
|
|
191
|
+
archived,
|
|
192
|
+
createdAt,
|
|
193
|
+
updatedAt,
|
|
194
|
+
...(lastRunAt !== undefined ? { lastRunAt } : {}),
|
|
195
|
+
}),
|
|
196
|
+
),
|
|
197
|
+
),
|
|
198
|
+
isLoading,
|
|
199
|
+
error,
|
|
200
|
+
hasMoreThreads,
|
|
201
|
+
isFetchingMoreThreads,
|
|
202
|
+
fetchMoreThreads: () => store.fetchNextPage(),
|
|
203
|
+
renameThread: (threadId: string, name: string) =>
|
|
204
|
+
store.renameThread(threadId, name),
|
|
205
|
+
archiveThread: (threadId: string) => store.archiveThread(threadId),
|
|
206
|
+
deleteThread: (threadId: string) => store.deleteThread(threadId),
|
|
207
|
+
};
|
|
208
|
+
}
|
package/src/v2/index.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Re-export core (framework-agnostic)
|
|
2
|
+
export * from "@copilotkit/core";
|
|
3
|
+
export * from "@ag-ui/client";
|
|
4
|
+
|
|
5
|
+
// Local V2 vue code
|
|
6
|
+
export * from "./components";
|
|
7
|
+
export * from "./hooks";
|
|
8
|
+
export * from "./providers";
|
|
9
|
+
export * from "./types";
|
|
10
|
+
export * from "./lib/vue-core";
|
|
11
|
+
export * from "./lib/processPartialHtml";
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
processPartialHtml,
|
|
4
|
+
extractCompleteStyles,
|
|
5
|
+
} from "../processPartialHtml";
|
|
6
|
+
|
|
7
|
+
describe("processPartialHtml", () => {
|
|
8
|
+
it("returns empty string for empty input", () => {
|
|
9
|
+
expect(processPartialHtml("")).toBe("");
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("strips incomplete tag at end", () => {
|
|
13
|
+
expect(processPartialHtml('<div>Hello<span class="fo')).toBe("<div>Hello");
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("strips complete <style> blocks", () => {
|
|
17
|
+
const input =
|
|
18
|
+
"<div>Hello</div><style>.foo { color: red; }</style><p>World</p>";
|
|
19
|
+
expect(processPartialHtml(input)).toBe("<div>Hello</div><p>World</p>");
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("strips complete <script> blocks", () => {
|
|
23
|
+
const input = '<div>Hello</div><script>alert("hi")</script><p>World</p>';
|
|
24
|
+
expect(processPartialHtml(input)).toBe("<div>Hello</div><p>World</p>");
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("strips incomplete <style> block", () => {
|
|
28
|
+
const input = "<div>Hello</div><style>.foo { color:";
|
|
29
|
+
expect(processPartialHtml(input)).toBe("<div>Hello</div>");
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("strips incomplete <script> block", () => {
|
|
33
|
+
const input = '<div>Hello</div><script>const x = "val';
|
|
34
|
+
expect(processPartialHtml(input)).toBe("<div>Hello</div>");
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("strips incomplete HTML entities", () => {
|
|
38
|
+
expect(processPartialHtml("<p>Hello &")).toBe("<p>Hello ");
|
|
39
|
+
expect(processPartialHtml("<p>Hello {")).toBe("<p>Hello ");
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("preserves complete entities", () => {
|
|
43
|
+
expect(processPartialHtml("<p>Hello & World</p>")).toBe(
|
|
44
|
+
"<p>Hello & World</p>",
|
|
45
|
+
);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("extracts body content from full HTML document", () => {
|
|
49
|
+
const input =
|
|
50
|
+
"<html><head><title>Test</title></head><body><p>Content</p></body></html>";
|
|
51
|
+
expect(processPartialHtml(input)).toBe("<p>Content</p>");
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("handles <body> with attributes", () => {
|
|
55
|
+
const input = '<body class="dark"><p>Content</p></body>';
|
|
56
|
+
expect(processPartialHtml(input)).toBe("<p>Content</p>");
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("handles no <body> tag", () => {
|
|
60
|
+
const input = "<div><p>Just content</p></div>";
|
|
61
|
+
expect(processPartialHtml(input)).toBe("<div><p>Just content</p></div>");
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
describe("extractCompleteStyles", () => {
|
|
66
|
+
it("returns empty string for no styles", () => {
|
|
67
|
+
expect(extractCompleteStyles("<div>Hello</div>")).toBe("");
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("extracts a single complete style block", () => {
|
|
71
|
+
const input =
|
|
72
|
+
"<div>Hello</div><style>.foo { color: red; }</style><p>World</p>";
|
|
73
|
+
expect(extractCompleteStyles(input)).toBe(
|
|
74
|
+
"<style>.foo { color: red; }</style>",
|
|
75
|
+
);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("extracts multiple complete style blocks", () => {
|
|
79
|
+
const input = "<style>a{}</style><div>X</div><style>b{}</style>";
|
|
80
|
+
expect(extractCompleteStyles(input)).toBe(
|
|
81
|
+
"<style>a{}</style><style>b{}</style>",
|
|
82
|
+
);
|
|
83
|
+
});
|
|
84
|
+
});
|