@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,648 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
|
2
|
+
import { defineComponent, h, nextTick, ref } from "vue";
|
|
3
|
+
import type { AbstractAgent, Message } from "@ag-ui/client";
|
|
4
|
+
import { useFrontendTool } from "../use-frontend-tool";
|
|
5
|
+
import type { VueFrontendTool } from "../../types";
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
import { mountWithProvider } from "../../__tests__/utils/mount";
|
|
8
|
+
import {
|
|
9
|
+
SequencedRunAgent,
|
|
10
|
+
StateCapturingAgent,
|
|
11
|
+
toolCallMessage,
|
|
12
|
+
} from "../../__tests__/utils/agents";
|
|
13
|
+
|
|
14
|
+
describe("useFrontendTool", () => {
|
|
15
|
+
let consoleWarnSpy: ReturnType<typeof vi.spyOn>;
|
|
16
|
+
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
consoleWarnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
afterEach(() => {
|
|
22
|
+
consoleWarnSpy.mockRestore();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const assistantMessage = (content: string, id = "assistant-msg"): Message =>
|
|
26
|
+
({
|
|
27
|
+
id,
|
|
28
|
+
role: "assistant",
|
|
29
|
+
content,
|
|
30
|
+
}) as Message;
|
|
31
|
+
|
|
32
|
+
it("registers tool and executes it during agent run", async () => {
|
|
33
|
+
const handler = vi.fn(async () => "ok");
|
|
34
|
+
const tool = {
|
|
35
|
+
name: "dynamicTool",
|
|
36
|
+
description: "Dynamic",
|
|
37
|
+
parameters: z.object({ x: z.number() }),
|
|
38
|
+
handler,
|
|
39
|
+
followUp: false,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const ToolUser = defineComponent({
|
|
43
|
+
setup() {
|
|
44
|
+
useFrontendTool(tool);
|
|
45
|
+
return () => null;
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const agent = new StateCapturingAgent(
|
|
50
|
+
[
|
|
51
|
+
{
|
|
52
|
+
newMessages: [toolCallMessage("dynamicTool", { x: 42 })],
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
"test-agent",
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
const { getCore, wrapper } = mountWithProvider(() => h(ToolUser), {
|
|
59
|
+
agents__unsafe_dev_only: {
|
|
60
|
+
"test-agent": agent as unknown as AbstractAgent,
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
await nextTick();
|
|
65
|
+
await getCore().runAgent({ agent: agent as unknown as AbstractAgent });
|
|
66
|
+
|
|
67
|
+
expect(handler).toHaveBeenCalledWith(
|
|
68
|
+
{ x: 42 },
|
|
69
|
+
expect.objectContaining({
|
|
70
|
+
toolCall: expect.objectContaining({
|
|
71
|
+
function: expect.objectContaining({
|
|
72
|
+
name: "dynamicTool",
|
|
73
|
+
arguments: '{"x":42}',
|
|
74
|
+
}),
|
|
75
|
+
}),
|
|
76
|
+
agent: expect.objectContaining({ agentId: "test-agent" }),
|
|
77
|
+
}),
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
wrapper.unmount();
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("removes tool on unmount", async () => {
|
|
84
|
+
const handler = vi.fn(async () => "ok");
|
|
85
|
+
const tool = {
|
|
86
|
+
name: "toolToRemove",
|
|
87
|
+
description: "Remove",
|
|
88
|
+
parameters: z.object({}),
|
|
89
|
+
handler,
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const Show = defineComponent({
|
|
93
|
+
setup() {
|
|
94
|
+
const shown = ref(true);
|
|
95
|
+
return () =>
|
|
96
|
+
h("div", [
|
|
97
|
+
h(
|
|
98
|
+
"button",
|
|
99
|
+
{
|
|
100
|
+
"data-testid": "toggle",
|
|
101
|
+
onClick: () => (shown.value = !shown.value),
|
|
102
|
+
},
|
|
103
|
+
"toggle",
|
|
104
|
+
),
|
|
105
|
+
shown.value
|
|
106
|
+
? h(
|
|
107
|
+
defineComponent({
|
|
108
|
+
setup() {
|
|
109
|
+
useFrontendTool(tool);
|
|
110
|
+
return () => null;
|
|
111
|
+
},
|
|
112
|
+
}),
|
|
113
|
+
)
|
|
114
|
+
: null,
|
|
115
|
+
]);
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
const agent = new StateCapturingAgent([{ newMessages: [] }], "test-agent");
|
|
120
|
+
const { getCore, wrapper } = mountWithProvider(() => h(Show), {
|
|
121
|
+
agents__unsafe_dev_only: {
|
|
122
|
+
"test-agent": agent as unknown as AbstractAgent,
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
await nextTick();
|
|
127
|
+
expect(getCore().getTool({ toolName: "toolToRemove" })).toBeDefined();
|
|
128
|
+
|
|
129
|
+
await wrapper.find("[data-testid=toggle]").trigger("click");
|
|
130
|
+
await nextTick();
|
|
131
|
+
|
|
132
|
+
expect(getCore().getTool({ toolName: "toolToRemove" })).toBeUndefined();
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it("overrides existing tool and warns", async () => {
|
|
136
|
+
const handler1 = vi.fn(async () => "one");
|
|
137
|
+
const handler2 = vi.fn(async () => "two");
|
|
138
|
+
|
|
139
|
+
const tool1 = {
|
|
140
|
+
name: "sameTool",
|
|
141
|
+
description: "One",
|
|
142
|
+
parameters: z.object({}),
|
|
143
|
+
handler: handler1,
|
|
144
|
+
followUp: false,
|
|
145
|
+
};
|
|
146
|
+
const tool2 = {
|
|
147
|
+
name: "sameTool",
|
|
148
|
+
description: "Two",
|
|
149
|
+
parameters: z.object({}),
|
|
150
|
+
handler: handler2,
|
|
151
|
+
followUp: false,
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const Tool1User = defineComponent({
|
|
155
|
+
setup() {
|
|
156
|
+
useFrontendTool(tool1);
|
|
157
|
+
return () => null;
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
const Tool2User = defineComponent({
|
|
162
|
+
setup() {
|
|
163
|
+
useFrontendTool(tool2);
|
|
164
|
+
return () => null;
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
const Parent = defineComponent({
|
|
169
|
+
setup() {
|
|
170
|
+
const showSecond = ref(false);
|
|
171
|
+
return () =>
|
|
172
|
+
h("div", [
|
|
173
|
+
h(
|
|
174
|
+
"button",
|
|
175
|
+
{
|
|
176
|
+
"data-testid": "show-second",
|
|
177
|
+
onClick: () => (showSecond.value = true),
|
|
178
|
+
},
|
|
179
|
+
"show",
|
|
180
|
+
),
|
|
181
|
+
h(Tool1User),
|
|
182
|
+
showSecond.value ? h(Tool2User) : null,
|
|
183
|
+
]);
|
|
184
|
+
},
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
const agent = new StateCapturingAgent(
|
|
188
|
+
[{ newMessages: [toolCallMessage("sameTool")] }],
|
|
189
|
+
"test-agent",
|
|
190
|
+
);
|
|
191
|
+
const { getCore, wrapper } = mountWithProvider(() => h(Parent), {
|
|
192
|
+
agents__unsafe_dev_only: {
|
|
193
|
+
"test-agent": agent as unknown as AbstractAgent,
|
|
194
|
+
},
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
await nextTick();
|
|
198
|
+
expect(getCore().getTool({ toolName: "sameTool" })?.handler).toBe(handler1);
|
|
199
|
+
|
|
200
|
+
await wrapper.find("[data-testid=show-second]").trigger("click");
|
|
201
|
+
await nextTick();
|
|
202
|
+
await nextTick();
|
|
203
|
+
|
|
204
|
+
expect(consoleWarnSpy).toHaveBeenCalledWith(
|
|
205
|
+
expect.stringContaining("already exists"),
|
|
206
|
+
);
|
|
207
|
+
await getCore().runAgent({ agent: agent as unknown as AbstractAgent });
|
|
208
|
+
|
|
209
|
+
expect(handler2).toHaveBeenCalled();
|
|
210
|
+
expect(handler1).not.toHaveBeenCalled();
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
it("executes wildcard tool when specific tool is missing", async () => {
|
|
214
|
+
const handler = vi.fn(async () => "ok");
|
|
215
|
+
const wildcardTool: VueFrontendTool<{ toolName: string; args: unknown }> = {
|
|
216
|
+
name: "*",
|
|
217
|
+
description: "Wildcard",
|
|
218
|
+
handler,
|
|
219
|
+
followUp: false,
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
const ToolUser = defineComponent({
|
|
223
|
+
setup() {
|
|
224
|
+
useFrontendTool(wildcardTool);
|
|
225
|
+
return () => null;
|
|
226
|
+
},
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
const agent = new StateCapturingAgent(
|
|
230
|
+
[
|
|
231
|
+
{
|
|
232
|
+
newMessages: [toolCallMessage("unknownTool", { message: "hi" })],
|
|
233
|
+
},
|
|
234
|
+
],
|
|
235
|
+
"test-agent",
|
|
236
|
+
);
|
|
237
|
+
|
|
238
|
+
const { getCore, wrapper } = mountWithProvider(() => h(ToolUser), {
|
|
239
|
+
agents__unsafe_dev_only: {
|
|
240
|
+
"test-agent": agent as unknown as AbstractAgent,
|
|
241
|
+
},
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
await nextTick();
|
|
245
|
+
await getCore().runAgent({ agent: agent as unknown as AbstractAgent });
|
|
246
|
+
|
|
247
|
+
expect(handler).toHaveBeenCalledWith(
|
|
248
|
+
{ toolName: "unknownTool", args: { message: "hi" } },
|
|
249
|
+
expect.anything(),
|
|
250
|
+
);
|
|
251
|
+
|
|
252
|
+
wrapper.unmount();
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
it("re-registers tool when dep sources change", async () => {
|
|
256
|
+
const handler = vi.fn(async () => "ok");
|
|
257
|
+
const tool: VueFrontendTool<Record<string, unknown>> = {
|
|
258
|
+
name: "depTool",
|
|
259
|
+
description: "Deps",
|
|
260
|
+
parameters: z.object({}),
|
|
261
|
+
handler,
|
|
262
|
+
followUp: false,
|
|
263
|
+
};
|
|
264
|
+
const version = ref(0);
|
|
265
|
+
|
|
266
|
+
const ToolUser = defineComponent({
|
|
267
|
+
setup() {
|
|
268
|
+
useFrontendTool(tool, [version]);
|
|
269
|
+
return () => null;
|
|
270
|
+
},
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
const agent = new StateCapturingAgent([{ newMessages: [] }], "test-agent");
|
|
274
|
+
const { getCore } = mountWithProvider(() => h(ToolUser), {
|
|
275
|
+
agents__unsafe_dev_only: {
|
|
276
|
+
"test-agent": agent as unknown as AbstractAgent,
|
|
277
|
+
},
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
await nextTick();
|
|
281
|
+
const core = getCore();
|
|
282
|
+
expect(core.getTool({ toolName: "depTool" })).toBeDefined();
|
|
283
|
+
|
|
284
|
+
const addToolSpy = vi.spyOn(core, "addTool");
|
|
285
|
+
version.value += 1;
|
|
286
|
+
await nextTick();
|
|
287
|
+
await nextTick();
|
|
288
|
+
|
|
289
|
+
expect(addToolSpy).toHaveBeenCalled();
|
|
290
|
+
expect(core.getTool({ toolName: "depTool" })).toBeDefined();
|
|
291
|
+
addToolSpy.mockRestore();
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
it("registers a Vue component renderer when provided", async () => {
|
|
295
|
+
const handler = vi.fn(async () => "ok");
|
|
296
|
+
const ToolRenderer = defineComponent({
|
|
297
|
+
props: {
|
|
298
|
+
name: {
|
|
299
|
+
type: String,
|
|
300
|
+
required: true,
|
|
301
|
+
},
|
|
302
|
+
status: {
|
|
303
|
+
type: String,
|
|
304
|
+
required: true,
|
|
305
|
+
},
|
|
306
|
+
},
|
|
307
|
+
template: `<div data-testid="dynamic-tool-renderer">{{ name }}:{{ status }}</div>`,
|
|
308
|
+
});
|
|
309
|
+
const tool: VueFrontendTool<Record<string, unknown>> = {
|
|
310
|
+
name: "componentTool",
|
|
311
|
+
description: "Component renderer",
|
|
312
|
+
parameters: z.object({}),
|
|
313
|
+
handler,
|
|
314
|
+
followUp: false,
|
|
315
|
+
render: ToolRenderer,
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
const ToolUser = defineComponent({
|
|
319
|
+
setup() {
|
|
320
|
+
useFrontendTool(tool);
|
|
321
|
+
return () => null;
|
|
322
|
+
},
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
const agent = new StateCapturingAgent([{ newMessages: [] }], "test-agent");
|
|
326
|
+
const { getCore } = mountWithProvider(() => h(ToolUser), {
|
|
327
|
+
agents__unsafe_dev_only: {
|
|
328
|
+
"test-agent": agent as unknown as AbstractAgent,
|
|
329
|
+
},
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
await nextTick();
|
|
333
|
+
|
|
334
|
+
const renderers = getCore().renderToolCalls;
|
|
335
|
+
expect(renderers).toHaveLength(1);
|
|
336
|
+
expect(renderers[0]?.name).toBe("componentTool");
|
|
337
|
+
expect(renderers[0]?.render).toBe(ToolRenderer);
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
it("stops execution chain when followUp is false", async () => {
|
|
341
|
+
const handler = vi.fn(async () => "done");
|
|
342
|
+
const tool: VueFrontendTool<{ value: string }> = {
|
|
343
|
+
name: "noFollowUpTool",
|
|
344
|
+
description: "No follow up",
|
|
345
|
+
parameters: z.object({ value: z.string() }),
|
|
346
|
+
handler,
|
|
347
|
+
followUp: false,
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
const ToolUser = defineComponent({
|
|
351
|
+
setup() {
|
|
352
|
+
useFrontendTool(tool);
|
|
353
|
+
return () => null;
|
|
354
|
+
},
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
const agent = new SequencedRunAgent(
|
|
358
|
+
[
|
|
359
|
+
() => ({
|
|
360
|
+
newMessages: [toolCallMessage("noFollowUpTool", { value: "x" })],
|
|
361
|
+
}),
|
|
362
|
+
() => ({ newMessages: [assistantMessage("this should not run")] }),
|
|
363
|
+
],
|
|
364
|
+
"test-agent",
|
|
365
|
+
);
|
|
366
|
+
const runSpy = vi.spyOn(agent, "runAgent");
|
|
367
|
+
|
|
368
|
+
const { getCore } = mountWithProvider(() => h(ToolUser), {
|
|
369
|
+
agents__unsafe_dev_only: {
|
|
370
|
+
"test-agent": agent as unknown as AbstractAgent,
|
|
371
|
+
},
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
await nextTick();
|
|
375
|
+
await getCore().runAgent({ agent: agent as unknown as AbstractAgent });
|
|
376
|
+
|
|
377
|
+
expect(runSpy).toHaveBeenCalledTimes(1);
|
|
378
|
+
expect(handler).toHaveBeenCalledTimes(1);
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
it("continues execution chain when followUp is true or undefined", async () => {
|
|
382
|
+
const explicitFollowUpHandler = vi.fn(async () => "continue");
|
|
383
|
+
const defaultFollowUpHandler = vi.fn(async () => "continue-by-default");
|
|
384
|
+
|
|
385
|
+
const explicitTool: VueFrontendTool<{ value: string }> = {
|
|
386
|
+
name: "followUpTool",
|
|
387
|
+
description: "Explicit follow up",
|
|
388
|
+
parameters: z.object({ value: z.string() }),
|
|
389
|
+
handler: explicitFollowUpHandler,
|
|
390
|
+
followUp: true,
|
|
391
|
+
};
|
|
392
|
+
const defaultTool: VueFrontendTool<{ value: string }> = {
|
|
393
|
+
name: "defaultFollowUpTool",
|
|
394
|
+
description: "Default follow up",
|
|
395
|
+
parameters: z.object({ value: z.string() }),
|
|
396
|
+
handler: defaultFollowUpHandler,
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
const ToolUser = defineComponent({
|
|
400
|
+
setup() {
|
|
401
|
+
useFrontendTool(explicitTool);
|
|
402
|
+
useFrontendTool(defaultTool);
|
|
403
|
+
return () => null;
|
|
404
|
+
},
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
const explicitAgent = new SequencedRunAgent(
|
|
408
|
+
[
|
|
409
|
+
() => ({
|
|
410
|
+
newMessages: [toolCallMessage("followUpTool", { value: "x" })],
|
|
411
|
+
}),
|
|
412
|
+
() => ({ newMessages: [assistantMessage("follow-up explicit")] }),
|
|
413
|
+
],
|
|
414
|
+
"test-agent",
|
|
415
|
+
);
|
|
416
|
+
const explicitRunSpy = vi.spyOn(explicitAgent, "runAgent");
|
|
417
|
+
|
|
418
|
+
const { getCore } = mountWithProvider(() => h(ToolUser), {
|
|
419
|
+
agents__unsafe_dev_only: {
|
|
420
|
+
"test-agent": explicitAgent as unknown as AbstractAgent,
|
|
421
|
+
},
|
|
422
|
+
});
|
|
423
|
+
await nextTick();
|
|
424
|
+
await getCore().runAgent({
|
|
425
|
+
agent: explicitAgent as unknown as AbstractAgent,
|
|
426
|
+
});
|
|
427
|
+
expect(explicitRunSpy).toHaveBeenCalledTimes(2);
|
|
428
|
+
expect(explicitFollowUpHandler).toHaveBeenCalledTimes(1);
|
|
429
|
+
|
|
430
|
+
const defaultAgent = new SequencedRunAgent(
|
|
431
|
+
[
|
|
432
|
+
() => ({
|
|
433
|
+
newMessages: [toolCallMessage("defaultFollowUpTool", { value: "y" })],
|
|
434
|
+
}),
|
|
435
|
+
() => ({ newMessages: [assistantMessage("follow-up default")] }),
|
|
436
|
+
],
|
|
437
|
+
"test-agent",
|
|
438
|
+
);
|
|
439
|
+
const defaultRunSpy = vi.spyOn(defaultAgent, "runAgent");
|
|
440
|
+
await getCore().runAgent({
|
|
441
|
+
agent: defaultAgent as unknown as AbstractAgent,
|
|
442
|
+
});
|
|
443
|
+
expect(defaultRunSpy).toHaveBeenCalledTimes(2);
|
|
444
|
+
expect(defaultFollowUpHandler).toHaveBeenCalledTimes(1);
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
it("forwards registered frontend tools to run input", async () => {
|
|
448
|
+
const dynamicTool: VueFrontendTool<{ x: number }> = {
|
|
449
|
+
name: "dynamicForwarded",
|
|
450
|
+
parameters: z.object({ x: z.number() }),
|
|
451
|
+
handler: vi.fn(async () => "ok"),
|
|
452
|
+
followUp: false,
|
|
453
|
+
};
|
|
454
|
+
const baseTool: VueFrontendTool<{ y: number }> = {
|
|
455
|
+
name: "baseForwarded",
|
|
456
|
+
parameters: z.object({ y: z.number() }),
|
|
457
|
+
handler: vi.fn(async () => "ok"),
|
|
458
|
+
followUp: false,
|
|
459
|
+
};
|
|
460
|
+
|
|
461
|
+
const ToolUser = defineComponent({
|
|
462
|
+
setup() {
|
|
463
|
+
useFrontendTool(dynamicTool);
|
|
464
|
+
return () => null;
|
|
465
|
+
},
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
const agent = new StateCapturingAgent([{ newMessages: [] }], "test-agent");
|
|
469
|
+
const { getCore } = mountWithProvider(() => h(ToolUser), {
|
|
470
|
+
frontendTools: [baseTool],
|
|
471
|
+
agents__unsafe_dev_only: {
|
|
472
|
+
"test-agent": agent as unknown as AbstractAgent,
|
|
473
|
+
},
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
await nextTick();
|
|
477
|
+
await getCore().runAgent({ agent: agent as unknown as AbstractAgent });
|
|
478
|
+
|
|
479
|
+
const toolNames = (agent.lastRunInput?.tools ?? []).map(
|
|
480
|
+
(tool) => tool.name,
|
|
481
|
+
);
|
|
482
|
+
expect(toolNames).toContain("baseForwarded");
|
|
483
|
+
expect(toolNames).toContain("dynamicForwarded");
|
|
484
|
+
});
|
|
485
|
+
|
|
486
|
+
it("dispatches agent-scoped tools only for matching agent", async () => {
|
|
487
|
+
const scopedHandler = vi.fn(async () => "scoped");
|
|
488
|
+
const globalHandler = vi.fn(async () => "global");
|
|
489
|
+
|
|
490
|
+
const scopedTool: VueFrontendTool<{ a: number }> = {
|
|
491
|
+
name: "sharedName",
|
|
492
|
+
parameters: z.object({ a: z.number() }),
|
|
493
|
+
handler: scopedHandler,
|
|
494
|
+
followUp: false,
|
|
495
|
+
agentId: "target-agent",
|
|
496
|
+
};
|
|
497
|
+
const globalTool: VueFrontendTool<{ a: number }> = {
|
|
498
|
+
name: "sharedName",
|
|
499
|
+
parameters: z.object({ a: z.number() }),
|
|
500
|
+
handler: globalHandler,
|
|
501
|
+
followUp: false,
|
|
502
|
+
};
|
|
503
|
+
|
|
504
|
+
const ToolUser = defineComponent({
|
|
505
|
+
setup() {
|
|
506
|
+
useFrontendTool(scopedTool);
|
|
507
|
+
useFrontendTool(globalTool);
|
|
508
|
+
return () => null;
|
|
509
|
+
},
|
|
510
|
+
});
|
|
511
|
+
|
|
512
|
+
const targetAgent = new StateCapturingAgent(
|
|
513
|
+
[{ newMessages: [toolCallMessage("sharedName", { a: 1 })] }],
|
|
514
|
+
"target-agent",
|
|
515
|
+
);
|
|
516
|
+
const otherAgent = new StateCapturingAgent(
|
|
517
|
+
[{ newMessages: [toolCallMessage("sharedName", { a: 2 })] }],
|
|
518
|
+
"other-agent",
|
|
519
|
+
);
|
|
520
|
+
|
|
521
|
+
const { getCore } = mountWithProvider(() => h(ToolUser), {
|
|
522
|
+
agents__unsafe_dev_only: {
|
|
523
|
+
"target-agent": targetAgent as unknown as AbstractAgent,
|
|
524
|
+
"other-agent": otherAgent as unknown as AbstractAgent,
|
|
525
|
+
},
|
|
526
|
+
});
|
|
527
|
+
|
|
528
|
+
await nextTick();
|
|
529
|
+
await getCore().runAgent({
|
|
530
|
+
agent: targetAgent as unknown as AbstractAgent,
|
|
531
|
+
});
|
|
532
|
+
await getCore().runAgent({ agent: otherAgent as unknown as AbstractAgent });
|
|
533
|
+
|
|
534
|
+
expect(scopedHandler).toHaveBeenCalledTimes(1);
|
|
535
|
+
expect(globalHandler).toHaveBeenCalledTimes(1);
|
|
536
|
+
expect(scopedHandler).toHaveBeenCalledWith(
|
|
537
|
+
{ a: 1 },
|
|
538
|
+
expect.objectContaining({
|
|
539
|
+
agent: expect.objectContaining({ agentId: "target-agent" }),
|
|
540
|
+
}),
|
|
541
|
+
);
|
|
542
|
+
expect(globalHandler).toHaveBeenCalledWith(
|
|
543
|
+
{ a: 2 },
|
|
544
|
+
expect.objectContaining({
|
|
545
|
+
agent: expect.objectContaining({ agentId: "other-agent" }),
|
|
546
|
+
}),
|
|
547
|
+
);
|
|
548
|
+
});
|
|
549
|
+
|
|
550
|
+
it("converts handler errors into tool error messages", async () => {
|
|
551
|
+
const handler = vi.fn(async () => {
|
|
552
|
+
throw new Error("boom");
|
|
553
|
+
});
|
|
554
|
+
const tool: VueFrontendTool<{ x: number }> = {
|
|
555
|
+
name: "errorTool",
|
|
556
|
+
parameters: z.object({ x: z.number() }),
|
|
557
|
+
handler,
|
|
558
|
+
followUp: false,
|
|
559
|
+
};
|
|
560
|
+
|
|
561
|
+
const ToolUser = defineComponent({
|
|
562
|
+
setup() {
|
|
563
|
+
useFrontendTool(tool);
|
|
564
|
+
return () => null;
|
|
565
|
+
},
|
|
566
|
+
});
|
|
567
|
+
|
|
568
|
+
const agent = new StateCapturingAgent(
|
|
569
|
+
[{ newMessages: [toolCallMessage("errorTool", { x: 1 })] }],
|
|
570
|
+
"test-agent",
|
|
571
|
+
);
|
|
572
|
+
|
|
573
|
+
const { getCore } = mountWithProvider(() => h(ToolUser), {
|
|
574
|
+
agents__unsafe_dev_only: {
|
|
575
|
+
"test-agent": agent as unknown as AbstractAgent,
|
|
576
|
+
},
|
|
577
|
+
});
|
|
578
|
+
|
|
579
|
+
await nextTick();
|
|
580
|
+
await expect(
|
|
581
|
+
getCore().runAgent({ agent: agent as unknown as AbstractAgent }),
|
|
582
|
+
).resolves.toBeDefined();
|
|
583
|
+
|
|
584
|
+
const toolMessage = agent.messages.find(
|
|
585
|
+
(message) => message.role === "tool",
|
|
586
|
+
);
|
|
587
|
+
expect(toolMessage?.content).toContain("Error: boom");
|
|
588
|
+
});
|
|
589
|
+
|
|
590
|
+
it("throws on argument parse errors and does not call handler", async () => {
|
|
591
|
+
const handler = vi.fn(async () => "ok");
|
|
592
|
+
const tool: VueFrontendTool<{ x: number }> = {
|
|
593
|
+
name: "parseTool",
|
|
594
|
+
parameters: z.object({ x: z.number() }),
|
|
595
|
+
handler,
|
|
596
|
+
followUp: false,
|
|
597
|
+
};
|
|
598
|
+
|
|
599
|
+
const invalidToolCall: Message = {
|
|
600
|
+
id: "bad-call",
|
|
601
|
+
role: "assistant",
|
|
602
|
+
content: "",
|
|
603
|
+
toolCalls: [
|
|
604
|
+
{
|
|
605
|
+
id: "tool-1",
|
|
606
|
+
type: "function",
|
|
607
|
+
function: {
|
|
608
|
+
name: "parseTool",
|
|
609
|
+
arguments: "{not valid json",
|
|
610
|
+
},
|
|
611
|
+
},
|
|
612
|
+
],
|
|
613
|
+
} as Message;
|
|
614
|
+
|
|
615
|
+
const ToolUser = defineComponent({
|
|
616
|
+
setup() {
|
|
617
|
+
useFrontendTool(tool);
|
|
618
|
+
return () => null;
|
|
619
|
+
},
|
|
620
|
+
});
|
|
621
|
+
|
|
622
|
+
const agent = new StateCapturingAgent(
|
|
623
|
+
[{ newMessages: [invalidToolCall] }],
|
|
624
|
+
"test-agent",
|
|
625
|
+
);
|
|
626
|
+
|
|
627
|
+
const { getCore } = mountWithProvider(() => h(ToolUser), {
|
|
628
|
+
agents__unsafe_dev_only: {
|
|
629
|
+
"test-agent": agent as unknown as AbstractAgent,
|
|
630
|
+
},
|
|
631
|
+
});
|
|
632
|
+
|
|
633
|
+
await nextTick();
|
|
634
|
+
await expect(
|
|
635
|
+
getCore().runAgent({ agent: agent as unknown as AbstractAgent }),
|
|
636
|
+
).resolves.toMatchObject({
|
|
637
|
+
newMessages: [invalidToolCall],
|
|
638
|
+
});
|
|
639
|
+
expect(handler).not.toHaveBeenCalled();
|
|
640
|
+
expect(agent.messages).toContainEqual(
|
|
641
|
+
expect.objectContaining({
|
|
642
|
+
role: "tool",
|
|
643
|
+
toolCallId: "tool-1",
|
|
644
|
+
content: expect.stringContaining("Error:"),
|
|
645
|
+
}),
|
|
646
|
+
);
|
|
647
|
+
});
|
|
648
|
+
});
|