@meetsmore-oss/use-ai-client 1.10.0 → 1.12.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/bundled.js +4822 -4605
- package/dist/bundled.js.map +1 -1
- package/dist/index.d.ts +36 -4
- package/dist/index.js +454 -199
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// src/useAI.ts
|
|
2
|
-
import { useState as
|
|
2
|
+
import { useState as useState15, useEffect as useEffect12, useLayoutEffect, useRef as useRef14, useCallback as useCallback14, useMemo as useMemo6 } from "react";
|
|
3
3
|
|
|
4
4
|
// src/providers/useAIProvider.tsx
|
|
5
|
-
import { createContext as createContext4, useContext as useContext4, useState as
|
|
5
|
+
import { createContext as createContext4, useContext as useContext4, useState as useState14, useEffect as useEffect11, useCallback as useCallback13, useRef as useRef12 } from "react";
|
|
6
6
|
|
|
7
7
|
// src/theme/strings.ts
|
|
8
8
|
import { createContext, useContext } from "react";
|
|
@@ -97,6 +97,13 @@ var defaultStrings = {
|
|
|
97
97
|
/** Error for unknown/unexpected errors */
|
|
98
98
|
UNKNOWN_ERROR: "An unexpected error occurred. Please try again."
|
|
99
99
|
},
|
|
100
|
+
// Thinking/reasoning display
|
|
101
|
+
thinking: {
|
|
102
|
+
/** Label shown while thinking is in progress */
|
|
103
|
+
inProgress: "Thinking...",
|
|
104
|
+
/** Label shown when thinking is complete */
|
|
105
|
+
complete: "Thinking complete"
|
|
106
|
+
},
|
|
100
107
|
// Tool execution status
|
|
101
108
|
toolExecution: {
|
|
102
109
|
/** Fallback messages when no tool title is provided (one randomly selected) */
|
|
@@ -266,7 +273,7 @@ function UseAIFloatingButton({
|
|
|
266
273
|
}
|
|
267
274
|
|
|
268
275
|
// src/components/UseAIChatPanel.tsx
|
|
269
|
-
import { useState as
|
|
276
|
+
import { useState as useState6, useRef as useRef4, useEffect as useEffect4 } from "react";
|
|
270
277
|
|
|
271
278
|
// src/utils/messageContent.ts
|
|
272
279
|
function getTextFromContent(content) {
|
|
@@ -281,6 +288,7 @@ function mergeAssistantMessagesForDisplay(messages) {
|
|
|
281
288
|
const result = [];
|
|
282
289
|
let pendingTexts = [];
|
|
283
290
|
let pendingIds = [];
|
|
291
|
+
let pendingReasoningParts = [];
|
|
284
292
|
for (const msg of messages) {
|
|
285
293
|
if (msg.role === "tool") {
|
|
286
294
|
continue;
|
|
@@ -292,33 +300,45 @@ function mergeAssistantMessagesForDisplay(messages) {
|
|
|
292
300
|
if (text) {
|
|
293
301
|
pendingTexts.push(text);
|
|
294
302
|
}
|
|
303
|
+
if (msg.reasoningParts && msg.reasoningParts.length > 0) {
|
|
304
|
+
pendingReasoningParts.push(...msg.reasoningParts);
|
|
305
|
+
}
|
|
295
306
|
} else {
|
|
296
307
|
const allTexts = text ? [...pendingTexts, text] : pendingTexts;
|
|
297
308
|
const combined = allTexts.join("\n\n");
|
|
298
|
-
|
|
309
|
+
const allReasoningParts = msg.reasoningParts ? [...pendingReasoningParts, ...msg.reasoningParts] : pendingReasoningParts.length > 0 ? pendingReasoningParts : void 0;
|
|
310
|
+
result.push({
|
|
311
|
+
...msg,
|
|
312
|
+
content: combined || "",
|
|
313
|
+
...allReasoningParts && allReasoningParts.length > 0 ? { reasoningParts: allReasoningParts } : {}
|
|
314
|
+
});
|
|
299
315
|
pendingTexts = [];
|
|
300
316
|
pendingIds = [];
|
|
317
|
+
pendingReasoningParts = [];
|
|
301
318
|
}
|
|
302
319
|
} else {
|
|
303
|
-
if (pendingTexts.length > 0) {
|
|
320
|
+
if (pendingTexts.length > 0 || pendingReasoningParts.length > 0) {
|
|
304
321
|
result.push({
|
|
305
322
|
id: `merged-${pendingIds.join("-")}`,
|
|
306
323
|
role: "assistant",
|
|
307
324
|
content: pendingTexts.join("\n\n"),
|
|
308
|
-
createdAt: /* @__PURE__ */ new Date()
|
|
325
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
326
|
+
...pendingReasoningParts.length > 0 ? { reasoningParts: pendingReasoningParts } : {}
|
|
309
327
|
});
|
|
310
328
|
pendingTexts = [];
|
|
311
329
|
pendingIds = [];
|
|
330
|
+
pendingReasoningParts = [];
|
|
312
331
|
}
|
|
313
332
|
result.push(msg);
|
|
314
333
|
}
|
|
315
334
|
}
|
|
316
|
-
if (pendingTexts.length > 0) {
|
|
335
|
+
if (pendingTexts.length > 0 || pendingReasoningParts.length > 0) {
|
|
317
336
|
result.push({
|
|
318
337
|
id: `merged-${pendingIds.join("-")}`,
|
|
319
338
|
role: "assistant",
|
|
320
339
|
content: pendingTexts.join("\n\n"),
|
|
321
|
-
createdAt: /* @__PURE__ */ new Date()
|
|
340
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
341
|
+
...pendingReasoningParts.length > 0 ? { reasoningParts: pendingReasoningParts } : {}
|
|
322
342
|
});
|
|
323
343
|
}
|
|
324
344
|
return result;
|
|
@@ -1894,8 +1914,160 @@ function ToolApprovalDialog({
|
|
|
1894
1914
|
);
|
|
1895
1915
|
}
|
|
1896
1916
|
|
|
1917
|
+
// src/components/Reasoning.tsx
|
|
1918
|
+
import { useState as useState5, useCallback as useCallback4 } from "react";
|
|
1919
|
+
import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1920
|
+
function BrainIcon({ color, size = 16 }) {
|
|
1921
|
+
return /* @__PURE__ */ jsxs8(
|
|
1922
|
+
"svg",
|
|
1923
|
+
{
|
|
1924
|
+
width: size,
|
|
1925
|
+
height: size,
|
|
1926
|
+
viewBox: "0 0 24 24",
|
|
1927
|
+
fill: "none",
|
|
1928
|
+
stroke: color,
|
|
1929
|
+
strokeWidth: "2",
|
|
1930
|
+
strokeLinecap: "round",
|
|
1931
|
+
strokeLinejoin: "round",
|
|
1932
|
+
style: { flexShrink: 0 },
|
|
1933
|
+
children: [
|
|
1934
|
+
/* @__PURE__ */ jsx11("path", { d: "M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z" }),
|
|
1935
|
+
/* @__PURE__ */ jsx11("path", { d: "M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z" }),
|
|
1936
|
+
/* @__PURE__ */ jsx11("path", { d: "M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4" }),
|
|
1937
|
+
/* @__PURE__ */ jsx11("path", { d: "M17.599 6.5a3 3 0 0 0 .399-1.375" }),
|
|
1938
|
+
/* @__PURE__ */ jsx11("path", { d: "M6.003 5.125A3 3 0 0 0 6.401 6.5" }),
|
|
1939
|
+
/* @__PURE__ */ jsx11("path", { d: "M3.477 10.896a4 4 0 0 1 .585-.396" }),
|
|
1940
|
+
/* @__PURE__ */ jsx11("path", { d: "M19.938 10.5a4 4 0 0 1 .585.396" }),
|
|
1941
|
+
/* @__PURE__ */ jsx11("path", { d: "M6 18a4 4 0 0 1-1.967-.516" }),
|
|
1942
|
+
/* @__PURE__ */ jsx11("path", { d: "M19.967 17.484A4 4 0 0 1 18 18" })
|
|
1943
|
+
]
|
|
1944
|
+
}
|
|
1945
|
+
);
|
|
1946
|
+
}
|
|
1947
|
+
function ChevronIcon({ color, size = 16, rotated }) {
|
|
1948
|
+
return /* @__PURE__ */ jsx11(
|
|
1949
|
+
"svg",
|
|
1950
|
+
{
|
|
1951
|
+
width: size,
|
|
1952
|
+
height: size,
|
|
1953
|
+
viewBox: "0 0 24 24",
|
|
1954
|
+
fill: "none",
|
|
1955
|
+
stroke: color,
|
|
1956
|
+
strokeWidth: "2",
|
|
1957
|
+
strokeLinecap: "round",
|
|
1958
|
+
strokeLinejoin: "round",
|
|
1959
|
+
style: {
|
|
1960
|
+
flexShrink: 0,
|
|
1961
|
+
transition: "transform 200ms ease",
|
|
1962
|
+
transform: rotated ? "rotate(180deg)" : "rotate(0deg)"
|
|
1963
|
+
},
|
|
1964
|
+
children: /* @__PURE__ */ jsx11("path", { d: "m6 9 6 6 6-6" })
|
|
1965
|
+
}
|
|
1966
|
+
);
|
|
1967
|
+
}
|
|
1968
|
+
function Reasoning({
|
|
1969
|
+
reasoningParts,
|
|
1970
|
+
isStreaming = false,
|
|
1971
|
+
streamingText,
|
|
1972
|
+
theme,
|
|
1973
|
+
strings
|
|
1974
|
+
}) {
|
|
1975
|
+
const [isOpen, setIsOpen] = useState5(false);
|
|
1976
|
+
const toggle = useCallback4(() => setIsOpen((prev) => !prev), []);
|
|
1977
|
+
const allText = [
|
|
1978
|
+
...reasoningParts.map((p) => p.text),
|
|
1979
|
+
...isStreaming && streamingText ? [streamingText] : []
|
|
1980
|
+
].join("\n\n");
|
|
1981
|
+
const headerContent = isStreaming ? /* @__PURE__ */ jsx11(ShimmerText, { text: strings.thinking.inProgress, theme }) : /* @__PURE__ */ jsx11("span", { children: strings.thinking.complete });
|
|
1982
|
+
return /* @__PURE__ */ jsxs8("div", { "data-testid": "thinking-timeline", style: { marginBottom: "8px" }, children: [
|
|
1983
|
+
/* @__PURE__ */ jsx11("style", { children: `
|
|
1984
|
+
@keyframes use-ai-shimmer {
|
|
1985
|
+
from { background-position: 100% center; }
|
|
1986
|
+
to { background-position: 0% center; }
|
|
1987
|
+
}
|
|
1988
|
+
@keyframes use-ai-reasoning-open {
|
|
1989
|
+
from { opacity: 0; max-height: 0; }
|
|
1990
|
+
to { opacity: 1; max-height: 2000px; }
|
|
1991
|
+
}
|
|
1992
|
+
` }),
|
|
1993
|
+
/* @__PURE__ */ jsxs8(
|
|
1994
|
+
"button",
|
|
1995
|
+
{
|
|
1996
|
+
"data-testid": "thinking-toggle",
|
|
1997
|
+
onClick: toggle,
|
|
1998
|
+
style: {
|
|
1999
|
+
background: "none",
|
|
2000
|
+
border: "none",
|
|
2001
|
+
cursor: "pointer",
|
|
2002
|
+
padding: "4px 0",
|
|
2003
|
+
display: "flex",
|
|
2004
|
+
alignItems: "center",
|
|
2005
|
+
gap: "6px",
|
|
2006
|
+
color: theme.secondaryTextColor,
|
|
2007
|
+
fontSize: "14px",
|
|
2008
|
+
fontFamily: "inherit",
|
|
2009
|
+
lineHeight: "1.5"
|
|
2010
|
+
},
|
|
2011
|
+
children: [
|
|
2012
|
+
/* @__PURE__ */ jsx11(BrainIcon, { color: theme.secondaryTextColor, size: 16 }),
|
|
2013
|
+
headerContent,
|
|
2014
|
+
/* @__PURE__ */ jsx11(ChevronIcon, { color: theme.secondaryTextColor, size: 16, rotated: isOpen })
|
|
2015
|
+
]
|
|
2016
|
+
}
|
|
2017
|
+
),
|
|
2018
|
+
isOpen && allText && /* @__PURE__ */ jsx11(
|
|
2019
|
+
"div",
|
|
2020
|
+
{
|
|
2021
|
+
"data-testid": "thinking-content",
|
|
2022
|
+
style: {
|
|
2023
|
+
animation: "use-ai-reasoning-open 200ms ease-out forwards",
|
|
2024
|
+
overflow: "hidden",
|
|
2025
|
+
marginTop: "4px",
|
|
2026
|
+
paddingLeft: "4px"
|
|
2027
|
+
},
|
|
2028
|
+
children: /* @__PURE__ */ jsx11(
|
|
2029
|
+
"div",
|
|
2030
|
+
{
|
|
2031
|
+
style: {
|
|
2032
|
+
padding: "8px 12px",
|
|
2033
|
+
background: "transparent",
|
|
2034
|
+
borderLeft: `2px solid ${theme.borderColor}`,
|
|
2035
|
+
fontSize: "14px",
|
|
2036
|
+
lineHeight: "1.6",
|
|
2037
|
+
color: theme.secondaryTextColor,
|
|
2038
|
+
whiteSpace: "pre-wrap",
|
|
2039
|
+
wordWrap: "break-word"
|
|
2040
|
+
},
|
|
2041
|
+
children: allText
|
|
2042
|
+
}
|
|
2043
|
+
)
|
|
2044
|
+
}
|
|
2045
|
+
)
|
|
2046
|
+
] });
|
|
2047
|
+
}
|
|
2048
|
+
function ShimmerText({ text, theme }) {
|
|
2049
|
+
const spread = text.length * 2;
|
|
2050
|
+
return /* @__PURE__ */ jsx11(
|
|
2051
|
+
"span",
|
|
2052
|
+
{
|
|
2053
|
+
style: {
|
|
2054
|
+
display: "inline-block",
|
|
2055
|
+
backgroundSize: "250% 100%",
|
|
2056
|
+
backgroundRepeat: "no-repeat, padding-box",
|
|
2057
|
+
backgroundClip: "text",
|
|
2058
|
+
WebkitBackgroundClip: "text",
|
|
2059
|
+
color: "transparent",
|
|
2060
|
+
backgroundImage: `linear-gradient(90deg, transparent calc(50% - ${spread}px), ${theme.backgroundColor}, transparent calc(50% + ${spread}px)), linear-gradient(${theme.secondaryTextColor}, ${theme.secondaryTextColor})`,
|
|
2061
|
+
animation: "use-ai-shimmer 2s linear infinite"
|
|
2062
|
+
},
|
|
2063
|
+
children: text
|
|
2064
|
+
}
|
|
2065
|
+
);
|
|
2066
|
+
}
|
|
2067
|
+
Reasoning.displayName = "Reasoning";
|
|
2068
|
+
|
|
1897
2069
|
// src/components/UseAIChatPanel.tsx
|
|
1898
|
-
import { Fragment, jsx as
|
|
2070
|
+
import { Fragment, jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1899
2071
|
function FeedbackButton({ type, isSelected, onClick, selectedColor, unselectedColor }) {
|
|
1900
2072
|
const buttonRef = useRef4(null);
|
|
1901
2073
|
const handleClick = () => {
|
|
@@ -1911,7 +2083,7 @@ function FeedbackButton({ type, isSelected, onClick, selectedColor, unselectedCo
|
|
|
1911
2083
|
};
|
|
1912
2084
|
const thumbsUpPath = "M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3";
|
|
1913
2085
|
const thumbsDownPath = "M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17";
|
|
1914
|
-
return /* @__PURE__ */
|
|
2086
|
+
return /* @__PURE__ */ jsx12(
|
|
1915
2087
|
"button",
|
|
1916
2088
|
{
|
|
1917
2089
|
ref: buttonRef,
|
|
@@ -1944,7 +2116,7 @@ function FeedbackButton({ type, isSelected, onClick, selectedColor, unselectedCo
|
|
|
1944
2116
|
e.currentTarget.style.color = unselectedColor;
|
|
1945
2117
|
}
|
|
1946
2118
|
},
|
|
1947
|
-
children: /* @__PURE__ */
|
|
2119
|
+
children: /* @__PURE__ */ jsx12(
|
|
1948
2120
|
"svg",
|
|
1949
2121
|
{
|
|
1950
2122
|
width: "14",
|
|
@@ -1955,7 +2127,7 @@ function FeedbackButton({ type, isSelected, onClick, selectedColor, unselectedCo
|
|
|
1955
2127
|
strokeWidth: "2",
|
|
1956
2128
|
strokeLinecap: "round",
|
|
1957
2129
|
strokeLinejoin: "round",
|
|
1958
|
-
children: /* @__PURE__ */
|
|
2130
|
+
children: /* @__PURE__ */ jsx12("path", { d: type === "upvote" ? thumbsUpPath : thumbsDownPath })
|
|
1959
2131
|
}
|
|
1960
2132
|
)
|
|
1961
2133
|
}
|
|
@@ -1970,6 +2142,7 @@ function UseAIChatPanel({
|
|
|
1970
2142
|
loading,
|
|
1971
2143
|
connected,
|
|
1972
2144
|
streamingText = "",
|
|
2145
|
+
streamingReasoning = "",
|
|
1973
2146
|
currentChatId,
|
|
1974
2147
|
onNewChat,
|
|
1975
2148
|
onLoadChat,
|
|
@@ -1998,14 +2171,14 @@ function UseAIChatPanel({
|
|
|
1998
2171
|
const strings = useStrings();
|
|
1999
2172
|
const theme = useTheme();
|
|
2000
2173
|
const displayMessages = mergeAssistantMessagesForDisplay(messages);
|
|
2001
|
-
const [input, setInput] =
|
|
2174
|
+
const [input, setInput] = useState6("");
|
|
2002
2175
|
const chatHistoryDropdown = useDropdownState();
|
|
2003
2176
|
const agentDropdown = useDropdownState();
|
|
2004
|
-
const [chatHistory, setChatHistory] =
|
|
2177
|
+
const [chatHistory, setChatHistory] = useState6([]);
|
|
2005
2178
|
const messagesEndRef = useRef4(null);
|
|
2006
|
-
const [displayedSuggestions, setDisplayedSuggestions] =
|
|
2179
|
+
const [displayedSuggestions, setDisplayedSuggestions] = useState6([]);
|
|
2007
2180
|
const textareaRef = useRef4(null);
|
|
2008
|
-
const [hoveredMessageId, setHoveredMessageId] =
|
|
2181
|
+
const [hoveredMessageId, setHoveredMessageId] = useState6(null);
|
|
2009
2182
|
const {
|
|
2010
2183
|
attachments,
|
|
2011
2184
|
fileError,
|
|
@@ -2092,7 +2265,7 @@ function UseAIChatPanel({
|
|
|
2092
2265
|
chatHistoryDropdown.close();
|
|
2093
2266
|
}
|
|
2094
2267
|
};
|
|
2095
|
-
return /* @__PURE__ */
|
|
2268
|
+
return /* @__PURE__ */ jsxs9(
|
|
2096
2269
|
"div",
|
|
2097
2270
|
{
|
|
2098
2271
|
onClick: () => {
|
|
@@ -2110,7 +2283,7 @@ function UseAIChatPanel({
|
|
|
2110
2283
|
},
|
|
2111
2284
|
children: [
|
|
2112
2285
|
DropZoneOverlay,
|
|
2113
|
-
/* @__PURE__ */
|
|
2286
|
+
/* @__PURE__ */ jsxs9(
|
|
2114
2287
|
"div",
|
|
2115
2288
|
{
|
|
2116
2289
|
style: {
|
|
@@ -2123,7 +2296,7 @@ function UseAIChatPanel({
|
|
|
2123
2296
|
gap: "12px"
|
|
2124
2297
|
},
|
|
2125
2298
|
children: [
|
|
2126
|
-
/* @__PURE__ */
|
|
2299
|
+
/* @__PURE__ */ jsx12("div", { style: { flex: 1, minWidth: 0, position: "relative" }, children: onListChats ? /* @__PURE__ */ jsxs9(
|
|
2127
2300
|
"button",
|
|
2128
2301
|
{
|
|
2129
2302
|
"data-testid": "chat-history-dropdown-button",
|
|
@@ -2156,7 +2329,7 @@ function UseAIChatPanel({
|
|
|
2156
2329
|
e.currentTarget.style.background = "transparent";
|
|
2157
2330
|
},
|
|
2158
2331
|
children: [
|
|
2159
|
-
/* @__PURE__ */
|
|
2332
|
+
/* @__PURE__ */ jsx12("span", { style: {
|
|
2160
2333
|
overflow: "hidden",
|
|
2161
2334
|
textOverflow: "ellipsis",
|
|
2162
2335
|
whiteSpace: "nowrap",
|
|
@@ -2173,13 +2346,13 @@ function UseAIChatPanel({
|
|
|
2173
2346
|
}
|
|
2174
2347
|
return strings.header.newChat;
|
|
2175
2348
|
})() }),
|
|
2176
|
-
/* @__PURE__ */
|
|
2349
|
+
/* @__PURE__ */ jsx12("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", style: { flexShrink: 0 }, children: /* @__PURE__ */ jsx12("path", { d: "M3 4.5L6 7.5L9 4.5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
2177
2350
|
]
|
|
2178
2351
|
}
|
|
2179
|
-
) : /* @__PURE__ */
|
|
2180
|
-
/* @__PURE__ */
|
|
2181
|
-
availableAgents && availableAgents.length > 1 && onAgentChange && /* @__PURE__ */
|
|
2182
|
-
/* @__PURE__ */
|
|
2352
|
+
) : /* @__PURE__ */ jsx12("div", { style: { fontSize: "14px", fontWeight: "600", color: theme.textColor, padding: "6px 8px" }, children: strings.header.aiAssistant }) }),
|
|
2353
|
+
/* @__PURE__ */ jsxs9("div", { style: { display: "flex", alignItems: "center", gap: "4px" }, children: [
|
|
2354
|
+
availableAgents && availableAgents.length > 1 && onAgentChange && /* @__PURE__ */ jsxs9("div", { style: { position: "relative" }, children: [
|
|
2355
|
+
/* @__PURE__ */ jsxs9(
|
|
2183
2356
|
"button",
|
|
2184
2357
|
{
|
|
2185
2358
|
"data-testid": "agent-selector",
|
|
@@ -2208,7 +2381,7 @@ function UseAIChatPanel({
|
|
|
2208
2381
|
},
|
|
2209
2382
|
title: "Select AI model",
|
|
2210
2383
|
children: [
|
|
2211
|
-
/* @__PURE__ */
|
|
2384
|
+
/* @__PURE__ */ jsx12("span", { style: {
|
|
2212
2385
|
overflow: "hidden",
|
|
2213
2386
|
textOverflow: "ellipsis",
|
|
2214
2387
|
whiteSpace: "nowrap",
|
|
@@ -2217,11 +2390,11 @@ function UseAIChatPanel({
|
|
|
2217
2390
|
const agent = availableAgents.find((a) => a.id === (selectedAgent ?? defaultAgent));
|
|
2218
2391
|
return agent?.name || "AI";
|
|
2219
2392
|
})() }),
|
|
2220
|
-
/* @__PURE__ */
|
|
2393
|
+
/* @__PURE__ */ jsx12("svg", { width: "10", height: "10", viewBox: "0 0 12 12", fill: "none", style: { flexShrink: 0 }, children: /* @__PURE__ */ jsx12("path", { d: "M3 4.5L6 7.5L9 4.5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
2221
2394
|
]
|
|
2222
2395
|
}
|
|
2223
2396
|
),
|
|
2224
|
-
agentDropdown.isOpen && /* @__PURE__ */
|
|
2397
|
+
agentDropdown.isOpen && /* @__PURE__ */ jsx12(
|
|
2225
2398
|
"div",
|
|
2226
2399
|
{
|
|
2227
2400
|
style: {
|
|
@@ -2241,7 +2414,7 @@ function UseAIChatPanel({
|
|
|
2241
2414
|
},
|
|
2242
2415
|
children: availableAgents.map((agent) => {
|
|
2243
2416
|
const isSelected = agent.id === (selectedAgent ?? defaultAgent);
|
|
2244
|
-
return /* @__PURE__ */
|
|
2417
|
+
return /* @__PURE__ */ jsxs9(
|
|
2245
2418
|
"div",
|
|
2246
2419
|
{
|
|
2247
2420
|
"data-testid": "agent-option",
|
|
@@ -2271,13 +2444,13 @@ function UseAIChatPanel({
|
|
|
2271
2444
|
}
|
|
2272
2445
|
},
|
|
2273
2446
|
children: [
|
|
2274
|
-
/* @__PURE__ */
|
|
2275
|
-
/* @__PURE__ */
|
|
2447
|
+
/* @__PURE__ */ jsxs9("div", { style: { flex: 1, minWidth: 0 }, children: [
|
|
2448
|
+
/* @__PURE__ */ jsx12("div", { style: {
|
|
2276
2449
|
fontSize: "13px",
|
|
2277
2450
|
fontWeight: isSelected ? "600" : "500",
|
|
2278
2451
|
color: isSelected ? theme.primaryColor : theme.textColor
|
|
2279
2452
|
}, children: agent.name }),
|
|
2280
|
-
agent.annotation && /* @__PURE__ */
|
|
2453
|
+
agent.annotation && /* @__PURE__ */ jsx12("div", { style: {
|
|
2281
2454
|
fontSize: "11px",
|
|
2282
2455
|
color: theme.secondaryTextColor,
|
|
2283
2456
|
marginTop: "2px",
|
|
@@ -2286,7 +2459,7 @@ function UseAIChatPanel({
|
|
|
2286
2459
|
whiteSpace: "nowrap"
|
|
2287
2460
|
}, children: agent.annotation })
|
|
2288
2461
|
] }),
|
|
2289
|
-
isSelected && /* @__PURE__ */
|
|
2462
|
+
isSelected && /* @__PURE__ */ jsx12("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", style: { flexShrink: 0 }, children: /* @__PURE__ */ jsx12("path", { d: "M2 7L5.5 10.5L12 4", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
2290
2463
|
]
|
|
2291
2464
|
},
|
|
2292
2465
|
agent.id
|
|
@@ -2295,7 +2468,7 @@ function UseAIChatPanel({
|
|
|
2295
2468
|
}
|
|
2296
2469
|
)
|
|
2297
2470
|
] }),
|
|
2298
|
-
onNewChat && /* @__PURE__ */
|
|
2471
|
+
onNewChat && /* @__PURE__ */ jsx12(
|
|
2299
2472
|
"button",
|
|
2300
2473
|
{
|
|
2301
2474
|
"data-testid": "new-chat-button",
|
|
@@ -2322,10 +2495,10 @@ function UseAIChatPanel({
|
|
|
2322
2495
|
e.currentTarget.style.color = theme.secondaryTextColor;
|
|
2323
2496
|
},
|
|
2324
2497
|
title: strings.header.newChat,
|
|
2325
|
-
children: /* @__PURE__ */
|
|
2498
|
+
children: /* @__PURE__ */ jsx12("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", children: /* @__PURE__ */ jsx12("path", { d: "M8 3.5V12.5M3.5 8H12.5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }) })
|
|
2326
2499
|
}
|
|
2327
2500
|
),
|
|
2328
|
-
onDeleteChat && displayMessages.length > 0 && /* @__PURE__ */
|
|
2501
|
+
onDeleteChat && displayMessages.length > 0 && /* @__PURE__ */ jsx12(
|
|
2329
2502
|
"button",
|
|
2330
2503
|
{
|
|
2331
2504
|
"data-testid": "delete-chat-button",
|
|
@@ -2349,7 +2522,7 @@ function UseAIChatPanel({
|
|
|
2349
2522
|
e.currentTarget.style.color = theme.secondaryTextColor;
|
|
2350
2523
|
},
|
|
2351
2524
|
title: strings.header.deleteChat,
|
|
2352
|
-
children: /* @__PURE__ */
|
|
2525
|
+
children: /* @__PURE__ */ jsx12("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", children: /* @__PURE__ */ jsx12("path", { d: "M2 4H14M6.5 7V11M9.5 7V11M3 4L4 13C4 13.5304 4.21071 14.0391 4.58579 14.4142C4.96086 14.7893 5.46957 15 6 15H10C10.5304 15 11.0391 14.7893 11.4142 14.4142C11.7893 14.0391 12 13.5304 12 13L13 4M5.5 4V2.5C5.5 2.23478 5.60536 1.98043 5.79289 1.79289C5.98043 1.60536 6.23478 1.5 6.5 1.5H9.5C9.76522 1.5 10.0196 1.60536 10.2071 1.79289C10.3946 1.98043 10.5 2.23478 10.5 2.5V4", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
2353
2526
|
}
|
|
2354
2527
|
),
|
|
2355
2528
|
closeButton
|
|
@@ -2357,7 +2530,7 @@ function UseAIChatPanel({
|
|
|
2357
2530
|
]
|
|
2358
2531
|
}
|
|
2359
2532
|
),
|
|
2360
|
-
chatHistoryDropdown.isOpen && onListChats && /* @__PURE__ */
|
|
2533
|
+
chatHistoryDropdown.isOpen && onListChats && /* @__PURE__ */ jsx12(
|
|
2361
2534
|
"div",
|
|
2362
2535
|
{
|
|
2363
2536
|
style: {
|
|
@@ -2374,7 +2547,7 @@ function UseAIChatPanel({
|
|
|
2374
2547
|
flexDirection: "column",
|
|
2375
2548
|
overflow: "hidden"
|
|
2376
2549
|
},
|
|
2377
|
-
children: /* @__PURE__ */
|
|
2550
|
+
children: /* @__PURE__ */ jsx12(
|
|
2378
2551
|
"div",
|
|
2379
2552
|
{
|
|
2380
2553
|
style: {
|
|
@@ -2382,7 +2555,7 @@ function UseAIChatPanel({
|
|
|
2382
2555
|
overflowY: "auto",
|
|
2383
2556
|
padding: "8px"
|
|
2384
2557
|
},
|
|
2385
|
-
children: chatHistory.length === 0 ? /* @__PURE__ */
|
|
2558
|
+
children: chatHistory.length === 0 ? /* @__PURE__ */ jsx12(
|
|
2386
2559
|
"div",
|
|
2387
2560
|
{
|
|
2388
2561
|
style: {
|
|
@@ -2391,9 +2564,9 @@ function UseAIChatPanel({
|
|
|
2391
2564
|
padding: "32px 16px",
|
|
2392
2565
|
fontSize: "13px"
|
|
2393
2566
|
},
|
|
2394
|
-
children: /* @__PURE__ */
|
|
2567
|
+
children: /* @__PURE__ */ jsx12("p", { style: { margin: 0 }, children: strings.chatHistory.noChatHistory })
|
|
2395
2568
|
}
|
|
2396
|
-
) : chatHistory.map((chat) => /* @__PURE__ */
|
|
2569
|
+
) : chatHistory.map((chat) => /* @__PURE__ */ jsxs9(
|
|
2397
2570
|
"div",
|
|
2398
2571
|
{
|
|
2399
2572
|
"data-testid": "chat-history-item",
|
|
@@ -2417,10 +2590,10 @@ function UseAIChatPanel({
|
|
|
2417
2590
|
}
|
|
2418
2591
|
},
|
|
2419
2592
|
children: [
|
|
2420
|
-
/* @__PURE__ */
|
|
2421
|
-
/* @__PURE__ */
|
|
2593
|
+
/* @__PURE__ */ jsx12("div", { style: { fontSize: "13px", fontWeight: "500", color: theme.textColor, marginBottom: "4px", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: chat.title || strings.header.newChat }),
|
|
2594
|
+
/* @__PURE__ */ jsxs9("div", { style: { fontSize: "11px", color: theme.secondaryTextColor }, children: [
|
|
2422
2595
|
new Date(chat.updatedAt).toLocaleDateString([], { month: "short", day: "numeric" }),
|
|
2423
|
-
currentChatId === chat.id && /* @__PURE__ */
|
|
2596
|
+
currentChatId === chat.id && /* @__PURE__ */ jsxs9("span", { style: {
|
|
2424
2597
|
marginLeft: "8px",
|
|
2425
2598
|
color: theme.primaryColor,
|
|
2426
2599
|
fontWeight: "600"
|
|
@@ -2439,7 +2612,7 @@ function UseAIChatPanel({
|
|
|
2439
2612
|
),
|
|
2440
2613
|
chatHistoryDropdown.Backdrop,
|
|
2441
2614
|
agentDropdown.Backdrop,
|
|
2442
|
-
/* @__PURE__ */
|
|
2615
|
+
/* @__PURE__ */ jsxs9(
|
|
2443
2616
|
"div",
|
|
2444
2617
|
{
|
|
2445
2618
|
style: {
|
|
@@ -2451,7 +2624,7 @@ function UseAIChatPanel({
|
|
|
2451
2624
|
gap: "12px"
|
|
2452
2625
|
},
|
|
2453
2626
|
children: [
|
|
2454
|
-
displayMessages.length === 0 && /* @__PURE__ */
|
|
2627
|
+
displayMessages.length === 0 && /* @__PURE__ */ jsxs9(
|
|
2455
2628
|
"div",
|
|
2456
2629
|
{
|
|
2457
2630
|
style: {
|
|
@@ -2462,12 +2635,12 @@ function UseAIChatPanel({
|
|
|
2462
2635
|
gap: "20px"
|
|
2463
2636
|
},
|
|
2464
2637
|
children: [
|
|
2465
|
-
/* @__PURE__ */
|
|
2466
|
-
/* @__PURE__ */
|
|
2467
|
-
/* @__PURE__ */
|
|
2468
|
-
/* @__PURE__ */
|
|
2638
|
+
/* @__PURE__ */ jsxs9("div", { style: { textAlign: "center", color: theme.secondaryTextColor, fontSize: "14px" }, children: [
|
|
2639
|
+
/* @__PURE__ */ jsx12("p", { style: { margin: 0, fontSize: "32px", marginBottom: "12px" }, children: "\u{1F4AC}" }),
|
|
2640
|
+
/* @__PURE__ */ jsx12("p", { style: { margin: 0 }, children: strings.emptyChat.startConversation }),
|
|
2641
|
+
/* @__PURE__ */ jsx12("p", { style: { margin: "8px 0 0", fontSize: "12px" }, children: strings.emptyChat.askMeToHelp })
|
|
2469
2642
|
] }),
|
|
2470
|
-
displayedSuggestions.length > 0 && /* @__PURE__ */
|
|
2643
|
+
displayedSuggestions.length > 0 && /* @__PURE__ */ jsx12(
|
|
2471
2644
|
"div",
|
|
2472
2645
|
{
|
|
2473
2646
|
style: {
|
|
@@ -2477,7 +2650,7 @@ function UseAIChatPanel({
|
|
|
2477
2650
|
width: "100%",
|
|
2478
2651
|
maxWidth: "320px"
|
|
2479
2652
|
},
|
|
2480
|
-
children: displayedSuggestions.map((suggestion, index) => /* @__PURE__ */
|
|
2653
|
+
children: displayedSuggestions.map((suggestion, index) => /* @__PURE__ */ jsx12(
|
|
2481
2654
|
"button",
|
|
2482
2655
|
{
|
|
2483
2656
|
"data-testid": "chat-suggestion-button",
|
|
@@ -2521,7 +2694,7 @@ function UseAIChatPanel({
|
|
|
2521
2694
|
]
|
|
2522
2695
|
}
|
|
2523
2696
|
),
|
|
2524
|
-
displayMessages.map((message) => /* @__PURE__ */
|
|
2697
|
+
displayMessages.map((message) => /* @__PURE__ */ jsxs9(
|
|
2525
2698
|
"div",
|
|
2526
2699
|
{
|
|
2527
2700
|
"data-testid": `chat-message-${message.role}`,
|
|
@@ -2534,7 +2707,7 @@ function UseAIChatPanel({
|
|
|
2534
2707
|
onMouseEnter: () => message.role === "user" && setHoveredMessageId(message.id),
|
|
2535
2708
|
onMouseLeave: () => setHoveredMessageId(null),
|
|
2536
2709
|
children: [
|
|
2537
|
-
/* @__PURE__ */
|
|
2710
|
+
/* @__PURE__ */ jsxs9(
|
|
2538
2711
|
"div",
|
|
2539
2712
|
{
|
|
2540
2713
|
style: {
|
|
@@ -2542,7 +2715,7 @@ function UseAIChatPanel({
|
|
|
2542
2715
|
maxWidth: "80%"
|
|
2543
2716
|
},
|
|
2544
2717
|
children: [
|
|
2545
|
-
message.role === "user" && hoveredMessageId === message.id && onSaveCommand && !slashCommands.isSavingCommand(message.id) && /* @__PURE__ */
|
|
2718
|
+
message.role === "user" && hoveredMessageId === message.id && onSaveCommand && !slashCommands.isSavingCommand(message.id) && /* @__PURE__ */ jsx12(
|
|
2546
2719
|
"button",
|
|
2547
2720
|
{
|
|
2548
2721
|
"data-testid": "save-command-button",
|
|
@@ -2578,14 +2751,14 @@ function UseAIChatPanel({
|
|
|
2578
2751
|
e.currentTarget.style.transform = "scale(1)";
|
|
2579
2752
|
e.currentTarget.style.boxShadow = "0 2px 6px rgba(0, 0, 0, 0.15)";
|
|
2580
2753
|
},
|
|
2581
|
-
children: /* @__PURE__ */
|
|
2582
|
-
/* @__PURE__ */
|
|
2583
|
-
/* @__PURE__ */
|
|
2584
|
-
/* @__PURE__ */
|
|
2754
|
+
children: /* @__PURE__ */ jsxs9("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
2755
|
+
/* @__PURE__ */ jsx12("path", { d: "M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z" }),
|
|
2756
|
+
/* @__PURE__ */ jsx12("polyline", { points: "17 21 17 13 7 13 7 21" }),
|
|
2757
|
+
/* @__PURE__ */ jsx12("polyline", { points: "7 3 7 8 15 8" })
|
|
2585
2758
|
] })
|
|
2586
2759
|
}
|
|
2587
2760
|
),
|
|
2588
|
-
/* @__PURE__ */
|
|
2761
|
+
/* @__PURE__ */ jsxs9(
|
|
2589
2762
|
"div",
|
|
2590
2763
|
{
|
|
2591
2764
|
"data-testid": "chat-message-content",
|
|
@@ -2600,7 +2773,7 @@ function UseAIChatPanel({
|
|
|
2600
2773
|
wordWrap: "break-word"
|
|
2601
2774
|
},
|
|
2602
2775
|
children: [
|
|
2603
|
-
message.role === "user" && hasFileContent(message.content) && /* @__PURE__ */
|
|
2776
|
+
message.role === "user" && hasFileContent(message.content) && /* @__PURE__ */ jsx12("div", { style: { display: "flex", flexWrap: "wrap", gap: "6px", marginBottom: "8px" }, children: message.content.filter((part) => part.type === "file").map((part, idx) => /* @__PURE__ */ jsx12(
|
|
2604
2777
|
FilePlaceholder,
|
|
2605
2778
|
{
|
|
2606
2779
|
name: part.file.name,
|
|
@@ -2608,7 +2781,17 @@ function UseAIChatPanel({
|
|
|
2608
2781
|
},
|
|
2609
2782
|
idx
|
|
2610
2783
|
)) }),
|
|
2611
|
-
message.role === "assistant" ? /* @__PURE__ */
|
|
2784
|
+
message.role === "assistant" ? /* @__PURE__ */ jsxs9(Fragment, { children: [
|
|
2785
|
+
message.reasoningParts && message.reasoningParts.length > 0 && /* @__PURE__ */ jsx12(
|
|
2786
|
+
Reasoning,
|
|
2787
|
+
{
|
|
2788
|
+
reasoningParts: message.reasoningParts,
|
|
2789
|
+
theme,
|
|
2790
|
+
strings
|
|
2791
|
+
}
|
|
2792
|
+
),
|
|
2793
|
+
/* @__PURE__ */ jsx12(MarkdownContent, { content: getTextFromContent(message.content) })
|
|
2794
|
+
] }) : getTextFromContent(message.content)
|
|
2612
2795
|
]
|
|
2613
2796
|
}
|
|
2614
2797
|
),
|
|
@@ -2619,7 +2802,7 @@ function UseAIChatPanel({
|
|
|
2619
2802
|
]
|
|
2620
2803
|
}
|
|
2621
2804
|
),
|
|
2622
|
-
message.role === "assistant" && message.traceId && feedbackEnabled && onFeedback && /* @__PURE__ */
|
|
2805
|
+
message.role === "assistant" && message.traceId && feedbackEnabled && onFeedback && /* @__PURE__ */ jsxs9(
|
|
2623
2806
|
"div",
|
|
2624
2807
|
{
|
|
2625
2808
|
"data-testid": "feedback-buttons",
|
|
@@ -2630,7 +2813,7 @@ function UseAIChatPanel({
|
|
|
2630
2813
|
padding: "0 4px"
|
|
2631
2814
|
},
|
|
2632
2815
|
children: [
|
|
2633
|
-
/* @__PURE__ */
|
|
2816
|
+
/* @__PURE__ */ jsx12(
|
|
2634
2817
|
FeedbackButton,
|
|
2635
2818
|
{
|
|
2636
2819
|
type: "upvote",
|
|
@@ -2643,7 +2826,7 @@ function UseAIChatPanel({
|
|
|
2643
2826
|
unselectedColor: theme.secondaryTextColor
|
|
2644
2827
|
}
|
|
2645
2828
|
),
|
|
2646
|
-
/* @__PURE__ */
|
|
2829
|
+
/* @__PURE__ */ jsx12(
|
|
2647
2830
|
FeedbackButton,
|
|
2648
2831
|
{
|
|
2649
2832
|
type: "downvote",
|
|
@@ -2659,7 +2842,7 @@ function UseAIChatPanel({
|
|
|
2659
2842
|
]
|
|
2660
2843
|
}
|
|
2661
2844
|
),
|
|
2662
|
-
/* @__PURE__ */
|
|
2845
|
+
/* @__PURE__ */ jsx12(
|
|
2663
2846
|
"div",
|
|
2664
2847
|
{
|
|
2665
2848
|
style: {
|
|
@@ -2678,14 +2861,14 @@ function UseAIChatPanel({
|
|
|
2678
2861
|
},
|
|
2679
2862
|
message.id
|
|
2680
2863
|
)),
|
|
2681
|
-
loading && /* @__PURE__ */
|
|
2864
|
+
loading && /* @__PURE__ */ jsx12(
|
|
2682
2865
|
"div",
|
|
2683
2866
|
{
|
|
2684
2867
|
style: {
|
|
2685
2868
|
display: "flex",
|
|
2686
2869
|
alignItems: "flex-start"
|
|
2687
2870
|
},
|
|
2688
|
-
children: /* @__PURE__ */
|
|
2871
|
+
children: /* @__PURE__ */ jsx12(
|
|
2689
2872
|
"div",
|
|
2690
2873
|
{
|
|
2691
2874
|
className: "markdown-content",
|
|
@@ -2698,20 +2881,33 @@ function UseAIChatPanel({
|
|
|
2698
2881
|
color: theme.textColor,
|
|
2699
2882
|
maxWidth: "80%"
|
|
2700
2883
|
},
|
|
2701
|
-
children: streamingText
|
|
2702
|
-
/* @__PURE__ */
|
|
2703
|
-
|
|
2704
|
-
|
|
2884
|
+
children: streamingText || streamingReasoning ? /* @__PURE__ */ jsxs9(Fragment, { children: [
|
|
2885
|
+
streamingReasoning && /* @__PURE__ */ jsx12(
|
|
2886
|
+
Reasoning,
|
|
2887
|
+
{
|
|
2888
|
+
reasoningParts: [],
|
|
2889
|
+
isStreaming: true,
|
|
2890
|
+
streamingText: streamingReasoning,
|
|
2891
|
+
theme,
|
|
2892
|
+
strings
|
|
2893
|
+
}
|
|
2894
|
+
),
|
|
2895
|
+
streamingText && /* @__PURE__ */ jsx12(MarkdownContent, { content: streamingText }),
|
|
2896
|
+
!streamingText && /* @__PURE__ */ jsx12("span", { className: "dots", style: { opacity: 0.6 }, children: "..." })
|
|
2897
|
+
] }) : fileProcessing && fileProcessing.status === "processing" ? /* @__PURE__ */ jsxs9("div", { children: [
|
|
2898
|
+
/* @__PURE__ */ jsx12("span", { style: { opacity: 0.6 }, children: strings.input.processingFile }),
|
|
2899
|
+
fileProcessing.progress != null && /* @__PURE__ */ jsxs9(Fragment, { children: [
|
|
2900
|
+
/* @__PURE__ */ jsxs9("span", { style: { opacity: 0.6, marginLeft: "4px" }, children: [
|
|
2705
2901
|
Math.round(fileProcessing.progress),
|
|
2706
2902
|
"%"
|
|
2707
2903
|
] }),
|
|
2708
|
-
/* @__PURE__ */
|
|
2904
|
+
/* @__PURE__ */ jsx12("div", { style: {
|
|
2709
2905
|
marginTop: "6px",
|
|
2710
2906
|
height: "4px",
|
|
2711
2907
|
borderRadius: "2px",
|
|
2712
2908
|
background: theme.borderColor,
|
|
2713
2909
|
overflow: "hidden"
|
|
2714
|
-
}, children: /* @__PURE__ */
|
|
2910
|
+
}, children: /* @__PURE__ */ jsx12("div", { style: {
|
|
2715
2911
|
height: "100%",
|
|
2716
2912
|
width: `${fileProcessing.progress}%`,
|
|
2717
2913
|
borderRadius: "2px",
|
|
@@ -2719,17 +2915,17 @@ function UseAIChatPanel({
|
|
|
2719
2915
|
transition: "width 0.3s ease"
|
|
2720
2916
|
} }) })
|
|
2721
2917
|
] }),
|
|
2722
|
-
fileProcessing.progress == null && /* @__PURE__ */
|
|
2723
|
-
] }) : /* @__PURE__ */
|
|
2918
|
+
fileProcessing.progress == null && /* @__PURE__ */ jsx12("span", { className: "dots", style: { marginLeft: "4px" }, children: "..." })
|
|
2919
|
+
] }) : /* @__PURE__ */ jsx12("span", { className: "dots", style: { opacity: 0.6 }, children: "..." })
|
|
2724
2920
|
}
|
|
2725
2921
|
)
|
|
2726
2922
|
}
|
|
2727
2923
|
),
|
|
2728
|
-
/* @__PURE__ */
|
|
2924
|
+
/* @__PURE__ */ jsx12("div", { ref: messagesEndRef })
|
|
2729
2925
|
]
|
|
2730
2926
|
}
|
|
2731
2927
|
),
|
|
2732
|
-
/* @__PURE__ */
|
|
2928
|
+
/* @__PURE__ */ jsxs9(
|
|
2733
2929
|
"div",
|
|
2734
2930
|
{
|
|
2735
2931
|
style: {
|
|
@@ -2737,7 +2933,7 @@ function UseAIChatPanel({
|
|
|
2737
2933
|
borderTop: `1px solid ${theme.borderColor}`
|
|
2738
2934
|
},
|
|
2739
2935
|
children: [
|
|
2740
|
-
fileError && /* @__PURE__ */
|
|
2936
|
+
fileError && /* @__PURE__ */ jsx12(
|
|
2741
2937
|
"div",
|
|
2742
2938
|
{
|
|
2743
2939
|
"data-testid": "file-error",
|
|
@@ -2752,7 +2948,7 @@ function UseAIChatPanel({
|
|
|
2752
2948
|
children: fileError
|
|
2753
2949
|
}
|
|
2754
2950
|
),
|
|
2755
|
-
attachments.length > 0 && /* @__PURE__ */
|
|
2951
|
+
attachments.length > 0 && /* @__PURE__ */ jsx12(
|
|
2756
2952
|
"div",
|
|
2757
2953
|
{
|
|
2758
2954
|
"data-testid": "file-attachments",
|
|
@@ -2762,7 +2958,7 @@ function UseAIChatPanel({
|
|
|
2762
2958
|
gap: "8px",
|
|
2763
2959
|
marginBottom: "8px"
|
|
2764
2960
|
},
|
|
2765
|
-
children: attachments.map((attachment) => /* @__PURE__ */
|
|
2961
|
+
children: attachments.map((attachment) => /* @__PURE__ */ jsx12(
|
|
2766
2962
|
FileChip,
|
|
2767
2963
|
{
|
|
2768
2964
|
attachment,
|
|
@@ -2774,7 +2970,7 @@ function UseAIChatPanel({
|
|
|
2774
2970
|
))
|
|
2775
2971
|
}
|
|
2776
2972
|
),
|
|
2777
|
-
/* @__PURE__ */
|
|
2973
|
+
/* @__PURE__ */ jsx12(
|
|
2778
2974
|
"input",
|
|
2779
2975
|
{
|
|
2780
2976
|
ref: fileInputRef,
|
|
@@ -2786,7 +2982,7 @@ function UseAIChatPanel({
|
|
|
2786
2982
|
accept: acceptedTypes?.join(",")
|
|
2787
2983
|
}
|
|
2788
2984
|
),
|
|
2789
|
-
pendingApprovals.length > 0 && onApproveToolCall && onRejectToolCall ? /* @__PURE__ */
|
|
2985
|
+
pendingApprovals.length > 0 && onApproveToolCall && onRejectToolCall ? /* @__PURE__ */ jsx12(
|
|
2790
2986
|
ToolApprovalDialog,
|
|
2791
2987
|
{
|
|
2792
2988
|
toolCallName: pendingApprovals[0].toolCallName,
|
|
@@ -2801,7 +2997,7 @@ function UseAIChatPanel({
|
|
|
2801
2997
|
}
|
|
2802
2998
|
) : (
|
|
2803
2999
|
/* Input container - single border around everything */
|
|
2804
|
-
/* @__PURE__ */
|
|
3000
|
+
/* @__PURE__ */ jsxs9(
|
|
2805
3001
|
"div",
|
|
2806
3002
|
{
|
|
2807
3003
|
style: {
|
|
@@ -2813,7 +3009,7 @@ function UseAIChatPanel({
|
|
|
2813
3009
|
},
|
|
2814
3010
|
children: [
|
|
2815
3011
|
slashCommands.AutocompleteComponent,
|
|
2816
|
-
/* @__PURE__ */
|
|
3012
|
+
/* @__PURE__ */ jsx12(
|
|
2817
3013
|
"textarea",
|
|
2818
3014
|
{
|
|
2819
3015
|
ref: textareaRef,
|
|
@@ -2841,7 +3037,7 @@ function UseAIChatPanel({
|
|
|
2841
3037
|
}
|
|
2842
3038
|
}
|
|
2843
3039
|
),
|
|
2844
|
-
/* @__PURE__ */
|
|
3040
|
+
/* @__PURE__ */ jsxs9(
|
|
2845
3041
|
"div",
|
|
2846
3042
|
{
|
|
2847
3043
|
style: {
|
|
@@ -2851,7 +3047,7 @@ function UseAIChatPanel({
|
|
|
2851
3047
|
padding: "4px 8px"
|
|
2852
3048
|
},
|
|
2853
3049
|
children: [
|
|
2854
|
-
/* @__PURE__ */
|
|
3050
|
+
/* @__PURE__ */ jsx12("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: fileUploadEnabled && /* @__PURE__ */ jsx12(
|
|
2855
3051
|
"button",
|
|
2856
3052
|
{
|
|
2857
3053
|
"data-testid": "file-picker-button",
|
|
@@ -2883,13 +3079,13 @@ function UseAIChatPanel({
|
|
|
2883
3079
|
e.currentTarget.style.borderColor = theme.borderColor;
|
|
2884
3080
|
},
|
|
2885
3081
|
title: strings.fileUpload.attachFiles,
|
|
2886
|
-
children: /* @__PURE__ */
|
|
2887
|
-
/* @__PURE__ */
|
|
2888
|
-
/* @__PURE__ */
|
|
3082
|
+
children: /* @__PURE__ */ jsxs9("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
3083
|
+
/* @__PURE__ */ jsx12("line", { x1: "12", y1: "5", x2: "12", y2: "19" }),
|
|
3084
|
+
/* @__PURE__ */ jsx12("line", { x1: "5", y1: "12", x2: "19", y2: "12" })
|
|
2889
3085
|
] })
|
|
2890
3086
|
}
|
|
2891
3087
|
) }),
|
|
2892
|
-
/* @__PURE__ */
|
|
3088
|
+
/* @__PURE__ */ jsx12(
|
|
2893
3089
|
"button",
|
|
2894
3090
|
{
|
|
2895
3091
|
"data-testid": "chat-send-button",
|
|
@@ -2910,9 +3106,9 @@ function UseAIChatPanel({
|
|
|
2910
3106
|
height: "32px",
|
|
2911
3107
|
transition: "all 0.2s"
|
|
2912
3108
|
},
|
|
2913
|
-
children: /* @__PURE__ */
|
|
2914
|
-
/* @__PURE__ */
|
|
2915
|
-
/* @__PURE__ */
|
|
3109
|
+
children: /* @__PURE__ */ jsxs9("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
3110
|
+
/* @__PURE__ */ jsx12("line", { x1: "12", y1: "19", x2: "12", y2: "5" }),
|
|
3111
|
+
/* @__PURE__ */ jsx12("polyline", { points: "5 12 12 5 19 12" })
|
|
2916
3112
|
] })
|
|
2917
3113
|
}
|
|
2918
3114
|
)
|
|
@@ -2926,7 +3122,7 @@ function UseAIChatPanel({
|
|
|
2926
3122
|
]
|
|
2927
3123
|
}
|
|
2928
3124
|
),
|
|
2929
|
-
/* @__PURE__ */
|
|
3125
|
+
/* @__PURE__ */ jsx12("style", { children: `
|
|
2930
3126
|
/* Markdown content styles */
|
|
2931
3127
|
.markdown-content > :first-child {
|
|
2932
3128
|
margin-top: 0 !important;
|
|
@@ -2951,7 +3147,7 @@ function UseAIChatPanel({
|
|
|
2951
3147
|
}
|
|
2952
3148
|
|
|
2953
3149
|
// src/components/UseAIFloatingChatWrapper.tsx
|
|
2954
|
-
import { Fragment as Fragment2, jsx as
|
|
3150
|
+
import { Fragment as Fragment2, jsx as jsx13, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
2955
3151
|
function UseAIFloatingChatWrapper({
|
|
2956
3152
|
isOpen,
|
|
2957
3153
|
onClose,
|
|
@@ -2959,8 +3155,8 @@ function UseAIFloatingChatWrapper({
|
|
|
2959
3155
|
}) {
|
|
2960
3156
|
const theme = useTheme();
|
|
2961
3157
|
if (!isOpen) return null;
|
|
2962
|
-
return /* @__PURE__ */
|
|
2963
|
-
/* @__PURE__ */
|
|
3158
|
+
return /* @__PURE__ */ jsxs10(Fragment2, { children: [
|
|
3159
|
+
/* @__PURE__ */ jsx13(
|
|
2964
3160
|
"div",
|
|
2965
3161
|
{
|
|
2966
3162
|
style: {
|
|
@@ -2976,7 +3172,7 @@ function UseAIFloatingChatWrapper({
|
|
|
2976
3172
|
onClick: onClose
|
|
2977
3173
|
}
|
|
2978
3174
|
),
|
|
2979
|
-
/* @__PURE__ */
|
|
3175
|
+
/* @__PURE__ */ jsx13(
|
|
2980
3176
|
"div",
|
|
2981
3177
|
{
|
|
2982
3178
|
style: {
|
|
@@ -2995,7 +3191,7 @@ function UseAIFloatingChatWrapper({
|
|
|
2995
3191
|
children
|
|
2996
3192
|
}
|
|
2997
3193
|
),
|
|
2998
|
-
/* @__PURE__ */
|
|
3194
|
+
/* @__PURE__ */ jsx13("style", { children: `
|
|
2999
3195
|
@keyframes fadeIn {
|
|
3000
3196
|
from { opacity: 0; }
|
|
3001
3197
|
to { opacity: 1; }
|
|
@@ -3015,7 +3211,7 @@ function UseAIFloatingChatWrapper({
|
|
|
3015
3211
|
}
|
|
3016
3212
|
function CloseButton({ onClick }) {
|
|
3017
3213
|
const theme = useTheme();
|
|
3018
|
-
return /* @__PURE__ */
|
|
3214
|
+
return /* @__PURE__ */ jsx13(
|
|
3019
3215
|
"button",
|
|
3020
3216
|
{
|
|
3021
3217
|
"data-testid": "chat-close-button",
|
|
@@ -3050,7 +3246,7 @@ function CloseButton({ onClick }) {
|
|
|
3050
3246
|
|
|
3051
3247
|
// src/components/UseAIChat.tsx
|
|
3052
3248
|
import { createContext as createContext3, useContext as useContext3 } from "react";
|
|
3053
|
-
import { jsx as
|
|
3249
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
3054
3250
|
var __UseAIChatContext = createContext3(null);
|
|
3055
3251
|
function useChatUIContext() {
|
|
3056
3252
|
const context = useContext3(__UseAIChatContext);
|
|
@@ -3069,6 +3265,7 @@ function UseAIChat({ floating = false }) {
|
|
|
3069
3265
|
loading: ctx.loading,
|
|
3070
3266
|
connected: ctx.connected,
|
|
3071
3267
|
streamingText: ctx.streamingText,
|
|
3268
|
+
streamingReasoning: ctx.streamingReasoning,
|
|
3072
3269
|
currentChatId: ctx.history.currentId,
|
|
3073
3270
|
onNewChat: ctx.history.create,
|
|
3074
3271
|
onLoadChat: ctx.history.load,
|
|
@@ -3094,22 +3291,22 @@ function UseAIChat({ floating = false }) {
|
|
|
3094
3291
|
onRejectToolCall: ctx.tools.pending.tools.length > 0 ? ctx.tools.pending.rejectAll : void 0
|
|
3095
3292
|
};
|
|
3096
3293
|
if (floating) {
|
|
3097
|
-
return /* @__PURE__ */
|
|
3294
|
+
return /* @__PURE__ */ jsx14(
|
|
3098
3295
|
UseAIFloatingChatWrapper,
|
|
3099
3296
|
{
|
|
3100
3297
|
isOpen: ctx.ui.isOpen,
|
|
3101
3298
|
onClose: () => ctx.ui.setOpen(false),
|
|
3102
|
-
children: /* @__PURE__ */
|
|
3299
|
+
children: /* @__PURE__ */ jsx14(
|
|
3103
3300
|
UseAIChatPanel,
|
|
3104
3301
|
{
|
|
3105
3302
|
...chatPanelProps,
|
|
3106
|
-
closeButton: /* @__PURE__ */
|
|
3303
|
+
closeButton: /* @__PURE__ */ jsx14(CloseButton, { onClick: () => ctx.ui.setOpen(false) })
|
|
3107
3304
|
}
|
|
3108
3305
|
)
|
|
3109
3306
|
}
|
|
3110
3307
|
);
|
|
3111
3308
|
}
|
|
3112
|
-
return /* @__PURE__ */
|
|
3309
|
+
return /* @__PURE__ */ jsx14(UseAIChatPanel, { ...chatPanelProps });
|
|
3113
3310
|
}
|
|
3114
3311
|
|
|
3115
3312
|
// src/client.ts
|
|
@@ -3152,6 +3349,9 @@ var UseAIClient = class {
|
|
|
3152
3349
|
_pendingToolResults = [];
|
|
3153
3350
|
// Tool call assembly
|
|
3154
3351
|
currentToolCalls = /* @__PURE__ */ new Map();
|
|
3352
|
+
// Reasoning/thinking assembly
|
|
3353
|
+
_currentReasoningBlocks = [];
|
|
3354
|
+
_currentReasoningBlockText = "";
|
|
3155
3355
|
// Feedback tracking
|
|
3156
3356
|
_langfuseEnabled = false;
|
|
3157
3357
|
langfuseConfigHandlers = /* @__PURE__ */ new Set();
|
|
@@ -3219,6 +3419,8 @@ var UseAIClient = class {
|
|
|
3219
3419
|
};
|
|
3220
3420
|
this._currentAssistantToolCalls = [];
|
|
3221
3421
|
this._pendingToolResults = [];
|
|
3422
|
+
this._currentReasoningBlocks = [];
|
|
3423
|
+
this._currentReasoningBlockText = "";
|
|
3222
3424
|
}
|
|
3223
3425
|
if (event.type === EventType.TEXT_MESSAGE_START) {
|
|
3224
3426
|
const e = event;
|
|
@@ -3257,6 +3459,27 @@ var UseAIClient = class {
|
|
|
3257
3459
|
}
|
|
3258
3460
|
});
|
|
3259
3461
|
}
|
|
3462
|
+
} else if (event.type === EventType.REASONING_MESSAGE_START) {
|
|
3463
|
+
this._currentReasoningBlockText = "";
|
|
3464
|
+
} else if (event.type === EventType.REASONING_MESSAGE_CONTENT) {
|
|
3465
|
+
const e = event;
|
|
3466
|
+
this._currentReasoningBlockText += e.delta;
|
|
3467
|
+
} else if (event.type === EventType.REASONING_MESSAGE_END) {
|
|
3468
|
+
this._currentReasoningBlocks.push({
|
|
3469
|
+
text: this._currentReasoningBlockText
|
|
3470
|
+
});
|
|
3471
|
+
this._currentReasoningBlockText = "";
|
|
3472
|
+
} else if (event.type === EventType.REASONING_ENCRYPTED_VALUE) {
|
|
3473
|
+
const e = event;
|
|
3474
|
+
if (e.subtype === "message" && this._currentReasoningBlocks.length > 0) {
|
|
3475
|
+
const lastBlock = this._currentReasoningBlocks[this._currentReasoningBlocks.length - 1];
|
|
3476
|
+
lastBlock.encryptedValue = e.encryptedValue;
|
|
3477
|
+
} else if (e.subtype === "tool-call" && e.entityId) {
|
|
3478
|
+
const tc = this._currentAssistantToolCalls.find((tc2) => tc2.id === e.entityId);
|
|
3479
|
+
if (tc) {
|
|
3480
|
+
tc.encryptedValue = e.encryptedValue;
|
|
3481
|
+
}
|
|
3482
|
+
}
|
|
3260
3483
|
} else if (event.type === EventType.TOOL_CALL_RESULT) {
|
|
3261
3484
|
const e = event;
|
|
3262
3485
|
const alreadyTracked = this._pendingToolResults.some(
|
|
@@ -3272,26 +3495,31 @@ var UseAIClient = class {
|
|
|
3272
3495
|
}
|
|
3273
3496
|
} else if (event.type === EventType.STEP_FINISHED) {
|
|
3274
3497
|
if (this._currentAssistantToolCalls.length > 0 && this._currentAssistantMessage) {
|
|
3498
|
+
const reasoningParts = this._currentReasoningBlocks.length > 0 ? [...this._currentReasoningBlocks] : void 0;
|
|
3275
3499
|
const assistantMsg = {
|
|
3276
3500
|
id: this._currentAssistantMessage.id || uuidv42(),
|
|
3277
3501
|
role: "assistant",
|
|
3278
3502
|
content: this._currentAssistantMessage.content || "",
|
|
3279
|
-
toolCalls: [...this._currentAssistantToolCalls]
|
|
3503
|
+
toolCalls: [...this._currentAssistantToolCalls],
|
|
3504
|
+
...reasoningParts ? { reasoningParts } : {}
|
|
3280
3505
|
};
|
|
3281
3506
|
this._messages.push(assistantMsg);
|
|
3282
3507
|
this._messages.push(...this._pendingToolResults);
|
|
3283
3508
|
this._currentAssistantMessage = { id: uuidv42(), role: "assistant", content: "" };
|
|
3284
3509
|
this._currentAssistantToolCalls = [];
|
|
3285
3510
|
this._pendingToolResults = [];
|
|
3511
|
+
this._currentReasoningBlocks = [];
|
|
3286
3512
|
}
|
|
3287
3513
|
} else if (event.type === EventType.RUN_FINISHED) {
|
|
3288
3514
|
if (this._currentAssistantMessage) {
|
|
3515
|
+
const reasoningParts = this._currentReasoningBlocks.length > 0 ? [...this._currentReasoningBlocks] : void 0;
|
|
3289
3516
|
if (this._currentAssistantToolCalls.length > 0) {
|
|
3290
3517
|
const toolCallMessage = {
|
|
3291
3518
|
id: uuidv42(),
|
|
3292
3519
|
role: "assistant",
|
|
3293
3520
|
content: "",
|
|
3294
|
-
toolCalls: this._currentAssistantToolCalls
|
|
3521
|
+
toolCalls: this._currentAssistantToolCalls,
|
|
3522
|
+
...reasoningParts ? { reasoningParts } : {}
|
|
3295
3523
|
};
|
|
3296
3524
|
this._messages.push(toolCallMessage);
|
|
3297
3525
|
this._messages.push(...this._pendingToolResults);
|
|
@@ -3305,7 +3533,8 @@ var UseAIClient = class {
|
|
|
3305
3533
|
const assistantMessage = {
|
|
3306
3534
|
id: this._currentAssistantMessage.id,
|
|
3307
3535
|
role: "assistant",
|
|
3308
|
-
content: this._currentAssistantMessage.content || ""
|
|
3536
|
+
content: this._currentAssistantMessage.content || "",
|
|
3537
|
+
...reasoningParts ? { reasoningParts } : {}
|
|
3309
3538
|
};
|
|
3310
3539
|
this._messages.push(assistantMessage);
|
|
3311
3540
|
}
|
|
@@ -3528,6 +3757,12 @@ var UseAIClient = class {
|
|
|
3528
3757
|
get currentMessageContent() {
|
|
3529
3758
|
return this._currentMessageContent;
|
|
3530
3759
|
}
|
|
3760
|
+
/**
|
|
3761
|
+
* Gets the current reasoning blocks collected during the current run.
|
|
3762
|
+
*/
|
|
3763
|
+
get currentReasoningBlocks() {
|
|
3764
|
+
return this._currentReasoningBlocks;
|
|
3765
|
+
}
|
|
3531
3766
|
/**
|
|
3532
3767
|
* Gets the current thread ID for this session.
|
|
3533
3768
|
* Generates a new one if not set.
|
|
@@ -3942,7 +4177,7 @@ var LocalStorageChatRepository = class {
|
|
|
3942
4177
|
};
|
|
3943
4178
|
|
|
3944
4179
|
// src/hooks/useChatManagement.ts
|
|
3945
|
-
import { useState as
|
|
4180
|
+
import { useState as useState7, useCallback as useCallback5, useRef as useRef5, useEffect as useEffect5 } from "react";
|
|
3946
4181
|
|
|
3947
4182
|
// src/utils/messageConversion.ts
|
|
3948
4183
|
function transformMessagesToClientFormat(persistedMessages) {
|
|
@@ -3961,7 +4196,8 @@ function transformMessagesToClientFormat(persistedMessages) {
|
|
|
3961
4196
|
id: msg.id,
|
|
3962
4197
|
role: "assistant",
|
|
3963
4198
|
content: textContent,
|
|
3964
|
-
...msg.toolCalls && msg.toolCalls.length > 0 ? { toolCalls: msg.toolCalls } : {}
|
|
4199
|
+
...msg.toolCalls && msg.toolCalls.length > 0 ? { toolCalls: msg.toolCalls } : {},
|
|
4200
|
+
...msg.reasoningParts && msg.reasoningParts.length > 0 ? { reasoningParts: msg.reasoningParts } : {}
|
|
3965
4201
|
};
|
|
3966
4202
|
case "user":
|
|
3967
4203
|
return {
|
|
@@ -3977,12 +4213,14 @@ function extractTurnMessages(messages, startIndex) {
|
|
|
3977
4213
|
const result = [];
|
|
3978
4214
|
for (const msg of turnSlice) {
|
|
3979
4215
|
if (msg.role === "assistant" && "toolCalls" in msg && msg.toolCalls) {
|
|
4216
|
+
const reasoningParts = "reasoningParts" in msg && msg.reasoningParts ? msg.reasoningParts : void 0;
|
|
3980
4217
|
result.push({
|
|
3981
4218
|
id: msg.id,
|
|
3982
4219
|
role: "assistant",
|
|
3983
4220
|
content: typeof msg.content === "string" ? msg.content : "",
|
|
3984
4221
|
createdAt: /* @__PURE__ */ new Date(),
|
|
3985
|
-
toolCalls: msg.toolCalls
|
|
4222
|
+
toolCalls: msg.toolCalls,
|
|
4223
|
+
...reasoningParts ? { reasoningParts } : {}
|
|
3986
4224
|
});
|
|
3987
4225
|
} else if (msg.role === "tool") {
|
|
3988
4226
|
result.push({
|
|
@@ -4012,8 +4250,8 @@ function useChatManagement({
|
|
|
4012
4250
|
setMessages,
|
|
4013
4251
|
connected
|
|
4014
4252
|
}) {
|
|
4015
|
-
const [currentChatId, setCurrentChatId] =
|
|
4016
|
-
const [pendingChatId, setPendingChatId] =
|
|
4253
|
+
const [currentChatId, setCurrentChatId] = useState7(null);
|
|
4254
|
+
const [pendingChatId, setPendingChatId] = useState7(null);
|
|
4017
4255
|
const currentChatIdSnapshot = useRef5(null);
|
|
4018
4256
|
const pendingChatIdSnapshot = useRef5(null);
|
|
4019
4257
|
useEffect5(() => {
|
|
@@ -4022,7 +4260,7 @@ function useChatManagement({
|
|
|
4022
4260
|
useEffect5(() => {
|
|
4023
4261
|
pendingChatIdSnapshot.current = pendingChatId;
|
|
4024
4262
|
}, [pendingChatId]);
|
|
4025
|
-
const loadChatMessages =
|
|
4263
|
+
const loadChatMessages = useCallback5(async (chatId) => {
|
|
4026
4264
|
try {
|
|
4027
4265
|
const chat = await repository.loadChat(chatId);
|
|
4028
4266
|
if (chat) {
|
|
@@ -4037,11 +4275,11 @@ function useChatManagement({
|
|
|
4037
4275
|
return [];
|
|
4038
4276
|
}
|
|
4039
4277
|
}, [repository]);
|
|
4040
|
-
const reloadMessages =
|
|
4278
|
+
const reloadMessages = useCallback5(async (chatId) => {
|
|
4041
4279
|
const loadedMessages = await loadChatMessages(chatId);
|
|
4042
4280
|
setMessages(loadedMessages);
|
|
4043
4281
|
}, [loadChatMessages, setMessages]);
|
|
4044
|
-
const createNewChat =
|
|
4282
|
+
const createNewChat = useCallback5(async (options) => {
|
|
4045
4283
|
console.log("[ChatManagement] createNewChat called - currentChatId:", currentChatId, "pendingChatId:", pendingChatId, "messages.length:", messages.length);
|
|
4046
4284
|
if (pendingChatId && messages.length === 0) {
|
|
4047
4285
|
const existingChat = await repository.loadChat(pendingChatId);
|
|
@@ -4062,7 +4300,7 @@ function useChatManagement({
|
|
|
4062
4300
|
console.log("[ChatManagement] Created pending chat:", chatId, "(will activate on first message)");
|
|
4063
4301
|
return chatId;
|
|
4064
4302
|
}, [currentChatId, pendingChatId, messages, repository, clientRef, setMessages]);
|
|
4065
|
-
const loadChat =
|
|
4303
|
+
const loadChat = useCallback5(async (chatId) => {
|
|
4066
4304
|
setPendingChatId(chatId);
|
|
4067
4305
|
await reloadMessages(chatId);
|
|
4068
4306
|
if (clientRef.current) {
|
|
@@ -4071,7 +4309,7 @@ function useChatManagement({
|
|
|
4071
4309
|
}
|
|
4072
4310
|
console.log("[ChatManagement] Loaded pending chat:", chatId, "(will activate on first message)");
|
|
4073
4311
|
}, [reloadMessages, clientRef]);
|
|
4074
|
-
const deleteChat =
|
|
4312
|
+
const deleteChat = useCallback5(async (chatId) => {
|
|
4075
4313
|
await repository.deleteChat(chatId);
|
|
4076
4314
|
if (currentChatId === chatId) {
|
|
4077
4315
|
setCurrentChatId(null);
|
|
@@ -4083,10 +4321,10 @@ function useChatManagement({
|
|
|
4083
4321
|
}
|
|
4084
4322
|
console.log("[ChatManagement] Deleted chat:", chatId);
|
|
4085
4323
|
}, [currentChatId, pendingChatId, repository, setMessages]);
|
|
4086
|
-
const listChats =
|
|
4324
|
+
const listChats = useCallback5(async () => {
|
|
4087
4325
|
return await repository.listChats();
|
|
4088
4326
|
}, [repository]);
|
|
4089
|
-
const clearCurrentChat =
|
|
4327
|
+
const clearCurrentChat = useCallback5(async () => {
|
|
4090
4328
|
setMessages([]);
|
|
4091
4329
|
if (currentChatId) {
|
|
4092
4330
|
const chat = await repository.loadChat(currentChatId);
|
|
@@ -4097,7 +4335,7 @@ function useChatManagement({
|
|
|
4097
4335
|
}
|
|
4098
4336
|
}
|
|
4099
4337
|
}, [currentChatId, repository, setMessages]);
|
|
4100
|
-
const getCurrentChat =
|
|
4338
|
+
const getCurrentChat = useCallback5(async () => {
|
|
4101
4339
|
const chatId = pendingChatId || currentChatId;
|
|
4102
4340
|
if (!chatId) return null;
|
|
4103
4341
|
const chat = await repository.loadChat(chatId);
|
|
@@ -4106,14 +4344,14 @@ function useChatManagement({
|
|
|
4106
4344
|
}
|
|
4107
4345
|
return chat;
|
|
4108
4346
|
}, [pendingChatId, currentChatId, repository]);
|
|
4109
|
-
const updateMetadata =
|
|
4347
|
+
const updateMetadata = useCallback5(async (metadata, overwrite = false) => {
|
|
4110
4348
|
const chatId = pendingChatId || currentChatId;
|
|
4111
4349
|
if (!chatId) {
|
|
4112
4350
|
throw new Error("No active chat");
|
|
4113
4351
|
}
|
|
4114
4352
|
await repository.updateMetadata(chatId, metadata, overwrite);
|
|
4115
4353
|
}, [pendingChatId, currentChatId, repository]);
|
|
4116
|
-
const activatePendingChat =
|
|
4354
|
+
const activatePendingChat = useCallback5(() => {
|
|
4117
4355
|
if (!pendingChatId) return null;
|
|
4118
4356
|
console.log("[ChatManagement] Activating pending chat:", pendingChatId);
|
|
4119
4357
|
if (clientRef.current && messages.length > 0) {
|
|
@@ -4124,7 +4362,7 @@ function useChatManagement({
|
|
|
4124
4362
|
setPendingChatId(null);
|
|
4125
4363
|
return pendingChatId;
|
|
4126
4364
|
}, [pendingChatId, clientRef, messages]);
|
|
4127
|
-
const saveUserMessage =
|
|
4365
|
+
const saveUserMessage = useCallback5(async (chatId, content) => {
|
|
4128
4366
|
try {
|
|
4129
4367
|
const chat = await repository.loadChat(chatId);
|
|
4130
4368
|
if (!chat) {
|
|
@@ -4153,7 +4391,7 @@ function useChatManagement({
|
|
|
4153
4391
|
return false;
|
|
4154
4392
|
}
|
|
4155
4393
|
}, [repository, setMessages]);
|
|
4156
|
-
const saveAIResponse =
|
|
4394
|
+
const saveAIResponse = useCallback5(async (content, displayMode, traceId, turnMessages, reasoningParts) => {
|
|
4157
4395
|
const currentChatIdValue = currentChatIdSnapshot.current;
|
|
4158
4396
|
const pendingChatIdValue = pendingChatIdSnapshot.current;
|
|
4159
4397
|
const displayedChatId2 = pendingChatIdValue || currentChatIdValue;
|
|
@@ -4176,7 +4414,8 @@ function useChatManagement({
|
|
|
4176
4414
|
content,
|
|
4177
4415
|
createdAt: /* @__PURE__ */ new Date(),
|
|
4178
4416
|
displayMode,
|
|
4179
|
-
traceId
|
|
4417
|
+
traceId,
|
|
4418
|
+
...reasoningParts && reasoningParts.length > 0 ? { reasoningParts } : {}
|
|
4180
4419
|
};
|
|
4181
4420
|
chat.messages.push(finalMessage);
|
|
4182
4421
|
if (!chat.title) {
|
|
@@ -4273,7 +4512,7 @@ function useChatManagement({
|
|
|
4273
4512
|
}
|
|
4274
4513
|
|
|
4275
4514
|
// src/hooks/useAgentSelection.ts
|
|
4276
|
-
import { useState as
|
|
4515
|
+
import { useState as useState8, useCallback as useCallback6, useEffect as useEffect6, useMemo as useMemo3 } from "react";
|
|
4277
4516
|
function filterAgents(serverAgents, defaultAgentId, visibleAgentIds) {
|
|
4278
4517
|
const getDefaultAgentFallback = () => {
|
|
4279
4518
|
const defaultAgentInfo = serverAgents.find((a) => a.id === defaultAgentId);
|
|
@@ -4299,14 +4538,14 @@ function useAgentSelection({
|
|
|
4299
4538
|
connected,
|
|
4300
4539
|
visibleAgentIds
|
|
4301
4540
|
}) {
|
|
4302
|
-
const [serverAgents, setServerAgents] =
|
|
4303
|
-
const [defaultAgent, setDefaultAgent] =
|
|
4304
|
-
const [selectedAgent, setSelectedAgent] =
|
|
4541
|
+
const [serverAgents, setServerAgents] = useState8([]);
|
|
4542
|
+
const [defaultAgent, setDefaultAgent] = useState8(null);
|
|
4543
|
+
const [selectedAgent, setSelectedAgent] = useState8(null);
|
|
4305
4544
|
const availableAgents = useMemo3(
|
|
4306
4545
|
() => filterAgents(serverAgents, defaultAgent, visibleAgentIds),
|
|
4307
4546
|
[serverAgents, defaultAgent, visibleAgentIds]
|
|
4308
4547
|
);
|
|
4309
|
-
const setAgent =
|
|
4548
|
+
const setAgent = useCallback6((agentId) => {
|
|
4310
4549
|
setSelectedAgent(agentId);
|
|
4311
4550
|
if (clientRef.current) {
|
|
4312
4551
|
clientRef.current.setAgent(agentId);
|
|
@@ -4338,7 +4577,7 @@ function useAgentSelection({
|
|
|
4338
4577
|
}
|
|
4339
4578
|
|
|
4340
4579
|
// src/hooks/useCommandManagement.ts
|
|
4341
|
-
import { useState as
|
|
4580
|
+
import { useState as useState9, useCallback as useCallback7, useRef as useRef6, useEffect as useEffect7 } from "react";
|
|
4342
4581
|
|
|
4343
4582
|
// src/commands/LocalStorageCommandRepository.ts
|
|
4344
4583
|
var STORAGE_KEY_PREFIX2 = "use-ai:command:";
|
|
@@ -4471,8 +4710,8 @@ function useCommandManagement({
|
|
|
4471
4710
|
const repositoryRef = useRef6(
|
|
4472
4711
|
repository || new LocalStorageCommandRepository()
|
|
4473
4712
|
);
|
|
4474
|
-
const [commands, setCommands] =
|
|
4475
|
-
const refreshCommands =
|
|
4713
|
+
const [commands, setCommands] = useState9([]);
|
|
4714
|
+
const refreshCommands = useCallback7(async () => {
|
|
4476
4715
|
try {
|
|
4477
4716
|
const cmdList = await repositoryRef.current.listCommands();
|
|
4478
4717
|
setCommands(cmdList);
|
|
@@ -4481,13 +4720,13 @@ function useCommandManagement({
|
|
|
4481
4720
|
console.error("[CommandManagement] Failed to load commands:", err);
|
|
4482
4721
|
}
|
|
4483
4722
|
}, []);
|
|
4484
|
-
const saveCommand =
|
|
4723
|
+
const saveCommand = useCallback7(async (name, text) => {
|
|
4485
4724
|
const id = await repositoryRef.current.createCommand({ name, text });
|
|
4486
4725
|
await refreshCommands();
|
|
4487
4726
|
console.log("[CommandManagement] Saved command:", name);
|
|
4488
4727
|
return id;
|
|
4489
4728
|
}, [refreshCommands]);
|
|
4490
|
-
const renameCommand =
|
|
4729
|
+
const renameCommand = useCallback7(async (id, newName) => {
|
|
4491
4730
|
const command = await repositoryRef.current.loadCommand(id);
|
|
4492
4731
|
if (!command) throw new Error(`Command ${id} not found`);
|
|
4493
4732
|
command.name = newName.trim();
|
|
@@ -4495,7 +4734,7 @@ function useCommandManagement({
|
|
|
4495
4734
|
await refreshCommands();
|
|
4496
4735
|
console.log("[CommandManagement] Renamed command:", id, "to", newName);
|
|
4497
4736
|
}, [refreshCommands]);
|
|
4498
|
-
const deleteCommand =
|
|
4737
|
+
const deleteCommand = useCallback7(async (id) => {
|
|
4499
4738
|
await repositoryRef.current.deleteCommand(id);
|
|
4500
4739
|
await refreshCommands();
|
|
4501
4740
|
console.log("[CommandManagement] Deleted command:", id);
|
|
@@ -4513,22 +4752,22 @@ function useCommandManagement({
|
|
|
4513
4752
|
}
|
|
4514
4753
|
|
|
4515
4754
|
// src/hooks/useToolSystem.ts
|
|
4516
|
-
import { useState as
|
|
4755
|
+
import { useState as useState10, useCallback as useCallback8, useRef as useRef7, useMemo as useMemo4 } from "react";
|
|
4517
4756
|
function useToolSystem({
|
|
4518
4757
|
clientRef,
|
|
4519
4758
|
buildState
|
|
4520
4759
|
}) {
|
|
4521
4760
|
const toolRegistryRef = useRef7(/* @__PURE__ */ new Map());
|
|
4522
|
-
const [toolRegistryVersion, setToolRegistryVersion] =
|
|
4761
|
+
const [toolRegistryVersion, setToolRegistryVersion] = useState10(0);
|
|
4523
4762
|
const toolOwnershipRef = useRef7(/* @__PURE__ */ new Map());
|
|
4524
4763
|
const invisibleRef = useRef7(/* @__PURE__ */ new Set());
|
|
4525
4764
|
const readyStateRef = useRef7(/* @__PURE__ */ new Map());
|
|
4526
4765
|
const readyListenersRef = useRef7(/* @__PURE__ */ new Set());
|
|
4527
4766
|
const waitersRef = useRef7(/* @__PURE__ */ new Map());
|
|
4528
|
-
const [pendingApprovals, setPendingApprovals] =
|
|
4767
|
+
const [pendingApprovals, setPendingApprovals] = useState10([]);
|
|
4529
4768
|
const pendingApprovalToolCallsRef = useRef7(/* @__PURE__ */ new Map());
|
|
4530
4769
|
const runtimeApprovalResolversRef = useRef7(/* @__PURE__ */ new Map());
|
|
4531
|
-
const registerTools =
|
|
4770
|
+
const registerTools = useCallback8((id, tools, options) => {
|
|
4532
4771
|
const existingTools = toolRegistryRef.current.get(id);
|
|
4533
4772
|
toolRegistryRef.current.set(id, tools);
|
|
4534
4773
|
readyStateRef.current.set(id, false);
|
|
@@ -4550,14 +4789,14 @@ function useToolSystem({
|
|
|
4550
4789
|
invisibleRef.current.delete(id);
|
|
4551
4790
|
}
|
|
4552
4791
|
}, []);
|
|
4553
|
-
const signalReady =
|
|
4792
|
+
const signalReady = useCallback8((id) => {
|
|
4554
4793
|
if (!toolRegistryRef.current.has(id)) {
|
|
4555
4794
|
return;
|
|
4556
4795
|
}
|
|
4557
4796
|
readyStateRef.current.set(id, true);
|
|
4558
4797
|
readyListenersRef.current.forEach((listener) => listener());
|
|
4559
4798
|
}, []);
|
|
4560
|
-
const unregisterTools =
|
|
4799
|
+
const unregisterTools = useCallback8((id) => {
|
|
4561
4800
|
const tools = toolRegistryRef.current.get(id);
|
|
4562
4801
|
if (tools) {
|
|
4563
4802
|
Object.keys(tools).forEach((toolName) => {
|
|
@@ -4570,7 +4809,7 @@ function useToolSystem({
|
|
|
4570
4809
|
invisibleRef.current.delete(id);
|
|
4571
4810
|
readyListenersRef.current.forEach((listener) => listener());
|
|
4572
4811
|
}, []);
|
|
4573
|
-
const isInvisible =
|
|
4812
|
+
const isInvisible = useCallback8((id) => {
|
|
4574
4813
|
return invisibleRef.current.has(id);
|
|
4575
4814
|
}, []);
|
|
4576
4815
|
const aggregatedTools = useMemo4(() => {
|
|
@@ -4583,7 +4822,7 @@ function useToolSystem({
|
|
|
4583
4822
|
const hasTools = toolRegistryRef.current.size > 0;
|
|
4584
4823
|
const aggregatedToolsRef = useRef7(aggregatedTools);
|
|
4585
4824
|
aggregatedToolsRef.current = aggregatedTools;
|
|
4586
|
-
const waitForToolsToStabilize =
|
|
4825
|
+
const waitForToolsToStabilize = useCallback8(async () => {
|
|
4587
4826
|
const maxWaitMs = 500;
|
|
4588
4827
|
const checkAllReady = () => {
|
|
4589
4828
|
if (readyStateRef.current.size === 0) return true;
|
|
@@ -4620,16 +4859,16 @@ function useToolSystem({
|
|
|
4620
4859
|
onReadyChange();
|
|
4621
4860
|
});
|
|
4622
4861
|
}, []);
|
|
4623
|
-
const registerWaiter =
|
|
4862
|
+
const registerWaiter = useCallback8((id, waiter) => {
|
|
4624
4863
|
waitersRef.current.set(id, waiter);
|
|
4625
4864
|
}, []);
|
|
4626
|
-
const unregisterWaiter =
|
|
4865
|
+
const unregisterWaiter = useCallback8((id) => {
|
|
4627
4866
|
waitersRef.current.delete(id);
|
|
4628
4867
|
}, []);
|
|
4629
|
-
const getWaiter =
|
|
4868
|
+
const getWaiter = useCallback8((id) => {
|
|
4630
4869
|
return waitersRef.current.get(id);
|
|
4631
4870
|
}, []);
|
|
4632
|
-
const handleApprovalRequest =
|
|
4871
|
+
const handleApprovalRequest = useCallback8((event) => {
|
|
4633
4872
|
console.log("[useToolSystem] Tool approval requested:", event.toolCallName, event.toolCallId);
|
|
4634
4873
|
setPendingApprovals((prev) => [
|
|
4635
4874
|
...prev,
|
|
@@ -4643,7 +4882,7 @@ function useToolSystem({
|
|
|
4643
4882
|
}
|
|
4644
4883
|
]);
|
|
4645
4884
|
}, []);
|
|
4646
|
-
const executeToolCall =
|
|
4885
|
+
const executeToolCall = useCallback8(async (toolCallId, name, input) => {
|
|
4647
4886
|
const client = clientRef.current;
|
|
4648
4887
|
if (!client) {
|
|
4649
4888
|
console.error("[useToolSystem] No client available for tool execution");
|
|
@@ -4699,11 +4938,11 @@ function useToolSystem({
|
|
|
4699
4938
|
});
|
|
4700
4939
|
}
|
|
4701
4940
|
}, [clientRef, isInvisible, getWaiter, waitForToolsToStabilize, buildState]);
|
|
4702
|
-
const storePendingToolCall =
|
|
4941
|
+
const storePendingToolCall = useCallback8((toolCallId, name, input, toolCallData) => {
|
|
4703
4942
|
console.log(`[useToolSystem] Storing pending tool call "${name}" for approval`);
|
|
4704
4943
|
pendingApprovalToolCallsRef.current.set(toolCallId, { name, input, toolCallData });
|
|
4705
4944
|
}, []);
|
|
4706
|
-
const executePendingToolAfterApproval =
|
|
4945
|
+
const executePendingToolAfterApproval = useCallback8(async (toolCallId) => {
|
|
4707
4946
|
const pendingTool = pendingApprovalToolCallsRef.current.get(toolCallId);
|
|
4708
4947
|
if (!pendingTool) {
|
|
4709
4948
|
console.warn(`[useToolSystem] No pending tool found for ${toolCallId}`);
|
|
@@ -4712,7 +4951,7 @@ function useToolSystem({
|
|
|
4712
4951
|
pendingApprovalToolCallsRef.current.delete(toolCallId);
|
|
4713
4952
|
await executeToolCall(toolCallId, pendingTool.name, pendingTool.input);
|
|
4714
4953
|
}, [executeToolCall]);
|
|
4715
|
-
const approveAll =
|
|
4954
|
+
const approveAll = useCallback8(async () => {
|
|
4716
4955
|
if (!clientRef.current) return;
|
|
4717
4956
|
console.log("[useToolSystem] Approving all tool calls:", pendingApprovals.length);
|
|
4718
4957
|
const pendingTools = [...pendingApprovals];
|
|
@@ -4728,7 +4967,7 @@ function useToolSystem({
|
|
|
4728
4967
|
}
|
|
4729
4968
|
}
|
|
4730
4969
|
}, [clientRef, pendingApprovals, executePendingToolAfterApproval]);
|
|
4731
|
-
const rejectAll =
|
|
4970
|
+
const rejectAll = useCallback8((reason) => {
|
|
4732
4971
|
if (!clientRef.current) return;
|
|
4733
4972
|
console.log("[useToolSystem] Rejecting all tool calls:", pendingApprovals.length, reason);
|
|
4734
4973
|
const pendingTools = [...pendingApprovals];
|
|
@@ -4768,7 +5007,7 @@ function useToolSystem({
|
|
|
4768
5007
|
}
|
|
4769
5008
|
|
|
4770
5009
|
// src/hooks/usePromptState.ts
|
|
4771
|
-
import { useState as
|
|
5010
|
+
import { useState as useState11, useCallback as useCallback9, useRef as useRef8, useMemo as useMemo5, useEffect as useEffect8 } from "react";
|
|
4772
5011
|
function usePromptState({
|
|
4773
5012
|
systemPrompt,
|
|
4774
5013
|
clientRef,
|
|
@@ -4776,8 +5015,8 @@ function usePromptState({
|
|
|
4776
5015
|
}) {
|
|
4777
5016
|
const promptsRef = useRef8(/* @__PURE__ */ new Map());
|
|
4778
5017
|
const suggestionsRef = useRef8(/* @__PURE__ */ new Map());
|
|
4779
|
-
const [suggestionsVersion, setSuggestionsVersion] =
|
|
4780
|
-
const buildStateFromPrompts =
|
|
5018
|
+
const [suggestionsVersion, setSuggestionsVersion] = useState11(0);
|
|
5019
|
+
const buildStateFromPrompts = useCallback9(() => {
|
|
4781
5020
|
const promptParts = [];
|
|
4782
5021
|
if (systemPrompt) {
|
|
4783
5022
|
promptParts.push(systemPrompt);
|
|
@@ -4794,7 +5033,7 @@ function usePromptState({
|
|
|
4794
5033
|
clientRef.current.updateState(buildStateFromPrompts());
|
|
4795
5034
|
}
|
|
4796
5035
|
}, [connected, clientRef, systemPrompt, buildStateFromPrompts]);
|
|
4797
|
-
const updatePrompt =
|
|
5036
|
+
const updatePrompt = useCallback9((id, prompt, suggestions) => {
|
|
4798
5037
|
if (prompt) {
|
|
4799
5038
|
promptsRef.current.set(id, prompt);
|
|
4800
5039
|
} else {
|
|
@@ -4827,14 +5066,14 @@ function usePromptState({
|
|
|
4827
5066
|
}
|
|
4828
5067
|
|
|
4829
5068
|
// src/hooks/useFeedback.ts
|
|
4830
|
-
import { useState as
|
|
5069
|
+
import { useState as useState12, useEffect as useEffect9, useRef as useRef9, useCallback as useCallback10 } from "react";
|
|
4831
5070
|
function useFeedback({
|
|
4832
5071
|
clientRef,
|
|
4833
5072
|
repository,
|
|
4834
5073
|
getDisplayedChatId,
|
|
4835
5074
|
setMessages
|
|
4836
5075
|
}) {
|
|
4837
|
-
const [enabled, setEnabled] =
|
|
5076
|
+
const [enabled, setEnabled] = useState12(false);
|
|
4838
5077
|
const enabledRef = useRef9(false);
|
|
4839
5078
|
useEffect9(() => {
|
|
4840
5079
|
enabledRef.current = enabled;
|
|
@@ -4847,7 +5086,7 @@ function useFeedback({
|
|
|
4847
5086
|
});
|
|
4848
5087
|
return unsubscribe;
|
|
4849
5088
|
}, [clientRef.current]);
|
|
4850
|
-
const updateFeedbackInStorage =
|
|
5089
|
+
const updateFeedbackInStorage = useCallback10(async (messageId, feedback) => {
|
|
4851
5090
|
const displayedChatId = getDisplayedChatId();
|
|
4852
5091
|
if (!displayedChatId) {
|
|
4853
5092
|
console.warn("[useFeedback] No chat ID, cannot update feedback");
|
|
@@ -4875,7 +5114,7 @@ function useFeedback({
|
|
|
4875
5114
|
console.error("[useFeedback] Failed to update feedback:", error);
|
|
4876
5115
|
}
|
|
4877
5116
|
}, [repository, getDisplayedChatId, setMessages]);
|
|
4878
|
-
const submitFeedback =
|
|
5117
|
+
const submitFeedback = useCallback10((messageId, traceId, feedback) => {
|
|
4879
5118
|
updateFeedbackInStorage(messageId, feedback);
|
|
4880
5119
|
const client = clientRef.current;
|
|
4881
5120
|
if (client && enabledRef.current) {
|
|
@@ -4889,7 +5128,7 @@ function useFeedback({
|
|
|
4889
5128
|
}
|
|
4890
5129
|
|
|
4891
5130
|
// src/hooks/useServerEvents.ts
|
|
4892
|
-
import { useState as
|
|
5131
|
+
import { useState as useState13, useCallback as useCallback11, useRef as useRef10 } from "react";
|
|
4893
5132
|
|
|
4894
5133
|
// src/types.ts
|
|
4895
5134
|
import { EventType as EventType2, ErrorCode, TOOL_APPROVAL_REQUEST } from "@meetsmore-oss/use-ai-core";
|
|
@@ -4900,14 +5139,15 @@ function useServerEvents({
|
|
|
4900
5139
|
saveAIResponse,
|
|
4901
5140
|
strings
|
|
4902
5141
|
}) {
|
|
4903
|
-
const [loading, setLoading] =
|
|
4904
|
-
const [streamingText, setStreamingText] =
|
|
5142
|
+
const [loading, setLoading] = useState13(false);
|
|
5143
|
+
const [streamingText, setStreamingText] = useState13("");
|
|
5144
|
+
const [streamingReasoning, setStreamingReasoning] = useState13("");
|
|
4905
5145
|
const streamingChatIdRef = useRef10(null);
|
|
4906
5146
|
const messageCountAtRunStartRef = useRef10(0);
|
|
4907
5147
|
const hasTextFromPriorStepRef = useRef10(false);
|
|
4908
|
-
const [executingToolRaw, setExecutingTool] =
|
|
5148
|
+
const [executingToolRaw, setExecutingTool] = useState13(null);
|
|
4909
5149
|
const executingToolFallbackRef = useRef10(null);
|
|
4910
|
-
const clearStreamingText =
|
|
5150
|
+
const clearStreamingText = useCallback11(() => {
|
|
4911
5151
|
setStreamingText("");
|
|
4912
5152
|
}, []);
|
|
4913
5153
|
const toolSystemRef = useRef10(toolSystem);
|
|
@@ -4916,12 +5156,18 @@ function useServerEvents({
|
|
|
4916
5156
|
saveAIResponseRef.current = saveAIResponse;
|
|
4917
5157
|
const stringsRef = useRef10(strings);
|
|
4918
5158
|
stringsRef.current = strings;
|
|
4919
|
-
const handleServerEvent =
|
|
5159
|
+
const handleServerEvent = useCallback11(async (client, event) => {
|
|
4920
5160
|
const ts = toolSystemRef.current;
|
|
4921
5161
|
const strs = stringsRef.current;
|
|
4922
5162
|
if (event.type === EventType2.RUN_STARTED) {
|
|
4923
5163
|
messageCountAtRunStartRef.current = client.messages.length;
|
|
4924
5164
|
hasTextFromPriorStepRef.current = false;
|
|
5165
|
+
setStreamingReasoning("");
|
|
5166
|
+
} else if (event.type === EventType2.REASONING_MESSAGE_START) {
|
|
5167
|
+
setStreamingReasoning((prev) => prev ? prev + "\n\n" : prev);
|
|
5168
|
+
} else if (event.type === EventType2.REASONING_MESSAGE_CONTENT) {
|
|
5169
|
+
const reasoningEvent = event;
|
|
5170
|
+
setStreamingReasoning((prev) => prev + reasoningEvent.delta);
|
|
4925
5171
|
} else if (event.type === EventType2.TEXT_MESSAGE_START) {
|
|
4926
5172
|
if (hasTextFromPriorStepRef.current) {
|
|
4927
5173
|
setStreamingText((prev) => prev + "\n\n");
|
|
@@ -4971,9 +5217,11 @@ function useServerEvents({
|
|
|
4971
5217
|
const finishedEvent = event;
|
|
4972
5218
|
const traceId = finishedEvent.runId;
|
|
4973
5219
|
const turnMessages = extractTurnMessages(client.messages, messageCountAtRunStartRef.current);
|
|
4974
|
-
|
|
5220
|
+
const reasoningParts = client.currentReasoningBlocks.length > 0 ? [...client.currentReasoningBlocks] : void 0;
|
|
5221
|
+
saveAIResponseRef.current(content, void 0, traceId, turnMessages, reasoningParts);
|
|
4975
5222
|
}
|
|
4976
5223
|
setStreamingText("");
|
|
5224
|
+
setStreamingReasoning("");
|
|
4977
5225
|
streamingChatIdRef.current = null;
|
|
4978
5226
|
setExecutingTool(null);
|
|
4979
5227
|
setLoading(false);
|
|
@@ -4984,6 +5232,7 @@ function useServerEvents({
|
|
|
4984
5232
|
const userMessage = strs.errors[errorCode] || errorEvent.message || strs.errors[ErrorCode.UNKNOWN_ERROR];
|
|
4985
5233
|
saveAIResponseRef.current(userMessage, "error");
|
|
4986
5234
|
setStreamingText("");
|
|
5235
|
+
setStreamingReasoning("");
|
|
4987
5236
|
streamingChatIdRef.current = null;
|
|
4988
5237
|
setExecutingTool(null);
|
|
4989
5238
|
setLoading(false);
|
|
@@ -4999,12 +5248,13 @@ function useServerEvents({
|
|
|
4999
5248
|
clearStreamingText,
|
|
5000
5249
|
executingTool,
|
|
5001
5250
|
streamingChatIdRef,
|
|
5251
|
+
streamingReasoning,
|
|
5002
5252
|
handleServerEvent
|
|
5003
5253
|
};
|
|
5004
5254
|
}
|
|
5005
5255
|
|
|
5006
5256
|
// src/hooks/useMessageQueue.ts
|
|
5007
|
-
import { useCallback as
|
|
5257
|
+
import { useCallback as useCallback12, useRef as useRef11, useEffect as useEffect10 } from "react";
|
|
5008
5258
|
function useMessageQueue({
|
|
5009
5259
|
sendFn,
|
|
5010
5260
|
createNewChat,
|
|
@@ -5029,7 +5279,7 @@ function useMessageQueue({
|
|
|
5029
5279
|
useEffect10(() => {
|
|
5030
5280
|
hasPendingApprovalRef.current = hasPendingApproval;
|
|
5031
5281
|
}, [hasPendingApproval]);
|
|
5032
|
-
const processMessageQueue =
|
|
5282
|
+
const processMessageQueue = useCallback12(async () => {
|
|
5033
5283
|
if (isProcessingQueueRef.current || pendingMessagesRef.current.length === 0) {
|
|
5034
5284
|
return;
|
|
5035
5285
|
}
|
|
@@ -5077,7 +5327,7 @@ function useMessageQueue({
|
|
|
5077
5327
|
}
|
|
5078
5328
|
isProcessingQueueRef.current = false;
|
|
5079
5329
|
}, []);
|
|
5080
|
-
const sendMessage =
|
|
5330
|
+
const sendMessage = useCallback12(async (message, options) => {
|
|
5081
5331
|
if (!connected) {
|
|
5082
5332
|
throw new Error("Not connected to UseAI server");
|
|
5083
5333
|
}
|
|
@@ -5088,7 +5338,7 @@ function useMessageQueue({
|
|
|
5088
5338
|
}
|
|
5089
5339
|
|
|
5090
5340
|
// src/providers/useAIProvider.tsx
|
|
5091
|
-
import { Fragment as Fragment3, jsx as
|
|
5341
|
+
import { Fragment as Fragment3, jsx as jsx15, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
5092
5342
|
var __UseAIContext = createContext4(null);
|
|
5093
5343
|
var hasWarnedAboutMissingProvider = false;
|
|
5094
5344
|
var noOpContextValue = {
|
|
@@ -5170,11 +5420,11 @@ function UseAIProvider({
|
|
|
5170
5420
|
const fileUploadConfig = fileUploadConfigProp === false ? void 0 : fileUploadConfigProp ?? DEFAULT_FILE_UPLOAD_CONFIG;
|
|
5171
5421
|
const theme = { ...defaultTheme, ...customTheme };
|
|
5172
5422
|
const strings = { ...defaultStrings, ...customStrings };
|
|
5173
|
-
const [connected, setConnected] =
|
|
5174
|
-
const [isChatOpen, setIsChatOpen] =
|
|
5175
|
-
const [messages, setMessages] =
|
|
5176
|
-
const [fileProcessingState, setFileProcessingState] =
|
|
5177
|
-
const handleSetChatOpen =
|
|
5423
|
+
const [connected, setConnected] = useState14(false);
|
|
5424
|
+
const [isChatOpen, setIsChatOpen] = useState14(false);
|
|
5425
|
+
const [messages, setMessages] = useState14([]);
|
|
5426
|
+
const [fileProcessingState, setFileProcessingState] = useState14(null);
|
|
5427
|
+
const handleSetChatOpen = useCallback13((open) => {
|
|
5178
5428
|
setIsChatOpen(open);
|
|
5179
5429
|
onOpenChange?.(open);
|
|
5180
5430
|
}, [onOpenChange]);
|
|
@@ -5270,7 +5520,7 @@ function UseAIProvider({
|
|
|
5270
5520
|
console.error("Failed to register tools:", err);
|
|
5271
5521
|
}
|
|
5272
5522
|
}, [toolSystem.hasTools, toolSystem.aggregatedTools, connected]);
|
|
5273
|
-
const handleSendMessage =
|
|
5523
|
+
const handleSendMessage = useCallback13(async (message, attachments, messageForwardedProps) => {
|
|
5274
5524
|
if (!clientRef.current) return;
|
|
5275
5525
|
serverEvents.clearStreamingText();
|
|
5276
5526
|
const activatedChatId = chatManagement.activatePendingChat();
|
|
@@ -5384,12 +5634,14 @@ function UseAIProvider({
|
|
|
5384
5634
|
}
|
|
5385
5635
|
};
|
|
5386
5636
|
const effectiveStreamingText = serverEvents.streamingChatIdRef.current === chatManagement.displayedChatId ? serverEvents.streamingText : "";
|
|
5637
|
+
const effectiveStreamingReasoning = serverEvents.streamingChatIdRef.current === chatManagement.displayedChatId ? serverEvents.streamingReasoning : "";
|
|
5387
5638
|
const chatUIContextValue = {
|
|
5388
5639
|
connected,
|
|
5389
5640
|
loading: serverEvents.loading,
|
|
5390
5641
|
sendMessage: handleSendMessage,
|
|
5391
5642
|
messages,
|
|
5392
5643
|
streamingText: effectiveStreamingText,
|
|
5644
|
+
streamingReasoning: effectiveStreamingReasoning,
|
|
5393
5645
|
suggestions: promptState.aggregatedSuggestions,
|
|
5394
5646
|
fileUploadConfig,
|
|
5395
5647
|
fileProcessing: fileProcessingState,
|
|
@@ -5439,6 +5691,7 @@ function UseAIProvider({
|
|
|
5439
5691
|
loading: serverEvents.loading,
|
|
5440
5692
|
connected,
|
|
5441
5693
|
streamingText: effectiveStreamingText,
|
|
5694
|
+
streamingReasoning: effectiveStreamingReasoning,
|
|
5442
5695
|
currentChatId: chatManagement.displayedChatId,
|
|
5443
5696
|
onNewChat: chatManagement.createNewChat,
|
|
5444
5697
|
onLoadChat: chatManagement.loadChat,
|
|
@@ -5464,17 +5717,17 @@ function UseAIProvider({
|
|
|
5464
5717
|
};
|
|
5465
5718
|
const renderDefaultChat = () => {
|
|
5466
5719
|
if (isUIDisabled) return null;
|
|
5467
|
-
return /* @__PURE__ */
|
|
5720
|
+
return /* @__PURE__ */ jsx15(UseAIFloatingChatWrapper, { isOpen: isChatOpen, onClose: () => handleSetChatOpen(false), children: /* @__PURE__ */ jsx15(
|
|
5468
5721
|
UseAIChatPanel,
|
|
5469
5722
|
{
|
|
5470
5723
|
...chatPanelProps,
|
|
5471
|
-
closeButton: /* @__PURE__ */
|
|
5724
|
+
closeButton: /* @__PURE__ */ jsx15(CloseButton, { onClick: () => handleSetChatOpen(false) })
|
|
5472
5725
|
}
|
|
5473
5726
|
) });
|
|
5474
5727
|
};
|
|
5475
5728
|
const renderCustomChat = () => {
|
|
5476
5729
|
if (!CustomChat) return null;
|
|
5477
|
-
return /* @__PURE__ */
|
|
5730
|
+
return /* @__PURE__ */ jsx15(
|
|
5478
5731
|
CustomChat,
|
|
5479
5732
|
{
|
|
5480
5733
|
isOpen: isChatOpen,
|
|
@@ -5483,6 +5736,8 @@ function UseAIProvider({
|
|
|
5483
5736
|
messages,
|
|
5484
5737
|
loading: serverEvents.loading,
|
|
5485
5738
|
connected,
|
|
5739
|
+
streamingText: effectiveStreamingText,
|
|
5740
|
+
streamingReasoning: effectiveStreamingReasoning,
|
|
5486
5741
|
suggestions: promptState.aggregatedSuggestions,
|
|
5487
5742
|
availableAgents,
|
|
5488
5743
|
defaultAgent,
|
|
@@ -5493,8 +5748,8 @@ function UseAIProvider({
|
|
|
5493
5748
|
};
|
|
5494
5749
|
const renderBuiltInChat = () => {
|
|
5495
5750
|
if (!renderChat) return null;
|
|
5496
|
-
return /* @__PURE__ */
|
|
5497
|
-
ButtonComponent && /* @__PURE__ */
|
|
5751
|
+
return /* @__PURE__ */ jsxs11(Fragment3, { children: [
|
|
5752
|
+
ButtonComponent && /* @__PURE__ */ jsx15(
|
|
5498
5753
|
ButtonComponent,
|
|
5499
5754
|
{
|
|
5500
5755
|
onClick: () => handleSetChatOpen(true),
|
|
@@ -5504,7 +5759,7 @@ function UseAIProvider({
|
|
|
5504
5759
|
hasCustomChat ? renderCustomChat() : renderDefaultChat()
|
|
5505
5760
|
] });
|
|
5506
5761
|
};
|
|
5507
|
-
return /* @__PURE__ */
|
|
5762
|
+
return /* @__PURE__ */ jsx15(ThemeContext.Provider, { value: theme, children: /* @__PURE__ */ jsx15(StringsContext.Provider, { value: strings, children: /* @__PURE__ */ jsx15(__UseAIContext.Provider, { value, children: /* @__PURE__ */ jsxs11(__UseAIChatContext.Provider, { value: chatUIContextValue, children: [
|
|
5508
5763
|
children,
|
|
5509
5764
|
renderBuiltInChat()
|
|
5510
5765
|
] }) }) }) });
|
|
@@ -5598,9 +5853,9 @@ function useAI(options = {}) {
|
|
|
5598
5853
|
const { connected, tools, client, prompts } = useAIContext();
|
|
5599
5854
|
const { register: registerTools, unregister: unregisterTools, signalReady, registerWaiter, unregisterWaiter } = tools;
|
|
5600
5855
|
const { update: updatePrompt } = prompts;
|
|
5601
|
-
const [response, setResponse] =
|
|
5602
|
-
const [loading, setLoading] =
|
|
5603
|
-
const [error, setError] =
|
|
5856
|
+
const [response, setResponse] = useState15(null);
|
|
5857
|
+
const [loading, setLoading] = useState15(false);
|
|
5858
|
+
const [error, setError] = useState15(null);
|
|
5604
5859
|
const hookId = useRef14(`useAI-${Math.random().toString(36).substr(2, 9)}`);
|
|
5605
5860
|
const toolsRef = useRef14({});
|
|
5606
5861
|
const componentRef = useRef14(null);
|
|
@@ -5616,7 +5871,7 @@ function useAI(options = {}) {
|
|
|
5616
5871
|
componentRef.current.setAttribute("data-useai-context", "true");
|
|
5617
5872
|
}
|
|
5618
5873
|
}, []);
|
|
5619
|
-
const waitForPromptChange =
|
|
5874
|
+
const waitForPromptChange = useCallback14(() => {
|
|
5620
5875
|
return new Promise((resolve) => {
|
|
5621
5876
|
const timeoutMs = 100;
|
|
5622
5877
|
const timeoutId = setTimeout(() => {
|
|
@@ -5680,7 +5935,7 @@ function useAI(options = {}) {
|
|
|
5680
5935
|
unsubscribe();
|
|
5681
5936
|
};
|
|
5682
5937
|
}, [enabled, client]);
|
|
5683
|
-
const handleAGUIEvent =
|
|
5938
|
+
const handleAGUIEvent = useCallback14(async (event) => {
|
|
5684
5939
|
switch (event.type) {
|
|
5685
5940
|
case EventType2.TEXT_MESSAGE_END: {
|
|
5686
5941
|
const content = client?.currentMessageContent;
|
|
@@ -5700,7 +5955,7 @@ function useAI(options = {}) {
|
|
|
5700
5955
|
}
|
|
5701
5956
|
}
|
|
5702
5957
|
}, [client, options.onError]);
|
|
5703
|
-
const generate =
|
|
5958
|
+
const generate = useCallback14(async (prompt) => {
|
|
5704
5959
|
if (!enabled) {
|
|
5705
5960
|
const error2 = new Error("AI features are disabled");
|
|
5706
5961
|
setError(error2);
|
|
@@ -5736,17 +5991,17 @@ function useAI(options = {}) {
|
|
|
5736
5991
|
}
|
|
5737
5992
|
|
|
5738
5993
|
// src/useAIWorkflow.ts
|
|
5739
|
-
import { useState as
|
|
5994
|
+
import { useState as useState16, useCallback as useCallback15, useRef as useRef15, useEffect as useEffect13 } from "react";
|
|
5740
5995
|
import { EventType as EventType3 } from "@meetsmore-oss/use-ai-core";
|
|
5741
5996
|
import { v4 as uuidv43 } from "uuid";
|
|
5742
5997
|
function useAIWorkflow(runner, workflowId) {
|
|
5743
5998
|
const { connected, client } = useAIContext();
|
|
5744
|
-
const [status, setStatus] =
|
|
5745
|
-
const [text, setText] =
|
|
5746
|
-
const [error, setError] =
|
|
5999
|
+
const [status, setStatus] = useState16("idle");
|
|
6000
|
+
const [text, setText] = useState16(null);
|
|
6001
|
+
const [error, setError] = useState16(null);
|
|
5747
6002
|
const currentWorkflowRef = useRef15(null);
|
|
5748
6003
|
const eventListenerIdRef = useRef15(`useAIWorkflow-${Math.random().toString(36).substr(2, 9)}`);
|
|
5749
|
-
const handleWorkflowEvent =
|
|
6004
|
+
const handleWorkflowEvent = useCallback15(async (event) => {
|
|
5750
6005
|
const currentWorkflow = currentWorkflowRef.current;
|
|
5751
6006
|
if (!currentWorkflow) return;
|
|
5752
6007
|
if (event.type === EventType3.RUN_STARTED) {
|
|
@@ -5841,7 +6096,7 @@ function useAIWorkflow(runner, workflowId) {
|
|
|
5841
6096
|
unsubscribe();
|
|
5842
6097
|
};
|
|
5843
6098
|
}, [client, handleWorkflowEvent]);
|
|
5844
|
-
const trigger =
|
|
6099
|
+
const trigger = useCallback15(async (options) => {
|
|
5845
6100
|
if (!client?.isConnected()) {
|
|
5846
6101
|
const err = new Error("Not connected to server");
|
|
5847
6102
|
setError(err);
|