@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
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-BoOnQHlE.cjs');
|
|
5
5
|
require("./index.css");
|
|
6
6
|
let _copilotkit_a2ui_renderer = require("@copilotkit/a2ui-renderer");
|
|
7
7
|
|
package/dist/v2/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
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-
|
|
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-Bm4ox8G0.mjs";
|
|
4
4
|
import "./index.css";
|
|
5
5
|
import { defaultTheme as a2uiDefaultTheme } from "@copilotkit/a2ui-renderer";
|
|
6
6
|
|
package/dist/v2/index.umd.js
CHANGED
|
@@ -4947,11 +4947,8 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
4947
4947
|
useKatexStyles();
|
|
4948
4948
|
const boundMarkdownRenderer = renderSlot(markdownRenderer, CopilotChatAssistantMessage.MarkdownRenderer, { content: message.content || "" });
|
|
4949
4949
|
const boundCopyButton = renderSlot(copyButton, CopilotChatAssistantMessage.CopyButton, { onClick: async () => {
|
|
4950
|
-
if (message.content)
|
|
4951
|
-
|
|
4952
|
-
} catch (err) {
|
|
4953
|
-
console.error("Failed to copy message:", err);
|
|
4954
|
-
}
|
|
4950
|
+
if (message.content) return await (0, _copilotkit_shared.copyToClipboard)(message.content);
|
|
4951
|
+
return false;
|
|
4955
4952
|
} });
|
|
4956
4953
|
const boundThumbsUpButton = renderSlot(thumbsUpButton, CopilotChatAssistantMessage.ThumbsUpButton, { onClick: onThumbsUp });
|
|
4957
4954
|
const boundThumbsDownButton = renderSlot(thumbsDownButton, CopilotChatAssistantMessage.ThumbsDownButton, { onClick: onThumbsDown });
|
|
@@ -5051,14 +5048,17 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
5051
5048
|
if (timerRef.current !== null) clearTimeout(timerRef.current);
|
|
5052
5049
|
};
|
|
5053
5050
|
}, []);
|
|
5054
|
-
const handleClick = (event) => {
|
|
5055
|
-
|
|
5056
|
-
if (
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
|
|
5051
|
+
const handleClick = async (event) => {
|
|
5052
|
+
let success = false;
|
|
5053
|
+
if (onClick) success = await Promise.resolve(onClick(event)) === true;
|
|
5054
|
+
if (success) {
|
|
5055
|
+
setCopied(true);
|
|
5056
|
+
if (timerRef.current !== null) clearTimeout(timerRef.current);
|
|
5057
|
+
timerRef.current = setTimeout(() => {
|
|
5058
|
+
timerRef.current = null;
|
|
5059
|
+
setCopied(false);
|
|
5060
|
+
}, 2e3);
|
|
5061
|
+
}
|
|
5062
5062
|
};
|
|
5063
5063
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
|
|
5064
5064
|
"data-testid": "copilot-copy-button",
|
|
@@ -5220,11 +5220,8 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
5220
5220
|
const mediaParts = (0, react.useMemo)(() => getMediaParts(message.content), [message.content]);
|
|
5221
5221
|
const BoundMessageRenderer = renderSlot(messageRenderer, CopilotChatUserMessage.MessageRenderer, { content: flattenedContent });
|
|
5222
5222
|
const BoundCopyButton = renderSlot(copyButton, CopilotChatUserMessage.CopyButton, { onClick: async () => {
|
|
5223
|
-
if (flattenedContent)
|
|
5224
|
-
|
|
5225
|
-
} catch (err) {
|
|
5226
|
-
console.error("Failed to copy message:", err);
|
|
5227
|
-
}
|
|
5223
|
+
if (flattenedContent) return await (0, _copilotkit_shared.copyToClipboard)(flattenedContent);
|
|
5224
|
+
return false;
|
|
5228
5225
|
} });
|
|
5229
5226
|
const BoundEditButton = renderSlot(editButton, CopilotChatUserMessage.EditButton, { onClick: () => onEditMessage === null || onEditMessage === void 0 ? void 0 : onEditMessage({ message }) });
|
|
5230
5227
|
const BoundBranchNavigation = renderSlot(branchNavigation, CopilotChatUserMessage.BranchNavigation, {
|
|
@@ -5314,10 +5311,13 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
5314
5311
|
const config = useCopilotChatConfiguration();
|
|
5315
5312
|
const labels = (_config$labels = config === null || config === void 0 ? void 0 : config.labels) !== null && _config$labels !== void 0 ? _config$labels : CopilotChatDefaultLabels;
|
|
5316
5313
|
const [copied, setCopied] = (0, react.useState)(false);
|
|
5317
|
-
const handleClick = (event) => {
|
|
5318
|
-
|
|
5319
|
-
|
|
5320
|
-
if (
|
|
5314
|
+
const handleClick = async (event) => {
|
|
5315
|
+
let success = false;
|
|
5316
|
+
if (onClick) success = await Promise.resolve(onClick(event)) === true;
|
|
5317
|
+
if (success) {
|
|
5318
|
+
setCopied(true);
|
|
5319
|
+
setTimeout(() => setCopied(false), 2e3);
|
|
5320
|
+
}
|
|
5321
5321
|
};
|
|
5322
5322
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
|
|
5323
5323
|
"data-testid": "copilot-user-copy-button",
|
|
@@ -5427,17 +5427,24 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
5427
5427
|
return () => clearInterval(timer);
|
|
5428
5428
|
}, [isStreaming]);
|
|
5429
5429
|
const [isOpen, setIsOpen] = (0, react.useState)(isStreaming);
|
|
5430
|
+
const userToggledRef = (0, react.useRef)(false);
|
|
5430
5431
|
(0, react.useEffect)(() => {
|
|
5431
|
-
if (isStreaming)
|
|
5432
|
-
|
|
5432
|
+
if (isStreaming) {
|
|
5433
|
+
userToggledRef.current = false;
|
|
5434
|
+
setIsOpen(true);
|
|
5435
|
+
} else if (!userToggledRef.current) setIsOpen(false);
|
|
5433
5436
|
}, [isStreaming]);
|
|
5437
|
+
const handleToggle = hasContent ? () => {
|
|
5438
|
+
userToggledRef.current = true;
|
|
5439
|
+
setIsOpen((prev) => !prev);
|
|
5440
|
+
} : void 0;
|
|
5434
5441
|
const label = isStreaming ? "Thinking…" : `Thought for ${formatDuration(elapsed)}`;
|
|
5435
5442
|
const boundHeader = renderSlot(header, CopilotChatReasoningMessage.Header, {
|
|
5436
5443
|
isOpen,
|
|
5437
5444
|
label,
|
|
5438
5445
|
hasContent,
|
|
5439
5446
|
isStreaming,
|
|
5440
|
-
onClick:
|
|
5447
|
+
onClick: handleToggle
|
|
5441
5448
|
});
|
|
5442
5449
|
const boundContent = renderSlot(contentView, CopilotChatReasoningMessage.Content, {
|
|
5443
5450
|
isStreaming,
|
|
@@ -8169,6 +8176,20 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
8169
8176
|
/**
|
|
8170
8177
|
* An internal context to separate the messages state (which is constantly changing) from the rest of CopilotKit context
|
|
8171
8178
|
*/
|
|
8179
|
+
/**
|
|
8180
|
+
* Determine whether a GraphQL error should be suppressed based on its visibility
|
|
8181
|
+
* and whether the dev console is active.
|
|
8182
|
+
*
|
|
8183
|
+
* Returns `null` when the error should be surfaced to the UI, or a log prefix
|
|
8184
|
+
* string when the error should be suppressed (logged to console only).
|
|
8185
|
+
*
|
|
8186
|
+
* Exported for unit testing.
|
|
8187
|
+
*/
|
|
8188
|
+
function getErrorSuppression(visibility, isDev) {
|
|
8189
|
+
if (visibility === _copilotkit_shared.ErrorVisibility.SILENT) return "CopilotKit Silent Error:";
|
|
8190
|
+
if (!isDev && visibility === _copilotkit_shared.ErrorVisibility.DEV_ONLY) return "CopilotKit Error (hidden in production):";
|
|
8191
|
+
return null;
|
|
8192
|
+
}
|
|
8172
8193
|
const MessagesTapContext = (0, react.createContext)(null);
|
|
8173
8194
|
function useMessagesTap() {
|
|
8174
8195
|
const tap = (0, react.useContext)(MessagesTapContext);
|
|
@@ -8253,13 +8274,9 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
8253
8274
|
const graphQLErrors = error.graphQLErrors;
|
|
8254
8275
|
const routeError = (gqlError) => {
|
|
8255
8276
|
const extensions = gqlError.extensions;
|
|
8256
|
-
const
|
|
8257
|
-
if (
|
|
8258
|
-
console.error(
|
|
8259
|
-
return;
|
|
8260
|
-
}
|
|
8261
|
-
if (visibility === _copilotkit_shared.ErrorVisibility.SILENT) {
|
|
8262
|
-
console.error("CopilotKit Silent Error:", gqlError.message);
|
|
8277
|
+
const suppression = getErrorSuppression(extensions === null || extensions === void 0 ? void 0 : extensions.visibility, shouldShowDevConsole(showDevConsole));
|
|
8278
|
+
if (suppression) {
|
|
8279
|
+
console.error(suppression, gqlError.message);
|
|
8263
8280
|
return;
|
|
8264
8281
|
}
|
|
8265
8282
|
const ckError = createStructuredError(gqlError);
|
|
@@ -8276,8 +8293,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
8276
8293
|
}
|
|
8277
8294
|
};
|
|
8278
8295
|
graphQLErrors.forEach(routeError);
|
|
8279
|
-
} else
|
|
8280
|
-
else {
|
|
8296
|
+
} else {
|
|
8281
8297
|
const fallbackError = new _copilotkit_shared.CopilotKitError({
|
|
8282
8298
|
message: (error === null || error === void 0 ? void 0 : error.message) || String(error),
|
|
8283
8299
|
code: _copilotkit_shared.CopilotKitErrorCode.UNKNOWN
|