@copilotkit/react-core 1.55.2-next.0 → 1.55.2
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/CHANGELOG.md +23 -0
- package/dist/copilotkit-BuhSUZHb.d.mts.map +1 -1
- package/dist/{copilotkit-OhEIYGcY.mjs → copilotkit-Cd-NrDyp.mjs} +42 -15
- package/dist/copilotkit-Cd-NrDyp.mjs.map +1 -0
- package/dist/{copilotkit-7z4C8joY.cjs → copilotkit-Dgdpbqjt.cjs} +42 -15
- package/dist/copilotkit-Dgdpbqjt.cjs.map +1 -0
- package/dist/copilotkit-dwDWYpya.d.cts.map +1 -1
- package/dist/index.cjs +6 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +6 -3
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +23 -27
- 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 +47 -26
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +6 -6
- package/src/components/copilot-provider/copilotkit.tsx +2 -2
- package/src/hooks/use-agent-nodename.ts +3 -0
- package/src/hooks/use-coagent-state-render-bridge.helpers.ts +2 -1
- package/src/hooks/use-coagent-state-render-registry.ts +6 -6
- package/src/hooks/use-copilot-chat_internal.ts +1 -1
- package/src/lib/copilot-task.ts +1 -1
- package/src/utils/utils.ts +0 -2
- package/src/v2/a2ui/A2UIMessageRenderer.tsx +1 -1
- package/src/v2/components/chat/CopilotChatMessageView.tsx +41 -5
- package/src/v2/components/chat/__tests__/CopilotChatMessageView.test.tsx +192 -82
- package/src/v2/providers/CopilotChatConfigurationProvider.tsx +2 -2
- package/dist/copilotkit-7z4C8joY.cjs.map +0 -1
- package/dist/copilotkit-OhEIYGcY.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-Dgdpbqjt.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 useCopilotKit, A as CopilotChatSuggestionView, B as useConfigureSuggestions, C as CopilotChatToggleButton, D as CopilotChatView_default, E as CopilotChat, F as CopilotChatAssistantMessage_default, G as useComponent, H as useHumanInTheLoop, I as CopilotChatToolCallsView, J as useRenderCustomMessages, K as useFrontendTool, L as useAttachments, M as CopilotChatReasoningMessage_default, N as CopilotChatUserMessage_default, O as CopilotChatAttachmentQueue, P as CopilotChatAttachmentRenderer, Q as CopilotKitProvider, R as useThreads, S as CopilotModalHeader, T as DefaultOpenIcon, U as useDefaultRenderTool, V as useSuggestions, W as useRenderTool, X as useAgent, Y as UseAgentUpdate, Z as useRenderToolCall, _ as WildcardToolCallRender, at as useSandboxFunctions, b as CopilotPopupView, ct as MCPAppsActivityType, dt as AudioRecorderError, et as CopilotKitCoreReact, ft as CopilotChatAudioRecorder, it as SandboxFunctionsContext, j as CopilotChatSuggestionPill, k as CopilotChatMessageView, lt as CopilotKitInspector, mt as useCopilotChatConfiguration, nt as defineToolCallRenderer, ot as MCPAppsActivityContentSchema, pt as CopilotChatConfigurationProvider, q as useRenderActivityMessage, rt as createA2UIMessageRenderer, st as MCPAppsActivityRenderer, t as CopilotKit, tt as useAgentContext, ut as CopilotChatInput_default, v as CopilotPopup, w as DefaultCloseIcon, x as CopilotSidebarView, y as CopilotSidebar, z as useInterrupt } from "../copilotkit-
|
|
3
|
+
import { $ as useCopilotKit, A as CopilotChatSuggestionView, B as useConfigureSuggestions, C as CopilotChatToggleButton, D as CopilotChatView_default, E as CopilotChat, F as CopilotChatAssistantMessage_default, G as useComponent, H as useHumanInTheLoop, I as CopilotChatToolCallsView, J as useRenderCustomMessages, K as useFrontendTool, L as useAttachments, M as CopilotChatReasoningMessage_default, N as CopilotChatUserMessage_default, O as CopilotChatAttachmentQueue, P as CopilotChatAttachmentRenderer, Q as CopilotKitProvider, R as useThreads, S as CopilotModalHeader, T as DefaultOpenIcon, U as useDefaultRenderTool, V as useSuggestions, W as useRenderTool, X as useAgent, Y as UseAgentUpdate, Z as useRenderToolCall, _ as WildcardToolCallRender, at as useSandboxFunctions, b as CopilotPopupView, ct as MCPAppsActivityType, dt as AudioRecorderError, et as CopilotKitCoreReact, ft as CopilotChatAudioRecorder, it as SandboxFunctionsContext, j as CopilotChatSuggestionPill, k as CopilotChatMessageView, lt as CopilotKitInspector, mt as useCopilotChatConfiguration, nt as defineToolCallRenderer, ot as MCPAppsActivityContentSchema, pt as CopilotChatConfigurationProvider, q as useRenderActivityMessage, rt as createA2UIMessageRenderer, st as MCPAppsActivityRenderer, t as CopilotKit, tt as useAgentContext, ut as CopilotChatInput_default, v as CopilotPopup, w as DefaultCloseIcon, x as CopilotSidebarView, y as CopilotSidebar, z as useInterrupt } from "../copilotkit-Cd-NrDyp.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
|
@@ -165,14 +165,11 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
|
|
|
165
165
|
var _ref, _parentConfig$isModal, _parentConfig$setModa;
|
|
166
166
|
const parentConfig = (0, react.useContext)(CopilotChatConfiguration);
|
|
167
167
|
const stableLabels = useShallowStableRef(labels);
|
|
168
|
-
const mergedLabels = (0, react.useMemo)(() => {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
...stableLabels !== null && stableLabels !== void 0 ? stableLabels : {}
|
|
174
|
-
};
|
|
175
|
-
}, [stableLabels, parentConfig === null || parentConfig === void 0 ? void 0 : parentConfig.labels]);
|
|
168
|
+
const mergedLabels = (0, react.useMemo)(() => ({
|
|
169
|
+
...CopilotChatDefaultLabels,
|
|
170
|
+
...parentConfig === null || parentConfig === void 0 ? void 0 : parentConfig.labels,
|
|
171
|
+
...stableLabels
|
|
172
|
+
}), [stableLabels, parentConfig === null || parentConfig === void 0 ? void 0 : parentConfig.labels]);
|
|
176
173
|
const resolvedAgentId = (_ref = agentId !== null && agentId !== void 0 ? agentId : parentConfig === null || parentConfig === void 0 ? void 0 : parentConfig.agentId) !== null && _ref !== void 0 ? _ref : _copilotkit_shared.DEFAULT_AGENT_ID;
|
|
177
174
|
const resolvedThreadId = (0, react.useMemo)(() => {
|
|
178
175
|
if (threadId) return threadId;
|
|
@@ -2467,9 +2464,8 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
2467
2464
|
if (!agent) return;
|
|
2468
2465
|
message.userAction;
|
|
2469
2466
|
try {
|
|
2470
|
-
var _copilotkit$propertie;
|
|
2471
2467
|
copilotkit.setProperties({
|
|
2472
|
-
...
|
|
2468
|
+
...copilotkit.properties,
|
|
2473
2469
|
a2uiAction: message
|
|
2474
2470
|
});
|
|
2475
2471
|
await copilotkit.runAgent({ agent });
|
|
@@ -5725,6 +5721,34 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
5725
5721
|
if (JSON.stringify(prevProps.stateSnapshot) !== JSON.stringify(nextProps.stateSnapshot)) return false;
|
|
5726
5722
|
return true;
|
|
5727
5723
|
});
|
|
5724
|
+
/**
|
|
5725
|
+
* Deduplicates messages by ID. For assistant messages, merges occurrences:
|
|
5726
|
+
* recovers non-empty content from any earlier occurrence if the latest wiped it
|
|
5727
|
+
* (empty string means the streaming update cleared the field, not blank text),
|
|
5728
|
+
* and similarly recovers toolCalls from earlier occurrences if the latest is
|
|
5729
|
+
* undefined (an empty array [] is treated as intentional and kept as-is).
|
|
5730
|
+
* For all other roles, keeps the last entry.
|
|
5731
|
+
*
|
|
5732
|
+
* @internal Exported for unit testing only — not part of the public API.
|
|
5733
|
+
*/
|
|
5734
|
+
function deduplicateMessages(messages) {
|
|
5735
|
+
const acc = /* @__PURE__ */ new Map();
|
|
5736
|
+
for (const message of messages) {
|
|
5737
|
+
const existing = acc.get(message.id);
|
|
5738
|
+
if (existing && message.role === "assistant" && existing.role === "assistant") {
|
|
5739
|
+
var _message$toolCalls;
|
|
5740
|
+
const content = message.content || existing.content;
|
|
5741
|
+
const toolCalls = (_message$toolCalls = message.toolCalls) !== null && _message$toolCalls !== void 0 ? _message$toolCalls : existing.toolCalls;
|
|
5742
|
+
acc.set(message.id, {
|
|
5743
|
+
...existing,
|
|
5744
|
+
...message,
|
|
5745
|
+
content,
|
|
5746
|
+
toolCalls
|
|
5747
|
+
});
|
|
5748
|
+
} else acc.set(message.id, message);
|
|
5749
|
+
}
|
|
5750
|
+
return [...acc.values()];
|
|
5751
|
+
}
|
|
5728
5752
|
const VIRTUALIZE_THRESHOLD = 50;
|
|
5729
5753
|
function CopilotChatMessageView({ messages = [], assistantMessage, userMessage, reasoningMessage, cursor, isRunning = false, children, className, ...props }) {
|
|
5730
5754
|
var _deduplicatedMessages;
|
|
@@ -5762,8 +5786,8 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
5762
5786
|
if (!resolvedRunId) return void 0;
|
|
5763
5787
|
return copilotkit.getStateByRun(config.agentId, config.threadId, resolvedRunId);
|
|
5764
5788
|
};
|
|
5765
|
-
const deduplicatedMessages = (0, react.useMemo)(() =>
|
|
5766
|
-
if (process.env.NODE_ENV === "development" && deduplicatedMessages.length < messages.length) console.warn(`CopilotChatMessageView:
|
|
5789
|
+
const deduplicatedMessages = (0, react.useMemo)(() => deduplicateMessages(messages), [messages]);
|
|
5790
|
+
if (process.env.NODE_ENV === "development" && deduplicatedMessages.length < messages.length) console.warn(`CopilotChatMessageView: Merged ${messages.length - deduplicatedMessages.length} message(s) with duplicate IDs.`);
|
|
5767
5791
|
const { Component: AssistantComponent, slotProps: assistantSlotProps } = (0, react.useMemo)(() => resolveSlotComponent(assistantMessage, CopilotChatAssistantMessage_default), [assistantMessage]);
|
|
5768
5792
|
const { Component: UserComponent, slotProps: userSlotProps } = (0, react.useMemo)(() => resolveSlotComponent(userMessage, CopilotChatUserMessage_default), [userMessage]);
|
|
5769
5793
|
const { Component: ReasoningComponent, slotProps: reasoningSlotProps } = (0, react.useMemo)(() => resolveSlotComponent(reasoningMessage, CopilotChatReasoningMessage_default), [reasoningMessage]);
|
|
@@ -8731,8 +8755,8 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
8731
8755
|
* 5) last cached snapshot for stateRenderId
|
|
8732
8756
|
*/
|
|
8733
8757
|
function selectSnapshot({ messageId, messageName, allowLiveState, skipLatestCache, stateRenderId, effectiveRunId, stateSnapshotProp, agentState, agentMessages, existingClaim, caches }) {
|
|
8734
|
-
var
|
|
8735
|
-
const lastAssistantId = agentMessages ? (
|
|
8758
|
+
var _toReversed$find, _agentMessages$messag, _existingClaim$stateS, _existingClaim$stateS2;
|
|
8759
|
+
const lastAssistantId = agentMessages ? (_toReversed$find = [...agentMessages].toReversed().find((msg) => msg.role === "assistant")) === null || _toReversed$find === void 0 ? void 0 : _toReversed$find.id : void 0;
|
|
8736
8760
|
const latestSnapshot = stateRenderId !== void 0 ? caches.byStateRenderAndRun[`${stateRenderId}::latest`] : void 0;
|
|
8737
8761
|
const messageIndex = agentMessages ? agentMessages.findIndex((msg) => msg.id === messageId) : -1;
|
|
8738
8762
|
const messageRole = messageIndex >= 0 && agentMessages ? (_agentMessages$messag = agentMessages[messageIndex]) === null || _agentMessages$messag === void 0 ? void 0 : _agentMessages$messag.role : void 0;
|
|
@@ -8796,13 +8820,13 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
8796
8820
|
return () => {
|
|
8797
8821
|
const existingClaim = claimsRef.current[message.id];
|
|
8798
8822
|
if ((existingClaim === null || existingClaim === void 0 ? void 0 : existingClaim.stateSnapshot) && Object.keys(existingClaim.stateSnapshot).length > 0) {
|
|
8799
|
-
var
|
|
8800
|
-
const snapshotCache = { ...
|
|
8823
|
+
var _existingClaim$runId, _existingClaim$runId2;
|
|
8824
|
+
const snapshotCache = { ...store[LAST_SNAPSHOTS_BY_RENDER_AND_RUN] };
|
|
8801
8825
|
const cacheKey = `${existingClaim.stateRenderId}::${(_existingClaim$runId = existingClaim.runId) !== null && _existingClaim$runId !== void 0 ? _existingClaim$runId : "pending"}`;
|
|
8802
8826
|
snapshotCache[cacheKey] = existingClaim.stateSnapshot;
|
|
8803
8827
|
snapshotCache[`${existingClaim.stateRenderId}::latest`] = existingClaim.stateSnapshot;
|
|
8804
8828
|
store[LAST_SNAPSHOTS_BY_RENDER_AND_RUN] = snapshotCache;
|
|
8805
|
-
const messageCache = { ...
|
|
8829
|
+
const messageCache = { ...store[LAST_SNAPSHOTS_BY_MESSAGE] };
|
|
8806
8830
|
messageCache[message.id] = {
|
|
8807
8831
|
snapshot: existingClaim.stateSnapshot,
|
|
8808
8832
|
runId: (_existingClaim$runId2 = existingClaim.runId) !== null && _existingClaim$runId2 !== void 0 ? _existingClaim$runId2 : effectiveRunId
|
|
@@ -8857,14 +8881,13 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
8857
8881
|
const snapshotChanged = stateSnapshot && existingSnapshot !== void 0 && !areStatesEquals(existingSnapshot, snapshot);
|
|
8858
8882
|
if (snapshot && (stateSnapshot || hasSnapshotKeys || allowEmptySnapshot) && (!claimsRef.current[message.id].locked || snapshotChanged)) {
|
|
8859
8883
|
if (!claimsRef.current[message.id].locked || snapshotChanged) {
|
|
8860
|
-
var _store$LAST_SNAPSHOTS6, _store$LAST_SNAPSHOTS7;
|
|
8861
8884
|
claimsRef.current[message.id].stateSnapshot = snapshot;
|
|
8862
|
-
const snapshotCache = { ...
|
|
8885
|
+
const snapshotCache = { ...store[LAST_SNAPSHOTS_BY_RENDER_AND_RUN] };
|
|
8863
8886
|
const cacheKey = `${stateRenderId}::${effectiveRunId}`;
|
|
8864
8887
|
snapshotCache[cacheKey] = snapshot;
|
|
8865
8888
|
snapshotCache[`${stateRenderId}::latest`] = snapshot;
|
|
8866
8889
|
store[LAST_SNAPSHOTS_BY_RENDER_AND_RUN] = snapshotCache;
|
|
8867
|
-
const messageCache = { ...
|
|
8890
|
+
const messageCache = { ...store[LAST_SNAPSHOTS_BY_MESSAGE] };
|
|
8868
8891
|
messageCache[message.id] = {
|
|
8869
8892
|
snapshot,
|
|
8870
8893
|
runId: effectiveRunId
|
|
@@ -8874,14 +8897,13 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
8874
8897
|
}
|
|
8875
8898
|
} else if (snapshotForClaim) {
|
|
8876
8899
|
if (!claimsRef.current[message.id].stateSnapshot) {
|
|
8877
|
-
var _store$LAST_SNAPSHOTS8, _store$LAST_SNAPSHOTS9;
|
|
8878
8900
|
claimsRef.current[message.id].stateSnapshot = snapshotForClaim;
|
|
8879
|
-
const snapshotCache = { ...
|
|
8901
|
+
const snapshotCache = { ...store[LAST_SNAPSHOTS_BY_RENDER_AND_RUN] };
|
|
8880
8902
|
const cacheKey = `${stateRenderId}::${effectiveRunId}`;
|
|
8881
8903
|
snapshotCache[cacheKey] = snapshotForClaim;
|
|
8882
8904
|
snapshotCache[`${stateRenderId}::latest`] = snapshotForClaim;
|
|
8883
8905
|
store[LAST_SNAPSHOTS_BY_RENDER_AND_RUN] = snapshotCache;
|
|
8884
|
-
const messageCache = { ...
|
|
8906
|
+
const messageCache = { ...store[LAST_SNAPSHOTS_BY_MESSAGE] };
|
|
8885
8907
|
messageCache[message.id] = {
|
|
8886
8908
|
snapshot: snapshotForClaim,
|
|
8887
8909
|
runId: effectiveRunId
|
|
@@ -9233,7 +9255,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
9233
9255
|
return acc;
|
|
9234
9256
|
}, {});
|
|
9235
9257
|
return {
|
|
9236
|
-
...copilotApiConfig.headers
|
|
9258
|
+
...copilotApiConfig.headers,
|
|
9237
9259
|
...copilotApiConfig.publicApiKey ? { [_copilotkit_shared.COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: copilotApiConfig.publicApiKey } : {},
|
|
9238
9260
|
...authHeaders
|
|
9239
9261
|
};
|
|
@@ -9313,12 +9335,11 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
9313
9335
|
const [interruptActions, _setInterruptActions] = (0, react.useState)({});
|
|
9314
9336
|
const setInterruptAction = (0, react.useCallback)((action) => {
|
|
9315
9337
|
_setInterruptActions((prev) => {
|
|
9316
|
-
var _prev$action$id;
|
|
9317
9338
|
if (action == null || !action.id) return prev;
|
|
9318
9339
|
return {
|
|
9319
9340
|
...prev,
|
|
9320
9341
|
[action.id]: {
|
|
9321
|
-
...
|
|
9342
|
+
...prev[action.id],
|
|
9322
9343
|
...action
|
|
9323
9344
|
}
|
|
9324
9345
|
};
|