@copilotkit/react-core 1.55.1 → 1.55.2-canary.test-01
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 +34 -0
- package/dist/copilotkit-BuhSUZHb.d.mts.map +1 -1
- package/dist/{copilotkit-BY5S1-0P.mjs → copilotkit-Cd-NrDyp.mjs} +46 -16
- package/dist/copilotkit-Cd-NrDyp.mjs.map +1 -0
- package/dist/{copilotkit-Bz5-ImDl.cjs → copilotkit-Dgdpbqjt.cjs} +46 -16
- 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 +28 -29
- 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 +52 -28
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +7 -7
- 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/MCPAppsActivityRenderer.tsx +32 -2
- package/src/v2/components/chat/CopilotChatMessageView.tsx +41 -5
- package/src/v2/components/chat/__tests__/CopilotChatMessageView.test.tsx +192 -82
- package/src/v2/components/chat/__tests__/MCPAppsProxy.e2e.test.tsx +589 -0
- package/src/v2/components/chat/__tests__/MCPAppsUiMessage.e2e.test.tsx +458 -0
- package/src/v2/providers/CopilotChatConfigurationProvider.tsx +2 -2
- package/dist/copilotkit-BY5S1-0P.mjs.map +0 -1
- package/dist/copilotkit-Bz5-ImDl.cjs.map +0 -1
package/dist/index.umd.js
CHANGED
|
@@ -149,14 +149,11 @@ react_markdown = __toESM(react_markdown);
|
|
|
149
149
|
var _ref, _parentConfig$isModal, _parentConfig$setModa;
|
|
150
150
|
const parentConfig = (0, react.useContext)(CopilotChatConfiguration);
|
|
151
151
|
const stableLabels = useShallowStableRef(labels);
|
|
152
|
-
const mergedLabels = (0, react.useMemo)(() => {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
...stableLabels !== null && stableLabels !== void 0 ? stableLabels : {}
|
|
158
|
-
};
|
|
159
|
-
}, [stableLabels, parentConfig === null || parentConfig === void 0 ? void 0 : parentConfig.labels]);
|
|
152
|
+
const mergedLabels = (0, react.useMemo)(() => ({
|
|
153
|
+
...CopilotChatDefaultLabels,
|
|
154
|
+
...parentConfig === null || parentConfig === void 0 ? void 0 : parentConfig.labels,
|
|
155
|
+
...stableLabels
|
|
156
|
+
}), [stableLabels, parentConfig === null || parentConfig === void 0 ? void 0 : parentConfig.labels]);
|
|
160
157
|
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;
|
|
161
158
|
const resolvedThreadId = (0, react.useMemo)(() => {
|
|
162
159
|
if (threadId) return threadId;
|
|
@@ -493,6 +490,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
493
490
|
*/
|
|
494
491
|
const MCPAppsActivityRenderer = function MCPAppsActivityRenderer({ content, agent }) {
|
|
495
492
|
var _fetchedResource$_met2;
|
|
493
|
+
const { copilotkit } = useCopilotKit();
|
|
496
494
|
const containerRef = (0, react.useRef)(null);
|
|
497
495
|
const iframeRef = (0, react.useRef)(null);
|
|
498
496
|
const [iframeReady, setIframeReady] = (0, react.useState)(false);
|
|
@@ -670,15 +668,17 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
670
668
|
break;
|
|
671
669
|
}
|
|
672
670
|
try {
|
|
673
|
-
var _params$content;
|
|
671
|
+
var _params$content, _params$followUp;
|
|
674
672
|
const params = msg.params;
|
|
673
|
+
const role = params.role || "user";
|
|
675
674
|
const textContent = ((_params$content = params.content) === null || _params$content === void 0 ? void 0 : _params$content.filter((c) => c.type === "text" && c.text).map((c) => c.text).join("\n")) || "";
|
|
676
675
|
if (textContent) currentAgent.addMessage({
|
|
677
676
|
id: crypto.randomUUID(),
|
|
678
|
-
role
|
|
677
|
+
role,
|
|
679
678
|
content: textContent
|
|
680
679
|
});
|
|
681
680
|
sendResponse(msg.id, { isError: false });
|
|
681
|
+
if (((_params$followUp = params.followUp) !== null && _params$followUp !== void 0 ? _params$followUp : role === "user") && textContent) mcpAppsRequestQueue.enqueue(currentAgent, () => copilotkit.runAgent({ agent: currentAgent })).catch((err) => console.error("[MCPAppsRenderer] ui/message agent run failed:", err));
|
|
682
682
|
} catch (err) {
|
|
683
683
|
console.error("[MCPAppsRenderer] ui/message error:", err);
|
|
684
684
|
sendResponse(msg.id, { isError: true });
|
|
@@ -1311,9 +1311,8 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
1311
1311
|
if (!agent) return;
|
|
1312
1312
|
message.userAction;
|
|
1313
1313
|
try {
|
|
1314
|
-
var _copilotkit$propertie;
|
|
1315
1314
|
copilotkit.setProperties({
|
|
1316
|
-
...
|
|
1315
|
+
...copilotkit.properties,
|
|
1317
1316
|
a2uiAction: message
|
|
1318
1317
|
});
|
|
1319
1318
|
await copilotkit.runAgent({ agent });
|
|
@@ -4407,8 +4406,8 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
4407
4406
|
* 5) last cached snapshot for stateRenderId
|
|
4408
4407
|
*/
|
|
4409
4408
|
function selectSnapshot({ messageId, messageName, allowLiveState, skipLatestCache, stateRenderId, effectiveRunId, stateSnapshotProp, agentState, agentMessages, existingClaim, caches }) {
|
|
4410
|
-
var
|
|
4411
|
-
const lastAssistantId = agentMessages ? (
|
|
4409
|
+
var _toReversed$find, _agentMessages$messag, _existingClaim$stateS, _existingClaim$stateS2;
|
|
4410
|
+
const lastAssistantId = agentMessages ? (_toReversed$find = [...agentMessages].toReversed().find((msg) => msg.role === "assistant")) === null || _toReversed$find === void 0 ? void 0 : _toReversed$find.id : void 0;
|
|
4412
4411
|
const latestSnapshot = stateRenderId !== void 0 ? caches.byStateRenderAndRun[`${stateRenderId}::latest`] : void 0;
|
|
4413
4412
|
const messageIndex = agentMessages ? agentMessages.findIndex((msg) => msg.id === messageId) : -1;
|
|
4414
4413
|
const messageRole = messageIndex >= 0 && agentMessages ? (_agentMessages$messag = agentMessages[messageIndex]) === null || _agentMessages$messag === void 0 ? void 0 : _agentMessages$messag.role : void 0;
|
|
@@ -4472,13 +4471,13 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
4472
4471
|
return () => {
|
|
4473
4472
|
const existingClaim = claimsRef.current[message.id];
|
|
4474
4473
|
if ((existingClaim === null || existingClaim === void 0 ? void 0 : existingClaim.stateSnapshot) && Object.keys(existingClaim.stateSnapshot).length > 0) {
|
|
4475
|
-
var
|
|
4476
|
-
const snapshotCache = { ...
|
|
4474
|
+
var _existingClaim$runId, _existingClaim$runId2;
|
|
4475
|
+
const snapshotCache = { ...store[LAST_SNAPSHOTS_BY_RENDER_AND_RUN] };
|
|
4477
4476
|
const cacheKey = `${existingClaim.stateRenderId}::${(_existingClaim$runId = existingClaim.runId) !== null && _existingClaim$runId !== void 0 ? _existingClaim$runId : "pending"}`;
|
|
4478
4477
|
snapshotCache[cacheKey] = existingClaim.stateSnapshot;
|
|
4479
4478
|
snapshotCache[`${existingClaim.stateRenderId}::latest`] = existingClaim.stateSnapshot;
|
|
4480
4479
|
store[LAST_SNAPSHOTS_BY_RENDER_AND_RUN] = snapshotCache;
|
|
4481
|
-
const messageCache = { ...
|
|
4480
|
+
const messageCache = { ...store[LAST_SNAPSHOTS_BY_MESSAGE] };
|
|
4482
4481
|
messageCache[message.id] = {
|
|
4483
4482
|
snapshot: existingClaim.stateSnapshot,
|
|
4484
4483
|
runId: (_existingClaim$runId2 = existingClaim.runId) !== null && _existingClaim$runId2 !== void 0 ? _existingClaim$runId2 : effectiveRunId
|
|
@@ -4533,14 +4532,13 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
4533
4532
|
const snapshotChanged = stateSnapshot && existingSnapshot !== void 0 && !areStatesEquals(existingSnapshot, snapshot);
|
|
4534
4533
|
if (snapshot && (stateSnapshot || hasSnapshotKeys || allowEmptySnapshot) && (!claimsRef.current[message.id].locked || snapshotChanged)) {
|
|
4535
4534
|
if (!claimsRef.current[message.id].locked || snapshotChanged) {
|
|
4536
|
-
var _store$LAST_SNAPSHOTS6, _store$LAST_SNAPSHOTS7;
|
|
4537
4535
|
claimsRef.current[message.id].stateSnapshot = snapshot;
|
|
4538
|
-
const snapshotCache = { ...
|
|
4536
|
+
const snapshotCache = { ...store[LAST_SNAPSHOTS_BY_RENDER_AND_RUN] };
|
|
4539
4537
|
const cacheKey = `${stateRenderId}::${effectiveRunId}`;
|
|
4540
4538
|
snapshotCache[cacheKey] = snapshot;
|
|
4541
4539
|
snapshotCache[`${stateRenderId}::latest`] = snapshot;
|
|
4542
4540
|
store[LAST_SNAPSHOTS_BY_RENDER_AND_RUN] = snapshotCache;
|
|
4543
|
-
const messageCache = { ...
|
|
4541
|
+
const messageCache = { ...store[LAST_SNAPSHOTS_BY_MESSAGE] };
|
|
4544
4542
|
messageCache[message.id] = {
|
|
4545
4543
|
snapshot,
|
|
4546
4544
|
runId: effectiveRunId
|
|
@@ -4550,14 +4548,13 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
4550
4548
|
}
|
|
4551
4549
|
} else if (snapshotForClaim) {
|
|
4552
4550
|
if (!claimsRef.current[message.id].stateSnapshot) {
|
|
4553
|
-
var _store$LAST_SNAPSHOTS8, _store$LAST_SNAPSHOTS9;
|
|
4554
4551
|
claimsRef.current[message.id].stateSnapshot = snapshotForClaim;
|
|
4555
|
-
const snapshotCache = { ...
|
|
4552
|
+
const snapshotCache = { ...store[LAST_SNAPSHOTS_BY_RENDER_AND_RUN] };
|
|
4556
4553
|
const cacheKey = `${stateRenderId}::${effectiveRunId}`;
|
|
4557
4554
|
snapshotCache[cacheKey] = snapshotForClaim;
|
|
4558
4555
|
snapshotCache[`${stateRenderId}::latest`] = snapshotForClaim;
|
|
4559
4556
|
store[LAST_SNAPSHOTS_BY_RENDER_AND_RUN] = snapshotCache;
|
|
4560
|
-
const messageCache = { ...
|
|
4557
|
+
const messageCache = { ...store[LAST_SNAPSHOTS_BY_MESSAGE] };
|
|
4561
4558
|
messageCache[message.id] = {
|
|
4562
4559
|
snapshot: snapshotForClaim,
|
|
4563
4560
|
runId: effectiveRunId
|
|
@@ -4909,7 +4906,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
4909
4906
|
return acc;
|
|
4910
4907
|
}, {});
|
|
4911
4908
|
return {
|
|
4912
|
-
...copilotApiConfig.headers
|
|
4909
|
+
...copilotApiConfig.headers,
|
|
4913
4910
|
...copilotApiConfig.publicApiKey ? { [_copilotkit_shared.COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: copilotApiConfig.publicApiKey } : {},
|
|
4914
4911
|
...authHeaders
|
|
4915
4912
|
};
|
|
@@ -4989,12 +4986,11 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
4989
4986
|
const [interruptActions, _setInterruptActions] = (0, react.useState)({});
|
|
4990
4987
|
const setInterruptAction = (0, react.useCallback)((action) => {
|
|
4991
4988
|
_setInterruptActions((prev) => {
|
|
4992
|
-
var _prev$action$id;
|
|
4993
4989
|
if (action == null || !action.id) return prev;
|
|
4994
4990
|
return {
|
|
4995
4991
|
...prev,
|
|
4996
4992
|
[action.id]: {
|
|
4997
|
-
...
|
|
4993
|
+
...prev[action.id],
|
|
4998
4994
|
...action
|
|
4999
4995
|
}
|
|
5000
4996
|
};
|
|
@@ -5337,7 +5333,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
5337
5333
|
}
|
|
5338
5334
|
let historyCutoff = [messages[0]];
|
|
5339
5335
|
if (messages.length > 2 && reloadMessageIndex !== 0) {
|
|
5340
|
-
const lastUserMessageBeforeRegenerate = messages.slice(0, reloadMessageIndex).
|
|
5336
|
+
const lastUserMessageBeforeRegenerate = messages.slice(0, reloadMessageIndex).toReversed().find((msg) => msg.role === "user");
|
|
5341
5337
|
if (!lastUserMessageBeforeRegenerate) historyCutoff = [messages[0]];
|
|
5342
5338
|
else {
|
|
5343
5339
|
const indexOfLastUserMessageBeforeRegenerate = messages.findIndex((msg) => msg.id === lastUserMessageBeforeRegenerate.id);
|
|
@@ -6469,6 +6465,9 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
6469
6465
|
},
|
|
6470
6466
|
onRunFinishedEvent: () => {
|
|
6471
6467
|
nodeNameRef.current = "end";
|
|
6468
|
+
},
|
|
6469
|
+
onRunErrorEvent: () => {
|
|
6470
|
+
nodeNameRef.current = "end";
|
|
6472
6471
|
}
|
|
6473
6472
|
});
|
|
6474
6473
|
return () => {
|
|
@@ -7121,7 +7120,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
7121
7120
|
* @param data The data to use for the task.
|
|
7122
7121
|
*/
|
|
7123
7122
|
async run(context, data) {
|
|
7124
|
-
var
|
|
7123
|
+
var _response$data;
|
|
7125
7124
|
const actions = this.includeCopilotActions ? Object.assign({}, context.actions) : {};
|
|
7126
7125
|
for (const fn of this.actions) actions[fn.name] = fn;
|
|
7127
7126
|
let contextString = "";
|
|
@@ -7146,7 +7145,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
7146
7145
|
metadata: { requestType: _copilotkit_runtime_client_gql.CopilotRequestType.Task },
|
|
7147
7146
|
forwardedParameters: {
|
|
7148
7147
|
toolChoice: "required",
|
|
7149
|
-
...
|
|
7148
|
+
...this.forwardedParameters
|
|
7150
7149
|
}
|
|
7151
7150
|
},
|
|
7152
7151
|
properties: context.copilotApiConfig.properties
|