@copilotkitnext/react 0.0.20 → 0.0.21
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 +33 -2
- package/dist/index.d.ts +33 -2
- package/dist/index.js +327 -249
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +246 -169
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +6 -6
package/dist/index.mjs
CHANGED
|
@@ -1328,7 +1328,7 @@ CopilotChatInput.AddMenuButton.displayName = "CopilotChatInput.AddMenuButton";
|
|
|
1328
1328
|
var CopilotChatInput_default = CopilotChatInput;
|
|
1329
1329
|
|
|
1330
1330
|
// src/components/chat/CopilotChatAssistantMessage.tsx
|
|
1331
|
-
import { useState as
|
|
1331
|
+
import { useState as useState6 } from "react";
|
|
1332
1332
|
import {
|
|
1333
1333
|
Copy,
|
|
1334
1334
|
Check as Check2,
|
|
@@ -1362,14 +1362,19 @@ import { CopilotKitCore } from "@copilotkitnext/core";
|
|
|
1362
1362
|
var CopilotKitCoreReact = class extends CopilotKitCore {
|
|
1363
1363
|
_renderToolCalls = [];
|
|
1364
1364
|
_renderCustomMessages = [];
|
|
1365
|
+
_renderActivityMessages = [];
|
|
1365
1366
|
constructor(config) {
|
|
1366
1367
|
super(config);
|
|
1367
1368
|
this._renderToolCalls = config.renderToolCalls ?? [];
|
|
1368
1369
|
this._renderCustomMessages = config.renderCustomMessages ?? [];
|
|
1370
|
+
this._renderActivityMessages = config.renderActivityMessages ?? [];
|
|
1369
1371
|
}
|
|
1370
1372
|
get renderCustomMessages() {
|
|
1371
1373
|
return this._renderCustomMessages;
|
|
1372
1374
|
}
|
|
1375
|
+
get renderActivityMessages() {
|
|
1376
|
+
return this._renderActivityMessages;
|
|
1377
|
+
}
|
|
1373
1378
|
get renderToolCalls() {
|
|
1374
1379
|
return this._renderToolCalls;
|
|
1375
1380
|
}
|
|
@@ -1455,10 +1460,12 @@ var CopilotKitProvider = ({
|
|
|
1455
1460
|
properties = {},
|
|
1456
1461
|
agents__unsafe_dev_only: agents = {},
|
|
1457
1462
|
renderToolCalls,
|
|
1463
|
+
renderActivityMessages,
|
|
1458
1464
|
renderCustomMessages,
|
|
1459
1465
|
frontendTools,
|
|
1460
1466
|
humanInTheLoop,
|
|
1461
|
-
showDevConsole = false
|
|
1467
|
+
showDevConsole = false,
|
|
1468
|
+
useSingleEndpoint = false
|
|
1462
1469
|
}) => {
|
|
1463
1470
|
const [shouldRenderInspector, setShouldRenderInspector] = useState3(false);
|
|
1464
1471
|
useEffect4(() => {
|
|
@@ -1495,6 +1502,10 @@ var CopilotKitProvider = ({
|
|
|
1495
1502
|
renderCustomMessages,
|
|
1496
1503
|
"renderCustomMessages must be a stable array."
|
|
1497
1504
|
);
|
|
1505
|
+
const renderActivityMessagesList = useStableArrayProp(
|
|
1506
|
+
renderActivityMessages,
|
|
1507
|
+
"renderActivityMessages must be a stable array."
|
|
1508
|
+
);
|
|
1498
1509
|
const frontendToolsList = useStableArrayProp(
|
|
1499
1510
|
frontendTools,
|
|
1500
1511
|
"frontendTools must be a stable array. If you want to dynamically add or remove tools, use `useFrontendTool` instead."
|
|
@@ -1558,15 +1569,17 @@ var CopilotKitProvider = ({
|
|
|
1558
1569
|
const copilotkit = useMemo3(() => {
|
|
1559
1570
|
const copilotkit2 = new CopilotKitCoreReact({
|
|
1560
1571
|
runtimeUrl,
|
|
1572
|
+
runtimeTransport: useSingleEndpoint ? "single" : "rest",
|
|
1561
1573
|
headers,
|
|
1562
1574
|
properties,
|
|
1563
1575
|
agents__unsafe_dev_only: agents,
|
|
1564
1576
|
tools: allTools,
|
|
1565
1577
|
renderToolCalls: allRenderToolCalls,
|
|
1578
|
+
renderActivityMessages: renderActivityMessagesList,
|
|
1566
1579
|
renderCustomMessages: renderCustomMessagesList
|
|
1567
1580
|
});
|
|
1568
1581
|
return copilotkit2;
|
|
1569
|
-
}, [allTools, allRenderToolCalls, renderCustomMessagesList]);
|
|
1582
|
+
}, [allTools, allRenderToolCalls, renderActivityMessagesList, renderCustomMessagesList, useSingleEndpoint]);
|
|
1570
1583
|
const [, forceUpdate] = useReducer((x) => x + 1, 0);
|
|
1571
1584
|
useEffect4(() => {
|
|
1572
1585
|
const unsubscribe = copilotkit.subscribe({
|
|
@@ -1580,10 +1593,11 @@ var CopilotKitProvider = ({
|
|
|
1580
1593
|
}, [copilotkit]);
|
|
1581
1594
|
useEffect4(() => {
|
|
1582
1595
|
copilotkit.setRuntimeUrl(runtimeUrl);
|
|
1596
|
+
copilotkit.setRuntimeTransport(useSingleEndpoint ? "single" : "rest");
|
|
1583
1597
|
copilotkit.setHeaders(headers);
|
|
1584
1598
|
copilotkit.setProperties(properties);
|
|
1585
1599
|
copilotkit.setAgents__unsafe_dev_only(agents);
|
|
1586
|
-
}, [runtimeUrl, headers, properties, agents]);
|
|
1600
|
+
}, [runtimeUrl, headers, properties, agents, useSingleEndpoint]);
|
|
1587
1601
|
return /* @__PURE__ */ jsxs4(
|
|
1588
1602
|
CopilotKitContext.Provider,
|
|
1589
1603
|
{
|
|
@@ -1768,6 +1782,52 @@ function useRenderCustomMessages() {
|
|
|
1768
1782
|
};
|
|
1769
1783
|
}
|
|
1770
1784
|
|
|
1785
|
+
// src/hooks/use-render-activity-message.tsx
|
|
1786
|
+
import { DEFAULT_AGENT_ID as DEFAULT_AGENT_ID3 } from "@copilotkitnext/shared";
|
|
1787
|
+
import { useCallback as useCallback3 } from "react";
|
|
1788
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
1789
|
+
function useRenderActivityMessage() {
|
|
1790
|
+
const { copilotkit } = useCopilotKit();
|
|
1791
|
+
const config = useCopilotChatConfiguration();
|
|
1792
|
+
const agentId = config?.agentId ?? DEFAULT_AGENT_ID3;
|
|
1793
|
+
const renderers = copilotkit.renderActivityMessages;
|
|
1794
|
+
return useCallback3(
|
|
1795
|
+
(message) => {
|
|
1796
|
+
if (!renderers.length) {
|
|
1797
|
+
return null;
|
|
1798
|
+
}
|
|
1799
|
+
const matches = renderers.filter(
|
|
1800
|
+
(renderer2) => renderer2.activityType === message.activityType
|
|
1801
|
+
);
|
|
1802
|
+
const renderer = matches.find((candidate) => candidate.agentId === agentId) ?? matches.find((candidate) => candidate.agentId === void 0) ?? renderers.find((candidate) => candidate.activityType === "*");
|
|
1803
|
+
if (!renderer) {
|
|
1804
|
+
return null;
|
|
1805
|
+
}
|
|
1806
|
+
const parseResult = renderer.content.safeParse(message.content);
|
|
1807
|
+
if (!parseResult.success) {
|
|
1808
|
+
console.warn(
|
|
1809
|
+
`Failed to parse content for activity message '${message.activityType}':`,
|
|
1810
|
+
parseResult.error
|
|
1811
|
+
);
|
|
1812
|
+
return null;
|
|
1813
|
+
}
|
|
1814
|
+
const Component = renderer.render;
|
|
1815
|
+
const agent = copilotkit.getAgent(agentId);
|
|
1816
|
+
return /* @__PURE__ */ jsx11(
|
|
1817
|
+
Component,
|
|
1818
|
+
{
|
|
1819
|
+
activityType: message.activityType,
|
|
1820
|
+
content: parseResult.data,
|
|
1821
|
+
message,
|
|
1822
|
+
agent
|
|
1823
|
+
},
|
|
1824
|
+
message.id
|
|
1825
|
+
);
|
|
1826
|
+
},
|
|
1827
|
+
[agentId, copilotkit, renderers]
|
|
1828
|
+
);
|
|
1829
|
+
}
|
|
1830
|
+
|
|
1771
1831
|
// src/hooks/use-frontend-tool.tsx
|
|
1772
1832
|
import { useEffect as useEffect6 } from "react";
|
|
1773
1833
|
function useFrontendTool(tool) {
|
|
@@ -1804,34 +1864,26 @@ function useFrontendTool(tool) {
|
|
|
1804
1864
|
}
|
|
1805
1865
|
|
|
1806
1866
|
// src/hooks/use-human-in-the-loop.tsx
|
|
1807
|
-
import {
|
|
1867
|
+
import { useCallback as useCallback4, useRef as useRef5, useEffect as useEffect7 } from "react";
|
|
1808
1868
|
import React7 from "react";
|
|
1809
1869
|
function useHumanInTheLoop(tool) {
|
|
1810
1870
|
const { copilotkit } = useCopilotKit();
|
|
1811
|
-
const [status, setStatus] = useState5(
|
|
1812
|
-
"inProgress"
|
|
1813
|
-
);
|
|
1814
|
-
const statusRef = useRef5(status);
|
|
1815
1871
|
const resolvePromiseRef = useRef5(null);
|
|
1816
|
-
|
|
1817
|
-
const respond = useCallback3(async (result) => {
|
|
1872
|
+
const respond = useCallback4(async (result) => {
|
|
1818
1873
|
if (resolvePromiseRef.current) {
|
|
1819
1874
|
resolvePromiseRef.current(result);
|
|
1820
|
-
setStatus("complete");
|
|
1821
1875
|
resolvePromiseRef.current = null;
|
|
1822
1876
|
}
|
|
1823
1877
|
}, []);
|
|
1824
|
-
const handler =
|
|
1878
|
+
const handler = useCallback4(async () => {
|
|
1825
1879
|
return new Promise((resolve) => {
|
|
1826
|
-
setStatus("executing");
|
|
1827
1880
|
resolvePromiseRef.current = resolve;
|
|
1828
1881
|
});
|
|
1829
1882
|
}, []);
|
|
1830
|
-
const RenderComponent =
|
|
1883
|
+
const RenderComponent = useCallback4(
|
|
1831
1884
|
(props) => {
|
|
1832
1885
|
const ToolComponent = tool.render;
|
|
1833
|
-
|
|
1834
|
-
if (currentStatus === "inProgress" && props.status === "inProgress") {
|
|
1886
|
+
if (props.status === "inProgress") {
|
|
1835
1887
|
const enhancedProps = {
|
|
1836
1888
|
...props,
|
|
1837
1889
|
name: tool.name,
|
|
@@ -1839,7 +1891,7 @@ function useHumanInTheLoop(tool) {
|
|
|
1839
1891
|
respond: void 0
|
|
1840
1892
|
};
|
|
1841
1893
|
return React7.createElement(ToolComponent, enhancedProps);
|
|
1842
|
-
} else if (
|
|
1894
|
+
} else if (props.status === "executing") {
|
|
1843
1895
|
const enhancedProps = {
|
|
1844
1896
|
...props,
|
|
1845
1897
|
name: tool.name,
|
|
@@ -1847,7 +1899,7 @@ function useHumanInTheLoop(tool) {
|
|
|
1847
1899
|
respond
|
|
1848
1900
|
};
|
|
1849
1901
|
return React7.createElement(ToolComponent, enhancedProps);
|
|
1850
|
-
} else if (
|
|
1902
|
+
} else if (props.status === "complete") {
|
|
1851
1903
|
const enhancedProps = {
|
|
1852
1904
|
...props,
|
|
1853
1905
|
name: tool.name,
|
|
@@ -1880,14 +1932,14 @@ function useHumanInTheLoop(tool) {
|
|
|
1880
1932
|
|
|
1881
1933
|
// src/hooks/use-agent.tsx
|
|
1882
1934
|
import { useMemo as useMemo4, useEffect as useEffect8, useReducer as useReducer2 } from "react";
|
|
1883
|
-
import { DEFAULT_AGENT_ID as
|
|
1935
|
+
import { DEFAULT_AGENT_ID as DEFAULT_AGENT_ID4 } from "@copilotkitnext/shared";
|
|
1884
1936
|
var ALL_UPDATES = [
|
|
1885
1937
|
"OnMessagesChanged" /* OnMessagesChanged */,
|
|
1886
1938
|
"OnStateChanged" /* OnStateChanged */,
|
|
1887
1939
|
"OnRunStatusChanged" /* OnRunStatusChanged */
|
|
1888
1940
|
];
|
|
1889
1941
|
function useAgent({ agentId, updates } = {}) {
|
|
1890
|
-
agentId ??=
|
|
1942
|
+
agentId ??= DEFAULT_AGENT_ID4;
|
|
1891
1943
|
const { copilotkit } = useCopilotKit();
|
|
1892
1944
|
const [, forceUpdate] = useReducer2((x) => x + 1, 0);
|
|
1893
1945
|
const updateFlags = useMemo4(
|
|
@@ -1954,17 +2006,17 @@ function useAgentContext(context) {
|
|
|
1954
2006
|
}
|
|
1955
2007
|
|
|
1956
2008
|
// src/hooks/use-suggestions.tsx
|
|
1957
|
-
import { useCallback as
|
|
1958
|
-
import { DEFAULT_AGENT_ID as
|
|
2009
|
+
import { useCallback as useCallback5, useEffect as useEffect10, useMemo as useMemo5, useState as useState5 } from "react";
|
|
2010
|
+
import { DEFAULT_AGENT_ID as DEFAULT_AGENT_ID5 } from "@copilotkitnext/shared";
|
|
1959
2011
|
function useSuggestions({ agentId } = {}) {
|
|
1960
2012
|
const { copilotkit } = useCopilotKit();
|
|
1961
2013
|
const config = useCopilotChatConfiguration();
|
|
1962
|
-
const resolvedAgentId = useMemo5(() => agentId ?? config?.agentId ??
|
|
1963
|
-
const [suggestions, setSuggestions] =
|
|
2014
|
+
const resolvedAgentId = useMemo5(() => agentId ?? config?.agentId ?? DEFAULT_AGENT_ID5, [agentId, config?.agentId]);
|
|
2015
|
+
const [suggestions, setSuggestions] = useState5(() => {
|
|
1964
2016
|
const result = copilotkit.getSuggestions(resolvedAgentId);
|
|
1965
2017
|
return result.suggestions;
|
|
1966
2018
|
});
|
|
1967
|
-
const [isLoading, setIsLoading] =
|
|
2019
|
+
const [isLoading, setIsLoading] = useState5(() => {
|
|
1968
2020
|
const result = copilotkit.getSuggestions(resolvedAgentId);
|
|
1969
2021
|
return result.isLoading;
|
|
1970
2022
|
});
|
|
@@ -2003,10 +2055,10 @@ function useSuggestions({ agentId } = {}) {
|
|
|
2003
2055
|
unsubscribe();
|
|
2004
2056
|
};
|
|
2005
2057
|
}, [copilotkit, resolvedAgentId]);
|
|
2006
|
-
const reloadSuggestions =
|
|
2058
|
+
const reloadSuggestions = useCallback5(() => {
|
|
2007
2059
|
copilotkit.reloadSuggestions(resolvedAgentId);
|
|
2008
2060
|
}, [copilotkit, resolvedAgentId]);
|
|
2009
|
-
const clearSuggestions =
|
|
2061
|
+
const clearSuggestions = useCallback5(() => {
|
|
2010
2062
|
copilotkit.clearSuggestions(resolvedAgentId);
|
|
2011
2063
|
}, [copilotkit, resolvedAgentId]);
|
|
2012
2064
|
return {
|
|
@@ -2018,14 +2070,14 @@ function useSuggestions({ agentId } = {}) {
|
|
|
2018
2070
|
}
|
|
2019
2071
|
|
|
2020
2072
|
// src/hooks/use-configure-suggestions.tsx
|
|
2021
|
-
import { useCallback as
|
|
2022
|
-
import { DEFAULT_AGENT_ID as
|
|
2073
|
+
import { useCallback as useCallback6, useEffect as useEffect11, useMemo as useMemo6, useRef as useRef6 } from "react";
|
|
2074
|
+
import { DEFAULT_AGENT_ID as DEFAULT_AGENT_ID6 } from "@copilotkitnext/shared";
|
|
2023
2075
|
var EMPTY_DEPS = [];
|
|
2024
2076
|
function useConfigureSuggestions(config, options) {
|
|
2025
2077
|
const { copilotkit } = useCopilotKit();
|
|
2026
2078
|
const chatConfig = useCopilotChatConfiguration();
|
|
2027
2079
|
const extraDeps = options?.deps ?? EMPTY_DEPS;
|
|
2028
|
-
const resolvedConsumerAgentId = useMemo6(() => chatConfig?.agentId ??
|
|
2080
|
+
const resolvedConsumerAgentId = useMemo6(() => chatConfig?.agentId ?? DEFAULT_AGENT_ID6, [chatConfig?.agentId]);
|
|
2029
2081
|
const rawConsumerAgentId = useMemo6(() => config ? config.consumerAgentId : void 0, [config]);
|
|
2030
2082
|
const normalizationCacheRef = useRef6({
|
|
2031
2083
|
serialized: null,
|
|
@@ -2075,7 +2127,7 @@ function useConfigureSuggestions(config, options) {
|
|
|
2075
2127
|
return consumer;
|
|
2076
2128
|
}, [normalizedConfig, resolvedConsumerAgentId]);
|
|
2077
2129
|
const isGlobalConfig = rawConsumerAgentId === void 0 || rawConsumerAgentId === "*";
|
|
2078
|
-
const requestReload =
|
|
2130
|
+
const requestReload = useCallback6(() => {
|
|
2079
2131
|
if (!normalizedConfig) {
|
|
2080
2132
|
return;
|
|
2081
2133
|
}
|
|
@@ -2139,7 +2191,7 @@ function normalizeStaticSuggestions(suggestions) {
|
|
|
2139
2191
|
|
|
2140
2192
|
// src/components/chat/CopilotChatToolCallsView.tsx
|
|
2141
2193
|
import React8 from "react";
|
|
2142
|
-
import { Fragment as Fragment2, jsx as
|
|
2194
|
+
import { Fragment as Fragment2, jsx as jsx12 } from "react/jsx-runtime";
|
|
2143
2195
|
function CopilotChatToolCallsView({
|
|
2144
2196
|
message,
|
|
2145
2197
|
messages = []
|
|
@@ -2148,11 +2200,11 @@ function CopilotChatToolCallsView({
|
|
|
2148
2200
|
if (!message.toolCalls || message.toolCalls.length === 0) {
|
|
2149
2201
|
return null;
|
|
2150
2202
|
}
|
|
2151
|
-
return /* @__PURE__ */
|
|
2203
|
+
return /* @__PURE__ */ jsx12(Fragment2, { children: message.toolCalls.map((toolCall) => {
|
|
2152
2204
|
const toolMessage = messages.find(
|
|
2153
2205
|
(m) => m.role === "tool" && m.toolCallId === toolCall.id
|
|
2154
2206
|
);
|
|
2155
|
-
return /* @__PURE__ */
|
|
2207
|
+
return /* @__PURE__ */ jsx12(React8.Fragment, { children: renderToolCall({
|
|
2156
2208
|
toolCall,
|
|
2157
2209
|
toolMessage
|
|
2158
2210
|
}) }, toolCall.id);
|
|
@@ -2161,7 +2213,7 @@ function CopilotChatToolCallsView({
|
|
|
2161
2213
|
var CopilotChatToolCallsView_default = CopilotChatToolCallsView;
|
|
2162
2214
|
|
|
2163
2215
|
// src/components/chat/CopilotChatAssistantMessage.tsx
|
|
2164
|
-
import { Fragment as Fragment3, jsx as
|
|
2216
|
+
import { Fragment as Fragment3, jsx as jsx13, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
2165
2217
|
function CopilotChatAssistantMessage({
|
|
2166
2218
|
message,
|
|
2167
2219
|
messages,
|
|
@@ -2260,7 +2312,7 @@ function CopilotChatAssistantMessage({
|
|
|
2260
2312
|
const isLatestAssistantMessage = message.role === "assistant" && messages?.[messages.length - 1]?.id === message.id;
|
|
2261
2313
|
const shouldShowToolbar = toolbarVisible && hasContent && !(isRunning && isLatestAssistantMessage);
|
|
2262
2314
|
if (children) {
|
|
2263
|
-
return /* @__PURE__ */
|
|
2315
|
+
return /* @__PURE__ */ jsx13(Fragment3, { children: children({
|
|
2264
2316
|
markdownRenderer: boundMarkdownRenderer,
|
|
2265
2317
|
toolbar: boundToolbar,
|
|
2266
2318
|
toolCallsView: boundToolCallsView,
|
|
@@ -2298,11 +2350,11 @@ function CopilotChatAssistantMessage({
|
|
|
2298
2350
|
);
|
|
2299
2351
|
}
|
|
2300
2352
|
((CopilotChatAssistantMessage2) => {
|
|
2301
|
-
CopilotChatAssistantMessage2.MarkdownRenderer = ({ content, className, ...props }) => /* @__PURE__ */
|
|
2353
|
+
CopilotChatAssistantMessage2.MarkdownRenderer = ({ content, className, ...props }) => /* @__PURE__ */ jsx13(Streamdown, { className, ...props, children: content ?? "" });
|
|
2302
2354
|
CopilotChatAssistantMessage2.Toolbar = ({
|
|
2303
2355
|
className,
|
|
2304
2356
|
...props
|
|
2305
|
-
}) => /* @__PURE__ */
|
|
2357
|
+
}) => /* @__PURE__ */ jsx13(
|
|
2306
2358
|
"div",
|
|
2307
2359
|
{
|
|
2308
2360
|
className: twMerge4(
|
|
@@ -2314,7 +2366,7 @@ function CopilotChatAssistantMessage({
|
|
|
2314
2366
|
);
|
|
2315
2367
|
CopilotChatAssistantMessage2.ToolbarButton = ({ title, children, ...props }) => {
|
|
2316
2368
|
return /* @__PURE__ */ jsxs5(Tooltip, { children: [
|
|
2317
|
-
/* @__PURE__ */
|
|
2369
|
+
/* @__PURE__ */ jsx13(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx13(
|
|
2318
2370
|
Button,
|
|
2319
2371
|
{
|
|
2320
2372
|
type: "button",
|
|
@@ -2324,13 +2376,13 @@ function CopilotChatAssistantMessage({
|
|
|
2324
2376
|
children
|
|
2325
2377
|
}
|
|
2326
2378
|
) }),
|
|
2327
|
-
/* @__PURE__ */
|
|
2379
|
+
/* @__PURE__ */ jsx13(TooltipContent, { side: "bottom", children: /* @__PURE__ */ jsx13("p", { children: title }) })
|
|
2328
2380
|
] });
|
|
2329
2381
|
};
|
|
2330
2382
|
CopilotChatAssistantMessage2.CopyButton = ({ className, title, onClick, ...props }) => {
|
|
2331
2383
|
const config = useCopilotChatConfiguration();
|
|
2332
2384
|
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
2333
|
-
const [copied, setCopied] =
|
|
2385
|
+
const [copied, setCopied] = useState6(false);
|
|
2334
2386
|
const handleClick = (event) => {
|
|
2335
2387
|
setCopied(true);
|
|
2336
2388
|
setTimeout(() => setCopied(false), 2e3);
|
|
@@ -2338,62 +2390,62 @@ function CopilotChatAssistantMessage({
|
|
|
2338
2390
|
onClick(event);
|
|
2339
2391
|
}
|
|
2340
2392
|
};
|
|
2341
|
-
return /* @__PURE__ */
|
|
2393
|
+
return /* @__PURE__ */ jsx13(
|
|
2342
2394
|
CopilotChatAssistantMessage2.ToolbarButton,
|
|
2343
2395
|
{
|
|
2344
2396
|
title: title || labels.assistantMessageToolbarCopyMessageLabel,
|
|
2345
2397
|
onClick: handleClick,
|
|
2346
2398
|
className,
|
|
2347
2399
|
...props,
|
|
2348
|
-
children: copied ? /* @__PURE__ */
|
|
2400
|
+
children: copied ? /* @__PURE__ */ jsx13(Check2, { className: "size-[18px]" }) : /* @__PURE__ */ jsx13(Copy, { className: "size-[18px]" })
|
|
2349
2401
|
}
|
|
2350
2402
|
);
|
|
2351
2403
|
};
|
|
2352
2404
|
CopilotChatAssistantMessage2.ThumbsUpButton = ({ title, ...props }) => {
|
|
2353
2405
|
const config = useCopilotChatConfiguration();
|
|
2354
2406
|
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
2355
|
-
return /* @__PURE__ */
|
|
2407
|
+
return /* @__PURE__ */ jsx13(
|
|
2356
2408
|
CopilotChatAssistantMessage2.ToolbarButton,
|
|
2357
2409
|
{
|
|
2358
2410
|
title: title || labels.assistantMessageToolbarThumbsUpLabel,
|
|
2359
2411
|
...props,
|
|
2360
|
-
children: /* @__PURE__ */
|
|
2412
|
+
children: /* @__PURE__ */ jsx13(ThumbsUp, { className: "size-[18px]" })
|
|
2361
2413
|
}
|
|
2362
2414
|
);
|
|
2363
2415
|
};
|
|
2364
2416
|
CopilotChatAssistantMessage2.ThumbsDownButton = ({ title, ...props }) => {
|
|
2365
2417
|
const config = useCopilotChatConfiguration();
|
|
2366
2418
|
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
2367
|
-
return /* @__PURE__ */
|
|
2419
|
+
return /* @__PURE__ */ jsx13(
|
|
2368
2420
|
CopilotChatAssistantMessage2.ToolbarButton,
|
|
2369
2421
|
{
|
|
2370
2422
|
title: title || labels.assistantMessageToolbarThumbsDownLabel,
|
|
2371
2423
|
...props,
|
|
2372
|
-
children: /* @__PURE__ */
|
|
2424
|
+
children: /* @__PURE__ */ jsx13(ThumbsDown, { className: "size-[18px]" })
|
|
2373
2425
|
}
|
|
2374
2426
|
);
|
|
2375
2427
|
};
|
|
2376
2428
|
CopilotChatAssistantMessage2.ReadAloudButton = ({ title, ...props }) => {
|
|
2377
2429
|
const config = useCopilotChatConfiguration();
|
|
2378
2430
|
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
2379
|
-
return /* @__PURE__ */
|
|
2431
|
+
return /* @__PURE__ */ jsx13(
|
|
2380
2432
|
CopilotChatAssistantMessage2.ToolbarButton,
|
|
2381
2433
|
{
|
|
2382
2434
|
title: title || labels.assistantMessageToolbarReadAloudLabel,
|
|
2383
2435
|
...props,
|
|
2384
|
-
children: /* @__PURE__ */
|
|
2436
|
+
children: /* @__PURE__ */ jsx13(Volume2, { className: "size-[20px]" })
|
|
2385
2437
|
}
|
|
2386
2438
|
);
|
|
2387
2439
|
};
|
|
2388
2440
|
CopilotChatAssistantMessage2.RegenerateButton = ({ title, ...props }) => {
|
|
2389
2441
|
const config = useCopilotChatConfiguration();
|
|
2390
2442
|
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
2391
|
-
return /* @__PURE__ */
|
|
2443
|
+
return /* @__PURE__ */ jsx13(
|
|
2392
2444
|
CopilotChatAssistantMessage2.ToolbarButton,
|
|
2393
2445
|
{
|
|
2394
2446
|
title: title || labels.assistantMessageToolbarRegenerateLabel,
|
|
2395
2447
|
...props,
|
|
2396
|
-
children: /* @__PURE__ */
|
|
2448
|
+
children: /* @__PURE__ */ jsx13(RefreshCw, { className: "size-[18px]" })
|
|
2397
2449
|
}
|
|
2398
2450
|
);
|
|
2399
2451
|
};
|
|
@@ -2408,10 +2460,24 @@ CopilotChatAssistantMessage.RegenerateButton.displayName = "CopilotChatAssistant
|
|
|
2408
2460
|
var CopilotChatAssistantMessage_default = CopilotChatAssistantMessage;
|
|
2409
2461
|
|
|
2410
2462
|
// src/components/chat/CopilotChatUserMessage.tsx
|
|
2411
|
-
import { useState as
|
|
2463
|
+
import { useMemo as useMemo7, useState as useState7 } from "react";
|
|
2412
2464
|
import { Copy as Copy2, Check as Check3, Edit, ChevronLeft, ChevronRight } from "lucide-react";
|
|
2413
2465
|
import { twMerge as twMerge5 } from "tailwind-merge";
|
|
2414
|
-
import { Fragment as Fragment4, jsx as
|
|
2466
|
+
import { Fragment as Fragment4, jsx as jsx14, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
2467
|
+
function flattenUserMessageContent(content) {
|
|
2468
|
+
if (!content) {
|
|
2469
|
+
return "";
|
|
2470
|
+
}
|
|
2471
|
+
if (typeof content === "string") {
|
|
2472
|
+
return content;
|
|
2473
|
+
}
|
|
2474
|
+
return content.map((part) => {
|
|
2475
|
+
if (part && typeof part === "object" && "type" in part && part.type === "text" && typeof part.text === "string") {
|
|
2476
|
+
return part.text;
|
|
2477
|
+
}
|
|
2478
|
+
return "";
|
|
2479
|
+
}).filter((text) => text.length > 0).join("\n");
|
|
2480
|
+
}
|
|
2415
2481
|
function CopilotChatUserMessage({
|
|
2416
2482
|
message,
|
|
2417
2483
|
onEditMessage,
|
|
@@ -2428,11 +2494,15 @@ function CopilotChatUserMessage({
|
|
|
2428
2494
|
className,
|
|
2429
2495
|
...props
|
|
2430
2496
|
}) {
|
|
2497
|
+
const flattenedContent = useMemo7(
|
|
2498
|
+
() => flattenUserMessageContent(message.content),
|
|
2499
|
+
[message.content]
|
|
2500
|
+
);
|
|
2431
2501
|
const BoundMessageRenderer = renderSlot(
|
|
2432
2502
|
messageRenderer,
|
|
2433
2503
|
CopilotChatUserMessage.MessageRenderer,
|
|
2434
2504
|
{
|
|
2435
|
-
content:
|
|
2505
|
+
content: flattenedContent
|
|
2436
2506
|
}
|
|
2437
2507
|
);
|
|
2438
2508
|
const BoundCopyButton = renderSlot(
|
|
@@ -2440,9 +2510,9 @@ function CopilotChatUserMessage({
|
|
|
2440
2510
|
CopilotChatUserMessage.CopyButton,
|
|
2441
2511
|
{
|
|
2442
2512
|
onClick: async () => {
|
|
2443
|
-
if (
|
|
2513
|
+
if (flattenedContent) {
|
|
2444
2514
|
try {
|
|
2445
|
-
await navigator.clipboard.writeText(
|
|
2515
|
+
await navigator.clipboard.writeText(flattenedContent);
|
|
2446
2516
|
} catch (err) {
|
|
2447
2517
|
console.error("Failed to copy message:", err);
|
|
2448
2518
|
}
|
|
@@ -2477,7 +2547,7 @@ function CopilotChatUserMessage({
|
|
|
2477
2547
|
] })
|
|
2478
2548
|
});
|
|
2479
2549
|
if (children) {
|
|
2480
|
-
return /* @__PURE__ */
|
|
2550
|
+
return /* @__PURE__ */ jsx14(Fragment4, { children: children({
|
|
2481
2551
|
messageRenderer: BoundMessageRenderer,
|
|
2482
2552
|
toolbar: BoundToolbar,
|
|
2483
2553
|
copyButton: BoundCopyButton,
|
|
@@ -2503,7 +2573,7 @@ function CopilotChatUserMessage({
|
|
|
2503
2573
|
);
|
|
2504
2574
|
}
|
|
2505
2575
|
((CopilotChatUserMessage2) => {
|
|
2506
|
-
CopilotChatUserMessage2.Container = ({ children, className, ...props }) => /* @__PURE__ */
|
|
2576
|
+
CopilotChatUserMessage2.Container = ({ children, className, ...props }) => /* @__PURE__ */ jsx14(
|
|
2507
2577
|
"div",
|
|
2508
2578
|
{
|
|
2509
2579
|
className: twMerge5("flex flex-col items-end group", className),
|
|
@@ -2511,7 +2581,7 @@ function CopilotChatUserMessage({
|
|
|
2511
2581
|
children
|
|
2512
2582
|
}
|
|
2513
2583
|
);
|
|
2514
|
-
CopilotChatUserMessage2.MessageRenderer = ({ content, className }) => /* @__PURE__ */
|
|
2584
|
+
CopilotChatUserMessage2.MessageRenderer = ({ content, className }) => /* @__PURE__ */ jsx14(
|
|
2515
2585
|
"div",
|
|
2516
2586
|
{
|
|
2517
2587
|
className: twMerge5(
|
|
@@ -2524,7 +2594,7 @@ function CopilotChatUserMessage({
|
|
|
2524
2594
|
CopilotChatUserMessage2.Toolbar = ({
|
|
2525
2595
|
className,
|
|
2526
2596
|
...props
|
|
2527
|
-
}) => /* @__PURE__ */
|
|
2597
|
+
}) => /* @__PURE__ */ jsx14(
|
|
2528
2598
|
"div",
|
|
2529
2599
|
{
|
|
2530
2600
|
className: twMerge5(
|
|
@@ -2536,7 +2606,7 @@ function CopilotChatUserMessage({
|
|
|
2536
2606
|
);
|
|
2537
2607
|
CopilotChatUserMessage2.ToolbarButton = ({ title, children, className, ...props }) => {
|
|
2538
2608
|
return /* @__PURE__ */ jsxs6(Tooltip, { children: [
|
|
2539
|
-
/* @__PURE__ */
|
|
2609
|
+
/* @__PURE__ */ jsx14(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx14(
|
|
2540
2610
|
Button,
|
|
2541
2611
|
{
|
|
2542
2612
|
type: "button",
|
|
@@ -2547,13 +2617,13 @@ function CopilotChatUserMessage({
|
|
|
2547
2617
|
children
|
|
2548
2618
|
}
|
|
2549
2619
|
) }),
|
|
2550
|
-
/* @__PURE__ */
|
|
2620
|
+
/* @__PURE__ */ jsx14(TooltipContent, { side: "bottom", children: /* @__PURE__ */ jsx14("p", { children: title }) })
|
|
2551
2621
|
] });
|
|
2552
2622
|
};
|
|
2553
2623
|
CopilotChatUserMessage2.CopyButton = ({ className, title, onClick, ...props }) => {
|
|
2554
2624
|
const config = useCopilotChatConfiguration();
|
|
2555
2625
|
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
2556
|
-
const [copied, setCopied] =
|
|
2626
|
+
const [copied, setCopied] = useState7(false);
|
|
2557
2627
|
const handleClick = (event) => {
|
|
2558
2628
|
setCopied(true);
|
|
2559
2629
|
setTimeout(() => setCopied(false), 2e3);
|
|
@@ -2561,27 +2631,27 @@ function CopilotChatUserMessage({
|
|
|
2561
2631
|
onClick(event);
|
|
2562
2632
|
}
|
|
2563
2633
|
};
|
|
2564
|
-
return /* @__PURE__ */
|
|
2634
|
+
return /* @__PURE__ */ jsx14(
|
|
2565
2635
|
CopilotChatUserMessage2.ToolbarButton,
|
|
2566
2636
|
{
|
|
2567
2637
|
title: title || labels.userMessageToolbarCopyMessageLabel,
|
|
2568
2638
|
onClick: handleClick,
|
|
2569
2639
|
className,
|
|
2570
2640
|
...props,
|
|
2571
|
-
children: copied ? /* @__PURE__ */
|
|
2641
|
+
children: copied ? /* @__PURE__ */ jsx14(Check3, { className: "size-[18px]" }) : /* @__PURE__ */ jsx14(Copy2, { className: "size-[18px]" })
|
|
2572
2642
|
}
|
|
2573
2643
|
);
|
|
2574
2644
|
};
|
|
2575
2645
|
CopilotChatUserMessage2.EditButton = ({ className, title, ...props }) => {
|
|
2576
2646
|
const config = useCopilotChatConfiguration();
|
|
2577
2647
|
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
2578
|
-
return /* @__PURE__ */
|
|
2648
|
+
return /* @__PURE__ */ jsx14(
|
|
2579
2649
|
CopilotChatUserMessage2.ToolbarButton,
|
|
2580
2650
|
{
|
|
2581
2651
|
title: title || labels.userMessageToolbarEditMessageLabel,
|
|
2582
2652
|
className,
|
|
2583
2653
|
...props,
|
|
2584
|
-
children: /* @__PURE__ */
|
|
2654
|
+
children: /* @__PURE__ */ jsx14(Edit, { className: "size-[18px]" })
|
|
2585
2655
|
}
|
|
2586
2656
|
);
|
|
2587
2657
|
};
|
|
@@ -2599,7 +2669,7 @@ function CopilotChatUserMessage({
|
|
|
2599
2669
|
const canGoPrev = currentBranch > 0;
|
|
2600
2670
|
const canGoNext = currentBranch < numberOfBranches - 1;
|
|
2601
2671
|
return /* @__PURE__ */ jsxs6("div", { className: twMerge5("flex items-center gap-1", className), ...props, children: [
|
|
2602
|
-
/* @__PURE__ */
|
|
2672
|
+
/* @__PURE__ */ jsx14(
|
|
2603
2673
|
Button,
|
|
2604
2674
|
{
|
|
2605
2675
|
type: "button",
|
|
@@ -2611,7 +2681,7 @@ function CopilotChatUserMessage({
|
|
|
2611
2681
|
}),
|
|
2612
2682
|
disabled: !canGoPrev,
|
|
2613
2683
|
className: "h-6 w-6 p-0",
|
|
2614
|
-
children: /* @__PURE__ */
|
|
2684
|
+
children: /* @__PURE__ */ jsx14(ChevronLeft, { className: "size-[20px]" })
|
|
2615
2685
|
}
|
|
2616
2686
|
),
|
|
2617
2687
|
/* @__PURE__ */ jsxs6("span", { className: "text-sm text-muted-foreground px-0 font-medium", children: [
|
|
@@ -2619,7 +2689,7 @@ function CopilotChatUserMessage({
|
|
|
2619
2689
|
"/",
|
|
2620
2690
|
numberOfBranches
|
|
2621
2691
|
] }),
|
|
2622
|
-
/* @__PURE__ */
|
|
2692
|
+
/* @__PURE__ */ jsx14(
|
|
2623
2693
|
Button,
|
|
2624
2694
|
{
|
|
2625
2695
|
type: "button",
|
|
@@ -2631,7 +2701,7 @@ function CopilotChatUserMessage({
|
|
|
2631
2701
|
}),
|
|
2632
2702
|
disabled: !canGoNext,
|
|
2633
2703
|
className: "h-6 w-6 p-0",
|
|
2634
|
-
children: /* @__PURE__ */
|
|
2704
|
+
children: /* @__PURE__ */ jsx14(ChevronRight, { className: "size-[20px]" })
|
|
2635
2705
|
}
|
|
2636
2706
|
)
|
|
2637
2707
|
] });
|
|
@@ -2649,7 +2719,7 @@ var CopilotChatUserMessage_default = CopilotChatUserMessage;
|
|
|
2649
2719
|
// src/components/chat/CopilotChatSuggestionPill.tsx
|
|
2650
2720
|
import React9 from "react";
|
|
2651
2721
|
import { Loader2 } from "lucide-react";
|
|
2652
|
-
import { jsx as
|
|
2722
|
+
import { jsx as jsx15, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
2653
2723
|
var baseClasses = "group inline-flex h-7 sm:h-8 items-center gap-1 sm:gap-1.5 rounded-full border border-border/60 bg-background px-2.5 sm:px-3 text-[11px] sm:text-xs leading-none text-foreground transition-colors cursor-pointer hover:bg-accent/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:text-muted-foreground disabled:hover:bg-background disabled:hover:text-muted-foreground pointer-events-auto";
|
|
2654
2724
|
var labelClasses = "whitespace-nowrap font-medium leading-none";
|
|
2655
2725
|
var CopilotChatSuggestionPill = React9.forwardRef(function CopilotChatSuggestionPill2({ className, children, icon, isLoading, type, ...props }, ref) {
|
|
@@ -2665,8 +2735,8 @@ var CopilotChatSuggestionPill = React9.forwardRef(function CopilotChatSuggestion
|
|
|
2665
2735
|
disabled: isLoading || props.disabled,
|
|
2666
2736
|
...props,
|
|
2667
2737
|
children: [
|
|
2668
|
-
isLoading ? /* @__PURE__ */
|
|
2669
|
-
/* @__PURE__ */
|
|
2738
|
+
isLoading ? /* @__PURE__ */ jsx15("span", { className: "flex h-3.5 sm:h-4 w-3.5 sm:w-4 items-center justify-center text-muted-foreground", children: /* @__PURE__ */ jsx15(Loader2, { className: "h-3.5 sm:h-4 w-3.5 sm:w-4 animate-spin", "aria-hidden": "true" }) }) : showIcon && /* @__PURE__ */ jsx15("span", { className: "flex h-3.5 sm:h-4 w-3.5 sm:w-4 items-center justify-center text-muted-foreground", children: icon }),
|
|
2739
|
+
/* @__PURE__ */ jsx15("span", { className: labelClasses, children })
|
|
2670
2740
|
]
|
|
2671
2741
|
}
|
|
2672
2742
|
);
|
|
@@ -2676,9 +2746,9 @@ var CopilotChatSuggestionPill_default = CopilotChatSuggestionPill;
|
|
|
2676
2746
|
|
|
2677
2747
|
// src/components/chat/CopilotChatSuggestionView.tsx
|
|
2678
2748
|
import React10 from "react";
|
|
2679
|
-
import { Fragment as Fragment5, jsx as
|
|
2749
|
+
import { Fragment as Fragment5, jsx as jsx16, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
2680
2750
|
var DefaultContainer = React10.forwardRef(function DefaultContainer2({ className, ...props }, ref) {
|
|
2681
|
-
return /* @__PURE__ */
|
|
2751
|
+
return /* @__PURE__ */ jsx16(
|
|
2682
2752
|
"div",
|
|
2683
2753
|
{
|
|
2684
2754
|
ref,
|
|
@@ -2734,7 +2804,7 @@ var CopilotChatSuggestionView = React10.forwardRef(function CopilotChatSuggestio
|
|
|
2734
2804
|
isLoading: suggestions.length > 0 ? loadingSet.has(0) || suggestions[0]?.isLoading === true : false,
|
|
2735
2805
|
type: "button"
|
|
2736
2806
|
});
|
|
2737
|
-
return /* @__PURE__ */
|
|
2807
|
+
return /* @__PURE__ */ jsx16(Fragment5, { children: children({
|
|
2738
2808
|
container: boundContainer,
|
|
2739
2809
|
suggestion: sampleSuggestion,
|
|
2740
2810
|
suggestions,
|
|
@@ -2757,7 +2827,7 @@ var CopilotChatSuggestionView_default = CopilotChatSuggestionView;
|
|
|
2757
2827
|
|
|
2758
2828
|
// src/components/chat/CopilotChatMessageView.tsx
|
|
2759
2829
|
import { twMerge as twMerge6 } from "tailwind-merge";
|
|
2760
|
-
import { jsx as
|
|
2830
|
+
import { jsx as jsx17, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
2761
2831
|
function CopilotChatMessageView({
|
|
2762
2832
|
messages = [],
|
|
2763
2833
|
assistantMessage,
|
|
@@ -2769,6 +2839,7 @@ function CopilotChatMessageView({
|
|
|
2769
2839
|
...props
|
|
2770
2840
|
}) {
|
|
2771
2841
|
const renderCustomMessage = useRenderCustomMessages();
|
|
2842
|
+
const renderActivityMessage = useRenderActivityMessage();
|
|
2772
2843
|
const messageElements = messages.flatMap((message) => {
|
|
2773
2844
|
const elements = [];
|
|
2774
2845
|
if (renderCustomMessage) {
|
|
@@ -2795,6 +2866,11 @@ function CopilotChatMessageView({
|
|
|
2795
2866
|
message
|
|
2796
2867
|
})
|
|
2797
2868
|
);
|
|
2869
|
+
} else if (message.role === "activity") {
|
|
2870
|
+
const renderedActivity = renderActivityMessage(message);
|
|
2871
|
+
if (renderedActivity) {
|
|
2872
|
+
elements.push(renderedActivity);
|
|
2873
|
+
}
|
|
2798
2874
|
}
|
|
2799
2875
|
if (renderCustomMessage) {
|
|
2800
2876
|
elements.push(
|
|
@@ -2815,7 +2891,7 @@ function CopilotChatMessageView({
|
|
|
2815
2891
|
] });
|
|
2816
2892
|
}
|
|
2817
2893
|
CopilotChatMessageView.Cursor = function Cursor({ className, ...props }) {
|
|
2818
|
-
return /* @__PURE__ */
|
|
2894
|
+
return /* @__PURE__ */ jsx17(
|
|
2819
2895
|
"div",
|
|
2820
2896
|
{
|
|
2821
2897
|
className: twMerge6("w-[11px] h-[11px] rounded-full bg-foreground animate-pulse-cursor ml-1", className),
|
|
@@ -2826,15 +2902,15 @@ CopilotChatMessageView.Cursor = function Cursor({ className, ...props }) {
|
|
|
2826
2902
|
var CopilotChatMessageView_default = CopilotChatMessageView;
|
|
2827
2903
|
|
|
2828
2904
|
// src/components/chat/CopilotChatView.tsx
|
|
2829
|
-
import React11, { useRef as useRef7, useState as
|
|
2905
|
+
import React11, { useRef as useRef7, useState as useState9, useEffect as useEffect13 } from "react";
|
|
2830
2906
|
import { twMerge as twMerge7 } from "tailwind-merge";
|
|
2831
2907
|
import { StickToBottom, useStickToBottom, useStickToBottomContext } from "use-stick-to-bottom";
|
|
2832
2908
|
import { ChevronDown } from "lucide-react";
|
|
2833
2909
|
|
|
2834
2910
|
// src/hooks/use-keyboard-height.tsx
|
|
2835
|
-
import { useState as
|
|
2911
|
+
import { useState as useState8, useEffect as useEffect12 } from "react";
|
|
2836
2912
|
function useKeyboardHeight() {
|
|
2837
|
-
const [keyboardState, setKeyboardState] =
|
|
2913
|
+
const [keyboardState, setKeyboardState] = useState8({
|
|
2838
2914
|
isKeyboardOpen: false,
|
|
2839
2915
|
keyboardHeight: 0,
|
|
2840
2916
|
availableHeight: typeof window !== "undefined" ? window.innerHeight : 0,
|
|
@@ -2872,7 +2948,7 @@ function useKeyboardHeight() {
|
|
|
2872
2948
|
}
|
|
2873
2949
|
|
|
2874
2950
|
// src/components/chat/CopilotChatView.tsx
|
|
2875
|
-
import { Fragment as Fragment6, jsx as
|
|
2951
|
+
import { Fragment as Fragment6, jsx as jsx18, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
2876
2952
|
function CopilotChatView({
|
|
2877
2953
|
messageView,
|
|
2878
2954
|
input,
|
|
@@ -2894,8 +2970,8 @@ function CopilotChatView({
|
|
|
2894
2970
|
...props
|
|
2895
2971
|
}) {
|
|
2896
2972
|
const inputContainerRef = useRef7(null);
|
|
2897
|
-
const [inputContainerHeight, setInputContainerHeight] =
|
|
2898
|
-
const [isResizing, setIsResizing] =
|
|
2973
|
+
const [inputContainerHeight, setInputContainerHeight] = useState9(0);
|
|
2974
|
+
const [isResizing, setIsResizing] = useState9(false);
|
|
2899
2975
|
const resizeTimeoutRef = useRef7(null);
|
|
2900
2976
|
const { isKeyboardOpen, keyboardHeight, availableHeight } = useKeyboardHeight();
|
|
2901
2977
|
useEffect13(() => {
|
|
@@ -2950,9 +3026,9 @@ function CopilotChatView({
|
|
|
2950
3026
|
scrollToBottomButton,
|
|
2951
3027
|
inputContainerHeight,
|
|
2952
3028
|
isResizing,
|
|
2953
|
-
children: /* @__PURE__ */
|
|
3029
|
+
children: /* @__PURE__ */ jsx18("div", { style: { paddingBottom: `${inputContainerHeight + (hasSuggestions ? 4 : 32)}px` }, children: /* @__PURE__ */ jsxs10("div", { className: "max-w-3xl mx-auto", children: [
|
|
2954
3030
|
BoundMessageView,
|
|
2955
|
-
hasSuggestions ? /* @__PURE__ */
|
|
3031
|
+
hasSuggestions ? /* @__PURE__ */ jsx18("div", { className: "pl-0 pr-4 sm:px-0 mt-4", children: BoundSuggestionView }) : null
|
|
2956
3032
|
] }) })
|
|
2957
3033
|
});
|
|
2958
3034
|
const BoundScrollToBottomButton = renderSlot(scrollToBottomButton, CopilotChatView.ScrollToBottomButton, {});
|
|
@@ -2961,7 +3037,7 @@ function CopilotChatView({
|
|
|
2961
3037
|
ref: inputContainerRef,
|
|
2962
3038
|
keyboardHeight: isKeyboardOpen ? keyboardHeight : 0,
|
|
2963
3039
|
children: /* @__PURE__ */ jsxs10(Fragment6, { children: [
|
|
2964
|
-
/* @__PURE__ */
|
|
3040
|
+
/* @__PURE__ */ jsx18("div", { className: "max-w-3xl mx-auto py-0 px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6 pointer-events-auto", children: BoundInput }),
|
|
2965
3041
|
BoundDisclaimer
|
|
2966
3042
|
] })
|
|
2967
3043
|
});
|
|
@@ -2974,7 +3050,7 @@ function CopilotChatView({
|
|
|
2974
3050
|
feather: BoundFeather,
|
|
2975
3051
|
inputContainer: BoundInputContainer,
|
|
2976
3052
|
disclaimer: BoundDisclaimer,
|
|
2977
|
-
suggestionView: BoundSuggestionView ?? /* @__PURE__ */
|
|
3053
|
+
suggestionView: BoundSuggestionView ?? /* @__PURE__ */ jsx18(Fragment6, {})
|
|
2978
3054
|
});
|
|
2979
3055
|
}
|
|
2980
3056
|
return /* @__PURE__ */ jsxs10("div", { className: twMerge7("relative h-full", className), ...props, children: [
|
|
@@ -2987,8 +3063,8 @@ function CopilotChatView({
|
|
|
2987
3063
|
const ScrollContent = ({ children, scrollToBottomButton, inputContainerHeight, isResizing }) => {
|
|
2988
3064
|
const { isAtBottom, scrollToBottom } = useStickToBottomContext();
|
|
2989
3065
|
return /* @__PURE__ */ jsxs10(Fragment6, { children: [
|
|
2990
|
-
/* @__PURE__ */
|
|
2991
|
-
!isAtBottom && !isResizing && /* @__PURE__ */
|
|
3066
|
+
/* @__PURE__ */ jsx18(StickToBottom.Content, { className: "overflow-y-scroll overflow-x-hidden", children: /* @__PURE__ */ jsx18("div", { className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6", children }) }),
|
|
3067
|
+
!isAtBottom && !isResizing && /* @__PURE__ */ jsx18(
|
|
2992
3068
|
"div",
|
|
2993
3069
|
{
|
|
2994
3070
|
className: "absolute inset-x-0 flex justify-center z-10 pointer-events-none",
|
|
@@ -3011,9 +3087,9 @@ function CopilotChatView({
|
|
|
3011
3087
|
className,
|
|
3012
3088
|
...props
|
|
3013
3089
|
}) => {
|
|
3014
|
-
const [hasMounted, setHasMounted] =
|
|
3090
|
+
const [hasMounted, setHasMounted] = useState9(false);
|
|
3015
3091
|
const { scrollRef, contentRef, scrollToBottom } = useStickToBottom();
|
|
3016
|
-
const [showScrollButton, setShowScrollButton] =
|
|
3092
|
+
const [showScrollButton, setShowScrollButton] = useState9(false);
|
|
3017
3093
|
useEffect13(() => {
|
|
3018
3094
|
setHasMounted(true);
|
|
3019
3095
|
}, []);
|
|
@@ -3035,7 +3111,7 @@ function CopilotChatView({
|
|
|
3035
3111
|
};
|
|
3036
3112
|
}, [scrollRef, autoScroll]);
|
|
3037
3113
|
if (!hasMounted) {
|
|
3038
|
-
return /* @__PURE__ */
|
|
3114
|
+
return /* @__PURE__ */ jsx18("div", { className: "h-full max-h-full flex flex-col min-h-0 overflow-y-scroll overflow-x-hidden", children: /* @__PURE__ */ jsx18("div", { className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6", children }) });
|
|
3039
3115
|
}
|
|
3040
3116
|
if (!autoScroll) {
|
|
3041
3117
|
return /* @__PURE__ */ jsxs10(
|
|
@@ -3048,8 +3124,8 @@ function CopilotChatView({
|
|
|
3048
3124
|
),
|
|
3049
3125
|
...props,
|
|
3050
3126
|
children: [
|
|
3051
|
-
/* @__PURE__ */
|
|
3052
|
-
showScrollButton && !isResizing && /* @__PURE__ */
|
|
3127
|
+
/* @__PURE__ */ jsx18("div", { ref: contentRef, className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6", children }),
|
|
3128
|
+
showScrollButton && !isResizing && /* @__PURE__ */ jsx18(
|
|
3053
3129
|
"div",
|
|
3054
3130
|
{
|
|
3055
3131
|
className: "absolute inset-x-0 flex justify-center z-10 pointer-events-none",
|
|
@@ -3065,14 +3141,14 @@ function CopilotChatView({
|
|
|
3065
3141
|
}
|
|
3066
3142
|
);
|
|
3067
3143
|
}
|
|
3068
|
-
return /* @__PURE__ */
|
|
3144
|
+
return /* @__PURE__ */ jsx18(
|
|
3069
3145
|
StickToBottom,
|
|
3070
3146
|
{
|
|
3071
3147
|
className: cn("h-full max-h-full flex flex-col min-h-0 relative", className),
|
|
3072
3148
|
resize: "smooth",
|
|
3073
3149
|
initial: "smooth",
|
|
3074
3150
|
...props,
|
|
3075
|
-
children: /* @__PURE__ */
|
|
3151
|
+
children: /* @__PURE__ */ jsx18(
|
|
3076
3152
|
ScrollContent,
|
|
3077
3153
|
{
|
|
3078
3154
|
scrollToBottomButton,
|
|
@@ -3087,7 +3163,7 @@ function CopilotChatView({
|
|
|
3087
3163
|
CopilotChatView2.ScrollToBottomButton = ({
|
|
3088
3164
|
className,
|
|
3089
3165
|
...props
|
|
3090
|
-
}) => /* @__PURE__ */
|
|
3166
|
+
}) => /* @__PURE__ */ jsx18(
|
|
3091
3167
|
Button,
|
|
3092
3168
|
{
|
|
3093
3169
|
variant: "outline",
|
|
@@ -3101,10 +3177,10 @@ function CopilotChatView({
|
|
|
3101
3177
|
className
|
|
3102
3178
|
),
|
|
3103
3179
|
...props,
|
|
3104
|
-
children: /* @__PURE__ */
|
|
3180
|
+
children: /* @__PURE__ */ jsx18(ChevronDown, { className: "w-4 h-4 text-gray-600 dark:text-white" })
|
|
3105
3181
|
}
|
|
3106
3182
|
);
|
|
3107
|
-
CopilotChatView2.Feather = ({ className, style, ...props }) => /* @__PURE__ */
|
|
3183
|
+
CopilotChatView2.Feather = ({ className, style, ...props }) => /* @__PURE__ */ jsx18(
|
|
3108
3184
|
"div",
|
|
3109
3185
|
{
|
|
3110
3186
|
className: cn(
|
|
@@ -3117,7 +3193,7 @@ function CopilotChatView({
|
|
|
3117
3193
|
...props
|
|
3118
3194
|
}
|
|
3119
3195
|
);
|
|
3120
|
-
CopilotChatView2.InputContainer = React11.forwardRef(({ children, className, keyboardHeight = 0, ...props }, ref) => /* @__PURE__ */
|
|
3196
|
+
CopilotChatView2.InputContainer = React11.forwardRef(({ children, className, keyboardHeight = 0, ...props }, ref) => /* @__PURE__ */ jsx18(
|
|
3121
3197
|
"div",
|
|
3122
3198
|
{
|
|
3123
3199
|
ref,
|
|
@@ -3135,7 +3211,7 @@ function CopilotChatView({
|
|
|
3135
3211
|
CopilotChatView2.Disclaimer = ({ className, ...props }) => {
|
|
3136
3212
|
const config = useCopilotChatConfiguration();
|
|
3137
3213
|
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
3138
|
-
return /* @__PURE__ */
|
|
3214
|
+
return /* @__PURE__ */ jsx18(
|
|
3139
3215
|
"div",
|
|
3140
3216
|
{
|
|
3141
3217
|
className: cn("text-center text-xs text-muted-foreground py-3 px-4 max-w-3xl mx-auto", className),
|
|
@@ -3148,15 +3224,15 @@ function CopilotChatView({
|
|
|
3148
3224
|
var CopilotChatView_default = CopilotChatView;
|
|
3149
3225
|
|
|
3150
3226
|
// src/components/chat/CopilotChat.tsx
|
|
3151
|
-
import { DEFAULT_AGENT_ID as
|
|
3152
|
-
import { useCallback as
|
|
3227
|
+
import { DEFAULT_AGENT_ID as DEFAULT_AGENT_ID7, randomUUID as randomUUID2 } from "@copilotkitnext/shared";
|
|
3228
|
+
import { useCallback as useCallback7, useEffect as useEffect14, useMemo as useMemo8 } from "react";
|
|
3153
3229
|
import { merge } from "ts-deepmerge";
|
|
3154
3230
|
import { AGUIConnectNotImplementedError } from "@ag-ui/client";
|
|
3155
|
-
import { jsx as
|
|
3231
|
+
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
3156
3232
|
function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen, ...props }) {
|
|
3157
3233
|
const existingConfig = useCopilotChatConfiguration();
|
|
3158
|
-
const resolvedAgentId = agentId ?? existingConfig?.agentId ??
|
|
3159
|
-
const resolvedThreadId =
|
|
3234
|
+
const resolvedAgentId = agentId ?? existingConfig?.agentId ?? DEFAULT_AGENT_ID7;
|
|
3235
|
+
const resolvedThreadId = useMemo8(
|
|
3160
3236
|
() => threadId ?? existingConfig?.threadId ?? randomUUID2(),
|
|
3161
3237
|
[threadId, existingConfig?.threadId]
|
|
3162
3238
|
);
|
|
@@ -3187,7 +3263,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
3187
3263
|
return () => {
|
|
3188
3264
|
};
|
|
3189
3265
|
}, [resolvedThreadId, agent, copilotkit, resolvedAgentId]);
|
|
3190
|
-
const onSubmitInput =
|
|
3266
|
+
const onSubmitInput = useCallback7(
|
|
3191
3267
|
async (value) => {
|
|
3192
3268
|
agent?.addMessage({
|
|
3193
3269
|
id: randomUUID2(),
|
|
@@ -3204,7 +3280,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
3204
3280
|
},
|
|
3205
3281
|
[agent, copilotkit]
|
|
3206
3282
|
);
|
|
3207
|
-
const handleSelectSuggestion =
|
|
3283
|
+
const handleSelectSuggestion = useCallback7(
|
|
3208
3284
|
async (suggestion) => {
|
|
3209
3285
|
if (!agent) {
|
|
3210
3286
|
return;
|
|
@@ -3222,7 +3298,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
3222
3298
|
},
|
|
3223
3299
|
[agent, copilotkit]
|
|
3224
3300
|
);
|
|
3225
|
-
const stopCurrentRun =
|
|
3301
|
+
const stopCurrentRun = useCallback7(() => {
|
|
3226
3302
|
if (!agent) {
|
|
3227
3303
|
return;
|
|
3228
3304
|
}
|
|
@@ -3265,7 +3341,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
3265
3341
|
inputProps: finalInputProps
|
|
3266
3342
|
});
|
|
3267
3343
|
const RenderedChatView = renderSlot(chatView, CopilotChatView, finalProps);
|
|
3268
|
-
return /* @__PURE__ */
|
|
3344
|
+
return /* @__PURE__ */ jsx19(
|
|
3269
3345
|
CopilotChatConfigurationProvider,
|
|
3270
3346
|
{
|
|
3271
3347
|
agentId: resolvedAgentId,
|
|
@@ -3281,17 +3357,17 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
3281
3357
|
})(CopilotChat || (CopilotChat = {}));
|
|
3282
3358
|
|
|
3283
3359
|
// src/components/chat/CopilotChatToggleButton.tsx
|
|
3284
|
-
import React12, { useState as
|
|
3360
|
+
import React12, { useState as useState10 } from "react";
|
|
3285
3361
|
import { MessageCircle, X as X2 } from "lucide-react";
|
|
3286
|
-
import { jsx as
|
|
3362
|
+
import { jsx as jsx20, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
3287
3363
|
var DefaultOpenIcon = ({
|
|
3288
3364
|
className,
|
|
3289
3365
|
...props
|
|
3290
|
-
}) => /* @__PURE__ */
|
|
3366
|
+
}) => /* @__PURE__ */ jsx20(MessageCircle, { className: cn("h-6 w-6", className), strokeWidth: 1.75, fill: "currentColor", ...props });
|
|
3291
3367
|
var DefaultCloseIcon = ({
|
|
3292
3368
|
className,
|
|
3293
3369
|
...props
|
|
3294
|
-
}) => /* @__PURE__ */
|
|
3370
|
+
}) => /* @__PURE__ */ jsx20(X2, { className: cn("h-6 w-6", className), strokeWidth: 1.75, ...props });
|
|
3295
3371
|
DefaultOpenIcon.displayName = "CopilotChatToggleButton.OpenIcon";
|
|
3296
3372
|
DefaultCloseIcon.displayName = "CopilotChatToggleButton.CloseIcon";
|
|
3297
3373
|
var ICON_TRANSITION_STYLE = Object.freeze({
|
|
@@ -3312,7 +3388,7 @@ var CopilotChatToggleButton = React12.forwardRef(function CopilotChatToggleButto
|
|
|
3312
3388
|
const { onClick, type, disabled, ...restProps } = buttonProps;
|
|
3313
3389
|
const configuration = useCopilotChatConfiguration();
|
|
3314
3390
|
const labels = configuration?.labels ?? CopilotChatDefaultLabels;
|
|
3315
|
-
const [fallbackOpen, setFallbackOpen] =
|
|
3391
|
+
const [fallbackOpen, setFallbackOpen] = useState10(false);
|
|
3316
3392
|
const isOpen = configuration?.isModalOpen ?? fallbackOpen;
|
|
3317
3393
|
const setModalOpen = configuration?.setModalOpen ?? setFallbackOpen;
|
|
3318
3394
|
const handleClick = (event) => {
|
|
@@ -3346,7 +3422,7 @@ var CopilotChatToggleButton = React12.forwardRef(function CopilotChatToggleButto
|
|
|
3346
3422
|
focusable: false
|
|
3347
3423
|
}
|
|
3348
3424
|
);
|
|
3349
|
-
const openIconElement = /* @__PURE__ */
|
|
3425
|
+
const openIconElement = /* @__PURE__ */ jsx20(
|
|
3350
3426
|
"span",
|
|
3351
3427
|
{
|
|
3352
3428
|
"aria-hidden": "true",
|
|
@@ -3360,7 +3436,7 @@ var CopilotChatToggleButton = React12.forwardRef(function CopilotChatToggleButto
|
|
|
3360
3436
|
children: renderedOpenIcon
|
|
3361
3437
|
}
|
|
3362
3438
|
);
|
|
3363
|
-
const closeIconElement = /* @__PURE__ */
|
|
3439
|
+
const closeIconElement = /* @__PURE__ */ jsx20(
|
|
3364
3440
|
"span",
|
|
3365
3441
|
{
|
|
3366
3442
|
"aria-hidden": "true",
|
|
@@ -3398,12 +3474,12 @@ CopilotChatToggleButton.displayName = "CopilotChatToggleButton";
|
|
|
3398
3474
|
var CopilotChatToggleButton_default = CopilotChatToggleButton;
|
|
3399
3475
|
|
|
3400
3476
|
// src/components/chat/CopilotSidebarView.tsx
|
|
3401
|
-
import { useEffect as useEffect15, useRef as useRef8, useState as
|
|
3477
|
+
import { useEffect as useEffect15, useRef as useRef8, useState as useState11 } from "react";
|
|
3402
3478
|
|
|
3403
3479
|
// src/components/chat/CopilotModalHeader.tsx
|
|
3404
|
-
import { useCallback as
|
|
3480
|
+
import { useCallback as useCallback8 } from "react";
|
|
3405
3481
|
import { X as X3 } from "lucide-react";
|
|
3406
|
-
import { jsx as
|
|
3482
|
+
import { jsx as jsx21, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
3407
3483
|
function CopilotModalHeader({
|
|
3408
3484
|
title,
|
|
3409
3485
|
titleContent,
|
|
@@ -3415,7 +3491,7 @@ function CopilotModalHeader({
|
|
|
3415
3491
|
const configuration = useCopilotChatConfiguration();
|
|
3416
3492
|
const fallbackTitle = configuration?.labels.modalHeaderTitle ?? CopilotChatDefaultLabels.modalHeaderTitle;
|
|
3417
3493
|
const resolvedTitle = title ?? fallbackTitle;
|
|
3418
|
-
const handleClose =
|
|
3494
|
+
const handleClose = useCallback8(() => {
|
|
3419
3495
|
configuration?.setModalOpen(false);
|
|
3420
3496
|
}, [configuration]);
|
|
3421
3497
|
const BoundTitle = renderSlot(titleContent, CopilotModalHeader.Title, {
|
|
@@ -3432,7 +3508,7 @@ function CopilotModalHeader({
|
|
|
3432
3508
|
...rest
|
|
3433
3509
|
});
|
|
3434
3510
|
}
|
|
3435
|
-
return /* @__PURE__ */
|
|
3511
|
+
return /* @__PURE__ */ jsx21(
|
|
3436
3512
|
"header",
|
|
3437
3513
|
{
|
|
3438
3514
|
"data-slot": "copilot-modal-header",
|
|
@@ -3443,16 +3519,16 @@ function CopilotModalHeader({
|
|
|
3443
3519
|
),
|
|
3444
3520
|
...rest,
|
|
3445
3521
|
children: /* @__PURE__ */ jsxs12("div", { className: "flex w-full items-center gap-2", children: [
|
|
3446
|
-
/* @__PURE__ */
|
|
3447
|
-
/* @__PURE__ */
|
|
3448
|
-
/* @__PURE__ */
|
|
3522
|
+
/* @__PURE__ */ jsx21("div", { className: "flex-1", "aria-hidden": "true" }),
|
|
3523
|
+
/* @__PURE__ */ jsx21("div", { className: "flex flex-1 justify-center text-center", children: BoundTitle }),
|
|
3524
|
+
/* @__PURE__ */ jsx21("div", { className: "flex flex-1 justify-end", children: BoundCloseButton })
|
|
3449
3525
|
] })
|
|
3450
3526
|
}
|
|
3451
3527
|
);
|
|
3452
3528
|
}
|
|
3453
3529
|
CopilotModalHeader.displayName = "CopilotModalHeader";
|
|
3454
3530
|
((CopilotModalHeader2) => {
|
|
3455
|
-
CopilotModalHeader2.Title = ({ children, className, ...props }) => /* @__PURE__ */
|
|
3531
|
+
CopilotModalHeader2.Title = ({ children, className, ...props }) => /* @__PURE__ */ jsx21(
|
|
3456
3532
|
"div",
|
|
3457
3533
|
{
|
|
3458
3534
|
className: cn(
|
|
@@ -3466,7 +3542,7 @@ CopilotModalHeader.displayName = "CopilotModalHeader";
|
|
|
3466
3542
|
CopilotModalHeader2.CloseButton = ({
|
|
3467
3543
|
className,
|
|
3468
3544
|
...props
|
|
3469
|
-
}) => /* @__PURE__ */
|
|
3545
|
+
}) => /* @__PURE__ */ jsx21(
|
|
3470
3546
|
"button",
|
|
3471
3547
|
{
|
|
3472
3548
|
type: "button",
|
|
@@ -3477,7 +3553,7 @@ CopilotModalHeader.displayName = "CopilotModalHeader";
|
|
|
3477
3553
|
),
|
|
3478
3554
|
"aria-label": "Close",
|
|
3479
3555
|
...props,
|
|
3480
|
-
children: /* @__PURE__ */
|
|
3556
|
+
children: /* @__PURE__ */ jsx21(X3, { className: "h-4 w-4", "aria-hidden": "true" })
|
|
3481
3557
|
}
|
|
3482
3558
|
);
|
|
3483
3559
|
})(CopilotModalHeader || (CopilotModalHeader = {}));
|
|
@@ -3485,14 +3561,14 @@ CopilotModalHeader.Title.displayName = "CopilotModalHeader.Title";
|
|
|
3485
3561
|
CopilotModalHeader.CloseButton.displayName = "CopilotModalHeader.CloseButton";
|
|
3486
3562
|
|
|
3487
3563
|
// src/components/chat/CopilotSidebarView.tsx
|
|
3488
|
-
import { Fragment as Fragment7, jsx as
|
|
3564
|
+
import { Fragment as Fragment7, jsx as jsx22, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
3489
3565
|
var DEFAULT_SIDEBAR_WIDTH = 480;
|
|
3490
3566
|
var SIDEBAR_TRANSITION_MS = 260;
|
|
3491
3567
|
function CopilotSidebarView({ header, width, ...props }) {
|
|
3492
3568
|
const configuration = useCopilotChatConfiguration();
|
|
3493
3569
|
const isSidebarOpen = configuration?.isModalOpen ?? false;
|
|
3494
3570
|
const sidebarRef = useRef8(null);
|
|
3495
|
-
const [sidebarWidth, setSidebarWidth] =
|
|
3571
|
+
const [sidebarWidth, setSidebarWidth] = useState11(width ?? DEFAULT_SIDEBAR_WIDTH);
|
|
3496
3572
|
const widthToCss = (w) => {
|
|
3497
3573
|
return typeof w === "number" ? `${w}px` : w;
|
|
3498
3574
|
};
|
|
@@ -3530,7 +3606,7 @@ function CopilotSidebarView({ header, width, ...props }) {
|
|
|
3530
3606
|
}, [width]);
|
|
3531
3607
|
const headerElement = renderSlot(header, CopilotModalHeader, {});
|
|
3532
3608
|
return /* @__PURE__ */ jsxs13(Fragment7, { children: [
|
|
3533
|
-
isSidebarOpen && /* @__PURE__ */
|
|
3609
|
+
isSidebarOpen && /* @__PURE__ */ jsx22(
|
|
3534
3610
|
"style",
|
|
3535
3611
|
{
|
|
3536
3612
|
dangerouslySetInnerHTML: {
|
|
@@ -3544,8 +3620,8 @@ function CopilotSidebarView({ header, width, ...props }) {
|
|
|
3544
3620
|
}
|
|
3545
3621
|
}
|
|
3546
3622
|
),
|
|
3547
|
-
/* @__PURE__ */
|
|
3548
|
-
/* @__PURE__ */
|
|
3623
|
+
/* @__PURE__ */ jsx22(CopilotChatToggleButton_default, {}),
|
|
3624
|
+
/* @__PURE__ */ jsx22(
|
|
3549
3625
|
"aside",
|
|
3550
3626
|
{
|
|
3551
3627
|
ref: sidebarRef,
|
|
@@ -3572,7 +3648,7 @@ function CopilotSidebarView({ header, width, ...props }) {
|
|
|
3572
3648
|
role: "complementary",
|
|
3573
3649
|
children: /* @__PURE__ */ jsxs13("div", { className: "flex h-full w-full flex-col overflow-hidden", children: [
|
|
3574
3650
|
headerElement,
|
|
3575
|
-
/* @__PURE__ */
|
|
3651
|
+
/* @__PURE__ */ jsx22("div", { className: "flex-1 overflow-hidden", "data-sidebar-chat": true, children: /* @__PURE__ */ jsx22(CopilotChatView_default, { ...props }) })
|
|
3576
3652
|
] })
|
|
3577
3653
|
}
|
|
3578
3654
|
)
|
|
@@ -3581,8 +3657,8 @@ function CopilotSidebarView({ header, width, ...props }) {
|
|
|
3581
3657
|
CopilotSidebarView.displayName = "CopilotSidebarView";
|
|
3582
3658
|
|
|
3583
3659
|
// src/components/chat/CopilotPopupView.tsx
|
|
3584
|
-
import { useEffect as useEffect16, useMemo as
|
|
3585
|
-
import { Fragment as Fragment8, jsx as
|
|
3660
|
+
import { useEffect as useEffect16, useMemo as useMemo9, useRef as useRef9, useState as useState12 } from "react";
|
|
3661
|
+
import { Fragment as Fragment8, jsx as jsx23, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
3586
3662
|
var DEFAULT_POPUP_WIDTH = 420;
|
|
3587
3663
|
var DEFAULT_POPUP_HEIGHT = 560;
|
|
3588
3664
|
var dimensionToCss = (value, fallback) => {
|
|
@@ -3607,8 +3683,8 @@ function CopilotPopupView({
|
|
|
3607
3683
|
const setModalOpen = configuration?.setModalOpen;
|
|
3608
3684
|
const labels = configuration?.labels ?? CopilotChatDefaultLabels;
|
|
3609
3685
|
const containerRef = useRef9(null);
|
|
3610
|
-
const [isRendered, setIsRendered] =
|
|
3611
|
-
const [isAnimatingOut, setIsAnimatingOut] =
|
|
3686
|
+
const [isRendered, setIsRendered] = useState12(isPopupOpen);
|
|
3687
|
+
const [isAnimatingOut, setIsAnimatingOut] = useState12(false);
|
|
3612
3688
|
useEffect16(() => {
|
|
3613
3689
|
if (isPopupOpen) {
|
|
3614
3690
|
setIsRendered(true);
|
|
@@ -3675,10 +3751,10 @@ function CopilotPopupView({
|
|
|
3675
3751
|
document.addEventListener("pointerdown", handlePointerDown);
|
|
3676
3752
|
return () => document.removeEventListener("pointerdown", handlePointerDown);
|
|
3677
3753
|
}, [isPopupOpen, clickOutsideToClose, setModalOpen]);
|
|
3678
|
-
const headerElement =
|
|
3754
|
+
const headerElement = useMemo9(() => renderSlot(header, CopilotModalHeader, {}), [header]);
|
|
3679
3755
|
const resolvedWidth = dimensionToCss(width, DEFAULT_POPUP_WIDTH);
|
|
3680
3756
|
const resolvedHeight = dimensionToCss(height, DEFAULT_POPUP_HEIGHT);
|
|
3681
|
-
const popupStyle =
|
|
3757
|
+
const popupStyle = useMemo9(
|
|
3682
3758
|
() => ({
|
|
3683
3759
|
"--copilot-popup-width": resolvedWidth,
|
|
3684
3760
|
"--copilot-popup-height": resolvedHeight,
|
|
@@ -3692,7 +3768,7 @@ function CopilotPopupView({
|
|
|
3692
3768
|
[resolvedHeight, resolvedWidth]
|
|
3693
3769
|
);
|
|
3694
3770
|
const popupAnimationClass = isPopupOpen && !isAnimatingOut ? "pointer-events-auto translate-y-0 opacity-100 md:scale-100" : "pointer-events-none translate-y-4 opacity-0 md:translate-y-5 md:scale-[0.95]";
|
|
3695
|
-
const popupContent = isRendered ? /* @__PURE__ */
|
|
3771
|
+
const popupContent = isRendered ? /* @__PURE__ */ jsx23(
|
|
3696
3772
|
"div",
|
|
3697
3773
|
{
|
|
3698
3774
|
className: cn(
|
|
@@ -3720,7 +3796,7 @@ function CopilotPopupView({
|
|
|
3720
3796
|
style: popupStyle,
|
|
3721
3797
|
children: [
|
|
3722
3798
|
headerElement,
|
|
3723
|
-
/* @__PURE__ */
|
|
3799
|
+
/* @__PURE__ */ jsx23("div", { className: "flex-1 overflow-hidden", "data-popup-chat": true, children: /* @__PURE__ */ jsx23(
|
|
3724
3800
|
CopilotChatView_default,
|
|
3725
3801
|
{
|
|
3726
3802
|
...restProps,
|
|
@@ -3733,20 +3809,20 @@ function CopilotPopupView({
|
|
|
3733
3809
|
}
|
|
3734
3810
|
) : null;
|
|
3735
3811
|
return /* @__PURE__ */ jsxs14(Fragment8, { children: [
|
|
3736
|
-
/* @__PURE__ */
|
|
3812
|
+
/* @__PURE__ */ jsx23(CopilotChatToggleButton_default, {}),
|
|
3737
3813
|
popupContent
|
|
3738
3814
|
] });
|
|
3739
3815
|
}
|
|
3740
3816
|
CopilotPopupView.displayName = "CopilotPopupView";
|
|
3741
3817
|
|
|
3742
3818
|
// src/components/chat/CopilotSidebar.tsx
|
|
3743
|
-
import { useMemo as
|
|
3744
|
-
import { jsx as
|
|
3819
|
+
import { useMemo as useMemo10 } from "react";
|
|
3820
|
+
import { jsx as jsx24 } from "react/jsx-runtime";
|
|
3745
3821
|
function CopilotSidebar({ header, defaultOpen, width, ...chatProps }) {
|
|
3746
|
-
const SidebarViewOverride =
|
|
3822
|
+
const SidebarViewOverride = useMemo10(() => {
|
|
3747
3823
|
const Component = (viewProps) => {
|
|
3748
3824
|
const { header: viewHeader, width: viewWidth, ...restProps } = viewProps;
|
|
3749
|
-
return /* @__PURE__ */
|
|
3825
|
+
return /* @__PURE__ */ jsx24(
|
|
3750
3826
|
CopilotSidebarView,
|
|
3751
3827
|
{
|
|
3752
3828
|
...restProps,
|
|
@@ -3757,7 +3833,7 @@ function CopilotSidebar({ header, defaultOpen, width, ...chatProps }) {
|
|
|
3757
3833
|
};
|
|
3758
3834
|
return Object.assign(Component, CopilotChatView_default);
|
|
3759
3835
|
}, [header, width]);
|
|
3760
|
-
return /* @__PURE__ */
|
|
3836
|
+
return /* @__PURE__ */ jsx24(
|
|
3761
3837
|
CopilotChat,
|
|
3762
3838
|
{
|
|
3763
3839
|
...chatProps,
|
|
@@ -3769,8 +3845,8 @@ function CopilotSidebar({ header, defaultOpen, width, ...chatProps }) {
|
|
|
3769
3845
|
CopilotSidebar.displayName = "CopilotSidebar";
|
|
3770
3846
|
|
|
3771
3847
|
// src/components/chat/CopilotPopup.tsx
|
|
3772
|
-
import { useMemo as
|
|
3773
|
-
import { jsx as
|
|
3848
|
+
import { useMemo as useMemo11 } from "react";
|
|
3849
|
+
import { jsx as jsx25 } from "react/jsx-runtime";
|
|
3774
3850
|
function CopilotPopup({
|
|
3775
3851
|
header,
|
|
3776
3852
|
defaultOpen,
|
|
@@ -3779,7 +3855,7 @@ function CopilotPopup({
|
|
|
3779
3855
|
clickOutsideToClose,
|
|
3780
3856
|
...chatProps
|
|
3781
3857
|
}) {
|
|
3782
|
-
const PopupViewOverride =
|
|
3858
|
+
const PopupViewOverride = useMemo11(() => {
|
|
3783
3859
|
const Component = (viewProps) => {
|
|
3784
3860
|
const {
|
|
3785
3861
|
header: viewHeader,
|
|
@@ -3788,7 +3864,7 @@ function CopilotPopup({
|
|
|
3788
3864
|
clickOutsideToClose: viewClickOutsideToClose,
|
|
3789
3865
|
...restProps
|
|
3790
3866
|
} = viewProps;
|
|
3791
|
-
return /* @__PURE__ */
|
|
3867
|
+
return /* @__PURE__ */ jsx25(
|
|
3792
3868
|
CopilotPopupView,
|
|
3793
3869
|
{
|
|
3794
3870
|
...restProps,
|
|
@@ -3801,7 +3877,7 @@ function CopilotPopup({
|
|
|
3801
3877
|
};
|
|
3802
3878
|
return Object.assign(Component, CopilotChatView_default);
|
|
3803
3879
|
}, [clickOutsideToClose, header, height, width]);
|
|
3804
|
-
return /* @__PURE__ */
|
|
3880
|
+
return /* @__PURE__ */ jsx25(
|
|
3805
3881
|
CopilotChat,
|
|
3806
3882
|
{
|
|
3807
3883
|
...chatProps,
|
|
@@ -3825,17 +3901,17 @@ function defineToolCallRenderer(def) {
|
|
|
3825
3901
|
}
|
|
3826
3902
|
|
|
3827
3903
|
// src/components/WildcardToolCallRender.tsx
|
|
3828
|
-
import { useState as
|
|
3829
|
-
import { jsx as
|
|
3904
|
+
import { useState as useState13 } from "react";
|
|
3905
|
+
import { jsx as jsx26, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
3830
3906
|
var WildcardToolCallRender = defineToolCallRenderer({
|
|
3831
3907
|
name: "*",
|
|
3832
3908
|
render: ({ args, result, name, status }) => {
|
|
3833
|
-
const [isExpanded, setIsExpanded] =
|
|
3909
|
+
const [isExpanded, setIsExpanded] = useState13(false);
|
|
3834
3910
|
const statusString = String(status);
|
|
3835
3911
|
const isActive = statusString === "inProgress" || statusString === "executing";
|
|
3836
3912
|
const isComplete = statusString === "complete";
|
|
3837
3913
|
const statusStyles = isActive ? "bg-amber-100 text-amber-800 dark:bg-amber-500/15 dark:text-amber-400" : isComplete ? "bg-emerald-100 text-emerald-800 dark:bg-emerald-500/15 dark:text-emerald-400" : "bg-zinc-100 text-zinc-800 dark:bg-zinc-700/40 dark:text-zinc-300";
|
|
3838
|
-
return /* @__PURE__ */
|
|
3914
|
+
return /* @__PURE__ */ jsx26("div", { className: "mt-2 pb-2", children: /* @__PURE__ */ jsxs15("div", { className: "rounded-xl border border-zinc-200/60 dark:border-zinc-800/60 bg-white/70 dark:bg-zinc-900/50 shadow-sm backdrop-blur p-4", children: [
|
|
3839
3915
|
/* @__PURE__ */ jsxs15(
|
|
3840
3916
|
"div",
|
|
3841
3917
|
{
|
|
@@ -3843,7 +3919,7 @@ var WildcardToolCallRender = defineToolCallRenderer({
|
|
|
3843
3919
|
onClick: () => setIsExpanded(!isExpanded),
|
|
3844
3920
|
children: [
|
|
3845
3921
|
/* @__PURE__ */ jsxs15("div", { className: "flex items-center gap-2 min-w-0", children: [
|
|
3846
|
-
/* @__PURE__ */
|
|
3922
|
+
/* @__PURE__ */ jsx26(
|
|
3847
3923
|
"svg",
|
|
3848
3924
|
{
|
|
3849
3925
|
className: `h-4 w-4 text-zinc-500 dark:text-zinc-400 transition-transform ${isExpanded ? "rotate-90" : ""}`,
|
|
@@ -3851,7 +3927,7 @@ var WildcardToolCallRender = defineToolCallRenderer({
|
|
|
3851
3927
|
viewBox: "0 0 24 24",
|
|
3852
3928
|
strokeWidth: 2,
|
|
3853
3929
|
stroke: "currentColor",
|
|
3854
|
-
children: /* @__PURE__ */
|
|
3930
|
+
children: /* @__PURE__ */ jsx26(
|
|
3855
3931
|
"path",
|
|
3856
3932
|
{
|
|
3857
3933
|
strokeLinecap: "round",
|
|
@@ -3861,10 +3937,10 @@ var WildcardToolCallRender = defineToolCallRenderer({
|
|
|
3861
3937
|
)
|
|
3862
3938
|
}
|
|
3863
3939
|
),
|
|
3864
|
-
/* @__PURE__ */
|
|
3865
|
-
/* @__PURE__ */
|
|
3940
|
+
/* @__PURE__ */ jsx26("span", { className: "inline-block h-2 w-2 rounded-full bg-blue-500" }),
|
|
3941
|
+
/* @__PURE__ */ jsx26("span", { className: "truncate text-sm font-medium text-zinc-900 dark:text-zinc-100", children: name })
|
|
3866
3942
|
] }),
|
|
3867
|
-
/* @__PURE__ */
|
|
3943
|
+
/* @__PURE__ */ jsx26(
|
|
3868
3944
|
"span",
|
|
3869
3945
|
{
|
|
3870
3946
|
className: `inline-flex items-center rounded-full px-2 py-1 text-xs font-medium ${statusStyles}`,
|
|
@@ -3876,12 +3952,12 @@ var WildcardToolCallRender = defineToolCallRenderer({
|
|
|
3876
3952
|
),
|
|
3877
3953
|
isExpanded && /* @__PURE__ */ jsxs15("div", { className: "mt-3 grid gap-4", children: [
|
|
3878
3954
|
/* @__PURE__ */ jsxs15("div", { children: [
|
|
3879
|
-
/* @__PURE__ */
|
|
3880
|
-
/* @__PURE__ */
|
|
3955
|
+
/* @__PURE__ */ jsx26("div", { className: "text-xs uppercase tracking-wide text-zinc-500 dark:text-zinc-400", children: "Arguments" }),
|
|
3956
|
+
/* @__PURE__ */ jsx26("pre", { className: "mt-2 max-h-64 overflow-auto rounded-md bg-zinc-50 dark:bg-zinc-800/60 p-3 text-xs leading-relaxed text-zinc-800 dark:text-zinc-200 whitespace-pre-wrap break-words", children: JSON.stringify(args ?? {}, null, 2) })
|
|
3881
3957
|
] }),
|
|
3882
3958
|
result !== void 0 && /* @__PURE__ */ jsxs15("div", { children: [
|
|
3883
|
-
/* @__PURE__ */
|
|
3884
|
-
/* @__PURE__ */
|
|
3959
|
+
/* @__PURE__ */ jsx26("div", { className: "text-xs uppercase tracking-wide text-zinc-500 dark:text-zinc-400", children: "Result" }),
|
|
3960
|
+
/* @__PURE__ */ jsx26("pre", { className: "mt-2 max-h-64 overflow-auto rounded-md bg-zinc-50 dark:bg-zinc-800/60 p-3 text-xs leading-relaxed text-zinc-800 dark:text-zinc-200 whitespace-pre-wrap break-words", children: typeof result === "string" ? result : JSON.stringify(result, null, 2) })
|
|
3885
3961
|
] })
|
|
3886
3962
|
] })
|
|
3887
3963
|
] }) });
|
|
@@ -3920,6 +3996,7 @@ export {
|
|
|
3920
3996
|
useCopilotKit,
|
|
3921
3997
|
useFrontendTool,
|
|
3922
3998
|
useHumanInTheLoop,
|
|
3999
|
+
useRenderActivityMessage,
|
|
3923
4000
|
useRenderCustomMessages,
|
|
3924
4001
|
useRenderToolCall,
|
|
3925
4002
|
useSuggestions
|