@copilotkit/react-core 1.55.2-next.0 → 1.55.2-next.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/CHANGELOG.md +11 -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/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;
|
|
@@ -1314,9 +1311,8 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
1314
1311
|
if (!agent) return;
|
|
1315
1312
|
message.userAction;
|
|
1316
1313
|
try {
|
|
1317
|
-
var _copilotkit$propertie;
|
|
1318
1314
|
copilotkit.setProperties({
|
|
1319
|
-
...
|
|
1315
|
+
...copilotkit.properties,
|
|
1320
1316
|
a2uiAction: message
|
|
1321
1317
|
});
|
|
1322
1318
|
await copilotkit.runAgent({ agent });
|
|
@@ -4410,8 +4406,8 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
4410
4406
|
* 5) last cached snapshot for stateRenderId
|
|
4411
4407
|
*/
|
|
4412
4408
|
function selectSnapshot({ messageId, messageName, allowLiveState, skipLatestCache, stateRenderId, effectiveRunId, stateSnapshotProp, agentState, agentMessages, existingClaim, caches }) {
|
|
4413
|
-
var
|
|
4414
|
-
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;
|
|
4415
4411
|
const latestSnapshot = stateRenderId !== void 0 ? caches.byStateRenderAndRun[`${stateRenderId}::latest`] : void 0;
|
|
4416
4412
|
const messageIndex = agentMessages ? agentMessages.findIndex((msg) => msg.id === messageId) : -1;
|
|
4417
4413
|
const messageRole = messageIndex >= 0 && agentMessages ? (_agentMessages$messag = agentMessages[messageIndex]) === null || _agentMessages$messag === void 0 ? void 0 : _agentMessages$messag.role : void 0;
|
|
@@ -4475,13 +4471,13 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
4475
4471
|
return () => {
|
|
4476
4472
|
const existingClaim = claimsRef.current[message.id];
|
|
4477
4473
|
if ((existingClaim === null || existingClaim === void 0 ? void 0 : existingClaim.stateSnapshot) && Object.keys(existingClaim.stateSnapshot).length > 0) {
|
|
4478
|
-
var
|
|
4479
|
-
const snapshotCache = { ...
|
|
4474
|
+
var _existingClaim$runId, _existingClaim$runId2;
|
|
4475
|
+
const snapshotCache = { ...store[LAST_SNAPSHOTS_BY_RENDER_AND_RUN] };
|
|
4480
4476
|
const cacheKey = `${existingClaim.stateRenderId}::${(_existingClaim$runId = existingClaim.runId) !== null && _existingClaim$runId !== void 0 ? _existingClaim$runId : "pending"}`;
|
|
4481
4477
|
snapshotCache[cacheKey] = existingClaim.stateSnapshot;
|
|
4482
4478
|
snapshotCache[`${existingClaim.stateRenderId}::latest`] = existingClaim.stateSnapshot;
|
|
4483
4479
|
store[LAST_SNAPSHOTS_BY_RENDER_AND_RUN] = snapshotCache;
|
|
4484
|
-
const messageCache = { ...
|
|
4480
|
+
const messageCache = { ...store[LAST_SNAPSHOTS_BY_MESSAGE] };
|
|
4485
4481
|
messageCache[message.id] = {
|
|
4486
4482
|
snapshot: existingClaim.stateSnapshot,
|
|
4487
4483
|
runId: (_existingClaim$runId2 = existingClaim.runId) !== null && _existingClaim$runId2 !== void 0 ? _existingClaim$runId2 : effectiveRunId
|
|
@@ -4536,14 +4532,13 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
4536
4532
|
const snapshotChanged = stateSnapshot && existingSnapshot !== void 0 && !areStatesEquals(existingSnapshot, snapshot);
|
|
4537
4533
|
if (snapshot && (stateSnapshot || hasSnapshotKeys || allowEmptySnapshot) && (!claimsRef.current[message.id].locked || snapshotChanged)) {
|
|
4538
4534
|
if (!claimsRef.current[message.id].locked || snapshotChanged) {
|
|
4539
|
-
var _store$LAST_SNAPSHOTS6, _store$LAST_SNAPSHOTS7;
|
|
4540
4535
|
claimsRef.current[message.id].stateSnapshot = snapshot;
|
|
4541
|
-
const snapshotCache = { ...
|
|
4536
|
+
const snapshotCache = { ...store[LAST_SNAPSHOTS_BY_RENDER_AND_RUN] };
|
|
4542
4537
|
const cacheKey = `${stateRenderId}::${effectiveRunId}`;
|
|
4543
4538
|
snapshotCache[cacheKey] = snapshot;
|
|
4544
4539
|
snapshotCache[`${stateRenderId}::latest`] = snapshot;
|
|
4545
4540
|
store[LAST_SNAPSHOTS_BY_RENDER_AND_RUN] = snapshotCache;
|
|
4546
|
-
const messageCache = { ...
|
|
4541
|
+
const messageCache = { ...store[LAST_SNAPSHOTS_BY_MESSAGE] };
|
|
4547
4542
|
messageCache[message.id] = {
|
|
4548
4543
|
snapshot,
|
|
4549
4544
|
runId: effectiveRunId
|
|
@@ -4553,14 +4548,13 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
4553
4548
|
}
|
|
4554
4549
|
} else if (snapshotForClaim) {
|
|
4555
4550
|
if (!claimsRef.current[message.id].stateSnapshot) {
|
|
4556
|
-
var _store$LAST_SNAPSHOTS8, _store$LAST_SNAPSHOTS9;
|
|
4557
4551
|
claimsRef.current[message.id].stateSnapshot = snapshotForClaim;
|
|
4558
|
-
const snapshotCache = { ...
|
|
4552
|
+
const snapshotCache = { ...store[LAST_SNAPSHOTS_BY_RENDER_AND_RUN] };
|
|
4559
4553
|
const cacheKey = `${stateRenderId}::${effectiveRunId}`;
|
|
4560
4554
|
snapshotCache[cacheKey] = snapshotForClaim;
|
|
4561
4555
|
snapshotCache[`${stateRenderId}::latest`] = snapshotForClaim;
|
|
4562
4556
|
store[LAST_SNAPSHOTS_BY_RENDER_AND_RUN] = snapshotCache;
|
|
4563
|
-
const messageCache = { ...
|
|
4557
|
+
const messageCache = { ...store[LAST_SNAPSHOTS_BY_MESSAGE] };
|
|
4564
4558
|
messageCache[message.id] = {
|
|
4565
4559
|
snapshot: snapshotForClaim,
|
|
4566
4560
|
runId: effectiveRunId
|
|
@@ -4912,7 +4906,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
4912
4906
|
return acc;
|
|
4913
4907
|
}, {});
|
|
4914
4908
|
return {
|
|
4915
|
-
...copilotApiConfig.headers
|
|
4909
|
+
...copilotApiConfig.headers,
|
|
4916
4910
|
...copilotApiConfig.publicApiKey ? { [_copilotkit_shared.COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: copilotApiConfig.publicApiKey } : {},
|
|
4917
4911
|
...authHeaders
|
|
4918
4912
|
};
|
|
@@ -4992,12 +4986,11 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
4992
4986
|
const [interruptActions, _setInterruptActions] = (0, react.useState)({});
|
|
4993
4987
|
const setInterruptAction = (0, react.useCallback)((action) => {
|
|
4994
4988
|
_setInterruptActions((prev) => {
|
|
4995
|
-
var _prev$action$id;
|
|
4996
4989
|
if (action == null || !action.id) return prev;
|
|
4997
4990
|
return {
|
|
4998
4991
|
...prev,
|
|
4999
4992
|
[action.id]: {
|
|
5000
|
-
...
|
|
4993
|
+
...prev[action.id],
|
|
5001
4994
|
...action
|
|
5002
4995
|
}
|
|
5003
4996
|
};
|
|
@@ -5340,7 +5333,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
5340
5333
|
}
|
|
5341
5334
|
let historyCutoff = [messages[0]];
|
|
5342
5335
|
if (messages.length > 2 && reloadMessageIndex !== 0) {
|
|
5343
|
-
const lastUserMessageBeforeRegenerate = messages.slice(0, reloadMessageIndex).
|
|
5336
|
+
const lastUserMessageBeforeRegenerate = messages.slice(0, reloadMessageIndex).toReversed().find((msg) => msg.role === "user");
|
|
5344
5337
|
if (!lastUserMessageBeforeRegenerate) historyCutoff = [messages[0]];
|
|
5345
5338
|
else {
|
|
5346
5339
|
const indexOfLastUserMessageBeforeRegenerate = messages.findIndex((msg) => msg.id === lastUserMessageBeforeRegenerate.id);
|
|
@@ -6472,6 +6465,9 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
6472
6465
|
},
|
|
6473
6466
|
onRunFinishedEvent: () => {
|
|
6474
6467
|
nodeNameRef.current = "end";
|
|
6468
|
+
},
|
|
6469
|
+
onRunErrorEvent: () => {
|
|
6470
|
+
nodeNameRef.current = "end";
|
|
6475
6471
|
}
|
|
6476
6472
|
});
|
|
6477
6473
|
return () => {
|
|
@@ -7124,7 +7120,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
7124
7120
|
* @param data The data to use for the task.
|
|
7125
7121
|
*/
|
|
7126
7122
|
async run(context, data) {
|
|
7127
|
-
var
|
|
7123
|
+
var _response$data;
|
|
7128
7124
|
const actions = this.includeCopilotActions ? Object.assign({}, context.actions) : {};
|
|
7129
7125
|
for (const fn of this.actions) actions[fn.name] = fn;
|
|
7130
7126
|
let contextString = "";
|
|
@@ -7149,7 +7145,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
7149
7145
|
metadata: { requestType: _copilotkit_runtime_client_gql.CopilotRequestType.Task },
|
|
7150
7146
|
forwardedParameters: {
|
|
7151
7147
|
toolChoice: "required",
|
|
7152
|
-
...
|
|
7148
|
+
...this.forwardedParameters
|
|
7153
7149
|
}
|
|
7154
7150
|
},
|
|
7155
7151
|
properties: context.copilotApiConfig.properties
|