@copilotkit/react-core 1.60.1 → 1.60.2
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-BTHcCAVQ.cjs → copilotkit-CP5uyB2h.cjs} +43 -133
- package/dist/copilotkit-CP5uyB2h.cjs.map +1 -0
- package/dist/{copilotkit-C9ptuh-b.d.cts → copilotkit-CyL6ZsLP.d.cts} +7 -7
- package/dist/{copilotkit-DvbI8G0d.d.mts.map → copilotkit-CyL6ZsLP.d.cts.map} +1 -1
- package/dist/{copilotkit-CV519nFv.mjs → copilotkit-DheptEiV.mjs} +43 -133
- package/dist/copilotkit-DheptEiV.mjs.map +1 -0
- package/dist/{copilotkit-DvbI8G0d.d.mts → copilotkit-UaQ7KSUq.d.mts} +7 -7
- package/dist/{copilotkit-C9ptuh-b.d.cts.map → copilotkit-UaQ7KSUq.d.mts.map} +1 -1
- package/dist/index.cjs +6 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +6 -6
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +44 -129
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/context.cjs +8 -3
- package/dist/v2/context.cjs.map +1 -1
- package/dist/v2/context.d.cts.map +1 -1
- package/dist/v2/context.d.mts.map +1 -1
- package/dist/v2/context.mjs +8 -3
- package/dist/v2/context.mjs.map +1 -1
- package/dist/v2/headless.cjs +15 -8
- package/dist/v2/headless.cjs.map +1 -1
- package/dist/v2/headless.d.cts +3 -3
- package/dist/v2/headless.d.cts.map +1 -1
- package/dist/v2/headless.d.mts +3 -3
- package/dist/v2/headless.d.mts.map +1 -1
- package/dist/v2/headless.mjs +15 -8
- package/dist/v2/headless.mjs.map +1 -1
- package/dist/v2/index.cjs +1 -1
- package/dist/v2/index.css +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 +42 -132
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +6 -6
- package/dist/copilotkit-BTHcCAVQ.cjs.map +0 -1
- package/dist/copilotkit-CV519nFv.mjs.map +0 -1
|
@@ -1428,9 +1428,14 @@ const useCopilotKit = () => {
|
|
|
1428
1428
|
const [, forceUpdate] = (0, react.useReducer)((x) => x + 1, 0);
|
|
1429
1429
|
if (!context) throw new Error("useCopilotKit must be used within CopilotKitProvider");
|
|
1430
1430
|
(0, react.useEffect)(() => {
|
|
1431
|
-
const subscription = context.copilotkit.subscribe({
|
|
1432
|
-
|
|
1433
|
-
|
|
1431
|
+
const subscription = context.copilotkit.subscribe({
|
|
1432
|
+
onRuntimeConnectionStatusChanged: () => {
|
|
1433
|
+
forceUpdate();
|
|
1434
|
+
},
|
|
1435
|
+
onHeadersChanged: () => {
|
|
1436
|
+
forceUpdate();
|
|
1437
|
+
}
|
|
1438
|
+
});
|
|
1434
1439
|
return () => {
|
|
1435
1440
|
subscription.unsubscribe();
|
|
1436
1441
|
};
|
|
@@ -1637,9 +1642,8 @@ function DefaultToolCallRenderer({ name, toolCallId, parameters, status, result
|
|
|
1637
1642
|
const isActive = status === "inProgress" || status === "executing";
|
|
1638
1643
|
const isComplete = status === "complete";
|
|
1639
1644
|
const statusLabel = isActive ? "Running" : isComplete ? "Done" : status;
|
|
1640
|
-
const
|
|
1641
|
-
const
|
|
1642
|
-
const badgeColor = isActive ? "#92400e" : isComplete ? "#065f46" : "#3f3f46";
|
|
1645
|
+
const dotClassName = isActive ? "cpk:bg-amber-500" : isComplete ? "cpk:bg-emerald-500" : "cpk:bg-zinc-400";
|
|
1646
|
+
const badgeClassName = isActive ? "cpk:bg-amber-100 cpk:text-amber-800 cpk:dark:bg-amber-500/15 cpk:dark:text-amber-400" : isComplete ? "cpk:bg-emerald-100 cpk:text-emerald-800 cpk:dark:bg-emerald-500/15 cpk:dark:text-emerald-400" : "cpk:bg-zinc-100 cpk:text-zinc-800 cpk:dark:bg-zinc-700/40 cpk:dark:text-zinc-300";
|
|
1643
1647
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1644
1648
|
"data-testid": "copilot-tool-render",
|
|
1645
1649
|
"data-tool-name": name,
|
|
@@ -1647,54 +1651,20 @@ function DefaultToolCallRenderer({ name, toolCallId, parameters, status, result
|
|
|
1647
1651
|
"data-status": status,
|
|
1648
1652
|
"data-args": safeStringifyForAttr(parameters),
|
|
1649
1653
|
"data-result": safeStringifyForAttr(result),
|
|
1650
|
-
|
|
1651
|
-
marginTop: "8px",
|
|
1652
|
-
paddingBottom: "8px"
|
|
1653
|
-
},
|
|
1654
|
+
className: "cpk:mt-2 cpk:pb-2",
|
|
1654
1655
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1655
|
-
|
|
1656
|
-
borderRadius: "12px",
|
|
1657
|
-
border: "1px solid #e4e4e7",
|
|
1658
|
-
backgroundColor: "#fafafa",
|
|
1659
|
-
padding: "14px 16px"
|
|
1660
|
-
},
|
|
1656
|
+
className: "cpk:rounded-xl cpk:border cpk:border-zinc-200/60 cpk:bg-white/70 cpk:p-4 cpk:shadow-sm cpk:backdrop-blur cpk:dark:border-zinc-800/60 cpk:dark:bg-zinc-900/50",
|
|
1661
1657
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
1662
1658
|
type: "button",
|
|
1663
1659
|
"aria-expanded": isExpanded,
|
|
1664
1660
|
onClick: () => setIsExpanded(!isExpanded),
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
alignItems: "center",
|
|
1668
|
-
justifyContent: "space-between",
|
|
1669
|
-
gap: "10px",
|
|
1670
|
-
cursor: "pointer",
|
|
1671
|
-
userSelect: "none",
|
|
1672
|
-
width: "100%",
|
|
1673
|
-
border: "none",
|
|
1674
|
-
padding: 0,
|
|
1675
|
-
margin: 0,
|
|
1676
|
-
background: "transparent",
|
|
1677
|
-
textAlign: "left",
|
|
1678
|
-
font: "inherit",
|
|
1679
|
-
color: "inherit"
|
|
1680
|
-
},
|
|
1661
|
+
className: "cpk:flex cpk:w-full cpk:cursor-pointer cpk:select-none cpk:items-center cpk:justify-between cpk:gap-2.5 cpk:border-none cpk:bg-transparent cpk:p-0 cpk:m-0 cpk:text-left cpk:text-inherit",
|
|
1662
|
+
style: { font: "inherit" },
|
|
1681
1663
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1682
|
-
|
|
1683
|
-
display: "flex",
|
|
1684
|
-
alignItems: "center",
|
|
1685
|
-
gap: "8px",
|
|
1686
|
-
minWidth: 0
|
|
1687
|
-
},
|
|
1664
|
+
className: "cpk:flex cpk:min-w-0 cpk:items-center cpk:gap-2",
|
|
1688
1665
|
children: [
|
|
1689
1666
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
|
|
1690
|
-
|
|
1691
|
-
height: "14px",
|
|
1692
|
-
width: "14px",
|
|
1693
|
-
color: "#71717a",
|
|
1694
|
-
transition: "transform 0.15s",
|
|
1695
|
-
transform: isExpanded ? "rotate(90deg)" : "rotate(0deg)",
|
|
1696
|
-
flexShrink: 0
|
|
1697
|
-
},
|
|
1667
|
+
className: `cpk:h-3.5 cpk:w-3.5 cpk:flex-shrink-0 cpk:text-zinc-500 cpk:transition-transform cpk:dark:text-zinc-400 ${isExpanded ? "cpk:rotate-90" : ""}`,
|
|
1698
1668
|
fill: "none",
|
|
1699
1669
|
viewBox: "0 0 24 24",
|
|
1700
1670
|
strokeWidth: 2,
|
|
@@ -1705,93 +1675,31 @@ function DefaultToolCallRenderer({ name, toolCallId, parameters, status, result
|
|
|
1705
1675
|
d: "M8.25 4.5l7.5 7.5-7.5 7.5"
|
|
1706
1676
|
})
|
|
1707
1677
|
}),
|
|
1708
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1709
|
-
display: "inline-block",
|
|
1710
|
-
height: "8px",
|
|
1711
|
-
width: "8px",
|
|
1712
|
-
borderRadius: "50%",
|
|
1713
|
-
backgroundColor: dotColor,
|
|
1714
|
-
flexShrink: 0
|
|
1715
|
-
} }),
|
|
1678
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: `cpk:inline-block cpk:h-2 cpk:w-2 cpk:flex-shrink-0 cpk:rounded-full ${dotClassName}` }),
|
|
1716
1679
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1717
1680
|
"data-testid": "copilot-tool-render-name",
|
|
1718
|
-
|
|
1719
|
-
fontSize: "13px",
|
|
1720
|
-
fontWeight: 600,
|
|
1721
|
-
color: "#18181b",
|
|
1722
|
-
overflow: "hidden",
|
|
1723
|
-
textOverflow: "ellipsis",
|
|
1724
|
-
whiteSpace: "nowrap"
|
|
1725
|
-
},
|
|
1681
|
+
className: "cpk:truncate cpk:text-[13px] cpk:font-semibold cpk:text-zinc-900 cpk:dark:text-zinc-100",
|
|
1726
1682
|
children: name
|
|
1727
1683
|
})
|
|
1728
1684
|
]
|
|
1729
1685
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1730
1686
|
"data-testid": "copilot-tool-render-status",
|
|
1731
|
-
|
|
1732
|
-
display: "inline-flex",
|
|
1733
|
-
alignItems: "center",
|
|
1734
|
-
borderRadius: "9999px",
|
|
1735
|
-
padding: "2px 8px",
|
|
1736
|
-
fontSize: "11px",
|
|
1737
|
-
fontWeight: 500,
|
|
1738
|
-
backgroundColor: badgeBg,
|
|
1739
|
-
color: badgeColor,
|
|
1740
|
-
flexShrink: 0
|
|
1741
|
-
},
|
|
1687
|
+
className: `cpk:inline-flex cpk:flex-shrink-0 cpk:items-center cpk:rounded-full cpk:px-2 cpk:py-0.5 cpk:text-[11px] cpk:font-medium ${badgeClassName}`,
|
|
1742
1688
|
children: statusLabel
|
|
1743
1689
|
})]
|
|
1744
1690
|
}), isExpanded && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1745
|
-
|
|
1746
|
-
marginTop: "12px",
|
|
1747
|
-
display: "grid",
|
|
1748
|
-
gap: "12px"
|
|
1749
|
-
},
|
|
1691
|
+
className: "cpk:mt-3 cpk:grid cpk:gap-3",
|
|
1750
1692
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1751
|
-
|
|
1752
|
-
fontSize: "10px",
|
|
1753
|
-
textTransform: "uppercase",
|
|
1754
|
-
letterSpacing: "0.05em",
|
|
1755
|
-
color: "#71717a"
|
|
1756
|
-
},
|
|
1693
|
+
className: "cpk:text-[10px] cpk:uppercase cpk:text-zinc-500 cpk:dark:text-zinc-400",
|
|
1757
1694
|
children: "Arguments"
|
|
1758
1695
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
|
|
1759
|
-
|
|
1760
|
-
marginTop: "6px",
|
|
1761
|
-
maxHeight: "200px",
|
|
1762
|
-
overflow: "auto",
|
|
1763
|
-
borderRadius: "6px",
|
|
1764
|
-
backgroundColor: "#f4f4f5",
|
|
1765
|
-
padding: "10px",
|
|
1766
|
-
fontSize: "11px",
|
|
1767
|
-
lineHeight: 1.6,
|
|
1768
|
-
color: "#27272a",
|
|
1769
|
-
whiteSpace: "pre-wrap",
|
|
1770
|
-
wordBreak: "break-word"
|
|
1771
|
-
},
|
|
1696
|
+
className: "cpk:mt-1.5 cpk:max-h-[200px] cpk:overflow-auto cpk:rounded-md cpk:bg-zinc-100 cpk:p-2.5 cpk:text-[11px] cpk:leading-relaxed cpk:text-zinc-800 cpk:whitespace-pre-wrap cpk:break-words cpk:dark:bg-zinc-800/60 cpk:dark:text-zinc-200",
|
|
1772
1697
|
children: safeStringifyForPre(parameters ?? {})
|
|
1773
1698
|
})] }), result !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1774
|
-
|
|
1775
|
-
fontSize: "10px",
|
|
1776
|
-
textTransform: "uppercase",
|
|
1777
|
-
letterSpacing: "0.05em",
|
|
1778
|
-
color: "#71717a"
|
|
1779
|
-
},
|
|
1699
|
+
className: "cpk:text-[10px] cpk:uppercase cpk:text-zinc-500 cpk:dark:text-zinc-400",
|
|
1780
1700
|
children: "Result"
|
|
1781
1701
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
|
|
1782
|
-
|
|
1783
|
-
marginTop: "6px",
|
|
1784
|
-
maxHeight: "200px",
|
|
1785
|
-
overflow: "auto",
|
|
1786
|
-
borderRadius: "6px",
|
|
1787
|
-
backgroundColor: "#f4f4f5",
|
|
1788
|
-
padding: "10px",
|
|
1789
|
-
fontSize: "11px",
|
|
1790
|
-
lineHeight: 1.6,
|
|
1791
|
-
color: "#27272a",
|
|
1792
|
-
whiteSpace: "pre-wrap",
|
|
1793
|
-
wordBreak: "break-word"
|
|
1794
|
-
},
|
|
1702
|
+
className: "cpk:mt-1.5 cpk:max-h-[200px] cpk:overflow-auto cpk:rounded-md cpk:bg-zinc-100 cpk:p-2.5 cpk:text-[11px] cpk:leading-relaxed cpk:text-zinc-800 cpk:whitespace-pre-wrap cpk:break-words cpk:dark:bg-zinc-800/60 cpk:dark:text-zinc-200",
|
|
1795
1703
|
children: typeof result === "string" ? result : safeStringifyForPre(result)
|
|
1796
1704
|
})] })]
|
|
1797
1705
|
})]
|
|
@@ -4731,18 +4639,25 @@ function useInterrupt(config) {
|
|
|
4731
4639
|
},
|
|
4732
4640
|
onRunFailed: () => {
|
|
4733
4641
|
localInterrupt = null;
|
|
4642
|
+
setPendingEvent(null);
|
|
4734
4643
|
}
|
|
4735
4644
|
});
|
|
4736
4645
|
return () => subscription.unsubscribe();
|
|
4737
4646
|
}, [agent]);
|
|
4738
|
-
const resolve = (0, react.useCallback)((response) => {
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4647
|
+
const resolve = (0, react.useCallback)(async (response) => {
|
|
4648
|
+
try {
|
|
4649
|
+
return await copilotkit.runAgent({
|
|
4650
|
+
agent,
|
|
4651
|
+
forwardedProps: { command: {
|
|
4652
|
+
resume: response,
|
|
4653
|
+
interruptEvent: pendingEventRef.current?.value
|
|
4654
|
+
} }
|
|
4655
|
+
});
|
|
4656
|
+
} catch (err) {
|
|
4657
|
+
console.error("[CopilotKit] useInterrupt resolve: runAgent rejected; clearing pending + rethrowing", err);
|
|
4658
|
+
setPendingEvent(null);
|
|
4659
|
+
throw err;
|
|
4660
|
+
}
|
|
4746
4661
|
}, [agent, copilotkit]);
|
|
4747
4662
|
const renderRef = (0, react.useRef)(config.render);
|
|
4748
4663
|
renderRef.current = config.render;
|
|
@@ -7111,7 +7026,6 @@ const LastUserMessageContext = react.default.createContext({
|
|
|
7111
7026
|
function usePinToSend({ scrollRef, contentRef, spacerRef, topOffset = 16 }) {
|
|
7112
7027
|
const { id, sendNonce } = (0, react.useContext)(LastUserMessageContext);
|
|
7113
7028
|
const lastNonceRef = (0, react.useRef)(-1);
|
|
7114
|
-
const currentSpacerHeightRef = (0, react.useRef)(0);
|
|
7115
7029
|
(0, react.useEffect)(() => {
|
|
7116
7030
|
if (sendNonce === lastNonceRef.current) return;
|
|
7117
7031
|
lastNonceRef.current = sendNonce;
|
|
@@ -7129,7 +7043,6 @@ function usePinToSend({ scrollRef, contentRef, spacerRef, topOffset = 16 }) {
|
|
|
7129
7043
|
const bubbleHeight = Math.max(0, userMessageHeight - paddingTop);
|
|
7130
7044
|
const spacerHeight = Math.max(0, viewportHeight - bubbleHeight - topOffset);
|
|
7131
7045
|
spacerEl.style.height = `${spacerHeight}px`;
|
|
7132
|
-
currentSpacerHeightRef.current = spacerHeight;
|
|
7133
7046
|
const raf = requestAnimationFrame(() => {
|
|
7134
7047
|
const targetTop = computeOffsetTop(targetEl, scrollEl) + paddingTop - topOffset;
|
|
7135
7048
|
scrollEl.scrollTo({
|
|
@@ -7141,10 +7054,7 @@ function usePinToSend({ scrollRef, contentRef, spacerRef, topOffset = 16 }) {
|
|
|
7141
7054
|
if (!contentEl || !spacerEl || !scrollEl) return;
|
|
7142
7055
|
const consumedBelow = contentEl.getBoundingClientRect().height - computeOffsetTop(targetEl, contentEl) - userMessageHeight;
|
|
7143
7056
|
const remaining = Math.max(0, spacerHeight - consumedBelow);
|
|
7144
|
-
|
|
7145
|
-
spacerEl.style.height = `${remaining}px`;
|
|
7146
|
-
currentSpacerHeightRef.current = remaining;
|
|
7147
|
-
}
|
|
7057
|
+
spacerEl.style.height = `${remaining}px`;
|
|
7148
7058
|
});
|
|
7149
7059
|
ro.observe(contentEl);
|
|
7150
7060
|
return () => {
|
|
@@ -7438,7 +7348,7 @@ function CopilotChatView({ messageView, input, scrollView, suggestionView, welco
|
|
|
7438
7348
|
}, []);
|
|
7439
7349
|
(0, react.useEffect)(() => {
|
|
7440
7350
|
if (mode === "pin-to-bottom") return;
|
|
7441
|
-
const scrollElement =
|
|
7351
|
+
const scrollElement = nonAutoScrollEl;
|
|
7442
7352
|
if (!scrollElement) return;
|
|
7443
7353
|
const checkScroll = () => {
|
|
7444
7354
|
setShowScrollButton(!(scrollElement.scrollHeight - scrollElement.scrollTop - scrollElement.clientHeight < 10));
|
|
@@ -7451,7 +7361,7 @@ function CopilotChatView({ messageView, input, scrollView, suggestionView, welco
|
|
|
7451
7361
|
scrollElement.removeEventListener("scroll", checkScroll);
|
|
7452
7362
|
resizeObserver.disconnect();
|
|
7453
7363
|
};
|
|
7454
|
-
}, [
|
|
7364
|
+
}, [nonAutoScrollEl, mode]);
|
|
7455
7365
|
if (!hasMounted) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
7456
7366
|
className: "cpk:h-full cpk:max-h-full cpk:flex cpk:flex-col cpk:min-h-0 cpk:overflow-y-auto cpk:overflow-x-hidden",
|
|
7457
7367
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -11176,4 +11086,4 @@ Object.defineProperty(exports, 'useToast', {
|
|
|
11176
11086
|
return useToast;
|
|
11177
11087
|
}
|
|
11178
11088
|
});
|
|
11179
|
-
//# sourceMappingURL=copilotkit-
|
|
11089
|
+
//# sourceMappingURL=copilotkit-CP5uyB2h.cjs.map
|