@copilotkitnext/react 0.0.29 → 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.js +21 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +80 -74
- 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
|
|
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
|
|
@@ -1386,10 +1386,10 @@ import {
|
|
|
1386
1386
|
createContext as createContext2,
|
|
1387
1387
|
useContext as useContext2,
|
|
1388
1388
|
useMemo as useMemo3,
|
|
1389
|
-
useEffect as
|
|
1389
|
+
useEffect as useEffect4,
|
|
1390
1390
|
useReducer,
|
|
1391
1391
|
useRef as useRef3,
|
|
1392
|
-
useState as
|
|
1392
|
+
useState as useState4
|
|
1393
1393
|
} from "react";
|
|
1394
1394
|
import { z } from "zod";
|
|
1395
1395
|
|
|
@@ -1439,22 +1439,28 @@ var CopilotKitCoreReact = class extends CopilotKitCore {
|
|
|
1439
1439
|
import * as React4 from "react";
|
|
1440
1440
|
import { createComponent } from "@lit-labs/react";
|
|
1441
1441
|
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
1442
|
-
var
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
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);
|
|
1455
|
+
}
|
|
1453
1456
|
});
|
|
1454
|
-
return
|
|
1455
|
-
|
|
1456
|
-
}
|
|
1457
|
-
|
|
1457
|
+
return () => {
|
|
1458
|
+
mounted = false;
|
|
1459
|
+
};
|
|
1460
|
+
}, []);
|
|
1461
|
+
if (!InspectorComponent) return null;
|
|
1462
|
+
return /* @__PURE__ */ jsx7(InspectorComponent, { ...rest, core: core ?? null });
|
|
1463
|
+
};
|
|
1458
1464
|
CopilotKitInspector.displayName = "CopilotKitInspector";
|
|
1459
1465
|
|
|
1460
1466
|
// src/providers/CopilotKitProvider.tsx
|
|
@@ -1466,7 +1472,7 @@ function useStableArrayProp(prop, warningMessage, isMeaningfulChange) {
|
|
|
1466
1472
|
const empty = useMemo3(() => [], []);
|
|
1467
1473
|
const value = prop ?? empty;
|
|
1468
1474
|
const initial = useRef3(value);
|
|
1469
|
-
|
|
1475
|
+
useEffect4(() => {
|
|
1470
1476
|
if (warningMessage && value !== initial.current && (isMeaningfulChange ? isMeaningfulChange(initial.current, value) : true)) {
|
|
1471
1477
|
console.error(warningMessage);
|
|
1472
1478
|
}
|
|
@@ -1487,8 +1493,8 @@ var CopilotKitProvider = ({
|
|
|
1487
1493
|
showDevConsole = false,
|
|
1488
1494
|
useSingleEndpoint = false
|
|
1489
1495
|
}) => {
|
|
1490
|
-
const [shouldRenderInspector, setShouldRenderInspector] =
|
|
1491
|
-
|
|
1496
|
+
const [shouldRenderInspector, setShouldRenderInspector] = useState4(false);
|
|
1497
|
+
useEffect4(() => {
|
|
1492
1498
|
if (typeof window === "undefined") {
|
|
1493
1499
|
return;
|
|
1494
1500
|
}
|
|
@@ -1601,7 +1607,7 @@ var CopilotKitProvider = ({
|
|
|
1601
1607
|
return copilotkit2;
|
|
1602
1608
|
}, [allTools, allRenderToolCalls, renderActivityMessagesList, renderCustomMessagesList, useSingleEndpoint]);
|
|
1603
1609
|
const [, forceUpdate] = useReducer((x) => x + 1, 0);
|
|
1604
|
-
|
|
1610
|
+
useEffect4(() => {
|
|
1605
1611
|
const subscription = copilotkit.subscribe({
|
|
1606
1612
|
onRenderToolCallsChanged: () => {
|
|
1607
1613
|
forceUpdate();
|
|
@@ -1611,7 +1617,7 @@ var CopilotKitProvider = ({
|
|
|
1611
1617
|
subscription.unsubscribe();
|
|
1612
1618
|
};
|
|
1613
1619
|
}, [copilotkit]);
|
|
1614
|
-
|
|
1620
|
+
useEffect4(() => {
|
|
1615
1621
|
copilotkit.setRuntimeUrl(runtimeUrl);
|
|
1616
1622
|
copilotkit.setRuntimeTransport(useSingleEndpoint ? "single" : "rest");
|
|
1617
1623
|
copilotkit.setHeaders(headers);
|
|
@@ -1637,7 +1643,7 @@ var useCopilotKit = () => {
|
|
|
1637
1643
|
if (!context) {
|
|
1638
1644
|
throw new Error("useCopilotKit must be used within CopilotKitProvider");
|
|
1639
1645
|
}
|
|
1640
|
-
|
|
1646
|
+
useEffect4(() => {
|
|
1641
1647
|
const subscription = context.copilotkit.subscribe({
|
|
1642
1648
|
onRuntimeConnectionStatusChanged: () => {
|
|
1643
1649
|
forceUpdate();
|
|
@@ -1715,7 +1721,7 @@ function useRenderToolCall() {
|
|
|
1715
1721
|
const { copilotkit } = useCopilotKit();
|
|
1716
1722
|
const config = useCopilotChatConfiguration();
|
|
1717
1723
|
const agentId = config?.agentId ?? DEFAULT_AGENT_ID2;
|
|
1718
|
-
const [executingToolCallIds, setExecutingToolCallIds] =
|
|
1724
|
+
const [executingToolCallIds, setExecutingToolCallIds] = useState5(() => /* @__PURE__ */ new Set());
|
|
1719
1725
|
const renderToolCalls = useSyncExternalStore(
|
|
1720
1726
|
(callback) => {
|
|
1721
1727
|
return copilotkit.subscribe({
|
|
@@ -1725,7 +1731,7 @@ function useRenderToolCall() {
|
|
|
1725
1731
|
() => copilotkit.renderToolCalls,
|
|
1726
1732
|
() => copilotkit.renderToolCalls
|
|
1727
1733
|
);
|
|
1728
|
-
|
|
1734
|
+
useEffect5(() => {
|
|
1729
1735
|
const subscription = copilotkit.subscribe({
|
|
1730
1736
|
onToolExecutionStart: ({ toolCallId }) => {
|
|
1731
1737
|
setExecutingToolCallIds((prev) => {
|
|
@@ -1881,12 +1887,12 @@ function useRenderActivityMessage() {
|
|
|
1881
1887
|
}
|
|
1882
1888
|
|
|
1883
1889
|
// src/hooks/use-frontend-tool.tsx
|
|
1884
|
-
import { useEffect as
|
|
1890
|
+
import { useEffect as useEffect6 } from "react";
|
|
1885
1891
|
var EMPTY_DEPS = [];
|
|
1886
1892
|
function useFrontendTool(tool, deps) {
|
|
1887
1893
|
const { copilotkit } = useCopilotKit();
|
|
1888
1894
|
const extraDeps = deps ?? EMPTY_DEPS;
|
|
1889
|
-
|
|
1895
|
+
useEffect6(() => {
|
|
1890
1896
|
const name = tool.name;
|
|
1891
1897
|
if (copilotkit.getTool({ toolName: name, agentId: tool.agentId })) {
|
|
1892
1898
|
console.warn(
|
|
@@ -1918,7 +1924,7 @@ function useFrontendTool(tool, deps) {
|
|
|
1918
1924
|
}
|
|
1919
1925
|
|
|
1920
1926
|
// src/hooks/use-human-in-the-loop.tsx
|
|
1921
|
-
import { useCallback as useCallback4, useRef as useRef4, useEffect as
|
|
1927
|
+
import { useCallback as useCallback4, useRef as useRef4, useEffect as useEffect7 } from "react";
|
|
1922
1928
|
import React7 from "react";
|
|
1923
1929
|
function useHumanInTheLoop(tool, deps) {
|
|
1924
1930
|
const { copilotkit } = useCopilotKit();
|
|
@@ -1972,7 +1978,7 @@ function useHumanInTheLoop(tool, deps) {
|
|
|
1972
1978
|
render: RenderComponent
|
|
1973
1979
|
};
|
|
1974
1980
|
useFrontendTool(frontendTool, deps);
|
|
1975
|
-
|
|
1981
|
+
useEffect7(() => {
|
|
1976
1982
|
return () => {
|
|
1977
1983
|
const keyOf = (rc) => `${rc.agentId ?? ""}:${rc.name}`;
|
|
1978
1984
|
const currentRenderToolCalls = copilotkit.renderToolCalls;
|
|
@@ -1985,7 +1991,7 @@ function useHumanInTheLoop(tool, deps) {
|
|
|
1985
1991
|
}
|
|
1986
1992
|
|
|
1987
1993
|
// src/hooks/use-agent.tsx
|
|
1988
|
-
import { useMemo as useMemo5, useEffect as
|
|
1994
|
+
import { useMemo as useMemo5, useEffect as useEffect8, useReducer as useReducer2 } from "react";
|
|
1989
1995
|
import { DEFAULT_AGENT_ID as DEFAULT_AGENT_ID4 } from "@copilotkitnext/shared";
|
|
1990
1996
|
import { ProxiedCopilotRuntimeAgent, CopilotKitCoreRuntimeConnectionStatus } from "@copilotkitnext/core";
|
|
1991
1997
|
var ALL_UPDATES = [
|
|
@@ -2031,7 +2037,7 @@ function useAgent({ agentId, updates } = {}) {
|
|
|
2031
2037
|
JSON.stringify(copilotkit.headers),
|
|
2032
2038
|
copilotkit
|
|
2033
2039
|
]);
|
|
2034
|
-
|
|
2040
|
+
useEffect8(() => {
|
|
2035
2041
|
if (updateFlags.length === 0) {
|
|
2036
2042
|
return;
|
|
2037
2043
|
}
|
|
@@ -2066,7 +2072,7 @@ function useAgent({ agentId, updates } = {}) {
|
|
|
2066
2072
|
}
|
|
2067
2073
|
|
|
2068
2074
|
// src/hooks/use-agent-context.tsx
|
|
2069
|
-
import { useEffect as
|
|
2075
|
+
import { useEffect as useEffect9, useMemo as useMemo6 } from "react";
|
|
2070
2076
|
function useAgentContext(context) {
|
|
2071
2077
|
const { description, value } = context;
|
|
2072
2078
|
const { copilotkit } = useCopilotKit();
|
|
@@ -2076,7 +2082,7 @@ function useAgentContext(context) {
|
|
|
2076
2082
|
}
|
|
2077
2083
|
return JSON.stringify(value);
|
|
2078
2084
|
}, [value]);
|
|
2079
|
-
|
|
2085
|
+
useEffect9(() => {
|
|
2080
2086
|
if (!copilotkit) return;
|
|
2081
2087
|
const id = copilotkit.addContext({ description, value: stringValue });
|
|
2082
2088
|
return () => {
|
|
@@ -2086,26 +2092,26 @@ function useAgentContext(context) {
|
|
|
2086
2092
|
}
|
|
2087
2093
|
|
|
2088
2094
|
// src/hooks/use-suggestions.tsx
|
|
2089
|
-
import { useCallback as useCallback5, useEffect as
|
|
2095
|
+
import { useCallback as useCallback5, useEffect as useEffect10, useMemo as useMemo7, useState as useState6 } from "react";
|
|
2090
2096
|
import { DEFAULT_AGENT_ID as DEFAULT_AGENT_ID5 } from "@copilotkitnext/shared";
|
|
2091
2097
|
function useSuggestions({ agentId } = {}) {
|
|
2092
2098
|
const { copilotkit } = useCopilotKit();
|
|
2093
2099
|
const config = useCopilotChatConfiguration();
|
|
2094
2100
|
const resolvedAgentId = useMemo7(() => agentId ?? config?.agentId ?? DEFAULT_AGENT_ID5, [agentId, config?.agentId]);
|
|
2095
|
-
const [suggestions, setSuggestions] =
|
|
2101
|
+
const [suggestions, setSuggestions] = useState6(() => {
|
|
2096
2102
|
const result = copilotkit.getSuggestions(resolvedAgentId);
|
|
2097
2103
|
return result.suggestions;
|
|
2098
2104
|
});
|
|
2099
|
-
const [isLoading, setIsLoading] =
|
|
2105
|
+
const [isLoading, setIsLoading] = useState6(() => {
|
|
2100
2106
|
const result = copilotkit.getSuggestions(resolvedAgentId);
|
|
2101
2107
|
return result.isLoading;
|
|
2102
2108
|
});
|
|
2103
|
-
|
|
2109
|
+
useEffect10(() => {
|
|
2104
2110
|
const result = copilotkit.getSuggestions(resolvedAgentId);
|
|
2105
2111
|
setSuggestions(result.suggestions);
|
|
2106
2112
|
setIsLoading(result.isLoading);
|
|
2107
2113
|
}, [copilotkit, resolvedAgentId]);
|
|
2108
|
-
|
|
2114
|
+
useEffect10(() => {
|
|
2109
2115
|
const subscription = copilotkit.subscribe({
|
|
2110
2116
|
onSuggestionsChanged: ({ agentId: changedAgentId, suggestions: suggestions2 }) => {
|
|
2111
2117
|
if (changedAgentId !== resolvedAgentId) {
|
|
@@ -2150,7 +2156,7 @@ function useSuggestions({ agentId } = {}) {
|
|
|
2150
2156
|
}
|
|
2151
2157
|
|
|
2152
2158
|
// src/hooks/use-configure-suggestions.tsx
|
|
2153
|
-
import { useCallback as useCallback6, useEffect as
|
|
2159
|
+
import { useCallback as useCallback6, useEffect as useEffect11, useMemo as useMemo8, useRef as useRef5 } from "react";
|
|
2154
2160
|
import { DEFAULT_AGENT_ID as DEFAULT_AGENT_ID6 } from "@copilotkitnext/shared";
|
|
2155
2161
|
function useConfigureSuggestions(config, deps) {
|
|
2156
2162
|
const { copilotkit } = useCopilotKit();
|
|
@@ -2228,7 +2234,7 @@ function useConfigureSuggestions(config, deps) {
|
|
|
2228
2234
|
}
|
|
2229
2235
|
copilotkit.reloadSuggestions(targetAgentId);
|
|
2230
2236
|
}, [copilotkit, isGlobalConfig, normalizedConfig, targetAgentId]);
|
|
2231
|
-
|
|
2237
|
+
useEffect11(() => {
|
|
2232
2238
|
if (!serializedConfig || !latestConfigRef.current) {
|
|
2233
2239
|
return;
|
|
2234
2240
|
}
|
|
@@ -2238,7 +2244,7 @@ function useConfigureSuggestions(config, deps) {
|
|
|
2238
2244
|
copilotkit.removeSuggestionsConfig(id);
|
|
2239
2245
|
};
|
|
2240
2246
|
}, [copilotkit, serializedConfig, requestReload]);
|
|
2241
|
-
|
|
2247
|
+
useEffect11(() => {
|
|
2242
2248
|
if (!normalizedConfig) {
|
|
2243
2249
|
previousSerializedConfigRef.current = null;
|
|
2244
2250
|
return;
|
|
@@ -2251,7 +2257,7 @@ function useConfigureSuggestions(config, deps) {
|
|
|
2251
2257
|
}
|
|
2252
2258
|
requestReload();
|
|
2253
2259
|
}, [normalizedConfig, requestReload, serializedConfig]);
|
|
2254
|
-
|
|
2260
|
+
useEffect11(() => {
|
|
2255
2261
|
if (!normalizedConfig || extraDeps.length === 0) {
|
|
2256
2262
|
return;
|
|
2257
2263
|
}
|
|
@@ -2461,7 +2467,7 @@ function CopilotChatAssistantMessage({
|
|
|
2461
2467
|
CopilotChatAssistantMessage2.CopyButton = ({ className, title, onClick, ...props }) => {
|
|
2462
2468
|
const config = useCopilotChatConfiguration();
|
|
2463
2469
|
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
2464
|
-
const [copied, setCopied] =
|
|
2470
|
+
const [copied, setCopied] = useState7(false);
|
|
2465
2471
|
const handleClick = (event) => {
|
|
2466
2472
|
setCopied(true);
|
|
2467
2473
|
setTimeout(() => setCopied(false), 2e3);
|
|
@@ -2539,7 +2545,7 @@ CopilotChatAssistantMessage.RegenerateButton.displayName = "CopilotChatAssistant
|
|
|
2539
2545
|
var CopilotChatAssistantMessage_default = CopilotChatAssistantMessage;
|
|
2540
2546
|
|
|
2541
2547
|
// src/components/chat/CopilotChatUserMessage.tsx
|
|
2542
|
-
import { useMemo as useMemo9, useState as
|
|
2548
|
+
import { useMemo as useMemo9, useState as useState8 } from "react";
|
|
2543
2549
|
import { Copy as Copy2, Check as Check3, Edit, ChevronLeft, ChevronRight } from "lucide-react";
|
|
2544
2550
|
import { twMerge as twMerge5 } from "tailwind-merge";
|
|
2545
2551
|
import { Fragment as Fragment4, jsx as jsx14, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
@@ -2702,7 +2708,7 @@ function CopilotChatUserMessage({
|
|
|
2702
2708
|
CopilotChatUserMessage2.CopyButton = ({ className, title, onClick, ...props }) => {
|
|
2703
2709
|
const config = useCopilotChatConfiguration();
|
|
2704
2710
|
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
2705
|
-
const [copied, setCopied] =
|
|
2711
|
+
const [copied, setCopied] = useState8(false);
|
|
2706
2712
|
const handleClick = (event) => {
|
|
2707
2713
|
setCopied(true);
|
|
2708
2714
|
setTimeout(() => setCopied(false), 2e3);
|
|
@@ -3102,21 +3108,21 @@ CopilotChatMessageView.Cursor = function Cursor({ className, ...props }) {
|
|
|
3102
3108
|
var CopilotChatMessageView_default = CopilotChatMessageView;
|
|
3103
3109
|
|
|
3104
3110
|
// src/components/chat/CopilotChatView.tsx
|
|
3105
|
-
import React12, { useRef as useRef6, useState as
|
|
3111
|
+
import React12, { useRef as useRef6, useState as useState10, useEffect as useEffect13 } from "react";
|
|
3106
3112
|
import { twMerge as twMerge7 } from "tailwind-merge";
|
|
3107
3113
|
import { StickToBottom, useStickToBottom, useStickToBottomContext } from "use-stick-to-bottom";
|
|
3108
3114
|
import { ChevronDown } from "lucide-react";
|
|
3109
3115
|
|
|
3110
3116
|
// src/hooks/use-keyboard-height.tsx
|
|
3111
|
-
import { useState as
|
|
3117
|
+
import { useState as useState9, useEffect as useEffect12 } from "react";
|
|
3112
3118
|
function useKeyboardHeight() {
|
|
3113
|
-
const [keyboardState, setKeyboardState] =
|
|
3119
|
+
const [keyboardState, setKeyboardState] = useState9({
|
|
3114
3120
|
isKeyboardOpen: false,
|
|
3115
3121
|
keyboardHeight: 0,
|
|
3116
3122
|
availableHeight: typeof window !== "undefined" ? window.innerHeight : 0,
|
|
3117
3123
|
viewportHeight: typeof window !== "undefined" ? window.innerHeight : 0
|
|
3118
3124
|
});
|
|
3119
|
-
|
|
3125
|
+
useEffect12(() => {
|
|
3120
3126
|
if (typeof window === "undefined") {
|
|
3121
3127
|
return;
|
|
3122
3128
|
}
|
|
@@ -3170,11 +3176,11 @@ function CopilotChatView({
|
|
|
3170
3176
|
...props
|
|
3171
3177
|
}) {
|
|
3172
3178
|
const inputContainerRef = useRef6(null);
|
|
3173
|
-
const [inputContainerHeight, setInputContainerHeight] =
|
|
3174
|
-
const [isResizing, setIsResizing] =
|
|
3179
|
+
const [inputContainerHeight, setInputContainerHeight] = useState10(0);
|
|
3180
|
+
const [isResizing, setIsResizing] = useState10(false);
|
|
3175
3181
|
const resizeTimeoutRef = useRef6(null);
|
|
3176
3182
|
const { isKeyboardOpen, keyboardHeight, availableHeight } = useKeyboardHeight();
|
|
3177
|
-
|
|
3183
|
+
useEffect13(() => {
|
|
3178
3184
|
const element = inputContainerRef.current;
|
|
3179
3185
|
if (!element) return;
|
|
3180
3186
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
@@ -3283,13 +3289,13 @@ function CopilotChatView({
|
|
|
3283
3289
|
className,
|
|
3284
3290
|
...props
|
|
3285
3291
|
}) => {
|
|
3286
|
-
const [hasMounted, setHasMounted] =
|
|
3292
|
+
const [hasMounted, setHasMounted] = useState10(false);
|
|
3287
3293
|
const { scrollRef, contentRef, scrollToBottom } = useStickToBottom();
|
|
3288
|
-
const [showScrollButton, setShowScrollButton] =
|
|
3289
|
-
|
|
3294
|
+
const [showScrollButton, setShowScrollButton] = useState10(false);
|
|
3295
|
+
useEffect13(() => {
|
|
3290
3296
|
setHasMounted(true);
|
|
3291
3297
|
}, []);
|
|
3292
|
-
|
|
3298
|
+
useEffect13(() => {
|
|
3293
3299
|
if (autoScroll) return;
|
|
3294
3300
|
const scrollElement = scrollRef.current;
|
|
3295
3301
|
if (!scrollElement) return;
|
|
@@ -3421,7 +3427,7 @@ var CopilotChatView_default = CopilotChatView;
|
|
|
3421
3427
|
|
|
3422
3428
|
// src/components/chat/CopilotChat.tsx
|
|
3423
3429
|
import { DEFAULT_AGENT_ID as DEFAULT_AGENT_ID7, randomUUID as randomUUID2 } from "@copilotkitnext/shared";
|
|
3424
|
-
import { useCallback as useCallback7, useEffect as
|
|
3430
|
+
import { useCallback as useCallback7, useEffect as useEffect14, useMemo as useMemo10 } from "react";
|
|
3425
3431
|
import { merge } from "ts-deepmerge";
|
|
3426
3432
|
import { AGUIConnectNotImplementedError } from "@ag-ui/client";
|
|
3427
3433
|
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
@@ -3441,7 +3447,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
3441
3447
|
suggestionView: providedSuggestionView,
|
|
3442
3448
|
...restProps
|
|
3443
3449
|
} = props;
|
|
3444
|
-
|
|
3450
|
+
useEffect14(() => {
|
|
3445
3451
|
const connect = async (agent2) => {
|
|
3446
3452
|
try {
|
|
3447
3453
|
await copilotkit.connectAgent({ agent: agent2 });
|
|
@@ -3543,7 +3549,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
3543
3549
|
})(CopilotChat || (CopilotChat = {}));
|
|
3544
3550
|
|
|
3545
3551
|
// src/components/chat/CopilotChatToggleButton.tsx
|
|
3546
|
-
import React13, { useState as
|
|
3552
|
+
import React13, { useState as useState11 } from "react";
|
|
3547
3553
|
import { MessageCircle, X as X2 } from "lucide-react";
|
|
3548
3554
|
import { jsx as jsx20, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
3549
3555
|
var DefaultOpenIcon = ({
|
|
@@ -3574,7 +3580,7 @@ var CopilotChatToggleButton = React13.forwardRef(function CopilotChatToggleButto
|
|
|
3574
3580
|
const { onClick, type, disabled, ...restProps } = buttonProps;
|
|
3575
3581
|
const configuration = useCopilotChatConfiguration();
|
|
3576
3582
|
const labels = configuration?.labels ?? CopilotChatDefaultLabels;
|
|
3577
|
-
const [fallbackOpen, setFallbackOpen] =
|
|
3583
|
+
const [fallbackOpen, setFallbackOpen] = useState11(false);
|
|
3578
3584
|
const isOpen = configuration?.isModalOpen ?? fallbackOpen;
|
|
3579
3585
|
const setModalOpen = configuration?.setModalOpen ?? setFallbackOpen;
|
|
3580
3586
|
const handleClick = (event) => {
|
|
@@ -3660,7 +3666,7 @@ CopilotChatToggleButton.displayName = "CopilotChatToggleButton";
|
|
|
3660
3666
|
var CopilotChatToggleButton_default = CopilotChatToggleButton;
|
|
3661
3667
|
|
|
3662
3668
|
// src/components/chat/CopilotSidebarView.tsx
|
|
3663
|
-
import { useEffect as
|
|
3669
|
+
import { useEffect as useEffect15, useRef as useRef7, useState as useState12 } from "react";
|
|
3664
3670
|
|
|
3665
3671
|
// src/components/chat/CopilotModalHeader.tsx
|
|
3666
3672
|
import { useCallback as useCallback8 } from "react";
|
|
@@ -3754,7 +3760,7 @@ function CopilotSidebarView({ header, width, ...props }) {
|
|
|
3754
3760
|
const configuration = useCopilotChatConfiguration();
|
|
3755
3761
|
const isSidebarOpen = configuration?.isModalOpen ?? false;
|
|
3756
3762
|
const sidebarRef = useRef7(null);
|
|
3757
|
-
const [sidebarWidth, setSidebarWidth] =
|
|
3763
|
+
const [sidebarWidth, setSidebarWidth] = useState12(width ?? DEFAULT_SIDEBAR_WIDTH);
|
|
3758
3764
|
const widthToCss = (w) => {
|
|
3759
3765
|
return typeof w === "number" ? `${w}px` : w;
|
|
3760
3766
|
};
|
|
@@ -3764,7 +3770,7 @@ function CopilotSidebarView({ header, width, ...props }) {
|
|
|
3764
3770
|
}
|
|
3765
3771
|
return w;
|
|
3766
3772
|
};
|
|
3767
|
-
|
|
3773
|
+
useEffect15(() => {
|
|
3768
3774
|
if (width !== void 0) {
|
|
3769
3775
|
return;
|
|
3770
3776
|
}
|
|
@@ -3843,7 +3849,7 @@ function CopilotSidebarView({ header, width, ...props }) {
|
|
|
3843
3849
|
CopilotSidebarView.displayName = "CopilotSidebarView";
|
|
3844
3850
|
|
|
3845
3851
|
// src/components/chat/CopilotPopupView.tsx
|
|
3846
|
-
import { useEffect as
|
|
3852
|
+
import { useEffect as useEffect16, useMemo as useMemo11, useRef as useRef8, useState as useState13 } from "react";
|
|
3847
3853
|
import { Fragment as Fragment8, jsx as jsx23, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
3848
3854
|
var DEFAULT_POPUP_WIDTH = 420;
|
|
3849
3855
|
var DEFAULT_POPUP_HEIGHT = 560;
|
|
@@ -3869,9 +3875,9 @@ function CopilotPopupView({
|
|
|
3869
3875
|
const setModalOpen = configuration?.setModalOpen;
|
|
3870
3876
|
const labels = configuration?.labels ?? CopilotChatDefaultLabels;
|
|
3871
3877
|
const containerRef = useRef8(null);
|
|
3872
|
-
const [isRendered, setIsRendered] =
|
|
3873
|
-
const [isAnimatingOut, setIsAnimatingOut] =
|
|
3874
|
-
|
|
3878
|
+
const [isRendered, setIsRendered] = useState13(isPopupOpen);
|
|
3879
|
+
const [isAnimatingOut, setIsAnimatingOut] = useState13(false);
|
|
3880
|
+
useEffect16(() => {
|
|
3875
3881
|
if (isPopupOpen) {
|
|
3876
3882
|
setIsRendered(true);
|
|
3877
3883
|
setIsAnimatingOut(false);
|
|
@@ -3887,7 +3893,7 @@ function CopilotPopupView({
|
|
|
3887
3893
|
}, 200);
|
|
3888
3894
|
return () => clearTimeout(timeout);
|
|
3889
3895
|
}, [isPopupOpen, isRendered]);
|
|
3890
|
-
|
|
3896
|
+
useEffect16(() => {
|
|
3891
3897
|
if (!isPopupOpen) {
|
|
3892
3898
|
return;
|
|
3893
3899
|
}
|
|
@@ -3903,7 +3909,7 @@ function CopilotPopupView({
|
|
|
3903
3909
|
window.addEventListener("keydown", handleKeyDown);
|
|
3904
3910
|
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
3905
3911
|
}, [isPopupOpen, setModalOpen]);
|
|
3906
|
-
|
|
3912
|
+
useEffect16(() => {
|
|
3907
3913
|
if (!isPopupOpen) {
|
|
3908
3914
|
return;
|
|
3909
3915
|
}
|
|
@@ -3912,7 +3918,7 @@ function CopilotPopupView({
|
|
|
3912
3918
|
}, 200);
|
|
3913
3919
|
return () => clearTimeout(focusTimer);
|
|
3914
3920
|
}, [isPopupOpen]);
|
|
3915
|
-
|
|
3921
|
+
useEffect16(() => {
|
|
3916
3922
|
if (!isPopupOpen || !clickOutsideToClose) {
|
|
3917
3923
|
return;
|
|
3918
3924
|
}
|
|
@@ -4087,12 +4093,12 @@ function defineToolCallRenderer(def) {
|
|
|
4087
4093
|
}
|
|
4088
4094
|
|
|
4089
4095
|
// src/components/WildcardToolCallRender.tsx
|
|
4090
|
-
import { useState as
|
|
4096
|
+
import { useState as useState14 } from "react";
|
|
4091
4097
|
import { jsx as jsx26, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
4092
4098
|
var WildcardToolCallRender = defineToolCallRenderer({
|
|
4093
4099
|
name: "*",
|
|
4094
4100
|
render: ({ args, result, name, status }) => {
|
|
4095
|
-
const [isExpanded, setIsExpanded] =
|
|
4101
|
+
const [isExpanded, setIsExpanded] = useState14(false);
|
|
4096
4102
|
const statusString = String(status);
|
|
4097
4103
|
const isActive = statusString === "inProgress" || statusString === "executing";
|
|
4098
4104
|
const isComplete = statusString === "complete";
|