@copilotkit/react-core 1.73.3 → 1.75.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-CfyJ1-Nx.d.mts → copilotkit-CGlSOKHM.d.mts} +38 -2
- package/dist/copilotkit-CGlSOKHM.d.mts.map +1 -0
- package/dist/{copilotkit-C7c_w9iV.d.cts → copilotkit-Cjj9wDI8.d.cts} +38 -2
- package/dist/copilotkit-Cjj9wDI8.d.cts.map +1 -0
- package/dist/{copilotkit-CwVE-0JG.mjs → copilotkit-CoWG8EAX.mjs} +169 -63
- package/dist/copilotkit-CoWG8EAX.mjs.map +1 -0
- package/dist/{copilotkit-D_c2dJ9t.cjs → copilotkit-D2emzYuj.cjs} +169 -63
- package/dist/copilotkit-D2emzYuj.cjs.map +1 -0
- 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 +10 -2
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/index.cjs +1 -1
- package/dist/v2/index.d.cts +1 -1
- package/dist/v2/index.d.mts +1 -1
- package/dist/v2/index.mjs +1 -1
- package/dist/v2/index.umd.js +168 -62
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +9 -9
- package/dist/copilotkit-C7c_w9iV.d.cts.map +0 -1
- package/dist/copilotkit-CfyJ1-Nx.d.mts.map +0 -1
- package/dist/copilotkit-CwVE-0JG.mjs.map +0 -1
- package/dist/copilotkit-D_c2dJ9t.cjs.map +0 -1
|
@@ -1603,6 +1603,10 @@ function useRenderToolCall() {
|
|
|
1603
1603
|
return renderToolCall;
|
|
1604
1604
|
}
|
|
1605
1605
|
|
|
1606
|
+
//#endregion
|
|
1607
|
+
//#region package.json
|
|
1608
|
+
var version = "1.75.0";
|
|
1609
|
+
|
|
1606
1610
|
//#endregion
|
|
1607
1611
|
//#region src/v2/components/CopilotKitInspector.tsx
|
|
1608
1612
|
const CopilotKitInspector = ({ core, openRequest, onVisibilityChange }) => {
|
|
@@ -1625,7 +1629,11 @@ const CopilotKitInspector = ({ core, openRequest, onVisibilityChange }) => {
|
|
|
1625
1629
|
if (!mounted || !mountRef.current) return;
|
|
1626
1630
|
mod.defineWebInspector?.();
|
|
1627
1631
|
inspector = mountRef.current.ownerDocument.createElement(mod.WEB_INSPECTOR_TAG);
|
|
1628
|
-
mod.configureWebInspectorElement(inspector, latestCoreRef.current
|
|
1632
|
+
mod.configureWebInspectorElement(inspector, latestCoreRef.current, {
|
|
1633
|
+
development: process.env.NODE_ENV === "development",
|
|
1634
|
+
framework: "react",
|
|
1635
|
+
sdkVersion: version
|
|
1636
|
+
});
|
|
1629
1637
|
inspector.addEventListener("cpk-inspector-visibility-change", handleVisibilityChange);
|
|
1630
1638
|
mountRef.current.appendChild(inspector);
|
|
1631
1639
|
inspectorRef.current = inspector;
|
|
@@ -3830,8 +3838,8 @@ function useRenderCustomMessages() {
|
|
|
3830
3838
|
if (aHasAgent === (b.agentId !== void 0)) return 0;
|
|
3831
3839
|
return aHasAgent ? -1 : 1;
|
|
3832
3840
|
});
|
|
3841
|
+
if (!customMessageRenderers.length) return null;
|
|
3833
3842
|
return function(params) {
|
|
3834
|
-
if (!customMessageRenderers.length) return null;
|
|
3835
3843
|
const { message, position } = params;
|
|
3836
3844
|
const resolvedRunId = copilotkit.getRunIdForMessage(agentId, threadId, message.id) ?? copilotkit.getRunIdsForThread(agentId, threadId).slice(-1)[0];
|
|
3837
3845
|
const runId = resolvedRunId ?? `missing-run-id:${message.id}`;
|
|
@@ -6326,7 +6334,7 @@ function BoundInspectorButton({ inspectorButton, messageId, openInspector, ...pr
|
|
|
6326
6334
|
})
|
|
6327
6335
|
});
|
|
6328
6336
|
}
|
|
6329
|
-
function CopilotChatAssistantMessage({ message, messages, isRunning, onThumbsUp, onThumbsDown, onReadAloud, onRegenerate, additionalToolbarItems, toolbarVisible = true, markdownRenderer, toolbar, copyButton, inspectorButton, thumbsUpButton, thumbsDownButton, readAloudButton, regenerateButton, toolCallsView, children, className, ...props }) {
|
|
6337
|
+
function CopilotChatAssistantMessage({ message, messages, isRunning, isLatest, onThumbsUp, onThumbsDown, onReadAloud, onRegenerate, additionalToolbarItems, toolbarVisible = true, markdownRenderer, toolbar, copyButton, inspectorButton, thumbsUpButton, thumbsDownButton, readAloudButton, regenerateButton, toolCallsView, children, className, ...props }) {
|
|
6330
6338
|
useKatexStyles();
|
|
6331
6339
|
const { isInspectorEnabled, openInspector } = useCopilotKitInspector();
|
|
6332
6340
|
const shortcutsHidden = useInspectorShortcutsHidden();
|
|
@@ -6362,7 +6370,7 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, onThumbsUp,
|
|
|
6362
6370
|
messages
|
|
6363
6371
|
});
|
|
6364
6372
|
const hasContent = !!(message.content && message.content.trim().length > 0);
|
|
6365
|
-
const isLatestAssistantMessage = message.role === "assistant" && messages?.[messages.length - 1]?.id === message.id;
|
|
6373
|
+
const isLatestAssistantMessage = message.role === "assistant" && (isLatest ?? messages?.[messages.length - 1]?.id === message.id);
|
|
6366
6374
|
const shouldShowToolbar = toolbarVisible && (hasContent || showInspectorShortcut) && !(isRunning && isLatestAssistantMessage);
|
|
6367
6375
|
if (children) return /* @__PURE__ */ jsx("div", {
|
|
6368
6376
|
"data-copilotkit": true,
|
|
@@ -6876,8 +6884,8 @@ function formatDuration(seconds) {
|
|
|
6876
6884
|
if (secs === 0) return `${mins} minute${mins > 1 ? "s" : ""}`;
|
|
6877
6885
|
return `${mins}m ${secs}s`;
|
|
6878
6886
|
}
|
|
6879
|
-
function CopilotChatReasoningMessage({ message, messages, isRunning, header, contentView, toggle, children, className, ...props }) {
|
|
6880
|
-
const isLatest = messages?.[messages.length - 1]?.id === message.id;
|
|
6887
|
+
function CopilotChatReasoningMessage({ message, messages, isRunning, isLatest: isLatestProp, header, contentView, toggle, children, className, ...props }) {
|
|
6888
|
+
const isLatest = isLatestProp ?? messages?.[messages.length - 1]?.id === message.id;
|
|
6881
6889
|
const isStreaming = !!(isRunning && isLatest);
|
|
6882
6890
|
const hasContent = !!(message.content && message.content.length > 0);
|
|
6883
6891
|
const startTimeRef = useRef(null);
|
|
@@ -7102,6 +7110,32 @@ CopilotChatSuggestionView.displayName = "CopilotChatSuggestionView";
|
|
|
7102
7110
|
*/
|
|
7103
7111
|
const ScrollElementContext = React.createContext(null);
|
|
7104
7112
|
|
|
7113
|
+
//#endregion
|
|
7114
|
+
//#region src/v2/components/chat/scroll-pinned-context.ts
|
|
7115
|
+
/**
|
|
7116
|
+
* True while the pin-to-bottom behaviour is actively following the bottom of
|
|
7117
|
+
* the thread — i.e. `use-stick-to-bottom` will animate the scroll position to
|
|
7118
|
+
* the bottom the next time the content grows.
|
|
7119
|
+
*
|
|
7120
|
+
* Only CopilotChatView's pin-to-bottom branch provides this. The other scroll
|
|
7121
|
+
* modes leave it `false`, which is correct: nothing else writes the scroll
|
|
7122
|
+
* position on its own, so no one is competing with the virtualizer.
|
|
7123
|
+
*
|
|
7124
|
+
* Why this exists: the virtualizer and `use-stick-to-bottom` both write
|
|
7125
|
+
* `scrollTop` on the same element. The virtualizer writes it to compensate
|
|
7126
|
+
* when a row above the viewport turns out taller than its estimate, so that
|
|
7127
|
+
* what the reader is looking at does not shift. That compensation is essential
|
|
7128
|
+
* while the reader is scrolled up — and pointless while pinned to the bottom,
|
|
7129
|
+
* because the pin is about to move the scroll position anyway. Worse than
|
|
7130
|
+
* pointless: the compensation changes the virtual container's height, the pin
|
|
7131
|
+
* reads that as content growth and animates, the animation brings unmeasured
|
|
7132
|
+
* rows into view, they measure, and the two keep shoving each other.
|
|
7133
|
+
*
|
|
7134
|
+
* Consumed by CopilotChatMessageView to stand the virtualizer down while the
|
|
7135
|
+
* pin owns the scroll position.
|
|
7136
|
+
*/
|
|
7137
|
+
const ScrollPinnedContext = React.createContext(false);
|
|
7138
|
+
|
|
7105
7139
|
//#endregion
|
|
7106
7140
|
//#region src/v2/components/intelligence-indicator/IntelligenceIndicatorView.tsx
|
|
7107
7141
|
/**
|
|
@@ -7246,24 +7280,31 @@ const INTELLIGENCE_TURN_HEAD = "__cpk_turn_head__";
|
|
|
7246
7280
|
* emits exactly one `IntelligenceIndicator` per entry, keyed by the turn id and
|
|
7247
7281
|
* positioned at the anchor; the per-turn key also lets every past turn keep its
|
|
7248
7282
|
* own indicator in scroll-back.
|
|
7283
|
+
*
|
|
7284
|
+
* `visibleMessages` is what actually renders, when that differs from
|
|
7285
|
+
* `messages` (the chat's `transformMessages`). Turns are still read from the
|
|
7286
|
+
* full list, so hiding a user message does not merge its turn into the one
|
|
7287
|
+
* before it, and anchors are only chosen among visible messages. A message the
|
|
7288
|
+
* transform built itself joins the turn of the visible message before it.
|
|
7249
7289
|
*/
|
|
7250
|
-
function getIntelligenceTurnAnchors(messages) {
|
|
7251
|
-
const
|
|
7290
|
+
function getIntelligenceTurnAnchors(messages, visibleMessages = messages) {
|
|
7291
|
+
const turnOfMessage = /* @__PURE__ */ new Map();
|
|
7252
7292
|
let turnId = INTELLIGENCE_TURN_HEAD;
|
|
7253
|
-
let anchorId = null;
|
|
7254
|
-
const commit = () => {
|
|
7255
|
-
if (anchorId !== null) anchors.set(anchorId, turnId);
|
|
7256
|
-
anchorId = null;
|
|
7257
|
-
};
|
|
7258
7293
|
for (const m of messages) {
|
|
7259
|
-
if (m.role === "user")
|
|
7260
|
-
|
|
7261
|
-
|
|
7262
|
-
|
|
7294
|
+
if (m.role === "user") turnId = m.id;
|
|
7295
|
+
turnOfMessage.set(m.id, turnId);
|
|
7296
|
+
}
|
|
7297
|
+
const anchors = /* @__PURE__ */ new Map();
|
|
7298
|
+
const anchoredTurns = /* @__PURE__ */ new Set();
|
|
7299
|
+
let currentTurn = INTELLIGENCE_TURN_HEAD;
|
|
7300
|
+
for (const m of visibleMessages) {
|
|
7301
|
+
currentTurn = turnOfMessage.get(m.id) ?? currentTurn;
|
|
7302
|
+
if (m.role === "user") continue;
|
|
7303
|
+
if (!anchoredTurns.has(currentTurn) && messageHasMatchingToolCall(m)) {
|
|
7304
|
+
anchors.set(m.id, currentTurn);
|
|
7305
|
+
anchoredTurns.add(currentTurn);
|
|
7263
7306
|
}
|
|
7264
|
-
if (anchorId === null && messageHasMatchingToolCall(m)) anchorId = m.id;
|
|
7265
7307
|
}
|
|
7266
|
-
commit();
|
|
7267
7308
|
return anchors;
|
|
7268
7309
|
}
|
|
7269
7310
|
/**
|
|
@@ -7409,11 +7450,12 @@ function resolveSlotComponent(slot, DefaultComponent) {
|
|
|
7409
7450
|
/**
|
|
7410
7451
|
* Memoized wrapper for assistant messages to prevent re-renders when other messages change.
|
|
7411
7452
|
*/
|
|
7412
|
-
const MemoizedAssistantMessage = React.memo(function MemoizedAssistantMessage({ message, messages, isRunning, AssistantMessageComponent, slotProps }) {
|
|
7453
|
+
const MemoizedAssistantMessage = React.memo(function MemoizedAssistantMessage({ message, messages, isRunning, isLatest, AssistantMessageComponent, slotProps }) {
|
|
7413
7454
|
return /* @__PURE__ */ jsx(AssistantMessageComponent, {
|
|
7414
7455
|
message,
|
|
7415
7456
|
messages,
|
|
7416
7457
|
isRunning,
|
|
7458
|
+
isLatest,
|
|
7417
7459
|
...slotProps
|
|
7418
7460
|
});
|
|
7419
7461
|
}, (prevProps, nextProps) => {
|
|
@@ -7435,7 +7477,7 @@ const MemoizedAssistantMessage = React.memo(function MemoizedAssistantMessage({
|
|
|
7435
7477
|
if (prevToolResults.length !== nextToolResults.length) return false;
|
|
7436
7478
|
for (let i = 0; i < prevToolResults.length; i++) if (prevToolResults[i].content !== nextToolResults[i].content) return false;
|
|
7437
7479
|
}
|
|
7438
|
-
if (
|
|
7480
|
+
if ((prevProps.isRunning && prevProps.isLatest) !== (nextProps.isRunning && nextProps.isLatest)) return false;
|
|
7439
7481
|
if (prevProps.AssistantMessageComponent !== nextProps.AssistantMessageComponent) return false;
|
|
7440
7482
|
if (prevProps.slotProps !== nextProps.slotProps) return false;
|
|
7441
7483
|
return true;
|
|
@@ -7469,20 +7511,19 @@ const MemoizedActivityMessage = React.memo(function MemoizedActivityMessage({ me
|
|
|
7469
7511
|
/**
|
|
7470
7512
|
* Memoized wrapper for reasoning messages to prevent re-renders when other messages change.
|
|
7471
7513
|
*/
|
|
7472
|
-
const MemoizedReasoningMessage = React.memo(function MemoizedReasoningMessage({ message, messages, isRunning, ReasoningMessageComponent, slotProps }) {
|
|
7514
|
+
const MemoizedReasoningMessage = React.memo(function MemoizedReasoningMessage({ message, messages, isRunning, isLatest, ReasoningMessageComponent, slotProps }) {
|
|
7473
7515
|
return /* @__PURE__ */ jsx(ReasoningMessageComponent, {
|
|
7474
7516
|
message,
|
|
7475
7517
|
messages,
|
|
7476
7518
|
isRunning,
|
|
7519
|
+
isLatest,
|
|
7477
7520
|
...slotProps
|
|
7478
7521
|
});
|
|
7479
7522
|
}, (prevProps, nextProps) => {
|
|
7480
7523
|
if (prevProps.message.id !== nextProps.message.id) return false;
|
|
7481
7524
|
if (prevProps.message.content !== nextProps.message.content) return false;
|
|
7482
|
-
|
|
7483
|
-
|
|
7484
|
-
if (prevIsLatest !== nextIsLatest) return false;
|
|
7485
|
-
if (nextIsLatest && prevProps.isRunning !== nextProps.isRunning) return false;
|
|
7525
|
+
if (prevProps.isLatest !== nextProps.isLatest) return false;
|
|
7526
|
+
if (nextProps.isLatest && prevProps.isRunning !== nextProps.isRunning) return false;
|
|
7486
7527
|
if (prevProps.ReasoningMessageComponent !== nextProps.ReasoningMessageComponent) return false;
|
|
7487
7528
|
if (prevProps.slotProps !== nextProps.slotProps) return false;
|
|
7488
7529
|
return true;
|
|
@@ -7566,7 +7607,8 @@ function deduplicateMessages(messages) {
|
|
|
7566
7607
|
return [...acc.values()];
|
|
7567
7608
|
}
|
|
7568
7609
|
const VIRTUALIZE_THRESHOLD = 50;
|
|
7569
|
-
function CopilotChatMessageView({ messages = [], assistantMessage, userMessage, reasoningMessage, cursor, intelligenceIndicator, isRunning = false, children, className, ...props }) {
|
|
7610
|
+
function CopilotChatMessageView({ messages = [], assistantMessage, userMessage, reasoningMessage, cursor, intelligenceIndicator, isRunning = false, transformMessages, children, className, ...props }) {
|
|
7611
|
+
const isPinnedToBottom = useContext(ScrollPinnedContext);
|
|
7570
7612
|
const renderCustomMessage = useRenderCustomMessages();
|
|
7571
7613
|
const { renderActivityMessage } = useRenderActivityMessage();
|
|
7572
7614
|
const { copilotkit } = useCopilotKit$1();
|
|
@@ -7598,13 +7640,27 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
|
|
|
7598
7640
|
return copilotkit.getStateByRun(config.agentId, config.threadId, resolvedRunId);
|
|
7599
7641
|
};
|
|
7600
7642
|
const deduplicatedMessages = useMemo(() => deduplicateMessages(messages), [messages]);
|
|
7643
|
+
const renderedMessages = useMemo(() => transformMessages ? transformMessages(deduplicatedMessages) : deduplicatedMessages, [deduplicatedMessages, transformMessages]);
|
|
7644
|
+
const latestRenderedId = renderedMessages[renderedMessages.length - 1]?.id;
|
|
7645
|
+
const transformDuplicateId = useMemo(() => {
|
|
7646
|
+
if (process.env.NODE_ENV === "production" || !transformMessages) return;
|
|
7647
|
+
const seen = /* @__PURE__ */ new Set();
|
|
7648
|
+
for (const message of renderedMessages) {
|
|
7649
|
+
if (seen.has(message.id)) return message.id;
|
|
7650
|
+
seen.add(message.id);
|
|
7651
|
+
}
|
|
7652
|
+
}, [renderedMessages, transformMessages]);
|
|
7653
|
+
useEffect(() => {
|
|
7654
|
+
if (transformDuplicateId === void 0) return;
|
|
7655
|
+
console.warn(`[CopilotKit] CopilotChatMessageView: \`transformMessages\` returned more than one message with id "${transformDuplicateId}". Return each id at most once; a message you create needs its own id, stable across renders.`);
|
|
7656
|
+
}, [transformDuplicateId]);
|
|
7601
7657
|
const rowKeyStoreRef = useRef(null);
|
|
7602
7658
|
rowKeyStoreRef.current ??= createRowKeyStore();
|
|
7603
7659
|
const rowKeyStore = rowKeyStoreRef.current;
|
|
7604
|
-
const rowRenderKeys = useMemo(() => resolveRowRenderKeysById(rowKeyStore,
|
|
7660
|
+
const rowRenderKeys = useMemo(() => resolveRowRenderKeysById(rowKeyStore, renderedMessages), [rowKeyStore, renderedMessages]);
|
|
7605
7661
|
useLayoutEffect(() => {
|
|
7606
|
-
commitRowKeyStore(rowKeyStore,
|
|
7607
|
-
}, [rowKeyStore,
|
|
7662
|
+
commitRowKeyStore(rowKeyStore, renderedMessages);
|
|
7663
|
+
}, [rowKeyStore, renderedMessages]);
|
|
7608
7664
|
if (process.env.NODE_ENV === "development" && deduplicatedMessages.length < messages.length) console.warn(`CopilotChatMessageView: Merged ${messages.length - deduplicatedMessages.length} message(s) with duplicate IDs.`);
|
|
7609
7665
|
const { Component: AssistantComponent, slotProps: assistantSlotProps } = useMemo(() => resolveSlotComponent(assistantMessage, CopilotChatAssistantMessage_default), [assistantMessage]);
|
|
7610
7666
|
const agentId = config?.agentId;
|
|
@@ -7638,27 +7694,72 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
|
|
|
7638
7694
|
useEffect(() => {
|
|
7639
7695
|
if (process.env.NODE_ENV !== "production" && scrollElementFromCtx && scrollElementFromCtx.clientHeight === 0) console.warn("[CopilotKit] Chat scroll container has clientHeight=0 — virtualization disabled. Ensure the chat is rendered in a visible container with a non-zero height.");
|
|
7640
7696
|
}, [scrollElementFromCtx]);
|
|
7641
|
-
const shouldVirtualize = !!scrollElement && !children &&
|
|
7697
|
+
const shouldVirtualize = !!scrollElement && !children && renderedMessages.length > VIRTUALIZE_THRESHOLD;
|
|
7698
|
+
const childrenDisabledVirtualization = !!children && !!scrollElement && renderedMessages.length > VIRTUALIZE_THRESHOLD;
|
|
7699
|
+
const warnedChildrenRef = useRef(false);
|
|
7700
|
+
useEffect(() => {
|
|
7701
|
+
if (process.env.NODE_ENV === "production" || !childrenDisabledVirtualization || warnedChildrenRef.current) return;
|
|
7702
|
+
warnedChildrenRef.current = true;
|
|
7703
|
+
console.warn(`[CopilotKit] CopilotChatMessageView: the \`children\` render prop disables virtualization, so all ${renderedMessages.length} messages are mounted. ` + (transformMessages ? "`transformMessages` keeps virtualization on by itself; drop `children` to use it." : "To reshape the list and keep virtualization, use `transformMessages` instead."));
|
|
7704
|
+
}, [
|
|
7705
|
+
childrenDisabledVirtualization,
|
|
7706
|
+
renderedMessages.length,
|
|
7707
|
+
transformMessages
|
|
7708
|
+
]);
|
|
7709
|
+
const measuredRef = React.useRef({
|
|
7710
|
+
total: 0,
|
|
7711
|
+
sizes: /* @__PURE__ */ new Map()
|
|
7712
|
+
});
|
|
7713
|
+
const firstMessageId = deduplicatedMessages[0]?.id;
|
|
7714
|
+
const measuredThreadRef = React.useRef(firstMessageId);
|
|
7715
|
+
if (measuredThreadRef.current !== firstMessageId) {
|
|
7716
|
+
measuredThreadRef.current = firstMessageId;
|
|
7717
|
+
measuredRef.current = {
|
|
7718
|
+
total: 0,
|
|
7719
|
+
sizes: /* @__PURE__ */ new Map()
|
|
7720
|
+
};
|
|
7721
|
+
}
|
|
7722
|
+
const estimateRowSize = React.useCallback(() => {
|
|
7723
|
+
const { total, sizes } = measuredRef.current;
|
|
7724
|
+
return sizes.size > 0 ? Math.max(1, Math.round(total / sizes.size)) : 100;
|
|
7725
|
+
}, []);
|
|
7726
|
+
const measureRowElement = React.useCallback((el) => {
|
|
7727
|
+
const height = el?.getBoundingClientRect().height ?? 0;
|
|
7728
|
+
const index = Number(el?.dataset?.index);
|
|
7729
|
+
if (height > 0 && Number.isInteger(index)) {
|
|
7730
|
+
const { total, sizes } = measuredRef.current;
|
|
7731
|
+
measuredRef.current.total = total - (sizes.get(index) ?? 0) + height;
|
|
7732
|
+
sizes.set(index, height);
|
|
7733
|
+
}
|
|
7734
|
+
return height;
|
|
7735
|
+
}, []);
|
|
7736
|
+
const isPinnedToBottomRef = React.useRef(isPinnedToBottom);
|
|
7737
|
+
const shouldAdjustScrollOnResize = React.useCallback((item, _delta, instance) => {
|
|
7738
|
+
if (isPinnedToBottomRef.current) return false;
|
|
7739
|
+
const scrollAdjustments = instance.scrollAdjustments ?? 0;
|
|
7740
|
+
return item.start < (instance.scrollOffset ?? 0) + scrollAdjustments;
|
|
7741
|
+
}, []);
|
|
7642
7742
|
const virtualizer = useVirtualizer({
|
|
7643
|
-
count: shouldVirtualize ?
|
|
7743
|
+
count: shouldVirtualize ? renderedMessages.length : 0,
|
|
7644
7744
|
getScrollElement: () => scrollElement,
|
|
7645
|
-
estimateSize:
|
|
7745
|
+
estimateSize: estimateRowSize,
|
|
7646
7746
|
overscan: 5,
|
|
7647
|
-
measureElement:
|
|
7747
|
+
measureElement: measureRowElement,
|
|
7648
7748
|
initialRect: {
|
|
7649
7749
|
width: 0,
|
|
7650
7750
|
height: 600
|
|
7651
7751
|
}
|
|
7652
7752
|
});
|
|
7653
|
-
|
|
7753
|
+
isPinnedToBottomRef.current = isPinnedToBottom;
|
|
7754
|
+
virtualizer.shouldAdjustScrollPositionOnItemSizeChange = shouldAdjustScrollOnResize;
|
|
7654
7755
|
useLayoutEffect(() => {
|
|
7655
|
-
if (!shouldVirtualize || !
|
|
7656
|
-
virtualizer.scrollToIndex(
|
|
7756
|
+
if (!shouldVirtualize || !renderedMessages.length) return;
|
|
7757
|
+
virtualizer.scrollToIndex(renderedMessages.length - 1, { align: "end" });
|
|
7657
7758
|
}, [shouldVirtualize, firstMessageId]);
|
|
7658
|
-
const intelligenceTurnAnchors = useMemo(() => getIntelligenceTurnAnchors(deduplicatedMessages), [deduplicatedMessages]);
|
|
7759
|
+
const intelligenceTurnAnchors = useMemo(() => getIntelligenceTurnAnchors(deduplicatedMessages, renderedMessages), [deduplicatedMessages, renderedMessages]);
|
|
7659
7760
|
const renderMessageBlock = (message) => {
|
|
7660
7761
|
const elements = [];
|
|
7661
|
-
const stateSnapshot = getStateSnapshotForMessage(message.id);
|
|
7762
|
+
const stateSnapshot = renderCustomMessage ? getStateSnapshotForMessage(message.id) : void 0;
|
|
7662
7763
|
const rowKey = rowRenderKeys.get(message.id) ?? message.id;
|
|
7663
7764
|
if (renderCustomMessage) elements.push(/* @__PURE__ */ jsx(MemoizedCustomMessage, {
|
|
7664
7765
|
message,
|
|
@@ -7670,6 +7771,7 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
|
|
|
7670
7771
|
message,
|
|
7671
7772
|
messages,
|
|
7672
7773
|
isRunning,
|
|
7774
|
+
isLatest: message.id === latestRenderedId,
|
|
7673
7775
|
AssistantMessageComponent: AssistantComponent,
|
|
7674
7776
|
slotProps: assistantSlotPropsWithFeedback
|
|
7675
7777
|
}, rowKey));
|
|
@@ -7686,6 +7788,7 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
|
|
|
7686
7788
|
message,
|
|
7687
7789
|
messages,
|
|
7688
7790
|
isRunning,
|
|
7791
|
+
isLatest: message.id === latestRenderedId,
|
|
7689
7792
|
ReasoningMessageComponent: ReasoningComponent,
|
|
7690
7793
|
slotProps: reasoningSlotProps
|
|
7691
7794
|
}, rowKey));
|
|
@@ -7703,7 +7806,7 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
|
|
|
7703
7806
|
}, `intelligence-${intelligenceTurnId}`));
|
|
7704
7807
|
return elements.filter(Boolean);
|
|
7705
7808
|
};
|
|
7706
|
-
const messageElements = shouldVirtualize ? [] :
|
|
7809
|
+
const messageElements = shouldVirtualize ? [] : renderedMessages.flatMap(renderMessageBlock);
|
|
7707
7810
|
if (children) return /* @__PURE__ */ jsx("div", {
|
|
7708
7811
|
"data-copilotkit": true,
|
|
7709
7812
|
style: { display: "contents" },
|
|
@@ -7714,7 +7817,7 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
|
|
|
7714
7817
|
interruptElement
|
|
7715
7818
|
})
|
|
7716
7819
|
});
|
|
7717
|
-
const lastMessage =
|
|
7820
|
+
const lastMessage = renderedMessages[renderedMessages.length - 1];
|
|
7718
7821
|
const showCursor = isRunning && lastMessage?.role !== "reasoning";
|
|
7719
7822
|
return /* @__PURE__ */ jsxs("div", {
|
|
7720
7823
|
"data-copilotkit": true,
|
|
@@ -7728,7 +7831,7 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
|
|
|
7728
7831
|
position: "relative"
|
|
7729
7832
|
},
|
|
7730
7833
|
children: virtualizer.getVirtualItems().map((virtualItem) => {
|
|
7731
|
-
const message =
|
|
7834
|
+
const message = renderedMessages[virtualItem.index];
|
|
7732
7835
|
return /* @__PURE__ */ jsx("div", {
|
|
7733
7836
|
"data-index": virtualItem.index,
|
|
7734
7837
|
ref: virtualizer.measureElement,
|
|
@@ -8295,7 +8398,7 @@ function CopilotChatView({ messageView, input, scrollView, suggestionView, welco
|
|
|
8295
8398
|
}
|
|
8296
8399
|
(function(_CopilotChatView) {
|
|
8297
8400
|
const ScrollContent = ({ children, scrollToBottomButton, feather, inputContainerHeight, isResizing }) => {
|
|
8298
|
-
const { isAtBottom, scrollToBottom, scrollRef } = useStickToBottomContext();
|
|
8401
|
+
const { isAtBottom, scrollToBottom, scrollRef, state } = useStickToBottomContext();
|
|
8299
8402
|
const [scrollEl, setScrollEl] = useState(null);
|
|
8300
8403
|
useLayoutEffect(() => {
|
|
8301
8404
|
setScrollEl(scrollRef.current ?? null);
|
|
@@ -8303,25 +8406,28 @@ function CopilotChatView({ messageView, input, scrollView, suggestionView, welco
|
|
|
8303
8406
|
const BoundFeather = renderSlot(feather, CopilotChatView.Feather, {});
|
|
8304
8407
|
return /* @__PURE__ */ jsx(ScrollElementContext.Provider, {
|
|
8305
8408
|
value: scrollEl,
|
|
8306
|
-
children: /* @__PURE__ */
|
|
8307
|
-
|
|
8308
|
-
|
|
8309
|
-
|
|
8310
|
-
|
|
8311
|
-
|
|
8312
|
-
|
|
8313
|
-
|
|
8314
|
-
|
|
8315
|
-
children
|
|
8409
|
+
children: /* @__PURE__ */ jsx(ScrollPinnedContext.Provider, {
|
|
8410
|
+
value: state.isAtBottom,
|
|
8411
|
+
children: /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
8412
|
+
/* @__PURE__ */ jsx(StickToBottom.Content, {
|
|
8413
|
+
className: "cpk:overflow-y-auto cpk:overflow-x-hidden",
|
|
8414
|
+
style: {
|
|
8415
|
+
flex: "1 1 0%",
|
|
8416
|
+
minHeight: 0
|
|
8417
|
+
},
|
|
8418
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
8419
|
+
className: "cpk:px-4 cpk:@3xl:px-0 cpk:[div[data-sidebar-chat]_&]:px-8 cpk:[div[data-popup-chat]_&]:px-6",
|
|
8420
|
+
children
|
|
8421
|
+
})
|
|
8422
|
+
}),
|
|
8423
|
+
BoundFeather,
|
|
8424
|
+
!isAtBottom && !isResizing && /* @__PURE__ */ jsx("div", {
|
|
8425
|
+
className: "cpk:absolute cpk:inset-x-0 cpk:flex cpk:justify-center cpk:z-30 cpk:pointer-events-none",
|
|
8426
|
+
style: { bottom: `${inputContainerHeight + SCROLL_BUTTON_OFFSET}px` },
|
|
8427
|
+
children: renderSlot(scrollToBottomButton, CopilotChatView.ScrollToBottomButton, { onClick: () => scrollToBottom() })
|
|
8316
8428
|
})
|
|
8317
|
-
})
|
|
8318
|
-
|
|
8319
|
-
!isAtBottom && !isResizing && /* @__PURE__ */ jsx("div", {
|
|
8320
|
-
className: "cpk:absolute cpk:inset-x-0 cpk:flex cpk:justify-center cpk:z-30 cpk:pointer-events-none",
|
|
8321
|
-
style: { bottom: `${inputContainerHeight + SCROLL_BUTTON_OFFSET}px` },
|
|
8322
|
-
children: renderSlot(scrollToBottomButton, CopilotChatView.ScrollToBottomButton, { onClick: () => scrollToBottom() })
|
|
8323
|
-
})
|
|
8324
|
-
] })
|
|
8429
|
+
] })
|
|
8430
|
+
})
|
|
8325
8431
|
});
|
|
8326
8432
|
};
|
|
8327
8433
|
const PinToSendScrollContainer = ({ children, scrollRef, contentRef, scrollToBottom, scrollToBottomButton, feather, inputContainerHeight, isResizing, nonAutoScrollEl, nonAutoScrollRefCallback, showScrollButton, className, ...props }) => {
|
|
@@ -10009,7 +10115,7 @@ function CopilotThreadsDrawer({ agentId, onThreadSelect, onNewThread, onLicensed
|
|
|
10009
10115
|
const { status, checkFeature } = useLicenseContext$1();
|
|
10010
10116
|
const licensePresent = status === "valid" || status === "expiring";
|
|
10011
10117
|
const featureLicensed = checkFeature("threads");
|
|
10012
|
-
const licensed = licensePresent && featureLicensed;
|
|
10118
|
+
const licensed = status === "unknown" || licensePresent && featureLicensed;
|
|
10013
10119
|
const licensePending = status === null;
|
|
10014
10120
|
const providerAgentId = useDefaultAgentId();
|
|
10015
10121
|
const resolvedAgentId = agentId ?? configuration?.agentId ?? providerAgentId ?? DEFAULT_AGENT_ID;
|
|
@@ -12476,4 +12582,4 @@ function validateProps(props) {
|
|
|
12476
12582
|
|
|
12477
12583
|
//#endregion
|
|
12478
12584
|
export { useAgentContext as $, ɵisRetryableMemoryStatus as $i, ResumeEntrySchema as $n, compactEvents as $r, BaseMessageSchema as $t, CopilotChatMessageView as A, parseSSEStream as Ai, MemoryError as An, ThinkingEndEventSchema as Ar, CopilotChatInput_default as At, CopilotChatAssistantMessage_default as B, tokenUsageFromLangChainMetadata as Bi, OutputCapabilitiesSchema as Bn, ToolCallSchema as Br, ActivityMessageSchema as Bt, CopilotModalHeader as C, ɵselectThreadsError$1 as Ca, ofType as Ci, InputContentDataSourceSchema as Cn, SuggestionEngine as Cr, useSandboxFunctions as Ct, CopilotChat as D, onInspectorViewThread$1 as Di, IntelligenceAgent as Dn, TextMessageContentEventSchema as Dr, ɵrunMcpFollowUp as Dt, DefaultOpenIcon as E, onInspectorStopViewing$1 as Ei, InputContentUrlSourceSchema as En, TextMessageChunkEventSchema as Er, MCPAppsActivityType as Et, CopilotChatSuggestionView as F, resolveDebugLogger as Fi, MultiAgentCapabilitiesSchema as Fn, TokenUsageSchema as Fr, AGUIConnectNotImplementedError$1 as Ft, useLearnFromUserActionInCurrentThread as G, ɵInterruptState$1 as Gi, ReasoningEncryptedValueSubtypeSchema as Gn, ToolsCapabilitiesSchema as Gr, AssistantMessageSchema as Gt, useLearningContainersInCurrentThread as H, transformHttpEventStream as Hi, RawEventSchema as Hn, ToolCallStatus$1 as Hr, AgentCapabilitiesSchema as Ht, CopilotChatSuggestionPill as I, runHttpRequest as Ii, MultimodalCapabilitiesSchema as In, ToolCallArgsEventSchema as Ir, AGUIError as It, useThreads$1 as J, ɵTHREAD_REQUEST_TIMEOUT_MS as Ji, ReasoningMessageContentEventSchema as Jn, VideoInputContentSchema as Jr, BackwardCompatibility_0_0_39 as Jt, useLearnFromUserAction as K, ɵMAX_SOCKET_RETRIES as Ki, ReasoningEndEventSchema as Kn, TransportCapabilitiesSchema as Kr, AudioInputContentSchema as Kt, CopilotChatReasoningMessage_default as L, select as Li, MultimodalInputCapabilitiesSchema as Ln, ToolCallChunkEventSchema as Lr, AGUI_METADATA_KEY as Lt, IntelligenceIndicator as M, props as Mi, MessagesSnapshotEventSchema as Mn, ThinkingTextMessageContentEventSchema as Mr, CopilotChatAudioRecorder as Mt, getIntelligenceTurnAnchors as N, randomUUID$2 as Ni, MetadataSchema as Nn, ThinkingTextMessageEndEventSchema as Nr, CopilotChatConfigurationProvider as Nt, CopilotChatView_default as O, onInspectorViewThreadResult as Oi, InterruptSchema as On, TextMessageEndEventSchema as Or, CopilotKitInspector as Ot, IntelligenceIndicatorView as P, resolveAgentDebugConfig as Pi, Middleware as Pn, ThinkingTextMessageStartEventSchema as Pr, useCopilotChatConfiguration as Pt, useSuggestions as Q, ɵisCopilotKitFeature as Qi, ReasoningStartEventSchema as Qn, buildResumeArray as Qr, BaseEventSchema as Qt, CopilotChatUserMessage_default as R, structuredClone_ as Ri, MultimodalOutputCapabilitiesSchema as Rn, ToolCallEndEventSchema as Rr, AbstractAgent$1 as Rt, CopilotSidebarView as S, ɵselectThreads$1 as Sa, mergeMetadata as Si, ImageInputPartSchema as Sn, SubagentStartedEventSchema as Sr, SandboxFunctionsContext as St, DefaultCloseIcon as T, ɵthreadAdapterEvents as Ta, onInspectorActiveThread as Ti, InputContentSourceSchema as Tn, TextInputContentSchema as Tr, MCPAppsActivityRenderer as Tt, useLearningContainers as U, verifyEvents as Ui, ReasoningCapabilitiesSchema as Un, ToolMessageSchema as Ur, AgentRegistry as Ut, CopilotChatToolCallsView as V, transformChunks as Vi, ProxiedCopilotRuntimeAgent$1 as Vn, ToolCallStartEventSchema as Vr, ActivitySnapshotEventSchema as Vt, useAttachments as W, ɵCOPILOTKIT_FEATURES as Wi, ReasoningEncryptedValueEventSchema as Wn, ToolSchema as Wr, AgentThreadLockedError as Wt, INTERRUPT_EVENT_NAME as X, ɵcreateThreadSelectors as Xi, ReasoningMessageSchema as Xn, WebMCPRegistry as Xr, BackwardCompatibility_0_0_47 as Xt, useInterrupt as Y, ɵcreateMemoryStore as Yi, ReasoningMessageEndEventSchema as Yn, VideoInputPartSchema as Yr, BackwardCompatibility_0_0_45 as Yt, useConfigureSuggestions as Z, ɵcreateThreadStore$1 as Zi, ReasoningMessageStartEventSchema as Zn, aggregateTokenUsage as Zr, BackwardCompatibility_0_0_57 as Zt, WildcardToolCallRender as _, ɵselectMemoriesAvailable$1 as _a, getWebMCPModelContext as _i, HttpAgent$1 as _n, SubagentErrorEventSchema as _r, GenerateSandboxedUiArgsSchema as _t, ThreadsProvider as a, ɵmemoryRestEvents as aa, createInspectorThreadRequestId as ai, CopilotKitCoreRuntimeConnectionStatus$1 as an, RunFinishedOutcomeSchema as ar, useRenderTool as at, CopilotSidebar as b, ɵselectMemoriesIsMutating as ba, isInterruptExpired as bi, IdentityCapabilitiesSchema as bn, SubagentFinishedSuccessOutcomeSchema as br, OpenGenerativeUIContentSchema as bt, CoAgentStateRendersProvider as c, ɵobservePhoenixSocketHealth$ as ca, createStore as ci, DeveloperMessageSchema as cn, RunStartedEventSchema as cr, useFrontendTool as ct, shouldShowDevConsole as d, ɵphoenixSocket$ as da, emitInspectorStopViewing as di, EventSchemas as dn, StateManager as dr, CopilotKitProvider as dt, ɵjoinPhoenixChannel$ as ea, completePartialMarkdown as ei, BinaryInputContentSchema as en, RoleSchema as er, useCapabilities as et, useToast as f, ɵselectFetchMoreError$1 as fa, emitInspectorViewThread as fi, EventType as fn, StateSchema as fr, useCopilotKit$1 as ft, useCopilotContext as g, ɵselectMemories$1 as ga, getRunOutcome as gi, FunctionMiddleware as gn, SubAgentInfoSchema as gr, createA2UIMessageRenderer as gt, CopilotContext as h, ɵselectIsMutating$1 as ha, ensureObjectArgs as hi, FunctionCallSchema as hn, StepStartedEventSchema as hr, defineToolCallRenderer as ht, ThreadsContext as i, ɵmemoryReducer as ia, createEffect as ii, CopilotKitCoreErrorCode$1 as in, RunFinishedInterruptOutcomeSchema as ir, useDefaultRenderTool as it, INTELLIGENCE_TURN_HEAD as j, parseToolArguments as ji, MessageSchema as jn, ThinkingStartEventSchema as jr, AudioRecorderError as jt, CopilotChatAttachmentQueue as k, parseProtoStream as ki, MEMORY_ERROR_REGISTRY as kn, TextMessageStartEventSchema as kr, useRenderToolCall as kt, useCoAgentStateRenders as l, ɵobservePhoenixSocketSignals$ as la, defaultApplyEvents as li, DocumentInputContentSchema as ln, StateCapabilitiesSchema as lr, useRenderActivityMessage as lt, useCopilotMessagesContext as m, ɵselectIsFetchingNextPage$1 as ma, empty as mi, FilterToolCallsMiddleware as mn, StepFinishedEventSchema as mr, CopilotKitCoreReact as mt, defaultCopilotContextCategories as n, ɵmemoryAdapterEvents as na, createActionGroup as ni, ContextStore as nn, RunErrorEventSchema as nr, useAgent as nt, useThreads as o, ɵobservePhoenixEvent$ as oa, createReducer as oi, CustomEventSchema as on, RunFinishedSuccessOutcomeSchema as or, useComponent as ot, CopilotMessagesContext as p, ɵselectHasNextPage$1 as pa, emitInspectorViewThreadResult$1 as pi, ExecutionCapabilitiesSchema as pn, StateSnapshotEventSchema as pr, useLicenseContext$1 as pt, useMemories as q, ɵRUNTIME_PROBE_TIMEOUT_MS as qi, ReasoningMessageChunkEventSchema as qn, UserMessageSchema as qr, AudioInputPartSchema as qt, CoAgentStateRenderBridge as r, ɵmemoryDomainEvents as ra, createDebugLogger as ri, CopilotKitCore$1 as rn, RunFinishedEventSchema as rr, useHumanInTheLoop as rt, CoAgentStateRendersContext as s, ɵobservePhoenixJoinOutcome$ as sa, createSelector as si, DebugLogger as sn, RunHandler as sr, useFrontendTools as st, CopilotKit as t, ɵmapMemoryMetadataEvent as ta, convertToLegacyEvents as ti, ContextSchema as tn, RunAgentInputSchema as tr, UseAgentUpdate as tt, useAsyncCallback as u, ɵphoenixChannel$ as ua, emitInspectorActiveThread$1 as ui, DocumentInputPartSchema as un, StateDeltaEventSchema as ur, useRenderCustomMessages as ut, CopilotThreadsDrawer as v, ɵselectMemoriesError$1 as va, isAbortError as vi, HumanInTheLoopCapabilitiesSchema as vn, SubagentFinishedEventSchema as vr, OpenGenerativeUIActivityRenderer as vt, CopilotChatToggleButton as w, ɵselectThreadsIsLoading$1 as wa, on as wi, InputContentSchema as wn, SystemMessageSchema as wr, MCPAppsActivityContentSchema as wt, CopilotPopupView as x, ɵselectMemoriesRealtimeStatus$1 as xa, isRunCompletionAware$1 as xi, ImageInputContentSchema as xn, SubagentFinishedSuspendedOutcomeSchema as xr, OpenGenerativeUIToolRenderer as xt, CopilotPopup as y, ɵselectMemoriesIsLoading$1 as ya, isInspectorThreadBridgeEnabled$1 as yi, INSPECTOR_THREAD_BRIDGE_PLUGIN_ID as yn, SubagentFinishedOutcomeSchema as yr, OpenGenerativeUIActivityType as yt, CopilotChatAttachmentRenderer as z, tokenUsageFromAiSdkUsage as zi, OptionalMetadataSchema as zn, ToolCallResultEventSchema as zr, ActivityDeltaEventSchema as zt };
|
|
12479
|
-
//# sourceMappingURL=copilotkit-
|
|
12585
|
+
//# sourceMappingURL=copilotkit-CoWG8EAX.mjs.map
|