@copilotkitnext/react 0.0.19 → 0.0.21-alpha.0
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 +326 -240
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +223 -138
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -63,6 +63,7 @@ __export(index_exports, {
|
|
|
63
63
|
useCopilotKit: () => useCopilotKit,
|
|
64
64
|
useFrontendTool: () => useFrontendTool,
|
|
65
65
|
useHumanInTheLoop: () => useHumanInTheLoop,
|
|
66
|
+
useRenderActivityMessage: () => useRenderActivityMessage,
|
|
66
67
|
useRenderCustomMessages: () => useRenderCustomMessages,
|
|
67
68
|
useRenderToolCall: () => useRenderToolCall,
|
|
68
69
|
useSuggestions: () => useSuggestions
|
|
@@ -1388,7 +1389,7 @@ CopilotChatInput.AddMenuButton.displayName = "CopilotChatInput.AddMenuButton";
|
|
|
1388
1389
|
var CopilotChatInput_default = CopilotChatInput;
|
|
1389
1390
|
|
|
1390
1391
|
// src/components/chat/CopilotChatAssistantMessage.tsx
|
|
1391
|
-
var
|
|
1392
|
+
var import_react17 = require("react");
|
|
1392
1393
|
var import_lucide_react3 = require("lucide-react");
|
|
1393
1394
|
var import_tailwind_merge4 = require("tailwind-merge");
|
|
1394
1395
|
var import_katex_min = require("katex/dist/katex.min.css");
|
|
@@ -1407,14 +1408,19 @@ var import_core = require("@copilotkitnext/core");
|
|
|
1407
1408
|
var CopilotKitCoreReact = class extends import_core.CopilotKitCore {
|
|
1408
1409
|
_renderToolCalls = [];
|
|
1409
1410
|
_renderCustomMessages = [];
|
|
1411
|
+
_renderActivityMessages = [];
|
|
1410
1412
|
constructor(config) {
|
|
1411
1413
|
super(config);
|
|
1412
1414
|
this._renderToolCalls = config.renderToolCalls ?? [];
|
|
1413
1415
|
this._renderCustomMessages = config.renderCustomMessages ?? [];
|
|
1416
|
+
this._renderActivityMessages = config.renderActivityMessages ?? [];
|
|
1414
1417
|
}
|
|
1415
1418
|
get renderCustomMessages() {
|
|
1416
1419
|
return this._renderCustomMessages;
|
|
1417
1420
|
}
|
|
1421
|
+
get renderActivityMessages() {
|
|
1422
|
+
return this._renderActivityMessages;
|
|
1423
|
+
}
|
|
1418
1424
|
get renderToolCalls() {
|
|
1419
1425
|
return this._renderToolCalls;
|
|
1420
1426
|
}
|
|
@@ -1496,10 +1502,12 @@ var CopilotKitProvider = ({
|
|
|
1496
1502
|
properties = {},
|
|
1497
1503
|
agents__unsafe_dev_only: agents = {},
|
|
1498
1504
|
renderToolCalls,
|
|
1505
|
+
renderActivityMessages,
|
|
1499
1506
|
renderCustomMessages,
|
|
1500
1507
|
frontendTools,
|
|
1501
1508
|
humanInTheLoop,
|
|
1502
|
-
showDevConsole = false
|
|
1509
|
+
showDevConsole = false,
|
|
1510
|
+
useSingleEndpoint = false
|
|
1503
1511
|
}) => {
|
|
1504
1512
|
const [shouldRenderInspector, setShouldRenderInspector] = (0, import_react6.useState)(false);
|
|
1505
1513
|
(0, import_react6.useEffect)(() => {
|
|
@@ -1536,6 +1544,10 @@ var CopilotKitProvider = ({
|
|
|
1536
1544
|
renderCustomMessages,
|
|
1537
1545
|
"renderCustomMessages must be a stable array."
|
|
1538
1546
|
);
|
|
1547
|
+
const renderActivityMessagesList = useStableArrayProp(
|
|
1548
|
+
renderActivityMessages,
|
|
1549
|
+
"renderActivityMessages must be a stable array."
|
|
1550
|
+
);
|
|
1539
1551
|
const frontendToolsList = useStableArrayProp(
|
|
1540
1552
|
frontendTools,
|
|
1541
1553
|
"frontendTools must be a stable array. If you want to dynamically add or remove tools, use `useFrontendTool` instead."
|
|
@@ -1599,15 +1611,17 @@ var CopilotKitProvider = ({
|
|
|
1599
1611
|
const copilotkit = (0, import_react6.useMemo)(() => {
|
|
1600
1612
|
const copilotkit2 = new CopilotKitCoreReact({
|
|
1601
1613
|
runtimeUrl,
|
|
1614
|
+
runtimeTransport: useSingleEndpoint ? "single" : "rest",
|
|
1602
1615
|
headers,
|
|
1603
1616
|
properties,
|
|
1604
1617
|
agents__unsafe_dev_only: agents,
|
|
1605
1618
|
tools: allTools,
|
|
1606
1619
|
renderToolCalls: allRenderToolCalls,
|
|
1620
|
+
renderActivityMessages: renderActivityMessagesList,
|
|
1607
1621
|
renderCustomMessages: renderCustomMessagesList
|
|
1608
1622
|
});
|
|
1609
1623
|
return copilotkit2;
|
|
1610
|
-
}, [allTools, allRenderToolCalls, renderCustomMessagesList]);
|
|
1624
|
+
}, [allTools, allRenderToolCalls, renderActivityMessagesList, renderCustomMessagesList, useSingleEndpoint]);
|
|
1611
1625
|
const [, forceUpdate] = (0, import_react6.useReducer)((x) => x + 1, 0);
|
|
1612
1626
|
(0, import_react6.useEffect)(() => {
|
|
1613
1627
|
const unsubscribe = copilotkit.subscribe({
|
|
@@ -1621,10 +1635,11 @@ var CopilotKitProvider = ({
|
|
|
1621
1635
|
}, [copilotkit]);
|
|
1622
1636
|
(0, import_react6.useEffect)(() => {
|
|
1623
1637
|
copilotkit.setRuntimeUrl(runtimeUrl);
|
|
1638
|
+
copilotkit.setRuntimeTransport(useSingleEndpoint ? "single" : "rest");
|
|
1624
1639
|
copilotkit.setHeaders(headers);
|
|
1625
1640
|
copilotkit.setProperties(properties);
|
|
1626
1641
|
copilotkit.setAgents__unsafe_dev_only(agents);
|
|
1627
|
-
}, [runtimeUrl, headers, properties, agents]);
|
|
1642
|
+
}, [runtimeUrl, headers, properties, agents, useSingleEndpoint]);
|
|
1628
1643
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1629
1644
|
CopilotKitContext.Provider,
|
|
1630
1645
|
{
|
|
@@ -1809,11 +1824,57 @@ function useRenderCustomMessages() {
|
|
|
1809
1824
|
};
|
|
1810
1825
|
}
|
|
1811
1826
|
|
|
1812
|
-
// src/hooks/use-
|
|
1827
|
+
// src/hooks/use-render-activity-message.tsx
|
|
1828
|
+
var import_shared4 = require("@copilotkitnext/shared");
|
|
1813
1829
|
var import_react8 = require("react");
|
|
1830
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1831
|
+
function useRenderActivityMessage() {
|
|
1832
|
+
const { copilotkit } = useCopilotKit();
|
|
1833
|
+
const config = useCopilotChatConfiguration();
|
|
1834
|
+
const agentId = config?.agentId ?? import_shared4.DEFAULT_AGENT_ID;
|
|
1835
|
+
const renderers = copilotkit.renderActivityMessages;
|
|
1836
|
+
return (0, import_react8.useCallback)(
|
|
1837
|
+
(message) => {
|
|
1838
|
+
if (!renderers.length) {
|
|
1839
|
+
return null;
|
|
1840
|
+
}
|
|
1841
|
+
const matches = renderers.filter(
|
|
1842
|
+
(renderer2) => renderer2.activityType === message.activityType
|
|
1843
|
+
);
|
|
1844
|
+
const renderer = matches.find((candidate) => candidate.agentId === agentId) ?? matches.find((candidate) => candidate.agentId === void 0) ?? renderers.find((candidate) => candidate.activityType === "*");
|
|
1845
|
+
if (!renderer) {
|
|
1846
|
+
return null;
|
|
1847
|
+
}
|
|
1848
|
+
const parseResult = renderer.content.safeParse(message.content);
|
|
1849
|
+
if (!parseResult.success) {
|
|
1850
|
+
console.warn(
|
|
1851
|
+
`Failed to parse content for activity message '${message.activityType}':`,
|
|
1852
|
+
parseResult.error
|
|
1853
|
+
);
|
|
1854
|
+
return null;
|
|
1855
|
+
}
|
|
1856
|
+
const Component = renderer.render;
|
|
1857
|
+
const agent = copilotkit.getAgent(agentId);
|
|
1858
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1859
|
+
Component,
|
|
1860
|
+
{
|
|
1861
|
+
activityType: message.activityType,
|
|
1862
|
+
content: parseResult.data,
|
|
1863
|
+
message,
|
|
1864
|
+
agent
|
|
1865
|
+
},
|
|
1866
|
+
message.id
|
|
1867
|
+
);
|
|
1868
|
+
},
|
|
1869
|
+
[agentId, copilotkit, renderers]
|
|
1870
|
+
);
|
|
1871
|
+
}
|
|
1872
|
+
|
|
1873
|
+
// src/hooks/use-frontend-tool.tsx
|
|
1874
|
+
var import_react9 = require("react");
|
|
1814
1875
|
function useFrontendTool(tool) {
|
|
1815
1876
|
const { copilotkit } = useCopilotKit();
|
|
1816
|
-
(0,
|
|
1877
|
+
(0, import_react9.useEffect)(() => {
|
|
1817
1878
|
const name = tool.name;
|
|
1818
1879
|
if (copilotkit.getTool({ toolName: name, agentId: tool.agentId })) {
|
|
1819
1880
|
console.warn(
|
|
@@ -1845,30 +1906,30 @@ function useFrontendTool(tool) {
|
|
|
1845
1906
|
}
|
|
1846
1907
|
|
|
1847
1908
|
// src/hooks/use-human-in-the-loop.tsx
|
|
1848
|
-
var
|
|
1849
|
-
var
|
|
1909
|
+
var import_react10 = require("react");
|
|
1910
|
+
var import_react11 = __toESM(require("react"));
|
|
1850
1911
|
function useHumanInTheLoop(tool) {
|
|
1851
1912
|
const { copilotkit } = useCopilotKit();
|
|
1852
|
-
const [status, setStatus] = (0,
|
|
1913
|
+
const [status, setStatus] = (0, import_react10.useState)(
|
|
1853
1914
|
"inProgress"
|
|
1854
1915
|
);
|
|
1855
|
-
const statusRef = (0,
|
|
1856
|
-
const resolvePromiseRef = (0,
|
|
1916
|
+
const statusRef = (0, import_react10.useRef)(status);
|
|
1917
|
+
const resolvePromiseRef = (0, import_react10.useRef)(null);
|
|
1857
1918
|
statusRef.current = status;
|
|
1858
|
-
const respond = (0,
|
|
1919
|
+
const respond = (0, import_react10.useCallback)(async (result) => {
|
|
1859
1920
|
if (resolvePromiseRef.current) {
|
|
1860
1921
|
resolvePromiseRef.current(result);
|
|
1861
1922
|
setStatus("complete");
|
|
1862
1923
|
resolvePromiseRef.current = null;
|
|
1863
1924
|
}
|
|
1864
1925
|
}, []);
|
|
1865
|
-
const handler = (0,
|
|
1926
|
+
const handler = (0, import_react10.useCallback)(async () => {
|
|
1866
1927
|
return new Promise((resolve) => {
|
|
1867
1928
|
setStatus("executing");
|
|
1868
1929
|
resolvePromiseRef.current = resolve;
|
|
1869
1930
|
});
|
|
1870
1931
|
}, []);
|
|
1871
|
-
const RenderComponent = (0,
|
|
1932
|
+
const RenderComponent = (0, import_react10.useCallback)(
|
|
1872
1933
|
(props) => {
|
|
1873
1934
|
const ToolComponent = tool.render;
|
|
1874
1935
|
const currentStatus = statusRef.current;
|
|
@@ -1879,7 +1940,7 @@ function useHumanInTheLoop(tool) {
|
|
|
1879
1940
|
description: tool.description || "",
|
|
1880
1941
|
respond: void 0
|
|
1881
1942
|
};
|
|
1882
|
-
return
|
|
1943
|
+
return import_react11.default.createElement(ToolComponent, enhancedProps);
|
|
1883
1944
|
} else if (currentStatus === "executing" && props.status === "executing") {
|
|
1884
1945
|
const enhancedProps = {
|
|
1885
1946
|
...props,
|
|
@@ -1887,7 +1948,7 @@ function useHumanInTheLoop(tool) {
|
|
|
1887
1948
|
description: tool.description || "",
|
|
1888
1949
|
respond
|
|
1889
1950
|
};
|
|
1890
|
-
return
|
|
1951
|
+
return import_react11.default.createElement(ToolComponent, enhancedProps);
|
|
1891
1952
|
} else if (currentStatus === "complete" && props.status === "complete") {
|
|
1892
1953
|
const enhancedProps = {
|
|
1893
1954
|
...props,
|
|
@@ -1895,9 +1956,9 @@ function useHumanInTheLoop(tool) {
|
|
|
1895
1956
|
description: tool.description || "",
|
|
1896
1957
|
respond: void 0
|
|
1897
1958
|
};
|
|
1898
|
-
return
|
|
1959
|
+
return import_react11.default.createElement(ToolComponent, enhancedProps);
|
|
1899
1960
|
}
|
|
1900
|
-
return
|
|
1961
|
+
return import_react11.default.createElement(ToolComponent, props);
|
|
1901
1962
|
},
|
|
1902
1963
|
[tool.render, tool.name, tool.description, respond]
|
|
1903
1964
|
);
|
|
@@ -1907,7 +1968,7 @@ function useHumanInTheLoop(tool) {
|
|
|
1907
1968
|
render: RenderComponent
|
|
1908
1969
|
};
|
|
1909
1970
|
useFrontendTool(frontendTool);
|
|
1910
|
-
(0,
|
|
1971
|
+
(0, import_react10.useEffect)(() => {
|
|
1911
1972
|
return () => {
|
|
1912
1973
|
const keyOf = (rc) => `${rc.agentId ?? ""}:${rc.name}`;
|
|
1913
1974
|
const currentRenderToolCalls = copilotkit.renderToolCalls;
|
|
@@ -1920,22 +1981,22 @@ function useHumanInTheLoop(tool) {
|
|
|
1920
1981
|
}
|
|
1921
1982
|
|
|
1922
1983
|
// src/hooks/use-agent.tsx
|
|
1923
|
-
var
|
|
1924
|
-
var
|
|
1984
|
+
var import_react12 = require("react");
|
|
1985
|
+
var import_shared5 = require("@copilotkitnext/shared");
|
|
1925
1986
|
var ALL_UPDATES = [
|
|
1926
1987
|
"OnMessagesChanged" /* OnMessagesChanged */,
|
|
1927
1988
|
"OnStateChanged" /* OnStateChanged */,
|
|
1928
1989
|
"OnRunStatusChanged" /* OnRunStatusChanged */
|
|
1929
1990
|
];
|
|
1930
1991
|
function useAgent({ agentId, updates } = {}) {
|
|
1931
|
-
agentId ??=
|
|
1992
|
+
agentId ??= import_shared5.DEFAULT_AGENT_ID;
|
|
1932
1993
|
const { copilotkit } = useCopilotKit();
|
|
1933
|
-
const [, forceUpdate] = (0,
|
|
1934
|
-
const updateFlags = (0,
|
|
1994
|
+
const [, forceUpdate] = (0, import_react12.useReducer)((x) => x + 1, 0);
|
|
1995
|
+
const updateFlags = (0, import_react12.useMemo)(
|
|
1935
1996
|
() => updates ?? ALL_UPDATES,
|
|
1936
1997
|
[JSON.stringify(updates)]
|
|
1937
1998
|
);
|
|
1938
|
-
const agent = (0,
|
|
1999
|
+
const agent = (0, import_react12.useMemo)(() => {
|
|
1939
2000
|
return copilotkit.getAgent(agentId);
|
|
1940
2001
|
}, [
|
|
1941
2002
|
agentId,
|
|
@@ -1943,7 +2004,7 @@ function useAgent({ agentId, updates } = {}) {
|
|
|
1943
2004
|
copilotkit.runtimeConnectionStatus,
|
|
1944
2005
|
copilotkit
|
|
1945
2006
|
]);
|
|
1946
|
-
(0,
|
|
2007
|
+
(0, import_react12.useEffect)(() => {
|
|
1947
2008
|
if (!agent) {
|
|
1948
2009
|
return;
|
|
1949
2010
|
}
|
|
@@ -1981,11 +2042,11 @@ function useAgent({ agentId, updates } = {}) {
|
|
|
1981
2042
|
}
|
|
1982
2043
|
|
|
1983
2044
|
// src/hooks/use-agent-context.tsx
|
|
1984
|
-
var
|
|
2045
|
+
var import_react13 = require("react");
|
|
1985
2046
|
function useAgentContext(context) {
|
|
1986
2047
|
const { description, value } = context;
|
|
1987
2048
|
const { copilotkit } = useCopilotKit();
|
|
1988
|
-
(0,
|
|
2049
|
+
(0, import_react13.useEffect)(() => {
|
|
1989
2050
|
if (!copilotkit) return;
|
|
1990
2051
|
const id = copilotkit.addContext(context);
|
|
1991
2052
|
return () => {
|
|
@@ -1995,26 +2056,26 @@ function useAgentContext(context) {
|
|
|
1995
2056
|
}
|
|
1996
2057
|
|
|
1997
2058
|
// src/hooks/use-suggestions.tsx
|
|
1998
|
-
var
|
|
1999
|
-
var
|
|
2059
|
+
var import_react14 = require("react");
|
|
2060
|
+
var import_shared6 = require("@copilotkitnext/shared");
|
|
2000
2061
|
function useSuggestions({ agentId } = {}) {
|
|
2001
2062
|
const { copilotkit } = useCopilotKit();
|
|
2002
2063
|
const config = useCopilotChatConfiguration();
|
|
2003
|
-
const resolvedAgentId = (0,
|
|
2004
|
-
const [suggestions, setSuggestions] = (0,
|
|
2064
|
+
const resolvedAgentId = (0, import_react14.useMemo)(() => agentId ?? config?.agentId ?? import_shared6.DEFAULT_AGENT_ID, [agentId, config?.agentId]);
|
|
2065
|
+
const [suggestions, setSuggestions] = (0, import_react14.useState)(() => {
|
|
2005
2066
|
const result = copilotkit.getSuggestions(resolvedAgentId);
|
|
2006
2067
|
return result.suggestions;
|
|
2007
2068
|
});
|
|
2008
|
-
const [isLoading, setIsLoading] = (0,
|
|
2069
|
+
const [isLoading, setIsLoading] = (0, import_react14.useState)(() => {
|
|
2009
2070
|
const result = copilotkit.getSuggestions(resolvedAgentId);
|
|
2010
2071
|
return result.isLoading;
|
|
2011
2072
|
});
|
|
2012
|
-
(0,
|
|
2073
|
+
(0, import_react14.useEffect)(() => {
|
|
2013
2074
|
const result = copilotkit.getSuggestions(resolvedAgentId);
|
|
2014
2075
|
setSuggestions(result.suggestions);
|
|
2015
2076
|
setIsLoading(result.isLoading);
|
|
2016
2077
|
}, [copilotkit, resolvedAgentId]);
|
|
2017
|
-
(0,
|
|
2078
|
+
(0, import_react14.useEffect)(() => {
|
|
2018
2079
|
const unsubscribe = copilotkit.subscribe({
|
|
2019
2080
|
onSuggestionsChanged: ({ agentId: changedAgentId, suggestions: suggestions2 }) => {
|
|
2020
2081
|
if (changedAgentId !== resolvedAgentId) {
|
|
@@ -2044,10 +2105,10 @@ function useSuggestions({ agentId } = {}) {
|
|
|
2044
2105
|
unsubscribe();
|
|
2045
2106
|
};
|
|
2046
2107
|
}, [copilotkit, resolvedAgentId]);
|
|
2047
|
-
const reloadSuggestions = (0,
|
|
2108
|
+
const reloadSuggestions = (0, import_react14.useCallback)(() => {
|
|
2048
2109
|
copilotkit.reloadSuggestions(resolvedAgentId);
|
|
2049
2110
|
}, [copilotkit, resolvedAgentId]);
|
|
2050
|
-
const clearSuggestions = (0,
|
|
2111
|
+
const clearSuggestions = (0, import_react14.useCallback)(() => {
|
|
2051
2112
|
copilotkit.clearSuggestions(resolvedAgentId);
|
|
2052
2113
|
}, [copilotkit, resolvedAgentId]);
|
|
2053
2114
|
return {
|
|
@@ -2059,20 +2120,20 @@ function useSuggestions({ agentId } = {}) {
|
|
|
2059
2120
|
}
|
|
2060
2121
|
|
|
2061
2122
|
// src/hooks/use-configure-suggestions.tsx
|
|
2062
|
-
var
|
|
2063
|
-
var
|
|
2123
|
+
var import_react15 = require("react");
|
|
2124
|
+
var import_shared7 = require("@copilotkitnext/shared");
|
|
2064
2125
|
var EMPTY_DEPS = [];
|
|
2065
2126
|
function useConfigureSuggestions(config, options) {
|
|
2066
2127
|
const { copilotkit } = useCopilotKit();
|
|
2067
2128
|
const chatConfig = useCopilotChatConfiguration();
|
|
2068
2129
|
const extraDeps = options?.deps ?? EMPTY_DEPS;
|
|
2069
|
-
const resolvedConsumerAgentId = (0,
|
|
2070
|
-
const rawConsumerAgentId = (0,
|
|
2071
|
-
const normalizationCacheRef = (0,
|
|
2130
|
+
const resolvedConsumerAgentId = (0, import_react15.useMemo)(() => chatConfig?.agentId ?? import_shared7.DEFAULT_AGENT_ID, [chatConfig?.agentId]);
|
|
2131
|
+
const rawConsumerAgentId = (0, import_react15.useMemo)(() => config ? config.consumerAgentId : void 0, [config]);
|
|
2132
|
+
const normalizationCacheRef = (0, import_react15.useRef)({
|
|
2072
2133
|
serialized: null,
|
|
2073
2134
|
config: null
|
|
2074
2135
|
});
|
|
2075
|
-
const { normalizedConfig, serializedConfig } = (0,
|
|
2136
|
+
const { normalizedConfig, serializedConfig } = (0, import_react15.useMemo)(() => {
|
|
2076
2137
|
if (!config) {
|
|
2077
2138
|
normalizationCacheRef.current = { serialized: null, config: null };
|
|
2078
2139
|
return { normalizedConfig: null, serializedConfig: null };
|
|
@@ -2102,10 +2163,10 @@ function useConfigureSuggestions(config, options) {
|
|
|
2102
2163
|
normalizationCacheRef.current = { serialized, config: built };
|
|
2103
2164
|
return { normalizedConfig: built, serializedConfig: serialized };
|
|
2104
2165
|
}, [config, resolvedConsumerAgentId, ...extraDeps]);
|
|
2105
|
-
const latestConfigRef = (0,
|
|
2166
|
+
const latestConfigRef = (0, import_react15.useRef)(null);
|
|
2106
2167
|
latestConfigRef.current = normalizedConfig;
|
|
2107
|
-
const previousSerializedConfigRef = (0,
|
|
2108
|
-
const targetAgentId = (0,
|
|
2168
|
+
const previousSerializedConfigRef = (0, import_react15.useRef)(null);
|
|
2169
|
+
const targetAgentId = (0, import_react15.useMemo)(() => {
|
|
2109
2170
|
if (!normalizedConfig) {
|
|
2110
2171
|
return resolvedConsumerAgentId;
|
|
2111
2172
|
}
|
|
@@ -2116,7 +2177,7 @@ function useConfigureSuggestions(config, options) {
|
|
|
2116
2177
|
return consumer;
|
|
2117
2178
|
}, [normalizedConfig, resolvedConsumerAgentId]);
|
|
2118
2179
|
const isGlobalConfig = rawConsumerAgentId === void 0 || rawConsumerAgentId === "*";
|
|
2119
|
-
const requestReload = (0,
|
|
2180
|
+
const requestReload = (0, import_react15.useCallback)(() => {
|
|
2120
2181
|
if (!normalizedConfig) {
|
|
2121
2182
|
return;
|
|
2122
2183
|
}
|
|
@@ -2138,7 +2199,7 @@ function useConfigureSuggestions(config, options) {
|
|
|
2138
2199
|
}
|
|
2139
2200
|
copilotkit.reloadSuggestions(targetAgentId);
|
|
2140
2201
|
}, [copilotkit, isGlobalConfig, normalizedConfig, targetAgentId]);
|
|
2141
|
-
(0,
|
|
2202
|
+
(0, import_react15.useEffect)(() => {
|
|
2142
2203
|
if (!serializedConfig || !latestConfigRef.current) {
|
|
2143
2204
|
return;
|
|
2144
2205
|
}
|
|
@@ -2148,7 +2209,7 @@ function useConfigureSuggestions(config, options) {
|
|
|
2148
2209
|
copilotkit.removeSuggestionsConfig(id);
|
|
2149
2210
|
};
|
|
2150
2211
|
}, [copilotkit, serializedConfig, requestReload]);
|
|
2151
|
-
(0,
|
|
2212
|
+
(0, import_react15.useEffect)(() => {
|
|
2152
2213
|
if (!normalizedConfig) {
|
|
2153
2214
|
previousSerializedConfigRef.current = null;
|
|
2154
2215
|
return;
|
|
@@ -2161,7 +2222,7 @@ function useConfigureSuggestions(config, options) {
|
|
|
2161
2222
|
}
|
|
2162
2223
|
requestReload();
|
|
2163
2224
|
}, [normalizedConfig, requestReload, serializedConfig]);
|
|
2164
|
-
(0,
|
|
2225
|
+
(0, import_react15.useEffect)(() => {
|
|
2165
2226
|
if (!normalizedConfig || extraDeps.length === 0) {
|
|
2166
2227
|
return;
|
|
2167
2228
|
}
|
|
@@ -2179,8 +2240,8 @@ function normalizeStaticSuggestions(suggestions) {
|
|
|
2179
2240
|
}
|
|
2180
2241
|
|
|
2181
2242
|
// src/components/chat/CopilotChatToolCallsView.tsx
|
|
2182
|
-
var
|
|
2183
|
-
var
|
|
2243
|
+
var import_react16 = __toESM(require("react"));
|
|
2244
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
2184
2245
|
function CopilotChatToolCallsView({
|
|
2185
2246
|
message,
|
|
2186
2247
|
messages = []
|
|
@@ -2189,11 +2250,11 @@ function CopilotChatToolCallsView({
|
|
|
2189
2250
|
if (!message.toolCalls || message.toolCalls.length === 0) {
|
|
2190
2251
|
return null;
|
|
2191
2252
|
}
|
|
2192
|
-
return /* @__PURE__ */ (0,
|
|
2253
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_jsx_runtime12.Fragment, { children: message.toolCalls.map((toolCall) => {
|
|
2193
2254
|
const toolMessage = messages.find(
|
|
2194
2255
|
(m) => m.role === "tool" && m.toolCallId === toolCall.id
|
|
2195
2256
|
);
|
|
2196
|
-
return /* @__PURE__ */ (0,
|
|
2257
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react16.default.Fragment, { children: renderToolCall({
|
|
2197
2258
|
toolCall,
|
|
2198
2259
|
toolMessage
|
|
2199
2260
|
}) }, toolCall.id);
|
|
@@ -2202,7 +2263,7 @@ function CopilotChatToolCallsView({
|
|
|
2202
2263
|
var CopilotChatToolCallsView_default = CopilotChatToolCallsView;
|
|
2203
2264
|
|
|
2204
2265
|
// src/components/chat/CopilotChatAssistantMessage.tsx
|
|
2205
|
-
var
|
|
2266
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
2206
2267
|
function CopilotChatAssistantMessage({
|
|
2207
2268
|
message,
|
|
2208
2269
|
messages,
|
|
@@ -2279,7 +2340,7 @@ function CopilotChatAssistantMessage({
|
|
|
2279
2340
|
toolbar,
|
|
2280
2341
|
CopilotChatAssistantMessage.Toolbar,
|
|
2281
2342
|
{
|
|
2282
|
-
children: /* @__PURE__ */ (0,
|
|
2343
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
2283
2344
|
boundCopyButton,
|
|
2284
2345
|
(onThumbsUp || thumbsUpButton) && boundThumbsUpButton,
|
|
2285
2346
|
(onThumbsDown || thumbsDownButton) && boundThumbsDownButton,
|
|
@@ -2301,7 +2362,7 @@ function CopilotChatAssistantMessage({
|
|
|
2301
2362
|
const isLatestAssistantMessage = message.role === "assistant" && messages?.[messages.length - 1]?.id === message.id;
|
|
2302
2363
|
const shouldShowToolbar = toolbarVisible && hasContent && !(isRunning && isLatestAssistantMessage);
|
|
2303
2364
|
if (children) {
|
|
2304
|
-
return /* @__PURE__ */ (0,
|
|
2365
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_jsx_runtime13.Fragment, { children: children({
|
|
2305
2366
|
markdownRenderer: boundMarkdownRenderer,
|
|
2306
2367
|
toolbar: boundToolbar,
|
|
2307
2368
|
toolCallsView: boundToolCallsView,
|
|
@@ -2321,7 +2382,7 @@ function CopilotChatAssistantMessage({
|
|
|
2321
2382
|
toolbarVisible: shouldShowToolbar
|
|
2322
2383
|
}) });
|
|
2323
2384
|
}
|
|
2324
|
-
return /* @__PURE__ */ (0,
|
|
2385
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
2325
2386
|
"div",
|
|
2326
2387
|
{
|
|
2327
2388
|
className: (0, import_tailwind_merge4.twMerge)(
|
|
@@ -2339,11 +2400,11 @@ function CopilotChatAssistantMessage({
|
|
|
2339
2400
|
);
|
|
2340
2401
|
}
|
|
2341
2402
|
((CopilotChatAssistantMessage2) => {
|
|
2342
|
-
CopilotChatAssistantMessage2.MarkdownRenderer = ({ content, className, ...props }) => /* @__PURE__ */ (0,
|
|
2403
|
+
CopilotChatAssistantMessage2.MarkdownRenderer = ({ content, className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_streamdown.Streamdown, { className, ...props, children: content ?? "" });
|
|
2343
2404
|
CopilotChatAssistantMessage2.Toolbar = ({
|
|
2344
2405
|
className,
|
|
2345
2406
|
...props
|
|
2346
|
-
}) => /* @__PURE__ */ (0,
|
|
2407
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2347
2408
|
"div",
|
|
2348
2409
|
{
|
|
2349
2410
|
className: (0, import_tailwind_merge4.twMerge)(
|
|
@@ -2354,8 +2415,8 @@ function CopilotChatAssistantMessage({
|
|
|
2354
2415
|
}
|
|
2355
2416
|
);
|
|
2356
2417
|
CopilotChatAssistantMessage2.ToolbarButton = ({ title, children, ...props }) => {
|
|
2357
|
-
return /* @__PURE__ */ (0,
|
|
2358
|
-
/* @__PURE__ */ (0,
|
|
2418
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(Tooltip, { children: [
|
|
2419
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2359
2420
|
Button,
|
|
2360
2421
|
{
|
|
2361
2422
|
type: "button",
|
|
@@ -2365,13 +2426,13 @@ function CopilotChatAssistantMessage({
|
|
|
2365
2426
|
children
|
|
2366
2427
|
}
|
|
2367
2428
|
) }),
|
|
2368
|
-
/* @__PURE__ */ (0,
|
|
2429
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(TooltipContent, { side: "bottom", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { children: title }) })
|
|
2369
2430
|
] });
|
|
2370
2431
|
};
|
|
2371
2432
|
CopilotChatAssistantMessage2.CopyButton = ({ className, title, onClick, ...props }) => {
|
|
2372
2433
|
const config = useCopilotChatConfiguration();
|
|
2373
2434
|
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
2374
|
-
const [copied, setCopied] = (0,
|
|
2435
|
+
const [copied, setCopied] = (0, import_react17.useState)(false);
|
|
2375
2436
|
const handleClick = (event) => {
|
|
2376
2437
|
setCopied(true);
|
|
2377
2438
|
setTimeout(() => setCopied(false), 2e3);
|
|
@@ -2379,62 +2440,62 @@ function CopilotChatAssistantMessage({
|
|
|
2379
2440
|
onClick(event);
|
|
2380
2441
|
}
|
|
2381
2442
|
};
|
|
2382
|
-
return /* @__PURE__ */ (0,
|
|
2443
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2383
2444
|
CopilotChatAssistantMessage2.ToolbarButton,
|
|
2384
2445
|
{
|
|
2385
2446
|
title: title || labels.assistantMessageToolbarCopyMessageLabel,
|
|
2386
2447
|
onClick: handleClick,
|
|
2387
2448
|
className,
|
|
2388
2449
|
...props,
|
|
2389
|
-
children: copied ? /* @__PURE__ */ (0,
|
|
2450
|
+
children: copied ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react3.Check, { className: "size-[18px]" }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react3.Copy, { className: "size-[18px]" })
|
|
2390
2451
|
}
|
|
2391
2452
|
);
|
|
2392
2453
|
};
|
|
2393
2454
|
CopilotChatAssistantMessage2.ThumbsUpButton = ({ title, ...props }) => {
|
|
2394
2455
|
const config = useCopilotChatConfiguration();
|
|
2395
2456
|
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
2396
|
-
return /* @__PURE__ */ (0,
|
|
2457
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2397
2458
|
CopilotChatAssistantMessage2.ToolbarButton,
|
|
2398
2459
|
{
|
|
2399
2460
|
title: title || labels.assistantMessageToolbarThumbsUpLabel,
|
|
2400
2461
|
...props,
|
|
2401
|
-
children: /* @__PURE__ */ (0,
|
|
2462
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react3.ThumbsUp, { className: "size-[18px]" })
|
|
2402
2463
|
}
|
|
2403
2464
|
);
|
|
2404
2465
|
};
|
|
2405
2466
|
CopilotChatAssistantMessage2.ThumbsDownButton = ({ title, ...props }) => {
|
|
2406
2467
|
const config = useCopilotChatConfiguration();
|
|
2407
2468
|
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
2408
|
-
return /* @__PURE__ */ (0,
|
|
2469
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2409
2470
|
CopilotChatAssistantMessage2.ToolbarButton,
|
|
2410
2471
|
{
|
|
2411
2472
|
title: title || labels.assistantMessageToolbarThumbsDownLabel,
|
|
2412
2473
|
...props,
|
|
2413
|
-
children: /* @__PURE__ */ (0,
|
|
2474
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react3.ThumbsDown, { className: "size-[18px]" })
|
|
2414
2475
|
}
|
|
2415
2476
|
);
|
|
2416
2477
|
};
|
|
2417
2478
|
CopilotChatAssistantMessage2.ReadAloudButton = ({ title, ...props }) => {
|
|
2418
2479
|
const config = useCopilotChatConfiguration();
|
|
2419
2480
|
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
2420
|
-
return /* @__PURE__ */ (0,
|
|
2481
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2421
2482
|
CopilotChatAssistantMessage2.ToolbarButton,
|
|
2422
2483
|
{
|
|
2423
2484
|
title: title || labels.assistantMessageToolbarReadAloudLabel,
|
|
2424
2485
|
...props,
|
|
2425
|
-
children: /* @__PURE__ */ (0,
|
|
2486
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react3.Volume2, { className: "size-[20px]" })
|
|
2426
2487
|
}
|
|
2427
2488
|
);
|
|
2428
2489
|
};
|
|
2429
2490
|
CopilotChatAssistantMessage2.RegenerateButton = ({ title, ...props }) => {
|
|
2430
2491
|
const config = useCopilotChatConfiguration();
|
|
2431
2492
|
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
2432
|
-
return /* @__PURE__ */ (0,
|
|
2493
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2433
2494
|
CopilotChatAssistantMessage2.ToolbarButton,
|
|
2434
2495
|
{
|
|
2435
2496
|
title: title || labels.assistantMessageToolbarRegenerateLabel,
|
|
2436
2497
|
...props,
|
|
2437
|
-
children: /* @__PURE__ */ (0,
|
|
2498
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react3.RefreshCw, { className: "size-[18px]" })
|
|
2438
2499
|
}
|
|
2439
2500
|
);
|
|
2440
2501
|
};
|
|
@@ -2449,10 +2510,24 @@ CopilotChatAssistantMessage.RegenerateButton.displayName = "CopilotChatAssistant
|
|
|
2449
2510
|
var CopilotChatAssistantMessage_default = CopilotChatAssistantMessage;
|
|
2450
2511
|
|
|
2451
2512
|
// src/components/chat/CopilotChatUserMessage.tsx
|
|
2452
|
-
var
|
|
2513
|
+
var import_react18 = require("react");
|
|
2453
2514
|
var import_lucide_react4 = require("lucide-react");
|
|
2454
2515
|
var import_tailwind_merge5 = require("tailwind-merge");
|
|
2455
|
-
var
|
|
2516
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
2517
|
+
function flattenUserMessageContent(content) {
|
|
2518
|
+
if (!content) {
|
|
2519
|
+
return "";
|
|
2520
|
+
}
|
|
2521
|
+
if (typeof content === "string") {
|
|
2522
|
+
return content;
|
|
2523
|
+
}
|
|
2524
|
+
return content.map((part) => {
|
|
2525
|
+
if (part && typeof part === "object" && "type" in part && part.type === "text" && typeof part.text === "string") {
|
|
2526
|
+
return part.text;
|
|
2527
|
+
}
|
|
2528
|
+
return "";
|
|
2529
|
+
}).filter((text) => text.length > 0).join("\n");
|
|
2530
|
+
}
|
|
2456
2531
|
function CopilotChatUserMessage({
|
|
2457
2532
|
message,
|
|
2458
2533
|
onEditMessage,
|
|
@@ -2469,11 +2544,15 @@ function CopilotChatUserMessage({
|
|
|
2469
2544
|
className,
|
|
2470
2545
|
...props
|
|
2471
2546
|
}) {
|
|
2547
|
+
const flattenedContent = (0, import_react18.useMemo)(
|
|
2548
|
+
() => flattenUserMessageContent(message.content),
|
|
2549
|
+
[message.content]
|
|
2550
|
+
);
|
|
2472
2551
|
const BoundMessageRenderer = renderSlot(
|
|
2473
2552
|
messageRenderer,
|
|
2474
2553
|
CopilotChatUserMessage.MessageRenderer,
|
|
2475
2554
|
{
|
|
2476
|
-
content:
|
|
2555
|
+
content: flattenedContent
|
|
2477
2556
|
}
|
|
2478
2557
|
);
|
|
2479
2558
|
const BoundCopyButton = renderSlot(
|
|
@@ -2481,9 +2560,9 @@ function CopilotChatUserMessage({
|
|
|
2481
2560
|
CopilotChatUserMessage.CopyButton,
|
|
2482
2561
|
{
|
|
2483
2562
|
onClick: async () => {
|
|
2484
|
-
if (
|
|
2563
|
+
if (flattenedContent) {
|
|
2485
2564
|
try {
|
|
2486
|
-
await navigator.clipboard.writeText(
|
|
2565
|
+
await navigator.clipboard.writeText(flattenedContent);
|
|
2487
2566
|
} catch (err) {
|
|
2488
2567
|
console.error("Failed to copy message:", err);
|
|
2489
2568
|
}
|
|
@@ -2510,7 +2589,7 @@ function CopilotChatUserMessage({
|
|
|
2510
2589
|
);
|
|
2511
2590
|
const showBranchNavigation = numberOfBranches && numberOfBranches > 1 && onSwitchToBranch;
|
|
2512
2591
|
const BoundToolbar = renderSlot(toolbar, CopilotChatUserMessage.Toolbar, {
|
|
2513
|
-
children: /* @__PURE__ */ (0,
|
|
2592
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex items-center gap-1 justify-end", children: [
|
|
2514
2593
|
additionalToolbarItems,
|
|
2515
2594
|
BoundCopyButton,
|
|
2516
2595
|
onEditMessage && BoundEditButton,
|
|
@@ -2518,7 +2597,7 @@ function CopilotChatUserMessage({
|
|
|
2518
2597
|
] })
|
|
2519
2598
|
});
|
|
2520
2599
|
if (children) {
|
|
2521
|
-
return /* @__PURE__ */ (0,
|
|
2600
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_jsx_runtime14.Fragment, { children: children({
|
|
2522
2601
|
messageRenderer: BoundMessageRenderer,
|
|
2523
2602
|
toolbar: BoundToolbar,
|
|
2524
2603
|
copyButton: BoundCopyButton,
|
|
@@ -2530,7 +2609,7 @@ function CopilotChatUserMessage({
|
|
|
2530
2609
|
additionalToolbarItems
|
|
2531
2610
|
}) });
|
|
2532
2611
|
}
|
|
2533
|
-
return /* @__PURE__ */ (0,
|
|
2612
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
2534
2613
|
"div",
|
|
2535
2614
|
{
|
|
2536
2615
|
className: (0, import_tailwind_merge5.twMerge)("flex flex-col items-end group pt-10", className),
|
|
@@ -2544,7 +2623,7 @@ function CopilotChatUserMessage({
|
|
|
2544
2623
|
);
|
|
2545
2624
|
}
|
|
2546
2625
|
((CopilotChatUserMessage2) => {
|
|
2547
|
-
CopilotChatUserMessage2.Container = ({ children, className, ...props }) => /* @__PURE__ */ (0,
|
|
2626
|
+
CopilotChatUserMessage2.Container = ({ children, className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2548
2627
|
"div",
|
|
2549
2628
|
{
|
|
2550
2629
|
className: (0, import_tailwind_merge5.twMerge)("flex flex-col items-end group", className),
|
|
@@ -2552,7 +2631,7 @@ function CopilotChatUserMessage({
|
|
|
2552
2631
|
children
|
|
2553
2632
|
}
|
|
2554
2633
|
);
|
|
2555
|
-
CopilotChatUserMessage2.MessageRenderer = ({ content, className }) => /* @__PURE__ */ (0,
|
|
2634
|
+
CopilotChatUserMessage2.MessageRenderer = ({ content, className }) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2556
2635
|
"div",
|
|
2557
2636
|
{
|
|
2558
2637
|
className: (0, import_tailwind_merge5.twMerge)(
|
|
@@ -2565,7 +2644,7 @@ function CopilotChatUserMessage({
|
|
|
2565
2644
|
CopilotChatUserMessage2.Toolbar = ({
|
|
2566
2645
|
className,
|
|
2567
2646
|
...props
|
|
2568
|
-
}) => /* @__PURE__ */ (0,
|
|
2647
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2569
2648
|
"div",
|
|
2570
2649
|
{
|
|
2571
2650
|
className: (0, import_tailwind_merge5.twMerge)(
|
|
@@ -2576,8 +2655,8 @@ function CopilotChatUserMessage({
|
|
|
2576
2655
|
}
|
|
2577
2656
|
);
|
|
2578
2657
|
CopilotChatUserMessage2.ToolbarButton = ({ title, children, className, ...props }) => {
|
|
2579
|
-
return /* @__PURE__ */ (0,
|
|
2580
|
-
/* @__PURE__ */ (0,
|
|
2658
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Tooltip, { children: [
|
|
2659
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2581
2660
|
Button,
|
|
2582
2661
|
{
|
|
2583
2662
|
type: "button",
|
|
@@ -2588,13 +2667,13 @@ function CopilotChatUserMessage({
|
|
|
2588
2667
|
children
|
|
2589
2668
|
}
|
|
2590
2669
|
) }),
|
|
2591
|
-
/* @__PURE__ */ (0,
|
|
2670
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(TooltipContent, { side: "bottom", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { children: title }) })
|
|
2592
2671
|
] });
|
|
2593
2672
|
};
|
|
2594
2673
|
CopilotChatUserMessage2.CopyButton = ({ className, title, onClick, ...props }) => {
|
|
2595
2674
|
const config = useCopilotChatConfiguration();
|
|
2596
2675
|
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
2597
|
-
const [copied, setCopied] = (0,
|
|
2676
|
+
const [copied, setCopied] = (0, import_react18.useState)(false);
|
|
2598
2677
|
const handleClick = (event) => {
|
|
2599
2678
|
setCopied(true);
|
|
2600
2679
|
setTimeout(() => setCopied(false), 2e3);
|
|
@@ -2602,27 +2681,27 @@ function CopilotChatUserMessage({
|
|
|
2602
2681
|
onClick(event);
|
|
2603
2682
|
}
|
|
2604
2683
|
};
|
|
2605
|
-
return /* @__PURE__ */ (0,
|
|
2684
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2606
2685
|
CopilotChatUserMessage2.ToolbarButton,
|
|
2607
2686
|
{
|
|
2608
2687
|
title: title || labels.userMessageToolbarCopyMessageLabel,
|
|
2609
2688
|
onClick: handleClick,
|
|
2610
2689
|
className,
|
|
2611
2690
|
...props,
|
|
2612
|
-
children: copied ? /* @__PURE__ */ (0,
|
|
2691
|
+
children: copied ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react4.Check, { className: "size-[18px]" }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react4.Copy, { className: "size-[18px]" })
|
|
2613
2692
|
}
|
|
2614
2693
|
);
|
|
2615
2694
|
};
|
|
2616
2695
|
CopilotChatUserMessage2.EditButton = ({ className, title, ...props }) => {
|
|
2617
2696
|
const config = useCopilotChatConfiguration();
|
|
2618
2697
|
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
2619
|
-
return /* @__PURE__ */ (0,
|
|
2698
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2620
2699
|
CopilotChatUserMessage2.ToolbarButton,
|
|
2621
2700
|
{
|
|
2622
2701
|
title: title || labels.userMessageToolbarEditMessageLabel,
|
|
2623
2702
|
className,
|
|
2624
2703
|
...props,
|
|
2625
|
-
children: /* @__PURE__ */ (0,
|
|
2704
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react4.Edit, { className: "size-[18px]" })
|
|
2626
2705
|
}
|
|
2627
2706
|
);
|
|
2628
2707
|
};
|
|
@@ -2639,8 +2718,8 @@ function CopilotChatUserMessage({
|
|
|
2639
2718
|
}
|
|
2640
2719
|
const canGoPrev = currentBranch > 0;
|
|
2641
2720
|
const canGoNext = currentBranch < numberOfBranches - 1;
|
|
2642
|
-
return /* @__PURE__ */ (0,
|
|
2643
|
-
/* @__PURE__ */ (0,
|
|
2721
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: (0, import_tailwind_merge5.twMerge)("flex items-center gap-1", className), ...props, children: [
|
|
2722
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2644
2723
|
Button,
|
|
2645
2724
|
{
|
|
2646
2725
|
type: "button",
|
|
@@ -2652,15 +2731,15 @@ function CopilotChatUserMessage({
|
|
|
2652
2731
|
}),
|
|
2653
2732
|
disabled: !canGoPrev,
|
|
2654
2733
|
className: "h-6 w-6 p-0",
|
|
2655
|
-
children: /* @__PURE__ */ (0,
|
|
2734
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react4.ChevronLeft, { className: "size-[20px]" })
|
|
2656
2735
|
}
|
|
2657
2736
|
),
|
|
2658
|
-
/* @__PURE__ */ (0,
|
|
2737
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "text-sm text-muted-foreground px-0 font-medium", children: [
|
|
2659
2738
|
currentBranch + 1,
|
|
2660
2739
|
"/",
|
|
2661
2740
|
numberOfBranches
|
|
2662
2741
|
] }),
|
|
2663
|
-
/* @__PURE__ */ (0,
|
|
2742
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2664
2743
|
Button,
|
|
2665
2744
|
{
|
|
2666
2745
|
type: "button",
|
|
@@ -2672,7 +2751,7 @@ function CopilotChatUserMessage({
|
|
|
2672
2751
|
}),
|
|
2673
2752
|
disabled: !canGoNext,
|
|
2674
2753
|
className: "h-6 w-6 p-0",
|
|
2675
|
-
children: /* @__PURE__ */ (0,
|
|
2754
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react4.ChevronRight, { className: "size-[20px]" })
|
|
2676
2755
|
}
|
|
2677
2756
|
)
|
|
2678
2757
|
] });
|
|
@@ -2688,14 +2767,14 @@ CopilotChatUserMessage.BranchNavigation.displayName = "CopilotChatUserMessage.Br
|
|
|
2688
2767
|
var CopilotChatUserMessage_default = CopilotChatUserMessage;
|
|
2689
2768
|
|
|
2690
2769
|
// src/components/chat/CopilotChatSuggestionPill.tsx
|
|
2691
|
-
var
|
|
2770
|
+
var import_react19 = __toESM(require("react"));
|
|
2692
2771
|
var import_lucide_react5 = require("lucide-react");
|
|
2693
|
-
var
|
|
2772
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
2694
2773
|
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";
|
|
2695
2774
|
var labelClasses = "whitespace-nowrap font-medium leading-none";
|
|
2696
|
-
var CopilotChatSuggestionPill =
|
|
2775
|
+
var CopilotChatSuggestionPill = import_react19.default.forwardRef(function CopilotChatSuggestionPill2({ className, children, icon, isLoading, type, ...props }, ref) {
|
|
2697
2776
|
const showIcon = !isLoading && icon;
|
|
2698
|
-
return /* @__PURE__ */ (0,
|
|
2777
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
2699
2778
|
"button",
|
|
2700
2779
|
{
|
|
2701
2780
|
ref,
|
|
@@ -2706,8 +2785,8 @@ var CopilotChatSuggestionPill = import_react18.default.forwardRef(function Copil
|
|
|
2706
2785
|
disabled: isLoading || props.disabled,
|
|
2707
2786
|
...props,
|
|
2708
2787
|
children: [
|
|
2709
|
-
isLoading ? /* @__PURE__ */ (0,
|
|
2710
|
-
/* @__PURE__ */ (0,
|
|
2788
|
+
isLoading ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "flex h-3.5 sm:h-4 w-3.5 sm:w-4 items-center justify-center text-muted-foreground", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react5.Loader2, { className: "h-3.5 sm:h-4 w-3.5 sm:w-4 animate-spin", "aria-hidden": "true" }) }) : showIcon && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "flex h-3.5 sm:h-4 w-3.5 sm:w-4 items-center justify-center text-muted-foreground", children: icon }),
|
|
2789
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: labelClasses, children })
|
|
2711
2790
|
]
|
|
2712
2791
|
}
|
|
2713
2792
|
);
|
|
@@ -2716,10 +2795,10 @@ CopilotChatSuggestionPill.displayName = "CopilotChatSuggestionPill";
|
|
|
2716
2795
|
var CopilotChatSuggestionPill_default = CopilotChatSuggestionPill;
|
|
2717
2796
|
|
|
2718
2797
|
// src/components/chat/CopilotChatSuggestionView.tsx
|
|
2719
|
-
var
|
|
2720
|
-
var
|
|
2721
|
-
var DefaultContainer =
|
|
2722
|
-
return /* @__PURE__ */ (0,
|
|
2798
|
+
var import_react20 = __toESM(require("react"));
|
|
2799
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
2800
|
+
var DefaultContainer = import_react20.default.forwardRef(function DefaultContainer2({ className, ...props }, ref) {
|
|
2801
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2723
2802
|
"div",
|
|
2724
2803
|
{
|
|
2725
2804
|
ref,
|
|
@@ -2731,7 +2810,7 @@ var DefaultContainer = import_react19.default.forwardRef(function DefaultContain
|
|
|
2731
2810
|
}
|
|
2732
2811
|
);
|
|
2733
2812
|
});
|
|
2734
|
-
var CopilotChatSuggestionView =
|
|
2813
|
+
var CopilotChatSuggestionView = import_react20.default.forwardRef(function CopilotChatSuggestionView2({
|
|
2735
2814
|
suggestions,
|
|
2736
2815
|
onSelectSuggestion,
|
|
2737
2816
|
loadingIndexes,
|
|
@@ -2741,7 +2820,7 @@ var CopilotChatSuggestionView = import_react19.default.forwardRef(function Copil
|
|
|
2741
2820
|
children,
|
|
2742
2821
|
...restProps
|
|
2743
2822
|
}, ref) {
|
|
2744
|
-
const loadingSet =
|
|
2823
|
+
const loadingSet = import_react20.default.useMemo(() => {
|
|
2745
2824
|
if (!loadingIndexes || loadingIndexes.length === 0) {
|
|
2746
2825
|
return /* @__PURE__ */ new Set();
|
|
2747
2826
|
}
|
|
@@ -2760,11 +2839,11 @@ var CopilotChatSuggestionView = import_react19.default.forwardRef(function Copil
|
|
|
2760
2839
|
type: "button",
|
|
2761
2840
|
onClick: () => onSelectSuggestion?.(suggestion, index)
|
|
2762
2841
|
});
|
|
2763
|
-
return
|
|
2842
|
+
return import_react20.default.cloneElement(pill, {
|
|
2764
2843
|
key: `${suggestion.title}-${index}`
|
|
2765
2844
|
});
|
|
2766
2845
|
});
|
|
2767
|
-
const boundContainer =
|
|
2846
|
+
const boundContainer = import_react20.default.cloneElement(
|
|
2768
2847
|
ContainerElement,
|
|
2769
2848
|
void 0,
|
|
2770
2849
|
suggestionElements
|
|
@@ -2775,7 +2854,7 @@ var CopilotChatSuggestionView = import_react19.default.forwardRef(function Copil
|
|
|
2775
2854
|
isLoading: suggestions.length > 0 ? loadingSet.has(0) || suggestions[0]?.isLoading === true : false,
|
|
2776
2855
|
type: "button"
|
|
2777
2856
|
});
|
|
2778
|
-
return /* @__PURE__ */ (0,
|
|
2857
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_jsx_runtime16.Fragment, { children: children({
|
|
2779
2858
|
container: boundContainer,
|
|
2780
2859
|
suggestion: sampleSuggestion,
|
|
2781
2860
|
suggestions,
|
|
@@ -2786,7 +2865,7 @@ var CopilotChatSuggestionView = import_react19.default.forwardRef(function Copil
|
|
|
2786
2865
|
}) });
|
|
2787
2866
|
}
|
|
2788
2867
|
if (children) {
|
|
2789
|
-
return /* @__PURE__ */ (0,
|
|
2868
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
|
|
2790
2869
|
boundContainer,
|
|
2791
2870
|
children
|
|
2792
2871
|
] });
|
|
@@ -2798,7 +2877,7 @@ var CopilotChatSuggestionView_default = CopilotChatSuggestionView;
|
|
|
2798
2877
|
|
|
2799
2878
|
// src/components/chat/CopilotChatMessageView.tsx
|
|
2800
2879
|
var import_tailwind_merge6 = require("tailwind-merge");
|
|
2801
|
-
var
|
|
2880
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
2802
2881
|
function CopilotChatMessageView({
|
|
2803
2882
|
messages = [],
|
|
2804
2883
|
assistantMessage,
|
|
@@ -2810,6 +2889,7 @@ function CopilotChatMessageView({
|
|
|
2810
2889
|
...props
|
|
2811
2890
|
}) {
|
|
2812
2891
|
const renderCustomMessage = useRenderCustomMessages();
|
|
2892
|
+
const renderActivityMessage = useRenderActivityMessage();
|
|
2813
2893
|
const messageElements = messages.flatMap((message) => {
|
|
2814
2894
|
const elements = [];
|
|
2815
2895
|
if (renderCustomMessage) {
|
|
@@ -2836,6 +2916,11 @@ function CopilotChatMessageView({
|
|
|
2836
2916
|
message
|
|
2837
2917
|
})
|
|
2838
2918
|
);
|
|
2919
|
+
} else if (message.role === "activity") {
|
|
2920
|
+
const renderedActivity = renderActivityMessage(message);
|
|
2921
|
+
if (renderedActivity) {
|
|
2922
|
+
elements.push(renderedActivity);
|
|
2923
|
+
}
|
|
2839
2924
|
}
|
|
2840
2925
|
if (renderCustomMessage) {
|
|
2841
2926
|
elements.push(
|
|
@@ -2850,13 +2935,13 @@ function CopilotChatMessageView({
|
|
|
2850
2935
|
if (children) {
|
|
2851
2936
|
return children({ messageElements, messages, isRunning });
|
|
2852
2937
|
}
|
|
2853
|
-
return /* @__PURE__ */ (0,
|
|
2938
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: (0, import_tailwind_merge6.twMerge)("flex flex-col", className), ...props, children: [
|
|
2854
2939
|
messageElements,
|
|
2855
2940
|
isRunning && renderSlot(cursor, CopilotChatMessageView.Cursor, {})
|
|
2856
2941
|
] });
|
|
2857
2942
|
}
|
|
2858
2943
|
CopilotChatMessageView.Cursor = function Cursor({ className, ...props }) {
|
|
2859
|
-
return /* @__PURE__ */ (0,
|
|
2944
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2860
2945
|
"div",
|
|
2861
2946
|
{
|
|
2862
2947
|
className: (0, import_tailwind_merge6.twMerge)("w-[11px] h-[11px] rounded-full bg-foreground animate-pulse-cursor ml-1", className),
|
|
@@ -2867,21 +2952,21 @@ CopilotChatMessageView.Cursor = function Cursor({ className, ...props }) {
|
|
|
2867
2952
|
var CopilotChatMessageView_default = CopilotChatMessageView;
|
|
2868
2953
|
|
|
2869
2954
|
// src/components/chat/CopilotChatView.tsx
|
|
2870
|
-
var
|
|
2955
|
+
var import_react22 = __toESM(require("react"));
|
|
2871
2956
|
var import_tailwind_merge7 = require("tailwind-merge");
|
|
2872
2957
|
var import_use_stick_to_bottom = require("use-stick-to-bottom");
|
|
2873
2958
|
var import_lucide_react6 = require("lucide-react");
|
|
2874
2959
|
|
|
2875
2960
|
// src/hooks/use-keyboard-height.tsx
|
|
2876
|
-
var
|
|
2961
|
+
var import_react21 = require("react");
|
|
2877
2962
|
function useKeyboardHeight() {
|
|
2878
|
-
const [keyboardState, setKeyboardState] = (0,
|
|
2963
|
+
const [keyboardState, setKeyboardState] = (0, import_react21.useState)({
|
|
2879
2964
|
isKeyboardOpen: false,
|
|
2880
2965
|
keyboardHeight: 0,
|
|
2881
2966
|
availableHeight: typeof window !== "undefined" ? window.innerHeight : 0,
|
|
2882
2967
|
viewportHeight: typeof window !== "undefined" ? window.innerHeight : 0
|
|
2883
2968
|
});
|
|
2884
|
-
(0,
|
|
2969
|
+
(0, import_react21.useEffect)(() => {
|
|
2885
2970
|
if (typeof window === "undefined") {
|
|
2886
2971
|
return;
|
|
2887
2972
|
}
|
|
@@ -2913,7 +2998,7 @@ function useKeyboardHeight() {
|
|
|
2913
2998
|
}
|
|
2914
2999
|
|
|
2915
3000
|
// src/components/chat/CopilotChatView.tsx
|
|
2916
|
-
var
|
|
3001
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
2917
3002
|
function CopilotChatView({
|
|
2918
3003
|
messageView,
|
|
2919
3004
|
input,
|
|
@@ -2934,12 +3019,12 @@ function CopilotChatView({
|
|
|
2934
3019
|
className,
|
|
2935
3020
|
...props
|
|
2936
3021
|
}) {
|
|
2937
|
-
const inputContainerRef = (0,
|
|
2938
|
-
const [inputContainerHeight, setInputContainerHeight] = (0,
|
|
2939
|
-
const [isResizing, setIsResizing] = (0,
|
|
2940
|
-
const resizeTimeoutRef = (0,
|
|
3022
|
+
const inputContainerRef = (0, import_react22.useRef)(null);
|
|
3023
|
+
const [inputContainerHeight, setInputContainerHeight] = (0, import_react22.useState)(0);
|
|
3024
|
+
const [isResizing, setIsResizing] = (0, import_react22.useState)(false);
|
|
3025
|
+
const resizeTimeoutRef = (0, import_react22.useRef)(null);
|
|
2941
3026
|
const { isKeyboardOpen, keyboardHeight, availableHeight } = useKeyboardHeight();
|
|
2942
|
-
(0,
|
|
3027
|
+
(0, import_react22.useEffect)(() => {
|
|
2943
3028
|
const element = inputContainerRef.current;
|
|
2944
3029
|
if (!element) return;
|
|
2945
3030
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
@@ -2991,9 +3076,9 @@ function CopilotChatView({
|
|
|
2991
3076
|
scrollToBottomButton,
|
|
2992
3077
|
inputContainerHeight,
|
|
2993
3078
|
isResizing,
|
|
2994
|
-
children: /* @__PURE__ */ (0,
|
|
3079
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { style: { paddingBottom: `${inputContainerHeight + (hasSuggestions ? 4 : 32)}px` }, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "max-w-3xl mx-auto", children: [
|
|
2995
3080
|
BoundMessageView,
|
|
2996
|
-
hasSuggestions ? /* @__PURE__ */ (0,
|
|
3081
|
+
hasSuggestions ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "pl-0 pr-4 sm:px-0 mt-4", children: BoundSuggestionView }) : null
|
|
2997
3082
|
] }) })
|
|
2998
3083
|
});
|
|
2999
3084
|
const BoundScrollToBottomButton = renderSlot(scrollToBottomButton, CopilotChatView.ScrollToBottomButton, {});
|
|
@@ -3001,8 +3086,8 @@ function CopilotChatView({
|
|
|
3001
3086
|
const BoundInputContainer = renderSlot(inputContainer, CopilotChatView.InputContainer, {
|
|
3002
3087
|
ref: inputContainerRef,
|
|
3003
3088
|
keyboardHeight: isKeyboardOpen ? keyboardHeight : 0,
|
|
3004
|
-
children: /* @__PURE__ */ (0,
|
|
3005
|
-
/* @__PURE__ */ (0,
|
|
3089
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
|
|
3090
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("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 }),
|
|
3006
3091
|
BoundDisclaimer
|
|
3007
3092
|
] })
|
|
3008
3093
|
});
|
|
@@ -3015,10 +3100,10 @@ function CopilotChatView({
|
|
|
3015
3100
|
feather: BoundFeather,
|
|
3016
3101
|
inputContainer: BoundInputContainer,
|
|
3017
3102
|
disclaimer: BoundDisclaimer,
|
|
3018
|
-
suggestionView: BoundSuggestionView ?? /* @__PURE__ */ (0,
|
|
3103
|
+
suggestionView: BoundSuggestionView ?? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_jsx_runtime18.Fragment, {})
|
|
3019
3104
|
});
|
|
3020
3105
|
}
|
|
3021
|
-
return /* @__PURE__ */ (0,
|
|
3106
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: (0, import_tailwind_merge7.twMerge)("relative h-full", className), ...props, children: [
|
|
3022
3107
|
BoundScrollView,
|
|
3023
3108
|
BoundFeather,
|
|
3024
3109
|
BoundInputContainer
|
|
@@ -3027,9 +3112,9 @@ function CopilotChatView({
|
|
|
3027
3112
|
((CopilotChatView2) => {
|
|
3028
3113
|
const ScrollContent = ({ children, scrollToBottomButton, inputContainerHeight, isResizing }) => {
|
|
3029
3114
|
const { isAtBottom, scrollToBottom } = (0, import_use_stick_to_bottom.useStickToBottomContext)();
|
|
3030
|
-
return /* @__PURE__ */ (0,
|
|
3031
|
-
/* @__PURE__ */ (0,
|
|
3032
|
-
!isAtBottom && !isResizing && /* @__PURE__ */ (0,
|
|
3115
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
|
|
3116
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_use_stick_to_bottom.StickToBottom.Content, { className: "overflow-y-scroll overflow-x-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6", children }) }),
|
|
3117
|
+
!isAtBottom && !isResizing && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3033
3118
|
"div",
|
|
3034
3119
|
{
|
|
3035
3120
|
className: "absolute inset-x-0 flex justify-center z-10 pointer-events-none",
|
|
@@ -3052,13 +3137,13 @@ function CopilotChatView({
|
|
|
3052
3137
|
className,
|
|
3053
3138
|
...props
|
|
3054
3139
|
}) => {
|
|
3055
|
-
const [hasMounted, setHasMounted] = (0,
|
|
3140
|
+
const [hasMounted, setHasMounted] = (0, import_react22.useState)(false);
|
|
3056
3141
|
const { scrollRef, contentRef, scrollToBottom } = (0, import_use_stick_to_bottom.useStickToBottom)();
|
|
3057
|
-
const [showScrollButton, setShowScrollButton] = (0,
|
|
3058
|
-
(0,
|
|
3142
|
+
const [showScrollButton, setShowScrollButton] = (0, import_react22.useState)(false);
|
|
3143
|
+
(0, import_react22.useEffect)(() => {
|
|
3059
3144
|
setHasMounted(true);
|
|
3060
3145
|
}, []);
|
|
3061
|
-
(0,
|
|
3146
|
+
(0, import_react22.useEffect)(() => {
|
|
3062
3147
|
if (autoScroll) return;
|
|
3063
3148
|
const scrollElement = scrollRef.current;
|
|
3064
3149
|
if (!scrollElement) return;
|
|
@@ -3076,10 +3161,10 @@ function CopilotChatView({
|
|
|
3076
3161
|
};
|
|
3077
3162
|
}, [scrollRef, autoScroll]);
|
|
3078
3163
|
if (!hasMounted) {
|
|
3079
|
-
return /* @__PURE__ */ (0,
|
|
3164
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "h-full max-h-full flex flex-col min-h-0 overflow-y-scroll overflow-x-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6", children }) });
|
|
3080
3165
|
}
|
|
3081
3166
|
if (!autoScroll) {
|
|
3082
|
-
return /* @__PURE__ */ (0,
|
|
3167
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
3083
3168
|
"div",
|
|
3084
3169
|
{
|
|
3085
3170
|
ref: scrollRef,
|
|
@@ -3089,8 +3174,8 @@ function CopilotChatView({
|
|
|
3089
3174
|
),
|
|
3090
3175
|
...props,
|
|
3091
3176
|
children: [
|
|
3092
|
-
/* @__PURE__ */ (0,
|
|
3093
|
-
showScrollButton && !isResizing && /* @__PURE__ */ (0,
|
|
3177
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { ref: contentRef, className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6", children }),
|
|
3178
|
+
showScrollButton && !isResizing && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3094
3179
|
"div",
|
|
3095
3180
|
{
|
|
3096
3181
|
className: "absolute inset-x-0 flex justify-center z-10 pointer-events-none",
|
|
@@ -3106,14 +3191,14 @@ function CopilotChatView({
|
|
|
3106
3191
|
}
|
|
3107
3192
|
);
|
|
3108
3193
|
}
|
|
3109
|
-
return /* @__PURE__ */ (0,
|
|
3194
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3110
3195
|
import_use_stick_to_bottom.StickToBottom,
|
|
3111
3196
|
{
|
|
3112
3197
|
className: cn("h-full max-h-full flex flex-col min-h-0 relative", className),
|
|
3113
3198
|
resize: "smooth",
|
|
3114
3199
|
initial: "smooth",
|
|
3115
3200
|
...props,
|
|
3116
|
-
children: /* @__PURE__ */ (0,
|
|
3201
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3117
3202
|
ScrollContent,
|
|
3118
3203
|
{
|
|
3119
3204
|
scrollToBottomButton,
|
|
@@ -3128,7 +3213,7 @@ function CopilotChatView({
|
|
|
3128
3213
|
CopilotChatView2.ScrollToBottomButton = ({
|
|
3129
3214
|
className,
|
|
3130
3215
|
...props
|
|
3131
|
-
}) => /* @__PURE__ */ (0,
|
|
3216
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3132
3217
|
Button,
|
|
3133
3218
|
{
|
|
3134
3219
|
variant: "outline",
|
|
@@ -3142,10 +3227,10 @@ function CopilotChatView({
|
|
|
3142
3227
|
className
|
|
3143
3228
|
),
|
|
3144
3229
|
...props,
|
|
3145
|
-
children: /* @__PURE__ */ (0,
|
|
3230
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_lucide_react6.ChevronDown, { className: "w-4 h-4 text-gray-600 dark:text-white" })
|
|
3146
3231
|
}
|
|
3147
3232
|
);
|
|
3148
|
-
CopilotChatView2.Feather = ({ className, style, ...props }) => /* @__PURE__ */ (0,
|
|
3233
|
+
CopilotChatView2.Feather = ({ className, style, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3149
3234
|
"div",
|
|
3150
3235
|
{
|
|
3151
3236
|
className: cn(
|
|
@@ -3158,7 +3243,7 @@ function CopilotChatView({
|
|
|
3158
3243
|
...props
|
|
3159
3244
|
}
|
|
3160
3245
|
);
|
|
3161
|
-
CopilotChatView2.InputContainer =
|
|
3246
|
+
CopilotChatView2.InputContainer = import_react22.default.forwardRef(({ children, className, keyboardHeight = 0, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3162
3247
|
"div",
|
|
3163
3248
|
{
|
|
3164
3249
|
ref,
|
|
@@ -3176,7 +3261,7 @@ function CopilotChatView({
|
|
|
3176
3261
|
CopilotChatView2.Disclaimer = ({ className, ...props }) => {
|
|
3177
3262
|
const config = useCopilotChatConfiguration();
|
|
3178
3263
|
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
3179
|
-
return /* @__PURE__ */ (0,
|
|
3264
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3180
3265
|
"div",
|
|
3181
3266
|
{
|
|
3182
3267
|
className: cn("text-center text-xs text-muted-foreground py-3 px-4 max-w-3xl mx-auto", className),
|
|
@@ -3189,16 +3274,16 @@ function CopilotChatView({
|
|
|
3189
3274
|
var CopilotChatView_default = CopilotChatView;
|
|
3190
3275
|
|
|
3191
3276
|
// src/components/chat/CopilotChat.tsx
|
|
3192
|
-
var
|
|
3193
|
-
var
|
|
3277
|
+
var import_shared8 = require("@copilotkitnext/shared");
|
|
3278
|
+
var import_react23 = require("react");
|
|
3194
3279
|
var import_ts_deepmerge = require("ts-deepmerge");
|
|
3195
3280
|
var import_client = require("@ag-ui/client");
|
|
3196
|
-
var
|
|
3281
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
3197
3282
|
function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen, ...props }) {
|
|
3198
3283
|
const existingConfig = useCopilotChatConfiguration();
|
|
3199
|
-
const resolvedAgentId = agentId ?? existingConfig?.agentId ??
|
|
3200
|
-
const resolvedThreadId = (0,
|
|
3201
|
-
() => threadId ?? existingConfig?.threadId ?? (0,
|
|
3284
|
+
const resolvedAgentId = agentId ?? existingConfig?.agentId ?? import_shared8.DEFAULT_AGENT_ID;
|
|
3285
|
+
const resolvedThreadId = (0, import_react23.useMemo)(
|
|
3286
|
+
() => threadId ?? existingConfig?.threadId ?? (0, import_shared8.randomUUID)(),
|
|
3202
3287
|
[threadId, existingConfig?.threadId]
|
|
3203
3288
|
);
|
|
3204
3289
|
const { agent } = useAgent({ agentId: resolvedAgentId });
|
|
@@ -3210,7 +3295,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
3210
3295
|
suggestionView: providedSuggestionView,
|
|
3211
3296
|
...restProps
|
|
3212
3297
|
} = props;
|
|
3213
|
-
(0,
|
|
3298
|
+
(0, import_react23.useEffect)(() => {
|
|
3214
3299
|
const connect = async (agent2) => {
|
|
3215
3300
|
try {
|
|
3216
3301
|
await copilotkit.connectAgent({ agent: agent2 });
|
|
@@ -3228,10 +3313,10 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
3228
3313
|
return () => {
|
|
3229
3314
|
};
|
|
3230
3315
|
}, [resolvedThreadId, agent, copilotkit, resolvedAgentId]);
|
|
3231
|
-
const onSubmitInput = (0,
|
|
3316
|
+
const onSubmitInput = (0, import_react23.useCallback)(
|
|
3232
3317
|
async (value) => {
|
|
3233
3318
|
agent?.addMessage({
|
|
3234
|
-
id: (0,
|
|
3319
|
+
id: (0, import_shared8.randomUUID)(),
|
|
3235
3320
|
role: "user",
|
|
3236
3321
|
content: value
|
|
3237
3322
|
});
|
|
@@ -3245,13 +3330,13 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
3245
3330
|
},
|
|
3246
3331
|
[agent, copilotkit]
|
|
3247
3332
|
);
|
|
3248
|
-
const handleSelectSuggestion = (0,
|
|
3333
|
+
const handleSelectSuggestion = (0, import_react23.useCallback)(
|
|
3249
3334
|
async (suggestion) => {
|
|
3250
3335
|
if (!agent) {
|
|
3251
3336
|
return;
|
|
3252
3337
|
}
|
|
3253
3338
|
agent.addMessage({
|
|
3254
|
-
id: (0,
|
|
3339
|
+
id: (0, import_shared8.randomUUID)(),
|
|
3255
3340
|
role: "user",
|
|
3256
3341
|
content: suggestion.message
|
|
3257
3342
|
});
|
|
@@ -3263,7 +3348,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
3263
3348
|
},
|
|
3264
3349
|
[agent, copilotkit]
|
|
3265
3350
|
);
|
|
3266
|
-
const stopCurrentRun = (0,
|
|
3351
|
+
const stopCurrentRun = (0, import_react23.useCallback)(() => {
|
|
3267
3352
|
if (!agent) {
|
|
3268
3353
|
return;
|
|
3269
3354
|
}
|
|
@@ -3306,7 +3391,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
3306
3391
|
inputProps: finalInputProps
|
|
3307
3392
|
});
|
|
3308
3393
|
const RenderedChatView = renderSlot(chatView, CopilotChatView, finalProps);
|
|
3309
|
-
return /* @__PURE__ */ (0,
|
|
3394
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
3310
3395
|
CopilotChatConfigurationProvider,
|
|
3311
3396
|
{
|
|
3312
3397
|
agentId: resolvedAgentId,
|
|
@@ -3322,17 +3407,17 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
3322
3407
|
})(CopilotChat || (CopilotChat = {}));
|
|
3323
3408
|
|
|
3324
3409
|
// src/components/chat/CopilotChatToggleButton.tsx
|
|
3325
|
-
var
|
|
3410
|
+
var import_react24 = __toESM(require("react"));
|
|
3326
3411
|
var import_lucide_react7 = require("lucide-react");
|
|
3327
|
-
var
|
|
3412
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
3328
3413
|
var DefaultOpenIcon = ({
|
|
3329
3414
|
className,
|
|
3330
3415
|
...props
|
|
3331
|
-
}) => /* @__PURE__ */ (0,
|
|
3416
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_lucide_react7.MessageCircle, { className: cn("h-6 w-6", className), strokeWidth: 1.75, fill: "currentColor", ...props });
|
|
3332
3417
|
var DefaultCloseIcon = ({
|
|
3333
3418
|
className,
|
|
3334
3419
|
...props
|
|
3335
|
-
}) => /* @__PURE__ */ (0,
|
|
3420
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_lucide_react7.X, { className: cn("h-6 w-6", className), strokeWidth: 1.75, ...props });
|
|
3336
3421
|
DefaultOpenIcon.displayName = "CopilotChatToggleButton.OpenIcon";
|
|
3337
3422
|
DefaultCloseIcon.displayName = "CopilotChatToggleButton.CloseIcon";
|
|
3338
3423
|
var ICON_TRANSITION_STYLE = Object.freeze({
|
|
@@ -3349,11 +3434,11 @@ var BUTTON_BASE_CLASSES = cn(
|
|
|
3349
3434
|
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 focus-visible:ring-offset-2 focus-visible:ring-offset-background",
|
|
3350
3435
|
"disabled:pointer-events-none disabled:opacity-60"
|
|
3351
3436
|
);
|
|
3352
|
-
var CopilotChatToggleButton =
|
|
3437
|
+
var CopilotChatToggleButton = import_react24.default.forwardRef(function CopilotChatToggleButton2({ openIcon, closeIcon, className, ...buttonProps }, ref) {
|
|
3353
3438
|
const { onClick, type, disabled, ...restProps } = buttonProps;
|
|
3354
3439
|
const configuration = useCopilotChatConfiguration();
|
|
3355
3440
|
const labels = configuration?.labels ?? CopilotChatDefaultLabels;
|
|
3356
|
-
const [fallbackOpen, setFallbackOpen] = (0,
|
|
3441
|
+
const [fallbackOpen, setFallbackOpen] = (0, import_react24.useState)(false);
|
|
3357
3442
|
const isOpen = configuration?.isModalOpen ?? fallbackOpen;
|
|
3358
3443
|
const setModalOpen = configuration?.setModalOpen ?? setFallbackOpen;
|
|
3359
3444
|
const handleClick = (event) => {
|
|
@@ -3387,7 +3472,7 @@ var CopilotChatToggleButton = import_react23.default.forwardRef(function Copilot
|
|
|
3387
3472
|
focusable: false
|
|
3388
3473
|
}
|
|
3389
3474
|
);
|
|
3390
|
-
const openIconElement = /* @__PURE__ */ (0,
|
|
3475
|
+
const openIconElement = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
3391
3476
|
"span",
|
|
3392
3477
|
{
|
|
3393
3478
|
"aria-hidden": "true",
|
|
@@ -3401,7 +3486,7 @@ var CopilotChatToggleButton = import_react23.default.forwardRef(function Copilot
|
|
|
3401
3486
|
children: renderedOpenIcon
|
|
3402
3487
|
}
|
|
3403
3488
|
);
|
|
3404
|
-
const closeIconElement = /* @__PURE__ */ (0,
|
|
3489
|
+
const closeIconElement = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
3405
3490
|
"span",
|
|
3406
3491
|
{
|
|
3407
3492
|
"aria-hidden": "true",
|
|
@@ -3415,7 +3500,7 @@ var CopilotChatToggleButton = import_react23.default.forwardRef(function Copilot
|
|
|
3415
3500
|
children: renderedCloseIcon
|
|
3416
3501
|
}
|
|
3417
3502
|
);
|
|
3418
|
-
return /* @__PURE__ */ (0,
|
|
3503
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
3419
3504
|
"button",
|
|
3420
3505
|
{
|
|
3421
3506
|
ref,
|
|
@@ -3439,12 +3524,12 @@ CopilotChatToggleButton.displayName = "CopilotChatToggleButton";
|
|
|
3439
3524
|
var CopilotChatToggleButton_default = CopilotChatToggleButton;
|
|
3440
3525
|
|
|
3441
3526
|
// src/components/chat/CopilotSidebarView.tsx
|
|
3442
|
-
var
|
|
3527
|
+
var import_react26 = require("react");
|
|
3443
3528
|
|
|
3444
3529
|
// src/components/chat/CopilotModalHeader.tsx
|
|
3445
|
-
var
|
|
3530
|
+
var import_react25 = require("react");
|
|
3446
3531
|
var import_lucide_react8 = require("lucide-react");
|
|
3447
|
-
var
|
|
3532
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
3448
3533
|
function CopilotModalHeader({
|
|
3449
3534
|
title,
|
|
3450
3535
|
titleContent,
|
|
@@ -3456,7 +3541,7 @@ function CopilotModalHeader({
|
|
|
3456
3541
|
const configuration = useCopilotChatConfiguration();
|
|
3457
3542
|
const fallbackTitle = configuration?.labels.modalHeaderTitle ?? CopilotChatDefaultLabels.modalHeaderTitle;
|
|
3458
3543
|
const resolvedTitle = title ?? fallbackTitle;
|
|
3459
|
-
const handleClose = (0,
|
|
3544
|
+
const handleClose = (0, import_react25.useCallback)(() => {
|
|
3460
3545
|
configuration?.setModalOpen(false);
|
|
3461
3546
|
}, [configuration]);
|
|
3462
3547
|
const BoundTitle = renderSlot(titleContent, CopilotModalHeader.Title, {
|
|
@@ -3473,7 +3558,7 @@ function CopilotModalHeader({
|
|
|
3473
3558
|
...rest
|
|
3474
3559
|
});
|
|
3475
3560
|
}
|
|
3476
|
-
return /* @__PURE__ */ (0,
|
|
3561
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
3477
3562
|
"header",
|
|
3478
3563
|
{
|
|
3479
3564
|
"data-slot": "copilot-modal-header",
|
|
@@ -3483,17 +3568,17 @@ function CopilotModalHeader({
|
|
|
3483
3568
|
className
|
|
3484
3569
|
),
|
|
3485
3570
|
...rest,
|
|
3486
|
-
children: /* @__PURE__ */ (0,
|
|
3487
|
-
/* @__PURE__ */ (0,
|
|
3488
|
-
/* @__PURE__ */ (0,
|
|
3489
|
-
/* @__PURE__ */ (0,
|
|
3571
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex w-full items-center gap-2", children: [
|
|
3572
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "flex-1", "aria-hidden": "true" }),
|
|
3573
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "flex flex-1 justify-center text-center", children: BoundTitle }),
|
|
3574
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "flex flex-1 justify-end", children: BoundCloseButton })
|
|
3490
3575
|
] })
|
|
3491
3576
|
}
|
|
3492
3577
|
);
|
|
3493
3578
|
}
|
|
3494
3579
|
CopilotModalHeader.displayName = "CopilotModalHeader";
|
|
3495
3580
|
((CopilotModalHeader2) => {
|
|
3496
|
-
CopilotModalHeader2.Title = ({ children, className, ...props }) => /* @__PURE__ */ (0,
|
|
3581
|
+
CopilotModalHeader2.Title = ({ children, className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
3497
3582
|
"div",
|
|
3498
3583
|
{
|
|
3499
3584
|
className: cn(
|
|
@@ -3507,7 +3592,7 @@ CopilotModalHeader.displayName = "CopilotModalHeader";
|
|
|
3507
3592
|
CopilotModalHeader2.CloseButton = ({
|
|
3508
3593
|
className,
|
|
3509
3594
|
...props
|
|
3510
|
-
}) => /* @__PURE__ */ (0,
|
|
3595
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
3511
3596
|
"button",
|
|
3512
3597
|
{
|
|
3513
3598
|
type: "button",
|
|
@@ -3518,7 +3603,7 @@ CopilotModalHeader.displayName = "CopilotModalHeader";
|
|
|
3518
3603
|
),
|
|
3519
3604
|
"aria-label": "Close",
|
|
3520
3605
|
...props,
|
|
3521
|
-
children: /* @__PURE__ */ (0,
|
|
3606
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_lucide_react8.X, { className: "h-4 w-4", "aria-hidden": "true" })
|
|
3522
3607
|
}
|
|
3523
3608
|
);
|
|
3524
3609
|
})(CopilotModalHeader || (CopilotModalHeader = {}));
|
|
@@ -3526,14 +3611,14 @@ CopilotModalHeader.Title.displayName = "CopilotModalHeader.Title";
|
|
|
3526
3611
|
CopilotModalHeader.CloseButton.displayName = "CopilotModalHeader.CloseButton";
|
|
3527
3612
|
|
|
3528
3613
|
// src/components/chat/CopilotSidebarView.tsx
|
|
3529
|
-
var
|
|
3614
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
3530
3615
|
var DEFAULT_SIDEBAR_WIDTH = 480;
|
|
3531
3616
|
var SIDEBAR_TRANSITION_MS = 260;
|
|
3532
3617
|
function CopilotSidebarView({ header, width, ...props }) {
|
|
3533
3618
|
const configuration = useCopilotChatConfiguration();
|
|
3534
3619
|
const isSidebarOpen = configuration?.isModalOpen ?? false;
|
|
3535
|
-
const sidebarRef = (0,
|
|
3536
|
-
const [sidebarWidth, setSidebarWidth] = (0,
|
|
3620
|
+
const sidebarRef = (0, import_react26.useRef)(null);
|
|
3621
|
+
const [sidebarWidth, setSidebarWidth] = (0, import_react26.useState)(width ?? DEFAULT_SIDEBAR_WIDTH);
|
|
3537
3622
|
const widthToCss = (w) => {
|
|
3538
3623
|
return typeof w === "number" ? `${w}px` : w;
|
|
3539
3624
|
};
|
|
@@ -3543,7 +3628,7 @@ function CopilotSidebarView({ header, width, ...props }) {
|
|
|
3543
3628
|
}
|
|
3544
3629
|
return w;
|
|
3545
3630
|
};
|
|
3546
|
-
(0,
|
|
3631
|
+
(0, import_react26.useEffect)(() => {
|
|
3547
3632
|
if (width !== void 0) {
|
|
3548
3633
|
return;
|
|
3549
3634
|
}
|
|
@@ -3570,8 +3655,8 @@ function CopilotSidebarView({ header, width, ...props }) {
|
|
|
3570
3655
|
return () => window.removeEventListener("resize", updateWidth);
|
|
3571
3656
|
}, [width]);
|
|
3572
3657
|
const headerElement = renderSlot(header, CopilotModalHeader, {});
|
|
3573
|
-
return /* @__PURE__ */ (0,
|
|
3574
|
-
isSidebarOpen && /* @__PURE__ */ (0,
|
|
3658
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(import_jsx_runtime22.Fragment, { children: [
|
|
3659
|
+
isSidebarOpen && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
3575
3660
|
"style",
|
|
3576
3661
|
{
|
|
3577
3662
|
dangerouslySetInnerHTML: {
|
|
@@ -3585,8 +3670,8 @@ function CopilotSidebarView({ header, width, ...props }) {
|
|
|
3585
3670
|
}
|
|
3586
3671
|
}
|
|
3587
3672
|
),
|
|
3588
|
-
/* @__PURE__ */ (0,
|
|
3589
|
-
/* @__PURE__ */ (0,
|
|
3673
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(CopilotChatToggleButton_default, {}),
|
|
3674
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
3590
3675
|
"aside",
|
|
3591
3676
|
{
|
|
3592
3677
|
ref: sidebarRef,
|
|
@@ -3611,9 +3696,9 @@ function CopilotSidebarView({ header, width, ...props }) {
|
|
|
3611
3696
|
"aria-hidden": !isSidebarOpen,
|
|
3612
3697
|
"aria-label": "Copilot chat sidebar",
|
|
3613
3698
|
role: "complementary",
|
|
3614
|
-
children: /* @__PURE__ */ (0,
|
|
3699
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex h-full w-full flex-col overflow-hidden", children: [
|
|
3615
3700
|
headerElement,
|
|
3616
|
-
/* @__PURE__ */ (0,
|
|
3701
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "flex-1 overflow-hidden", "data-sidebar-chat": true, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(CopilotChatView_default, { ...props }) })
|
|
3617
3702
|
] })
|
|
3618
3703
|
}
|
|
3619
3704
|
)
|
|
@@ -3622,8 +3707,8 @@ function CopilotSidebarView({ header, width, ...props }) {
|
|
|
3622
3707
|
CopilotSidebarView.displayName = "CopilotSidebarView";
|
|
3623
3708
|
|
|
3624
3709
|
// src/components/chat/CopilotPopupView.tsx
|
|
3625
|
-
var
|
|
3626
|
-
var
|
|
3710
|
+
var import_react27 = require("react");
|
|
3711
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
3627
3712
|
var DEFAULT_POPUP_WIDTH = 420;
|
|
3628
3713
|
var DEFAULT_POPUP_HEIGHT = 560;
|
|
3629
3714
|
var dimensionToCss = (value, fallback) => {
|
|
@@ -3647,10 +3732,10 @@ function CopilotPopupView({
|
|
|
3647
3732
|
const isPopupOpen = configuration?.isModalOpen ?? false;
|
|
3648
3733
|
const setModalOpen = configuration?.setModalOpen;
|
|
3649
3734
|
const labels = configuration?.labels ?? CopilotChatDefaultLabels;
|
|
3650
|
-
const containerRef = (0,
|
|
3651
|
-
const [isRendered, setIsRendered] = (0,
|
|
3652
|
-
const [isAnimatingOut, setIsAnimatingOut] = (0,
|
|
3653
|
-
(0,
|
|
3735
|
+
const containerRef = (0, import_react27.useRef)(null);
|
|
3736
|
+
const [isRendered, setIsRendered] = (0, import_react27.useState)(isPopupOpen);
|
|
3737
|
+
const [isAnimatingOut, setIsAnimatingOut] = (0, import_react27.useState)(false);
|
|
3738
|
+
(0, import_react27.useEffect)(() => {
|
|
3654
3739
|
if (isPopupOpen) {
|
|
3655
3740
|
setIsRendered(true);
|
|
3656
3741
|
setIsAnimatingOut(false);
|
|
@@ -3666,7 +3751,7 @@ function CopilotPopupView({
|
|
|
3666
3751
|
}, 200);
|
|
3667
3752
|
return () => clearTimeout(timeout);
|
|
3668
3753
|
}, [isPopupOpen, isRendered]);
|
|
3669
|
-
(0,
|
|
3754
|
+
(0, import_react27.useEffect)(() => {
|
|
3670
3755
|
if (!isPopupOpen) {
|
|
3671
3756
|
return;
|
|
3672
3757
|
}
|
|
@@ -3682,7 +3767,7 @@ function CopilotPopupView({
|
|
|
3682
3767
|
window.addEventListener("keydown", handleKeyDown);
|
|
3683
3768
|
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
3684
3769
|
}, [isPopupOpen, setModalOpen]);
|
|
3685
|
-
(0,
|
|
3770
|
+
(0, import_react27.useEffect)(() => {
|
|
3686
3771
|
if (!isPopupOpen) {
|
|
3687
3772
|
return;
|
|
3688
3773
|
}
|
|
@@ -3691,7 +3776,7 @@ function CopilotPopupView({
|
|
|
3691
3776
|
}, 200);
|
|
3692
3777
|
return () => clearTimeout(focusTimer);
|
|
3693
3778
|
}, [isPopupOpen]);
|
|
3694
|
-
(0,
|
|
3779
|
+
(0, import_react27.useEffect)(() => {
|
|
3695
3780
|
if (!isPopupOpen || !clickOutsideToClose) {
|
|
3696
3781
|
return;
|
|
3697
3782
|
}
|
|
@@ -3716,10 +3801,10 @@ function CopilotPopupView({
|
|
|
3716
3801
|
document.addEventListener("pointerdown", handlePointerDown);
|
|
3717
3802
|
return () => document.removeEventListener("pointerdown", handlePointerDown);
|
|
3718
3803
|
}, [isPopupOpen, clickOutsideToClose, setModalOpen]);
|
|
3719
|
-
const headerElement = (0,
|
|
3804
|
+
const headerElement = (0, import_react27.useMemo)(() => renderSlot(header, CopilotModalHeader, {}), [header]);
|
|
3720
3805
|
const resolvedWidth = dimensionToCss(width, DEFAULT_POPUP_WIDTH);
|
|
3721
3806
|
const resolvedHeight = dimensionToCss(height, DEFAULT_POPUP_HEIGHT);
|
|
3722
|
-
const popupStyle = (0,
|
|
3807
|
+
const popupStyle = (0, import_react27.useMemo)(
|
|
3723
3808
|
() => ({
|
|
3724
3809
|
"--copilot-popup-width": resolvedWidth,
|
|
3725
3810
|
"--copilot-popup-height": resolvedHeight,
|
|
@@ -3733,14 +3818,14 @@ function CopilotPopupView({
|
|
|
3733
3818
|
[resolvedHeight, resolvedWidth]
|
|
3734
3819
|
);
|
|
3735
3820
|
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]";
|
|
3736
|
-
const popupContent = isRendered ? /* @__PURE__ */ (0,
|
|
3821
|
+
const popupContent = isRendered ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3737
3822
|
"div",
|
|
3738
3823
|
{
|
|
3739
3824
|
className: cn(
|
|
3740
3825
|
"fixed inset-0 z-[1200] flex max-w-full flex-col items-stretch",
|
|
3741
3826
|
"md:inset-auto md:bottom-24 md:right-6 md:items-end md:gap-4"
|
|
3742
3827
|
),
|
|
3743
|
-
children: /* @__PURE__ */ (0,
|
|
3828
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
3744
3829
|
"div",
|
|
3745
3830
|
{
|
|
3746
3831
|
ref: containerRef,
|
|
@@ -3761,7 +3846,7 @@ function CopilotPopupView({
|
|
|
3761
3846
|
style: popupStyle,
|
|
3762
3847
|
children: [
|
|
3763
3848
|
headerElement,
|
|
3764
|
-
/* @__PURE__ */ (0,
|
|
3849
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "flex-1 overflow-hidden", "data-popup-chat": true, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3765
3850
|
CopilotChatView_default,
|
|
3766
3851
|
{
|
|
3767
3852
|
...restProps,
|
|
@@ -3773,21 +3858,21 @@ function CopilotPopupView({
|
|
|
3773
3858
|
)
|
|
3774
3859
|
}
|
|
3775
3860
|
) : null;
|
|
3776
|
-
return /* @__PURE__ */ (0,
|
|
3777
|
-
/* @__PURE__ */ (0,
|
|
3861
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
|
|
3862
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(CopilotChatToggleButton_default, {}),
|
|
3778
3863
|
popupContent
|
|
3779
3864
|
] });
|
|
3780
3865
|
}
|
|
3781
3866
|
CopilotPopupView.displayName = "CopilotPopupView";
|
|
3782
3867
|
|
|
3783
3868
|
// src/components/chat/CopilotSidebar.tsx
|
|
3784
|
-
var
|
|
3785
|
-
var
|
|
3869
|
+
var import_react28 = require("react");
|
|
3870
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
3786
3871
|
function CopilotSidebar({ header, defaultOpen, width, ...chatProps }) {
|
|
3787
|
-
const SidebarViewOverride = (0,
|
|
3872
|
+
const SidebarViewOverride = (0, import_react28.useMemo)(() => {
|
|
3788
3873
|
const Component = (viewProps) => {
|
|
3789
3874
|
const { header: viewHeader, width: viewWidth, ...restProps } = viewProps;
|
|
3790
|
-
return /* @__PURE__ */ (0,
|
|
3875
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
3791
3876
|
CopilotSidebarView,
|
|
3792
3877
|
{
|
|
3793
3878
|
...restProps,
|
|
@@ -3798,7 +3883,7 @@ function CopilotSidebar({ header, defaultOpen, width, ...chatProps }) {
|
|
|
3798
3883
|
};
|
|
3799
3884
|
return Object.assign(Component, CopilotChatView_default);
|
|
3800
3885
|
}, [header, width]);
|
|
3801
|
-
return /* @__PURE__ */ (0,
|
|
3886
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
3802
3887
|
CopilotChat,
|
|
3803
3888
|
{
|
|
3804
3889
|
...chatProps,
|
|
@@ -3810,8 +3895,8 @@ function CopilotSidebar({ header, defaultOpen, width, ...chatProps }) {
|
|
|
3810
3895
|
CopilotSidebar.displayName = "CopilotSidebar";
|
|
3811
3896
|
|
|
3812
3897
|
// src/components/chat/CopilotPopup.tsx
|
|
3813
|
-
var
|
|
3814
|
-
var
|
|
3898
|
+
var import_react29 = require("react");
|
|
3899
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
3815
3900
|
function CopilotPopup({
|
|
3816
3901
|
header,
|
|
3817
3902
|
defaultOpen,
|
|
@@ -3820,7 +3905,7 @@ function CopilotPopup({
|
|
|
3820
3905
|
clickOutsideToClose,
|
|
3821
3906
|
...chatProps
|
|
3822
3907
|
}) {
|
|
3823
|
-
const PopupViewOverride = (0,
|
|
3908
|
+
const PopupViewOverride = (0, import_react29.useMemo)(() => {
|
|
3824
3909
|
const Component = (viewProps) => {
|
|
3825
3910
|
const {
|
|
3826
3911
|
header: viewHeader,
|
|
@@ -3829,7 +3914,7 @@ function CopilotPopup({
|
|
|
3829
3914
|
clickOutsideToClose: viewClickOutsideToClose,
|
|
3830
3915
|
...restProps
|
|
3831
3916
|
} = viewProps;
|
|
3832
|
-
return /* @__PURE__ */ (0,
|
|
3917
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3833
3918
|
CopilotPopupView,
|
|
3834
3919
|
{
|
|
3835
3920
|
...restProps,
|
|
@@ -3842,7 +3927,7 @@ function CopilotPopup({
|
|
|
3842
3927
|
};
|
|
3843
3928
|
return Object.assign(Component, CopilotChatView_default);
|
|
3844
3929
|
}, [clickOutsideToClose, header, height, width]);
|
|
3845
|
-
return /* @__PURE__ */ (0,
|
|
3930
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3846
3931
|
CopilotChat,
|
|
3847
3932
|
{
|
|
3848
3933
|
...chatProps,
|
|
@@ -3866,25 +3951,25 @@ function defineToolCallRenderer(def) {
|
|
|
3866
3951
|
}
|
|
3867
3952
|
|
|
3868
3953
|
// src/components/WildcardToolCallRender.tsx
|
|
3869
|
-
var
|
|
3870
|
-
var
|
|
3954
|
+
var import_react30 = require("react");
|
|
3955
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
3871
3956
|
var WildcardToolCallRender = defineToolCallRenderer({
|
|
3872
3957
|
name: "*",
|
|
3873
3958
|
render: ({ args, result, name, status }) => {
|
|
3874
|
-
const [isExpanded, setIsExpanded] = (0,
|
|
3959
|
+
const [isExpanded, setIsExpanded] = (0, import_react30.useState)(false);
|
|
3875
3960
|
const statusString = String(status);
|
|
3876
3961
|
const isActive = statusString === "inProgress" || statusString === "executing";
|
|
3877
3962
|
const isComplete = statusString === "complete";
|
|
3878
3963
|
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";
|
|
3879
|
-
return /* @__PURE__ */ (0,
|
|
3880
|
-
/* @__PURE__ */ (0,
|
|
3964
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "mt-2 pb-2", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("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: [
|
|
3965
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
3881
3966
|
"div",
|
|
3882
3967
|
{
|
|
3883
3968
|
className: "flex items-center justify-between gap-3 cursor-pointer",
|
|
3884
3969
|
onClick: () => setIsExpanded(!isExpanded),
|
|
3885
3970
|
children: [
|
|
3886
|
-
/* @__PURE__ */ (0,
|
|
3887
|
-
/* @__PURE__ */ (0,
|
|
3971
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex items-center gap-2 min-w-0", children: [
|
|
3972
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3888
3973
|
"svg",
|
|
3889
3974
|
{
|
|
3890
3975
|
className: `h-4 w-4 text-zinc-500 dark:text-zinc-400 transition-transform ${isExpanded ? "rotate-90" : ""}`,
|
|
@@ -3892,7 +3977,7 @@ var WildcardToolCallRender = defineToolCallRenderer({
|
|
|
3892
3977
|
viewBox: "0 0 24 24",
|
|
3893
3978
|
strokeWidth: 2,
|
|
3894
3979
|
stroke: "currentColor",
|
|
3895
|
-
children: /* @__PURE__ */ (0,
|
|
3980
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3896
3981
|
"path",
|
|
3897
3982
|
{
|
|
3898
3983
|
strokeLinecap: "round",
|
|
@@ -3902,10 +3987,10 @@ var WildcardToolCallRender = defineToolCallRenderer({
|
|
|
3902
3987
|
)
|
|
3903
3988
|
}
|
|
3904
3989
|
),
|
|
3905
|
-
/* @__PURE__ */ (0,
|
|
3906
|
-
/* @__PURE__ */ (0,
|
|
3990
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "inline-block h-2 w-2 rounded-full bg-blue-500" }),
|
|
3991
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "truncate text-sm font-medium text-zinc-900 dark:text-zinc-100", children: name })
|
|
3907
3992
|
] }),
|
|
3908
|
-
/* @__PURE__ */ (0,
|
|
3993
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3909
3994
|
"span",
|
|
3910
3995
|
{
|
|
3911
3996
|
className: `inline-flex items-center rounded-full px-2 py-1 text-xs font-medium ${statusStyles}`,
|
|
@@ -3915,14 +4000,14 @@ var WildcardToolCallRender = defineToolCallRenderer({
|
|
|
3915
4000
|
]
|
|
3916
4001
|
}
|
|
3917
4002
|
),
|
|
3918
|
-
isExpanded && /* @__PURE__ */ (0,
|
|
3919
|
-
/* @__PURE__ */ (0,
|
|
3920
|
-
/* @__PURE__ */ (0,
|
|
3921
|
-
/* @__PURE__ */ (0,
|
|
4003
|
+
isExpanded && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "mt-3 grid gap-4", children: [
|
|
4004
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { children: [
|
|
4005
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "text-xs uppercase tracking-wide text-zinc-500 dark:text-zinc-400", children: "Arguments" }),
|
|
4006
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("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) })
|
|
3922
4007
|
] }),
|
|
3923
|
-
result !== void 0 && /* @__PURE__ */ (0,
|
|
3924
|
-
/* @__PURE__ */ (0,
|
|
3925
|
-
/* @__PURE__ */ (0,
|
|
4008
|
+
result !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { children: [
|
|
4009
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "text-xs uppercase tracking-wide text-zinc-500 dark:text-zinc-400", children: "Result" }),
|
|
4010
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("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) })
|
|
3926
4011
|
] })
|
|
3927
4012
|
] })
|
|
3928
4013
|
] }) });
|
|
@@ -3962,6 +4047,7 @@ var WildcardToolCallRender = defineToolCallRenderer({
|
|
|
3962
4047
|
useCopilotKit,
|
|
3963
4048
|
useFrontendTool,
|
|
3964
4049
|
useHumanInTheLoop,
|
|
4050
|
+
useRenderActivityMessage,
|
|
3965
4051
|
useRenderCustomMessages,
|
|
3966
4052
|
useRenderToolCall,
|
|
3967
4053
|
useSuggestions
|