@copilotkit/react-core 1.55.3 → 1.56.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/dist/{copilotkit-dwDWYpya.d.cts → copilotkit-BtP7w7cT.d.cts} +56 -10
- package/dist/copilotkit-BtP7w7cT.d.cts.map +1 -0
- package/dist/{copilotkit-BuhSUZHb.d.mts → copilotkit-CCbxm6JM.d.mts} +56 -10
- package/dist/copilotkit-CCbxm6JM.d.mts.map +1 -0
- package/dist/{copilotkit-Dgdpbqjt.cjs → copilotkit-CSJw5BG8.cjs} +129 -58
- package/dist/copilotkit-CSJw5BG8.cjs.map +1 -0
- package/dist/{copilotkit-Cd-NrDyp.mjs → copilotkit-Cj2ZIxVr.mjs} +125 -60
- package/dist/copilotkit-Cj2ZIxVr.mjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.umd.js +55 -23
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/index.cjs +2 -1
- package/dist/v2/index.d.cts +2 -2
- package/dist/v2/index.d.mts +2 -2
- package/dist/v2/index.mjs +2 -2
- package/dist/v2/index.umd.js +124 -59
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +6 -6
- package/src/components/CopilotListeners.tsx +15 -4
- package/src/components/__tests__/CopilotListeners.test.tsx +38 -0
- package/src/components/copilot-provider/__tests__/error-visibility-prod.test.tsx +70 -0
- package/src/components/copilot-provider/copilot-messages.tsx +39 -24
- package/src/components/copilot-provider/copilotkit-props.tsx +26 -6
- package/src/components/copilot-provider/copilotkit.tsx +4 -1
- package/src/v2/components/chat/CopilotChatAssistantMessage.tsx +22 -19
- package/src/v2/components/chat/CopilotChatInput.tsx +21 -2
- package/src/v2/components/chat/CopilotChatReasoningMessage.tsx +17 -4
- package/src/v2/components/chat/CopilotChatUserMessage.tsx +13 -10
- package/src/v2/components/chat/__tests__/CopilotChat.e2e.test.tsx +131 -5
- package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.test.tsx +1 -1
- package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.thumbs.test.tsx +72 -0
- package/src/v2/components/chat/__tests__/CopilotChatCopyButton.clipboard.test.tsx +241 -0
- package/src/v2/components/chat/__tests__/CopilotChatInput.test.tsx +38 -0
- package/src/v2/components/ui/button.tsx +12 -11
- package/src/v2/hooks/__tests__/use-agent-throttle.test.tsx +10 -10
- package/src/v2/hooks/__tests__/use-capabilities.test.tsx +76 -0
- package/src/v2/hooks/__tests__/use-render-custom-messages.test.tsx +55 -0
- package/src/v2/hooks/index.ts +1 -0
- package/src/v2/hooks/use-agent.tsx +23 -4
- package/src/v2/hooks/use-capabilities.tsx +25 -0
- package/src/v2/hooks/use-render-custom-messages.tsx +1 -1
- package/src/v2/hooks/use-render-tool-call.tsx +3 -0
- package/src/v2/hooks/use-render-tool.tsx +3 -0
- package/src/v2/providers/CopilotKitProvider.tsx +15 -2
- package/src/v2/types/defineToolCallRenderer.ts +3 -0
- package/src/v2/types/react-tool-call-renderer.ts +3 -0
- package/dist/copilotkit-BuhSUZHb.d.mts.map +0 -1
- package/dist/copilotkit-Cd-NrDyp.mjs.map +0 -1
- package/dist/copilotkit-Dgdpbqjt.cjs.map +0 -1
- package/dist/copilotkit-dwDWYpya.d.cts.map +0 -1
package/dist/v2/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
const require_copilotkit = require('../copilotkit-
|
|
4
|
+
const require_copilotkit = require('../copilotkit-CSJw5BG8.cjs');
|
|
5
5
|
require("./index.css");
|
|
6
6
|
let _copilotkit_a2ui_renderer = require("@copilotkit/a2ui-renderer");
|
|
7
7
|
|
|
@@ -69,6 +69,7 @@ exports.defineToolCallRenderer = require_copilotkit.defineToolCallRenderer;
|
|
|
69
69
|
exports.useAgent = require_copilotkit.useAgent;
|
|
70
70
|
exports.useAgentContext = require_copilotkit.useAgentContext;
|
|
71
71
|
exports.useAttachments = require_copilotkit.useAttachments;
|
|
72
|
+
exports.useCapabilities = require_copilotkit.useCapabilities;
|
|
72
73
|
exports.useComponent = require_copilotkit.useComponent;
|
|
73
74
|
exports.useConfigureSuggestions = require_copilotkit.useConfigureSuggestions;
|
|
74
75
|
exports.useCopilotChatConfiguration = require_copilotkit.useCopilotChatConfiguration;
|
package/dist/v2/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as MCPAppsActivityContent, $t as CopilotChatAudioRecorder, A as useAgentContext, At as CopilotChatMessageViewProps, B as SandboxFunction, Bt as CopilotChatAssistantMessageProps, C as useThreads, Ct as DefaultCloseIcon, D as useSuggestions, Dt as CopilotChatView, E as useConfigureSuggestions, Et as CopilotChatProps, F as useDefaultRenderTool, Ft as CopilotChatReasoningMessage, G as ReactHumanInTheLoop, Gt as ToolsMenuItem, H as InterruptHandlerProps, Ht as CopilotChatToolCallsViewProps, I as useRenderTool, It as CopilotChatReasoningMessageProps, J as ReactToolCallRenderer, Jt as CopilotChatConfigurationValue, K as ReactFrontendTool, Kt as CopilotChatConfigurationProvider, L as useComponent, Lt as CopilotChatUserMessage, M as UseAgentUpdate, Mt as CopilotChatSuggestionViewProps, N as useAgent, Nt as CopilotChatSuggestionPill, O as AgentContextInput, Ot as CopilotChatViewProps, P as useHumanInTheLoop, Pt as CopilotChatSuggestionPillProps, Q as useRenderToolCall, Qt as AudioRecorderState, R as useFrontendTool, Rt as CopilotChatUserMessageProps, S as UseThreadsResult, St as CopilotChatToggleButtonProps, T as useInterrupt, Tt as CopilotChat, U as InterruptRenderProps, Ut as CopilotChatInput, V as InterruptEvent, Vt as CopilotChatToolCallsView, W as defineToolCallRenderer, Wt as CopilotChatInputProps, X as ReactCustomMessageRenderer, Xt as useCopilotChatConfiguration, Y as useRenderCustomMessages, Yt as CopilotChatLabels, Z as ReactCustomMessageRendererPosition, Zt as AudioRecorderError, _ as UseAttachmentsProps, _t as CopilotSidebarView, a as A2UIUserAction, at as WildcardToolCallRender, b as Thread, bt as CopilotModalHeaderProps, c as SandboxFunctionsContext, ct as AttachmentsConfig, d as CopilotKitProvider, dt as CopilotPopup, et as MCPAppsActivityContentSchema, f as CopilotKitProviderProps, ft as CopilotPopupProps, g as CopilotKitCoreReactSubscriber, gt as CopilotPopupViewProps, h as CopilotKitCoreReactConfig, ht as CopilotPopupView, i as A2UIMessageRendererOptions, it as CopilotKitInspectorProps, j as useCapabilities, jt as CopilotChatSuggestionView, k as JsonSerializable, kt as CopilotChatMessageView, l as useSandboxFunctions, lt as CopilotChatAttachmentRenderer, m as CopilotKitCoreReact, mt as CopilotSidebarProps, nt as MCPAppsActivityType, o as createA2UIMessageRenderer, ot as Attachment, p as useCopilotKit, pt as CopilotSidebar, q as ReactActivityMessageRenderer, qt as CopilotChatConfigurationProviderProps, r as CopilotKitProps, rt as CopilotKitInspector, s as InspectorAnchor, st as AttachmentModality, t as CopilotKit, tt as MCPAppsActivityRenderer, u as CopilotKitContextValue, ut as CopilotChatAttachmentQueue, v as UseAttachmentsReturn, vt as CopilotSidebarViewProps, w as UseInterruptConfig, wt as DefaultOpenIcon, x as UseThreadsInput, xt as CopilotChatToggleButton, y as useAttachments, yt as CopilotModalHeader, z as useRenderActivityMessage, zt as CopilotChatAssistantMessage } from "../copilotkit-BtP7w7cT.cjs";
|
|
2
2
|
import "./index.css";
|
|
3
3
|
import { Theme as A2UITheme, defaultTheme as a2uiDefaultTheme } from "@copilotkit/a2ui-renderer";
|
|
4
4
|
export * from "@copilotkit/core";
|
|
5
5
|
export * from "@ag-ui/client";
|
|
6
|
-
export { type A2UIMessageRendererOptions, type A2UITheme, type A2UIUserAction, AgentContextInput, Attachment, AttachmentModality, AttachmentsConfig, AudioRecorderError, AudioRecorderState, CopilotChat, CopilotChatAssistantMessage, CopilotChatAssistantMessageProps, CopilotChatAttachmentQueue, CopilotChatAttachmentRenderer, CopilotChatAudioRecorder, CopilotChatConfigurationProvider, CopilotChatConfigurationProviderProps, CopilotChatConfigurationValue, CopilotChatInput, CopilotChatInputProps, CopilotChatLabels, CopilotChatMessageView, CopilotChatMessageViewProps, CopilotChatProps, CopilotChatReasoningMessage, CopilotChatReasoningMessageProps, CopilotChatSuggestionPill, CopilotChatSuggestionPillProps, CopilotChatSuggestionView, CopilotChatSuggestionViewProps, CopilotChatToggleButton, DefaultCloseIcon as CopilotChatToggleButtonCloseIcon, DefaultOpenIcon as CopilotChatToggleButtonOpenIcon, CopilotChatToggleButtonProps, CopilotChatToolCallsView, CopilotChatToolCallsViewProps, CopilotChatUserMessage, CopilotChatUserMessageProps, CopilotChatView, CopilotChatViewProps, CopilotKit, CopilotKitContextValue, CopilotKitCoreReact, CopilotKitCoreReactConfig, CopilotKitCoreReactSubscriber, CopilotKitInspector, CopilotKitInspectorProps, type CopilotKitProps, CopilotKitProvider, CopilotKitProviderProps, CopilotModalHeader, CopilotModalHeaderProps, CopilotPopup, CopilotPopupProps, CopilotPopupView, CopilotPopupViewProps, CopilotSidebar, CopilotSidebarProps, CopilotSidebarView, CopilotSidebarViewProps, InspectorAnchor, InterruptEvent, InterruptHandlerProps, InterruptRenderProps, JsonSerializable, MCPAppsActivityContent, MCPAppsActivityContentSchema, MCPAppsActivityRenderer, MCPAppsActivityType, ReactActivityMessageRenderer, ReactCustomMessageRenderer, ReactCustomMessageRendererPosition, ReactFrontendTool, ReactHumanInTheLoop, ReactToolCallRenderer, SandboxFunction, SandboxFunctionsContext, Thread, ToolsMenuItem, UseAgentUpdate, UseAttachmentsProps, UseAttachmentsReturn, UseInterruptConfig, UseThreadsInput, UseThreadsResult, WildcardToolCallRender, a2uiDefaultTheme, createA2UIMessageRenderer, defineToolCallRenderer, useAgent, useAgentContext, useAttachments, useComponent, useConfigureSuggestions, useCopilotChatConfiguration, useCopilotKit, useDefaultRenderTool, useFrontendTool, useHumanInTheLoop, useInterrupt, useRenderActivityMessage, useRenderCustomMessages, useRenderTool, useRenderToolCall, useSandboxFunctions, useSuggestions, useThreads };
|
|
6
|
+
export { type A2UIMessageRendererOptions, type A2UITheme, type A2UIUserAction, AgentContextInput, Attachment, AttachmentModality, AttachmentsConfig, AudioRecorderError, AudioRecorderState, CopilotChat, CopilotChatAssistantMessage, CopilotChatAssistantMessageProps, CopilotChatAttachmentQueue, CopilotChatAttachmentRenderer, CopilotChatAudioRecorder, CopilotChatConfigurationProvider, CopilotChatConfigurationProviderProps, CopilotChatConfigurationValue, CopilotChatInput, CopilotChatInputProps, CopilotChatLabels, CopilotChatMessageView, CopilotChatMessageViewProps, CopilotChatProps, CopilotChatReasoningMessage, CopilotChatReasoningMessageProps, CopilotChatSuggestionPill, CopilotChatSuggestionPillProps, CopilotChatSuggestionView, CopilotChatSuggestionViewProps, CopilotChatToggleButton, DefaultCloseIcon as CopilotChatToggleButtonCloseIcon, DefaultOpenIcon as CopilotChatToggleButtonOpenIcon, CopilotChatToggleButtonProps, CopilotChatToolCallsView, CopilotChatToolCallsViewProps, CopilotChatUserMessage, CopilotChatUserMessageProps, CopilotChatView, CopilotChatViewProps, CopilotKit, CopilotKitContextValue, CopilotKitCoreReact, CopilotKitCoreReactConfig, CopilotKitCoreReactSubscriber, CopilotKitInspector, CopilotKitInspectorProps, type CopilotKitProps, CopilotKitProvider, CopilotKitProviderProps, CopilotModalHeader, CopilotModalHeaderProps, CopilotPopup, CopilotPopupProps, CopilotPopupView, CopilotPopupViewProps, CopilotSidebar, CopilotSidebarProps, CopilotSidebarView, CopilotSidebarViewProps, InspectorAnchor, InterruptEvent, InterruptHandlerProps, InterruptRenderProps, JsonSerializable, MCPAppsActivityContent, MCPAppsActivityContentSchema, MCPAppsActivityRenderer, MCPAppsActivityType, ReactActivityMessageRenderer, ReactCustomMessageRenderer, ReactCustomMessageRendererPosition, ReactFrontendTool, ReactHumanInTheLoop, ReactToolCallRenderer, SandboxFunction, SandboxFunctionsContext, Thread, ToolsMenuItem, UseAgentUpdate, UseAttachmentsProps, UseAttachmentsReturn, UseInterruptConfig, UseThreadsInput, UseThreadsResult, WildcardToolCallRender, a2uiDefaultTheme, createA2UIMessageRenderer, defineToolCallRenderer, useAgent, useAgentContext, useAttachments, useCapabilities, useComponent, useConfigureSuggestions, useCopilotChatConfiguration, useCopilotKit, useDefaultRenderTool, useFrontendTool, useHumanInTheLoop, useInterrupt, useRenderActivityMessage, useRenderCustomMessages, useRenderTool, useRenderToolCall, useSandboxFunctions, useSuggestions, useThreads };
|
package/dist/v2/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as MCPAppsActivityContent, $t as CopilotChatAudioRecorder, A as useAgentContext, At as CopilotChatMessageViewProps, B as SandboxFunction, Bt as CopilotChatAssistantMessageProps, C as useThreads, Ct as DefaultCloseIcon, D as useSuggestions, Dt as CopilotChatView, E as useConfigureSuggestions, Et as CopilotChatProps, F as useDefaultRenderTool, Ft as CopilotChatReasoningMessage, G as ReactHumanInTheLoop, Gt as ToolsMenuItem, H as InterruptHandlerProps, Ht as CopilotChatToolCallsViewProps, I as useRenderTool, It as CopilotChatReasoningMessageProps, J as ReactToolCallRenderer, Jt as CopilotChatConfigurationValue, K as ReactFrontendTool, Kt as CopilotChatConfigurationProvider, L as useComponent, Lt as CopilotChatUserMessage, M as UseAgentUpdate, Mt as CopilotChatSuggestionViewProps, N as useAgent, Nt as CopilotChatSuggestionPill, O as AgentContextInput, Ot as CopilotChatViewProps, P as useHumanInTheLoop, Pt as CopilotChatSuggestionPillProps, Q as useRenderToolCall, Qt as AudioRecorderState, R as useFrontendTool, Rt as CopilotChatUserMessageProps, S as UseThreadsResult, St as CopilotChatToggleButtonProps, T as useInterrupt, Tt as CopilotChat, U as InterruptRenderProps, Ut as CopilotChatInput, V as InterruptEvent, Vt as CopilotChatToolCallsView, W as defineToolCallRenderer, Wt as CopilotChatInputProps, X as ReactCustomMessageRenderer, Xt as useCopilotChatConfiguration, Y as useRenderCustomMessages, Yt as CopilotChatLabels, Z as ReactCustomMessageRendererPosition, Zt as AudioRecorderError, _ as UseAttachmentsProps, _t as CopilotSidebarView, a as A2UIUserAction, at as WildcardToolCallRender, b as Thread, bt as CopilotModalHeaderProps, c as SandboxFunctionsContext, ct as AttachmentsConfig, d as CopilotKitProvider, dt as CopilotPopup, et as MCPAppsActivityContentSchema, f as CopilotKitProviderProps, ft as CopilotPopupProps, g as CopilotKitCoreReactSubscriber, gt as CopilotPopupViewProps, h as CopilotKitCoreReactConfig, ht as CopilotPopupView, i as A2UIMessageRendererOptions, it as CopilotKitInspectorProps, j as useCapabilities, jt as CopilotChatSuggestionView, k as JsonSerializable, kt as CopilotChatMessageView, l as useSandboxFunctions, lt as CopilotChatAttachmentRenderer, m as CopilotKitCoreReact, mt as CopilotSidebarProps, nt as MCPAppsActivityType, o as createA2UIMessageRenderer, ot as Attachment, p as useCopilotKit, pt as CopilotSidebar, q as ReactActivityMessageRenderer, qt as CopilotChatConfigurationProviderProps, r as CopilotKitProps, rt as CopilotKitInspector, s as InspectorAnchor, st as AttachmentModality, t as CopilotKit, tt as MCPAppsActivityRenderer, u as CopilotKitContextValue, ut as CopilotChatAttachmentQueue, v as UseAttachmentsReturn, vt as CopilotSidebarViewProps, w as UseInterruptConfig, wt as DefaultOpenIcon, x as UseThreadsInput, xt as CopilotChatToggleButton, y as useAttachments, yt as CopilotModalHeader, z as useRenderActivityMessage, zt as CopilotChatAssistantMessage } from "../copilotkit-CCbxm6JM.mjs";
|
|
2
2
|
import "./index.css";
|
|
3
3
|
import { Theme as A2UITheme, defaultTheme as a2uiDefaultTheme } from "@copilotkit/a2ui-renderer";
|
|
4
4
|
export * from "@copilotkit/core";
|
|
5
5
|
export * from "@ag-ui/client";
|
|
6
|
-
export { type A2UIMessageRendererOptions, type A2UITheme, type A2UIUserAction, AgentContextInput, Attachment, AttachmentModality, AttachmentsConfig, AudioRecorderError, AudioRecorderState, CopilotChat, CopilotChatAssistantMessage, CopilotChatAssistantMessageProps, CopilotChatAttachmentQueue, CopilotChatAttachmentRenderer, CopilotChatAudioRecorder, CopilotChatConfigurationProvider, CopilotChatConfigurationProviderProps, CopilotChatConfigurationValue, CopilotChatInput, CopilotChatInputProps, CopilotChatLabels, CopilotChatMessageView, CopilotChatMessageViewProps, CopilotChatProps, CopilotChatReasoningMessage, CopilotChatReasoningMessageProps, CopilotChatSuggestionPill, CopilotChatSuggestionPillProps, CopilotChatSuggestionView, CopilotChatSuggestionViewProps, CopilotChatToggleButton, DefaultCloseIcon as CopilotChatToggleButtonCloseIcon, DefaultOpenIcon as CopilotChatToggleButtonOpenIcon, CopilotChatToggleButtonProps, CopilotChatToolCallsView, CopilotChatToolCallsViewProps, CopilotChatUserMessage, CopilotChatUserMessageProps, CopilotChatView, CopilotChatViewProps, CopilotKit, CopilotKitContextValue, CopilotKitCoreReact, CopilotKitCoreReactConfig, CopilotKitCoreReactSubscriber, CopilotKitInspector, CopilotKitInspectorProps, type CopilotKitProps, CopilotKitProvider, CopilotKitProviderProps, CopilotModalHeader, CopilotModalHeaderProps, CopilotPopup, CopilotPopupProps, CopilotPopupView, CopilotPopupViewProps, CopilotSidebar, CopilotSidebarProps, CopilotSidebarView, CopilotSidebarViewProps, InspectorAnchor, InterruptEvent, InterruptHandlerProps, InterruptRenderProps, JsonSerializable, MCPAppsActivityContent, MCPAppsActivityContentSchema, MCPAppsActivityRenderer, MCPAppsActivityType, ReactActivityMessageRenderer, ReactCustomMessageRenderer, ReactCustomMessageRendererPosition, ReactFrontendTool, ReactHumanInTheLoop, ReactToolCallRenderer, SandboxFunction, SandboxFunctionsContext, Thread, ToolsMenuItem, UseAgentUpdate, UseAttachmentsProps, UseAttachmentsReturn, UseInterruptConfig, UseThreadsInput, UseThreadsResult, WildcardToolCallRender, a2uiDefaultTheme, createA2UIMessageRenderer, defineToolCallRenderer, useAgent, useAgentContext, useAttachments, useComponent, useConfigureSuggestions, useCopilotChatConfiguration, useCopilotKit, useDefaultRenderTool, useFrontendTool, useHumanInTheLoop, useInterrupt, useRenderActivityMessage, useRenderCustomMessages, useRenderTool, useRenderToolCall, useSandboxFunctions, useSuggestions, useThreads };
|
|
6
|
+
export { type A2UIMessageRendererOptions, type A2UITheme, type A2UIUserAction, AgentContextInput, Attachment, AttachmentModality, AttachmentsConfig, AudioRecorderError, AudioRecorderState, CopilotChat, CopilotChatAssistantMessage, CopilotChatAssistantMessageProps, CopilotChatAttachmentQueue, CopilotChatAttachmentRenderer, CopilotChatAudioRecorder, CopilotChatConfigurationProvider, CopilotChatConfigurationProviderProps, CopilotChatConfigurationValue, CopilotChatInput, CopilotChatInputProps, CopilotChatLabels, CopilotChatMessageView, CopilotChatMessageViewProps, CopilotChatProps, CopilotChatReasoningMessage, CopilotChatReasoningMessageProps, CopilotChatSuggestionPill, CopilotChatSuggestionPillProps, CopilotChatSuggestionView, CopilotChatSuggestionViewProps, CopilotChatToggleButton, DefaultCloseIcon as CopilotChatToggleButtonCloseIcon, DefaultOpenIcon as CopilotChatToggleButtonOpenIcon, CopilotChatToggleButtonProps, CopilotChatToolCallsView, CopilotChatToolCallsViewProps, CopilotChatUserMessage, CopilotChatUserMessageProps, CopilotChatView, CopilotChatViewProps, CopilotKit, CopilotKitContextValue, CopilotKitCoreReact, CopilotKitCoreReactConfig, CopilotKitCoreReactSubscriber, CopilotKitInspector, CopilotKitInspectorProps, type CopilotKitProps, CopilotKitProvider, CopilotKitProviderProps, CopilotModalHeader, CopilotModalHeaderProps, CopilotPopup, CopilotPopupProps, CopilotPopupView, CopilotPopupViewProps, CopilotSidebar, CopilotSidebarProps, CopilotSidebarView, CopilotSidebarViewProps, InspectorAnchor, InterruptEvent, InterruptHandlerProps, InterruptRenderProps, JsonSerializable, MCPAppsActivityContent, MCPAppsActivityContentSchema, MCPAppsActivityRenderer, MCPAppsActivityType, ReactActivityMessageRenderer, ReactCustomMessageRenderer, ReactCustomMessageRendererPosition, ReactFrontendTool, ReactHumanInTheLoop, ReactToolCallRenderer, SandboxFunction, SandboxFunctionsContext, Thread, ToolsMenuItem, UseAgentUpdate, UseAttachmentsProps, UseAttachmentsReturn, UseInterruptConfig, UseThreadsInput, UseThreadsResult, WildcardToolCallRender, a2uiDefaultTheme, createA2UIMessageRenderer, defineToolCallRenderer, useAgent, useAgentContext, useAttachments, useCapabilities, useComponent, useConfigureSuggestions, useCopilotChatConfiguration, useCopilotKit, useDefaultRenderTool, useFrontendTool, useHumanInTheLoop, useInterrupt, useRenderActivityMessage, useRenderCustomMessages, useRenderTool, useRenderToolCall, useSandboxFunctions, useSuggestions, useThreads };
|
package/dist/v2/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { $ as
|
|
3
|
+
import { $ as CopilotKitProvider, A as CopilotChatSuggestionView, B as useConfigureSuggestions, C as CopilotChatToggleButton, D as CopilotChatView_default, E as CopilotChat, F as CopilotChatAssistantMessage_default, G as useRenderTool, H as useCapabilities, I as CopilotChatToolCallsView, J as useRenderActivityMessage, K as useComponent, L as useAttachments, M as CopilotChatReasoningMessage_default, N as CopilotChatUserMessage_default, O as CopilotChatAttachmentQueue, P as CopilotChatAttachmentRenderer, Q as useRenderToolCall, R as useThreads, S as CopilotModalHeader, T as DefaultOpenIcon, U as useHumanInTheLoop, V as useSuggestions, W as useDefaultRenderTool, X as UseAgentUpdate, Y as useRenderCustomMessages, Z as useAgent, _ as WildcardToolCallRender, at as SandboxFunctionsContext, b as CopilotPopupView, ct as MCPAppsActivityRenderer, dt as CopilotChatInput_default, et as useCopilotKit, ft as AudioRecorderError, ht as useCopilotChatConfiguration, it as createA2UIMessageRenderer, j as CopilotChatSuggestionPill, k as CopilotChatMessageView, lt as MCPAppsActivityType, mt as CopilotChatConfigurationProvider, nt as useAgentContext, ot as useSandboxFunctions, pt as CopilotChatAudioRecorder, q as useFrontendTool, rt as defineToolCallRenderer, st as MCPAppsActivityContentSchema, t as CopilotKit, tt as CopilotKitCoreReact, ut as CopilotKitInspector, v as CopilotPopup, w as DefaultCloseIcon, x as CopilotSidebarView, y as CopilotSidebar, z as useInterrupt } from "../copilotkit-Cj2ZIxVr.mjs";
|
|
4
4
|
import "./index.css";
|
|
5
5
|
import { defaultTheme as a2uiDefaultTheme } from "@copilotkit/a2ui-renderer";
|
|
6
6
|
|
|
@@ -8,4 +8,4 @@ export * from "@copilotkit/core"
|
|
|
8
8
|
|
|
9
9
|
export * from "@ag-ui/client"
|
|
10
10
|
|
|
11
|
-
export { AudioRecorderError, CopilotChat, CopilotChatAssistantMessage_default as CopilotChatAssistantMessage, CopilotChatAttachmentQueue, CopilotChatAttachmentRenderer, CopilotChatAudioRecorder, CopilotChatConfigurationProvider, CopilotChatInput_default as CopilotChatInput, CopilotChatMessageView, CopilotChatReasoningMessage_default as CopilotChatReasoningMessage, CopilotChatSuggestionPill, CopilotChatSuggestionView, CopilotChatToggleButton, DefaultCloseIcon as CopilotChatToggleButtonCloseIcon, DefaultOpenIcon as CopilotChatToggleButtonOpenIcon, CopilotChatToolCallsView, CopilotChatUserMessage_default as CopilotChatUserMessage, CopilotChatView_default as CopilotChatView, CopilotKit, CopilotKitCoreReact, CopilotKitInspector, CopilotKitProvider, CopilotModalHeader, CopilotPopup, CopilotPopupView, CopilotSidebar, CopilotSidebarView, MCPAppsActivityContentSchema, MCPAppsActivityRenderer, MCPAppsActivityType, SandboxFunctionsContext, UseAgentUpdate, WildcardToolCallRender, a2uiDefaultTheme, createA2UIMessageRenderer, defineToolCallRenderer, useAgent, useAgentContext, useAttachments, useComponent, useConfigureSuggestions, useCopilotChatConfiguration, useCopilotKit, useDefaultRenderTool, useFrontendTool, useHumanInTheLoop, useInterrupt, useRenderActivityMessage, useRenderCustomMessages, useRenderTool, useRenderToolCall, useSandboxFunctions, useSuggestions, useThreads };
|
|
11
|
+
export { AudioRecorderError, CopilotChat, CopilotChatAssistantMessage_default as CopilotChatAssistantMessage, CopilotChatAttachmentQueue, CopilotChatAttachmentRenderer, CopilotChatAudioRecorder, CopilotChatConfigurationProvider, CopilotChatInput_default as CopilotChatInput, CopilotChatMessageView, CopilotChatReasoningMessage_default as CopilotChatReasoningMessage, CopilotChatSuggestionPill, CopilotChatSuggestionView, CopilotChatToggleButton, DefaultCloseIcon as CopilotChatToggleButtonCloseIcon, DefaultOpenIcon as CopilotChatToggleButtonOpenIcon, CopilotChatToolCallsView, CopilotChatUserMessage_default as CopilotChatUserMessage, CopilotChatView_default as CopilotChatView, CopilotKit, CopilotKitCoreReact, CopilotKitInspector, CopilotKitProvider, CopilotModalHeader, CopilotPopup, CopilotPopupView, CopilotSidebar, CopilotSidebarView, MCPAppsActivityContentSchema, MCPAppsActivityRenderer, MCPAppsActivityType, SandboxFunctionsContext, UseAgentUpdate, WildcardToolCallRender, a2uiDefaultTheme, createA2UIMessageRenderer, defineToolCallRenderer, useAgent, useAgentContext, useAttachments, useCapabilities, useComponent, useConfigureSuggestions, useCopilotChatConfiguration, useCopilotKit, useDefaultRenderTool, useFrontendTool, useHumanInTheLoop, useInterrupt, useRenderActivityMessage, useRenderCustomMessages, useRenderTool, useRenderToolCall, useSandboxFunctions, useSuggestions, useThreads };
|
package/dist/v2/index.umd.js
CHANGED
|
@@ -286,8 +286,9 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
|
|
|
286
286
|
size: "default"
|
|
287
287
|
}
|
|
288
288
|
});
|
|
289
|
-
function Button({ className, variant, size, asChild = false, ...props }) {
|
|
289
|
+
const Button = react.forwardRef(function Button({ className, variant, size, asChild = false, ...props }, ref) {
|
|
290
290
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(asChild ? _radix_ui_react_slot.Slot : "button", {
|
|
291
|
+
ref,
|
|
291
292
|
"data-slot": "button",
|
|
292
293
|
className: cn(buttonVariants({
|
|
293
294
|
variant,
|
|
@@ -296,7 +297,7 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
|
|
|
296
297
|
})),
|
|
297
298
|
...props
|
|
298
299
|
});
|
|
299
|
-
}
|
|
300
|
+
});
|
|
300
301
|
|
|
301
302
|
//#endregion
|
|
302
303
|
//#region src/v2/components/ui/tooltip.tsx
|
|
@@ -747,6 +748,7 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
|
|
|
747
748
|
});
|
|
748
749
|
}, [clearInputValue]);
|
|
749
750
|
const handleKeyDown = (e) => {
|
|
751
|
+
if (e.nativeEvent.isComposing || e.keyCode === 229) return;
|
|
750
752
|
if (commandQuery !== null && mode === "input") {
|
|
751
753
|
if (e.key === "ArrowDown") {
|
|
752
754
|
if (filteredCommands.length > 0) {
|
|
@@ -794,10 +796,8 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
|
|
|
794
796
|
const trimmed = resolvedValue.trim();
|
|
795
797
|
if (!trimmed) return;
|
|
796
798
|
onSubmitMessage(trimmed);
|
|
797
|
-
if (!isControlled)
|
|
798
|
-
|
|
799
|
-
onChange === null || onChange === void 0 || onChange("");
|
|
800
|
-
}
|
|
799
|
+
if (!isControlled) setInternalValue("");
|
|
800
|
+
onChange === null || onChange === void 0 || onChange("");
|
|
801
801
|
if (inputRef.current) inputRef.current.focus();
|
|
802
802
|
};
|
|
803
803
|
const BoundTextArea = renderSlot(textArea, CopilotChatInput.TextArea, {
|
|
@@ -805,6 +805,12 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
|
|
|
805
805
|
value: resolvedValue,
|
|
806
806
|
onChange: handleChange,
|
|
807
807
|
onKeyDown: handleKeyDown,
|
|
808
|
+
onCompositionStart: () => {
|
|
809
|
+
isComposingRef.current = true;
|
|
810
|
+
},
|
|
811
|
+
onCompositionEnd: () => {
|
|
812
|
+
isComposingRef.current = false;
|
|
813
|
+
},
|
|
808
814
|
autoFocus,
|
|
809
815
|
className: (0, tailwind_merge.twMerge)("cpk:w-full cpk:py-3", isExpanded ? "cpk:px-5" : "cpk:pr-5")
|
|
810
816
|
});
|
|
@@ -879,9 +885,10 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
|
|
|
879
885
|
const target = e.target;
|
|
880
886
|
if (target.tagName !== "BUTTON" && !target.closest("button") && inputRef.current && mode === "input") inputRef.current.focus();
|
|
881
887
|
};
|
|
888
|
+
const isComposingRef = (0, react.useRef)(false);
|
|
882
889
|
const ensureMeasurements = (0, react.useCallback)(() => {
|
|
883
890
|
const textarea = inputRef.current;
|
|
884
|
-
if (!textarea) return;
|
|
891
|
+
if (!textarea || isComposingRef.current) return;
|
|
885
892
|
const previousValue = textarea.value;
|
|
886
893
|
const previousHeight = textarea.style.height;
|
|
887
894
|
textarea.style.height = "auto";
|
|
@@ -3108,7 +3115,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
3108
3115
|
}, [value, warningMessage]);
|
|
3109
3116
|
return value;
|
|
3110
3117
|
}
|
|
3111
|
-
const CopilotKitProvider = ({ children, runtimeUrl, headers = {}, credentials, publicApiKey, publicLicenseKey, licenseToken, properties = {}, agents__unsafe_dev_only: agents = {}, selfManagedAgents = {}, renderToolCalls, renderActivityMessages, renderCustomMessages, frontendTools, humanInTheLoop, openGenerativeUI, showDevConsole = false, useSingleEndpoint, onError, a2ui, defaultThrottleMs, inspectorDefaultAnchor }) => {
|
|
3118
|
+
const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = {}, credentials, publicApiKey, publicLicenseKey, licenseToken, properties = {}, agents__unsafe_dev_only: agents = {}, selfManagedAgents = {}, renderToolCalls, renderActivityMessages, renderCustomMessages, frontendTools, humanInTheLoop, openGenerativeUI, showDevConsole = false, useSingleEndpoint, onError, a2ui, defaultThrottleMs, inspectorDefaultAnchor, debug }) => {
|
|
3112
3119
|
var _openGenerativeUI$des;
|
|
3113
3120
|
const [shouldRenderInspector, setShouldRenderInspector] = (0, react.useState)(false);
|
|
3114
3121
|
const [runtimeA2UIEnabled, setRuntimeA2UIEnabled] = (0, react.useState)(false);
|
|
@@ -3170,6 +3177,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
3170
3177
|
...selfManagedAgents
|
|
3171
3178
|
}), [agents, selfManagedAgents]);
|
|
3172
3179
|
const hasLocalAgents = mergedAgents && Object.keys(mergedAgents).length > 0;
|
|
3180
|
+
const headers = typeof headersProp === "function" ? headersProp() : headersProp;
|
|
3173
3181
|
const mergedHeaders = (0, react.useMemo)(() => {
|
|
3174
3182
|
if (!resolvedPublicKey) return headers;
|
|
3175
3183
|
if (headers[HEADER_NAME]) return headers;
|
|
@@ -3271,7 +3279,8 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
3271
3279
|
tools: allTools,
|
|
3272
3280
|
renderToolCalls: allRenderToolCalls,
|
|
3273
3281
|
renderActivityMessages: allActivityRenderers,
|
|
3274
|
-
renderCustomMessages: renderCustomMessagesList
|
|
3282
|
+
renderCustomMessages: renderCustomMessagesList,
|
|
3283
|
+
debug
|
|
3275
3284
|
});
|
|
3276
3285
|
if (defaultThrottleMs !== void 0) copilotkitRef.current.setDefaultThrottleMs(defaultThrottleMs);
|
|
3277
3286
|
}
|
|
@@ -3345,6 +3354,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
3345
3354
|
copilotkit.setCredentials(credentials);
|
|
3346
3355
|
copilotkit.setProperties(properties);
|
|
3347
3356
|
copilotkit.setAgents__unsafe_dev_only(mergedAgents);
|
|
3357
|
+
copilotkit.setDebug(debug);
|
|
3348
3358
|
}, [
|
|
3349
3359
|
copilotkit,
|
|
3350
3360
|
chatApiEndpoint,
|
|
@@ -3352,7 +3362,8 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
3352
3362
|
credentials,
|
|
3353
3363
|
properties,
|
|
3354
3364
|
mergedAgents,
|
|
3355
|
-
useSingleEndpoint
|
|
3365
|
+
useSingleEndpoint,
|
|
3366
|
+
debug
|
|
3356
3367
|
]);
|
|
3357
3368
|
const didMountRef = (0, react.useRef)(false);
|
|
3358
3369
|
(0, react.useEffect)(() => {
|
|
@@ -3473,18 +3484,21 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
3473
3484
|
const toolName = toolCall.function.name;
|
|
3474
3485
|
if (toolMessage) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RenderComponent, {
|
|
3475
3486
|
name: toolName,
|
|
3487
|
+
toolCallId: toolCall.id,
|
|
3476
3488
|
args,
|
|
3477
3489
|
status: _copilotkit_core.ToolCallStatus.Complete,
|
|
3478
3490
|
result: toolMessage.content
|
|
3479
3491
|
});
|
|
3480
3492
|
else if (isExecuting) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RenderComponent, {
|
|
3481
3493
|
name: toolName,
|
|
3494
|
+
toolCallId: toolCall.id,
|
|
3482
3495
|
args,
|
|
3483
3496
|
status: _copilotkit_core.ToolCallStatus.Executing,
|
|
3484
3497
|
result: void 0
|
|
3485
3498
|
});
|
|
3486
3499
|
else return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RenderComponent, {
|
|
3487
3500
|
name: toolName,
|
|
3501
|
+
toolCallId: toolCall.id,
|
|
3488
3502
|
args,
|
|
3489
3503
|
status: _copilotkit_core.ToolCallStatus.InProgress,
|
|
3490
3504
|
result: void 0
|
|
@@ -3670,6 +3684,17 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
3670
3684
|
const handlers = {};
|
|
3671
3685
|
let timerId = null;
|
|
3672
3686
|
let active = true;
|
|
3687
|
+
let batchScheduled = false;
|
|
3688
|
+
const batchedForceUpdate = () => {
|
|
3689
|
+
if (!active) return;
|
|
3690
|
+
if (!batchScheduled) {
|
|
3691
|
+
batchScheduled = true;
|
|
3692
|
+
queueMicrotask(() => {
|
|
3693
|
+
batchScheduled = false;
|
|
3694
|
+
if (active) forceUpdate();
|
|
3695
|
+
});
|
|
3696
|
+
}
|
|
3697
|
+
};
|
|
3673
3698
|
if (updateFlags.includes(UseAgentUpdate.OnMessagesChanged)) {
|
|
3674
3699
|
const ms = effectiveThrottleMs;
|
|
3675
3700
|
if (ms > 0) {
|
|
@@ -3694,11 +3719,11 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
3694
3719
|
handlers.onMessagesChanged = throttledNotify;
|
|
3695
3720
|
} else handlers.onMessagesChanged = forceUpdate;
|
|
3696
3721
|
}
|
|
3697
|
-
if (updateFlags.includes(UseAgentUpdate.OnStateChanged)) handlers.onStateChanged =
|
|
3722
|
+
if (updateFlags.includes(UseAgentUpdate.OnStateChanged)) handlers.onStateChanged = batchedForceUpdate;
|
|
3698
3723
|
if (updateFlags.includes(UseAgentUpdate.OnRunStatusChanged)) {
|
|
3699
|
-
handlers.onRunInitialized =
|
|
3700
|
-
handlers.onRunFinalized =
|
|
3701
|
-
handlers.onRunFailed =
|
|
3724
|
+
handlers.onRunInitialized = batchedForceUpdate;
|
|
3725
|
+
handlers.onRunFinalized = batchedForceUpdate;
|
|
3726
|
+
handlers.onRunFailed = batchedForceUpdate;
|
|
3702
3727
|
}
|
|
3703
3728
|
const subscription = agent.subscribe(handlers);
|
|
3704
3729
|
return () => {
|
|
@@ -3738,7 +3763,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
3738
3763
|
const runId = resolvedRunId !== null && resolvedRunId !== void 0 ? resolvedRunId : `missing-run-id:${message.id}`;
|
|
3739
3764
|
const registryAgent = copilotkit.getAgent(agentId);
|
|
3740
3765
|
const agent = (_getThreadClone = getThreadClone(registryAgent, threadId)) !== null && _getThreadClone !== void 0 ? _getThreadClone : registryAgent;
|
|
3741
|
-
if (!agent)
|
|
3766
|
+
if (!agent) return null;
|
|
3742
3767
|
const messagesIdsInRun = resolvedRunId ? agent.messages.filter((msg) => copilotkit.getRunIdForMessage(agentId, threadId, msg.id) === resolvedRunId).map((msg) => msg.id) : [message.id];
|
|
3743
3768
|
const rawMessageIndex = agent.messages.findIndex((msg) => msg.id === message.id);
|
|
3744
3769
|
const messageIndex = rawMessageIndex >= 0 ? rawMessageIndex : 0;
|
|
@@ -4240,6 +4265,24 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
4240
4265
|
]);
|
|
4241
4266
|
}
|
|
4242
4267
|
|
|
4268
|
+
//#endregion
|
|
4269
|
+
//#region src/v2/hooks/use-capabilities.tsx
|
|
4270
|
+
/**
|
|
4271
|
+
* Returns the capabilities declared by the given agent (or the default agent).
|
|
4272
|
+
* Capabilities are populated from the runtime `/info` response at connection
|
|
4273
|
+
* time. The hook reads them synchronously from the agent instance — there is
|
|
4274
|
+
* no separate loading state, but the value will be `undefined` until the
|
|
4275
|
+
* runtime handshake completes.
|
|
4276
|
+
*
|
|
4277
|
+
* @param agentId - Optional agent ID. If omitted, uses the default agent.
|
|
4278
|
+
* @returns The agent's capabilities, or `undefined` if the agent doesn't
|
|
4279
|
+
* declare capabilities.
|
|
4280
|
+
*/
|
|
4281
|
+
function useCapabilities(agentId) {
|
|
4282
|
+
const { agent } = useAgent({ agentId });
|
|
4283
|
+
if (agent && "capabilities" in agent) return agent.capabilities;
|
|
4284
|
+
}
|
|
4285
|
+
|
|
4243
4286
|
//#endregion
|
|
4244
4287
|
//#region src/v2/hooks/use-suggestions.tsx
|
|
4245
4288
|
function useSuggestions({ agentId } = {}) {
|
|
@@ -4917,16 +4960,13 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
4917
4960
|
useKatexStyles();
|
|
4918
4961
|
const boundMarkdownRenderer = renderSlot(markdownRenderer, CopilotChatAssistantMessage.MarkdownRenderer, { content: message.content || "" });
|
|
4919
4962
|
const boundCopyButton = renderSlot(copyButton, CopilotChatAssistantMessage.CopyButton, { onClick: async () => {
|
|
4920
|
-
if (message.content)
|
|
4921
|
-
|
|
4922
|
-
} catch (err) {
|
|
4923
|
-
console.error("Failed to copy message:", err);
|
|
4924
|
-
}
|
|
4963
|
+
if (message.content) return await (0, _copilotkit_shared.copyToClipboard)(message.content);
|
|
4964
|
+
return false;
|
|
4925
4965
|
} });
|
|
4926
|
-
const boundThumbsUpButton = renderSlot(thumbsUpButton, CopilotChatAssistantMessage.ThumbsUpButton, { onClick: onThumbsUp });
|
|
4927
|
-
const boundThumbsDownButton = renderSlot(thumbsDownButton, CopilotChatAssistantMessage.ThumbsDownButton, { onClick: onThumbsDown });
|
|
4928
|
-
const boundReadAloudButton = renderSlot(readAloudButton, CopilotChatAssistantMessage.ReadAloudButton, { onClick: onReadAloud });
|
|
4929
|
-
const boundRegenerateButton = renderSlot(regenerateButton, CopilotChatAssistantMessage.RegenerateButton, { onClick: onRegenerate });
|
|
4966
|
+
const boundThumbsUpButton = renderSlot(thumbsUpButton, CopilotChatAssistantMessage.ThumbsUpButton, { onClick: onThumbsUp ? () => onThumbsUp(message) : void 0 });
|
|
4967
|
+
const boundThumbsDownButton = renderSlot(thumbsDownButton, CopilotChatAssistantMessage.ThumbsDownButton, { onClick: onThumbsDown ? () => onThumbsDown(message) : void 0 });
|
|
4968
|
+
const boundReadAloudButton = renderSlot(readAloudButton, CopilotChatAssistantMessage.ReadAloudButton, { onClick: onReadAloud ? () => onReadAloud(message) : void 0 });
|
|
4969
|
+
const boundRegenerateButton = renderSlot(regenerateButton, CopilotChatAssistantMessage.RegenerateButton, { onClick: onRegenerate ? () => onRegenerate(message) : void 0 });
|
|
4930
4970
|
const boundToolbar = renderSlot(toolbar, CopilotChatAssistantMessage.Toolbar, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4931
4971
|
className: "cpk:flex cpk:items-center cpk:gap-1",
|
|
4932
4972
|
children: [
|
|
@@ -5021,14 +5061,17 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
5021
5061
|
if (timerRef.current !== null) clearTimeout(timerRef.current);
|
|
5022
5062
|
};
|
|
5023
5063
|
}, []);
|
|
5024
|
-
const handleClick = (event) => {
|
|
5025
|
-
|
|
5026
|
-
if (
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5064
|
+
const handleClick = async (event) => {
|
|
5065
|
+
let success = false;
|
|
5066
|
+
if (onClick) success = await Promise.resolve(onClick(event)) === true;
|
|
5067
|
+
if (success) {
|
|
5068
|
+
setCopied(true);
|
|
5069
|
+
if (timerRef.current !== null) clearTimeout(timerRef.current);
|
|
5070
|
+
timerRef.current = setTimeout(() => {
|
|
5071
|
+
timerRef.current = null;
|
|
5072
|
+
setCopied(false);
|
|
5073
|
+
}, 2e3);
|
|
5074
|
+
}
|
|
5032
5075
|
};
|
|
5033
5076
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
|
|
5034
5077
|
"data-testid": "copilot-copy-button",
|
|
@@ -5190,11 +5233,8 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
5190
5233
|
const mediaParts = (0, react.useMemo)(() => getMediaParts(message.content), [message.content]);
|
|
5191
5234
|
const BoundMessageRenderer = renderSlot(messageRenderer, CopilotChatUserMessage.MessageRenderer, { content: flattenedContent });
|
|
5192
5235
|
const BoundCopyButton = renderSlot(copyButton, CopilotChatUserMessage.CopyButton, { onClick: async () => {
|
|
5193
|
-
if (flattenedContent)
|
|
5194
|
-
|
|
5195
|
-
} catch (err) {
|
|
5196
|
-
console.error("Failed to copy message:", err);
|
|
5197
|
-
}
|
|
5236
|
+
if (flattenedContent) return await (0, _copilotkit_shared.copyToClipboard)(flattenedContent);
|
|
5237
|
+
return false;
|
|
5198
5238
|
} });
|
|
5199
5239
|
const BoundEditButton = renderSlot(editButton, CopilotChatUserMessage.EditButton, { onClick: () => onEditMessage === null || onEditMessage === void 0 ? void 0 : onEditMessage({ message }) });
|
|
5200
5240
|
const BoundBranchNavigation = renderSlot(branchNavigation, CopilotChatUserMessage.BranchNavigation, {
|
|
@@ -5284,10 +5324,13 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
5284
5324
|
const config = useCopilotChatConfiguration();
|
|
5285
5325
|
const labels = (_config$labels = config === null || config === void 0 ? void 0 : config.labels) !== null && _config$labels !== void 0 ? _config$labels : CopilotChatDefaultLabels;
|
|
5286
5326
|
const [copied, setCopied] = (0, react.useState)(false);
|
|
5287
|
-
const handleClick = (event) => {
|
|
5288
|
-
|
|
5289
|
-
|
|
5290
|
-
if (
|
|
5327
|
+
const handleClick = async (event) => {
|
|
5328
|
+
let success = false;
|
|
5329
|
+
if (onClick) success = await Promise.resolve(onClick(event)) === true;
|
|
5330
|
+
if (success) {
|
|
5331
|
+
setCopied(true);
|
|
5332
|
+
setTimeout(() => setCopied(false), 2e3);
|
|
5333
|
+
}
|
|
5291
5334
|
};
|
|
5292
5335
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
|
|
5293
5336
|
"data-testid": "copilot-user-copy-button",
|
|
@@ -5397,17 +5440,24 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
5397
5440
|
return () => clearInterval(timer);
|
|
5398
5441
|
}, [isStreaming]);
|
|
5399
5442
|
const [isOpen, setIsOpen] = (0, react.useState)(isStreaming);
|
|
5443
|
+
const userToggledRef = (0, react.useRef)(false);
|
|
5400
5444
|
(0, react.useEffect)(() => {
|
|
5401
|
-
if (isStreaming)
|
|
5402
|
-
|
|
5445
|
+
if (isStreaming) {
|
|
5446
|
+
userToggledRef.current = false;
|
|
5447
|
+
setIsOpen(true);
|
|
5448
|
+
} else if (!userToggledRef.current) setIsOpen(false);
|
|
5403
5449
|
}, [isStreaming]);
|
|
5450
|
+
const handleToggle = hasContent ? () => {
|
|
5451
|
+
userToggledRef.current = true;
|
|
5452
|
+
setIsOpen((prev) => !prev);
|
|
5453
|
+
} : void 0;
|
|
5404
5454
|
const label = isStreaming ? "Thinking…" : `Thought for ${formatDuration(elapsed)}`;
|
|
5405
5455
|
const boundHeader = renderSlot(header, CopilotChatReasoningMessage.Header, {
|
|
5406
5456
|
isOpen,
|
|
5407
5457
|
label,
|
|
5408
5458
|
hasContent,
|
|
5409
5459
|
isStreaming,
|
|
5410
|
-
onClick:
|
|
5460
|
+
onClick: handleToggle
|
|
5411
5461
|
});
|
|
5412
5462
|
const boundContent = renderSlot(contentView, CopilotChatReasoningMessage.Content, {
|
|
5413
5463
|
isStreaming,
|
|
@@ -8139,6 +8189,20 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
8139
8189
|
/**
|
|
8140
8190
|
* An internal context to separate the messages state (which is constantly changing) from the rest of CopilotKit context
|
|
8141
8191
|
*/
|
|
8192
|
+
/**
|
|
8193
|
+
* Determine whether a GraphQL error should be suppressed based on its visibility
|
|
8194
|
+
* and whether the dev console is active.
|
|
8195
|
+
*
|
|
8196
|
+
* Returns `null` when the error should be surfaced to the UI, or a log prefix
|
|
8197
|
+
* string when the error should be suppressed (logged to console only).
|
|
8198
|
+
*
|
|
8199
|
+
* Exported for unit testing.
|
|
8200
|
+
*/
|
|
8201
|
+
function getErrorSuppression(visibility, isDev) {
|
|
8202
|
+
if (visibility === _copilotkit_shared.ErrorVisibility.SILENT) return "CopilotKit Silent Error:";
|
|
8203
|
+
if (!isDev && visibility === _copilotkit_shared.ErrorVisibility.DEV_ONLY) return "CopilotKit Error (hidden in production):";
|
|
8204
|
+
return null;
|
|
8205
|
+
}
|
|
8142
8206
|
const MessagesTapContext = (0, react.createContext)(null);
|
|
8143
8207
|
function useMessagesTap() {
|
|
8144
8208
|
const tap = (0, react.useContext)(MessagesTapContext);
|
|
@@ -8223,13 +8287,9 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
8223
8287
|
const graphQLErrors = error.graphQLErrors;
|
|
8224
8288
|
const routeError = (gqlError) => {
|
|
8225
8289
|
const extensions = gqlError.extensions;
|
|
8226
|
-
const
|
|
8227
|
-
if (
|
|
8228
|
-
console.error(
|
|
8229
|
-
return;
|
|
8230
|
-
}
|
|
8231
|
-
if (visibility === _copilotkit_shared.ErrorVisibility.SILENT) {
|
|
8232
|
-
console.error("CopilotKit Silent Error:", gqlError.message);
|
|
8290
|
+
const suppression = getErrorSuppression(extensions === null || extensions === void 0 ? void 0 : extensions.visibility, shouldShowDevConsole(showDevConsole));
|
|
8291
|
+
if (suppression) {
|
|
8292
|
+
console.error(suppression, gqlError.message);
|
|
8233
8293
|
return;
|
|
8234
8294
|
}
|
|
8235
8295
|
const ckError = createStructuredError(gqlError);
|
|
@@ -8246,8 +8306,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
8246
8306
|
}
|
|
8247
8307
|
};
|
|
8248
8308
|
graphQLErrors.forEach(routeError);
|
|
8249
|
-
} else
|
|
8250
|
-
else {
|
|
8309
|
+
} else {
|
|
8251
8310
|
const fallbackError = new _copilotkit_shared.CopilotKitError({
|
|
8252
8311
|
message: (error === null || error === void 0 ? void 0 : error.message) || String(error),
|
|
8253
8312
|
code: _copilotkit_shared.CopilotKitErrorCode.UNKNOWN
|
|
@@ -9028,13 +9087,18 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
9028
9087
|
};
|
|
9029
9088
|
}, [agent, getSubscriber]);
|
|
9030
9089
|
};
|
|
9090
|
+
function CopilotListenersAgentSubscription() {
|
|
9091
|
+
const existingConfig = useCopilotChatConfiguration();
|
|
9092
|
+
const { agent } = useAgent({ agentId: existingConfig === null || existingConfig === void 0 ? void 0 : existingConfig.agentId });
|
|
9093
|
+
usePredictStateSubscription(agent);
|
|
9094
|
+
return null;
|
|
9095
|
+
}
|
|
9031
9096
|
function CopilotListeners() {
|
|
9097
|
+
var _copilotkit$agents;
|
|
9032
9098
|
const { copilotkit } = useCopilotKit();
|
|
9033
|
-
const existingConfig = useCopilotChatConfiguration();
|
|
9034
|
-
const resolvedAgentId = existingConfig === null || existingConfig === void 0 ? void 0 : existingConfig.agentId;
|
|
9035
9099
|
const { setBannerError } = useToast();
|
|
9036
|
-
const
|
|
9037
|
-
|
|
9100
|
+
const hasAgents = Object.keys((_copilotkit$agents = copilotkit.agents) !== null && _copilotkit$agents !== void 0 ? _copilotkit$agents : {}).length > 0;
|
|
9101
|
+
const hasRuntime = copilotkit.runtimeUrl !== void 0;
|
|
9038
9102
|
(0, react.useEffect)(() => {
|
|
9039
9103
|
const subscription = copilotkit.subscribe({ onError: ({ error, code, context }) => {
|
|
9040
9104
|
if (error.name === "AbortError" || error.message === "Fetch is aborted" || error.message === "signal is aborted without reason" || error.message === "component unmounted" || !error.message) return;
|
|
@@ -9056,7 +9120,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
9056
9120
|
subscription.unsubscribe();
|
|
9057
9121
|
};
|
|
9058
9122
|
}, [copilotkit === null || copilotkit === void 0 ? void 0 : copilotkit.subscribe]);
|
|
9059
|
-
return null;
|
|
9123
|
+
return hasAgents || hasRuntime ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotListenersAgentSubscription, {}) : null;
|
|
9060
9124
|
}
|
|
9061
9125
|
|
|
9062
9126
|
//#endregion
|
|
@@ -9227,7 +9291,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
9227
9291
|
publicApiKey,
|
|
9228
9292
|
...cloud ? { cloud } : {},
|
|
9229
9293
|
chatApiEndpoint,
|
|
9230
|
-
headers: props.headers || {},
|
|
9294
|
+
headers: typeof props.headers === "function" ? props.headers() : props.headers || {},
|
|
9231
9295
|
properties: props.properties || {},
|
|
9232
9296
|
transcribeAudioUrl: props.transcribeAudioUrl,
|
|
9233
9297
|
textToSpeechUrl: props.textToSpeechUrl,
|
|
@@ -9644,6 +9708,7 @@ exports.defineToolCallRenderer = defineToolCallRenderer;
|
|
|
9644
9708
|
exports.useAgent = useAgent;
|
|
9645
9709
|
exports.useAgentContext = useAgentContext;
|
|
9646
9710
|
exports.useAttachments = useAttachments;
|
|
9711
|
+
exports.useCapabilities = useCapabilities;
|
|
9647
9712
|
exports.useComponent = useComponent;
|
|
9648
9713
|
exports.useConfigureSuggestions = useConfigureSuggestions;
|
|
9649
9714
|
exports.useCopilotChatConfiguration = useCopilotChatConfiguration;
|