@copilotkit/vue 2.0.0-rc.2 → 2.0.0-rc.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/PARITY.md +3 -3
- package/dist/hooks/use-copilot-action.d.ts.map +1 -1
- package/dist/hooks/use-frontend-tool.d.ts +1 -1
- package/dist/hooks/use-frontend-tool.d.ts.map +1 -1
- package/dist/hooks/zod-parameters.d.ts +14 -0
- package/dist/hooks/zod-parameters.d.ts.map +1 -0
- package/dist/index.cjs +1 -73
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +365 -16920
- package/dist/index.mjs.map +1 -1
- package/dist/use-render-activity-message-BAhbpSDh.js +16200 -0
- package/dist/use-render-activity-message-BAhbpSDh.js.map +1 -0
- package/dist/use-render-activity-message-DJ6q1qHV.cjs +114 -0
- package/dist/use-render-activity-message-DJ6q1qHV.cjs.map +1 -0
- package/dist/v2/components/A2UIMessageRenderer.d.ts +14 -0
- package/dist/v2/components/A2UIMessageRenderer.d.ts.map +1 -1
- package/dist/v2/components/A2UISurfaceActivityRenderer.vue.d.ts +10 -3
- package/dist/v2/components/A2UISurfaceActivityRenderer.vue.d.ts.map +1 -1
- package/dist/v2/components/CopilotKitInspector.vue.d.ts +5 -1
- package/dist/v2/components/CopilotKitInspector.vue.d.ts.map +1 -1
- package/dist/v2/components/InlineFeatureWarning.vue.d.ts.map +1 -1
- package/dist/v2/components/LicenseWarningBanner.vue.d.ts +2 -2
- package/dist/v2/components/LicenseWarningBanner.vue.d.ts.map +1 -1
- package/dist/v2/components/MCPAppsActivityRenderer.d.ts.map +1 -1
- package/dist/v2/components/OpenGenerativeUIRenderer.d.ts +13 -59
- package/dist/v2/components/OpenGenerativeUIRenderer.d.ts.map +1 -1
- package/dist/v2/components/a2ui/A2UIBuiltInToolCallRenderer.d.ts +0 -5
- package/dist/v2/components/a2ui/A2UIBuiltInToolCallRenderer.d.ts.map +1 -1
- package/dist/v2/components/a2ui/A2UICatalogContext.d.ts +10 -15
- package/dist/v2/components/a2ui/A2UICatalogContext.d.ts.map +1 -1
- package/dist/v2/components/a2ui/A2UIRecoveryStates.d.ts +14 -130
- package/dist/v2/components/a2ui/A2UIRecoveryStates.d.ts.map +1 -1
- package/dist/v2/components/a2ui/catalog.d.ts.map +1 -1
- package/dist/v2/components/a2ui/utils.d.ts +3 -15
- package/dist/v2/components/a2ui/utils.d.ts.map +1 -1
- package/dist/v2/components/a2ui.d.ts +9 -8
- package/dist/v2/components/a2ui.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChat.vue.d.ts +2 -2
- package/dist/v2/components/chat/CopilotChat.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatAssistantMessage.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatAttachmentQueue.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatAttachmentRenderer.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatAudioRecorder.vue.d.ts +4 -8
- package/dist/v2/components/chat/CopilotChatAudioRecorder.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatFeedbackCommentPopover.vue.d.ts +1 -1
- package/dist/v2/components/chat/CopilotChatFeedbackCommentPopover.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatInput.vue.d.ts +6 -270
- package/dist/v2/components/chat/CopilotChatInput.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatInspectorButton.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatLightbox.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatMessageView.vue.d.ts +1 -1
- package/dist/v2/components/chat/CopilotChatMessageView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatReasoningMessage.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatToolCallGroup.vue.d.ts +1 -1
- package/dist/v2/components/chat/CopilotChatToolCallGroup.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatToolCallItem.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatToolCallsView.vue.d.ts +1 -1
- package/dist/v2/components/chat/CopilotChatToolCallsView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatUserMessage.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatView.vue.d.ts +3 -3
- package/dist/v2/components/chat/CopilotChatView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatWorkSummary.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotModalHeader.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotPopup.vue.d.ts +8 -3
- package/dist/v2/components/chat/CopilotPopup.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotPopupView.vue.d.ts +5 -3
- package/dist/v2/components/chat/CopilotPopupView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotPopupViewInternal.vue.d.ts +5 -3
- package/dist/v2/components/chat/CopilotPopupViewInternal.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotSidebar.vue.d.ts +8 -3
- package/dist/v2/components/chat/CopilotSidebar.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotSidebarView.vue.d.ts +6 -4
- package/dist/v2/components/chat/CopilotSidebarView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotSidebarViewInternal.vue.d.ts +6 -4
- package/dist/v2/components/chat/CopilotSidebarViewInternal.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotThreadsDrawer.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/StreamingMarkdownDefault.vue.d.ts +1 -0
- package/dist/v2/components/chat/StreamingMarkdownDefault.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/audioRecorder.d.ts +3 -4
- package/dist/v2/components/chat/audioRecorder.d.ts.map +1 -1
- package/dist/v2/components/chat/copilotChatToolCallItemRender.d.ts +3 -3
- package/dist/v2/components/chat/copilotChatToolCallItemRender.d.ts.map +1 -1
- package/dist/v2/components/chat/forwarded-slots.d.ts +12 -0
- package/dist/v2/components/chat/forwarded-slots.d.ts.map +1 -0
- package/dist/v2/components/chat/index.d.ts +34 -31
- package/dist/v2/components/chat/index.d.ts.map +1 -1
- package/dist/v2/components/chat/inspector-shortcuts.d.ts +2 -1
- package/dist/v2/components/chat/inspector-shortcuts.d.ts.map +1 -1
- package/dist/v2/components/chat/message-feedback.d.ts +18 -49
- package/dist/v2/components/chat/message-feedback.d.ts.map +1 -1
- package/dist/v2/components/chat/tool-call-display-context.d.ts +4 -19
- package/dist/v2/components/chat/tool-call-display-context.d.ts.map +1 -1
- package/dist/v2/components/chat/tool-call-group-parts.d.ts +7 -20
- package/dist/v2/components/chat/tool-call-group-parts.d.ts.map +1 -1
- package/dist/v2/components/chat/turn-work.d.ts +0 -2
- package/dist/v2/components/chat/turn-work.d.ts.map +1 -1
- package/dist/v2/components/chat/types.d.ts +9 -4
- package/dist/v2/components/chat/types.d.ts.map +1 -1
- package/dist/v2/components/chat/use-chat-labels.d.ts +8 -0
- package/dist/v2/components/chat/use-chat-labels.d.ts.map +1 -0
- package/dist/v2/components/chat/use-copy-feedback.d.ts +11 -0
- package/dist/v2/components/chat/use-copy-feedback.d.ts.map +1 -0
- package/dist/v2/components/chat/use-lightbox.d.ts.map +1 -1
- package/dist/v2/components/icons/index.d.ts +968 -1
- package/dist/v2/components/icons/index.d.ts.map +1 -1
- package/dist/v2/components/ui/CopilotDropdownMenuContent.vue.d.ts +1 -1
- package/dist/v2/components/ui/CopilotDropdownMenuContent.vue.d.ts.map +1 -1
- package/dist/v2/hooks/use-agent-context.d.ts +2 -3
- package/dist/v2/hooks/use-agent-context.d.ts.map +1 -1
- package/dist/v2/hooks/use-agent.d.ts +4 -1
- package/dist/v2/hooks/use-agent.d.ts.map +1 -1
- package/dist/v2/hooks/use-attachments.d.ts +7 -0
- package/dist/v2/hooks/use-attachments.d.ts.map +1 -1
- package/dist/v2/hooks/use-capabilities.d.ts.map +1 -1
- package/dist/v2/hooks/use-component.d.ts +1 -0
- package/dist/v2/hooks/use-component.d.ts.map +1 -1
- package/dist/v2/hooks/use-configure-suggestions.d.ts +4 -9
- package/dist/v2/hooks/use-configure-suggestions.d.ts.map +1 -1
- package/dist/v2/hooks/use-default-render-tool.d.ts.map +1 -1
- package/dist/v2/hooks/use-frontend-tool.d.ts +5 -0
- package/dist/v2/hooks/use-frontend-tool.d.ts.map +1 -1
- package/dist/v2/hooks/use-human-in-the-loop.d.ts +2 -1
- package/dist/v2/hooks/use-human-in-the-loop.d.ts.map +1 -1
- package/dist/v2/hooks/use-interrupt.d.ts +0 -1
- package/dist/v2/hooks/use-interrupt.d.ts.map +1 -1
- package/dist/v2/hooks/use-keyboard-height.d.ts +1 -1
- package/dist/v2/hooks/use-keyboard-height.d.ts.map +1 -1
- package/dist/v2/hooks/use-pin-to-send.d.ts +4 -12
- package/dist/v2/hooks/use-pin-to-send.d.ts.map +1 -1
- package/dist/v2/hooks/use-render-activity-message.d.ts +13 -9
- package/dist/v2/hooks/use-render-activity-message.d.ts.map +1 -1
- package/dist/v2/hooks/use-render-custom-messages.d.ts +5 -7
- package/dist/v2/hooks/use-render-custom-messages.d.ts.map +1 -1
- package/dist/v2/hooks/use-suggestions.d.ts.map +1 -1
- package/dist/v2/hooks/use-threads.d.ts +0 -8
- package/dist/v2/hooks/use-threads.d.ts.map +1 -1
- package/dist/v2/index.cjs +1 -1
- package/dist/v2/index.mjs +197 -200
- package/dist/v2/index.mjs.map +1 -1
- package/dist/v2/lib/processPartialHtml.d.ts +1 -2
- package/dist/v2/lib/processPartialHtml.d.ts.map +1 -1
- package/dist/v2/lib/shallow-stable.d.ts.map +1 -1
- package/dist/v2/lib/vue-core.d.ts +12 -12
- package/dist/v2/lib/vue-core.d.ts.map +1 -1
- package/dist/v2/providers/CopilotChatConfigurationProvider.vue.d.ts.map +1 -1
- package/dist/v2/providers/CopilotKitProvider.types.d.ts +9 -129
- package/dist/v2/providers/CopilotKitProvider.types.d.ts.map +1 -1
- package/dist/v2/providers/CopilotKitProvider.vue.d.ts +9 -10
- package/dist/v2/providers/CopilotKitProvider.vue.d.ts.map +1 -1
- package/dist/v2/providers/chat-configuration-store-key.d.ts +8 -0
- package/dist/v2/providers/chat-configuration-store-key.d.ts.map +1 -0
- package/dist/v2/providers/markdown-renderer.d.ts +4 -2
- package/dist/v2/providers/markdown-renderer.d.ts.map +1 -1
- package/dist/v2/providers/types.d.ts +3 -46
- package/dist/v2/providers/types.d.ts.map +1 -1
- package/dist/v2/providers/use-inspector-thread-override.d.ts +5 -0
- package/dist/v2/providers/use-inspector-thread-override.d.ts.map +1 -1
- package/dist/v2/types/human-in-the-loop.d.ts +8 -29
- package/dist/v2/types/human-in-the-loop.d.ts.map +1 -1
- package/dist/v2/types/interrupt.d.ts +1 -22
- package/dist/v2/types/interrupt.d.ts.map +1 -1
- package/dist/v2/types/vue-activity-message-renderer.d.ts +16 -15
- package/dist/v2/types/vue-activity-message-renderer.d.ts.map +1 -1
- package/dist/v2/types/vue-custom-message-renderer.d.ts +7 -16
- package/dist/v2/types/vue-custom-message-renderer.d.ts.map +1 -1
- package/dist/v2/types/vue-tool-call-renderer.d.ts +16 -35
- package/dist/v2/types/vue-tool-call-renderer.d.ts.map +1 -1
- package/package.json +10 -11
- package/src/__tests__/build-entries.test.ts +27 -0
- package/src/hooks/__tests__/zod-parameters.test.ts +520 -0
- package/src/hooks/use-copilot-action.ts +2 -1
- package/src/hooks/use-frontend-tool.ts +3 -6
- package/src/hooks/zod-parameters.ts +162 -0
- package/src/v2/__tests__/exports.test.ts +10 -0
- package/src/v2/__tests__/mocks/web-inspector.ts +6 -0
- package/src/v2/__tests__/utils/test-helpers.ts +34 -4
- package/src/v2/components/A2UIMessageRenderer.ts +98 -68
- package/src/v2/components/A2UISurfaceActivityRenderer.vue +68 -103
- package/src/v2/components/CopilotKitInspector.vue +104 -51
- package/src/v2/components/InlineFeatureWarning.vue +20 -21
- package/src/v2/components/LicenseWarningBanner.vue +27 -135
- package/src/v2/components/MCPAppsActivityRenderer.ts +75 -201
- package/src/v2/components/OpenGenerativeUIRenderer.ts +122 -446
- package/src/v2/components/__tests__/A2UIMessageRenderer.test.ts +171 -8
- package/src/v2/components/__tests__/CopilotKitInspector.test.ts +42 -0
- package/src/v2/components/__tests__/LicenseWarningBanner.test.ts +60 -0
- package/src/v2/components/__tests__/OpenGenerativeUIRenderer.test.ts +64 -8
- package/src/v2/components/__tests__/OpenGenerativeUIToolRenderer.test.ts +38 -0
- package/src/v2/components/a2ui/A2UIBuiltInToolCallRenderer.ts +2 -7
- package/src/v2/components/a2ui/A2UICatalogContext.ts +27 -185
- package/src/v2/components/a2ui/A2UIRecoveryStates.ts +127 -327
- package/src/v2/components/a2ui/catalog.ts +3 -3
- package/src/v2/components/a2ui/utils.ts +13 -65
- package/src/v2/components/a2ui.ts +15 -22
- package/src/v2/components/chat/CopilotChat.vue +147 -356
- package/src/v2/components/chat/CopilotChatAssistantMessage.vue +19 -43
- package/src/v2/components/chat/CopilotChatAttachmentQueue.vue +36 -55
- package/src/v2/components/chat/CopilotChatAttachmentRenderer.vue +14 -6
- package/src/v2/components/chat/CopilotChatAudioRecorder.vue +19 -246
- package/src/v2/components/chat/CopilotChatFeedbackCommentPopover.vue +2 -2
- package/src/v2/components/chat/CopilotChatInput.vue +108 -436
- package/src/v2/components/chat/CopilotChatInspectorButton.vue +45 -108
- package/src/v2/components/chat/CopilotChatLightbox.vue +10 -31
- package/src/v2/components/chat/CopilotChatMessageView.vue +82 -210
- package/src/v2/components/chat/CopilotChatReasoningMessage.vue +7 -15
- package/src/v2/components/chat/CopilotChatToolCallGroup.vue +63 -71
- package/src/v2/components/chat/CopilotChatToolCallItem.vue +8 -6
- package/src/v2/components/chat/CopilotChatToolCallsView.vue +31 -32
- package/src/v2/components/chat/CopilotChatUserMessage.vue +24 -112
- package/src/v2/components/chat/CopilotChatView.vue +33 -28
- package/src/v2/components/chat/CopilotChatWorkSummary.vue +26 -36
- package/src/v2/components/chat/CopilotModalHeader.vue +11 -23
- package/src/v2/components/chat/CopilotPopup.vue +23 -25
- package/src/v2/components/chat/CopilotPopupView.vue +10 -39
- package/src/v2/components/chat/CopilotPopupViewInternal.vue +35 -131
- package/src/v2/components/chat/CopilotSidebar.vue +23 -25
- package/src/v2/components/chat/CopilotSidebarView.vue +10 -39
- package/src/v2/components/chat/CopilotSidebarViewInternal.vue +38 -59
- package/src/v2/components/chat/CopilotThreadsDrawer.vue +37 -102
- package/src/v2/components/chat/StreamingMarkdownDefault.vue +15 -28
- package/src/v2/components/chat/__tests__/CopilotChat.labels.test.ts +19 -4
- package/src/v2/components/chat/__tests__/CopilotChat.test.ts +12 -10
- package/src/v2/components/chat/__tests__/CopilotChatActivityRendering.e2e.test.ts +26 -9
- package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.learningFeedback.test.ts +5 -5
- package/src/v2/components/chat/__tests__/CopilotChatAttachmentQueue.test.ts +28 -0
- package/src/v2/components/chat/__tests__/CopilotChatInput.test.ts +89 -1
- package/src/v2/components/chat/__tests__/CopilotChatMessageView.test.ts +247 -403
- package/src/v2/components/chat/__tests__/CopilotChatMessageView.toolCallDisplay.test.ts +1 -99
- package/src/v2/components/chat/__tests__/CopilotPopup.test.ts +90 -1
- package/src/v2/components/chat/__tests__/CopilotPopupView.test.ts +19 -0
- package/src/v2/components/chat/__tests__/CopilotSidebar.test.ts +90 -1
- package/src/v2/components/chat/__tests__/CopilotSidebarView.position.test.ts +32 -8
- package/src/v2/components/chat/__tests__/CopilotSidebarView.test.ts +2 -1
- package/src/v2/components/chat/__tests__/StreamingMarkdownDefault.test.ts +54 -0
- package/src/v2/components/chat/audioRecorder.ts +4 -7
- package/src/v2/components/chat/copilotChatToolCallItemRender.ts +24 -89
- package/src/v2/components/chat/forwarded-slots.ts +17 -0
- package/src/v2/components/chat/index.ts +0 -1
- package/src/v2/components/chat/inspector-shortcuts.ts +10 -16
- package/src/v2/components/chat/message-feedback.ts +62 -197
- package/src/v2/components/chat/tool-call-display-context.ts +6 -22
- package/src/v2/components/chat/tool-call-group-parts.ts +47 -108
- package/src/v2/components/chat/turn-work.ts +0 -9
- package/src/v2/components/chat/types.ts +12 -4
- package/src/v2/components/chat/use-chat-labels.ts +16 -0
- package/src/v2/components/chat/use-copy-feedback.ts +21 -0
- package/src/v2/components/chat/use-lightbox.ts +15 -33
- package/src/v2/components/icons/__tests__/icons.test.ts +72 -68
- package/src/v2/components/icons/index.ts +109 -27
- package/src/v2/hooks/__tests__/use-agent-error-state.test.ts +5 -3
- package/src/v2/hooks/__tests__/use-agent-stability.test.ts +25 -4
- package/src/v2/hooks/__tests__/use-agent-throttle.test.ts +5 -1
- package/src/v2/hooks/__tests__/use-agent.test.ts +6 -3
- package/src/v2/hooks/__tests__/use-component.test.ts +21 -0
- package/src/v2/hooks/__tests__/use-configure-suggestions.test.ts +30 -1
- package/src/v2/hooks/__tests__/use-default-render-tool.test.ts +10 -10
- package/src/v2/hooks/__tests__/use-frontend-tool.e2e.test.ts +66 -1
- package/src/v2/hooks/__tests__/use-human-in-the-loop.e2e.test.ts +6 -1
- package/src/v2/hooks/__tests__/use-human-in-the-loop.test.ts +187 -12
- package/src/v2/hooks/__tests__/use-interrupt.test.ts +97 -0
- package/src/v2/hooks/__tests__/use-render-activity-message.test.ts +106 -0
- package/src/v2/hooks/__tests__/use-render-tool.test.ts +3 -6
- package/src/v2/hooks/__tests__/use-threads.test.ts +48 -6
- package/src/v2/hooks/__tests__/zod-regression.test.ts +5 -4
- package/src/v2/hooks/use-agent-context.ts +4 -10
- package/src/v2/hooks/use-agent.ts +86 -290
- package/src/v2/hooks/use-attachments.ts +48 -168
- package/src/v2/hooks/use-capabilities.ts +2 -7
- package/src/v2/hooks/use-component.ts +7 -4
- package/src/v2/hooks/use-configure-suggestions.ts +28 -218
- package/src/v2/hooks/use-default-render-tool.ts +34 -94
- package/src/v2/hooks/use-frontend-tool.ts +10 -10
- package/src/v2/hooks/use-human-in-the-loop.ts +11 -80
- package/src/v2/hooks/use-interrupt.ts +29 -308
- package/src/v2/hooks/use-keyboard-height.ts +17 -40
- package/src/v2/hooks/use-pin-to-send.ts +15 -99
- package/src/v2/hooks/use-render-activity-message.ts +31 -55
- package/src/v2/hooks/use-render-custom-messages.ts +24 -88
- package/src/v2/hooks/use-suggestions.ts +9 -33
- package/src/v2/hooks/use-threads.ts +43 -273
- package/src/v2/lib/__tests__/shallow-stable.test.ts +54 -0
- package/src/v2/lib/__tests__/vue-core-renderers.test.ts +42 -0
- package/src/v2/lib/processPartialHtml.ts +6 -21
- package/src/v2/lib/shallow-stable.ts +2 -16
- package/src/v2/lib/vue-core.ts +69 -78
- package/src/v2/providers/CopilotChatConfigurationProvider.vue +48 -186
- package/src/v2/providers/CopilotKitProvider.types.ts +12 -132
- package/src/v2/providers/CopilotKitProvider.vue +237 -510
- package/src/v2/providers/__tests__/CopilotChatConfigurationProvider.test.ts +22 -2
- package/src/v2/providers/__tests__/CopilotKitProvider.a2ui.test.ts +20 -2
- package/src/v2/providers/__tests__/CopilotKitProvider.config.test.ts +124 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.headersAtSendTime.test.ts +3 -3
- package/src/v2/providers/__tests__/CopilotKitProvider.learning.test.ts +3 -1
- package/src/v2/providers/__tests__/CopilotKitProvider.sandboxFunctions.test.ts +4 -1
- package/src/v2/providers/__tests__/CopilotKitProvider.test.ts +53 -26
- package/src/v2/providers/chat-configuration-store-key.ts +9 -0
- package/src/v2/providers/markdown-renderer.ts +8 -2
- package/src/v2/providers/types.ts +3 -49
- package/src/v2/providers/use-inspector-thread-override.ts +22 -80
- package/src/v2/types/__tests__/defineToolCallRenderer.test.ts +28 -33
- package/src/v2/types/defineToolCallRenderer.ts +5 -4
- package/src/v2/types/human-in-the-loop.ts +8 -32
- package/src/v2/types/interrupt.ts +7 -31
- package/src/v2/types/vue-activity-message-renderer.ts +24 -15
- package/src/v2/types/vue-custom-message-renderer.ts +12 -16
- package/src/v2/types/vue-tool-call-renderer.ts +23 -38
- package/tsconfig.json +0 -1
- package/vite.config.ts +8 -5
- package/vitest.config.ts +12 -7
- package/dist/v2/components/chat/BasicMarkdown.vue.d.ts +0 -9
- package/dist/v2/components/chat/BasicMarkdown.vue.d.ts.map +0 -1
- package/dist/v2/components/chat/normalize-auto-scroll.d.ts +0 -3
- package/dist/v2/components/chat/normalize-auto-scroll.d.ts.map +0 -1
- package/dist/v2/components/chat/tool-call-layout.d.ts +0 -115
- package/dist/v2/components/chat/tool-call-layout.d.ts.map +0 -1
- package/dist/v2/lib/is-mobile-viewport.d.ts +0 -15
- package/dist/v2/lib/is-mobile-viewport.d.ts.map +0 -1
- package/dist/v2/lib/message-feedback.d.ts +0 -33
- package/dist/v2/lib/message-feedback.d.ts.map +0 -1
- package/dist/v2/lib/transcription-client.d.ts +0 -19
- package/dist/v2/lib/transcription-client.d.ts.map +0 -1
- package/src/v2/components/__tests__/A2UICatalogContext.test.ts +0 -63
- package/src/v2/components/a2ui/__tests__/A2UIRecoveryStates.test.ts +0 -175
- package/src/v2/components/chat/BasicMarkdown.vue +0 -160
- package/src/v2/components/chat/__tests__/BasicMarkdown.test.ts +0 -69
- package/src/v2/components/chat/__tests__/normalize-auto-scroll.test.ts +0 -39
- package/src/v2/components/chat/normalize-auto-scroll.ts +0 -17
- package/src/v2/components/chat/tool-call-layout.ts +0 -304
- package/src/v2/lib/__tests__/is-mobile-viewport.test.ts +0 -48
- package/src/v2/lib/__tests__/message-feedback.test.ts +0 -152
- package/src/v2/lib/__tests__/processPartialHtml.test.ts +0 -84
- package/src/v2/lib/__tests__/transcription-client.test.ts +0 -67
- package/src/v2/lib/is-mobile-viewport.ts +0 -23
- package/src/v2/lib/message-feedback.ts +0 -120
- package/src/v2/lib/transcription-client.ts +0 -151
|
@@ -4,6 +4,19 @@ import type { Ref } from "vue";
|
|
|
4
4
|
import { describe, expect, it, beforeEach, vi } from "vitest";
|
|
5
5
|
import { useCopilotKit } from "../../providers/useCopilotKit";
|
|
6
6
|
|
|
7
|
+
/** Core's `ɵruntimeInfo` snapshot, built from a fake core's runtime fields. */
|
|
8
|
+
function runtimeInfoOf(core: {
|
|
9
|
+
runtimeConnectionStatus: CopilotKitCoreRuntimeConnectionStatus;
|
|
10
|
+
threadEndpoints?: unknown;
|
|
11
|
+
intelligence?: unknown;
|
|
12
|
+
}) {
|
|
13
|
+
return {
|
|
14
|
+
status: core.runtimeConnectionStatus,
|
|
15
|
+
threadEndpoints: core.threadEndpoints,
|
|
16
|
+
intelligence: core.intelligence,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
7
20
|
type ThreadRecord = {
|
|
8
21
|
id: string;
|
|
9
22
|
organizationId: string;
|
|
@@ -54,7 +67,8 @@ function compareThreadsByActivity(left: ThreadRecord, right: ThreadRecord) {
|
|
|
54
67
|
return rightKey.localeCompare(leftKey);
|
|
55
68
|
}
|
|
56
69
|
|
|
57
|
-
vi.mock("@copilotkit/core", () => {
|
|
70
|
+
vi.mock("@copilotkit/core", async (importOriginal) => {
|
|
71
|
+
const actual = await importOriginal<typeof import("@copilotkit/core")>();
|
|
58
72
|
class MockChannel {
|
|
59
73
|
topic: string;
|
|
60
74
|
left = false;
|
|
@@ -118,6 +132,16 @@ vi.mock("@copilotkit/core", () => {
|
|
|
118
132
|
private listeners = new Set<() => void>();
|
|
119
133
|
private socket: MockSocket | null = null;
|
|
120
134
|
|
|
135
|
+
readonly selectors = {
|
|
136
|
+
threads: (state: ThreadState) => state.threads,
|
|
137
|
+
isLoading: (state: ThreadState) => state.isLoading,
|
|
138
|
+
error: (state: ThreadState) => state.error,
|
|
139
|
+
fetchMoreError: (state: ThreadState) => state.fetchMoreError,
|
|
140
|
+
hasNextPage: (state: ThreadState) => state.hasNextPage,
|
|
141
|
+
isFetchingNextPage: (state: ThreadState) => state.isFetchingNextPage,
|
|
142
|
+
isMutating: (state: ThreadState) => state.isMutating,
|
|
143
|
+
};
|
|
144
|
+
|
|
121
145
|
start(): void {}
|
|
122
146
|
|
|
123
147
|
stop(): void {
|
|
@@ -317,6 +341,10 @@ vi.mock("@copilotkit/core", () => {
|
|
|
317
341
|
return this.state;
|
|
318
342
|
}
|
|
319
343
|
|
|
344
|
+
getServerState(): ThreadState {
|
|
345
|
+
return { ...this.state, threads: [] };
|
|
346
|
+
}
|
|
347
|
+
|
|
320
348
|
select<T>(selector: (state: ThreadState) => T) {
|
|
321
349
|
return {
|
|
322
350
|
subscribe: (callback: () => void) => {
|
|
@@ -357,6 +385,8 @@ vi.mock("@copilotkit/core", () => {
|
|
|
357
385
|
ɵselectHasNextPage: select((state) => state.hasNextPage),
|
|
358
386
|
ɵselectIsFetchingNextPage: select((state) => state.isFetchingNextPage),
|
|
359
387
|
ɵselectIsMutating: select((state) => state.isMutating),
|
|
388
|
+
// The real view model, driving the mock store above.
|
|
389
|
+
ɵThreadsController: actual.ɵThreadsController,
|
|
360
390
|
};
|
|
361
391
|
});
|
|
362
392
|
|
|
@@ -394,6 +424,7 @@ const supportedThreadEndpoints: ThreadEndpointRuntimeInfo = {
|
|
|
394
424
|
|
|
395
425
|
type MockCopilotKit = {
|
|
396
426
|
runtimeUrl: string | undefined;
|
|
427
|
+
readonly ɵruntimeInfo: unknown;
|
|
397
428
|
runtimeConnectionStatus: CopilotKitCoreRuntimeConnectionStatus;
|
|
398
429
|
headers: Record<string, string>;
|
|
399
430
|
/**
|
|
@@ -417,6 +448,9 @@ function setupCopilotKit(
|
|
|
417
448
|
) {
|
|
418
449
|
const copilotkit = ref<MockCopilotKit>({
|
|
419
450
|
runtimeUrl,
|
|
451
|
+
get ɵruntimeInfo() {
|
|
452
|
+
return runtimeInfoOf(this);
|
|
453
|
+
},
|
|
420
454
|
runtimeConnectionStatus,
|
|
421
455
|
headers: { Authorization: "Bearer test-token" },
|
|
422
456
|
ɵheadersGeneration: 0,
|
|
@@ -965,6 +999,9 @@ describe("useThreads", () => {
|
|
|
965
999
|
// exactly one list fetch (+ one subscribe after it lands).
|
|
966
1000
|
copilotkit.value = {
|
|
967
1001
|
...copilotkit.value,
|
|
1002
|
+
get ɵruntimeInfo() {
|
|
1003
|
+
return runtimeInfoOf(this);
|
|
1004
|
+
},
|
|
968
1005
|
runtimeConnectionStatus:
|
|
969
1006
|
CopilotKitCoreRuntimeConnectionStatus.Connected,
|
|
970
1007
|
intelligence: { wsUrl: "ws://localhost:4000/client" },
|
|
@@ -1020,6 +1057,9 @@ describe("useThreads", () => {
|
|
|
1020
1057
|
|
|
1021
1058
|
copilotkit.value = {
|
|
1022
1059
|
...copilotkit.value,
|
|
1060
|
+
get ɵruntimeInfo() {
|
|
1061
|
+
return runtimeInfoOf(this);
|
|
1062
|
+
},
|
|
1023
1063
|
runtimeConnectionStatus:
|
|
1024
1064
|
CopilotKitCoreRuntimeConnectionStatus.Disconnected,
|
|
1025
1065
|
};
|
|
@@ -1216,8 +1256,9 @@ describe("useThreads", () => {
|
|
|
1216
1256
|
|
|
1217
1257
|
expect(fetchMock).not.toHaveBeenCalled();
|
|
1218
1258
|
expect(getResult().threads.value).toEqual([]);
|
|
1219
|
-
|
|
1220
|
-
|
|
1259
|
+
// Nothing was ever sent, so nothing is cleared either (no extra
|
|
1260
|
+
// queued list fetch).
|
|
1261
|
+
expect(getDispatchedContexts()).toEqual([]);
|
|
1221
1262
|
// A disabled consumer must not be stuck in a permanent loading state:
|
|
1222
1263
|
// preConnectLoading must factor in `enabled`, otherwise isLoading would
|
|
1223
1264
|
// stay true forever since hasDispatchedContext never gets set.
|
|
@@ -1240,7 +1281,7 @@ describe("useThreads", () => {
|
|
|
1240
1281
|
// Disabled: inert, not loading, no fetch.
|
|
1241
1282
|
expect(getResult().isLoading.value).toBe(false);
|
|
1242
1283
|
expect(fetchMock).not.toHaveBeenCalled();
|
|
1243
|
-
expect(getDispatchedContexts().
|
|
1284
|
+
expect(getDispatchedContexts().filter(Boolean)).toEqual([]);
|
|
1244
1285
|
|
|
1245
1286
|
// Re-enable: the pre-connect loading indicator must re-arm (i.e.
|
|
1246
1287
|
// hasDispatchedContext was reset to false on disable) so consumers see
|
|
@@ -1343,8 +1384,9 @@ describe("useThreads", () => {
|
|
|
1343
1384
|
|
|
1344
1385
|
expect(fetchMock).not.toHaveBeenCalled();
|
|
1345
1386
|
expect(getResult().threads.value).toEqual([]);
|
|
1346
|
-
|
|
1347
|
-
|
|
1387
|
+
// Nothing was ever sent, so nothing is cleared either (no extra
|
|
1388
|
+
// queued list fetch).
|
|
1389
|
+
expect(getDispatchedContexts()).toEqual([]);
|
|
1348
1390
|
expect(getResult().error.value?.message).toBe(
|
|
1349
1391
|
"Thread endpoints are not available on this CopilotKit runtime",
|
|
1350
1392
|
);
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Covers:
|
|
6
6
|
* 1. useRenderTool with complex Zod schemas
|
|
7
|
-
* 2. defineToolCallRenderer with Zod (named + wildcard default
|
|
7
|
+
* 2. defineToolCallRenderer with Zod (named + wildcard default schema)
|
|
8
8
|
* 3. useComponent with Zod schemas
|
|
9
9
|
* 4. The registered schema object is the original Zod instance (identity check)
|
|
10
10
|
*/
|
|
@@ -134,7 +134,7 @@ describe("useRenderTool Zod regression", () => {
|
|
|
134
134
|
const schema = z.object({
|
|
135
135
|
action: z.discriminatedUnion("type", [
|
|
136
136
|
z.object({ type: z.literal("search"), query: z.string() }),
|
|
137
|
-
z.object({ type: z.literal("navigate"), url: z.
|
|
137
|
+
z.object({ type: z.literal("navigate"), url: z.url() }),
|
|
138
138
|
]),
|
|
139
139
|
});
|
|
140
140
|
|
|
@@ -196,14 +196,15 @@ describe("useRenderTool Zod regression", () => {
|
|
|
196
196
|
});
|
|
197
197
|
|
|
198
198
|
describe("defineToolCallRenderer Zod regression", () => {
|
|
199
|
-
it("wildcard tool defaults to
|
|
199
|
+
it("wildcard tool defaults to a schema that accepts any value", () => {
|
|
200
200
|
const renderer = defineToolCallRenderer({
|
|
201
201
|
name: "*",
|
|
202
202
|
render: () => "wildcard",
|
|
203
203
|
});
|
|
204
204
|
|
|
205
205
|
expect(renderer.name).toBe("*");
|
|
206
|
-
|
|
206
|
+
const result = renderer.args["~standard"].validate({ city: "Paris" });
|
|
207
|
+
expect(result).toEqual({ value: { city: "Paris" } });
|
|
207
208
|
});
|
|
208
209
|
|
|
209
210
|
it("named tool with Zod args preserves schema identity", () => {
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import { computed, toValue, watch } from "vue";
|
|
2
2
|
import type { MaybeRefOrGetter } from "vue";
|
|
3
|
+
import { ɵserializeContextValue } from "@copilotkit/core";
|
|
4
|
+
import type { ɵJsonSerializable } from "@copilotkit/core";
|
|
3
5
|
import { useCopilotKit } from "../providers/useCopilotKit";
|
|
4
6
|
|
|
5
|
-
export type JsonSerializable =
|
|
6
|
-
| string
|
|
7
|
-
| number
|
|
8
|
-
| boolean
|
|
9
|
-
| null
|
|
10
|
-
| JsonSerializable[]
|
|
11
|
-
| { [key: string]: JsonSerializable };
|
|
7
|
+
export type JsonSerializable = ɵJsonSerializable;
|
|
12
8
|
|
|
13
9
|
export interface AgentContextInput {
|
|
14
10
|
description: MaybeRefOrGetter<string>;
|
|
@@ -35,9 +31,7 @@ export function useAgentContext(context: AgentContextInput): void {
|
|
|
35
31
|
const resolvedValue = computed(() => toValue(context.value));
|
|
36
32
|
|
|
37
33
|
const stringValue = computed(() =>
|
|
38
|
-
|
|
39
|
-
? resolvedValue.value
|
|
40
|
-
: JSON.stringify(resolvedValue.value),
|
|
34
|
+
ɵserializeContextValue(resolvedValue.value),
|
|
41
35
|
);
|
|
42
36
|
|
|
43
37
|
watch(
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { computed, shallowRef, toValue, triggerRef, watch } from "vue";
|
|
2
2
|
import type { MaybeRefOrGetter } from "vue";
|
|
3
|
-
import { DEFAULT_AGENT_ID } from "@copilotkit/shared";
|
|
4
3
|
import type { AbstractAgent } from "@ag-ui/client";
|
|
5
4
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
CopilotRuntimeTransport,
|
|
12
|
-
SubscribeToAgentSubscriber,
|
|
5
|
+
ɵgetAgentResolver,
|
|
6
|
+
ɵresolveAgentId,
|
|
7
|
+
ɵresolveAgentThreadId,
|
|
8
|
+
ɵsubscribeToAgentUpdates,
|
|
9
|
+
ɵvalidateAgentBinding,
|
|
13
10
|
} from "@copilotkit/core";
|
|
14
11
|
import { useCopilotKit } from "../providers/useCopilotKit";
|
|
15
12
|
import { useCopilotChatConfiguration } from "../providers/useCopilotChatConfiguration";
|
|
@@ -126,7 +123,9 @@ export type UseAgentProps = UseAgentPropsBase &
|
|
|
126
123
|
*
|
|
127
124
|
* It returns a reactive `agent` ref that updates when the selected agent
|
|
128
125
|
* changes, when runtime connection state changes, or when subscribed update
|
|
129
|
-
* events fire
|
|
126
|
+
* events fire, and an `isReady` ref: `false` while `agent` is a provisional
|
|
127
|
+
* stand-in used before the runtime `/info` sync lands (or after it failed),
|
|
128
|
+
* `true` once it is the real agent.
|
|
130
129
|
*
|
|
131
130
|
* @example
|
|
132
131
|
* ```ts
|
|
@@ -134,348 +133,145 @@ export type UseAgentProps = UseAgentPropsBase &
|
|
|
134
133
|
* ```
|
|
135
134
|
*/
|
|
136
135
|
export function useAgent(props: UseAgentProps = {}) {
|
|
137
|
-
//
|
|
138
|
-
//
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
if (hasThreadId && !hasRuntimeAgentId) {
|
|
146
|
-
throw new Error(
|
|
147
|
-
"useAgent: `threadId` requires `runtimeAgentId`. A threadId is written onto a " +
|
|
148
|
-
"single agent, but an agent resolved by agentId alone is shared, so scoping a " +
|
|
149
|
-
"thread to it would clobber other useAgent callers. Pass a distinct local `agentId` " +
|
|
150
|
-
'and the runtime agent to route to, e.g. useAgent({ agentId: "chat-1", ' +
|
|
151
|
-
'runtimeAgentId: "assistant", threadId }).',
|
|
152
|
-
);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
if (hasRuntimeAgentId && !hasThreadId) {
|
|
156
|
-
throw new Error(
|
|
157
|
-
"useAgent: `runtimeAgentId` requires `threadId`. A proxied agent exists to scope a " +
|
|
158
|
-
"thread to a private instance; without a threadId it behaves like the shared agent " +
|
|
159
|
-
"while adding a registration and a local agentId to keep unique. Either pass the " +
|
|
160
|
-
"thread, or bind to the agent directly with useAgent({ agentId }).",
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
if (hasRuntimeAgentId && !hasAgentId) {
|
|
165
|
-
throw new Error(
|
|
166
|
-
"useAgent: `runtimeAgentId` requires an explicit `agentId`. The proxied agent is " +
|
|
167
|
-
"registered under `agentId`, and the usual fallbacks (chat configuration, then " +
|
|
168
|
-
`"${DEFAULT_AGENT_ID}") name agents that already exist — registering over one throws ` +
|
|
169
|
-
"or shadows it. Pick a local id for this hook, e.g. " +
|
|
170
|
-
'useAgent({ agentId: "chat-1", runtimeAgentId: "assistant", threadId }).',
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
// After the guards, all three are present or none are.
|
|
175
|
-
const isThreadScoped = hasRuntimeAgentId;
|
|
136
|
+
// Runtime backstop for the all-or-nothing rule UseAgentProps enforces at
|
|
137
|
+
// compile time (plain JS, `as any`). Same checks and messages as React.
|
|
138
|
+
ɵvalidateAgentBinding({
|
|
139
|
+
agentId: toValue(props.agentId),
|
|
140
|
+
threadId: toValue(props.threadId),
|
|
141
|
+
runtimeAgentId: toValue(props.runtimeAgentId),
|
|
142
|
+
});
|
|
143
|
+
const isThreadScoped = props.runtimeAgentId !== undefined;
|
|
176
144
|
|
|
177
145
|
const chatConfig = useCopilotChatConfiguration();
|
|
178
|
-
const agentId = computed(
|
|
179
|
-
(
|
|
180
|
-
toValue(props.agentId)
|
|
146
|
+
const agentId = computed(() =>
|
|
147
|
+
ɵresolveAgentId({
|
|
148
|
+
agentId: toValue(props.agentId),
|
|
149
|
+
chatAgentId: chatConfig.value?.agentId,
|
|
150
|
+
}),
|
|
181
151
|
);
|
|
182
152
|
const runtimeAgentId = computed(() =>
|
|
183
153
|
isThreadScoped ? toValue(props.runtimeAgentId) : undefined,
|
|
184
154
|
);
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
toValue(props.threadId) ??
|
|
192
|
-
(chatConfig.value?.hasExplicitThreadId
|
|
193
|
-
? chatConfig.value.threadId
|
|
194
|
-
: undefined),
|
|
155
|
+
const resolvedThreadId = computed(() =>
|
|
156
|
+
ɵresolveAgentThreadId({
|
|
157
|
+
threadId: toValue(props.threadId),
|
|
158
|
+
chatThreadId: chatConfig.value?.threadId,
|
|
159
|
+
chatHasExplicitThreadId: chatConfig.value?.hasExplicitThreadId,
|
|
160
|
+
}),
|
|
195
161
|
);
|
|
196
162
|
const { copilotkit } = useCopilotKit();
|
|
163
|
+
const resolver = computed(() => ɵgetAgentResolver(copilotkit.value));
|
|
197
164
|
const updateFlags = computed(() => props.updates ?? ALL_UPDATES);
|
|
198
165
|
// Read the provider-level default so it appears in the subscribe watcher
|
|
199
|
-
// deps
|
|
200
|
-
// Vue still needs the dep to know when to resubscribe (same role it plays
|
|
201
|
-
// in React's `useEffect` dep array).
|
|
166
|
+
// deps: core reads it, but Vue needs the dep to resubscribe.
|
|
202
167
|
const providerThrottleMs = computed(() => copilotkit.value.defaultThrottleMs);
|
|
203
168
|
const hookThrottleMs = computed(() => toValue(props.throttleMs));
|
|
204
169
|
|
|
205
170
|
const agent = shallowRef<AbstractAgent | null>(null);
|
|
206
|
-
const
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
});
|
|
220
|
-
// Never invokes the headers builder — installs `ɵruntimeFetch` and
|
|
221
|
-
// own-only headers on this proxied agent, so a request it actually sends
|
|
222
|
-
// resolves the current headers at send time (#1937).
|
|
223
|
-
copilotkit.value.applyHeadersToAgent(provisional);
|
|
224
|
-
return provisional;
|
|
225
|
-
};
|
|
171
|
+
const isReady = shallowRef(false);
|
|
172
|
+
const resolverRevision = shallowRef(0);
|
|
173
|
+
watch(
|
|
174
|
+
resolver,
|
|
175
|
+
(current, _old, onCleanup) => {
|
|
176
|
+
onCleanup(
|
|
177
|
+
current.subscribe(() => {
|
|
178
|
+
resolverRevision.value = current.getSnapshot();
|
|
179
|
+
}),
|
|
180
|
+
);
|
|
181
|
+
},
|
|
182
|
+
{ immediate: true },
|
|
183
|
+
);
|
|
226
184
|
|
|
227
|
-
//
|
|
228
|
-
// `agentId` that routes to `runtimeAgentId`.
|
|
229
|
-
//
|
|
230
|
-
// scope is disposed. Mirrors React's registration effect, including its dep
|
|
231
|
-
// set (core identity plus the two ids).
|
|
232
|
-
const registeredProxy = shallowRef<AbstractAgent | null>(null);
|
|
185
|
+
// Thread-scoped path: this hook owns a proxied agent registered under
|
|
186
|
+
// `agentId` that routes to `runtimeAgentId`. The cleanup unregisters both
|
|
187
|
+
// when the ids change and when the scope is disposed.
|
|
233
188
|
if (isThreadScoped) {
|
|
234
189
|
watch(
|
|
235
|
-
[agentId, runtimeAgentId,
|
|
236
|
-
([id, rtId], _old, onCleanup) => {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
agentId: id as string,
|
|
240
|
-
runtimeAgentId: rtId as string,
|
|
241
|
-
});
|
|
242
|
-
provisionalAgentCache.delete(id as string);
|
|
243
|
-
registeredProxy.value = proxy;
|
|
244
|
-
onCleanup(() => {
|
|
245
|
-
unregister();
|
|
246
|
-
registeredProxy.value = null;
|
|
247
|
-
});
|
|
190
|
+
[agentId, runtimeAgentId, resolver],
|
|
191
|
+
([id, rtId, current], _old, onCleanup) => {
|
|
192
|
+
if (rtId === undefined) return;
|
|
193
|
+
onCleanup(current.bindProxy({ agentId: id, runtimeAgentId: rtId }));
|
|
248
194
|
},
|
|
249
195
|
{ immediate: true },
|
|
250
196
|
);
|
|
251
197
|
}
|
|
252
198
|
|
|
253
199
|
const resolveAgent = () => {
|
|
254
|
-
const
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
if (
|
|
261
|
-
|
|
262
|
-
if (proxy) {
|
|
263
|
-
provisionalAgentCache.delete(id);
|
|
264
|
-
const shouldForceUpdate = agent.value === proxy;
|
|
265
|
-
agent.value = proxy;
|
|
266
|
-
subscriptionAgent.value = proxy;
|
|
267
|
-
if (shouldForceUpdate) triggerRef(agent);
|
|
268
|
-
return;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
const cachedProxy = provisionalAgentCache.get(id);
|
|
272
|
-
if (cachedProxy) {
|
|
273
|
-
core.applyHeadersToAgent(cachedProxy);
|
|
274
|
-
agent.value = cachedProxy;
|
|
275
|
-
subscriptionAgent.value = cachedProxy;
|
|
276
|
-
return;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
const provisionalProxy = new ProxiedCopilotRuntimeAgent({
|
|
280
|
-
runtimeUrl: core.runtimeUrl,
|
|
281
|
-
agentId: id,
|
|
282
|
-
runtimeAgentId: runtimeAgentId.value as string,
|
|
283
|
-
transport: core.runtimeTransport,
|
|
284
|
-
runtimeMode: "pending",
|
|
285
|
-
});
|
|
286
|
-
core.applyHeadersToAgent(provisionalProxy);
|
|
287
|
-
provisionalAgentCache.set(id, provisionalProxy);
|
|
288
|
-
agent.value = provisionalProxy;
|
|
289
|
-
subscriptionAgent.value = provisionalProxy;
|
|
290
|
-
return;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
const existing = core.getAgent(id);
|
|
294
|
-
if (existing) {
|
|
295
|
-
provisionalAgentCache.delete(id);
|
|
296
|
-
|
|
297
|
-
const shouldForceUpdate = agent.value === existing;
|
|
298
|
-
agent.value = existing;
|
|
299
|
-
subscriptionAgent.value = existing;
|
|
300
|
-
if (shouldForceUpdate) {
|
|
301
|
-
triggerRef(agent);
|
|
302
|
-
}
|
|
303
|
-
return;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
const isRuntimeConfigured = core.runtimeUrl !== undefined;
|
|
307
|
-
const status = core.runtimeConnectionStatus;
|
|
308
|
-
|
|
309
|
-
if (
|
|
310
|
-
isRuntimeConfigured &&
|
|
311
|
-
(status === CopilotKitCoreRuntimeConnectionStatus.Disconnected ||
|
|
312
|
-
status === CopilotKitCoreRuntimeConnectionStatus.Connecting ||
|
|
313
|
-
status === CopilotKitCoreRuntimeConnectionStatus.Error)
|
|
314
|
-
) {
|
|
315
|
-
const cached = provisionalAgentCache.get(id);
|
|
316
|
-
if (cached) {
|
|
317
|
-
core.applyHeadersToAgent(cached);
|
|
318
|
-
agent.value = cached;
|
|
319
|
-
subscriptionAgent.value = cached;
|
|
320
|
-
return;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
const provisional = createProvisionalAgent(
|
|
324
|
-
id,
|
|
325
|
-
core.runtimeUrl!,
|
|
326
|
-
core.runtimeTransport,
|
|
327
|
-
);
|
|
328
|
-
provisionalAgentCache.set(id, provisional);
|
|
329
|
-
agent.value = provisional;
|
|
330
|
-
subscriptionAgent.value = provisional;
|
|
200
|
+
const resolved = resolver.value.resolve({
|
|
201
|
+
agentId: agentId.value,
|
|
202
|
+
runtimeAgentId: runtimeAgentId.value,
|
|
203
|
+
caller: "useAgent",
|
|
204
|
+
});
|
|
205
|
+
isReady.value = resolved.isReady;
|
|
206
|
+
if (agent.value === resolved.agent) {
|
|
207
|
+
triggerRef(agent);
|
|
331
208
|
return;
|
|
332
209
|
}
|
|
333
|
-
|
|
334
|
-
const knownAgents = Object.keys(core.agents ?? {});
|
|
335
|
-
const runtimePart = isRuntimeConfigured
|
|
336
|
-
? `runtimeUrl=${core.runtimeUrl}`
|
|
337
|
-
: "no runtimeUrl";
|
|
338
|
-
throw new Error(
|
|
339
|
-
`useAgent: Agent '${id}' not found after runtime sync (${runtimePart}). ` +
|
|
340
|
-
(knownAgents.length
|
|
341
|
-
? `Known agents: [${knownAgents.join(", ")}]`
|
|
342
|
-
: "No agents registered.") +
|
|
343
|
-
" Verify your runtime /info and/or agents__unsafe_dev_only.",
|
|
344
|
-
);
|
|
210
|
+
agent.value = resolved.agent;
|
|
345
211
|
};
|
|
346
212
|
|
|
347
213
|
// Keyed on `ɵheadersGeneration`, not header VALUES: a builder's returned
|
|
348
214
|
// token can change on every resolution without a new source ever being
|
|
349
|
-
// set
|
|
350
|
-
// `resolveAgent` (and force-trigger `agent`) on that (#1937).
|
|
351
|
-
// A genuine source change (a real `setHeaders()` call) still re-runs it,
|
|
352
|
-
// refreshing a cached provisional's headers via the branches above.
|
|
215
|
+
// set, and this must not re-run `resolveAgent` on that (#1937).
|
|
353
216
|
//
|
|
354
|
-
//
|
|
355
|
-
//
|
|
356
|
-
//
|
|
357
|
-
// itself a shallowRef/reactive object, which makes the callback run on
|
|
358
|
-
// ANY dependency dirtying regardless of whether a source's value actually
|
|
359
|
-
// changed — silently defeating the `ɵheadersGeneration` rekey above (and
|
|
360
|
-
// every other source's diffing) the moment `registeredProxy` is present.
|
|
361
|
-
// A getter reads the same value without contributing to that flag.
|
|
217
|
+
// Sources are getters, not refs: Vue's multi-source `watch` force-triggers
|
|
218
|
+
// the whole array when any raw element is a shallowRef, which would defeat
|
|
219
|
+
// the diffing of every other source.
|
|
362
220
|
watch(
|
|
363
221
|
[
|
|
364
222
|
agentId,
|
|
365
|
-
() =>
|
|
223
|
+
() => resolverRevision.value,
|
|
366
224
|
() => copilotkit.value.agents,
|
|
367
225
|
() => copilotkit.value.runtimeConnectionStatus,
|
|
368
226
|
() => copilotkit.value.runtimeUrl,
|
|
369
227
|
() => copilotkit.value.runtimeTransport,
|
|
370
228
|
() => copilotkit.value.ɵheadersGeneration,
|
|
229
|
+
() => copilotkit.value.credentials,
|
|
371
230
|
],
|
|
372
231
|
resolveAgent,
|
|
373
232
|
{ immediate: true },
|
|
374
233
|
);
|
|
375
234
|
|
|
376
|
-
// Pin the resolved thread onto the current agent.
|
|
377
|
-
//
|
|
378
|
-
//
|
|
379
|
-
// the agent and the thread — matching React — so status/header churn cannot
|
|
380
|
-
// re-fire this and overwrite a thread `CopilotChat` pinned for its own chat.
|
|
381
|
-
// `() => agent.value`, not `agent`: Vue sets `forceTrigger` when any array
|
|
382
|
-
// watch source is a shallow ref, which would re-run this on every
|
|
383
|
-
// `triggerRef(agent)` — i.e. every streamed message — and re-pin a thread that
|
|
384
|
-
// `CopilotChat` may have deliberately overridden for the chat it renders. A
|
|
385
|
-
// getter fires only when the identity actually changes.
|
|
235
|
+
// Pin the resolved thread onto the current agent. Deps are just the agent
|
|
236
|
+
// identity and the thread, so status or header churn cannot re-pin a thread
|
|
237
|
+
// `CopilotChat` set for the chat it renders.
|
|
386
238
|
watch(
|
|
387
239
|
[() => agent.value, resolvedThreadId],
|
|
388
240
|
([currentAgent, threadId]) => {
|
|
389
241
|
if (!currentAgent || !threadId) return;
|
|
390
|
-
currentAgent.threadId = threadId
|
|
242
|
+
currentAgent.threadId = threadId;
|
|
391
243
|
},
|
|
392
244
|
{ immediate: true },
|
|
393
245
|
);
|
|
394
246
|
|
|
395
|
-
// Keyed on `ɵheadersGeneration`, not header VALUES: a builder's returned
|
|
396
|
-
// token can change on every resolution without a new source ever being set,
|
|
397
|
-
// and this watcher must not re-fire on that (see #1937).
|
|
398
247
|
watch(
|
|
399
|
-
[
|
|
248
|
+
[
|
|
249
|
+
() => agent.value,
|
|
250
|
+
() => copilotkit.value.ɵheadersGeneration,
|
|
251
|
+
() => copilotkit.value.credentials,
|
|
252
|
+
],
|
|
400
253
|
([currentAgent]) => {
|
|
401
|
-
if (
|
|
402
|
-
copilotkit.value.applyHeadersToAgent(currentAgent);
|
|
403
|
-
}
|
|
254
|
+
if (currentAgent) resolver.value.refreshRequestSettings(currentAgent);
|
|
404
255
|
},
|
|
405
256
|
{ immediate: true },
|
|
406
257
|
);
|
|
407
258
|
|
|
408
|
-
//
|
|
409
|
-
//
|
|
410
|
-
// - shared leading+trailing throttle window across `onMessagesChanged`
|
|
411
|
-
// and `onStateChanged` (parity with React)
|
|
412
|
-
// - safeCall-guarded callbacks (errors in subscribers never poison the
|
|
413
|
-
// agent notification loop)
|
|
414
|
-
// - validation/fallback for invalid `throttleMs`
|
|
415
|
-
// - `onRunErrorEvent` in the run-status callback set
|
|
416
|
-
//
|
|
417
|
-
// The hook only schedules a microtask-batched `triggerRef(agent)` so
|
|
418
|
-
// multiple synchronous notifications (e.g. state + run-status firing in
|
|
419
|
-
// the same tick) coalesce into a single Vue re-render — matching React's
|
|
420
|
-
// `queueMicrotask`-batched forceUpdate strategy.
|
|
259
|
+
// Core owns throttling, safe callbacks and `throttleMs` validation; the
|
|
260
|
+
// re-render is microtask-batched so notifications in one tick coalesce.
|
|
421
261
|
watch(
|
|
422
|
-
[
|
|
423
|
-
([
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
if (!batchScheduled) {
|
|
432
|
-
batchScheduled = true;
|
|
433
|
-
queueMicrotask(() => {
|
|
434
|
-
batchScheduled = false;
|
|
435
|
-
if (active) {
|
|
436
|
-
triggerRef(agent);
|
|
437
|
-
}
|
|
438
|
-
});
|
|
439
|
-
}
|
|
440
|
-
};
|
|
441
|
-
|
|
442
|
-
const handlers: SubscribeToAgentSubscriber = {};
|
|
443
|
-
|
|
444
|
-
if (f.includes(UseAgentUpdate.OnMessagesChanged)) {
|
|
445
|
-
// Messages fire immediately (no microtask indirection) so shared-
|
|
446
|
-
// window throttling in core sees an unadorned callback. Matches
|
|
447
|
-
// React's `handlers.onMessagesChanged = forceUpdate`.
|
|
448
|
-
handlers.onMessagesChanged = () => {
|
|
449
|
-
if (active) triggerRef(agent);
|
|
450
|
-
};
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
if (f.includes(UseAgentUpdate.OnStateChanged)) {
|
|
454
|
-
handlers.onStateChanged = batchedRefresh;
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
if (f.includes(UseAgentUpdate.OnRunStatusChanged)) {
|
|
458
|
-
handlers.onRunInitialized = batchedRefresh;
|
|
459
|
-
handlers.onRunFinalized = batchedRefresh;
|
|
460
|
-
handlers.onRunFailed = batchedRefresh;
|
|
461
|
-
// Protocol-level RUN_ERROR event (distinct from `onRunFailed`
|
|
462
|
-
// which handles local exceptions like network errors).
|
|
463
|
-
handlers.onRunErrorEvent = batchedRefresh;
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
const subscription = copilotkit.value.subscribeToAgentWithOptions(
|
|
467
|
-
a as AbstractAgent,
|
|
468
|
-
handlers,
|
|
469
|
-
{ throttleMs: toValue(props.throttleMs) },
|
|
262
|
+
[() => agent.value, updateFlags, hookThrottleMs, providerThrottleMs],
|
|
263
|
+
([currentAgent, flags], _old, onCleanup) => {
|
|
264
|
+
if (!currentAgent) return;
|
|
265
|
+
onCleanup(
|
|
266
|
+
ɵsubscribeToAgentUpdates(copilotkit.value, currentAgent, {
|
|
267
|
+
updates: flags,
|
|
268
|
+
throttleMs: toValue(props.throttleMs),
|
|
269
|
+
onUpdate: () => triggerRef(agent),
|
|
270
|
+
}),
|
|
470
271
|
);
|
|
471
|
-
|
|
472
|
-
onCleanup(() => {
|
|
473
|
-
active = false;
|
|
474
|
-
subscription.unsubscribe();
|
|
475
|
-
});
|
|
476
272
|
},
|
|
477
273
|
{ immediate: true },
|
|
478
274
|
);
|
|
479
275
|
|
|
480
|
-
return { agent };
|
|
276
|
+
return { agent, isReady };
|
|
481
277
|
}
|