@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.mjs
CHANGED
|
@@ -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,7 +1864,7 @@ function useFrontendTool(tool) {
|
|
|
1804
1864
|
}
|
|
1805
1865
|
|
|
1806
1866
|
// src/hooks/use-human-in-the-loop.tsx
|
|
1807
|
-
import { useState as useState5, useCallback as
|
|
1867
|
+
import { useState as useState5, 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();
|
|
@@ -1814,20 +1874,20 @@ function useHumanInTheLoop(tool) {
|
|
|
1814
1874
|
const statusRef = useRef5(status);
|
|
1815
1875
|
const resolvePromiseRef = useRef5(null);
|
|
1816
1876
|
statusRef.current = status;
|
|
1817
|
-
const respond =
|
|
1877
|
+
const respond = useCallback4(async (result) => {
|
|
1818
1878
|
if (resolvePromiseRef.current) {
|
|
1819
1879
|
resolvePromiseRef.current(result);
|
|
1820
1880
|
setStatus("complete");
|
|
1821
1881
|
resolvePromiseRef.current = null;
|
|
1822
1882
|
}
|
|
1823
1883
|
}, []);
|
|
1824
|
-
const handler =
|
|
1884
|
+
const handler = useCallback4(async () => {
|
|
1825
1885
|
return new Promise((resolve) => {
|
|
1826
1886
|
setStatus("executing");
|
|
1827
1887
|
resolvePromiseRef.current = resolve;
|
|
1828
1888
|
});
|
|
1829
1889
|
}, []);
|
|
1830
|
-
const RenderComponent =
|
|
1890
|
+
const RenderComponent = useCallback4(
|
|
1831
1891
|
(props) => {
|
|
1832
1892
|
const ToolComponent = tool.render;
|
|
1833
1893
|
const currentStatus = statusRef.current;
|
|
@@ -1880,14 +1940,14 @@ function useHumanInTheLoop(tool) {
|
|
|
1880
1940
|
|
|
1881
1941
|
// src/hooks/use-agent.tsx
|
|
1882
1942
|
import { useMemo as useMemo4, useEffect as useEffect8, useReducer as useReducer2 } from "react";
|
|
1883
|
-
import { DEFAULT_AGENT_ID as
|
|
1943
|
+
import { DEFAULT_AGENT_ID as DEFAULT_AGENT_ID4 } from "@copilotkitnext/shared";
|
|
1884
1944
|
var ALL_UPDATES = [
|
|
1885
1945
|
"OnMessagesChanged" /* OnMessagesChanged */,
|
|
1886
1946
|
"OnStateChanged" /* OnStateChanged */,
|
|
1887
1947
|
"OnRunStatusChanged" /* OnRunStatusChanged */
|
|
1888
1948
|
];
|
|
1889
1949
|
function useAgent({ agentId, updates } = {}) {
|
|
1890
|
-
agentId ??=
|
|
1950
|
+
agentId ??= DEFAULT_AGENT_ID4;
|
|
1891
1951
|
const { copilotkit } = useCopilotKit();
|
|
1892
1952
|
const [, forceUpdate] = useReducer2((x) => x + 1, 0);
|
|
1893
1953
|
const updateFlags = useMemo4(
|
|
@@ -1954,12 +2014,12 @@ function useAgentContext(context) {
|
|
|
1954
2014
|
}
|
|
1955
2015
|
|
|
1956
2016
|
// src/hooks/use-suggestions.tsx
|
|
1957
|
-
import { useCallback as
|
|
1958
|
-
import { DEFAULT_AGENT_ID as
|
|
2017
|
+
import { useCallback as useCallback5, useEffect as useEffect10, useMemo as useMemo5, useState as useState6 } from "react";
|
|
2018
|
+
import { DEFAULT_AGENT_ID as DEFAULT_AGENT_ID5 } from "@copilotkitnext/shared";
|
|
1959
2019
|
function useSuggestions({ agentId } = {}) {
|
|
1960
2020
|
const { copilotkit } = useCopilotKit();
|
|
1961
2021
|
const config = useCopilotChatConfiguration();
|
|
1962
|
-
const resolvedAgentId = useMemo5(() => agentId ?? config?.agentId ??
|
|
2022
|
+
const resolvedAgentId = useMemo5(() => agentId ?? config?.agentId ?? DEFAULT_AGENT_ID5, [agentId, config?.agentId]);
|
|
1963
2023
|
const [suggestions, setSuggestions] = useState6(() => {
|
|
1964
2024
|
const result = copilotkit.getSuggestions(resolvedAgentId);
|
|
1965
2025
|
return result.suggestions;
|
|
@@ -2003,10 +2063,10 @@ function useSuggestions({ agentId } = {}) {
|
|
|
2003
2063
|
unsubscribe();
|
|
2004
2064
|
};
|
|
2005
2065
|
}, [copilotkit, resolvedAgentId]);
|
|
2006
|
-
const reloadSuggestions =
|
|
2066
|
+
const reloadSuggestions = useCallback5(() => {
|
|
2007
2067
|
copilotkit.reloadSuggestions(resolvedAgentId);
|
|
2008
2068
|
}, [copilotkit, resolvedAgentId]);
|
|
2009
|
-
const clearSuggestions =
|
|
2069
|
+
const clearSuggestions = useCallback5(() => {
|
|
2010
2070
|
copilotkit.clearSuggestions(resolvedAgentId);
|
|
2011
2071
|
}, [copilotkit, resolvedAgentId]);
|
|
2012
2072
|
return {
|
|
@@ -2018,14 +2078,14 @@ function useSuggestions({ agentId } = {}) {
|
|
|
2018
2078
|
}
|
|
2019
2079
|
|
|
2020
2080
|
// src/hooks/use-configure-suggestions.tsx
|
|
2021
|
-
import { useCallback as
|
|
2022
|
-
import { DEFAULT_AGENT_ID as
|
|
2081
|
+
import { useCallback as useCallback6, useEffect as useEffect11, useMemo as useMemo6, useRef as useRef6 } from "react";
|
|
2082
|
+
import { DEFAULT_AGENT_ID as DEFAULT_AGENT_ID6 } from "@copilotkitnext/shared";
|
|
2023
2083
|
var EMPTY_DEPS = [];
|
|
2024
2084
|
function useConfigureSuggestions(config, options) {
|
|
2025
2085
|
const { copilotkit } = useCopilotKit();
|
|
2026
2086
|
const chatConfig = useCopilotChatConfiguration();
|
|
2027
2087
|
const extraDeps = options?.deps ?? EMPTY_DEPS;
|
|
2028
|
-
const resolvedConsumerAgentId = useMemo6(() => chatConfig?.agentId ??
|
|
2088
|
+
const resolvedConsumerAgentId = useMemo6(() => chatConfig?.agentId ?? DEFAULT_AGENT_ID6, [chatConfig?.agentId]);
|
|
2029
2089
|
const rawConsumerAgentId = useMemo6(() => config ? config.consumerAgentId : void 0, [config]);
|
|
2030
2090
|
const normalizationCacheRef = useRef6({
|
|
2031
2091
|
serialized: null,
|
|
@@ -2075,7 +2135,7 @@ function useConfigureSuggestions(config, options) {
|
|
|
2075
2135
|
return consumer;
|
|
2076
2136
|
}, [normalizedConfig, resolvedConsumerAgentId]);
|
|
2077
2137
|
const isGlobalConfig = rawConsumerAgentId === void 0 || rawConsumerAgentId === "*";
|
|
2078
|
-
const requestReload =
|
|
2138
|
+
const requestReload = useCallback6(() => {
|
|
2079
2139
|
if (!normalizedConfig) {
|
|
2080
2140
|
return;
|
|
2081
2141
|
}
|
|
@@ -2139,7 +2199,7 @@ function normalizeStaticSuggestions(suggestions) {
|
|
|
2139
2199
|
|
|
2140
2200
|
// src/components/chat/CopilotChatToolCallsView.tsx
|
|
2141
2201
|
import React8 from "react";
|
|
2142
|
-
import { Fragment as Fragment2, jsx as
|
|
2202
|
+
import { Fragment as Fragment2, jsx as jsx12 } from "react/jsx-runtime";
|
|
2143
2203
|
function CopilotChatToolCallsView({
|
|
2144
2204
|
message,
|
|
2145
2205
|
messages = []
|
|
@@ -2148,11 +2208,11 @@ function CopilotChatToolCallsView({
|
|
|
2148
2208
|
if (!message.toolCalls || message.toolCalls.length === 0) {
|
|
2149
2209
|
return null;
|
|
2150
2210
|
}
|
|
2151
|
-
return /* @__PURE__ */
|
|
2211
|
+
return /* @__PURE__ */ jsx12(Fragment2, { children: message.toolCalls.map((toolCall) => {
|
|
2152
2212
|
const toolMessage = messages.find(
|
|
2153
2213
|
(m) => m.role === "tool" && m.toolCallId === toolCall.id
|
|
2154
2214
|
);
|
|
2155
|
-
return /* @__PURE__ */
|
|
2215
|
+
return /* @__PURE__ */ jsx12(React8.Fragment, { children: renderToolCall({
|
|
2156
2216
|
toolCall,
|
|
2157
2217
|
toolMessage
|
|
2158
2218
|
}) }, toolCall.id);
|
|
@@ -2161,7 +2221,7 @@ function CopilotChatToolCallsView({
|
|
|
2161
2221
|
var CopilotChatToolCallsView_default = CopilotChatToolCallsView;
|
|
2162
2222
|
|
|
2163
2223
|
// src/components/chat/CopilotChatAssistantMessage.tsx
|
|
2164
|
-
import { Fragment as Fragment3, jsx as
|
|
2224
|
+
import { Fragment as Fragment3, jsx as jsx13, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
2165
2225
|
function CopilotChatAssistantMessage({
|
|
2166
2226
|
message,
|
|
2167
2227
|
messages,
|
|
@@ -2260,7 +2320,7 @@ function CopilotChatAssistantMessage({
|
|
|
2260
2320
|
const isLatestAssistantMessage = message.role === "assistant" && messages?.[messages.length - 1]?.id === message.id;
|
|
2261
2321
|
const shouldShowToolbar = toolbarVisible && hasContent && !(isRunning && isLatestAssistantMessage);
|
|
2262
2322
|
if (children) {
|
|
2263
|
-
return /* @__PURE__ */
|
|
2323
|
+
return /* @__PURE__ */ jsx13(Fragment3, { children: children({
|
|
2264
2324
|
markdownRenderer: boundMarkdownRenderer,
|
|
2265
2325
|
toolbar: boundToolbar,
|
|
2266
2326
|
toolCallsView: boundToolCallsView,
|
|
@@ -2298,11 +2358,11 @@ function CopilotChatAssistantMessage({
|
|
|
2298
2358
|
);
|
|
2299
2359
|
}
|
|
2300
2360
|
((CopilotChatAssistantMessage2) => {
|
|
2301
|
-
CopilotChatAssistantMessage2.MarkdownRenderer = ({ content, className, ...props }) => /* @__PURE__ */
|
|
2361
|
+
CopilotChatAssistantMessage2.MarkdownRenderer = ({ content, className, ...props }) => /* @__PURE__ */ jsx13(Streamdown, { className, ...props, children: content ?? "" });
|
|
2302
2362
|
CopilotChatAssistantMessage2.Toolbar = ({
|
|
2303
2363
|
className,
|
|
2304
2364
|
...props
|
|
2305
|
-
}) => /* @__PURE__ */
|
|
2365
|
+
}) => /* @__PURE__ */ jsx13(
|
|
2306
2366
|
"div",
|
|
2307
2367
|
{
|
|
2308
2368
|
className: twMerge4(
|
|
@@ -2314,7 +2374,7 @@ function CopilotChatAssistantMessage({
|
|
|
2314
2374
|
);
|
|
2315
2375
|
CopilotChatAssistantMessage2.ToolbarButton = ({ title, children, ...props }) => {
|
|
2316
2376
|
return /* @__PURE__ */ jsxs5(Tooltip, { children: [
|
|
2317
|
-
/* @__PURE__ */
|
|
2377
|
+
/* @__PURE__ */ jsx13(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx13(
|
|
2318
2378
|
Button,
|
|
2319
2379
|
{
|
|
2320
2380
|
type: "button",
|
|
@@ -2324,7 +2384,7 @@ function CopilotChatAssistantMessage({
|
|
|
2324
2384
|
children
|
|
2325
2385
|
}
|
|
2326
2386
|
) }),
|
|
2327
|
-
/* @__PURE__ */
|
|
2387
|
+
/* @__PURE__ */ jsx13(TooltipContent, { side: "bottom", children: /* @__PURE__ */ jsx13("p", { children: title }) })
|
|
2328
2388
|
] });
|
|
2329
2389
|
};
|
|
2330
2390
|
CopilotChatAssistantMessage2.CopyButton = ({ className, title, onClick, ...props }) => {
|
|
@@ -2338,62 +2398,62 @@ function CopilotChatAssistantMessage({
|
|
|
2338
2398
|
onClick(event);
|
|
2339
2399
|
}
|
|
2340
2400
|
};
|
|
2341
|
-
return /* @__PURE__ */
|
|
2401
|
+
return /* @__PURE__ */ jsx13(
|
|
2342
2402
|
CopilotChatAssistantMessage2.ToolbarButton,
|
|
2343
2403
|
{
|
|
2344
2404
|
title: title || labels.assistantMessageToolbarCopyMessageLabel,
|
|
2345
2405
|
onClick: handleClick,
|
|
2346
2406
|
className,
|
|
2347
2407
|
...props,
|
|
2348
|
-
children: copied ? /* @__PURE__ */
|
|
2408
|
+
children: copied ? /* @__PURE__ */ jsx13(Check2, { className: "size-[18px]" }) : /* @__PURE__ */ jsx13(Copy, { className: "size-[18px]" })
|
|
2349
2409
|
}
|
|
2350
2410
|
);
|
|
2351
2411
|
};
|
|
2352
2412
|
CopilotChatAssistantMessage2.ThumbsUpButton = ({ title, ...props }) => {
|
|
2353
2413
|
const config = useCopilotChatConfiguration();
|
|
2354
2414
|
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
2355
|
-
return /* @__PURE__ */
|
|
2415
|
+
return /* @__PURE__ */ jsx13(
|
|
2356
2416
|
CopilotChatAssistantMessage2.ToolbarButton,
|
|
2357
2417
|
{
|
|
2358
2418
|
title: title || labels.assistantMessageToolbarThumbsUpLabel,
|
|
2359
2419
|
...props,
|
|
2360
|
-
children: /* @__PURE__ */
|
|
2420
|
+
children: /* @__PURE__ */ jsx13(ThumbsUp, { className: "size-[18px]" })
|
|
2361
2421
|
}
|
|
2362
2422
|
);
|
|
2363
2423
|
};
|
|
2364
2424
|
CopilotChatAssistantMessage2.ThumbsDownButton = ({ title, ...props }) => {
|
|
2365
2425
|
const config = useCopilotChatConfiguration();
|
|
2366
2426
|
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
2367
|
-
return /* @__PURE__ */
|
|
2427
|
+
return /* @__PURE__ */ jsx13(
|
|
2368
2428
|
CopilotChatAssistantMessage2.ToolbarButton,
|
|
2369
2429
|
{
|
|
2370
2430
|
title: title || labels.assistantMessageToolbarThumbsDownLabel,
|
|
2371
2431
|
...props,
|
|
2372
|
-
children: /* @__PURE__ */
|
|
2432
|
+
children: /* @__PURE__ */ jsx13(ThumbsDown, { className: "size-[18px]" })
|
|
2373
2433
|
}
|
|
2374
2434
|
);
|
|
2375
2435
|
};
|
|
2376
2436
|
CopilotChatAssistantMessage2.ReadAloudButton = ({ title, ...props }) => {
|
|
2377
2437
|
const config = useCopilotChatConfiguration();
|
|
2378
2438
|
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
2379
|
-
return /* @__PURE__ */
|
|
2439
|
+
return /* @__PURE__ */ jsx13(
|
|
2380
2440
|
CopilotChatAssistantMessage2.ToolbarButton,
|
|
2381
2441
|
{
|
|
2382
2442
|
title: title || labels.assistantMessageToolbarReadAloudLabel,
|
|
2383
2443
|
...props,
|
|
2384
|
-
children: /* @__PURE__ */
|
|
2444
|
+
children: /* @__PURE__ */ jsx13(Volume2, { className: "size-[20px]" })
|
|
2385
2445
|
}
|
|
2386
2446
|
);
|
|
2387
2447
|
};
|
|
2388
2448
|
CopilotChatAssistantMessage2.RegenerateButton = ({ title, ...props }) => {
|
|
2389
2449
|
const config = useCopilotChatConfiguration();
|
|
2390
2450
|
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
2391
|
-
return /* @__PURE__ */
|
|
2451
|
+
return /* @__PURE__ */ jsx13(
|
|
2392
2452
|
CopilotChatAssistantMessage2.ToolbarButton,
|
|
2393
2453
|
{
|
|
2394
2454
|
title: title || labels.assistantMessageToolbarRegenerateLabel,
|
|
2395
2455
|
...props,
|
|
2396
|
-
children: /* @__PURE__ */
|
|
2456
|
+
children: /* @__PURE__ */ jsx13(RefreshCw, { className: "size-[18px]" })
|
|
2397
2457
|
}
|
|
2398
2458
|
);
|
|
2399
2459
|
};
|
|
@@ -2408,10 +2468,24 @@ CopilotChatAssistantMessage.RegenerateButton.displayName = "CopilotChatAssistant
|
|
|
2408
2468
|
var CopilotChatAssistantMessage_default = CopilotChatAssistantMessage;
|
|
2409
2469
|
|
|
2410
2470
|
// src/components/chat/CopilotChatUserMessage.tsx
|
|
2411
|
-
import { useState as useState8 } from "react";
|
|
2471
|
+
import { useMemo as useMemo7, useState as useState8 } from "react";
|
|
2412
2472
|
import { Copy as Copy2, Check as Check3, Edit, ChevronLeft, ChevronRight } from "lucide-react";
|
|
2413
2473
|
import { twMerge as twMerge5 } from "tailwind-merge";
|
|
2414
|
-
import { Fragment as Fragment4, jsx as
|
|
2474
|
+
import { Fragment as Fragment4, jsx as jsx14, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
2475
|
+
function flattenUserMessageContent(content) {
|
|
2476
|
+
if (!content) {
|
|
2477
|
+
return "";
|
|
2478
|
+
}
|
|
2479
|
+
if (typeof content === "string") {
|
|
2480
|
+
return content;
|
|
2481
|
+
}
|
|
2482
|
+
return content.map((part) => {
|
|
2483
|
+
if (part && typeof part === "object" && "type" in part && part.type === "text" && typeof part.text === "string") {
|
|
2484
|
+
return part.text;
|
|
2485
|
+
}
|
|
2486
|
+
return "";
|
|
2487
|
+
}).filter((text) => text.length > 0).join("\n");
|
|
2488
|
+
}
|
|
2415
2489
|
function CopilotChatUserMessage({
|
|
2416
2490
|
message,
|
|
2417
2491
|
onEditMessage,
|
|
@@ -2428,11 +2502,15 @@ function CopilotChatUserMessage({
|
|
|
2428
2502
|
className,
|
|
2429
2503
|
...props
|
|
2430
2504
|
}) {
|
|
2505
|
+
const flattenedContent = useMemo7(
|
|
2506
|
+
() => flattenUserMessageContent(message.content),
|
|
2507
|
+
[message.content]
|
|
2508
|
+
);
|
|
2431
2509
|
const BoundMessageRenderer = renderSlot(
|
|
2432
2510
|
messageRenderer,
|
|
2433
2511
|
CopilotChatUserMessage.MessageRenderer,
|
|
2434
2512
|
{
|
|
2435
|
-
content:
|
|
2513
|
+
content: flattenedContent
|
|
2436
2514
|
}
|
|
2437
2515
|
);
|
|
2438
2516
|
const BoundCopyButton = renderSlot(
|
|
@@ -2440,9 +2518,9 @@ function CopilotChatUserMessage({
|
|
|
2440
2518
|
CopilotChatUserMessage.CopyButton,
|
|
2441
2519
|
{
|
|
2442
2520
|
onClick: async () => {
|
|
2443
|
-
if (
|
|
2521
|
+
if (flattenedContent) {
|
|
2444
2522
|
try {
|
|
2445
|
-
await navigator.clipboard.writeText(
|
|
2523
|
+
await navigator.clipboard.writeText(flattenedContent);
|
|
2446
2524
|
} catch (err) {
|
|
2447
2525
|
console.error("Failed to copy message:", err);
|
|
2448
2526
|
}
|
|
@@ -2477,7 +2555,7 @@ function CopilotChatUserMessage({
|
|
|
2477
2555
|
] })
|
|
2478
2556
|
});
|
|
2479
2557
|
if (children) {
|
|
2480
|
-
return /* @__PURE__ */
|
|
2558
|
+
return /* @__PURE__ */ jsx14(Fragment4, { children: children({
|
|
2481
2559
|
messageRenderer: BoundMessageRenderer,
|
|
2482
2560
|
toolbar: BoundToolbar,
|
|
2483
2561
|
copyButton: BoundCopyButton,
|
|
@@ -2503,7 +2581,7 @@ function CopilotChatUserMessage({
|
|
|
2503
2581
|
);
|
|
2504
2582
|
}
|
|
2505
2583
|
((CopilotChatUserMessage2) => {
|
|
2506
|
-
CopilotChatUserMessage2.Container = ({ children, className, ...props }) => /* @__PURE__ */
|
|
2584
|
+
CopilotChatUserMessage2.Container = ({ children, className, ...props }) => /* @__PURE__ */ jsx14(
|
|
2507
2585
|
"div",
|
|
2508
2586
|
{
|
|
2509
2587
|
className: twMerge5("flex flex-col items-end group", className),
|
|
@@ -2511,7 +2589,7 @@ function CopilotChatUserMessage({
|
|
|
2511
2589
|
children
|
|
2512
2590
|
}
|
|
2513
2591
|
);
|
|
2514
|
-
CopilotChatUserMessage2.MessageRenderer = ({ content, className }) => /* @__PURE__ */
|
|
2592
|
+
CopilotChatUserMessage2.MessageRenderer = ({ content, className }) => /* @__PURE__ */ jsx14(
|
|
2515
2593
|
"div",
|
|
2516
2594
|
{
|
|
2517
2595
|
className: twMerge5(
|
|
@@ -2524,7 +2602,7 @@ function CopilotChatUserMessage({
|
|
|
2524
2602
|
CopilotChatUserMessage2.Toolbar = ({
|
|
2525
2603
|
className,
|
|
2526
2604
|
...props
|
|
2527
|
-
}) => /* @__PURE__ */
|
|
2605
|
+
}) => /* @__PURE__ */ jsx14(
|
|
2528
2606
|
"div",
|
|
2529
2607
|
{
|
|
2530
2608
|
className: twMerge5(
|
|
@@ -2536,7 +2614,7 @@ function CopilotChatUserMessage({
|
|
|
2536
2614
|
);
|
|
2537
2615
|
CopilotChatUserMessage2.ToolbarButton = ({ title, children, className, ...props }) => {
|
|
2538
2616
|
return /* @__PURE__ */ jsxs6(Tooltip, { children: [
|
|
2539
|
-
/* @__PURE__ */
|
|
2617
|
+
/* @__PURE__ */ jsx14(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx14(
|
|
2540
2618
|
Button,
|
|
2541
2619
|
{
|
|
2542
2620
|
type: "button",
|
|
@@ -2547,7 +2625,7 @@ function CopilotChatUserMessage({
|
|
|
2547
2625
|
children
|
|
2548
2626
|
}
|
|
2549
2627
|
) }),
|
|
2550
|
-
/* @__PURE__ */
|
|
2628
|
+
/* @__PURE__ */ jsx14(TooltipContent, { side: "bottom", children: /* @__PURE__ */ jsx14("p", { children: title }) })
|
|
2551
2629
|
] });
|
|
2552
2630
|
};
|
|
2553
2631
|
CopilotChatUserMessage2.CopyButton = ({ className, title, onClick, ...props }) => {
|
|
@@ -2561,27 +2639,27 @@ function CopilotChatUserMessage({
|
|
|
2561
2639
|
onClick(event);
|
|
2562
2640
|
}
|
|
2563
2641
|
};
|
|
2564
|
-
return /* @__PURE__ */
|
|
2642
|
+
return /* @__PURE__ */ jsx14(
|
|
2565
2643
|
CopilotChatUserMessage2.ToolbarButton,
|
|
2566
2644
|
{
|
|
2567
2645
|
title: title || labels.userMessageToolbarCopyMessageLabel,
|
|
2568
2646
|
onClick: handleClick,
|
|
2569
2647
|
className,
|
|
2570
2648
|
...props,
|
|
2571
|
-
children: copied ? /* @__PURE__ */
|
|
2649
|
+
children: copied ? /* @__PURE__ */ jsx14(Check3, { className: "size-[18px]" }) : /* @__PURE__ */ jsx14(Copy2, { className: "size-[18px]" })
|
|
2572
2650
|
}
|
|
2573
2651
|
);
|
|
2574
2652
|
};
|
|
2575
2653
|
CopilotChatUserMessage2.EditButton = ({ className, title, ...props }) => {
|
|
2576
2654
|
const config = useCopilotChatConfiguration();
|
|
2577
2655
|
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
2578
|
-
return /* @__PURE__ */
|
|
2656
|
+
return /* @__PURE__ */ jsx14(
|
|
2579
2657
|
CopilotChatUserMessage2.ToolbarButton,
|
|
2580
2658
|
{
|
|
2581
2659
|
title: title || labels.userMessageToolbarEditMessageLabel,
|
|
2582
2660
|
className,
|
|
2583
2661
|
...props,
|
|
2584
|
-
children: /* @__PURE__ */
|
|
2662
|
+
children: /* @__PURE__ */ jsx14(Edit, { className: "size-[18px]" })
|
|
2585
2663
|
}
|
|
2586
2664
|
);
|
|
2587
2665
|
};
|
|
@@ -2599,7 +2677,7 @@ function CopilotChatUserMessage({
|
|
|
2599
2677
|
const canGoPrev = currentBranch > 0;
|
|
2600
2678
|
const canGoNext = currentBranch < numberOfBranches - 1;
|
|
2601
2679
|
return /* @__PURE__ */ jsxs6("div", { className: twMerge5("flex items-center gap-1", className), ...props, children: [
|
|
2602
|
-
/* @__PURE__ */
|
|
2680
|
+
/* @__PURE__ */ jsx14(
|
|
2603
2681
|
Button,
|
|
2604
2682
|
{
|
|
2605
2683
|
type: "button",
|
|
@@ -2611,7 +2689,7 @@ function CopilotChatUserMessage({
|
|
|
2611
2689
|
}),
|
|
2612
2690
|
disabled: !canGoPrev,
|
|
2613
2691
|
className: "h-6 w-6 p-0",
|
|
2614
|
-
children: /* @__PURE__ */
|
|
2692
|
+
children: /* @__PURE__ */ jsx14(ChevronLeft, { className: "size-[20px]" })
|
|
2615
2693
|
}
|
|
2616
2694
|
),
|
|
2617
2695
|
/* @__PURE__ */ jsxs6("span", { className: "text-sm text-muted-foreground px-0 font-medium", children: [
|
|
@@ -2619,7 +2697,7 @@ function CopilotChatUserMessage({
|
|
|
2619
2697
|
"/",
|
|
2620
2698
|
numberOfBranches
|
|
2621
2699
|
] }),
|
|
2622
|
-
/* @__PURE__ */
|
|
2700
|
+
/* @__PURE__ */ jsx14(
|
|
2623
2701
|
Button,
|
|
2624
2702
|
{
|
|
2625
2703
|
type: "button",
|
|
@@ -2631,7 +2709,7 @@ function CopilotChatUserMessage({
|
|
|
2631
2709
|
}),
|
|
2632
2710
|
disabled: !canGoNext,
|
|
2633
2711
|
className: "h-6 w-6 p-0",
|
|
2634
|
-
children: /* @__PURE__ */
|
|
2712
|
+
children: /* @__PURE__ */ jsx14(ChevronRight, { className: "size-[20px]" })
|
|
2635
2713
|
}
|
|
2636
2714
|
)
|
|
2637
2715
|
] });
|
|
@@ -2649,7 +2727,7 @@ var CopilotChatUserMessage_default = CopilotChatUserMessage;
|
|
|
2649
2727
|
// src/components/chat/CopilotChatSuggestionPill.tsx
|
|
2650
2728
|
import React9 from "react";
|
|
2651
2729
|
import { Loader2 } from "lucide-react";
|
|
2652
|
-
import { jsx as
|
|
2730
|
+
import { jsx as jsx15, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
2653
2731
|
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
2732
|
var labelClasses = "whitespace-nowrap font-medium leading-none";
|
|
2655
2733
|
var CopilotChatSuggestionPill = React9.forwardRef(function CopilotChatSuggestionPill2({ className, children, icon, isLoading, type, ...props }, ref) {
|
|
@@ -2665,8 +2743,8 @@ var CopilotChatSuggestionPill = React9.forwardRef(function CopilotChatSuggestion
|
|
|
2665
2743
|
disabled: isLoading || props.disabled,
|
|
2666
2744
|
...props,
|
|
2667
2745
|
children: [
|
|
2668
|
-
isLoading ? /* @__PURE__ */
|
|
2669
|
-
/* @__PURE__ */
|
|
2746
|
+
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 }),
|
|
2747
|
+
/* @__PURE__ */ jsx15("span", { className: labelClasses, children })
|
|
2670
2748
|
]
|
|
2671
2749
|
}
|
|
2672
2750
|
);
|
|
@@ -2676,9 +2754,9 @@ var CopilotChatSuggestionPill_default = CopilotChatSuggestionPill;
|
|
|
2676
2754
|
|
|
2677
2755
|
// src/components/chat/CopilotChatSuggestionView.tsx
|
|
2678
2756
|
import React10 from "react";
|
|
2679
|
-
import { Fragment as Fragment5, jsx as
|
|
2757
|
+
import { Fragment as Fragment5, jsx as jsx16, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
2680
2758
|
var DefaultContainer = React10.forwardRef(function DefaultContainer2({ className, ...props }, ref) {
|
|
2681
|
-
return /* @__PURE__ */
|
|
2759
|
+
return /* @__PURE__ */ jsx16(
|
|
2682
2760
|
"div",
|
|
2683
2761
|
{
|
|
2684
2762
|
ref,
|
|
@@ -2734,7 +2812,7 @@ var CopilotChatSuggestionView = React10.forwardRef(function CopilotChatSuggestio
|
|
|
2734
2812
|
isLoading: suggestions.length > 0 ? loadingSet.has(0) || suggestions[0]?.isLoading === true : false,
|
|
2735
2813
|
type: "button"
|
|
2736
2814
|
});
|
|
2737
|
-
return /* @__PURE__ */
|
|
2815
|
+
return /* @__PURE__ */ jsx16(Fragment5, { children: children({
|
|
2738
2816
|
container: boundContainer,
|
|
2739
2817
|
suggestion: sampleSuggestion,
|
|
2740
2818
|
suggestions,
|
|
@@ -2757,7 +2835,7 @@ var CopilotChatSuggestionView_default = CopilotChatSuggestionView;
|
|
|
2757
2835
|
|
|
2758
2836
|
// src/components/chat/CopilotChatMessageView.tsx
|
|
2759
2837
|
import { twMerge as twMerge6 } from "tailwind-merge";
|
|
2760
|
-
import { jsx as
|
|
2838
|
+
import { jsx as jsx17, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
2761
2839
|
function CopilotChatMessageView({
|
|
2762
2840
|
messages = [],
|
|
2763
2841
|
assistantMessage,
|
|
@@ -2769,6 +2847,7 @@ function CopilotChatMessageView({
|
|
|
2769
2847
|
...props
|
|
2770
2848
|
}) {
|
|
2771
2849
|
const renderCustomMessage = useRenderCustomMessages();
|
|
2850
|
+
const renderActivityMessage = useRenderActivityMessage();
|
|
2772
2851
|
const messageElements = messages.flatMap((message) => {
|
|
2773
2852
|
const elements = [];
|
|
2774
2853
|
if (renderCustomMessage) {
|
|
@@ -2795,6 +2874,11 @@ function CopilotChatMessageView({
|
|
|
2795
2874
|
message
|
|
2796
2875
|
})
|
|
2797
2876
|
);
|
|
2877
|
+
} else if (message.role === "activity") {
|
|
2878
|
+
const renderedActivity = renderActivityMessage(message);
|
|
2879
|
+
if (renderedActivity) {
|
|
2880
|
+
elements.push(renderedActivity);
|
|
2881
|
+
}
|
|
2798
2882
|
}
|
|
2799
2883
|
if (renderCustomMessage) {
|
|
2800
2884
|
elements.push(
|
|
@@ -2815,7 +2899,7 @@ function CopilotChatMessageView({
|
|
|
2815
2899
|
] });
|
|
2816
2900
|
}
|
|
2817
2901
|
CopilotChatMessageView.Cursor = function Cursor({ className, ...props }) {
|
|
2818
|
-
return /* @__PURE__ */
|
|
2902
|
+
return /* @__PURE__ */ jsx17(
|
|
2819
2903
|
"div",
|
|
2820
2904
|
{
|
|
2821
2905
|
className: twMerge6("w-[11px] h-[11px] rounded-full bg-foreground animate-pulse-cursor ml-1", className),
|
|
@@ -2872,7 +2956,7 @@ function useKeyboardHeight() {
|
|
|
2872
2956
|
}
|
|
2873
2957
|
|
|
2874
2958
|
// src/components/chat/CopilotChatView.tsx
|
|
2875
|
-
import { Fragment as Fragment6, jsx as
|
|
2959
|
+
import { Fragment as Fragment6, jsx as jsx18, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
2876
2960
|
function CopilotChatView({
|
|
2877
2961
|
messageView,
|
|
2878
2962
|
input,
|
|
@@ -2950,9 +3034,9 @@ function CopilotChatView({
|
|
|
2950
3034
|
scrollToBottomButton,
|
|
2951
3035
|
inputContainerHeight,
|
|
2952
3036
|
isResizing,
|
|
2953
|
-
children: /* @__PURE__ */
|
|
3037
|
+
children: /* @__PURE__ */ jsx18("div", { style: { paddingBottom: `${inputContainerHeight + (hasSuggestions ? 4 : 32)}px` }, children: /* @__PURE__ */ jsxs10("div", { className: "max-w-3xl mx-auto", children: [
|
|
2954
3038
|
BoundMessageView,
|
|
2955
|
-
hasSuggestions ? /* @__PURE__ */
|
|
3039
|
+
hasSuggestions ? /* @__PURE__ */ jsx18("div", { className: "pl-0 pr-4 sm:px-0 mt-4", children: BoundSuggestionView }) : null
|
|
2956
3040
|
] }) })
|
|
2957
3041
|
});
|
|
2958
3042
|
const BoundScrollToBottomButton = renderSlot(scrollToBottomButton, CopilotChatView.ScrollToBottomButton, {});
|
|
@@ -2961,7 +3045,7 @@ function CopilotChatView({
|
|
|
2961
3045
|
ref: inputContainerRef,
|
|
2962
3046
|
keyboardHeight: isKeyboardOpen ? keyboardHeight : 0,
|
|
2963
3047
|
children: /* @__PURE__ */ jsxs10(Fragment6, { children: [
|
|
2964
|
-
/* @__PURE__ */
|
|
3048
|
+
/* @__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
3049
|
BoundDisclaimer
|
|
2966
3050
|
] })
|
|
2967
3051
|
});
|
|
@@ -2974,7 +3058,7 @@ function CopilotChatView({
|
|
|
2974
3058
|
feather: BoundFeather,
|
|
2975
3059
|
inputContainer: BoundInputContainer,
|
|
2976
3060
|
disclaimer: BoundDisclaimer,
|
|
2977
|
-
suggestionView: BoundSuggestionView ?? /* @__PURE__ */
|
|
3061
|
+
suggestionView: BoundSuggestionView ?? /* @__PURE__ */ jsx18(Fragment6, {})
|
|
2978
3062
|
});
|
|
2979
3063
|
}
|
|
2980
3064
|
return /* @__PURE__ */ jsxs10("div", { className: twMerge7("relative h-full", className), ...props, children: [
|
|
@@ -2987,8 +3071,8 @@ function CopilotChatView({
|
|
|
2987
3071
|
const ScrollContent = ({ children, scrollToBottomButton, inputContainerHeight, isResizing }) => {
|
|
2988
3072
|
const { isAtBottom, scrollToBottom } = useStickToBottomContext();
|
|
2989
3073
|
return /* @__PURE__ */ jsxs10(Fragment6, { children: [
|
|
2990
|
-
/* @__PURE__ */
|
|
2991
|
-
!isAtBottom && !isResizing && /* @__PURE__ */
|
|
3074
|
+
/* @__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 }) }),
|
|
3075
|
+
!isAtBottom && !isResizing && /* @__PURE__ */ jsx18(
|
|
2992
3076
|
"div",
|
|
2993
3077
|
{
|
|
2994
3078
|
className: "absolute inset-x-0 flex justify-center z-10 pointer-events-none",
|
|
@@ -3035,7 +3119,7 @@ function CopilotChatView({
|
|
|
3035
3119
|
};
|
|
3036
3120
|
}, [scrollRef, autoScroll]);
|
|
3037
3121
|
if (!hasMounted) {
|
|
3038
|
-
return /* @__PURE__ */
|
|
3122
|
+
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
3123
|
}
|
|
3040
3124
|
if (!autoScroll) {
|
|
3041
3125
|
return /* @__PURE__ */ jsxs10(
|
|
@@ -3048,8 +3132,8 @@ function CopilotChatView({
|
|
|
3048
3132
|
),
|
|
3049
3133
|
...props,
|
|
3050
3134
|
children: [
|
|
3051
|
-
/* @__PURE__ */
|
|
3052
|
-
showScrollButton && !isResizing && /* @__PURE__ */
|
|
3135
|
+
/* @__PURE__ */ jsx18("div", { ref: contentRef, className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6", children }),
|
|
3136
|
+
showScrollButton && !isResizing && /* @__PURE__ */ jsx18(
|
|
3053
3137
|
"div",
|
|
3054
3138
|
{
|
|
3055
3139
|
className: "absolute inset-x-0 flex justify-center z-10 pointer-events-none",
|
|
@@ -3065,14 +3149,14 @@ function CopilotChatView({
|
|
|
3065
3149
|
}
|
|
3066
3150
|
);
|
|
3067
3151
|
}
|
|
3068
|
-
return /* @__PURE__ */
|
|
3152
|
+
return /* @__PURE__ */ jsx18(
|
|
3069
3153
|
StickToBottom,
|
|
3070
3154
|
{
|
|
3071
3155
|
className: cn("h-full max-h-full flex flex-col min-h-0 relative", className),
|
|
3072
3156
|
resize: "smooth",
|
|
3073
3157
|
initial: "smooth",
|
|
3074
3158
|
...props,
|
|
3075
|
-
children: /* @__PURE__ */
|
|
3159
|
+
children: /* @__PURE__ */ jsx18(
|
|
3076
3160
|
ScrollContent,
|
|
3077
3161
|
{
|
|
3078
3162
|
scrollToBottomButton,
|
|
@@ -3087,7 +3171,7 @@ function CopilotChatView({
|
|
|
3087
3171
|
CopilotChatView2.ScrollToBottomButton = ({
|
|
3088
3172
|
className,
|
|
3089
3173
|
...props
|
|
3090
|
-
}) => /* @__PURE__ */
|
|
3174
|
+
}) => /* @__PURE__ */ jsx18(
|
|
3091
3175
|
Button,
|
|
3092
3176
|
{
|
|
3093
3177
|
variant: "outline",
|
|
@@ -3101,10 +3185,10 @@ function CopilotChatView({
|
|
|
3101
3185
|
className
|
|
3102
3186
|
),
|
|
3103
3187
|
...props,
|
|
3104
|
-
children: /* @__PURE__ */
|
|
3188
|
+
children: /* @__PURE__ */ jsx18(ChevronDown, { className: "w-4 h-4 text-gray-600 dark:text-white" })
|
|
3105
3189
|
}
|
|
3106
3190
|
);
|
|
3107
|
-
CopilotChatView2.Feather = ({ className, style, ...props }) => /* @__PURE__ */
|
|
3191
|
+
CopilotChatView2.Feather = ({ className, style, ...props }) => /* @__PURE__ */ jsx18(
|
|
3108
3192
|
"div",
|
|
3109
3193
|
{
|
|
3110
3194
|
className: cn(
|
|
@@ -3117,7 +3201,7 @@ function CopilotChatView({
|
|
|
3117
3201
|
...props
|
|
3118
3202
|
}
|
|
3119
3203
|
);
|
|
3120
|
-
CopilotChatView2.InputContainer = React11.forwardRef(({ children, className, keyboardHeight = 0, ...props }, ref) => /* @__PURE__ */
|
|
3204
|
+
CopilotChatView2.InputContainer = React11.forwardRef(({ children, className, keyboardHeight = 0, ...props }, ref) => /* @__PURE__ */ jsx18(
|
|
3121
3205
|
"div",
|
|
3122
3206
|
{
|
|
3123
3207
|
ref,
|
|
@@ -3135,7 +3219,7 @@ function CopilotChatView({
|
|
|
3135
3219
|
CopilotChatView2.Disclaimer = ({ className, ...props }) => {
|
|
3136
3220
|
const config = useCopilotChatConfiguration();
|
|
3137
3221
|
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
3138
|
-
return /* @__PURE__ */
|
|
3222
|
+
return /* @__PURE__ */ jsx18(
|
|
3139
3223
|
"div",
|
|
3140
3224
|
{
|
|
3141
3225
|
className: cn("text-center text-xs text-muted-foreground py-3 px-4 max-w-3xl mx-auto", className),
|
|
@@ -3148,15 +3232,15 @@ function CopilotChatView({
|
|
|
3148
3232
|
var CopilotChatView_default = CopilotChatView;
|
|
3149
3233
|
|
|
3150
3234
|
// src/components/chat/CopilotChat.tsx
|
|
3151
|
-
import { DEFAULT_AGENT_ID as
|
|
3152
|
-
import { useCallback as
|
|
3235
|
+
import { DEFAULT_AGENT_ID as DEFAULT_AGENT_ID7, randomUUID as randomUUID2 } from "@copilotkitnext/shared";
|
|
3236
|
+
import { useCallback as useCallback7, useEffect as useEffect14, useMemo as useMemo8 } from "react";
|
|
3153
3237
|
import { merge } from "ts-deepmerge";
|
|
3154
3238
|
import { AGUIConnectNotImplementedError } from "@ag-ui/client";
|
|
3155
|
-
import { jsx as
|
|
3239
|
+
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
3156
3240
|
function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen, ...props }) {
|
|
3157
3241
|
const existingConfig = useCopilotChatConfiguration();
|
|
3158
|
-
const resolvedAgentId = agentId ?? existingConfig?.agentId ??
|
|
3159
|
-
const resolvedThreadId =
|
|
3242
|
+
const resolvedAgentId = agentId ?? existingConfig?.agentId ?? DEFAULT_AGENT_ID7;
|
|
3243
|
+
const resolvedThreadId = useMemo8(
|
|
3160
3244
|
() => threadId ?? existingConfig?.threadId ?? randomUUID2(),
|
|
3161
3245
|
[threadId, existingConfig?.threadId]
|
|
3162
3246
|
);
|
|
@@ -3187,7 +3271,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
3187
3271
|
return () => {
|
|
3188
3272
|
};
|
|
3189
3273
|
}, [resolvedThreadId, agent, copilotkit, resolvedAgentId]);
|
|
3190
|
-
const onSubmitInput =
|
|
3274
|
+
const onSubmitInput = useCallback7(
|
|
3191
3275
|
async (value) => {
|
|
3192
3276
|
agent?.addMessage({
|
|
3193
3277
|
id: randomUUID2(),
|
|
@@ -3204,7 +3288,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
3204
3288
|
},
|
|
3205
3289
|
[agent, copilotkit]
|
|
3206
3290
|
);
|
|
3207
|
-
const handleSelectSuggestion =
|
|
3291
|
+
const handleSelectSuggestion = useCallback7(
|
|
3208
3292
|
async (suggestion) => {
|
|
3209
3293
|
if (!agent) {
|
|
3210
3294
|
return;
|
|
@@ -3222,7 +3306,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
3222
3306
|
},
|
|
3223
3307
|
[agent, copilotkit]
|
|
3224
3308
|
);
|
|
3225
|
-
const stopCurrentRun =
|
|
3309
|
+
const stopCurrentRun = useCallback7(() => {
|
|
3226
3310
|
if (!agent) {
|
|
3227
3311
|
return;
|
|
3228
3312
|
}
|
|
@@ -3265,7 +3349,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
3265
3349
|
inputProps: finalInputProps
|
|
3266
3350
|
});
|
|
3267
3351
|
const RenderedChatView = renderSlot(chatView, CopilotChatView, finalProps);
|
|
3268
|
-
return /* @__PURE__ */
|
|
3352
|
+
return /* @__PURE__ */ jsx19(
|
|
3269
3353
|
CopilotChatConfigurationProvider,
|
|
3270
3354
|
{
|
|
3271
3355
|
agentId: resolvedAgentId,
|
|
@@ -3283,15 +3367,15 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
3283
3367
|
// src/components/chat/CopilotChatToggleButton.tsx
|
|
3284
3368
|
import React12, { useState as useState11 } from "react";
|
|
3285
3369
|
import { MessageCircle, X as X2 } from "lucide-react";
|
|
3286
|
-
import { jsx as
|
|
3370
|
+
import { jsx as jsx20, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
3287
3371
|
var DefaultOpenIcon = ({
|
|
3288
3372
|
className,
|
|
3289
3373
|
...props
|
|
3290
|
-
}) => /* @__PURE__ */
|
|
3374
|
+
}) => /* @__PURE__ */ jsx20(MessageCircle, { className: cn("h-6 w-6", className), strokeWidth: 1.75, fill: "currentColor", ...props });
|
|
3291
3375
|
var DefaultCloseIcon = ({
|
|
3292
3376
|
className,
|
|
3293
3377
|
...props
|
|
3294
|
-
}) => /* @__PURE__ */
|
|
3378
|
+
}) => /* @__PURE__ */ jsx20(X2, { className: cn("h-6 w-6", className), strokeWidth: 1.75, ...props });
|
|
3295
3379
|
DefaultOpenIcon.displayName = "CopilotChatToggleButton.OpenIcon";
|
|
3296
3380
|
DefaultCloseIcon.displayName = "CopilotChatToggleButton.CloseIcon";
|
|
3297
3381
|
var ICON_TRANSITION_STYLE = Object.freeze({
|
|
@@ -3346,7 +3430,7 @@ var CopilotChatToggleButton = React12.forwardRef(function CopilotChatToggleButto
|
|
|
3346
3430
|
focusable: false
|
|
3347
3431
|
}
|
|
3348
3432
|
);
|
|
3349
|
-
const openIconElement = /* @__PURE__ */
|
|
3433
|
+
const openIconElement = /* @__PURE__ */ jsx20(
|
|
3350
3434
|
"span",
|
|
3351
3435
|
{
|
|
3352
3436
|
"aria-hidden": "true",
|
|
@@ -3360,7 +3444,7 @@ var CopilotChatToggleButton = React12.forwardRef(function CopilotChatToggleButto
|
|
|
3360
3444
|
children: renderedOpenIcon
|
|
3361
3445
|
}
|
|
3362
3446
|
);
|
|
3363
|
-
const closeIconElement = /* @__PURE__ */
|
|
3447
|
+
const closeIconElement = /* @__PURE__ */ jsx20(
|
|
3364
3448
|
"span",
|
|
3365
3449
|
{
|
|
3366
3450
|
"aria-hidden": "true",
|
|
@@ -3401,9 +3485,9 @@ var CopilotChatToggleButton_default = CopilotChatToggleButton;
|
|
|
3401
3485
|
import { useEffect as useEffect15, useRef as useRef8, useState as useState12 } from "react";
|
|
3402
3486
|
|
|
3403
3487
|
// src/components/chat/CopilotModalHeader.tsx
|
|
3404
|
-
import { useCallback as
|
|
3488
|
+
import { useCallback as useCallback8 } from "react";
|
|
3405
3489
|
import { X as X3 } from "lucide-react";
|
|
3406
|
-
import { jsx as
|
|
3490
|
+
import { jsx as jsx21, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
3407
3491
|
function CopilotModalHeader({
|
|
3408
3492
|
title,
|
|
3409
3493
|
titleContent,
|
|
@@ -3415,7 +3499,7 @@ function CopilotModalHeader({
|
|
|
3415
3499
|
const configuration = useCopilotChatConfiguration();
|
|
3416
3500
|
const fallbackTitle = configuration?.labels.modalHeaderTitle ?? CopilotChatDefaultLabels.modalHeaderTitle;
|
|
3417
3501
|
const resolvedTitle = title ?? fallbackTitle;
|
|
3418
|
-
const handleClose =
|
|
3502
|
+
const handleClose = useCallback8(() => {
|
|
3419
3503
|
configuration?.setModalOpen(false);
|
|
3420
3504
|
}, [configuration]);
|
|
3421
3505
|
const BoundTitle = renderSlot(titleContent, CopilotModalHeader.Title, {
|
|
@@ -3432,7 +3516,7 @@ function CopilotModalHeader({
|
|
|
3432
3516
|
...rest
|
|
3433
3517
|
});
|
|
3434
3518
|
}
|
|
3435
|
-
return /* @__PURE__ */
|
|
3519
|
+
return /* @__PURE__ */ jsx21(
|
|
3436
3520
|
"header",
|
|
3437
3521
|
{
|
|
3438
3522
|
"data-slot": "copilot-modal-header",
|
|
@@ -3443,16 +3527,16 @@ function CopilotModalHeader({
|
|
|
3443
3527
|
),
|
|
3444
3528
|
...rest,
|
|
3445
3529
|
children: /* @__PURE__ */ jsxs12("div", { className: "flex w-full items-center gap-2", children: [
|
|
3446
|
-
/* @__PURE__ */
|
|
3447
|
-
/* @__PURE__ */
|
|
3448
|
-
/* @__PURE__ */
|
|
3530
|
+
/* @__PURE__ */ jsx21("div", { className: "flex-1", "aria-hidden": "true" }),
|
|
3531
|
+
/* @__PURE__ */ jsx21("div", { className: "flex flex-1 justify-center text-center", children: BoundTitle }),
|
|
3532
|
+
/* @__PURE__ */ jsx21("div", { className: "flex flex-1 justify-end", children: BoundCloseButton })
|
|
3449
3533
|
] })
|
|
3450
3534
|
}
|
|
3451
3535
|
);
|
|
3452
3536
|
}
|
|
3453
3537
|
CopilotModalHeader.displayName = "CopilotModalHeader";
|
|
3454
3538
|
((CopilotModalHeader2) => {
|
|
3455
|
-
CopilotModalHeader2.Title = ({ children, className, ...props }) => /* @__PURE__ */
|
|
3539
|
+
CopilotModalHeader2.Title = ({ children, className, ...props }) => /* @__PURE__ */ jsx21(
|
|
3456
3540
|
"div",
|
|
3457
3541
|
{
|
|
3458
3542
|
className: cn(
|
|
@@ -3466,7 +3550,7 @@ CopilotModalHeader.displayName = "CopilotModalHeader";
|
|
|
3466
3550
|
CopilotModalHeader2.CloseButton = ({
|
|
3467
3551
|
className,
|
|
3468
3552
|
...props
|
|
3469
|
-
}) => /* @__PURE__ */
|
|
3553
|
+
}) => /* @__PURE__ */ jsx21(
|
|
3470
3554
|
"button",
|
|
3471
3555
|
{
|
|
3472
3556
|
type: "button",
|
|
@@ -3477,7 +3561,7 @@ CopilotModalHeader.displayName = "CopilotModalHeader";
|
|
|
3477
3561
|
),
|
|
3478
3562
|
"aria-label": "Close",
|
|
3479
3563
|
...props,
|
|
3480
|
-
children: /* @__PURE__ */
|
|
3564
|
+
children: /* @__PURE__ */ jsx21(X3, { className: "h-4 w-4", "aria-hidden": "true" })
|
|
3481
3565
|
}
|
|
3482
3566
|
);
|
|
3483
3567
|
})(CopilotModalHeader || (CopilotModalHeader = {}));
|
|
@@ -3485,7 +3569,7 @@ CopilotModalHeader.Title.displayName = "CopilotModalHeader.Title";
|
|
|
3485
3569
|
CopilotModalHeader.CloseButton.displayName = "CopilotModalHeader.CloseButton";
|
|
3486
3570
|
|
|
3487
3571
|
// src/components/chat/CopilotSidebarView.tsx
|
|
3488
|
-
import { Fragment as Fragment7, jsx as
|
|
3572
|
+
import { Fragment as Fragment7, jsx as jsx22, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
3489
3573
|
var DEFAULT_SIDEBAR_WIDTH = 480;
|
|
3490
3574
|
var SIDEBAR_TRANSITION_MS = 260;
|
|
3491
3575
|
function CopilotSidebarView({ header, width, ...props }) {
|
|
@@ -3530,7 +3614,7 @@ function CopilotSidebarView({ header, width, ...props }) {
|
|
|
3530
3614
|
}, [width]);
|
|
3531
3615
|
const headerElement = renderSlot(header, CopilotModalHeader, {});
|
|
3532
3616
|
return /* @__PURE__ */ jsxs13(Fragment7, { children: [
|
|
3533
|
-
isSidebarOpen && /* @__PURE__ */
|
|
3617
|
+
isSidebarOpen && /* @__PURE__ */ jsx22(
|
|
3534
3618
|
"style",
|
|
3535
3619
|
{
|
|
3536
3620
|
dangerouslySetInnerHTML: {
|
|
@@ -3544,8 +3628,8 @@ function CopilotSidebarView({ header, width, ...props }) {
|
|
|
3544
3628
|
}
|
|
3545
3629
|
}
|
|
3546
3630
|
),
|
|
3547
|
-
/* @__PURE__ */
|
|
3548
|
-
/* @__PURE__ */
|
|
3631
|
+
/* @__PURE__ */ jsx22(CopilotChatToggleButton_default, {}),
|
|
3632
|
+
/* @__PURE__ */ jsx22(
|
|
3549
3633
|
"aside",
|
|
3550
3634
|
{
|
|
3551
3635
|
ref: sidebarRef,
|
|
@@ -3572,7 +3656,7 @@ function CopilotSidebarView({ header, width, ...props }) {
|
|
|
3572
3656
|
role: "complementary",
|
|
3573
3657
|
children: /* @__PURE__ */ jsxs13("div", { className: "flex h-full w-full flex-col overflow-hidden", children: [
|
|
3574
3658
|
headerElement,
|
|
3575
|
-
/* @__PURE__ */
|
|
3659
|
+
/* @__PURE__ */ jsx22("div", { className: "flex-1 overflow-hidden", "data-sidebar-chat": true, children: /* @__PURE__ */ jsx22(CopilotChatView_default, { ...props }) })
|
|
3576
3660
|
] })
|
|
3577
3661
|
}
|
|
3578
3662
|
)
|
|
@@ -3581,8 +3665,8 @@ function CopilotSidebarView({ header, width, ...props }) {
|
|
|
3581
3665
|
CopilotSidebarView.displayName = "CopilotSidebarView";
|
|
3582
3666
|
|
|
3583
3667
|
// src/components/chat/CopilotPopupView.tsx
|
|
3584
|
-
import { useEffect as useEffect16, useMemo as
|
|
3585
|
-
import { Fragment as Fragment8, jsx as
|
|
3668
|
+
import { useEffect as useEffect16, useMemo as useMemo9, useRef as useRef9, useState as useState13 } from "react";
|
|
3669
|
+
import { Fragment as Fragment8, jsx as jsx23, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
3586
3670
|
var DEFAULT_POPUP_WIDTH = 420;
|
|
3587
3671
|
var DEFAULT_POPUP_HEIGHT = 560;
|
|
3588
3672
|
var dimensionToCss = (value, fallback) => {
|
|
@@ -3675,10 +3759,10 @@ function CopilotPopupView({
|
|
|
3675
3759
|
document.addEventListener("pointerdown", handlePointerDown);
|
|
3676
3760
|
return () => document.removeEventListener("pointerdown", handlePointerDown);
|
|
3677
3761
|
}, [isPopupOpen, clickOutsideToClose, setModalOpen]);
|
|
3678
|
-
const headerElement =
|
|
3762
|
+
const headerElement = useMemo9(() => renderSlot(header, CopilotModalHeader, {}), [header]);
|
|
3679
3763
|
const resolvedWidth = dimensionToCss(width, DEFAULT_POPUP_WIDTH);
|
|
3680
3764
|
const resolvedHeight = dimensionToCss(height, DEFAULT_POPUP_HEIGHT);
|
|
3681
|
-
const popupStyle =
|
|
3765
|
+
const popupStyle = useMemo9(
|
|
3682
3766
|
() => ({
|
|
3683
3767
|
"--copilot-popup-width": resolvedWidth,
|
|
3684
3768
|
"--copilot-popup-height": resolvedHeight,
|
|
@@ -3692,7 +3776,7 @@ function CopilotPopupView({
|
|
|
3692
3776
|
[resolvedHeight, resolvedWidth]
|
|
3693
3777
|
);
|
|
3694
3778
|
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__ */
|
|
3779
|
+
const popupContent = isRendered ? /* @__PURE__ */ jsx23(
|
|
3696
3780
|
"div",
|
|
3697
3781
|
{
|
|
3698
3782
|
className: cn(
|
|
@@ -3720,7 +3804,7 @@ function CopilotPopupView({
|
|
|
3720
3804
|
style: popupStyle,
|
|
3721
3805
|
children: [
|
|
3722
3806
|
headerElement,
|
|
3723
|
-
/* @__PURE__ */
|
|
3807
|
+
/* @__PURE__ */ jsx23("div", { className: "flex-1 overflow-hidden", "data-popup-chat": true, children: /* @__PURE__ */ jsx23(
|
|
3724
3808
|
CopilotChatView_default,
|
|
3725
3809
|
{
|
|
3726
3810
|
...restProps,
|
|
@@ -3733,20 +3817,20 @@ function CopilotPopupView({
|
|
|
3733
3817
|
}
|
|
3734
3818
|
) : null;
|
|
3735
3819
|
return /* @__PURE__ */ jsxs14(Fragment8, { children: [
|
|
3736
|
-
/* @__PURE__ */
|
|
3820
|
+
/* @__PURE__ */ jsx23(CopilotChatToggleButton_default, {}),
|
|
3737
3821
|
popupContent
|
|
3738
3822
|
] });
|
|
3739
3823
|
}
|
|
3740
3824
|
CopilotPopupView.displayName = "CopilotPopupView";
|
|
3741
3825
|
|
|
3742
3826
|
// src/components/chat/CopilotSidebar.tsx
|
|
3743
|
-
import { useMemo as
|
|
3744
|
-
import { jsx as
|
|
3827
|
+
import { useMemo as useMemo10 } from "react";
|
|
3828
|
+
import { jsx as jsx24 } from "react/jsx-runtime";
|
|
3745
3829
|
function CopilotSidebar({ header, defaultOpen, width, ...chatProps }) {
|
|
3746
|
-
const SidebarViewOverride =
|
|
3830
|
+
const SidebarViewOverride = useMemo10(() => {
|
|
3747
3831
|
const Component = (viewProps) => {
|
|
3748
3832
|
const { header: viewHeader, width: viewWidth, ...restProps } = viewProps;
|
|
3749
|
-
return /* @__PURE__ */
|
|
3833
|
+
return /* @__PURE__ */ jsx24(
|
|
3750
3834
|
CopilotSidebarView,
|
|
3751
3835
|
{
|
|
3752
3836
|
...restProps,
|
|
@@ -3757,7 +3841,7 @@ function CopilotSidebar({ header, defaultOpen, width, ...chatProps }) {
|
|
|
3757
3841
|
};
|
|
3758
3842
|
return Object.assign(Component, CopilotChatView_default);
|
|
3759
3843
|
}, [header, width]);
|
|
3760
|
-
return /* @__PURE__ */
|
|
3844
|
+
return /* @__PURE__ */ jsx24(
|
|
3761
3845
|
CopilotChat,
|
|
3762
3846
|
{
|
|
3763
3847
|
...chatProps,
|
|
@@ -3769,8 +3853,8 @@ function CopilotSidebar({ header, defaultOpen, width, ...chatProps }) {
|
|
|
3769
3853
|
CopilotSidebar.displayName = "CopilotSidebar";
|
|
3770
3854
|
|
|
3771
3855
|
// src/components/chat/CopilotPopup.tsx
|
|
3772
|
-
import { useMemo as
|
|
3773
|
-
import { jsx as
|
|
3856
|
+
import { useMemo as useMemo11 } from "react";
|
|
3857
|
+
import { jsx as jsx25 } from "react/jsx-runtime";
|
|
3774
3858
|
function CopilotPopup({
|
|
3775
3859
|
header,
|
|
3776
3860
|
defaultOpen,
|
|
@@ -3779,7 +3863,7 @@ function CopilotPopup({
|
|
|
3779
3863
|
clickOutsideToClose,
|
|
3780
3864
|
...chatProps
|
|
3781
3865
|
}) {
|
|
3782
|
-
const PopupViewOverride =
|
|
3866
|
+
const PopupViewOverride = useMemo11(() => {
|
|
3783
3867
|
const Component = (viewProps) => {
|
|
3784
3868
|
const {
|
|
3785
3869
|
header: viewHeader,
|
|
@@ -3788,7 +3872,7 @@ function CopilotPopup({
|
|
|
3788
3872
|
clickOutsideToClose: viewClickOutsideToClose,
|
|
3789
3873
|
...restProps
|
|
3790
3874
|
} = viewProps;
|
|
3791
|
-
return /* @__PURE__ */
|
|
3875
|
+
return /* @__PURE__ */ jsx25(
|
|
3792
3876
|
CopilotPopupView,
|
|
3793
3877
|
{
|
|
3794
3878
|
...restProps,
|
|
@@ -3801,7 +3885,7 @@ function CopilotPopup({
|
|
|
3801
3885
|
};
|
|
3802
3886
|
return Object.assign(Component, CopilotChatView_default);
|
|
3803
3887
|
}, [clickOutsideToClose, header, height, width]);
|
|
3804
|
-
return /* @__PURE__ */
|
|
3888
|
+
return /* @__PURE__ */ jsx25(
|
|
3805
3889
|
CopilotChat,
|
|
3806
3890
|
{
|
|
3807
3891
|
...chatProps,
|
|
@@ -3826,7 +3910,7 @@ function defineToolCallRenderer(def) {
|
|
|
3826
3910
|
|
|
3827
3911
|
// src/components/WildcardToolCallRender.tsx
|
|
3828
3912
|
import { useState as useState14 } from "react";
|
|
3829
|
-
import { jsx as
|
|
3913
|
+
import { jsx as jsx26, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
3830
3914
|
var WildcardToolCallRender = defineToolCallRenderer({
|
|
3831
3915
|
name: "*",
|
|
3832
3916
|
render: ({ args, result, name, status }) => {
|
|
@@ -3835,7 +3919,7 @@ var WildcardToolCallRender = defineToolCallRenderer({
|
|
|
3835
3919
|
const isActive = statusString === "inProgress" || statusString === "executing";
|
|
3836
3920
|
const isComplete = statusString === "complete";
|
|
3837
3921
|
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__ */
|
|
3922
|
+
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
3923
|
/* @__PURE__ */ jsxs15(
|
|
3840
3924
|
"div",
|
|
3841
3925
|
{
|
|
@@ -3843,7 +3927,7 @@ var WildcardToolCallRender = defineToolCallRenderer({
|
|
|
3843
3927
|
onClick: () => setIsExpanded(!isExpanded),
|
|
3844
3928
|
children: [
|
|
3845
3929
|
/* @__PURE__ */ jsxs15("div", { className: "flex items-center gap-2 min-w-0", children: [
|
|
3846
|
-
/* @__PURE__ */
|
|
3930
|
+
/* @__PURE__ */ jsx26(
|
|
3847
3931
|
"svg",
|
|
3848
3932
|
{
|
|
3849
3933
|
className: `h-4 w-4 text-zinc-500 dark:text-zinc-400 transition-transform ${isExpanded ? "rotate-90" : ""}`,
|
|
@@ -3851,7 +3935,7 @@ var WildcardToolCallRender = defineToolCallRenderer({
|
|
|
3851
3935
|
viewBox: "0 0 24 24",
|
|
3852
3936
|
strokeWidth: 2,
|
|
3853
3937
|
stroke: "currentColor",
|
|
3854
|
-
children: /* @__PURE__ */
|
|
3938
|
+
children: /* @__PURE__ */ jsx26(
|
|
3855
3939
|
"path",
|
|
3856
3940
|
{
|
|
3857
3941
|
strokeLinecap: "round",
|
|
@@ -3861,10 +3945,10 @@ var WildcardToolCallRender = defineToolCallRenderer({
|
|
|
3861
3945
|
)
|
|
3862
3946
|
}
|
|
3863
3947
|
),
|
|
3864
|
-
/* @__PURE__ */
|
|
3865
|
-
/* @__PURE__ */
|
|
3948
|
+
/* @__PURE__ */ jsx26("span", { className: "inline-block h-2 w-2 rounded-full bg-blue-500" }),
|
|
3949
|
+
/* @__PURE__ */ jsx26("span", { className: "truncate text-sm font-medium text-zinc-900 dark:text-zinc-100", children: name })
|
|
3866
3950
|
] }),
|
|
3867
|
-
/* @__PURE__ */
|
|
3951
|
+
/* @__PURE__ */ jsx26(
|
|
3868
3952
|
"span",
|
|
3869
3953
|
{
|
|
3870
3954
|
className: `inline-flex items-center rounded-full px-2 py-1 text-xs font-medium ${statusStyles}`,
|
|
@@ -3876,12 +3960,12 @@ var WildcardToolCallRender = defineToolCallRenderer({
|
|
|
3876
3960
|
),
|
|
3877
3961
|
isExpanded && /* @__PURE__ */ jsxs15("div", { className: "mt-3 grid gap-4", children: [
|
|
3878
3962
|
/* @__PURE__ */ jsxs15("div", { children: [
|
|
3879
|
-
/* @__PURE__ */
|
|
3880
|
-
/* @__PURE__ */
|
|
3963
|
+
/* @__PURE__ */ jsx26("div", { className: "text-xs uppercase tracking-wide text-zinc-500 dark:text-zinc-400", children: "Arguments" }),
|
|
3964
|
+
/* @__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
3965
|
] }),
|
|
3882
3966
|
result !== void 0 && /* @__PURE__ */ jsxs15("div", { children: [
|
|
3883
|
-
/* @__PURE__ */
|
|
3884
|
-
/* @__PURE__ */
|
|
3967
|
+
/* @__PURE__ */ jsx26("div", { className: "text-xs uppercase tracking-wide text-zinc-500 dark:text-zinc-400", children: "Result" }),
|
|
3968
|
+
/* @__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
3969
|
] })
|
|
3886
3970
|
] })
|
|
3887
3971
|
] }) });
|
|
@@ -3920,6 +4004,7 @@ export {
|
|
|
3920
4004
|
useCopilotKit,
|
|
3921
4005
|
useFrontendTool,
|
|
3922
4006
|
useHumanInTheLoop,
|
|
4007
|
+
useRenderActivityMessage,
|
|
3923
4008
|
useRenderCustomMessages,
|
|
3924
4009
|
useRenderToolCall,
|
|
3925
4010
|
useSuggestions
|