@copilotkit/react-core 1.88.0 → 1.89.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-RAr-1JSr.d.mts → copilotkit-CfnudBCL.d.mts} +20 -5
- package/dist/copilotkit-CfnudBCL.d.mts.map +1 -0
- package/dist/{copilotkit-D4AAgBT1.cjs → copilotkit-DHJJxCeI.cjs} +267 -61
- package/dist/copilotkit-DHJJxCeI.cjs.map +1 -0
- package/dist/{copilotkit-CYqkB8Nv.mjs → copilotkit-GWoyxfzS.mjs} +271 -65
- package/dist/copilotkit-GWoyxfzS.mjs.map +1 -0
- package/dist/{copilotkit-BS_3fQrS.d.cts → copilotkit-XLp7jKQk.d.cts} +20 -5
- package/dist/copilotkit-XLp7jKQk.d.cts.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 +15 -10
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/generative-ui.d.cts +46 -46
- package/dist/v2/generative-ui.d.cts.map +1 -1
- package/dist/v2/generative-ui.d.mts +46 -46
- package/dist/v2/generative-ui.d.mts.map +1 -1
- package/dist/v2/index.cjs +19 -1
- package/dist/v2/index.css +1 -1
- package/dist/v2/index.d.cts +2 -2
- package/dist/v2/index.d.mts +2 -2
- package/dist/v2/index.mjs +2 -2
- package/dist/v2/index.umd.js +284 -60
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +10 -10
- package/dist/copilotkit-BS_3fQrS.d.cts.map +0 -1
- package/dist/copilotkit-CYqkB8Nv.mjs.map +0 -1
- package/dist/copilotkit-D4AAgBT1.cjs.map +0 -1
- package/dist/copilotkit-RAr-1JSr.d.mts.map +0 -1
package/dist/v2/index.umd.js
CHANGED
|
@@ -1825,7 +1825,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
1825
1825
|
|
|
1826
1826
|
//#endregion
|
|
1827
1827
|
//#region package.json
|
|
1828
|
-
var version = "1.
|
|
1828
|
+
var version = "1.89.0";
|
|
1829
1829
|
|
|
1830
1830
|
//#endregion
|
|
1831
1831
|
//#region src/v2/components/CopilotKitInspector.tsx
|
|
@@ -2061,7 +2061,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
2061
2061
|
* Fetches resource content on-demand via proxied MCP requests. The React shell
|
|
2062
2062
|
* owns the iframe; `bindMcpApp` owns the protocol.
|
|
2063
2063
|
*/
|
|
2064
|
-
const MCPAppsActivityRenderer = function MCPAppsActivityRenderer({ content, message, agent, allowSameOriginFallback }) {
|
|
2064
|
+
const MCPAppsActivityRenderer = function MCPAppsActivityRenderer({ content, message, agent, allowSameOriginFallback, modelContext }) {
|
|
2065
2065
|
const { copilotkit } = useCopilotKit();
|
|
2066
2066
|
const messageId = message?.id;
|
|
2067
2067
|
const containerRef = (0, react.useRef)(null);
|
|
@@ -2111,7 +2111,10 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
2111
2111
|
getAgent: () => agentRef.current,
|
|
2112
2112
|
host: copilotkit,
|
|
2113
2113
|
messageId,
|
|
2114
|
-
options: {
|
|
2114
|
+
options: {
|
|
2115
|
+
allowSameOriginFallback,
|
|
2116
|
+
modelContext
|
|
2117
|
+
},
|
|
2115
2118
|
hooks: {
|
|
2116
2119
|
onResource: (resource) => {
|
|
2117
2120
|
if (!mounted) return;
|
|
@@ -2154,6 +2157,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
2154
2157
|
copilotkit,
|
|
2155
2158
|
messageId,
|
|
2156
2159
|
allowSameOriginFallback,
|
|
2160
|
+
modelContext,
|
|
2157
2161
|
content.resourceUri,
|
|
2158
2162
|
content.serverHash,
|
|
2159
2163
|
content.serverId
|
|
@@ -5251,11 +5255,6 @@ surface to use a different protocol.`;
|
|
|
5251
5255
|
- Use CSS Grid or Flexbox for layout. Ensure the UI looks good at any width.
|
|
5252
5256
|
- Minimal transitions (150ms) for hover/focus states only. No decorative animations.
|
|
5253
5257
|
- Keep the UI focused and dense — avoid excessive padding. Use compact spacing (8–12px gaps, 10–14px padding in controls).`;
|
|
5254
|
-
/** The MCP Apps renderer with `mcpApps.allowSameOriginFallback` applied. */
|
|
5255
|
-
const SameOriginMCPAppsActivityRenderer = (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MCPAppsActivityRenderer, {
|
|
5256
|
-
...props,
|
|
5257
|
-
allowSameOriginFallback: true
|
|
5258
|
-
});
|
|
5259
5258
|
const DEFAULT_LEARNING = Object.freeze({});
|
|
5260
5259
|
function toLearningConfig(learning) {
|
|
5261
5260
|
if (learning === true) return DEFAULT_LEARNING;
|
|
@@ -5332,11 +5331,17 @@ surface to use a different protocol.`;
|
|
|
5332
5331
|
return (0, _copilotkit_a2ui_renderer.filterCatalog)(rawCatalog, (name) => core ? core.isCatalogComponentEnabled(name) : true);
|
|
5333
5332
|
}, [rawCatalog, catalogToggleVersion]);
|
|
5334
5333
|
const mcpAppsAllowSameOrigin = mcpApps?.allowSameOriginFallback === true;
|
|
5334
|
+
const mcpAppsModelContext = mcpApps?.modelContext === true;
|
|
5335
|
+
const mcpAppsRenderer = (0, react.useMemo)(() => mcpAppsAllowSameOrigin || mcpAppsModelContext ? (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MCPAppsActivityRenderer, {
|
|
5336
|
+
...props,
|
|
5337
|
+
allowSameOriginFallback: mcpAppsAllowSameOrigin,
|
|
5338
|
+
modelContext: mcpAppsModelContext
|
|
5339
|
+
}) : MCPAppsActivityRenderer, [mcpAppsAllowSameOrigin, mcpAppsModelContext]);
|
|
5335
5340
|
const builtInActivityRenderers = (0, react.useMemo)(() => {
|
|
5336
5341
|
const renderers = [{
|
|
5337
5342
|
activityType: _copilotkit_mcp_apps_renderer_activity.MCPAppsActivityType,
|
|
5338
5343
|
content: _copilotkit_mcp_apps_renderer_activity.MCPAppsActivityContentSchema,
|
|
5339
|
-
render:
|
|
5344
|
+
render: mcpAppsRenderer
|
|
5340
5345
|
}];
|
|
5341
5346
|
if (openGenUIActive) renderers.push({
|
|
5342
5347
|
activityType: OpenGenerativeUIActivityType,
|
|
@@ -5357,7 +5362,7 @@ surface to use a different protocol.`;
|
|
|
5357
5362
|
generativeUIActive,
|
|
5358
5363
|
a2ui,
|
|
5359
5364
|
filteredCatalog,
|
|
5360
|
-
|
|
5365
|
+
mcpAppsRenderer
|
|
5361
5366
|
]);
|
|
5362
5367
|
const allActivityRenderers = (0, react.useMemo)(() => {
|
|
5363
5368
|
return [...renderActivityMessagesList, ...builtInActivityRenderers];
|
|
@@ -9603,9 +9608,12 @@ surface to use a different protocol.`;
|
|
|
9603
9608
|
}
|
|
9604
9609
|
};
|
|
9605
9610
|
};
|
|
9611
|
+
const isLatestAssistantMessage = message.role === "assistant" && (isLatest ?? messages?.[messages.length - 1]?.id === message.id);
|
|
9612
|
+
const isStreaming = !!isRunning && (isLatest === void 0 && messages === void 0 ? true : isLatestAssistantMessage);
|
|
9606
9613
|
const boundMarkdownRenderer = renderSlot(markdownRenderer, CopilotChatAssistantMessage.MarkdownRenderer, {
|
|
9607
9614
|
content: message.content || "",
|
|
9608
|
-
messageId: message.id
|
|
9615
|
+
messageId: message.id,
|
|
9616
|
+
mode: isStreaming ? "streaming" : "static"
|
|
9609
9617
|
});
|
|
9610
9618
|
const boundCopyButton = renderSlot(copyButton, CopilotChatAssistantMessage.CopyButton, { onClick: async () => {
|
|
9611
9619
|
if (message.content) return await (0, _copilotkit_shared.copyToClipboard)(message.content);
|
|
@@ -9647,7 +9655,6 @@ surface to use a different protocol.`;
|
|
|
9647
9655
|
messages
|
|
9648
9656
|
});
|
|
9649
9657
|
const hasContent = !!(message.content && message.content.trim().length > 0);
|
|
9650
|
-
const isLatestAssistantMessage = message.role === "assistant" && (isLatest ?? messages?.[messages.length - 1]?.id === message.id);
|
|
9651
9658
|
const shouldShowToolbar = toolbarVisible && (hasContent || showInspectorShortcut) && !(isRunning && isLatestAssistantMessage);
|
|
9652
9659
|
const { open: commentOpen, close: closeComment } = comment;
|
|
9653
9660
|
(0, react.useEffect)(() => {
|
|
@@ -10987,25 +10994,14 @@ surface to use a different protocol.`;
|
|
|
10987
10994
|
return true;
|
|
10988
10995
|
});
|
|
10989
10996
|
/**
|
|
10990
|
-
* Deduplicates messages by ID. For assistant messages, merges occurrences:
|
|
10991
|
-
* recovers non-empty content from any earlier occurrence if the latest wiped it
|
|
10992
|
-
* (empty string means the streaming update cleared the field, not blank text),
|
|
10993
|
-
* and similarly recovers toolCalls from earlier occurrences if the latest is
|
|
10994
|
-
* undefined (an empty array [] is treated as intentional and kept as-is).
|
|
10995
|
-
* For all other roles, keeps the last entry.
|
|
10996
|
-
*
|
|
10997
|
-
* @internal Exported for unit testing only — not part of the public API.
|
|
10998
|
-
*/
|
|
10999
|
-
/**
|
|
11000
10997
|
* Collapse tool calls that share an id, keeping first-seen order.
|
|
11001
10998
|
*
|
|
11002
|
-
* AG-UI
|
|
11003
|
-
*
|
|
11004
|
-
*
|
|
11005
|
-
*
|
|
11006
|
-
*
|
|
11007
|
-
*
|
|
11008
|
-
* copy.
|
|
10999
|
+
* Older AG-UI clients appended to the parent message's `toolCalls` without
|
|
11000
|
+
* checking whether that id was already present. So whenever a start event was
|
|
11001
|
+
* applied twice — which the human-in-the-loop flow triggers when the run syncs
|
|
11002
|
+
* after `respond()` — the message ended up carrying the same call twice. The
|
|
11003
|
+
* second copy has EMPTY `arguments`, because a start event carries none; the
|
|
11004
|
+
* args arrive later as TOOL_CALL_ARGS deltas addressed to the first copy.
|
|
11009
11005
|
*
|
|
11010
11006
|
* Left alone that renders the same tool call twice: once populated and once
|
|
11011
11007
|
* blank (an approval card with no transaction id, offering live buttons for an
|
|
@@ -11027,13 +11023,42 @@ surface to use a different protocol.`;
|
|
|
11027
11023
|
}
|
|
11028
11024
|
return byId.size === toolCalls.length ? toolCalls : [...byId.values()];
|
|
11029
11025
|
}
|
|
11026
|
+
/**
|
|
11027
|
+
* Unite the tool calls of two occurrences of the same assistant message,
|
|
11028
|
+
* keeping first-seen order. Each occurrence can hold only some of the calls,
|
|
11029
|
+
* so neither list may replace the other.
|
|
11030
|
+
*
|
|
11031
|
+
* For an id present in both, the later occurrence wins when it carries
|
|
11032
|
+
* arguments: it is the newer streaming update. A blank later copy never
|
|
11033
|
+
* replaces a populated one.
|
|
11034
|
+
*/
|
|
11035
|
+
function mergeToolCalls(earlier, later) {
|
|
11036
|
+
const byId = new Map(earlier.map((toolCall) => [toolCall.id, toolCall]));
|
|
11037
|
+
for (const toolCall of later) {
|
|
11038
|
+
const existing = byId.get(toolCall.id);
|
|
11039
|
+
if (!existing || toolCall.function?.arguments || !existing.function?.arguments) byId.set(toolCall.id, toolCall);
|
|
11040
|
+
}
|
|
11041
|
+
return [...byId.values()];
|
|
11042
|
+
}
|
|
11043
|
+
/**
|
|
11044
|
+
* Deduplicates messages by ID. For assistant messages, merges occurrences:
|
|
11045
|
+
* recovers non-empty content from any earlier occurrence if the latest wiped it
|
|
11046
|
+
* (empty string means the streaming update cleared the field, not blank text).
|
|
11047
|
+
* Tool calls from every occurrence are kept: a copy can hold only some of the
|
|
11048
|
+
* calls, so when two occurrences both carry tool calls they are united by id.
|
|
11049
|
+
* If the latest has undefined toolCalls they are recovered from earlier
|
|
11050
|
+
* occurrences; an explicit empty array [] is treated as intentional and kept.
|
|
11051
|
+
* For all other roles, keeps the last entry.
|
|
11052
|
+
*
|
|
11053
|
+
* @internal Exported for unit testing only — not part of the public API.
|
|
11054
|
+
*/
|
|
11030
11055
|
function deduplicateMessages(messages) {
|
|
11031
11056
|
const acc = /* @__PURE__ */ new Map();
|
|
11032
11057
|
for (const message of messages) {
|
|
11033
11058
|
const existing = acc.get(message.id);
|
|
11034
11059
|
if (existing && message.role === "assistant" && existing.role === "assistant") {
|
|
11035
11060
|
const content = message.content || existing.content;
|
|
11036
|
-
const toolCalls = message.toolCalls ?? existing.toolCalls;
|
|
11061
|
+
const toolCalls = message.toolCalls?.length && existing.toolCalls?.length ? mergeToolCalls(dedupeToolCalls(existing.toolCalls), dedupeToolCalls(message.toolCalls)) : message.toolCalls ?? existing.toolCalls;
|
|
11037
11062
|
acc.set(message.id, {
|
|
11038
11063
|
...existing,
|
|
11039
11064
|
...message,
|
|
@@ -11048,6 +11073,8 @@ surface to use a different protocol.`;
|
|
|
11048
11073
|
}
|
|
11049
11074
|
return [...acc.values()];
|
|
11050
11075
|
}
|
|
11076
|
+
/** At most this many rows are rendered beyond the viewport on either side. */
|
|
11077
|
+
const MAX_OVERSCAN_ROWS = 400;
|
|
11051
11078
|
/** A row holding a single message, rendered as it would be ungrouped. */
|
|
11052
11079
|
function messageRow(message) {
|
|
11053
11080
|
return {
|
|
@@ -11065,6 +11092,17 @@ surface to use a different protocol.`;
|
|
|
11065
11092
|
const GROUP_ROW_KEY_PREFIX = "copilotkit-group:";
|
|
11066
11093
|
const MESSAGE_ROW_KEY_PREFIX = "copilotkit-message:";
|
|
11067
11094
|
const VIRTUALIZE_THRESHOLD = 50;
|
|
11095
|
+
/**
|
|
11096
|
+
* How long the scroll position must stay still, with no wheel or touch input,
|
|
11097
|
+
* before a correction held back during scrolling is written to `scrollTop`.
|
|
11098
|
+
*/
|
|
11099
|
+
const SCROLL_SETTLE_MS = 250;
|
|
11100
|
+
/**
|
|
11101
|
+
* The most a held correction moves per frame once it is written. Safari can
|
|
11102
|
+
* still drop a write when a new gesture starts in the same frame; a small
|
|
11103
|
+
* step keeps that from showing.
|
|
11104
|
+
*/
|
|
11105
|
+
const SETTLE_STEP_PX = 4;
|
|
11068
11106
|
function CopilotChatMessageView({ messages = [], assistantMessage, userMessage, reasoningMessage, cursor, intelligenceIndicator, workSummary, isRunning = false, transformMessages, groupMessages, messageFeedback = true, toolCallDisplay = "grouped", children, className, ...props }) {
|
|
11069
11107
|
const isPinnedToBottom = (0, react.useContext)(ScrollPinnedContext);
|
|
11070
11108
|
const renderCustomMessage = useRenderCustomMessages();
|
|
@@ -11339,20 +11377,49 @@ surface to use a different protocol.`;
|
|
|
11339
11377
|
]);
|
|
11340
11378
|
const measuredRef = react.default.useRef({
|
|
11341
11379
|
total: 0,
|
|
11342
|
-
sizes: /* @__PURE__ */ new Map()
|
|
11380
|
+
sizes: /* @__PURE__ */ new Map(),
|
|
11381
|
+
estimates: /* @__PURE__ */ new Map()
|
|
11343
11382
|
});
|
|
11344
11383
|
const rowKeysRef = react.default.useRef(rowKeys);
|
|
11345
11384
|
rowKeysRef.current = rowKeys;
|
|
11346
11385
|
const resizeAnchorRef = react.default.useRef(null);
|
|
11347
11386
|
const restoringVisibilityRef = react.default.useRef(false);
|
|
11387
|
+
const heldOffsetRef = react.default.useRef(0);
|
|
11388
|
+
const spacerRef = react.default.useRef(null);
|
|
11389
|
+
const shiftedRowsRef = react.default.useRef(null);
|
|
11390
|
+
const lastMeasuredRef = react.default.useRef(null);
|
|
11391
|
+
const userScrollingRef = react.default.useRef(false);
|
|
11392
|
+
const ownScrollWriteRef = react.default.useRef(null);
|
|
11393
|
+
const renderedTotalRef = (0, react.useRef)(0);
|
|
11394
|
+
const applyHeldOffset = react.default.useCallback(() => {
|
|
11395
|
+
const held = heldOffsetRef.current;
|
|
11396
|
+
if (spacerRef.current) spacerRef.current.style.height = `${renderedTotalRef.current - held}px`;
|
|
11397
|
+
if (shiftedRowsRef.current) shiftedRowsRef.current.style.transform = held ? `translateY(${-held}px)` : "";
|
|
11398
|
+
}, []);
|
|
11399
|
+
const keepListTopInView = react.default.useCallback((scrollTop) => {
|
|
11400
|
+
if (heldOffsetRef.current >= 0 || scrollTop + heldOffsetRef.current >= 0) return false;
|
|
11401
|
+
heldOffsetRef.current = scrollTop > 0 ? -scrollTop : 0;
|
|
11402
|
+
return true;
|
|
11403
|
+
}, []);
|
|
11404
|
+
const releaseHeldOffset = react.default.useCallback((element, amount) => {
|
|
11405
|
+
if (amount === 0) return;
|
|
11406
|
+
const scrollTop = element.scrollTop;
|
|
11407
|
+
heldOffsetRef.current -= amount;
|
|
11408
|
+
applyHeldOffset();
|
|
11409
|
+
const target = Math.max(0, scrollTop + amount);
|
|
11410
|
+
ownScrollWriteRef.current = target;
|
|
11411
|
+
element.scrollTop = target;
|
|
11412
|
+
}, [applyHeldOffset]);
|
|
11348
11413
|
const firstMessageId = deduplicatedMessages[0]?.id;
|
|
11349
11414
|
const measuredThreadRef = react.default.useRef(firstMessageId);
|
|
11350
11415
|
if (measuredThreadRef.current !== firstMessageId) {
|
|
11351
11416
|
measuredThreadRef.current = firstMessageId;
|
|
11352
11417
|
resizeAnchorRef.current = null;
|
|
11418
|
+
heldOffsetRef.current = 0;
|
|
11353
11419
|
measuredRef.current = {
|
|
11354
11420
|
total: 0,
|
|
11355
|
-
sizes: /* @__PURE__ */ new Map()
|
|
11421
|
+
sizes: /* @__PURE__ */ new Map(),
|
|
11422
|
+
estimates: /* @__PURE__ */ new Map()
|
|
11356
11423
|
};
|
|
11357
11424
|
}
|
|
11358
11425
|
const measuredKeysRef = react.default.useRef(rowKeys);
|
|
@@ -11364,10 +11431,19 @@ surface to use a different protocol.`;
|
|
|
11364
11431
|
measured.sizes.delete(key);
|
|
11365
11432
|
measured.total -= height;
|
|
11366
11433
|
}
|
|
11434
|
+
for (const key of measured.estimates.keys()) if (!live.has(key)) measured.estimates.delete(key);
|
|
11367
11435
|
}
|
|
11368
|
-
const estimateRowSize = react.default.useCallback(() => {
|
|
11369
|
-
const { total, sizes } = measuredRef.current;
|
|
11370
|
-
|
|
11436
|
+
const estimateRowSize = react.default.useCallback((index) => {
|
|
11437
|
+
const { total, sizes, estimates } = measuredRef.current;
|
|
11438
|
+
const mean = sizes.size > 0 ? Math.max(1, Math.round(total / sizes.size)) : 100;
|
|
11439
|
+
const key = rowKeysRef.current[index];
|
|
11440
|
+
if (key === void 0) return mean;
|
|
11441
|
+
let estimate = estimates.get(key);
|
|
11442
|
+
if (estimate === void 0) {
|
|
11443
|
+
estimate = mean;
|
|
11444
|
+
estimates.set(key, estimate);
|
|
11445
|
+
}
|
|
11446
|
+
return estimate;
|
|
11371
11447
|
}, []);
|
|
11372
11448
|
const getRowKey = react.default.useCallback((index) => rowKeys[index] ?? index, [rowKeys]);
|
|
11373
11449
|
const isPinnedToBottomRef = react.default.useRef(isPinnedToBottom);
|
|
@@ -11382,7 +11458,7 @@ surface to use a different protocol.`;
|
|
|
11382
11458
|
};
|
|
11383
11459
|
return;
|
|
11384
11460
|
}
|
|
11385
|
-
const offset = instance.scrollElement?.scrollTop ?? 0;
|
|
11461
|
+
const offset = (instance.scrollElement?.scrollTop ?? 0) + heldOffsetRef.current;
|
|
11386
11462
|
const anchor = instance.getVirtualItemForOffset(offset);
|
|
11387
11463
|
if (anchor) resizeAnchorRef.current = {
|
|
11388
11464
|
index: anchor.index,
|
|
@@ -11392,20 +11468,46 @@ surface to use a different protocol.`;
|
|
|
11392
11468
|
}, []);
|
|
11393
11469
|
const measureRowElement = react.default.useCallback((el, _entry, instance) => {
|
|
11394
11470
|
captureResizeAnchor(instance);
|
|
11395
|
-
const
|
|
11471
|
+
const rect = el?.getBoundingClientRect();
|
|
11472
|
+
const height = rect?.height ?? 0;
|
|
11396
11473
|
const index = Number(el?.dataset?.index);
|
|
11397
11474
|
const key = Number.isInteger(index) ? rowKeysRef.current[index] : void 0;
|
|
11398
|
-
|
|
11475
|
+
const viewportTop = typeof rect?.top === "number" ? instance.scrollElement?.getBoundingClientRect().top : void 0;
|
|
11476
|
+
lastMeasuredRef.current = Number.isInteger(index) && typeof rect?.top === "number" && typeof viewportTop === "number" ? {
|
|
11477
|
+
index,
|
|
11478
|
+
above: rect.top < viewportTop
|
|
11479
|
+
} : null;
|
|
11480
|
+
const hidden = !el?.isConnected || !instance.scrollElement?.clientHeight;
|
|
11481
|
+
if ((height > 0 || !hidden) && key !== void 0) {
|
|
11399
11482
|
const { total, sizes } = measuredRef.current;
|
|
11400
11483
|
measuredRef.current.total = total - (sizes.get(key) ?? 0) + height;
|
|
11401
11484
|
sizes.set(key, height);
|
|
11402
11485
|
}
|
|
11403
|
-
return height > 0 ? height : (key === void 0 ? void 0 : measuredRef.current.sizes.get(key)) ?? 100;
|
|
11486
|
+
return height > 0 || !hidden ? height : (key === void 0 ? void 0 : measuredRef.current.sizes.get(key)) ?? 100;
|
|
11404
11487
|
}, [captureResizeAnchor]);
|
|
11405
|
-
const shouldAdjustScrollOnResize = react.default.useCallback((item,
|
|
11488
|
+
const shouldAdjustScrollOnResize = react.default.useCallback((item, delta, instance) => {
|
|
11489
|
+
const measured = lastMeasuredRef.current;
|
|
11490
|
+
lastMeasuredRef.current = null;
|
|
11406
11491
|
if (isPinnedToBottomRef.current || resizeAnchorRef.current || restoringVisibilityRef.current) return false;
|
|
11407
11492
|
const scrollAdjustments = instance.scrollAdjustments ?? 0;
|
|
11408
|
-
|
|
11493
|
+
if (!(measured?.index === item.index ? measured.above : item.start < (instance.scrollOffset ?? 0) + scrollAdjustments)) return false;
|
|
11494
|
+
if (userScrollingRef.current || heldOffsetRef.current !== 0) {
|
|
11495
|
+
const held = heldOffsetRef.current;
|
|
11496
|
+
heldOffsetRef.current += delta;
|
|
11497
|
+
keepListTopInView(instance.scrollElement?.scrollTop ?? 0);
|
|
11498
|
+
instance.scrollOffset = (instance.scrollOffset ?? 0) + heldOffsetRef.current - held;
|
|
11499
|
+
return false;
|
|
11500
|
+
}
|
|
11501
|
+
return true;
|
|
11502
|
+
}, [keepListTopInView]);
|
|
11503
|
+
const observeListOffset = react.default.useCallback((instance, notify) => (0, _tanstack_react_virtual.observeElementOffset)(instance, (offset, isScrolling) => {
|
|
11504
|
+
if (keepListTopInView(offset)) applyHeldOffset();
|
|
11505
|
+
notify(offset + heldOffsetRef.current, isScrolling);
|
|
11506
|
+
}), [keepListTopInView, applyHeldOffset]);
|
|
11507
|
+
const scrollToListOffset = react.default.useCallback((offset, options, instance) => {
|
|
11508
|
+
const elementOffset = offset - heldOffsetRef.current;
|
|
11509
|
+
ownScrollWriteRef.current = elementOffset + (options.adjustments ?? 0);
|
|
11510
|
+
(0, _tanstack_react_virtual.elementScroll)(elementOffset, options, instance);
|
|
11409
11511
|
}, []);
|
|
11410
11512
|
const observeScrollRect = react.default.useCallback((instance, notify) => {
|
|
11411
11513
|
let frame;
|
|
@@ -11436,7 +11538,8 @@ surface to use a different protocol.`;
|
|
|
11436
11538
|
instance.getTotalSize();
|
|
11437
11539
|
measuredRef.current = {
|
|
11438
11540
|
total: 0,
|
|
11439
|
-
sizes: /* @__PURE__ */ new Map()
|
|
11541
|
+
sizes: /* @__PURE__ */ new Map(),
|
|
11542
|
+
estimates: /* @__PURE__ */ new Map()
|
|
11440
11543
|
};
|
|
11441
11544
|
instance.elementsCache.forEach((element) => {
|
|
11442
11545
|
measureRowElement(element, void 0, instance);
|
|
@@ -11461,28 +11564,120 @@ surface to use a different protocol.`;
|
|
|
11461
11564
|
resizeAnchorRef.current = null;
|
|
11462
11565
|
};
|
|
11463
11566
|
}, [captureResizeAnchor, measureRowElement]);
|
|
11567
|
+
const virtualizerRef = (0, react.useRef)(null);
|
|
11568
|
+
const rangeExtractor = react.default.useCallback((range) => {
|
|
11569
|
+
const instance = virtualizerRef.current;
|
|
11570
|
+
const items = instance?.measurementsCache;
|
|
11571
|
+
const reach = instance?.scrollRect?.height ?? 0;
|
|
11572
|
+
if (!items || items.length !== range.count || reach <= 0) return (0, _tanstack_react_virtual.defaultRangeExtractor)(range);
|
|
11573
|
+
let start = range.startIndex;
|
|
11574
|
+
for (let above = 0; start > 0 && range.startIndex - start < MAX_OVERSCAN_ROWS && (range.startIndex - start < range.overscan || above < reach);) {
|
|
11575
|
+
start -= 1;
|
|
11576
|
+
above += items[start].size;
|
|
11577
|
+
}
|
|
11578
|
+
let end = range.endIndex;
|
|
11579
|
+
for (let below = 0; end < range.count - 1 && end - range.endIndex < MAX_OVERSCAN_ROWS && (end - range.endIndex < range.overscan || below < reach);) {
|
|
11580
|
+
end += 1;
|
|
11581
|
+
below += items[end].size;
|
|
11582
|
+
}
|
|
11583
|
+
const indexes = [];
|
|
11584
|
+
for (let index = start; index <= end; index++) indexes.push(index);
|
|
11585
|
+
return indexes;
|
|
11586
|
+
}, []);
|
|
11464
11587
|
const virtualizer = (0, _tanstack_react_virtual.useVirtualizer)({
|
|
11465
11588
|
count: shouldVirtualize ? rows.length : 0,
|
|
11466
11589
|
getScrollElement: () => shouldVirtualize ? scrollElement : null,
|
|
11467
11590
|
observeElementRect: observeScrollRect,
|
|
11591
|
+
observeElementOffset: observeListOffset,
|
|
11592
|
+
scrollToFn: scrollToListOffset,
|
|
11468
11593
|
estimateSize: estimateRowSize,
|
|
11469
11594
|
getItemKey: getRowKey,
|
|
11470
11595
|
overscan: 5,
|
|
11596
|
+
rangeExtractor,
|
|
11471
11597
|
measureElement: measureRowElement,
|
|
11472
11598
|
initialRect: {
|
|
11473
11599
|
width: 0,
|
|
11474
11600
|
height: 600
|
|
11475
11601
|
}
|
|
11476
11602
|
});
|
|
11603
|
+
virtualizerRef.current = virtualizer;
|
|
11604
|
+
renderedTotalRef.current = virtualizer.getTotalSize();
|
|
11605
|
+
(0, react.useLayoutEffect)(applyHeldOffset);
|
|
11606
|
+
(0, react.useEffect)(() => {
|
|
11607
|
+
const element = shouldVirtualize ? scrollElement : null;
|
|
11608
|
+
if (!element) return;
|
|
11609
|
+
let settleTimer;
|
|
11610
|
+
let settleFrame;
|
|
11611
|
+
let touching = false;
|
|
11612
|
+
const settleStep = () => {
|
|
11613
|
+
settleFrame = void 0;
|
|
11614
|
+
const held = heldOffsetRef.current;
|
|
11615
|
+
if (userScrollingRef.current || touching || held === 0) return;
|
|
11616
|
+
releaseHeldOffset(element, Math.sign(held) * Math.min(Math.abs(held), SETTLE_STEP_PX));
|
|
11617
|
+
if (heldOffsetRef.current !== 0) settleFrame = requestAnimationFrame(settleStep);
|
|
11618
|
+
};
|
|
11619
|
+
const settle = () => {
|
|
11620
|
+
settleTimer = void 0;
|
|
11621
|
+
if (touching) return;
|
|
11622
|
+
userScrollingRef.current = false;
|
|
11623
|
+
if (heldOffsetRef.current !== 0 && settleFrame === void 0) settleFrame = requestAnimationFrame(settleStep);
|
|
11624
|
+
};
|
|
11625
|
+
const scrolling = () => {
|
|
11626
|
+
userScrollingRef.current = true;
|
|
11627
|
+
if (settleFrame !== void 0) {
|
|
11628
|
+
cancelAnimationFrame(settleFrame);
|
|
11629
|
+
settleFrame = void 0;
|
|
11630
|
+
}
|
|
11631
|
+
if (settleTimer !== void 0) clearTimeout(settleTimer);
|
|
11632
|
+
settleTimer = setTimeout(settle, SCROLL_SETTLE_MS);
|
|
11633
|
+
};
|
|
11634
|
+
const onScroll = () => {
|
|
11635
|
+
const own = ownScrollWriteRef.current;
|
|
11636
|
+
if (own !== null && Math.abs(element.scrollTop - own) < 1) {
|
|
11637
|
+
ownScrollWriteRef.current = null;
|
|
11638
|
+
return;
|
|
11639
|
+
}
|
|
11640
|
+
scrolling();
|
|
11641
|
+
};
|
|
11642
|
+
const onTouchStart = () => {
|
|
11643
|
+
touching = true;
|
|
11644
|
+
scrolling();
|
|
11645
|
+
};
|
|
11646
|
+
const onTouchEnd = () => {
|
|
11647
|
+
touching = false;
|
|
11648
|
+
scrolling();
|
|
11649
|
+
};
|
|
11650
|
+
element.addEventListener("scroll", onScroll, { passive: true });
|
|
11651
|
+
element.addEventListener("wheel", scrolling, { passive: true });
|
|
11652
|
+
element.addEventListener("touchstart", onTouchStart, { passive: true });
|
|
11653
|
+
element.addEventListener("touchend", onTouchEnd, { passive: true });
|
|
11654
|
+
element.addEventListener("touchcancel", onTouchEnd, { passive: true });
|
|
11655
|
+
return () => {
|
|
11656
|
+
if (settleTimer !== void 0) clearTimeout(settleTimer);
|
|
11657
|
+
if (settleFrame !== void 0) cancelAnimationFrame(settleFrame);
|
|
11658
|
+
userScrollingRef.current = false;
|
|
11659
|
+
element.removeEventListener("scroll", onScroll);
|
|
11660
|
+
element.removeEventListener("wheel", scrolling);
|
|
11661
|
+
element.removeEventListener("touchstart", onTouchStart);
|
|
11662
|
+
element.removeEventListener("touchend", onTouchEnd);
|
|
11663
|
+
element.removeEventListener("touchcancel", onTouchEnd);
|
|
11664
|
+
};
|
|
11665
|
+
}, [
|
|
11666
|
+
shouldVirtualize,
|
|
11667
|
+
scrollElement,
|
|
11668
|
+
releaseHeldOffset
|
|
11669
|
+
]);
|
|
11477
11670
|
isPinnedToBottomRef.current = isPinnedToBottom;
|
|
11478
11671
|
virtualizer.shouldAdjustScrollPositionOnItemSizeChange = shouldAdjustScrollOnResize;
|
|
11479
11672
|
(0, react.useLayoutEffect)(() => {
|
|
11480
11673
|
const anchor = resizeAnchorRef.current;
|
|
11481
11674
|
if (!anchor?.ready || restoringVisibilityRef.current) return;
|
|
11675
|
+
if (scrollElement) releaseHeldOffset(scrollElement, heldOffsetRef.current);
|
|
11482
11676
|
const position = virtualizer.getOffsetForIndex(anchor.index, "start");
|
|
11483
11677
|
if (position && !isPinnedToBottomRef.current) {
|
|
11484
11678
|
const target = position[0] + anchor.offset;
|
|
11485
|
-
|
|
11679
|
+
const listOffset = (scrollElement?.scrollTop ?? 0) + heldOffsetRef.current;
|
|
11680
|
+
if (Math.abs(listOffset - target) > .5) virtualizer.scrollToOffset(target);
|
|
11486
11681
|
}
|
|
11487
11682
|
const frame = requestAnimationFrame(() => {
|
|
11488
11683
|
if (resizeAnchorRef.current === anchor) resizeAnchorRef.current = null;
|
|
@@ -11700,26 +11895,37 @@ surface to use a different protocol.`;
|
|
|
11700
11895
|
...props,
|
|
11701
11896
|
children: [
|
|
11702
11897
|
shouldVirtualize ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
11898
|
+
ref: spacerRef,
|
|
11703
11899
|
style: {
|
|
11704
|
-
height:
|
|
11900
|
+
height: renderedTotalRef.current - heldOffsetRef.current,
|
|
11705
11901
|
position: "relative",
|
|
11706
11902
|
overflowAnchor: "none"
|
|
11707
11903
|
},
|
|
11708
|
-
children:
|
|
11709
|
-
|
|
11710
|
-
|
|
11711
|
-
"
|
|
11712
|
-
|
|
11713
|
-
|
|
11714
|
-
|
|
11715
|
-
|
|
11716
|
-
|
|
11717
|
-
|
|
11718
|
-
|
|
11719
|
-
|
|
11720
|
-
|
|
11721
|
-
|
|
11722
|
-
|
|
11904
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
11905
|
+
ref: shiftedRowsRef,
|
|
11906
|
+
style: {
|
|
11907
|
+
position: "absolute",
|
|
11908
|
+
top: 0,
|
|
11909
|
+
left: 0,
|
|
11910
|
+
width: "100%",
|
|
11911
|
+
transform: heldOffsetRef.current ? `translateY(${-heldOffsetRef.current}px)` : void 0
|
|
11912
|
+
},
|
|
11913
|
+
children: virtualizer.getVirtualItems().map((virtualItem) => {
|
|
11914
|
+
const row = rows[virtualItem.index];
|
|
11915
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
11916
|
+
"data-index": virtualItem.index,
|
|
11917
|
+
"data-scroll-anchor": rowKey(row),
|
|
11918
|
+
ref: virtualizer.measureElement,
|
|
11919
|
+
style: {
|
|
11920
|
+
position: "absolute",
|
|
11921
|
+
top: 0,
|
|
11922
|
+
left: 0,
|
|
11923
|
+
width: "100%",
|
|
11924
|
+
transform: `translateY(${virtualItem.start}px)`
|
|
11925
|
+
},
|
|
11926
|
+
children: renderRow(row)
|
|
11927
|
+
}, rowKey(row));
|
|
11928
|
+
})
|
|
11723
11929
|
})
|
|
11724
11930
|
}) : messageElements,
|
|
11725
11931
|
interruptElement,
|
|
@@ -12600,7 +12806,7 @@ surface to use a different protocol.`;
|
|
|
12600
12806
|
...props,
|
|
12601
12807
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Loader2, {
|
|
12602
12808
|
"aria-hidden": "true",
|
|
12603
|
-
className: "cpk:size-6 cpk:
|
|
12809
|
+
className: "cpk:size-6 cpk:text-muted-foreground cpk:*:origin-center cpk:*:animate-spin"
|
|
12604
12810
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
12605
12811
|
className: "cpk:sr-only",
|
|
12606
12812
|
children: labels.chatConnectingLabel
|
|
@@ -16617,6 +16823,12 @@ Object.defineProperty(exports, 'AGUIConnectNotImplementedError', {
|
|
|
16617
16823
|
return _ag_ui_client.AGUIConnectNotImplementedError;
|
|
16618
16824
|
}
|
|
16619
16825
|
});
|
|
16826
|
+
Object.defineProperty(exports, 'AGUIEnforcementLimitError', {
|
|
16827
|
+
enumerable: true,
|
|
16828
|
+
get: function () {
|
|
16829
|
+
return _ag_ui_client.AGUIEnforcementLimitError;
|
|
16830
|
+
}
|
|
16831
|
+
});
|
|
16620
16832
|
Object.defineProperty(exports, 'AGUIError', {
|
|
16621
16833
|
enumerable: true,
|
|
16622
16834
|
get: function () {
|
|
@@ -16847,6 +17059,12 @@ Object.defineProperty(exports, 'CustomEventSchema', {
|
|
|
16847
17059
|
return _ag_ui_core_schemas.CustomEventSchema;
|
|
16848
17060
|
}
|
|
16849
17061
|
});
|
|
17062
|
+
Object.defineProperty(exports, 'DEFAULT_MAX_ENFORCED_ENTRIES', {
|
|
17063
|
+
enumerable: true,
|
|
17064
|
+
get: function () {
|
|
17065
|
+
return _ag_ui_client.DEFAULT_MAX_ENFORCED_ENTRIES;
|
|
17066
|
+
}
|
|
17067
|
+
});
|
|
16850
17068
|
Object.defineProperty(exports, 'DataSourceSchema', {
|
|
16851
17069
|
enumerable: true,
|
|
16852
17070
|
get: function () {
|
|
@@ -17014,6 +17232,12 @@ Object.defineProperty(exports, 'IntelligenceAgent', {
|
|
|
17014
17232
|
});
|
|
17015
17233
|
exports.IntelligenceIndicator = IntelligenceIndicator;
|
|
17016
17234
|
exports.IntelligenceIndicatorView = IntelligenceIndicatorView;
|
|
17235
|
+
Object.defineProperty(exports, 'IntelligenceReplayFailedError', {
|
|
17236
|
+
enumerable: true,
|
|
17237
|
+
get: function () {
|
|
17238
|
+
return _copilotkit_core.IntelligenceReplayFailedError;
|
|
17239
|
+
}
|
|
17240
|
+
});
|
|
17017
17241
|
Object.defineProperty(exports, 'InterruptSchema', {
|
|
17018
17242
|
enumerable: true,
|
|
17019
17243
|
get: function () {
|