@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.
Files changed (40) hide show
  1. package/dist/{copilotkit-BTHcCAVQ.cjs → copilotkit-CP5uyB2h.cjs} +43 -133
  2. package/dist/copilotkit-CP5uyB2h.cjs.map +1 -0
  3. package/dist/{copilotkit-C9ptuh-b.d.cts → copilotkit-CyL6ZsLP.d.cts} +7 -7
  4. package/dist/{copilotkit-DvbI8G0d.d.mts.map → copilotkit-CyL6ZsLP.d.cts.map} +1 -1
  5. package/dist/{copilotkit-CV519nFv.mjs → copilotkit-DheptEiV.mjs} +43 -133
  6. package/dist/copilotkit-DheptEiV.mjs.map +1 -0
  7. package/dist/{copilotkit-DvbI8G0d.d.mts → copilotkit-UaQ7KSUq.d.mts} +7 -7
  8. package/dist/{copilotkit-C9ptuh-b.d.cts.map → copilotkit-UaQ7KSUq.d.mts.map} +1 -1
  9. package/dist/index.cjs +6 -6
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.cts +3 -3
  12. package/dist/index.d.mts +3 -3
  13. package/dist/index.mjs +6 -6
  14. package/dist/index.mjs.map +1 -1
  15. package/dist/index.umd.js +44 -129
  16. package/dist/index.umd.js.map +1 -1
  17. package/dist/v2/context.cjs +8 -3
  18. package/dist/v2/context.cjs.map +1 -1
  19. package/dist/v2/context.d.cts.map +1 -1
  20. package/dist/v2/context.d.mts.map +1 -1
  21. package/dist/v2/context.mjs +8 -3
  22. package/dist/v2/context.mjs.map +1 -1
  23. package/dist/v2/headless.cjs +15 -8
  24. package/dist/v2/headless.cjs.map +1 -1
  25. package/dist/v2/headless.d.cts +3 -3
  26. package/dist/v2/headless.d.cts.map +1 -1
  27. package/dist/v2/headless.d.mts +3 -3
  28. package/dist/v2/headless.d.mts.map +1 -1
  29. package/dist/v2/headless.mjs +15 -8
  30. package/dist/v2/headless.mjs.map +1 -1
  31. package/dist/v2/index.cjs +1 -1
  32. package/dist/v2/index.css +1 -1
  33. package/dist/v2/index.d.cts +1 -1
  34. package/dist/v2/index.d.mts +1 -1
  35. package/dist/v2/index.mjs +1 -1
  36. package/dist/v2/index.umd.js +42 -132
  37. package/dist/v2/index.umd.js.map +1 -1
  38. package/package.json +6 -6
  39. package/dist/copilotkit-BTHcCAVQ.cjs.map +0 -1
  40. package/dist/copilotkit-CV519nFv.mjs.map +0 -1
@@ -1414,9 +1414,14 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
1414
1414
  const [, forceUpdate] = (0, react.useReducer)((x) => x + 1, 0);
1415
1415
  if (!context) throw new Error("useCopilotKit must be used within CopilotKitProvider");
