@copilotkit/react-core 1.55.3-canary.1776215089 → 1.55.3-canary.1776243725
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-BzVUuD95.mjs → copilotkit-Bm4ox8G0.mjs} +52 -35
- package/dist/copilotkit-Bm4ox8G0.mjs.map +1 -0
- package/dist/{copilotkit-BZuXjQLc.cjs → copilotkit-BoOnQHlE.cjs} +51 -34
- package/dist/copilotkit-BoOnQHlE.cjs.map +1 -0
- package/dist/copilotkit-EfopO2gn.d.cts.map +1 -1
- package/dist/copilotkit-opur-20s.d.mts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.umd.js +18 -9
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/index.cjs +1 -1
- package/dist/v2/index.mjs +1 -1
- package/dist/v2/index.umd.js +50 -34
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +6 -6
- 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/v2/components/chat/CopilotChatAssistantMessage.tsx +18 -15
- 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__/CopilotChatCopyButton.clipboard.test.tsx +241 -0
- package/dist/copilotkit-BZuXjQLc.cjs.map +0 -1
- package/dist/copilotkit-BzVUuD95.mjs.map +0 -1
|
@@ -4,7 +4,7 @@ import { CopilotKitCore, CopilotKitCoreRuntimeConnectionStatus, ProxiedCopilotRu
|
|
|
4
4
|
import { HttpAgent } from "@ag-ui/client";
|
|
5
5
|
import { extendTailwindMerge, twMerge } from "tailwind-merge";
|
|
6
6
|
import { ArrowUp, Check, ChevronDown, ChevronLeft, ChevronRight, ChevronRightIcon, Copy, Edit, Loader2, MessageCircle, Mic, Play, Plus, RefreshCw, Square, ThumbsDown, ThumbsUp, Upload, Volume2, X } from "lucide-react";
|
|
7
|
-
import { A2UI_DEFAULT_DESIGN_GUIDELINES, A2UI_DEFAULT_GENERATION_GUIDELINES, COPILOT_CLOUD_API_URL, COPILOT_CLOUD_CHAT_URL, COPILOT_CLOUD_PUBLIC_API_KEY_HEADER, ConfigurationError, CopilotKitAgentDiscoveryError, CopilotKitApiDiscoveryError, CopilotKitError, CopilotKitErrorCode, CopilotKitLowLevelError, CopilotKitRemoteEndpointDiscoveryError, DEFAULT_AGENT_ID, ErrorVisibility, MissingPublicApiKeyError, Severity, TranscriptionErrorCode, TranscriptionErrorCode as TranscriptionErrorCode$1, createLicenseContextValue, dataToUUID, exceedsMaxSize, formatFileSize, generateVideoThumbnail, getDocumentIcon, getModalityFromMimeType, getSourceUrl, matchesAcceptFilter, parseJson, partialJSONParse, randomId, randomUUID, readFileAsBase64, schemaToJsonSchema } from "@copilotkit/shared";
|
|
7
|
+
import { A2UI_DEFAULT_DESIGN_GUIDELINES, A2UI_DEFAULT_GENERATION_GUIDELINES, COPILOT_CLOUD_API_URL, COPILOT_CLOUD_CHAT_URL, COPILOT_CLOUD_PUBLIC_API_KEY_HEADER, ConfigurationError, CopilotKitAgentDiscoveryError, CopilotKitApiDiscoveryError, CopilotKitError, CopilotKitErrorCode, CopilotKitLowLevelError, CopilotKitRemoteEndpointDiscoveryError, DEFAULT_AGENT_ID, ErrorVisibility, MissingPublicApiKeyError, Severity, TranscriptionErrorCode, TranscriptionErrorCode as TranscriptionErrorCode$1, copyToClipboard, createLicenseContextValue, dataToUUID, exceedsMaxSize, formatFileSize, generateVideoThumbnail, getDocumentIcon, getModalityFromMimeType, getSourceUrl, matchesAcceptFilter, parseJson, partialJSONParse, randomId, randomUUID, readFileAsBase64, schemaToJsonSchema } from "@copilotkit/shared";
|
|
8
8
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import { Slot } from "@radix-ui/react-slot";
|
|
10
10
|
import { cva } from "class-variance-authority";
|
|
@@ -4835,11 +4835,8 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, onThumbsUp,
|
|
|
4835
4835
|
useKatexStyles();
|
|
4836
4836
|
const boundMarkdownRenderer = renderSlot(markdownRenderer, CopilotChatAssistantMessage.MarkdownRenderer, { content: message.content || "" });
|
|
4837
4837
|
const boundCopyButton = renderSlot(copyButton, CopilotChatAssistantMessage.CopyButton, { onClick: async () => {
|
|
4838
|
-
if (message.content)
|
|
4839
|
-
|
|
4840
|
-
} catch (err) {
|
|
4841
|
-
console.error("Failed to copy message:", err);
|
|
4842
|
-
}
|
|
4838
|
+
if (message.content) return await copyToClipboard(message.content);
|
|
4839
|
+
return false;
|
|
4843
4840
|
} });
|
|
4844
4841
|
const boundThumbsUpButton = renderSlot(thumbsUpButton, CopilotChatAssistantMessage.ThumbsUpButton, { onClick: onThumbsUp });
|
|
4845
4842
|
const boundThumbsDownButton = renderSlot(thumbsDownButton, CopilotChatAssistantMessage.ThumbsDownButton, { onClick: onThumbsDown });
|
|
@@ -4937,14 +4934,17 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, onThumbsUp,
|
|
|
4937
4934
|
if (timerRef.current !== null) clearTimeout(timerRef.current);
|
|
4938
4935
|
};
|
|
4939
4936
|
}, []);
|
|
4940
|
-
const handleClick = (event) => {
|
|
4941
|
-
|
|
4942
|
-
if (
|
|
4943
|
-
|
|
4944
|
-
|
|
4945
|
-
|
|
4946
|
-
|
|
4947
|
-
|
|
4937
|
+
const handleClick = async (event) => {
|
|
4938
|
+
let success = false;
|
|
4939
|
+
if (onClick) success = await Promise.resolve(onClick(event)) === true;
|
|
4940
|
+
if (success) {
|
|
4941
|
+
setCopied(true);
|
|
4942
|
+
if (timerRef.current !== null) clearTimeout(timerRef.current);
|
|
4943
|
+
timerRef.current = setTimeout(() => {
|
|
4944
|
+
timerRef.current = null;
|
|
4945
|
+
setCopied(false);
|
|
4946
|
+
}, 2e3);
|
|
4947
|
+
}
|
|
4948
4948
|
};
|
|
4949
4949
|
return /* @__PURE__ */ jsx(ToolbarButton, {
|
|
4950
4950
|
"data-testid": "copilot-copy-button",
|
|
@@ -5097,11 +5097,8 @@ function CopilotChatUserMessage({ message, onEditMessage, branchIndex, numberOfB
|
|
|
5097
5097
|
const mediaParts = useMemo(() => getMediaParts(message.content), [message.content]);
|
|
5098
5098
|
const BoundMessageRenderer = renderSlot(messageRenderer, CopilotChatUserMessage.MessageRenderer, { content: flattenedContent });
|
|
5099
5099
|
const BoundCopyButton = renderSlot(copyButton, CopilotChatUserMessage.CopyButton, { onClick: async () => {
|
|
5100
|
-
if (flattenedContent)
|
|
5101
|
-
|
|
5102
|
-
} catch (err) {
|
|
5103
|
-
console.error("Failed to copy message:", err);
|
|
5104
|
-
}
|
|
5100
|
+
if (flattenedContent) return await copyToClipboard(flattenedContent);
|
|
5101
|
+
return false;
|
|
5105
5102
|
} });
|
|
5106
5103
|
const BoundEditButton = renderSlot(editButton, CopilotChatUserMessage.EditButton, { onClick: () => onEditMessage?.({ message }) });
|
|
5107
5104
|
const BoundBranchNavigation = renderSlot(branchNavigation, CopilotChatUserMessage.BranchNavigation, {
|
|
@@ -5189,10 +5186,13 @@ function CopilotChatUserMessage({ message, onEditMessage, branchIndex, numberOfB
|
|
|
5189
5186
|
_CopilotChatUserMessage.CopyButton = ({ className, title, onClick, ...props }) => {
|
|
5190
5187
|
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
5191
5188
|
const [copied, setCopied] = useState(false);
|
|
5192
|
-
const handleClick = (event) => {
|
|
5193
|
-
|
|
5194
|
-
|
|
5195
|
-
if (
|
|
5189
|
+
const handleClick = async (event) => {
|
|
5190
|
+
let success = false;
|
|
5191
|
+
if (onClick) success = await Promise.resolve(onClick(event)) === true;
|
|
5192
|
+
if (success) {
|
|
5193
|
+
setCopied(true);
|
|
5194
|
+
setTimeout(() => setCopied(false), 2e3);
|
|
5195
|
+
}
|
|
5196
5196
|
};
|
|
5197
5197
|
return /* @__PURE__ */ jsx(ToolbarButton, {
|
|
5198
5198
|
"data-testid": "copilot-user-copy-button",
|
|
@@ -5299,17 +5299,24 @@ function CopilotChatReasoningMessage({ message, messages, isRunning, header, con
|
|
|
5299
5299
|
return () => clearInterval(timer);
|
|
5300
5300
|
}, [isStreaming]);
|
|
5301
5301
|
const [isOpen, setIsOpen] = useState(isStreaming);
|
|
5302
|
+
const userToggledRef = useRef(false);
|
|
5302
5303
|
useEffect(() => {
|
|
5303
|
-
if (isStreaming)
|
|
5304
|
-
|
|
5304
|
+
if (isStreaming) {
|
|
5305
|
+
userToggledRef.current = false;
|
|
5306
|
+
setIsOpen(true);
|
|
5307
|
+
} else if (!userToggledRef.current) setIsOpen(false);
|
|
5305
5308
|
}, [isStreaming]);
|
|
5309
|
+
const handleToggle = hasContent ? () => {
|
|
5310
|
+
userToggledRef.current = true;
|
|
5311
|
+
setIsOpen((prev) => !prev);
|
|
5312
|
+
} : void 0;
|
|
5306
5313
|
const label = isStreaming ? "Thinking…" : `Thought for ${formatDuration(elapsed)}`;
|
|
5307
5314
|
const boundHeader = renderSlot(header, CopilotChatReasoningMessage.Header, {
|
|
5308
5315
|
isOpen,
|
|
5309
5316
|
label,
|
|
5310
5317
|
hasContent,
|
|
5311
5318
|
isStreaming,
|
|
5312
|
-
onClick:
|
|
5319
|
+
onClick: handleToggle
|
|
5313
5320
|
});
|
|
5314
5321
|
const boundContent = renderSlot(contentView, CopilotChatReasoningMessage.Content, {
|
|
5315
5322
|
isStreaming,
|
|
@@ -8013,6 +8020,20 @@ function shouldShowDevConsole(showDevConsole) {
|
|
|
8013
8020
|
/**
|
|
8014
8021
|
* An internal context to separate the messages state (which is constantly changing) from the rest of CopilotKit context
|
|
8015
8022
|
*/
|
|
8023
|
+
/**
|
|
8024
|
+
* Determine whether a GraphQL error should be suppressed based on its visibility
|
|
8025
|
+
* and whether the dev console is active.
|
|
8026
|
+
*
|
|
8027
|
+
* Returns `null` when the error should be surfaced to the UI, or a log prefix
|
|
8028
|
+
* string when the error should be suppressed (logged to console only).
|
|
8029
|
+
*
|
|
8030
|
+
* Exported for unit testing.
|
|
8031
|
+
*/
|
|
8032
|
+
function getErrorSuppression(visibility, isDev) {
|
|
8033
|
+
if (visibility === ErrorVisibility.SILENT) return "CopilotKit Silent Error:";
|
|
8034
|
+
if (!isDev && visibility === ErrorVisibility.DEV_ONLY) return "CopilotKit Error (hidden in production):";
|
|
8035
|
+
return null;
|
|
8036
|
+
}
|
|
8016
8037
|
const MessagesTapContext = createContext(null);
|
|
8017
8038
|
function useMessagesTap() {
|
|
8018
8039
|
const tap = useContext(MessagesTapContext);
|
|
@@ -8096,12 +8117,9 @@ function CopilotMessages({ children }) {
|
|
|
8096
8117
|
const graphQLErrors = error.graphQLErrors;
|
|
8097
8118
|
const routeError = (gqlError) => {
|
|
8098
8119
|
const visibility = gqlError.extensions?.visibility;
|
|
8099
|
-
|
|
8100
|
-
|
|
8101
|
-
|
|
8102
|
-
}
|
|
8103
|
-
if (visibility === ErrorVisibility.SILENT) {
|
|
8104
|
-
console.error("CopilotKit Silent Error:", gqlError.message);
|
|
8120
|
+
const suppression = getErrorSuppression(visibility, shouldShowDevConsole(showDevConsole));
|
|
8121
|
+
if (suppression) {
|
|
8122
|
+
console.error(suppression, gqlError.message);
|
|
8105
8123
|
return;
|
|
8106
8124
|
}
|
|
8107
8125
|
const ckError = createStructuredError(gqlError);
|
|
@@ -8118,8 +8136,7 @@ function CopilotMessages({ children }) {
|
|
|
8118
8136
|
}
|
|
8119
8137
|
};
|
|
8120
8138
|
graphQLErrors.forEach(routeError);
|
|
8121
|
-
} else
|
|
8122
|
-
else {
|
|
8139
|
+
} else {
|
|
8123
8140
|
const fallbackError = new CopilotKitError({
|
|
8124
8141
|
message: error?.message || String(error),
|
|
8125
8142
|
code: CopilotKitErrorCode.UNKNOWN
|
|
@@ -9533,4 +9550,4 @@ function validateProps(props) {
|
|
|
9533
9550
|
|
|
9534
9551
|
//#endregion
|
|
9535
9552
|
export { CopilotKitProvider as $, CopilotChatSuggestionView as A, useConfigureSuggestions as B, CopilotChatToggleButton as C, CopilotChatView_default as D, CopilotChat as E, CopilotChatAssistantMessage_default as F, useRenderTool as G, useCapabilities as H, CopilotChatToolCallsView as I, useRenderActivityMessage as J, useComponent as K, useAttachments as L, CopilotChatReasoningMessage_default as M, CopilotChatUserMessage_default as N, CopilotChatAttachmentQueue as O, CopilotChatAttachmentRenderer as P, useRenderToolCall as Q, useThreads$1 as R, CopilotModalHeader as S, DefaultOpenIcon as T, useHumanInTheLoop as U, useSuggestions as V, useDefaultRenderTool as W, UseAgentUpdate as X, useRenderCustomMessages as Y, useAgent as Z, WildcardToolCallRender as _, ThreadsProvider as a, SandboxFunctionsContext as at, CopilotPopupView as b, CoAgentStateRendersProvider as c, MCPAppsActivityRenderer as ct, shouldShowDevConsole as d, CopilotChatInput_default as dt, useCopilotKit as et, useToast as f, AudioRecorderError as ft, useCopilotContext as g, CopilotContext as h, useCopilotChatConfiguration as ht, ThreadsContext as i, createA2UIMessageRenderer as it, CopilotChatSuggestionPill as j, CopilotChatMessageView as k, useCoAgentStateRenders as l, MCPAppsActivityType as lt, useCopilotMessagesContext as m, CopilotChatConfigurationProvider as mt, defaultCopilotContextCategories as n, useAgentContext as nt, useThreads as o, useSandboxFunctions as ot, CopilotMessagesContext as p, CopilotChatAudioRecorder as pt, useFrontendTool as q, CoAgentStateRenderBridge as r, defineToolCallRenderer as rt, CoAgentStateRendersContext as s, MCPAppsActivityContentSchema as st, CopilotKit as t, CopilotKitCoreReact as tt, useAsyncCallback as u, CopilotKitInspector as ut, CopilotPopup as v, DefaultCloseIcon as w, CopilotSidebarView as x, CopilotSidebar as y, useInterrupt as z };
|
|
9536
|
-
//# sourceMappingURL=copilotkit-
|
|
9553
|
+
//# sourceMappingURL=copilotkit-Bm4ox8G0.mjs.map
|