@copilotkitnext/react 0.0.28 → 0.0.30
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/index.d.mts +6 -7
- package/dist/index.d.ts +6 -7
- package/dist/index.js +21 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +60 -67
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.mjs
CHANGED
|
@@ -1364,7 +1364,7 @@ CopilotChatInput.AddMenuButton.displayName = "CopilotChatInput.AddMenuButton";
|
|
|
1364
1364
|
var CopilotChatInput_default = CopilotChatInput;
|
|
1365
1365
|
|
|
1366
1366
|
// src/components/chat/CopilotChatAssistantMessage.tsx
|
|
1367
|
-
import { useState as
|
|
1367
|
+
import { useState as useState7 } from "react";
|
|
1368
1368
|
import {
|
|
1369
1369
|
Copy,
|
|
1370
1370
|
Check as Check2,
|
|
@@ -1378,7 +1378,7 @@ import "katex/dist/katex.min.css";
|
|
|
1378
1378
|
import { Streamdown } from "streamdown";
|
|
1379
1379
|
|
|
1380
1380
|
// src/hooks/use-render-tool-call.tsx
|
|
1381
|
-
import React6, { useCallback as useCallback2, useEffect as useEffect5, useMemo as useMemo4, useState as
|
|
1381
|
+
import React6, { useCallback as useCallback2, useEffect as useEffect5, useMemo as useMemo4, useState as useState5, useSyncExternalStore } from "react";
|
|
1382
1382
|
import { ToolCallStatus } from "@copilotkitnext/core";
|
|
1383
1383
|
|
|
1384
1384
|
// src/providers/CopilotKitProvider.tsx
|
|
@@ -1388,8 +1388,8 @@ import {
|
|
|
1388
1388
|
useMemo as useMemo3,
|
|
1389
1389
|
useEffect as useEffect4,
|
|
1390
1390
|
useReducer,
|
|
1391
|
-
useRef as
|
|
1392
|
-
useState as
|
|
1391
|
+
useRef as useRef3,
|
|
1392
|
+
useState as useState4
|
|
1393
1393
|
} from "react";
|
|
1394
1394
|
import { z } from "zod";
|
|
1395
1395
|
|
|
@@ -1438,36 +1438,29 @@ var CopilotKitCoreReact = class extends CopilotKitCore {
|
|
|
1438
1438
|
// src/components/CopilotKitInspector.tsx
|
|
1439
1439
|
import * as React4 from "react";
|
|
1440
1440
|
import { createComponent } from "@lit-labs/react";
|
|
1441
|
-
import {
|
|
1442
|
-
WEB_INSPECTOR_TAG,
|
|
1443
|
-
WebInspectorElement,
|
|
1444
|
-
defineWebInspector
|
|
1445
|
-
} from "@copilotkitnext/web-inspector";
|
|
1446
1441
|
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
if (
|
|
1459
|
-
|
|
1460
|
-
}
|
|
1461
|
-
}, [core]);
|
|
1462
|
-
return /* @__PURE__ */ jsx7(
|
|
1463
|
-
CopilotKitInspectorBase,
|
|
1464
|
-
{
|
|
1465
|
-
...rest,
|
|
1466
|
-
ref: innerRef
|
|
1442
|
+
var CopilotKitInspector = ({ core, ...rest }) => {
|
|
1443
|
+
const [InspectorComponent, setInspectorComponent] = React4.useState(null);
|
|
1444
|
+
React4.useEffect(() => {
|
|
1445
|
+
let mounted = true;
|
|
1446
|
+
import("@copilotkitnext/web-inspector").then((mod) => {
|
|
1447
|
+
mod.defineWebInspector?.();
|
|
1448
|
+
const Component = createComponent({
|
|
1449
|
+
tagName: mod.WEB_INSPECTOR_TAG,
|
|
1450
|
+
elementClass: mod.WebInspectorElement,
|
|
1451
|
+
react: React4
|
|
1452
|
+
});
|
|
1453
|
+
if (mounted) {
|
|
1454
|
+
setInspectorComponent(() => Component);
|
|
1467
1455
|
}
|
|
1468
|
-
);
|
|
1469
|
-
|
|
1470
|
-
|
|
1456
|
+
});
|
|
1457
|
+
return () => {
|
|
1458
|
+
mounted = false;
|
|
1459
|
+
};
|
|
1460
|
+
}, []);
|
|
1461
|
+
if (!InspectorComponent) return null;
|
|
1462
|
+
return /* @__PURE__ */ jsx7(InspectorComponent, { ...rest, core: core ?? null });
|
|
1463
|
+
};
|
|
1471
1464
|
CopilotKitInspector.displayName = "CopilotKitInspector";
|
|
1472
1465
|
|
|
1473
1466
|
// src/providers/CopilotKitProvider.tsx
|
|
@@ -1478,7 +1471,7 @@ var CopilotKitContext = createContext2({
|
|
|
1478
1471
|
function useStableArrayProp(prop, warningMessage, isMeaningfulChange) {
|
|
1479
1472
|
const empty = useMemo3(() => [], []);
|
|
1480
1473
|
const value = prop ?? empty;
|
|
1481
|
-
const initial =
|
|
1474
|
+
const initial = useRef3(value);
|
|
1482
1475
|
useEffect4(() => {
|
|
1483
1476
|
if (warningMessage && value !== initial.current && (isMeaningfulChange ? isMeaningfulChange(initial.current, value) : true)) {
|
|
1484
1477
|
console.error(warningMessage);
|
|
@@ -1500,7 +1493,7 @@ var CopilotKitProvider = ({
|
|
|
1500
1493
|
showDevConsole = false,
|
|
1501
1494
|
useSingleEndpoint = false
|
|
1502
1495
|
}) => {
|
|
1503
|
-
const [shouldRenderInspector, setShouldRenderInspector] =
|
|
1496
|
+
const [shouldRenderInspector, setShouldRenderInspector] = useState4(false);
|
|
1504
1497
|
useEffect4(() => {
|
|
1505
1498
|
if (typeof window === "undefined") {
|
|
1506
1499
|
return;
|
|
@@ -1728,7 +1721,7 @@ function useRenderToolCall() {
|
|
|
1728
1721
|
const { copilotkit } = useCopilotKit();
|
|
1729
1722
|
const config = useCopilotChatConfiguration();
|
|
1730
1723
|
const agentId = config?.agentId ?? DEFAULT_AGENT_ID2;
|
|
1731
|
-
const [executingToolCallIds, setExecutingToolCallIds] =
|
|
1724
|
+
const [executingToolCallIds, setExecutingToolCallIds] = useState5(() => /* @__PURE__ */ new Set());
|
|
1732
1725
|
const renderToolCalls = useSyncExternalStore(
|
|
1733
1726
|
(callback) => {
|
|
1734
1727
|
return copilotkit.subscribe({
|
|
@@ -1931,11 +1924,11 @@ function useFrontendTool(tool, deps) {
|
|
|
1931
1924
|
}
|
|
1932
1925
|
|
|
1933
1926
|
// src/hooks/use-human-in-the-loop.tsx
|
|
1934
|
-
import { useCallback as useCallback4, useRef as
|
|
1927
|
+
import { useCallback as useCallback4, useRef as useRef4, useEffect as useEffect7 } from "react";
|
|
1935
1928
|
import React7 from "react";
|
|
1936
1929
|
function useHumanInTheLoop(tool, deps) {
|
|
1937
1930
|
const { copilotkit } = useCopilotKit();
|
|
1938
|
-
const resolvePromiseRef =
|
|
1931
|
+
const resolvePromiseRef = useRef4(null);
|
|
1939
1932
|
const respond = useCallback4(async (result) => {
|
|
1940
1933
|
if (resolvePromiseRef.current) {
|
|
1941
1934
|
resolvePromiseRef.current(result);
|
|
@@ -2099,17 +2092,17 @@ function useAgentContext(context) {
|
|
|
2099
2092
|
}
|
|
2100
2093
|
|
|
2101
2094
|
// src/hooks/use-suggestions.tsx
|
|
2102
|
-
import { useCallback as useCallback5, useEffect as useEffect10, useMemo as useMemo7, useState as
|
|
2095
|
+
import { useCallback as useCallback5, useEffect as useEffect10, useMemo as useMemo7, useState as useState6 } from "react";
|
|
2103
2096
|
import { DEFAULT_AGENT_ID as DEFAULT_AGENT_ID5 } from "@copilotkitnext/shared";
|
|
2104
2097
|
function useSuggestions({ agentId } = {}) {
|
|
2105
2098
|
const { copilotkit } = useCopilotKit();
|
|
2106
2099
|
const config = useCopilotChatConfiguration();
|
|
2107
2100
|
const resolvedAgentId = useMemo7(() => agentId ?? config?.agentId ?? DEFAULT_AGENT_ID5, [agentId, config?.agentId]);
|
|
2108
|
-
const [suggestions, setSuggestions] =
|
|
2101
|
+
const [suggestions, setSuggestions] = useState6(() => {
|
|
2109
2102
|
const result = copilotkit.getSuggestions(resolvedAgentId);
|
|
2110
2103
|
return result.suggestions;
|
|
2111
2104
|
});
|
|
2112
|
-
const [isLoading, setIsLoading] =
|
|
2105
|
+
const [isLoading, setIsLoading] = useState6(() => {
|
|
2113
2106
|
const result = copilotkit.getSuggestions(resolvedAgentId);
|
|
2114
2107
|
return result.isLoading;
|
|
2115
2108
|
});
|
|
@@ -2163,7 +2156,7 @@ function useSuggestions({ agentId } = {}) {
|
|
|
2163
2156
|
}
|
|
2164
2157
|
|
|
2165
2158
|
// src/hooks/use-configure-suggestions.tsx
|
|
2166
|
-
import { useCallback as useCallback6, useEffect as useEffect11, useMemo as useMemo8, useRef as
|
|
2159
|
+
import { useCallback as useCallback6, useEffect as useEffect11, useMemo as useMemo8, useRef as useRef5 } from "react";
|
|
2167
2160
|
import { DEFAULT_AGENT_ID as DEFAULT_AGENT_ID6 } from "@copilotkitnext/shared";
|
|
2168
2161
|
function useConfigureSuggestions(config, deps) {
|
|
2169
2162
|
const { copilotkit } = useCopilotKit();
|
|
@@ -2171,7 +2164,7 @@ function useConfigureSuggestions(config, deps) {
|
|
|
2171
2164
|
const extraDeps = deps ?? [];
|
|
2172
2165
|
const resolvedConsumerAgentId = useMemo8(() => chatConfig?.agentId ?? DEFAULT_AGENT_ID6, [chatConfig?.agentId]);
|
|
2173
2166
|
const rawConsumerAgentId = useMemo8(() => config ? config.consumerAgentId : void 0, [config]);
|
|
2174
|
-
const normalizationCacheRef =
|
|
2167
|
+
const normalizationCacheRef = useRef5({
|
|
2175
2168
|
serialized: null,
|
|
2176
2169
|
config: null
|
|
2177
2170
|
});
|
|
@@ -2205,9 +2198,9 @@ function useConfigureSuggestions(config, deps) {
|
|
|
2205
2198
|
normalizationCacheRef.current = { serialized, config: built };
|
|
2206
2199
|
return { normalizedConfig: built, serializedConfig: serialized };
|
|
2207
2200
|
}, [config, resolvedConsumerAgentId, ...extraDeps]);
|
|
2208
|
-
const latestConfigRef =
|
|
2201
|
+
const latestConfigRef = useRef5(null);
|
|
2209
2202
|
latestConfigRef.current = normalizedConfig;
|
|
2210
|
-
const previousSerializedConfigRef =
|
|
2203
|
+
const previousSerializedConfigRef = useRef5(null);
|
|
2211
2204
|
const targetAgentId = useMemo8(() => {
|
|
2212
2205
|
if (!normalizedConfig) {
|
|
2213
2206
|
return resolvedConsumerAgentId;
|
|
@@ -2474,7 +2467,7 @@ function CopilotChatAssistantMessage({
|
|
|
2474
2467
|
CopilotChatAssistantMessage2.CopyButton = ({ className, title, onClick, ...props }) => {
|
|
2475
2468
|
const config = useCopilotChatConfiguration();
|
|
2476
2469
|
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
2477
|
-
const [copied, setCopied] =
|
|
2470
|
+
const [copied, setCopied] = useState7(false);
|
|
2478
2471
|
const handleClick = (event) => {
|
|
2479
2472
|
setCopied(true);
|
|
2480
2473
|
setTimeout(() => setCopied(false), 2e3);
|
|
@@ -2552,7 +2545,7 @@ CopilotChatAssistantMessage.RegenerateButton.displayName = "CopilotChatAssistant
|
|
|
2552
2545
|
var CopilotChatAssistantMessage_default = CopilotChatAssistantMessage;
|
|
2553
2546
|
|
|
2554
2547
|
// src/components/chat/CopilotChatUserMessage.tsx
|
|
2555
|
-
import { useMemo as useMemo9, useState as
|
|
2548
|
+
import { useMemo as useMemo9, useState as useState8 } from "react";
|
|
2556
2549
|
import { Copy as Copy2, Check as Check3, Edit, ChevronLeft, ChevronRight } from "lucide-react";
|
|
2557
2550
|
import { twMerge as twMerge5 } from "tailwind-merge";
|
|
2558
2551
|
import { Fragment as Fragment4, jsx as jsx14, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
@@ -2715,7 +2708,7 @@ function CopilotChatUserMessage({
|
|
|
2715
2708
|
CopilotChatUserMessage2.CopyButton = ({ className, title, onClick, ...props }) => {
|
|
2716
2709
|
const config = useCopilotChatConfiguration();
|
|
2717
2710
|
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
2718
|
-
const [copied, setCopied] =
|
|
2711
|
+
const [copied, setCopied] = useState8(false);
|
|
2719
2712
|
const handleClick = (event) => {
|
|
2720
2713
|
setCopied(true);
|
|
2721
2714
|
setTimeout(() => setCopied(false), 2e3);
|
|
@@ -3115,15 +3108,15 @@ CopilotChatMessageView.Cursor = function Cursor({ className, ...props }) {
|
|
|
3115
3108
|
var CopilotChatMessageView_default = CopilotChatMessageView;
|
|
3116
3109
|
|
|
3117
3110
|
// src/components/chat/CopilotChatView.tsx
|
|
3118
|
-
import React12, { useRef as
|
|
3111
|
+
import React12, { useRef as useRef6, useState as useState10, useEffect as useEffect13 } from "react";
|
|
3119
3112
|
import { twMerge as twMerge7 } from "tailwind-merge";
|
|
3120
3113
|
import { StickToBottom, useStickToBottom, useStickToBottomContext } from "use-stick-to-bottom";
|
|
3121
3114
|
import { ChevronDown } from "lucide-react";
|
|
3122
3115
|
|
|
3123
3116
|
// src/hooks/use-keyboard-height.tsx
|
|
3124
|
-
import { useState as
|
|
3117
|
+
import { useState as useState9, useEffect as useEffect12 } from "react";
|
|
3125
3118
|
function useKeyboardHeight() {
|
|
3126
|
-
const [keyboardState, setKeyboardState] =
|
|
3119
|
+
const [keyboardState, setKeyboardState] = useState9({
|
|
3127
3120
|
isKeyboardOpen: false,
|
|
3128
3121
|
keyboardHeight: 0,
|
|
3129
3122
|
availableHeight: typeof window !== "undefined" ? window.innerHeight : 0,
|
|
@@ -3182,10 +3175,10 @@ function CopilotChatView({
|
|
|
3182
3175
|
className,
|
|
3183
3176
|
...props
|
|
3184
3177
|
}) {
|
|
3185
|
-
const inputContainerRef =
|
|
3186
|
-
const [inputContainerHeight, setInputContainerHeight] =
|
|
3187
|
-
const [isResizing, setIsResizing] =
|
|
3188
|
-
const resizeTimeoutRef =
|
|
3178
|
+
const inputContainerRef = useRef6(null);
|
|
3179
|
+
const [inputContainerHeight, setInputContainerHeight] = useState10(0);
|
|
3180
|
+
const [isResizing, setIsResizing] = useState10(false);
|
|
3181
|
+
const resizeTimeoutRef = useRef6(null);
|
|
3189
3182
|
const { isKeyboardOpen, keyboardHeight, availableHeight } = useKeyboardHeight();
|
|
3190
3183
|
useEffect13(() => {
|
|
3191
3184
|
const element = inputContainerRef.current;
|
|
@@ -3296,9 +3289,9 @@ function CopilotChatView({
|
|
|
3296
3289
|
className,
|
|
3297
3290
|
...props
|
|
3298
3291
|
}) => {
|
|
3299
|
-
const [hasMounted, setHasMounted] =
|
|
3292
|
+
const [hasMounted, setHasMounted] = useState10(false);
|
|
3300
3293
|
const { scrollRef, contentRef, scrollToBottom } = useStickToBottom();
|
|
3301
|
-
const [showScrollButton, setShowScrollButton] =
|
|
3294
|
+
const [showScrollButton, setShowScrollButton] = useState10(false);
|
|
3302
3295
|
useEffect13(() => {
|
|
3303
3296
|
setHasMounted(true);
|
|
3304
3297
|
}, []);
|
|
@@ -3556,7 +3549,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
3556
3549
|
})(CopilotChat || (CopilotChat = {}));
|
|
3557
3550
|
|
|
3558
3551
|
// src/components/chat/CopilotChatToggleButton.tsx
|
|
3559
|
-
import React13, { useState as
|
|
3552
|
+
import React13, { useState as useState11 } from "react";
|
|
3560
3553
|
import { MessageCircle, X as X2 } from "lucide-react";
|
|
3561
3554
|
import { jsx as jsx20, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
3562
3555
|
var DefaultOpenIcon = ({
|
|
@@ -3587,7 +3580,7 @@ var CopilotChatToggleButton = React13.forwardRef(function CopilotChatToggleButto
|
|
|
3587
3580
|
const { onClick, type, disabled, ...restProps } = buttonProps;
|
|
3588
3581
|
const configuration = useCopilotChatConfiguration();
|
|
3589
3582
|
const labels = configuration?.labels ?? CopilotChatDefaultLabels;
|
|
3590
|
-
const [fallbackOpen, setFallbackOpen] =
|
|
3583
|
+
const [fallbackOpen, setFallbackOpen] = useState11(false);
|
|
3591
3584
|
const isOpen = configuration?.isModalOpen ?? fallbackOpen;
|
|
3592
3585
|
const setModalOpen = configuration?.setModalOpen ?? setFallbackOpen;
|
|
3593
3586
|
const handleClick = (event) => {
|
|
@@ -3673,7 +3666,7 @@ CopilotChatToggleButton.displayName = "CopilotChatToggleButton";
|
|
|
3673
3666
|
var CopilotChatToggleButton_default = CopilotChatToggleButton;
|
|
3674
3667
|
|
|
3675
3668
|
// src/components/chat/CopilotSidebarView.tsx
|
|
3676
|
-
import { useEffect as useEffect15, useRef as
|
|
3669
|
+
import { useEffect as useEffect15, useRef as useRef7, useState as useState12 } from "react";
|
|
3677
3670
|
|
|
3678
3671
|
// src/components/chat/CopilotModalHeader.tsx
|
|
3679
3672
|
import { useCallback as useCallback8 } from "react";
|
|
@@ -3766,8 +3759,8 @@ var SIDEBAR_TRANSITION_MS = 260;
|
|
|
3766
3759
|
function CopilotSidebarView({ header, width, ...props }) {
|
|
3767
3760
|
const configuration = useCopilotChatConfiguration();
|
|
3768
3761
|
const isSidebarOpen = configuration?.isModalOpen ?? false;
|
|
3769
|
-
const sidebarRef =
|
|
3770
|
-
const [sidebarWidth, setSidebarWidth] =
|
|
3762
|
+
const sidebarRef = useRef7(null);
|
|
3763
|
+
const [sidebarWidth, setSidebarWidth] = useState12(width ?? DEFAULT_SIDEBAR_WIDTH);
|
|
3771
3764
|
const widthToCss = (w) => {
|
|
3772
3765
|
return typeof w === "number" ? `${w}px` : w;
|
|
3773
3766
|
};
|
|
@@ -3856,7 +3849,7 @@ function CopilotSidebarView({ header, width, ...props }) {
|
|
|
3856
3849
|
CopilotSidebarView.displayName = "CopilotSidebarView";
|
|
3857
3850
|
|
|
3858
3851
|
// src/components/chat/CopilotPopupView.tsx
|
|
3859
|
-
import { useEffect as useEffect16, useMemo as useMemo11, useRef as
|
|
3852
|
+
import { useEffect as useEffect16, useMemo as useMemo11, useRef as useRef8, useState as useState13 } from "react";
|
|
3860
3853
|
import { Fragment as Fragment8, jsx as jsx23, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
3861
3854
|
var DEFAULT_POPUP_WIDTH = 420;
|
|
3862
3855
|
var DEFAULT_POPUP_HEIGHT = 560;
|
|
@@ -3881,9 +3874,9 @@ function CopilotPopupView({
|
|
|
3881
3874
|
const isPopupOpen = configuration?.isModalOpen ?? false;
|
|
3882
3875
|
const setModalOpen = configuration?.setModalOpen;
|
|
3883
3876
|
const labels = configuration?.labels ?? CopilotChatDefaultLabels;
|
|
3884
|
-
const containerRef =
|
|
3885
|
-
const [isRendered, setIsRendered] =
|
|
3886
|
-
const [isAnimatingOut, setIsAnimatingOut] =
|
|
3877
|
+
const containerRef = useRef8(null);
|
|
3878
|
+
const [isRendered, setIsRendered] = useState13(isPopupOpen);
|
|
3879
|
+
const [isAnimatingOut, setIsAnimatingOut] = useState13(false);
|
|
3887
3880
|
useEffect16(() => {
|
|
3888
3881
|
if (isPopupOpen) {
|
|
3889
3882
|
setIsRendered(true);
|
|
@@ -4100,12 +4093,12 @@ function defineToolCallRenderer(def) {
|
|
|
4100
4093
|
}
|
|
4101
4094
|
|
|
4102
4095
|
// src/components/WildcardToolCallRender.tsx
|
|
4103
|
-
import { useState as
|
|
4096
|
+
import { useState as useState14 } from "react";
|
|
4104
4097
|
import { jsx as jsx26, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
4105
4098
|
var WildcardToolCallRender = defineToolCallRenderer({
|
|
4106
4099
|
name: "*",
|
|
4107
4100
|
render: ({ args, result, name, status }) => {
|
|
4108
|
-
const [isExpanded, setIsExpanded] =
|
|
4101
|
+
const [isExpanded, setIsExpanded] = useState14(false);
|
|
4109
4102
|
const statusString = String(status);
|
|
4110
4103
|
const isActive = statusString === "inProgress" || statusString === "executing";
|
|
4111
4104
|
const isComplete = statusString === "complete";
|