1416
1416
  (0, react.useEffect)(() => {
1417
- const subscription = context.copilotkit.subscribe({ onRuntimeConnectionStatusChanged: () => {
1418
- forceUpdate();
1419
- } });
1417
+ const subscription = context.copilotkit.subscribe({
1418
+ onRuntimeConnectionStatusChanged: () => {
1419
+ forceUpdate();
1420
+ },
1421
+ onHeadersChanged: () => {
1422
+ forceUpdate();
1423
+ }
1424
+ });
1420
1425
  return () => {
1421
1426
  subscription.unsubscribe();
1422
1427
  };
@@ -1623,9 +1628,8 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
1623
1628
  const isActive = status === "inProgress" || status === "executing";
1624
1629
  const isComplete = status === "complete";
1625
1630
  const statusLabel = isActive ? "Running" : isComplete ? "Done" : status;
1626
- const dotColor = isActive ? "#f59e0b" : isComplete ? "#10b981" : "#a1a1aa";
1627
- const badgeBg = isActive ? "#fef3c7" : isComplete ? "#d1fae5" : "#f4f4f5";
1628
- const badgeColor = isActive ? "#92400e" : isComplete ? "#065f46" : "#3f3f46";
1631
+ const dotClassName = isActive ? "cpk:bg-amber-500" : isComplete ? "cpk:bg-emerald-500" : "cpk:bg-zinc-400";
1632
+ 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";
1629
1633
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1630
1634
  "data-testid": "copilot-tool-render",
1631
1635
  "data-tool-name": name,
@@ -1633,54 +1637,20 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
1633
1637
  "data-status": status,
1634
1638
  "data-args": safeStringifyForAttr(parameters),
1635
1639
  "data-result": safeStringifyForAttr(result),
1636
- style: {
1637
- marginTop: "8px",
1638
- paddingBottom: "8px"
1639
- },
1640
+ className: "cpk:mt-2 cpk:pb-2",
1640
1641
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1641
- style: {
1642
- borderRadius: "12px",
1643
- border: "1px solid #e4e4e7",
1644
- backgroundColor: "#fafafa",
1645
- padding: "14px 16px"
1646
- },
1642
+ 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",
1647
1643
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1648
1644
  type: "button",
1649
1645
  "aria-expanded": isExpanded,
1650
1646
  onClick: () => setIsExpanded(!isExpanded),
1651
- style: {
1652
- display: "flex",
1653
- alignItems: "center",
1654
- justifyContent: "space-between",
1655
- gap: "10px",
1656
- cursor: "pointer",
1657
- userSelect: "none",
1658
- width: "100%",
1659
- border: "none",
1660
- padding: 0,
1661
- margin: 0,
1662
- background: "transparent",
1663
- textAlign: "left",
1664
- font: "inherit",
1665
- color: "inherit"
1666
- },
1647
+ 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",
1648
+ style: { font: "inherit" },
1667
1649
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1668
- style: {
1669
- display: "flex",
1670
- alignItems: "center",
1671
- gap: "8px",
1672
- minWidth: 0
1673
- },
1650
+ className: "cpk:flex cpk:min-w-0 cpk:items-center cpk:gap-2",
1674
1651
  children: [
1675
1652
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
1676
- style: {
1677
- height: "14px",
1678
- width: "14px",
1679
- color: "#71717a",
1680
- transition: "transform 0.15s",
1681
- transform: isExpanded ? "rotate(90deg)" : "rotate(0deg)",
1682
- flexShrink: 0
1683
- },
1653
+ 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" : ""}`,
1684
1654
  fill: "none",
1685
1655
  viewBox: "0 0 24 24",
1686
1656
  strokeWidth: 2,
@@ -1691,93 +1661,31 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
1691
1661
  d: "M8.25 4.5l7.5 7.5-7.5 7.5"
1692
1662
  })
1693
1663
  }),
