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