@copilotkit/react-core 1.87.0 → 1.88.0
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-Bop-sY6y.d.cts → copilotkit-BS_3fQrS.d.cts} +8 -3
- package/dist/{copilotkit-Bop-sY6y.d.cts.map → copilotkit-BS_3fQrS.d.cts.map} +1 -1
- package/dist/{copilotkit-ChqQa52S.mjs → copilotkit-CYqkB8Nv.mjs} +67 -16
- package/dist/copilotkit-CYqkB8Nv.mjs.map +1 -0
- package/dist/{copilotkit-CZ9tI_J1.cjs → copilotkit-D4AAgBT1.cjs} +67 -16
- package/dist/copilotkit-D4AAgBT1.cjs.map +1 -0
- package/dist/{copilotkit-BNPEXnEE.d.mts → copilotkit-RAr-1JSr.d.mts} +8 -3
- package/dist/{copilotkit-BNPEXnEE.d.mts.map → copilotkit-RAr-1JSr.d.mts.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.umd.js +8 -3
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/generative-ui.d.cts +284 -284
- package/dist/v2/generative-ui.d.cts.map +1 -1
- package/dist/v2/generative-ui.d.mts +284 -284
- package/dist/v2/generative-ui.d.mts.map +1 -1
- package/dist/v2/headless.cjs +7 -2
- package/dist/v2/headless.cjs.map +1 -1
- package/dist/v2/headless.d.cts +5 -0
- package/dist/v2/headless.d.cts.map +1 -1
- package/dist/v2/headless.d.mts +5 -0
- package/dist/v2/headless.d.mts.map +1 -1
- package/dist/v2/headless.mjs +7 -2
- package/dist/v2/headless.mjs.map +1 -1
- package/dist/v2/index.cjs +1 -1
- package/dist/v2/index.d.cts +2 -2
- package/dist/v2/index.d.mts +2 -2
- package/dist/v2/index.mjs +1 -1
- package/dist/v2/index.umd.js +66 -15
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +8 -8
- package/dist/copilotkit-CZ9tI_J1.cjs.map +0 -1
- package/dist/copilotkit-ChqQa52S.mjs.map +0 -1
|
@@ -1326,7 +1326,7 @@ function useRenderToolCall() {
|
|
|
1326
1326
|
|
|
1327
1327
|
//#endregion
|
|
1328
1328
|
//#region package.json
|
|
1329
|
-
var version = "1.
|
|
1329
|
+
var version = "1.88.0";
|
|
1330
1330
|
|
|
1331
1331
|
//#endregion
|
|
1332
1332
|
//#region src/v2/components/CopilotKitInspector.tsx
|
|
@@ -4882,6 +4882,11 @@ const ALL_UPDATES = [
|
|
|
4882
4882
|
UseAgentUpdate.OnStateChanged,
|
|
4883
4883
|
UseAgentUpdate.OnRunStatusChanged
|
|
4884
4884
|
];
|
|
4885
|
+
/**
|
|
4886
|
+
* Returns the selected agent and its readiness, subscribing to agent updates.
|
|
4887
|
+
* Uses a shared agent by default, or a private proxy when `agentId`,
|
|
4888
|
+
* `runtimeAgentId`, and `threadId` are supplied together.
|
|
4889
|
+
*/
|
|
4885
4890
|
function useAgent({ agentId, threadId, runtimeAgentId, updates, throttleMs } = {}) {
|
|
4886
4891
|
if (threadId != null && runtimeAgentId == null) throw new Error(`useAgent: \`threadId\` requires \`runtimeAgentId\`. A threadId is written onto a single agent, but an agent resolved by agentId alone is shared, so scoping a thread to it would clobber other useAgent callers. Pass a distinct local \`agentId\` and the runtime agent to route to, e.g. useAgent({ agentId: "chat-1", runtimeAgentId: "${agentId ?? "default"}", threadId }).`);
|
|
4887
4892
|
if (runtimeAgentId != null && threadId == null) throw new Error(`useAgent: \`runtimeAgentId\` requires \`threadId\`. A proxied agent exists to scope a thread to a private instance; without a threadId it behaves like the shared agent while adding a registration and a local agentId to keep unique. Either pass the thread, e.g. useAgent({ agentId: "${agentId ?? "chat-1"}", runtimeAgentId: "${runtimeAgentId}", threadId }), or bind to the agent directly with useAgent({ agentId: "${runtimeAgentId}" }).`);
|
|
@@ -5008,7 +5013,7 @@ function useAgent({ agentId, threadId, runtimeAgentId, updates, throttleMs } = {
|
|
|
5008
5013
|
copilotkit.runtimeUrl,
|
|
5009
5014
|
copilotkit.runtimeTransport,
|
|
5010
5015
|
copilotkit.credentials,
|
|
5011
|
-
|
|
5016
|
+
copilotkit.ɵheadersGeneration
|
|
5012
5017
|
]);
|
|
5013
5018
|
(0, react.useEffect)(() => {
|
|
5014
5019
|
if (updateFlags.length === 0) return;
|
|
@@ -5051,7 +5056,7 @@ function useAgent({ agentId, threadId, runtimeAgentId, updates, throttleMs } = {
|
|
|
5051
5056
|
if (agent instanceof _copilotkit_core.ProxiedCopilotRuntimeAgent) agent.credentials = copilotkit.credentials;
|
|
5052
5057
|
}, [
|
|
5053
5058
|
agent,
|
|
5054
|
-
|
|
5059
|
+
copilotkit.ɵheadersGeneration,
|
|
5055
5060
|
copilotkit.credentials
|
|
5056
5061
|
]);
|
|
5057
5062
|
const configThreadId = chatConfig?.threadId;
|
|
@@ -6498,9 +6503,14 @@ function getToolCallLayouts(rendered, all, renderers) {
|
|
|
6498
6503
|
}
|
|
6499
6504
|
/**
|
|
6500
6505
|
* Finds the working phase of every reply in `rendered`: its messages up to the
|
|
6501
|
-
* last one that calls a tool
|
|
6506
|
+
* last one that calls a tool, plus the thinking and the silent messages that
|
|
6507
|
+
* trail it. Text in there was narration; the first text after the work is the
|
|
6502
6508
|
* reply itself. Replies that called no tools are omitted, except the latest,
|
|
6503
6509
|
* which may be about to.
|
|
6510
|
+
*
|
|
6511
|
+
* The trailing part matters: an agent that thinks once more after its last
|
|
6512
|
+
* tool call would otherwise leave those "Thought for 2 seconds" lines outside
|
|
6513
|
+
* the work, where nothing ever folds them away.
|
|
6504
6514
|
*/
|
|
6505
6515
|
function getTurnWork(rendered, layouts) {
|
|
6506
6516
|
const turns = /* @__PURE__ */ new Map();
|
|
@@ -6519,6 +6529,13 @@ function getTurnWork(rendered, layouts) {
|
|
|
6519
6529
|
visible.forEach((message, index) => {
|
|
6520
6530
|
if (message.role === "assistant" && message.toolCalls?.some((call) => shown.has(call.id))) lastWork = index;
|
|
6521
6531
|
});
|
|
6532
|
+
let workEnd = lastWork;
|
|
6533
|
+
for (let index = lastWork + 1; lastWork >= 0 && index < visible.length; index++) {
|
|
6534
|
+
const message = visible[index];
|
|
6535
|
+
const content = message.content;
|
|
6536
|
+
if (message.role === "assistant" && typeof content === "string" && content.trim()) break;
|
|
6537
|
+
workEnd = index;
|
|
6538
|
+
}
|
|
6522
6539
|
const first = visible[0];
|
|
6523
6540
|
if (first && (calls.length > 0 || isLatest)) {
|
|
6524
6541
|
let lastAssistant = -1;
|
|
@@ -6526,11 +6543,13 @@ function getTurnWork(rendered, layouts) {
|
|
|
6526
6543
|
if (message.role === "assistant") lastAssistant = index;
|
|
6527
6544
|
});
|
|
6528
6545
|
const replyText = visible[lastAssistant]?.content;
|
|
6529
|
-
const endsWithWork = lastAssistant >= 0 && lastAssistant <=
|
|
6546
|
+
const endsWithWork = lastAssistant >= 0 && lastAssistant <= workEnd && typeof replyText === "string" && replyText.trim().length > 0;
|
|
6547
|
+
const work = visible.slice(0, workEnd + 1);
|
|
6530
6548
|
turns.set(key, {
|
|
6531
6549
|
key,
|
|
6532
6550
|
firstMessageId: first.id,
|
|
6533
|
-
workMessageIds: new Set(
|
|
6551
|
+
workMessageIds: new Set(work.map((message) => message.id)),
|
|
6552
|
+
reasoningIds: work.filter((message) => message.role === "reasoning").map((message) => message.id),
|
|
6534
6553
|
replyTextMessageId: endsWithWork ? visible[lastAssistant].id : void 0,
|
|
6535
6554
|
calls,
|
|
6536
6555
|
isLatest
|
|
@@ -8145,7 +8164,7 @@ function CopilotChatReasoningMessage({ message, messages, isRunning, isLatest: i
|
|
|
8145
8164
|
...headerProps,
|
|
8146
8165
|
children: [
|
|
8147
8166
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
8148
|
-
className: "cpk:font-medium",
|
|
8167
|
+
className: (0, tailwind_merge.twMerge)("cpk:font-medium", isStreaming && "cpk-shimmer"),
|
|
8149
8168
|
children: label
|
|
8150
8169
|
}),
|
|
8151
8170
|
isStreaming && !hasContent && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
@@ -8871,6 +8890,7 @@ function messageGroup(group) {
|
|
|
8871
8890
|
};
|
|
8872
8891
|
}
|
|
8873
8892
|
const GROUP_ROW_KEY_PREFIX = "copilotkit-group:";
|
|
8893
|
+
const MESSAGE_ROW_KEY_PREFIX = "copilotkit-message:";
|
|
8874
8894
|
const VIRTUALIZE_THRESHOLD = 50;
|
|
8875
8895
|
function CopilotChatMessageView({ messages = [], assistantMessage, userMessage, reasoningMessage, cursor, intelligenceIndicator, workSummary, isRunning = false, transformMessages, groupMessages, messageFeedback = true, toolCallDisplay = "grouped", children, className, ...props }) {
|
|
8876
8896
|
const isPinnedToBottom = (0, react.useContext)(ScrollPinnedContext);
|
|
@@ -8975,6 +8995,17 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
|
|
|
8975
8995
|
isRunning,
|
|
8976
8996
|
latestTurnKey
|
|
8977
8997
|
]);
|
|
8998
|
+
const supersededReasoning = (0, react.useMemo)(() => {
|
|
8999
|
+
const ids = /* @__PURE__ */ new Set();
|
|
9000
|
+
if (!isRunning) return ids;
|
|
9001
|
+
const turn = turnWork?.get(latestTurnKey);
|
|
9002
|
+
for (const id of turn?.reasoningIds.slice(0, -1) ?? []) ids.add(id);
|
|
9003
|
+
return ids;
|
|
9004
|
+
}, [
|
|
9005
|
+
turnWork,
|
|
9006
|
+
latestTurnKey,
|
|
9007
|
+
isRunning
|
|
9008
|
+
]);
|
|
8978
9009
|
const toolCallDisplayContext = (0, react.useMemo)(() => ({
|
|
8979
9010
|
display: toolCallDisplay,
|
|
8980
9011
|
isRunning,
|
|
@@ -9044,6 +9075,14 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
|
|
|
9044
9075
|
(0, _copilotkit_shared.commitRowKeyStore)(rowKeyStore, renderedMessages);
|
|
9045
9076
|
}, [rowKeyStore, renderedMessages]);
|
|
9046
9077
|
const stableGroupKey = (key) => rowRenderKeys.get(key) ?? key;
|
|
9078
|
+
const rowKey = (row) => row.type === "group" ? `${GROUP_ROW_KEY_PREFIX}${stableGroupKey(row.key)}` : `${MESSAGE_ROW_KEY_PREFIX}${rowRenderKeys.get(row.message.id) ?? row.message.id}`;
|
|
9079
|
+
const previousRowKeysRef = (0, react.useRef)([]);
|
|
9080
|
+
const rowKeys = (0, react.useMemo)(() => {
|
|
9081
|
+
const next = rows.map(rowKey);
|
|
9082
|
+
const previous = previousRowKeysRef.current;
|
|
9083
|
+
return next.length === previous.length && next.every((key, index) => key === previous[index]) ? previous : next;
|
|
9084
|
+
}, [rows, rowRenderKeys]);
|
|
9085
|
+
previousRowKeysRef.current = rowKeys;
|
|
9047
9086
|
const groupStateRef = (0, react.useRef)(/* @__PURE__ */ new Map());
|
|
9048
9087
|
const groupSettersRef = (0, react.useRef)(/* @__PURE__ */ new Map());
|
|
9049
9088
|
const groupStateThreadRef = (0, react.useRef)(config?.threadId);
|
|
@@ -9129,6 +9168,8 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
|
|
|
9129
9168
|
total: 0,
|
|
9130
9169
|
sizes: /* @__PURE__ */ new Map()
|
|
9131
9170
|
});
|
|
9171
|
+
const rowKeysRef = react.default.useRef(rowKeys);
|
|
9172
|
+
rowKeysRef.current = rowKeys;
|
|
9132
9173
|
const resizeAnchorRef = react.default.useRef(null);
|
|
9133
9174
|
const restoringVisibilityRef = react.default.useRef(false);
|
|
9134
9175
|
const firstMessageId = deduplicatedMessages[0]?.id;
|
|
@@ -9141,10 +9182,21 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
|
|
|
9141
9182
|
sizes: /* @__PURE__ */ new Map()
|
|
9142
9183
|
};
|
|
9143
9184
|
}
|
|
9185
|
+
const measuredKeysRef = react.default.useRef(rowKeys);
|
|
9186
|
+
if (measuredKeysRef.current !== rowKeys) {
|
|
9187
|
+
measuredKeysRef.current = rowKeys;
|
|
9188
|
+
const live = new Set(rowKeys);
|
|
9189
|
+
const measured = measuredRef.current;
|
|
9190
|
+
for (const [key, height] of measured.sizes) if (!live.has(key)) {
|
|
9191
|
+
measured.sizes.delete(key);
|
|
9192
|
+
measured.total -= height;
|
|
9193
|
+
}
|
|
9194
|
+
}
|
|
9144
9195
|
const estimateRowSize = react.default.useCallback(() => {
|
|
9145
9196
|
const { total, sizes } = measuredRef.current;
|
|
9146
9197
|
return sizes.size > 0 ? Math.max(1, Math.round(total / sizes.size)) : 100;
|
|
9147
9198
|
}, []);
|
|
9199
|
+
const getRowKey = react.default.useCallback((index) => rowKeys[index] ?? index, [rowKeys]);
|
|
9148
9200
|
const isPinnedToBottomRef = react.default.useRef(isPinnedToBottom);
|
|
9149
9201
|
const measuredWidthRef = react.default.useRef(null);
|
|
9150
9202
|
const captureResizeAnchor = react.default.useCallback((instance) => {
|
|
@@ -9169,12 +9221,13 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
|
|
|
9169
9221
|
captureResizeAnchor(instance);
|
|
9170
9222
|
const height = el?.getBoundingClientRect().height ?? 0;
|
|
9171
9223
|
const index = Number(el?.dataset?.index);
|
|
9172
|
-
|
|
9224
|
+
const key = Number.isInteger(index) ? rowKeysRef.current[index] : void 0;
|
|
9225
|
+
if (height > 0 && key !== void 0) {
|
|
9173
9226
|
const { total, sizes } = measuredRef.current;
|
|
9174
|
-
measuredRef.current.total = total - (sizes.get(
|
|
9175
|
-
sizes.set(
|
|
9227
|
+
measuredRef.current.total = total - (sizes.get(key) ?? 0) + height;
|
|
9228
|
+
sizes.set(key, height);
|
|
9176
9229
|
}
|
|
9177
|
-
return height > 0 ? height : measuredRef.current.sizes.get(
|
|
9230
|
+
return height > 0 ? height : (key === void 0 ? void 0 : measuredRef.current.sizes.get(key)) ?? 100;
|
|
9178
9231
|
}, [captureResizeAnchor]);
|
|
9179
9232
|
const shouldAdjustScrollOnResize = react.default.useCallback((item, _delta, instance) => {
|
|
9180
9233
|
if (isPinnedToBottomRef.current || resizeAnchorRef.current || restoringVisibilityRef.current) return false;
|
|
@@ -9240,6 +9293,7 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
|
|
|
9240
9293
|
getScrollElement: () => shouldVirtualize ? scrollElement : null,
|
|
9241
9294
|
observeElementRect: observeScrollRect,
|
|
9242
9295
|
estimateSize: estimateRowSize,
|
|
9296
|
+
getItemKey: getRowKey,
|
|
9243
9297
|
overscan: 5,
|
|
9244
9298
|
measureElement: measureRowElement,
|
|
9245
9299
|
initialRect: {
|
|
@@ -9309,7 +9363,7 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
|
|
|
9309
9363
|
slotProps: reasoningSlotProps
|
|
9310
9364
|
}, rowKey);
|
|
9311
9365
|
elements.push(toolCallDisplay === "turn" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Collapsible, {
|
|
9312
|
-
open: workOpen.get(message.id) ?? true,
|
|
9366
|
+
open: (workOpen.get(message.id) ?? true) && !supersededReasoning.has(message.id),
|
|
9313
9367
|
children: reasoning
|
|
9314
9368
|
}, rowKey) : reasoning);
|
|
9315
9369
|
}
|
|
@@ -9327,7 +9381,6 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
|
|
|
9327
9381
|
}, `intelligence-${intelligenceTurnId}`));
|
|
9328
9382
|
return elements.filter(Boolean);
|
|
9329
9383
|
};
|
|
9330
|
-
const rowKey = (row) => row.type === "group" ? `${GROUP_ROW_KEY_PREFIX}${stableGroupKey(row.key)}` : rowRenderKeys.get(row.message.id) ?? row.message.id;
|
|
9331
9384
|
const renderRow = (row) => {
|
|
9332
9385
|
if (row.type === "message") return renderMessageBlock(row.message);
|
|
9333
9386
|
const Wrapper = row.wrapper;
|
|
@@ -9340,8 +9393,6 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
|
|
|
9340
9393
|
children: row.messages.flatMap(renderMessageBlock)
|
|
9341
9394
|
}, rowKey(row))];
|
|
9342
9395
|
};
|
|
9343
|
-
const rowKeysRef = (0, react.useRef)([]);
|
|
9344
|
-
rowKeysRef.current = rows.map(rowKey);
|
|
9345
9396
|
const virtualModeRef = (0, react.useRef)(shouldVirtualize);
|
|
9346
9397
|
virtualModeRef.current = shouldVirtualize;
|
|
9347
9398
|
(0, react.useEffect)(() => {
|
|
@@ -14993,4 +15044,4 @@ Object.defineProperty(exports, 'useToast', {
|
|
|
14993
15044
|
return useToast;
|
|
14994
15045
|
}
|
|
14995
15046
|
});
|
|
14996
|
-
//# sourceMappingURL=copilotkit-
|
|
15047
|
+
//# sourceMappingURL=copilotkit-D4AAgBT1.cjs.map
|