1694
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { style: {
1695
- display: "inline-block",
1696
- height: "8px",
1697
- width: "8px",
1698
- borderRadius: "50%",
1699
- backgroundColor: dotColor,
1700
- flexShrink: 0
1701
- } }),
1664
+ /* @__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}` }),
1702
1665
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1703
1666
  "data-testid": "copilot-tool-render-name",
1704
- style: {
1705
- fontSize: "13px",
1706
- fontWeight: 600,
1707
- color: "#18181b",
1708
- overflow: "hidden",
1709
- textOverflow: "ellipsis",
1710
- whiteSpace: "nowrap"
1711
- },
1667
+ className: "cpk:truncate cpk:text-[13px] cpk:font-semibold cpk:text-zinc-900 cpk:dark:text-zinc-100",
1712
1668
  children: name
1713
1669
  })
1714
1670
  ]
1715
1671
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1716
1672
  "data-testid": "copilot-tool-render-status",
1717
- style: {
1718
- display: "inline-flex",
1719
- alignItems: "center",
1720
- borderRadius: "9999px",
1721
- padding: "2px 8px",
1722
- fontSize: "11px",
1723
- fontWeight: 500,
1724
- backgroundColor: badgeBg,
1725
- color: badgeColor,
1726
- flexShrink: 0
1727
- },
1673
+ 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}`,
1728
1674
  children: statusLabel
1729
1675
  })]
1730
1676
  }), isExpanded && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1731
- style: {
1732
- marginTop: "12px",
1733
- display: "grid",
1734
- gap: "12px"
1735
- },
1677
+ className: "cpk:mt-3 cpk:grid cpk:gap-3",
1736
1678
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1737
- style: {
1738
- fontSize: "10px",
1739
- textTransform: "uppercase",
1740
- letterSpacing: "0.05em",
1741
- color: "#71717a"
1742
- },
1679
+ className: "cpk:text-[10px] cpk:uppercase cpk:text-zinc-500 cpk:dark:text-zinc-400",
1743
1680
  children: "Arguments"
1744
1681
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
1745
- style: {
1746
- marginTop: "6px",
1747
- maxHeight: "200px",
1748
- overflow: "auto",
1749
- borderRadius: "6px",
1750
- backgroundColor: "#f4f4f5",
1751
- padding: "10px",
1752
- fontSize: "11px",
1753
- lineHeight: 1.6,
1754
- color: "#27272a",
1755
- whiteSpace: "pre-wrap",
1756
- wordBreak: "break-word"
1757
- },
1682
+ 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",
1758
1683
  children: safeStringifyForPre(parameters ?? {})
1759
1684
  })] }), result !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1760
- style: {
1761
- fontSize: "10px",
1762
- textTransform: "uppercase",
1763
- letterSpacing: "0.05em",
1764
- color: "#71717a"
1765
- },
1685
+ className: "cpk:text-[10px] cpk:uppercase cpk:text-zinc-500 cpk:dark:text-zinc-400",
1766
1686
  children: "Result"
1767
1687
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
1768
- style: {
1769
- marginTop: "6px",
1770
- maxHeight: "200px",
1771
- overflow: "auto",
1772
- borderRadius: "6px",
1773
- backgroundColor: "#f4f4f5",
1774
- padding: "10px",
1775
- fontSize: "11px",
1776
- lineHeight: 1.6,
1777
- color: "#27272a",
1778
- whiteSpace: "pre-wrap",
1779
- wordBreak: "break-word"
1780
- },
1688
+ 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",
1781
1689
  children: typeof result === "string" ? result : safeStringifyForPre(result)
1782
1690
  })] })]
1783
1691
  })]
@@ -4717,18 +4625,25 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
4717
4625
  },
4718
4626
  onRunFailed: () => {
4719
4627
  localInterrupt = null;
4628
+ setPendingEvent(null);
4720
4629
  }
4721
4630
  });
4722
4631
  return () => subscription.unsubscribe();
4723
4632
  }, [agent]);
4724
- const resolve = (0, react.useCallback)((response) => {
4725
- copilotkit.runAgent({
4726
- agent,
4727
- forwardedProps: { command: {
4728
- resume: response,
4729
- interruptEvent: pendingEventRef.current?.value
4730
- } }
4731
- });
4633
+ const resolve = (0, react.useCallback)(async (response) => {
4634
+ try {
4635
+ return await copilotkit.runAgent({
4636
+ agent,
4637
+ forwardedProps: { command: {
4638
+ resume: response,
4639
+ interruptEvent: pendingEventRef.current?.value
4640
+ } }
4641
+ });
4642
+ } catch (err) {
4643
+ console.error("[CopilotKit] useInterrupt resolve: runAgent rejected; clearing pending + rethrowing", err);
4644
+ setPendingEvent(null);
4645
+ throw err;
4646
+ }
4732
4647
  }, [agent, copilotkit]);
4733
4648
  const renderRef = (0, react.useRef)(config.render);
4734
4649
  renderRef.current = config.render;
@@ -7097,7 +7012,6 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
7097
7012
  function usePinToSend({ scrollRef, contentRef, spacerRef, topOffset = 16 }) {
7098
7013
  const { id, sendNonce } = (0, react.useContext)(LastUserMessageContext);
7099
7014
  const lastNonceRef = (0, react.useRef)(-1);
7100
- const currentSpacerHeightRef = (0, react.useRef)(0);
7101
7015
  (0, react.useEffect)(() => {
7102
7016
  if (sendNonce === lastNonceRef.current) return;
7103
7017
  lastNonceRef.current = sendNonce;
@@ -7115,7 +7029,6 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
7115
7029
  const bubbleHeight = Math.max(0, userMessageHeight - paddingTop);
7116
7030
  const spacerHeight = Math.max(0, viewportHeight - bubbleHeight - topOffset);
7117
7031
  spacerEl.style.height = `${spacerHeight}px`;
7118
- currentSpacerHeightRef.current = spacerHeight;
7119
7032
  const raf = requestAnimationFrame(() => {
7120
7033
  const targetTop = computeOffsetTop(targetEl, scrollEl) + paddingTop - topOffset;
7121
7034
  scrollEl.scrollTo({
@@ -7127,10 +7040,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
7127
7040
  if (!contentEl || !spacerEl || !scrollEl) return;
7128
7041
  const consumedBelow = contentEl.getBoundingClientRect().height - computeOffsetTop(targetEl, contentEl) - userMessageHeight;
7129
7042
  const remaining = Math.max(0, spacerHeight - consumedBelow);
7130
- if (remaining < currentSpacerHeightRef.current) {
7131
- spacerEl.style.height = `${remaining}px`;
7132
- currentSpacerHeightRef.current = remaining;
7133
- }
7043
+ spacerEl.style.height = `${remaining}px`;
7134
7044
  });
7135
7045
  ro.observe(contentEl);
7136
7046
  return () => {
@@ -7424,7 +7334,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
7424
7334
  }, []);
7425
7335
  (0, react.useEffect)(() => {
7426
7336
  if (mode === "pin-to-bottom") return;
7427
- const scrollElement = scrollRef.current;
7337
+ const scrollElement = nonAutoScrollEl;
7428
7338
  if (!scrollElement) return;
7429
7339
  const checkScroll = () => {
7430
7340
  setShowScrollButton(!(scrollElement.scrollHeight - scrollElement.scrollTop - scrollElement.clientHeight < 10));
@@ -7437,7 +7347,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
7437
7347
  scrollElement.removeEventListener("scroll", checkScroll);
7438
7348
  resizeObserver.disconnect();
7439
7349
  };
7440
- }, [scrollRef, mode]);
7350
+ }, [nonAutoScrollEl, mode]);
7441
7351
  if (!hasMounted) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
7442
7352
  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",
7443
7353
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {