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