@hef2024/llmasaservice-ui 0.19.1 → 0.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AICHATPANEL-PORT-INVENTORY.md +831 -0
- package/DEBUG-ERROR-HANDLING.md +131 -0
- package/FIX-APPLIED.md +235 -0
- package/IMPLEMENTATION-COMPLETE.md +247 -0
- package/README.md +1 -0
- package/dist/index.css +635 -1
- package/dist/index.d.mts +37 -1
- package/dist/index.d.ts +37 -1
- package/dist/index.js +1241 -454
- package/dist/index.mjs +1083 -296
- package/docs/CHANGELOG-ERROR-HANDLING.md +248 -0
- package/docs/CONVERSATION-HISTORY.md +1 -0
- package/docs/ERROR-HANDLING-413.md +254 -0
- package/docs/ERROR-HANDLING-SUMMARY.md +132 -0
- package/package.json +2 -2
- package/src/AIAgentPanel.tsx +97 -1
- package/src/AIChatPanel.css +656 -1
- package/src/AIChatPanel.tsx +914 -69
- package/src/AgentPanel.tsx +3 -1
- package/src/ChatPanel.css +111 -0
- package/src/ChatPanel.tsx +169 -33
- package/src/components/ui/Button.tsx +1 -0
- package/src/components/ui/Dialog.tsx +1 -0
- package/src/components/ui/Input.tsx +1 -0
- package/src/components/ui/Select.tsx +1 -0
- package/src/components/ui/ToolInfoModal.tsx +66 -0
- package/src/components/ui/Tooltip.tsx +1 -0
- package/src/components/ui/index.ts +1 -0
- package/src/hooks/useAgentRegistry.ts +1 -0
package/dist/index.mjs
CHANGED
|
@@ -234,6 +234,7 @@ var ChatPanel = ({
|
|
|
234
234
|
const [alwaysApprovedTools, setAlwaysApprovedTools] = useState2([]);
|
|
235
235
|
const [thinkingBlocks, setThinkingBlocks] = useState2([]);
|
|
236
236
|
const [currentThinkingIndex, setCurrentThinkingIndex] = useState2(0);
|
|
237
|
+
const [error, setError] = useState2(null);
|
|
237
238
|
const [userResizedHeight, setUserResizedHeight] = useState2(null);
|
|
238
239
|
const [pendingButtonAttachments, setPendingButtonAttachments] = useState2([]);
|
|
239
240
|
const actionMatchRegistry = useRef(/* @__PURE__ */ new Map());
|
|
@@ -535,10 +536,10 @@ var ChatPanel = ({
|
|
|
535
536
|
const allTools = results.flat();
|
|
536
537
|
setToolList(allTools);
|
|
537
538
|
setToolsFetchError(false);
|
|
538
|
-
} catch (
|
|
539
|
+
} catch (error2) {
|
|
539
540
|
console.error(
|
|
540
541
|
"An error occurred while processing tool fetches:",
|
|
541
|
-
|
|
542
|
+
error2
|
|
542
543
|
);
|
|
543
544
|
setToolList([]);
|
|
544
545
|
setToolsFetchError(true);
|
|
@@ -548,7 +549,7 @@ var ChatPanel = ({
|
|
|
548
549
|
});
|
|
549
550
|
fetchAndSetTools();
|
|
550
551
|
}, [mcpServers, publicAPIUrl]);
|
|
551
|
-
const
|
|
552
|
+
const llmResult = useLLM({
|
|
552
553
|
project_id,
|
|
553
554
|
customer: currentCustomer,
|
|
554
555
|
url,
|
|
@@ -561,6 +562,41 @@ var ChatPanel = ({
|
|
|
561
562
|
};
|
|
562
563
|
})
|
|
563
564
|
});
|
|
565
|
+
const { send, response, idle, stop, lastCallId, setResponse, error: llmError } = llmResult;
|
|
566
|
+
const handleError = useCallback((errorMessage, historyKey) => {
|
|
567
|
+
console.log("[ChatPanel] Error detected:", errorMessage);
|
|
568
|
+
if (errorMessage.includes("413") || errorMessage.toLowerCase().includes("content too large")) {
|
|
569
|
+
setError({
|
|
570
|
+
message: "The context is too large to process. Please start a new conversation or reduce the amount of context.",
|
|
571
|
+
code: "413"
|
|
572
|
+
});
|
|
573
|
+
} else if (errorMessage.toLowerCase().includes("network error") || errorMessage.toLowerCase().includes("fetch")) {
|
|
574
|
+
setError({
|
|
575
|
+
message: "Network error. Please check your connection and try again.",
|
|
576
|
+
code: "NETWORK_ERROR"
|
|
577
|
+
});
|
|
578
|
+
} else {
|
|
579
|
+
setError({
|
|
580
|
+
message: errorMessage,
|
|
581
|
+
code: "UNKNOWN_ERROR"
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
setIsLoading(false);
|
|
585
|
+
const keyToUse = historyKey || lastKey;
|
|
586
|
+
if (keyToUse) {
|
|
587
|
+
setHistory((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
588
|
+
[keyToUse]: {
|
|
589
|
+
content: `Error: ${errorMessage}`,
|
|
590
|
+
callId: lastCallId || ""
|
|
591
|
+
}
|
|
592
|
+
}));
|
|
593
|
+
}
|
|
594
|
+
}, [lastKey, lastCallId]);
|
|
595
|
+
useEffect2(() => {
|
|
596
|
+
if (llmError && llmError.trim()) {
|
|
597
|
+
handleError(llmError);
|
|
598
|
+
}
|
|
599
|
+
}, [llmError, handleError]);
|
|
564
600
|
const processActionsOnContent = useCallback((content, context) => {
|
|
565
601
|
let workingContent = content;
|
|
566
602
|
const buttonAttachments = [];
|
|
@@ -897,8 +933,8 @@ var ChatPanel = ({
|
|
|
897
933
|
return action;
|
|
898
934
|
}
|
|
899
935
|
}).filter(Boolean);
|
|
900
|
-
} catch (
|
|
901
|
-
console.error("Error parsing actions string:",
|
|
936
|
+
} catch (error2) {
|
|
937
|
+
console.error("Error parsing actions string:", error2);
|
|
902
938
|
actions2 = [];
|
|
903
939
|
}
|
|
904
940
|
}
|
|
@@ -1086,8 +1122,8 @@ var ChatPanel = ({
|
|
|
1086
1122
|
console.error(`No content returned from tool ${req.toolName}`);
|
|
1087
1123
|
return null;
|
|
1088
1124
|
}
|
|
1089
|
-
} catch (
|
|
1090
|
-
console.error(`Error processing tool ${req.toolName}:`,
|
|
1125
|
+
} catch (error2) {
|
|
1126
|
+
console.error(`Error processing tool ${req.toolName}:`, error2);
|
|
1091
1127
|
return null;
|
|
1092
1128
|
}
|
|
1093
1129
|
}));
|
|
@@ -1129,10 +1165,14 @@ var ChatPanel = ({
|
|
|
1129
1165
|
true,
|
|
1130
1166
|
service,
|
|
1131
1167
|
currentConversation,
|
|
1132
|
-
lastController
|
|
1168
|
+
lastController,
|
|
1169
|
+
void 0,
|
|
1170
|
+
// onComplete
|
|
1171
|
+
(errorMsg) => handleError(errorMsg)
|
|
1172
|
+
// onError
|
|
1133
1173
|
);
|
|
1134
|
-
} catch (
|
|
1135
|
-
console.error("Error in processing all tools:",
|
|
1174
|
+
} catch (error2) {
|
|
1175
|
+
console.error("Error in processing all tools:", error2);
|
|
1136
1176
|
setIsLoading(false);
|
|
1137
1177
|
}
|
|
1138
1178
|
});
|
|
@@ -1264,8 +1304,8 @@ var ChatPanel = ({
|
|
|
1264
1304
|
if (typeof interactionClicked === "function") {
|
|
1265
1305
|
interactionClicked(lastCallId, "action");
|
|
1266
1306
|
}
|
|
1267
|
-
} catch (
|
|
1268
|
-
console.error("Error executing clickCode:",
|
|
1307
|
+
} catch (error2) {
|
|
1308
|
+
console.error("Error executing clickCode:", error2);
|
|
1269
1309
|
}
|
|
1270
1310
|
}
|
|
1271
1311
|
};
|
|
@@ -1360,10 +1400,10 @@ var ChatPanel = ({
|
|
|
1360
1400
|
if (typeof interactionClicked === "function") {
|
|
1361
1401
|
interactionClicked(lastCallId, "action");
|
|
1362
1402
|
}
|
|
1363
|
-
} catch (
|
|
1403
|
+
} catch (error2) {
|
|
1364
1404
|
console.error(
|
|
1365
1405
|
"Error executing clickCode via delegation:",
|
|
1366
|
-
|
|
1406
|
+
error2
|
|
1367
1407
|
);
|
|
1368
1408
|
}
|
|
1369
1409
|
}
|
|
@@ -1475,7 +1515,11 @@ var ChatPanel = ({
|
|
|
1475
1515
|
true,
|
|
1476
1516
|
service,
|
|
1477
1517
|
convId,
|
|
1478
|
-
controller
|
|
1518
|
+
controller,
|
|
1519
|
+
void 0,
|
|
1520
|
+
// onComplete
|
|
1521
|
+
(errorMsg) => handleError(errorMsg)
|
|
1522
|
+
// onError
|
|
1479
1523
|
);
|
|
1480
1524
|
setLastPrompt(initialPrompt);
|
|
1481
1525
|
setLastMessages(messages);
|
|
@@ -1571,8 +1615,8 @@ var ChatPanel = ({
|
|
|
1571
1615
|
return newConvo.id;
|
|
1572
1616
|
}
|
|
1573
1617
|
return "";
|
|
1574
|
-
}).catch((
|
|
1575
|
-
console.error("Error creating new conversation",
|
|
1618
|
+
}).catch((error2) => {
|
|
1619
|
+
console.error("Error creating new conversation", error2);
|
|
1576
1620
|
return "";
|
|
1577
1621
|
});
|
|
1578
1622
|
}
|
|
@@ -1621,7 +1665,7 @@ var ChatPanel = ({
|
|
|
1621
1665
|
customerEmail: updatedValues.customer_user_email
|
|
1622
1666
|
})
|
|
1623
1667
|
}).catch(
|
|
1624
|
-
(
|
|
1668
|
+
(error2) => console.error("Failed to update conversation:", error2)
|
|
1625
1669
|
);
|
|
1626
1670
|
}
|
|
1627
1671
|
});
|
|
@@ -1631,6 +1675,7 @@ var ChatPanel = ({
|
|
|
1631
1675
|
const continueChat = (suggestion) => {
|
|
1632
1676
|
setThinkingBlocks([]);
|
|
1633
1677
|
setCurrentThinkingIndex(0);
|
|
1678
|
+
setError(null);
|
|
1634
1679
|
setResponse("");
|
|
1635
1680
|
if (emailInput && isEmailAddress(emailInput) && !emailInputSet) {
|
|
1636
1681
|
const newId = (currentCustomer == null ? void 0 : currentCustomer.customer_id) && currentCustomer.customer_id !== "" && currentCustomer.customer_id !== (currentCustomer == null ? void 0 : currentCustomer.customer_user_email) ? currentCustomer.customer_id : emailInput;
|
|
@@ -1726,7 +1771,11 @@ var ChatPanel = ({
|
|
|
1726
1771
|
true,
|
|
1727
1772
|
service,
|
|
1728
1773
|
convId,
|
|
1729
|
-
controller
|
|
1774
|
+
controller,
|
|
1775
|
+
void 0,
|
|
1776
|
+
// onComplete
|
|
1777
|
+
(errorMsg) => handleError(errorMsg)
|
|
1778
|
+
// onError
|
|
1730
1779
|
);
|
|
1731
1780
|
setLastPrompt(nextPromptToSend);
|
|
1732
1781
|
setLastMessages(messagesAndHistory);
|
|
@@ -1816,16 +1865,16 @@ var ChatPanel = ({
|
|
|
1816
1865
|
return /* @__PURE__ */ React3.createElement("a", __spreadValues({ href, target: "_blank", rel: "noopener noreferrer" }, props), children);
|
|
1817
1866
|
};
|
|
1818
1867
|
const convertMarkdownToHTML = (markdown) => {
|
|
1868
|
+
const markdownContent = /* @__PURE__ */ React3.createElement(
|
|
1869
|
+
ReactMarkdown,
|
|
1870
|
+
{
|
|
1871
|
+
remarkPlugins: [remarkGfm],
|
|
1872
|
+
rehypePlugins: [rehypeRaw]
|
|
1873
|
+
},
|
|
1874
|
+
markdown
|
|
1875
|
+
);
|
|
1819
1876
|
const html = ReactDOMServer.renderToStaticMarkup(
|
|
1820
|
-
/* @__PURE__ */ React3.createElement(
|
|
1821
|
-
ReactMarkdown,
|
|
1822
|
-
{
|
|
1823
|
-
className: markdownClass,
|
|
1824
|
-
remarkPlugins: [remarkGfm],
|
|
1825
|
-
rehypePlugins: [rehypeRaw]
|
|
1826
|
-
},
|
|
1827
|
-
markdown
|
|
1828
|
-
)
|
|
1877
|
+
markdownClass ? /* @__PURE__ */ React3.createElement("div", { className: markdownClass }, markdownContent) : markdownContent
|
|
1829
1878
|
);
|
|
1830
1879
|
return html;
|
|
1831
1880
|
};
|
|
@@ -2045,10 +2094,25 @@ var ChatPanel = ({
|
|
|
2045
2094
|
className: "llm-panel" + (theme === "light" ? "" : " dark-theme")
|
|
2046
2095
|
},
|
|
2047
2096
|
title && title !== "" ? /* @__PURE__ */ React3.createElement("div", { className: "title" }, title) : null,
|
|
2048
|
-
/* @__PURE__ */ React3.createElement("div", { className: "
|
|
2097
|
+
error && /* @__PURE__ */ React3.createElement("div", { className: "error-banner" }, /* @__PURE__ */ React3.createElement("div", { className: "error-banner__icon" }, /* @__PURE__ */ React3.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, /* @__PURE__ */ React3.createElement("circle", { cx: "12", cy: "12", r: "10" }), /* @__PURE__ */ React3.createElement("line", { x1: "12", x2: "12", y1: "8", y2: "12" }), /* @__PURE__ */ React3.createElement("line", { x1: "12", x2: "12.01", y1: "16", y2: "16" }))), /* @__PURE__ */ React3.createElement("div", { className: "error-banner__content" }, /* @__PURE__ */ React3.createElement("div", { className: "error-banner__message" }, error.message), error.code === "413" && /* @__PURE__ */ React3.createElement("div", { className: "error-banner__hint" }, "Try starting a new conversation or reducing the amount of information being sent.")), /* @__PURE__ */ React3.createElement(
|
|
2098
|
+
"button",
|
|
2099
|
+
{
|
|
2100
|
+
className: "error-banner__close",
|
|
2101
|
+
onClick: () => setError(null),
|
|
2102
|
+
"aria-label": "Dismiss error"
|
|
2103
|
+
},
|
|
2104
|
+
/* @__PURE__ */ React3.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, /* @__PURE__ */ React3.createElement("line", { x1: "18", x2: "6", y1: "6", y2: "18" }), /* @__PURE__ */ React3.createElement("line", { x1: "6", x2: "18", y1: "6", y2: "18" }))
|
|
2105
|
+
)),
|
|
2106
|
+
/* @__PURE__ */ React3.createElement("div", { className: "responseArea", ref: responseAreaRef }, initialMessage && initialMessage !== "" ? /* @__PURE__ */ React3.createElement("div", { className: "history-entry" }, /* @__PURE__ */ React3.createElement("div", { className: "response" }, markdownClass ? /* @__PURE__ */ React3.createElement("div", { className: markdownClass }, /* @__PURE__ */ React3.createElement(
|
|
2107
|
+
ReactMarkdown,
|
|
2108
|
+
{
|
|
2109
|
+
remarkPlugins: [remarkGfm],
|
|
2110
|
+
rehypePlugins: [rehypeRaw]
|
|
2111
|
+
},
|
|
2112
|
+
initialMessage
|
|
2113
|
+
)) : /* @__PURE__ */ React3.createElement(
|
|
2049
2114
|
ReactMarkdown,
|
|
2050
2115
|
{
|
|
2051
|
-
className: markdownClass,
|
|
2052
2116
|
remarkPlugins: [remarkGfm],
|
|
2053
2117
|
rehypePlugins: [rehypeRaw]
|
|
2054
2118
|
},
|
|
@@ -2073,10 +2137,9 @@ var ChatPanel = ({
|
|
|
2073
2137
|
return null;
|
|
2074
2138
|
})(), (() => {
|
|
2075
2139
|
if (lastKey && history[lastKey] && history[lastKey].content) {
|
|
2076
|
-
|
|
2140
|
+
const content = /* @__PURE__ */ React3.createElement(
|
|
2077
2141
|
ReactMarkdown,
|
|
2078
2142
|
{
|
|
2079
|
-
className: markdownClass,
|
|
2080
2143
|
remarkPlugins: [remarkGfm],
|
|
2081
2144
|
rehypePlugins: [rehypeRaw],
|
|
2082
2145
|
components: {
|
|
@@ -2086,27 +2149,41 @@ var ChatPanel = ({
|
|
|
2086
2149
|
},
|
|
2087
2150
|
history[lastKey].content
|
|
2088
2151
|
);
|
|
2152
|
+
return markdownClass ? /* @__PURE__ */ React3.createElement("div", { className: markdownClass }, content) : content;
|
|
2089
2153
|
}
|
|
2090
2154
|
const { cleanedText } = processThinkingTags(
|
|
2091
2155
|
response || ""
|
|
2092
2156
|
);
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2157
|
+
if (cleanedText && cleanedText.length > 0) {
|
|
2158
|
+
const content = /* @__PURE__ */ React3.createElement(
|
|
2159
|
+
ReactMarkdown,
|
|
2160
|
+
{
|
|
2161
|
+
remarkPlugins: [remarkGfm],
|
|
2162
|
+
rehypePlugins: [rehypeRaw],
|
|
2163
|
+
components: {
|
|
2164
|
+
/*a: CustomLink,*/
|
|
2165
|
+
code: CodeBlock
|
|
2166
|
+
}
|
|
2167
|
+
},
|
|
2168
|
+
cleanedText
|
|
2169
|
+
);
|
|
2170
|
+
return markdownClass ? /* @__PURE__ */ React3.createElement("div", { className: markdownClass }, content) : content;
|
|
2171
|
+
}
|
|
2172
|
+
return null;
|
|
2173
|
+
})()) : /* @__PURE__ */ React3.createElement("div", null, isLastEntry && thinkingBlocks.length > 0 && renderThinkingBlocks(), markdownClass ? /* @__PURE__ */ React3.createElement("div", { className: markdownClass }, /* @__PURE__ */ React3.createElement(
|
|
2174
|
+
ReactMarkdown,
|
|
2175
|
+
{
|
|
2176
|
+
remarkPlugins: [remarkGfm],
|
|
2177
|
+
rehypePlugins: [rehypeRaw],
|
|
2178
|
+
components: {
|
|
2179
|
+
/*a: CustomLink,*/
|
|
2180
|
+
code: CodeBlock
|
|
2181
|
+
}
|
|
2182
|
+
},
|
|
2183
|
+
processThinkingTags(historyEntry.content).cleanedText
|
|
2184
|
+
)) : /* @__PURE__ */ React3.createElement(
|
|
2107
2185
|
ReactMarkdown,
|
|
2108
2186
|
{
|
|
2109
|
-
className: markdownClass,
|
|
2110
2187
|
remarkPlugins: [remarkGfm],
|
|
2111
2188
|
rehypePlugins: [rehypeRaw],
|
|
2112
2189
|
components: {
|
|
@@ -2354,6 +2431,7 @@ var ChatPanel = ({
|
|
|
2354
2431
|
setIsToolInfoModalOpen(false);
|
|
2355
2432
|
setToolInfoData(null);
|
|
2356
2433
|
setJustReset(true);
|
|
2434
|
+
setError(null);
|
|
2357
2435
|
setLastController(new AbortController());
|
|
2358
2436
|
buttonActionRegistry.current.clear();
|
|
2359
2437
|
setTimeout(() => {
|
|
@@ -2853,7 +2931,7 @@ var AgentPanel = ({
|
|
|
2853
2931
|
useEffect3(() => {
|
|
2854
2932
|
const fetchAgentData = () => __async(void 0, null, function* () {
|
|
2855
2933
|
try {
|
|
2856
|
-
const fetchUrl = `https://api.llmasaservice.io/agents/${agent}`;
|
|
2934
|
+
const fetchUrl = url.endsWith("dev") ? `https://8ftw8droff.execute-api.us-east-1.amazonaws.com/dev/agents/${agent}` : `https://api.llmasaservice.io/agents/${agent}`;
|
|
2857
2935
|
const response = yield fetch(fetchUrl, {
|
|
2858
2936
|
method: "GET",
|
|
2859
2937
|
headers: {
|
|
@@ -2961,16 +3039,17 @@ var AgentPanel = ({
|
|
|
2961
3039
|
var AgentPanel_default = AgentPanel;
|
|
2962
3040
|
|
|
2963
3041
|
// src/AIAgentPanel.tsx
|
|
2964
|
-
import
|
|
3042
|
+
import React13, { useCallback as useCallback4, useEffect as useEffect9, useMemo as useMemo4, useRef as useRef6, useState as useState8 } from "react";
|
|
2965
3043
|
|
|
2966
3044
|
// src/AIChatPanel.tsx
|
|
2967
|
-
import
|
|
3045
|
+
import React12, {
|
|
2968
3046
|
useCallback as useCallback2,
|
|
2969
3047
|
useEffect as useEffect7,
|
|
2970
3048
|
useMemo as useMemo2,
|
|
2971
3049
|
useRef as useRef5,
|
|
2972
3050
|
useState as useState6
|
|
2973
3051
|
} from "react";
|
|
3052
|
+
import ReactDOMServer2 from "react-dom/server";
|
|
2974
3053
|
import { useLLM as useLLM2 } from "llmasaservice-client";
|
|
2975
3054
|
import ReactMarkdown2 from "react-markdown";
|
|
2976
3055
|
import remarkGfm2 from "remark-gfm";
|
|
@@ -3312,20 +3391,69 @@ var DialogFooter = ({
|
|
|
3312
3391
|
return /* @__PURE__ */ React10.createElement("div", { className: `ai-dialog-footer ${className}` }, children);
|
|
3313
3392
|
};
|
|
3314
3393
|
|
|
3394
|
+
// src/components/ui/ToolInfoModal.tsx
|
|
3395
|
+
import React11 from "react";
|
|
3396
|
+
var ToolInfoModal2 = ({
|
|
3397
|
+
isOpen,
|
|
3398
|
+
onClose,
|
|
3399
|
+
data
|
|
3400
|
+
}) => {
|
|
3401
|
+
if (!isOpen || !data) return null;
|
|
3402
|
+
return /* @__PURE__ */ React11.createElement("div", { className: "ai-chat-modal-overlay", onClick: onClose }, /* @__PURE__ */ React11.createElement(
|
|
3403
|
+
"div",
|
|
3404
|
+
{
|
|
3405
|
+
className: "ai-chat-modal-content ai-chat-tool-info-modal",
|
|
3406
|
+
onClick: (e) => e.stopPropagation()
|
|
3407
|
+
},
|
|
3408
|
+
/* @__PURE__ */ React11.createElement("div", { className: "ai-chat-modal-header" }, /* @__PURE__ */ React11.createElement("h3", null, "Tool Information"), /* @__PURE__ */ React11.createElement(
|
|
3409
|
+
"button",
|
|
3410
|
+
{
|
|
3411
|
+
className: "ai-chat-modal-close",
|
|
3412
|
+
onClick: onClose,
|
|
3413
|
+
"aria-label": "Close"
|
|
3414
|
+
},
|
|
3415
|
+
"\xD7"
|
|
3416
|
+
)),
|
|
3417
|
+
/* @__PURE__ */ React11.createElement("div", { className: "ai-chat-modal-body ai-chat-tool-info-container" }, /* @__PURE__ */ React11.createElement("div", { className: "ai-chat-tool-info-section" }, /* @__PURE__ */ React11.createElement("h4", null, "Tool Calls"), /* @__PURE__ */ React11.createElement(
|
|
3418
|
+
"textarea",
|
|
3419
|
+
{
|
|
3420
|
+
className: "ai-chat-tool-info-json",
|
|
3421
|
+
readOnly: true,
|
|
3422
|
+
value: JSON.stringify(data.calls, null, 2)
|
|
3423
|
+
}
|
|
3424
|
+
)), /* @__PURE__ */ React11.createElement("div", { className: "ai-chat-tool-info-section" }, /* @__PURE__ */ React11.createElement("h4", null, "Tool Responses"), /* @__PURE__ */ React11.createElement(
|
|
3425
|
+
"textarea",
|
|
3426
|
+
{
|
|
3427
|
+
className: "ai-chat-tool-info-json",
|
|
3428
|
+
readOnly: true,
|
|
3429
|
+
value: JSON.stringify(data.responses, null, 2)
|
|
3430
|
+
}
|
|
3431
|
+
))),
|
|
3432
|
+
/* @__PURE__ */ React11.createElement("div", { className: "ai-chat-modal-footer" }, /* @__PURE__ */ React11.createElement(
|
|
3433
|
+
"button",
|
|
3434
|
+
{
|
|
3435
|
+
className: "ai-chat-modal-button ai-chat-modal-button--primary",
|
|
3436
|
+
onClick: onClose
|
|
3437
|
+
},
|
|
3438
|
+
"Close"
|
|
3439
|
+
))
|
|
3440
|
+
));
|
|
3441
|
+
};
|
|
3442
|
+
var ToolInfoModal_default2 = ToolInfoModal2;
|
|
3443
|
+
|
|
3315
3444
|
// src/AIChatPanel.tsx
|
|
3316
|
-
var ArrowUpIcon = () => /* @__PURE__ */
|
|
3317
|
-
var StopIcon = () => /* @__PURE__ */
|
|
3318
|
-
var
|
|
3319
|
-
var
|
|
3320
|
-
var
|
|
3321
|
-
var
|
|
3322
|
-
var
|
|
3323
|
-
var
|
|
3324
|
-
var
|
|
3325
|
-
var
|
|
3326
|
-
var
|
|
3327
|
-
var
|
|
3328
|
-
var ChatInput = React11.memo(({
|
|
3445
|
+
var ArrowUpIcon = () => /* @__PURE__ */ React12.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: "ai-chat-icon-sm" }, /* @__PURE__ */ React12.createElement("path", { d: "M12 19V5M5 12l7-7 7 7" }));
|
|
3446
|
+
var StopIcon = () => /* @__PURE__ */ React12.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", className: "ai-chat-icon" }, /* @__PURE__ */ React12.createElement("rect", { x: "6", y: "6", width: "12", height: "12", rx: "2" }));
|
|
3447
|
+
var ChevronDownIcon = () => /* @__PURE__ */ React12.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: "ai-chat-icon-sm" }, /* @__PURE__ */ React12.createElement("path", { d: "m6 9 6 6 6-6" }));
|
|
3448
|
+
var ChevronUpIcon = () => /* @__PURE__ */ React12.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: "ai-chat-icon-sm" }, /* @__PURE__ */ React12.createElement("path", { d: "m18 15-6-6-6 6" }));
|
|
3449
|
+
var AgentIcon = () => /* @__PURE__ */ React12.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: "ai-chat-icon-sm" }, /* @__PURE__ */ React12.createElement("path", { d: "M12 8V4H8" }), /* @__PURE__ */ React12.createElement("rect", { width: "16", height: "12", x: "4", y: "8", rx: "2" }), /* @__PURE__ */ React12.createElement("path", { d: "M2 14h2" }), /* @__PURE__ */ React12.createElement("path", { d: "M20 14h2" }), /* @__PURE__ */ React12.createElement("path", { d: "M15 13v2" }), /* @__PURE__ */ React12.createElement("path", { d: "M9 13v2" }));
|
|
3450
|
+
var CheckIcon = () => /* @__PURE__ */ React12.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: "ai-chat-icon-sm" }, /* @__PURE__ */ React12.createElement("polyline", { points: "20 6 9 17 4 12" }));
|
|
3451
|
+
var BrainIcon = () => /* @__PURE__ */ React12.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: "ai-chat-icon-sm" }, /* @__PURE__ */ React12.createElement("path", { d: "M9.5 2A2.5 2.5 0 0 1 12 4.5v15a2.5 2.5 0 0 1-4.96.44 2.5 2.5 0 0 1-2.96-3.08 3 3 0 0 1-.34-5.58 2.5 2.5 0 0 1 1.32-4.24 2.5 2.5 0 0 1 1.98-3A2.5 2.5 0 0 1 9.5 2Z" }), /* @__PURE__ */ React12.createElement("path", { d: "M14.5 2A2.5 2.5 0 0 0 12 4.5v15a2.5 2.5 0 0 0 4.96.44 2.5 2.5 0 0 0 2.96-3.08 3 3 0 0 0 .34-5.58 2.5 2.5 0 0 0-1.32-4.24 2.5 2.5 0 0 0-1.98-3A2.5 2.5 0 0 0 14.5 2Z" }));
|
|
3452
|
+
var SearchIcon = () => /* @__PURE__ */ React12.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: "ai-chat-icon-sm" }, /* @__PURE__ */ React12.createElement("circle", { cx: "11", cy: "11", r: "8" }), /* @__PURE__ */ React12.createElement("path", { d: "m21 21-4.3-4.3" }));
|
|
3453
|
+
var LLMAsAServiceLogo = () => /* @__PURE__ */ React12.createElement("svg", { width: "16", height: "16", viewBox: "0 0 72 72", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React12.createElement("ellipse", { cx: "14.0868", cy: "59.2146", rx: "7.8261", ry: "7.7854", fill: "#2487D8" }), /* @__PURE__ */ React12.createElement("ellipse", { cx: "24.9013", cy: "43.0776", rx: "6.11858", ry: "6.08676", fill: "#2487D8" }), /* @__PURE__ */ React12.createElement("ellipse", { cx: "45.391", cy: "43.0776", rx: "6.11858", ry: "6.08676", fill: "#2487D8" }), /* @__PURE__ */ React12.createElement("ellipse", { cx: "65.8813", cy: "43.0776", rx: "6.11858", ry: "6.08676", fill: "#2487D8" }), /* @__PURE__ */ React12.createElement("ellipse", { cx: "35.1461", cy: "26.5327", rx: "4.41103", ry: "4.3878", fill: "#2487D8" }), /* @__PURE__ */ React12.createElement("ellipse", { cx: "55.6364", cy: "26.5327", rx: "4.41103", ry: "4.3878", fill: "#2487D8" }), /* @__PURE__ */ React12.createElement("ellipse", { cx: "45.391", cy: "10.3959", rx: "2.70351", ry: "2.68919", fill: "#2487D8" }));
|
|
3454
|
+
var AlertCircleIcon = () => /* @__PURE__ */ React12.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: "ai-chat-icon-sm" }, /* @__PURE__ */ React12.createElement("circle", { cx: "12", cy: "12", r: "10" }), /* @__PURE__ */ React12.createElement("line", { x1: "12", x2: "12", y1: "8", y2: "12" }), /* @__PURE__ */ React12.createElement("line", { x1: "12", x2: "12.01", y1: "16", y2: "16" }));
|
|
3455
|
+
var CloseIcon = () => /* @__PURE__ */ React12.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: "ai-chat-icon-sm" }, /* @__PURE__ */ React12.createElement("line", { x1: "18", x2: "6", y1: "6", y2: "18" }), /* @__PURE__ */ React12.createElement("line", { x1: "6", x2: "18", y1: "6", y2: "18" }));
|
|
3456
|
+
var ChatInput = React12.memo(({
|
|
3329
3457
|
placeholder,
|
|
3330
3458
|
idle,
|
|
3331
3459
|
onSubmit,
|
|
@@ -3408,13 +3536,13 @@ var ChatInput = React11.memo(({
|
|
|
3408
3536
|
if (typeof data === "string") return data;
|
|
3409
3537
|
return JSON.stringify(data, null, 2);
|
|
3410
3538
|
};
|
|
3411
|
-
return /* @__PURE__ */
|
|
3539
|
+
return /* @__PURE__ */ React12.createElement(
|
|
3412
3540
|
"div",
|
|
3413
3541
|
{
|
|
3414
3542
|
className: `ai-chat-panel__input-container ${dropdownOpen ? "ai-chat-panel__input-container--dropdown-open" : ""}`,
|
|
3415
3543
|
ref: containerRef
|
|
3416
3544
|
},
|
|
3417
|
-
/* @__PURE__ */
|
|
3545
|
+
/* @__PURE__ */ React12.createElement("div", { className: "ai-chat-panel__input" }, /* @__PURE__ */ React12.createElement(
|
|
3418
3546
|
"textarea",
|
|
3419
3547
|
{
|
|
3420
3548
|
ref: textareaRef,
|
|
@@ -3434,24 +3562,24 @@ var ChatInput = React11.memo(({
|
|
|
3434
3562
|
rows: 1
|
|
3435
3563
|
}
|
|
3436
3564
|
)),
|
|
3437
|
-
/* @__PURE__ */
|
|
3565
|
+
/* @__PURE__ */ React12.createElement("div", { className: "ai-chat-panel__input-footer" }, agentOptions.length > 0 ? /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-agent-selector" }, /* @__PURE__ */ React12.createElement(
|
|
3438
3566
|
"button",
|
|
3439
3567
|
{
|
|
3440
3568
|
className: "ai-chat-agent-selector__trigger",
|
|
3441
3569
|
onClick: () => setDropdownOpen(!dropdownOpen),
|
|
3442
3570
|
disabled: agentsLoading
|
|
3443
3571
|
},
|
|
3444
|
-
currentAgentAvatarUrl ? /* @__PURE__ */
|
|
3572
|
+
currentAgentAvatarUrl ? /* @__PURE__ */ React12.createElement(
|
|
3445
3573
|
"img",
|
|
3446
3574
|
{
|
|
3447
3575
|
src: currentAgentAvatarUrl,
|
|
3448
3576
|
alt: currentAgentLabel || "Agent",
|
|
3449
3577
|
className: "ai-chat-agent-selector__avatar"
|
|
3450
3578
|
}
|
|
3451
|
-
) : /* @__PURE__ */
|
|
3452
|
-
/* @__PURE__ */
|
|
3453
|
-
dropdownOpen ? /* @__PURE__ */
|
|
3454
|
-
)) : /* @__PURE__ */
|
|
3579
|
+
) : /* @__PURE__ */ React12.createElement(AgentIcon, null),
|
|
3580
|
+
/* @__PURE__ */ React12.createElement("span", { className: "ai-chat-agent-selector__label" }, agentsLoading ? "Loading..." : currentAgentLabel || "Select agent"),
|
|
3581
|
+
dropdownOpen ? /* @__PURE__ */ React12.createElement(ChevronUpIcon, null) : /* @__PURE__ */ React12.createElement(ChevronDownIcon, null)
|
|
3582
|
+
)) : /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-panel__input-footer-spacer" }), contextSections.length > 0 && /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-context-pill-wrapper" }, /* @__PURE__ */ React12.createElement(
|
|
3455
3583
|
"button",
|
|
3456
3584
|
{
|
|
3457
3585
|
className: `ai-chat-context-pill ${contextViewerOpen ? "ai-chat-context-pill--active" : ""} ${isOverLimit ? "ai-chat-context-pill--warning" : ""}`,
|
|
@@ -3467,15 +3595,15 @@ var ChatInput = React11.memo(({
|
|
|
3467
3595
|
type: "button",
|
|
3468
3596
|
title: "View context"
|
|
3469
3597
|
},
|
|
3470
|
-
/* @__PURE__ */
|
|
3471
|
-
), contextViewerOpen && /* @__PURE__ */
|
|
3598
|
+
/* @__PURE__ */ React12.createElement("span", { className: "ai-chat-context-pill__label" }, "context: ", contextSections.length, " ", contextSections.length === 1 ? "section" : "sections")
|
|
3599
|
+
), contextViewerOpen && /* @__PURE__ */ React12.createElement(
|
|
3472
3600
|
"div",
|
|
3473
3601
|
{
|
|
3474
3602
|
className: `ai-chat-context-popover ${contextViewMode === "detail" ? "ai-chat-context-popover--detail" : ""}`,
|
|
3475
3603
|
ref: contextPopoverRef,
|
|
3476
3604
|
onClick: (e) => e.stopPropagation()
|
|
3477
3605
|
},
|
|
3478
|
-
contextViewMode === "summary" && /* @__PURE__ */
|
|
3606
|
+
contextViewMode === "summary" && /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-context-popover__summary" }, /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-context-popover__header" }, /* @__PURE__ */ React12.createElement("span", { className: "ai-chat-context-popover__title" }, "Context"), /* @__PURE__ */ React12.createElement(
|
|
3479
3607
|
"button",
|
|
3480
3608
|
{
|
|
3481
3609
|
className: "ai-chat-context-popover__close",
|
|
@@ -3483,13 +3611,13 @@ var ChatInput = React11.memo(({
|
|
|
3483
3611
|
type: "button"
|
|
3484
3612
|
},
|
|
3485
3613
|
"\xD7"
|
|
3486
|
-
)), /* @__PURE__ */
|
|
3614
|
+
)), /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-context-popover__token-bar" }, /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-context-popover__token-info" }, /* @__PURE__ */ React12.createElement("span", { className: isOverLimit ? "ai-chat-context-popover__tokens--warning" : "" }, formatTokens(totalContextTokens), " tokens"), /* @__PURE__ */ React12.createElement("span", { className: "ai-chat-context-popover__token-limit" }, "/ ", formatTokens(maxContextTokens), " limit")), /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-context-popover__progress" }, /* @__PURE__ */ React12.createElement(
|
|
3487
3615
|
"div",
|
|
3488
3616
|
{
|
|
3489
3617
|
className: `ai-chat-context-popover__progress-bar ${isOverLimit ? "ai-chat-context-popover__progress-bar--warning" : ""}`,
|
|
3490
3618
|
style: { width: `${Math.min(tokenPercentage, 100)}%` }
|
|
3491
3619
|
}
|
|
3492
|
-
))), /* @__PURE__ */
|
|
3620
|
+
))), /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-context-popover__sections" }, contextSections.map((section) => /* @__PURE__ */ React12.createElement(
|
|
3493
3621
|
"div",
|
|
3494
3622
|
{
|
|
3495
3623
|
key: section.id,
|
|
@@ -3500,10 +3628,10 @@ var ChatInput = React11.memo(({
|
|
|
3500
3628
|
}
|
|
3501
3629
|
}
|
|
3502
3630
|
},
|
|
3503
|
-
/* @__PURE__ */
|
|
3504
|
-
/* @__PURE__ */
|
|
3505
|
-
/* @__PURE__ */
|
|
3506
|
-
))), enableContextDetailView && /* @__PURE__ */
|
|
3631
|
+
/* @__PURE__ */ React12.createElement("span", { className: "ai-chat-context-popover__section-icon" }, "\u{1F4C4}"),
|
|
3632
|
+
/* @__PURE__ */ React12.createElement("span", { className: "ai-chat-context-popover__section-title" }, section.title),
|
|
3633
|
+
/* @__PURE__ */ React12.createElement("span", { className: "ai-chat-context-popover__section-tokens" }, section.tokens || Math.ceil(JSON.stringify(section.data).length / 4))
|
|
3634
|
+
))), enableContextDetailView && /* @__PURE__ */ React12.createElement(
|
|
3507
3635
|
"button",
|
|
3508
3636
|
{
|
|
3509
3637
|
className: "ai-chat-context-popover__expand-btn",
|
|
@@ -3512,7 +3640,7 @@ var ChatInput = React11.memo(({
|
|
|
3512
3640
|
},
|
|
3513
3641
|
"View details \u2192"
|
|
3514
3642
|
)),
|
|
3515
|
-
contextViewMode === "detail" && enableContextDetailView && /* @__PURE__ */
|
|
3643
|
+
contextViewMode === "detail" && enableContextDetailView && /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-context-popover__detail" }, /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-context-popover__header" }, /* @__PURE__ */ React12.createElement(
|
|
3516
3644
|
"button",
|
|
3517
3645
|
{
|
|
3518
3646
|
className: "ai-chat-context-popover__back",
|
|
@@ -3520,7 +3648,7 @@ var ChatInput = React11.memo(({
|
|
|
3520
3648
|
type: "button"
|
|
3521
3649
|
},
|
|
3522
3650
|
"\u2190 Back"
|
|
3523
|
-
), /* @__PURE__ */
|
|
3651
|
+
), /* @__PURE__ */ React12.createElement("span", { className: "ai-chat-context-popover__title" }, "Context Details"), /* @__PURE__ */ React12.createElement(
|
|
3524
3652
|
"button",
|
|
3525
3653
|
{
|
|
3526
3654
|
className: "ai-chat-context-popover__close",
|
|
@@ -3528,26 +3656,26 @@ var ChatInput = React11.memo(({
|
|
|
3528
3656
|
type: "button"
|
|
3529
3657
|
},
|
|
3530
3658
|
"\xD7"
|
|
3531
|
-
)), /* @__PURE__ */
|
|
3659
|
+
)), /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-context-popover__token-bar" }, /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-context-popover__token-info" }, /* @__PURE__ */ React12.createElement("span", { className: isOverLimit ? "ai-chat-context-popover__tokens--warning" : "" }, formatTokens(totalContextTokens), " tokens"), /* @__PURE__ */ React12.createElement("span", { className: "ai-chat-context-popover__token-limit" }, "/ ", formatTokens(maxContextTokens), " limit")), /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-context-popover__progress" }, /* @__PURE__ */ React12.createElement(
|
|
3532
3660
|
"div",
|
|
3533
3661
|
{
|
|
3534
3662
|
className: `ai-chat-context-popover__progress-bar ${isOverLimit ? "ai-chat-context-popover__progress-bar--warning" : ""}`,
|
|
3535
3663
|
style: { width: `${Math.min(tokenPercentage, 100)}%` }
|
|
3536
3664
|
}
|
|
3537
|
-
))), /* @__PURE__ */
|
|
3665
|
+
))), /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-context-popover__detail-sections" }, contextSections.map((section) => {
|
|
3538
3666
|
const format = detectFormat(section.data);
|
|
3539
|
-
return /* @__PURE__ */
|
|
3667
|
+
return /* @__PURE__ */ React12.createElement("details", { key: section.id, className: "ai-chat-context-popover__detail-section", open: true }, /* @__PURE__ */ React12.createElement("summary", { className: "ai-chat-context-popover__detail-section-header" }, /* @__PURE__ */ React12.createElement("span", { className: "ai-chat-context-popover__detail-section-title" }, section.title), /* @__PURE__ */ React12.createElement("span", { className: "ai-chat-context-popover__detail-section-meta" }, /* @__PURE__ */ React12.createElement("code", null, `{{${section.id}}}`), /* @__PURE__ */ React12.createElement("span", null, "~", section.tokens || Math.ceil(JSON.stringify(section.data).length / 4)))), /* @__PURE__ */ React12.createElement("pre", { className: "ai-chat-context-popover__detail-content" }, /* @__PURE__ */ React12.createElement("code", null, formatContent(section.data, format))));
|
|
3540
3668
|
})))
|
|
3541
|
-
)), /* @__PURE__ */
|
|
3669
|
+
)), /* @__PURE__ */ React12.createElement(
|
|
3542
3670
|
"button",
|
|
3543
3671
|
{
|
|
3544
3672
|
className: `ai-chat-send-button ${idle && !inputValue.trim() ? "ai-chat-send-button--disabled" : ""} ${!idle ? "ai-chat-send-button--stop" : ""}`,
|
|
3545
3673
|
onClick: () => idle ? handleSubmit() : onStop(),
|
|
3546
3674
|
disabled: idle && !inputValue.trim()
|
|
3547
3675
|
},
|
|
3548
|
-
idle ? /* @__PURE__ */
|
|
3676
|
+
idle ? /* @__PURE__ */ React12.createElement(ArrowUpIcon, null) : /* @__PURE__ */ React12.createElement(StopIcon, null)
|
|
3549
3677
|
)),
|
|
3550
|
-
agentOptions.length > 0 && dropdownOpen && /* @__PURE__ */
|
|
3678
|
+
agentOptions.length > 0 && dropdownOpen && /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-agent-selector__dropdown-inside" }, agentOptions.map((option) => /* @__PURE__ */ React12.createElement(
|
|
3551
3679
|
"button",
|
|
3552
3680
|
{
|
|
3553
3681
|
key: option.value,
|
|
@@ -3559,16 +3687,16 @@ var ChatInput = React11.memo(({
|
|
|
3559
3687
|
setDropdownOpen(false);
|
|
3560
3688
|
}
|
|
3561
3689
|
},
|
|
3562
|
-
option.avatarUrl ? /* @__PURE__ */
|
|
3690
|
+
option.avatarUrl ? /* @__PURE__ */ React12.createElement(
|
|
3563
3691
|
"img",
|
|
3564
3692
|
{
|
|
3565
3693
|
src: option.avatarUrl,
|
|
3566
3694
|
alt: option.label,
|
|
3567
3695
|
className: "ai-chat-agent-selector__option-avatar"
|
|
3568
3696
|
}
|
|
3569
|
-
) : option.icon ? /* @__PURE__ */
|
|
3570
|
-
/* @__PURE__ */
|
|
3571
|
-
option.value === currentAgentId && /* @__PURE__ */
|
|
3697
|
+
) : option.icon ? /* @__PURE__ */ React12.createElement("span", { className: "ai-chat-agent-selector__option-icon" }, option.icon) : null,
|
|
3698
|
+
/* @__PURE__ */ React12.createElement("span", { className: "ai-chat-agent-selector__option-content" }, /* @__PURE__ */ React12.createElement("span", { className: "ai-chat-agent-selector__option-label" }, option.label), option.description && /* @__PURE__ */ React12.createElement("span", { className: "ai-chat-agent-selector__option-description" }, option.description)),
|
|
3699
|
+
option.value === currentAgentId && /* @__PURE__ */ React12.createElement("span", { className: "ai-chat-agent-selector__option-check" }, /* @__PURE__ */ React12.createElement(CheckIcon, null))
|
|
3572
3700
|
)))
|
|
3573
3701
|
);
|
|
3574
3702
|
});
|
|
@@ -3612,8 +3740,28 @@ var AIChatPanel = ({
|
|
|
3612
3740
|
totalContextTokens = 0,
|
|
3613
3741
|
maxContextTokens = 8e3,
|
|
3614
3742
|
enableContextDetailView = false,
|
|
3615
|
-
onConversationCreated
|
|
3743
|
+
onConversationCreated,
|
|
3744
|
+
// UI Customization Props
|
|
3745
|
+
cssUrl,
|
|
3746
|
+
markdownClass,
|
|
3747
|
+
width,
|
|
3748
|
+
height,
|
|
3749
|
+
scrollToEnd = false,
|
|
3750
|
+
prismStyle,
|
|
3751
|
+
// Email & Save Props
|
|
3752
|
+
showSaveButton = true,
|
|
3753
|
+
showEmailButton = true,
|
|
3754
|
+
messages = [],
|
|
3755
|
+
// Call-to-Action Props
|
|
3756
|
+
showCallToAction = false,
|
|
3757
|
+
callToActionButtonText = "Submit",
|
|
3758
|
+
callToActionEmailAddress = "",
|
|
3759
|
+
callToActionEmailSubject = "Agent CTA submitted",
|
|
3760
|
+
// Customer Email Capture Props
|
|
3761
|
+
customerEmailCaptureMode = "HIDE",
|
|
3762
|
+
customerEmailCapturePlaceholder = "Please enter your email..."
|
|
3616
3763
|
}) => {
|
|
3764
|
+
var _a;
|
|
3617
3765
|
const publicAPIUrl = "https://api.llmasaservice.io";
|
|
3618
3766
|
const [lastController, setLastController] = useState6(new AbortController());
|
|
3619
3767
|
const [lastMessages, setLastMessages] = useState6([]);
|
|
@@ -3628,6 +3776,29 @@ var AIChatPanel = ({
|
|
|
3628
3776
|
const [newConversationConfirm, setNewConversationConfirm] = useState6(false);
|
|
3629
3777
|
const [justReset, setJustReset] = useState6(false);
|
|
3630
3778
|
const [copiedCallId, setCopiedCallId] = useState6(null);
|
|
3779
|
+
const [feedbackCallId, setFeedbackCallId] = useState6(null);
|
|
3780
|
+
const [error, setError] = useState6(null);
|
|
3781
|
+
const [emailSent, setEmailSent] = useState6(false);
|
|
3782
|
+
const [isToolInfoModalOpen, setIsToolInfoModalOpen] = useState6(false);
|
|
3783
|
+
const [toolInfoData, setToolInfoData] = useState6(null);
|
|
3784
|
+
const [callToActionSent, setCallToActionSent] = useState6(false);
|
|
3785
|
+
const [CTAClickedButNoEmail, setCTAClickedButNoEmail] = useState6(false);
|
|
3786
|
+
const [emailInput, setEmailInput] = useState6((_a = customer == null ? void 0 : customer.customer_user_email) != null ? _a : "");
|
|
3787
|
+
const [emailInputSet, setEmailInputSet] = useState6(false);
|
|
3788
|
+
const [emailValid, setEmailValid] = useState6(true);
|
|
3789
|
+
const [showEmailPanel, setShowEmailPanel] = useState6(customerEmailCaptureMode !== "HIDE");
|
|
3790
|
+
const [emailClickedButNoEmail, setEmailClickedButNoEmail] = useState6(false);
|
|
3791
|
+
const [pendingToolRequests, setPendingToolRequests] = useState6([]);
|
|
3792
|
+
const [sessionApprovedTools, setSessionApprovedTools] = useState6([]);
|
|
3793
|
+
const [alwaysApprovedTools, setAlwaysApprovedTools] = useState6([]);
|
|
3794
|
+
useEffect7(() => {
|
|
3795
|
+
setShowEmailPanel(customerEmailCaptureMode !== "HIDE");
|
|
3796
|
+
if (customerEmailCaptureMode === "REQUIRED") {
|
|
3797
|
+
if (!isEmailAddress(emailInput)) {
|
|
3798
|
+
setEmailValid(false);
|
|
3799
|
+
}
|
|
3800
|
+
}
|
|
3801
|
+
}, [customerEmailCaptureMode, emailInput]);
|
|
3631
3802
|
const bottomRef = useRef5(null);
|
|
3632
3803
|
const responseAreaRef = useRef5(null);
|
|
3633
3804
|
const [userHasScrolled, setUserHasScrolled] = useState6(false);
|
|
@@ -3638,6 +3809,7 @@ var AIChatPanel = ({
|
|
|
3638
3809
|
const hasNotifiedCompletionRef = useRef5(true);
|
|
3639
3810
|
const latestHistoryRef = useRef5(initialHistory);
|
|
3640
3811
|
const initialPromptSentRef = useRef5(false);
|
|
3812
|
+
const lastFollowOnPromptRef = useRef5("");
|
|
3641
3813
|
useEffect7(() => {
|
|
3642
3814
|
if (!initialHistory) return;
|
|
3643
3815
|
setHistory((prev) => {
|
|
@@ -3666,7 +3838,8 @@ var AIChatPanel = ({
|
|
|
3666
3838
|
idle,
|
|
3667
3839
|
lastCallId,
|
|
3668
3840
|
stop,
|
|
3669
|
-
setResponse
|
|
3841
|
+
setResponse,
|
|
3842
|
+
error: llmError
|
|
3670
3843
|
} = llmResult;
|
|
3671
3844
|
const toolList = llmResult.toolList || [];
|
|
3672
3845
|
const toolsLoading = llmResult.toolsLoading || false;
|
|
@@ -3683,9 +3856,9 @@ var AIChatPanel = ({
|
|
|
3683
3856
|
lastKeyRef.current = lastKey;
|
|
3684
3857
|
lastCallIdRef.current = lastCallId;
|
|
3685
3858
|
lastPromptRef.current = lastPrompt;
|
|
3686
|
-
const
|
|
3687
|
-
() => theme === "light" ? materialLight3 : materialDark3,
|
|
3688
|
-
[theme]
|
|
3859
|
+
const effectivePrismStyle = useMemo2(
|
|
3860
|
+
() => prismStyle != null ? prismStyle : theme === "light" ? materialLight3 : materialDark3,
|
|
3861
|
+
[prismStyle, theme]
|
|
3689
3862
|
);
|
|
3690
3863
|
const browserInfo = useMemo2(() => {
|
|
3691
3864
|
if (typeof window === "undefined") return null;
|
|
@@ -3696,7 +3869,7 @@ var AIChatPanel = ({
|
|
|
3696
3869
|
};
|
|
3697
3870
|
}, []);
|
|
3698
3871
|
const ensureConversation = useCallback2(() => {
|
|
3699
|
-
var
|
|
3872
|
+
var _a2, _b;
|
|
3700
3873
|
console.log("ensureConversation - called with:", {
|
|
3701
3874
|
currentConversation,
|
|
3702
3875
|
createConversationOnFirstChat,
|
|
@@ -3711,7 +3884,7 @@ var AIChatPanel = ({
|
|
|
3711
3884
|
const requestBody = {
|
|
3712
3885
|
project_id,
|
|
3713
3886
|
agentId: agent,
|
|
3714
|
-
customerId: (
|
|
3887
|
+
customerId: (_a2 = customer == null ? void 0 : customer.customer_id) != null ? _a2 : null,
|
|
3715
3888
|
customerEmail: (_b = customer == null ? void 0 : customer.customer_user_email) != null ? _b : null,
|
|
3716
3889
|
timezone: browserInfo == null ? void 0 : browserInfo.userTimezone,
|
|
3717
3890
|
language: browserInfo == null ? void 0 : browserInfo.userLanguage
|
|
@@ -3741,8 +3914,8 @@ var AIChatPanel = ({
|
|
|
3741
3914
|
}
|
|
3742
3915
|
console.warn("ensureConversation - No ID in response");
|
|
3743
3916
|
return "";
|
|
3744
|
-
}).catch((
|
|
3745
|
-
console.error("Error creating new conversation",
|
|
3917
|
+
}).catch((error2) => {
|
|
3918
|
+
console.error("Error creating new conversation", error2);
|
|
3746
3919
|
return "";
|
|
3747
3920
|
});
|
|
3748
3921
|
}
|
|
@@ -3750,10 +3923,10 @@ var AIChatPanel = ({
|
|
|
3750
3923
|
return Promise.resolve(currentConversation);
|
|
3751
3924
|
}, [currentConversation, createConversationOnFirstChat, publicAPIUrl, project_id, agent, customer, browserInfo]);
|
|
3752
3925
|
const dataWithExtras = useCallback2(() => {
|
|
3753
|
-
var
|
|
3926
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
3754
3927
|
return [
|
|
3755
3928
|
...data,
|
|
3756
|
-
{ key: "--customer_id", data: (
|
|
3929
|
+
{ key: "--customer_id", data: (_a2 = customer == null ? void 0 : customer.customer_id) != null ? _a2 : "" },
|
|
3757
3930
|
{ key: "--customer_name", data: (_b = customer == null ? void 0 : customer.customer_name) != null ? _b : "" },
|
|
3758
3931
|
{ key: "--customer_user_id", data: (_c = customer == null ? void 0 : customer.customer_user_id) != null ? _c : "" },
|
|
3759
3932
|
{ key: "--customer_user_name", data: (_d = customer == null ? void 0 : customer.customer_user_name) != null ? _d : "" },
|
|
@@ -3773,6 +3946,176 @@ var AIChatPanel = ({
|
|
|
3773
3946
|
}, [currentAgentId, agentOptions]);
|
|
3774
3947
|
const currentAgentLabel = currentAgentInfo.label;
|
|
3775
3948
|
const currentAgentAvatarUrl = currentAgentInfo.avatarUrl;
|
|
3949
|
+
const isEmailAddress = (email) => {
|
|
3950
|
+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
3951
|
+
return emailRegex.test(email);
|
|
3952
|
+
};
|
|
3953
|
+
const convertMarkdownToHTML = (markdown) => {
|
|
3954
|
+
const html = ReactDOMServer2.renderToStaticMarkup(
|
|
3955
|
+
/* @__PURE__ */ React12.createElement("div", { className: markdownClass }, /* @__PURE__ */ React12.createElement(
|
|
3956
|
+
ReactMarkdown2,
|
|
3957
|
+
{
|
|
3958
|
+
remarkPlugins: [remarkGfm2],
|
|
3959
|
+
rehypePlugins: [rehypeRaw2]
|
|
3960
|
+
},
|
|
3961
|
+
markdown
|
|
3962
|
+
))
|
|
3963
|
+
);
|
|
3964
|
+
return html;
|
|
3965
|
+
};
|
|
3966
|
+
const convertHistoryToHTML = (history2) => {
|
|
3967
|
+
const stylesheet = `
|
|
3968
|
+
<style>
|
|
3969
|
+
.conversation-history {
|
|
3970
|
+
font-family: Arial, sans-serif;
|
|
3971
|
+
line-height: 1.5;
|
|
3972
|
+
}
|
|
3973
|
+
.history-entry {
|
|
3974
|
+
margin-bottom: 15px;
|
|
3975
|
+
}
|
|
3976
|
+
.prompt-container, .response-container {
|
|
3977
|
+
margin-bottom: 10px;
|
|
3978
|
+
}
|
|
3979
|
+
.prompt, .response {
|
|
3980
|
+
display: block;
|
|
3981
|
+
margin: 5px 0;
|
|
3982
|
+
padding: 10px;
|
|
3983
|
+
border-radius: 5px;
|
|
3984
|
+
max-width: 80%;
|
|
3985
|
+
}
|
|
3986
|
+
.prompt {
|
|
3987
|
+
background-color: #efefef;
|
|
3988
|
+
margin-left: 0;
|
|
3989
|
+
}
|
|
3990
|
+
.response {
|
|
3991
|
+
background-color: #f0fcfd;
|
|
3992
|
+
margin-left: 25px;
|
|
3993
|
+
}
|
|
3994
|
+
</style>
|
|
3995
|
+
`;
|
|
3996
|
+
let html = `
|
|
3997
|
+
<html>
|
|
3998
|
+
<head>
|
|
3999
|
+
${stylesheet}
|
|
4000
|
+
</head>
|
|
4001
|
+
<body>
|
|
4002
|
+
<h1>Conversation History (${(/* @__PURE__ */ new Date()).toLocaleString()})</h1>
|
|
4003
|
+
<div class="conversation-history">
|
|
4004
|
+
`;
|
|
4005
|
+
Object.entries(history2).forEach(([prompt, response2], index) => {
|
|
4006
|
+
if (hideInitialPrompt && index === 0) {
|
|
4007
|
+
html += `
|
|
4008
|
+
<div class="history-entry">
|
|
4009
|
+
<div class="response-container">
|
|
4010
|
+
<div class="response">${convertMarkdownToHTML(response2.content)}</div>
|
|
4011
|
+
</div>
|
|
4012
|
+
</div>
|
|
4013
|
+
`;
|
|
4014
|
+
} else {
|
|
4015
|
+
html += `
|
|
4016
|
+
<div class="history-entry">
|
|
4017
|
+
<div class="prompt-container">
|
|
4018
|
+
<div class="prompt">${convertMarkdownToHTML(
|
|
4019
|
+
formatPromptForDisplay(prompt)
|
|
4020
|
+
)}</div>
|
|
4021
|
+
</div>
|
|
4022
|
+
<div class="response-container">
|
|
4023
|
+
<div class="response">${convertMarkdownToHTML(response2.content)}</div>
|
|
4024
|
+
</div>
|
|
4025
|
+
</div>
|
|
4026
|
+
`;
|
|
4027
|
+
}
|
|
4028
|
+
});
|
|
4029
|
+
html += `
|
|
4030
|
+
</div>
|
|
4031
|
+
</body>
|
|
4032
|
+
</html>
|
|
4033
|
+
`;
|
|
4034
|
+
return html;
|
|
4035
|
+
};
|
|
4036
|
+
const saveHTMLToFile = (html, filename) => {
|
|
4037
|
+
const blob = new Blob([html], { type: "text/html" });
|
|
4038
|
+
const link = document.createElement("a");
|
|
4039
|
+
link.href = URL.createObjectURL(blob);
|
|
4040
|
+
link.download = filename;
|
|
4041
|
+
document.body.appendChild(link);
|
|
4042
|
+
link.click();
|
|
4043
|
+
document.body.removeChild(link);
|
|
4044
|
+
};
|
|
4045
|
+
const saveAsHTMLFile = useCallback2(() => {
|
|
4046
|
+
saveHTMLToFile(
|
|
4047
|
+
convertHistoryToHTML(history),
|
|
4048
|
+
`conversation-${(/* @__PURE__ */ new Date()).toISOString()}.html`
|
|
4049
|
+
);
|
|
4050
|
+
interactionClicked(lastCallId || "", "save");
|
|
4051
|
+
}, [history, lastCallId]);
|
|
4052
|
+
const handleSendEmail = (to, from) => {
|
|
4053
|
+
sendConversationsViaEmail(to, `Conversation History from ${title}`, from);
|
|
4054
|
+
interactionClicked(lastCallId || "", "email", to);
|
|
4055
|
+
setEmailSent(true);
|
|
4056
|
+
};
|
|
4057
|
+
const sendConversationsViaEmail = (_0, ..._1) => __async(void 0, [_0, ..._1], function* (to, subject = `Conversation History from ${title}`, from = "") {
|
|
4058
|
+
fetch(`${publicAPIUrl}/share/email`, {
|
|
4059
|
+
method: "POST",
|
|
4060
|
+
headers: {
|
|
4061
|
+
"Content-Type": "application/json"
|
|
4062
|
+
},
|
|
4063
|
+
body: JSON.stringify({
|
|
4064
|
+
to,
|
|
4065
|
+
from,
|
|
4066
|
+
subject,
|
|
4067
|
+
html: convertHistoryToHTML(history),
|
|
4068
|
+
project_id: project_id != null ? project_id : "",
|
|
4069
|
+
customer,
|
|
4070
|
+
history,
|
|
4071
|
+
title
|
|
4072
|
+
})
|
|
4073
|
+
});
|
|
4074
|
+
yield interactionClicked(lastCallId || "", "email", from);
|
|
4075
|
+
});
|
|
4076
|
+
const sendCallToActionEmail = useCallback2((from) => __async(void 0, null, function* () {
|
|
4077
|
+
try {
|
|
4078
|
+
yield fetch(`${publicAPIUrl}/share/email`, {
|
|
4079
|
+
method: "POST",
|
|
4080
|
+
headers: {
|
|
4081
|
+
"Content-Type": "application/json"
|
|
4082
|
+
},
|
|
4083
|
+
body: JSON.stringify({
|
|
4084
|
+
to: callToActionEmailAddress,
|
|
4085
|
+
from,
|
|
4086
|
+
subject: `${callToActionEmailSubject} from ${from}`,
|
|
4087
|
+
html: convertHistoryToHTML(history),
|
|
4088
|
+
project_id: project_id != null ? project_id : "",
|
|
4089
|
+
customer,
|
|
4090
|
+
history,
|
|
4091
|
+
title
|
|
4092
|
+
})
|
|
4093
|
+
});
|
|
4094
|
+
yield interactionClicked(lastCallId || "", "cta", from);
|
|
4095
|
+
setCallToActionSent(true);
|
|
4096
|
+
} catch (err) {
|
|
4097
|
+
console.error("[AIChatPanel] Failed to send CTA email:", err);
|
|
4098
|
+
}
|
|
4099
|
+
}), [history, title, project_id, customer, lastCallId, publicAPIUrl, callToActionEmailAddress, callToActionEmailSubject]);
|
|
4100
|
+
const isDisabledDueToNoEmail = useCallback2(() => {
|
|
4101
|
+
if (customerEmailCaptureMode === "REQUIRED" && !emailInputSet) {
|
|
4102
|
+
return true;
|
|
4103
|
+
}
|
|
4104
|
+
return false;
|
|
4105
|
+
}, [customerEmailCaptureMode, emailInputSet]);
|
|
4106
|
+
const handleToolApproval = useCallback2((toolName, scope) => {
|
|
4107
|
+
if (scope === "session" || scope === "always") {
|
|
4108
|
+
setSessionApprovedTools((prev) => Array.from(/* @__PURE__ */ new Set([...prev, toolName])));
|
|
4109
|
+
}
|
|
4110
|
+
if (scope === "always") {
|
|
4111
|
+
setAlwaysApprovedTools((prev) => Array.from(/* @__PURE__ */ new Set([...prev, toolName])));
|
|
4112
|
+
}
|
|
4113
|
+
setPendingToolRequests((prev) => prev.filter((r) => r.toolName !== toolName));
|
|
4114
|
+
console.log(`[AIChatPanel] Tool "${toolName}" approved with scope: ${scope}`);
|
|
4115
|
+
}, []);
|
|
4116
|
+
const getUniqueToolNames = useCallback2(() => {
|
|
4117
|
+
return Array.from(new Set(pendingToolRequests.map((r) => r.toolName)));
|
|
4118
|
+
}, [pendingToolRequests]);
|
|
3776
4119
|
const cleanContentForDisplay = useCallback2((content) => {
|
|
3777
4120
|
let cleaned = content.replace(/\*\*(.*?)\*\*/g, "$1").replace(/\*(.*?)\*/g, "$1").replace(/\n+/g, " ").replace(/\s+/g, " ").trim();
|
|
3778
4121
|
if (cleaned.length > 100) {
|
|
@@ -3781,13 +4124,13 @@ var AIChatPanel = ({
|
|
|
3781
4124
|
return cleaned || "Thinking";
|
|
3782
4125
|
}, []);
|
|
3783
4126
|
const processThinkingTags = useCallback2((text) => {
|
|
3784
|
-
var
|
|
4127
|
+
var _a2, _b;
|
|
3785
4128
|
const blocks = [];
|
|
3786
4129
|
let index = 0;
|
|
3787
4130
|
const reasoningRegex = /<reasoning>([\s\S]*?)<\/reasoning>/gi;
|
|
3788
4131
|
let match;
|
|
3789
4132
|
while ((match = reasoningRegex.exec(text)) !== null) {
|
|
3790
|
-
blocks.push({ type: "reasoning", content: (
|
|
4133
|
+
blocks.push({ type: "reasoning", content: (_a2 = match[1]) != null ? _a2 : "", index: index++ });
|
|
3791
4134
|
}
|
|
3792
4135
|
const searchingRegex = /<searching>([\s\S]*?)<\/searching>/gi;
|
|
3793
4136
|
while ((match = searchingRegex.exec(text)) !== null) {
|
|
@@ -3834,37 +4177,81 @@ var AIChatPanel = ({
|
|
|
3834
4177
|
}
|
|
3835
4178
|
return displayPrompt;
|
|
3836
4179
|
}, [hideRagContextInPrompt]);
|
|
3837
|
-
const
|
|
4180
|
+
const interactionClicked = useCallback2((callId, action, emailaddress = "", comment = "") => __async(void 0, null, function* () {
|
|
4181
|
+
var _a2, _b;
|
|
4182
|
+
console.log(`[AIChatPanel] Interaction: ${action} for callId: ${callId}`);
|
|
4183
|
+
const convId = currentConversation || (yield ensureConversation());
|
|
4184
|
+
const finalCallId = callId || convId;
|
|
4185
|
+
const isEmailAddress2 = (str) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(str);
|
|
4186
|
+
const email = emailaddress && emailaddress !== "" ? emailaddress : isEmailAddress2((_a2 = customer == null ? void 0 : customer.customer_user_email) != null ? _a2 : "") ? customer == null ? void 0 : customer.customer_user_email : isEmailAddress2((_b = customer == null ? void 0 : customer.customer_id) != null ? _b : "") ? customer == null ? void 0 : customer.customer_id : "";
|
|
3838
4187
|
try {
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
4188
|
+
yield fetch(`${publicAPIUrl}/feedback/${finalCallId}/${action}`, {
|
|
4189
|
+
method: "POST",
|
|
4190
|
+
headers: {
|
|
4191
|
+
"Content-Type": "application/json"
|
|
4192
|
+
},
|
|
4193
|
+
body: JSON.stringify({
|
|
4194
|
+
project_id: project_id != null ? project_id : "",
|
|
4195
|
+
conversation_id: convId != null ? convId : "",
|
|
4196
|
+
email,
|
|
4197
|
+
comment
|
|
4198
|
+
})
|
|
4199
|
+
});
|
|
4200
|
+
} catch (err) {
|
|
4201
|
+
console.error("[AIChatPanel] Failed to send feedback:", err);
|
|
4202
|
+
}
|
|
4203
|
+
}), [currentConversation, ensureConversation, customer, project_id, publicAPIUrl]);
|
|
4204
|
+
const copyToClipboard = useCallback2((text, callId) => __async(void 0, null, function* () {
|
|
4205
|
+
try {
|
|
4206
|
+
const cleanText = text.replace(/<[^>]*>/g, "").replace(/\*\*(.*?)\*\*/g, "$1").replace(/\*(.*?)\*/g, "$1").replace(/#{1,6}\s/g, "").replace(/\[([^\]]+)\]\([^)]+\)/g, "$1");
|
|
4207
|
+
yield navigator.clipboard.writeText(cleanText);
|
|
4208
|
+
setCopiedCallId(callId);
|
|
4209
|
+
setTimeout(() => setCopiedCallId(null), 2e3);
|
|
4210
|
+
yield interactionClicked(callId, "copy");
|
|
4211
|
+
} catch (err) {
|
|
4212
|
+
console.error("Failed to copy:", err);
|
|
4213
|
+
}
|
|
4214
|
+
}), [interactionClicked]);
|
|
4215
|
+
const handleThumbsUp = useCallback2((callId) => __async(void 0, null, function* () {
|
|
4216
|
+
console.log("[AIChatPanel] Thumbs up clicked:", callId);
|
|
4217
|
+
setFeedbackCallId({ callId, type: "up" });
|
|
4218
|
+
setTimeout(() => setFeedbackCallId(null), 2e3);
|
|
4219
|
+
yield interactionClicked(callId, "thumbsup");
|
|
4220
|
+
if (thumbsUpClick) {
|
|
4221
|
+
thumbsUpClick(callId);
|
|
4222
|
+
}
|
|
4223
|
+
}), [thumbsUpClick, interactionClicked]);
|
|
4224
|
+
const handleThumbsDown = useCallback2((callId) => __async(void 0, null, function* () {
|
|
4225
|
+
console.log("[AIChatPanel] Thumbs down clicked:", callId);
|
|
4226
|
+
setFeedbackCallId({ callId, type: "down" });
|
|
4227
|
+
setTimeout(() => setFeedbackCallId(null), 2e3);
|
|
4228
|
+
yield interactionClicked(callId, "thumbsdown");
|
|
4229
|
+
if (thumbsDownClick) {
|
|
4230
|
+
thumbsDownClick(callId);
|
|
4231
|
+
}
|
|
4232
|
+
}), [thumbsDownClick, interactionClicked]);
|
|
4233
|
+
const scrollToBottom = useCallback2(() => {
|
|
4234
|
+
var _a2;
|
|
4235
|
+
if (scrollRAFRef.current) {
|
|
4236
|
+
cancelAnimationFrame(scrollRAFRef.current);
|
|
3851
4237
|
}
|
|
3852
4238
|
const now = Date.now();
|
|
3853
4239
|
if (now - lastScrollTimeRef.current < 100) {
|
|
3854
4240
|
scrollRAFRef.current = requestAnimationFrame(() => {
|
|
3855
|
-
var
|
|
3856
|
-
(
|
|
4241
|
+
var _a3;
|
|
4242
|
+
(_a3 = bottomRef.current) == null ? void 0 : _a3.scrollIntoView({ behavior: "auto" });
|
|
3857
4243
|
lastScrollTimeRef.current = Date.now();
|
|
3858
4244
|
});
|
|
3859
4245
|
return;
|
|
3860
4246
|
}
|
|
3861
|
-
(
|
|
4247
|
+
(_a2 = bottomRef.current) == null ? void 0 : _a2.scrollIntoView({ behavior: "auto" });
|
|
3862
4248
|
lastScrollTimeRef.current = now;
|
|
3863
4249
|
}, []);
|
|
3864
4250
|
const continueChat = useCallback2((promptText) => {
|
|
3865
4251
|
console.log("AIChatPanel.continueChat called with:", promptText);
|
|
3866
4252
|
setThinkingBlocks([]);
|
|
3867
4253
|
setCurrentThinkingIndex(0);
|
|
4254
|
+
setError(null);
|
|
3868
4255
|
setUserHasScrolled(false);
|
|
3869
4256
|
setResponse("");
|
|
3870
4257
|
if (!idle) {
|
|
@@ -3915,11 +4302,6 @@ var AIChatPanel = ({
|
|
|
3915
4302
|
if (messagesAndHistory.length === 0 && promptTemplate) {
|
|
3916
4303
|
fullPromptToSend = promptTemplate.replace("{{prompt}}", fullPromptToSend);
|
|
3917
4304
|
}
|
|
3918
|
-
if (followOnPrompt) {
|
|
3919
|
-
fullPromptToSend += `
|
|
3920
|
-
|
|
3921
|
-
${followOnPrompt}`;
|
|
3922
|
-
}
|
|
3923
4305
|
const newController = new AbortController();
|
|
3924
4306
|
setLastController(newController);
|
|
3925
4307
|
send(
|
|
@@ -3937,7 +4319,37 @@ ${followOnPrompt}`;
|
|
|
3937
4319
|
// group_id from agent config
|
|
3938
4320
|
convId,
|
|
3939
4321
|
// Use the conversation ID from ensureConversation
|
|
3940
|
-
newController
|
|
4322
|
+
newController,
|
|
4323
|
+
void 0,
|
|
4324
|
+
// onComplete
|
|
4325
|
+
(errorMsg) => {
|
|
4326
|
+
console.log("[AIChatPanel] Error callback triggered:", errorMsg);
|
|
4327
|
+
if (errorMsg.includes("413") || errorMsg.toLowerCase().includes("content too large")) {
|
|
4328
|
+
setError({
|
|
4329
|
+
message: "The context is too large to process. Please start a new conversation or reduce the amount of context.",
|
|
4330
|
+
code: "413"
|
|
4331
|
+
});
|
|
4332
|
+
} else if (errorMsg.toLowerCase().includes("network error") || errorMsg.toLowerCase().includes("fetch")) {
|
|
4333
|
+
setError({
|
|
4334
|
+
message: "Network error. Please check your connection and try again.",
|
|
4335
|
+
code: "NETWORK_ERROR"
|
|
4336
|
+
});
|
|
4337
|
+
} else {
|
|
4338
|
+
setError({
|
|
4339
|
+
message: errorMsg,
|
|
4340
|
+
code: "UNKNOWN_ERROR"
|
|
4341
|
+
});
|
|
4342
|
+
}
|
|
4343
|
+
setIsLoading(false);
|
|
4344
|
+
if (promptKey) {
|
|
4345
|
+
setHistory((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
4346
|
+
[promptKey]: {
|
|
4347
|
+
content: `Error: ${errorMsg}`,
|
|
4348
|
+
callId: lastCallId || ""
|
|
4349
|
+
}
|
|
4350
|
+
}));
|
|
4351
|
+
}
|
|
4352
|
+
}
|
|
3941
4353
|
);
|
|
3942
4354
|
setLastMessages(messagesAndHistory);
|
|
3943
4355
|
if (convId && onConversationCreated) {
|
|
@@ -3957,7 +4369,6 @@ ${followOnPrompt}`;
|
|
|
3957
4369
|
clearFollowOnQuestionsNextPrompt,
|
|
3958
4370
|
history,
|
|
3959
4371
|
promptTemplate,
|
|
3960
|
-
followOnPrompt,
|
|
3961
4372
|
send,
|
|
3962
4373
|
service,
|
|
3963
4374
|
ensureConversation,
|
|
@@ -3997,10 +4408,11 @@ ${followOnPrompt}`;
|
|
|
3997
4408
|
setJustReset(true);
|
|
3998
4409
|
setLastController(new AbortController());
|
|
3999
4410
|
setUserHasScrolled(false);
|
|
4411
|
+
setError(null);
|
|
4000
4412
|
setTimeout(() => {
|
|
4001
|
-
var
|
|
4413
|
+
var _a2;
|
|
4002
4414
|
setJustReset(false);
|
|
4003
|
-
(
|
|
4415
|
+
(_a2 = responseAreaRef.current) == null ? void 0 : _a2.scrollTo({ top: 0, behavior: "smooth" });
|
|
4004
4416
|
}, 100);
|
|
4005
4417
|
}, [newConversationConfirm, idle, stop, lastController, setResponse, followOnQuestions]);
|
|
4006
4418
|
useEffect7(() => {
|
|
@@ -4024,6 +4436,7 @@ ${followOnPrompt}`;
|
|
|
4024
4436
|
prevIdleRef.current = idle;
|
|
4025
4437
|
if (wasStreaming && isNowIdle && !hasNotifiedCompletionRef.current) {
|
|
4026
4438
|
hasNotifiedCompletionRef.current = true;
|
|
4439
|
+
setIsLoading(false);
|
|
4027
4440
|
const currentHistory = latestHistoryRef.current;
|
|
4028
4441
|
const currentLastKey = lastKeyRef.current;
|
|
4029
4442
|
const currentLastCallId = lastCallIdRef.current;
|
|
@@ -4043,10 +4456,11 @@ ${followOnPrompt}`;
|
|
|
4043
4456
|
}
|
|
4044
4457
|
}, [idle]);
|
|
4045
4458
|
useEffect7(() => {
|
|
4046
|
-
|
|
4459
|
+
const shouldAutoScroll = scrollToEnd || !userHasScrolled;
|
|
4460
|
+
if (!idle && shouldAutoScroll && response) {
|
|
4047
4461
|
scrollToBottom();
|
|
4048
4462
|
}
|
|
4049
|
-
}, [response, scrollToBottom, idle, userHasScrolled]);
|
|
4463
|
+
}, [response, scrollToBottom, idle, userHasScrolled, scrollToEnd]);
|
|
4050
4464
|
const idleRef = useRef5(idle);
|
|
4051
4465
|
idleRef.current = idle;
|
|
4052
4466
|
const userHasScrolledRef = useRef5(userHasScrolled);
|
|
@@ -4105,20 +4519,109 @@ ${followOnPrompt}`;
|
|
|
4105
4519
|
continueChat(initialPrompt);
|
|
4106
4520
|
}
|
|
4107
4521
|
}, [initialPrompt, continueChat]);
|
|
4108
|
-
|
|
4109
|
-
|
|
4522
|
+
useEffect7(() => {
|
|
4523
|
+
if (followOnPrompt && followOnPrompt !== "" && followOnPrompt !== lastFollowOnPromptRef.current) {
|
|
4524
|
+
lastFollowOnPromptRef.current = followOnPrompt;
|
|
4525
|
+
continueChat(followOnPrompt);
|
|
4526
|
+
}
|
|
4527
|
+
}, [followOnPrompt, continueChat]);
|
|
4528
|
+
useEffect7(() => {
|
|
4529
|
+
if (llmError && llmError.trim()) {
|
|
4530
|
+
console.log("[AIChatPanel] Error detected:", llmError);
|
|
4531
|
+
const errorMessage = llmError;
|
|
4532
|
+
if (errorMessage.includes("413") || errorMessage.toLowerCase().includes("content too large")) {
|
|
4533
|
+
setError({
|
|
4534
|
+
message: "The context is too large to process. Please start a new conversation or reduce the amount of context.",
|
|
4535
|
+
code: "413"
|
|
4536
|
+
});
|
|
4537
|
+
} else if (errorMessage.toLowerCase().includes("network error") || errorMessage.toLowerCase().includes("fetch")) {
|
|
4538
|
+
setError({
|
|
4539
|
+
message: "Network error. Please check your connection and try again.",
|
|
4540
|
+
code: "NETWORK_ERROR"
|
|
4541
|
+
});
|
|
4542
|
+
} else {
|
|
4543
|
+
setError({
|
|
4544
|
+
message: errorMessage,
|
|
4545
|
+
code: "UNKNOWN_ERROR"
|
|
4546
|
+
});
|
|
4547
|
+
}
|
|
4548
|
+
setIsLoading(false);
|
|
4549
|
+
if (lastKey) {
|
|
4550
|
+
setHistory((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
4551
|
+
[lastKey]: {
|
|
4552
|
+
content: `Error: ${errorMessage}`,
|
|
4553
|
+
callId: lastCallId || ""
|
|
4554
|
+
}
|
|
4555
|
+
}));
|
|
4556
|
+
}
|
|
4557
|
+
}
|
|
4558
|
+
}, [llmError, lastKey, lastCallId]);
|
|
4559
|
+
useEffect7(() => {
|
|
4560
|
+
const existingLinks = document.querySelectorAll(
|
|
4561
|
+
'link[data-source="ai-chat-panel"]'
|
|
4562
|
+
);
|
|
4563
|
+
existingLinks.forEach((link) => {
|
|
4564
|
+
var _a2;
|
|
4565
|
+
return (_a2 = link.parentNode) == null ? void 0 : _a2.removeChild(link);
|
|
4566
|
+
});
|
|
4567
|
+
const existingStyles = document.querySelectorAll(
|
|
4568
|
+
'style[data-source="ai-chat-panel"]'
|
|
4569
|
+
);
|
|
4570
|
+
existingStyles.forEach((style) => {
|
|
4571
|
+
var _a2;
|
|
4572
|
+
return (_a2 = style.parentNode) == null ? void 0 : _a2.removeChild(style);
|
|
4573
|
+
});
|
|
4574
|
+
if (cssUrl) {
|
|
4575
|
+
if (cssUrl.startsWith("http://") || cssUrl.startsWith("https://")) {
|
|
4576
|
+
const link = document.createElement("link");
|
|
4577
|
+
link.href = cssUrl;
|
|
4578
|
+
link.rel = "stylesheet";
|
|
4579
|
+
link.setAttribute("data-source", "ai-chat-panel");
|
|
4580
|
+
document.head.appendChild(link);
|
|
4581
|
+
} else {
|
|
4582
|
+
const style = document.createElement("style");
|
|
4583
|
+
style.textContent = cssUrl;
|
|
4584
|
+
style.setAttribute("data-source", "ai-chat-panel");
|
|
4585
|
+
document.head.appendChild(style);
|
|
4586
|
+
}
|
|
4587
|
+
}
|
|
4588
|
+
return () => {
|
|
4589
|
+
const links = document.querySelectorAll(
|
|
4590
|
+
'link[data-source="ai-chat-panel"]'
|
|
4591
|
+
);
|
|
4592
|
+
links.forEach((link) => {
|
|
4593
|
+
var _a2;
|
|
4594
|
+
return (_a2 = link.parentNode) == null ? void 0 : _a2.removeChild(link);
|
|
4595
|
+
});
|
|
4596
|
+
const styles = document.querySelectorAll(
|
|
4597
|
+
'style[data-source="ai-chat-panel"]'
|
|
4598
|
+
);
|
|
4599
|
+
styles.forEach((style) => {
|
|
4600
|
+
var _a2;
|
|
4601
|
+
return (_a2 = style.parentNode) == null ? void 0 : _a2.removeChild(style);
|
|
4602
|
+
});
|
|
4603
|
+
};
|
|
4604
|
+
}, [cssUrl]);
|
|
4605
|
+
const CodeBlock = useCallback2((_b) => {
|
|
4606
|
+
var _c = _b, { node, inline, className, children } = _c, props = __objRest(_c, ["node", "inline", "className", "children"]);
|
|
4110
4607
|
const match = /language-(\w+)/.exec(className || "");
|
|
4111
|
-
return !inline && match ? /* @__PURE__ */
|
|
4608
|
+
return !inline && match ? /* @__PURE__ */ React12.createElement(
|
|
4112
4609
|
SyntaxHighlighter2,
|
|
4113
4610
|
__spreadValues({
|
|
4114
|
-
style:
|
|
4611
|
+
style: effectivePrismStyle,
|
|
4115
4612
|
language: match[1],
|
|
4116
4613
|
PreTag: "div"
|
|
4117
4614
|
}, props),
|
|
4118
4615
|
String(children).replace(/\n$/, "")
|
|
4119
|
-
) : /* @__PURE__ */
|
|
4120
|
-
}, [
|
|
4121
|
-
const AgentSuggestionCard =
|
|
4616
|
+
) : /* @__PURE__ */ React12.createElement("code", __spreadValues({ className }, props), children);
|
|
4617
|
+
}, [effectivePrismStyle]);
|
|
4618
|
+
const AgentSuggestionCard = React12.memo(({ agentId, agentName, reason }) => {
|
|
4619
|
+
useEffect7(() => {
|
|
4620
|
+
const timer = setTimeout(() => {
|
|
4621
|
+
scrollToBottom();
|
|
4622
|
+
}, 100);
|
|
4623
|
+
return () => clearTimeout(timer);
|
|
4624
|
+
}, []);
|
|
4122
4625
|
if (!agentId || !onAgentChange) return null;
|
|
4123
4626
|
const isValidUUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(agentId);
|
|
4124
4627
|
const agentOption = agentOptions.find((opt) => opt.value === agentId);
|
|
@@ -4127,33 +4630,33 @@ ${followOnPrompt}`;
|
|
|
4127
4630
|
const avatarUrl = agentOption == null ? void 0 : agentOption.avatarUrl;
|
|
4128
4631
|
const isCurrentAgent = currentAgentId === agentId;
|
|
4129
4632
|
if (!isValidAgent || agentId.includes("{") || agentId.includes("$")) {
|
|
4130
|
-
return /* @__PURE__ */
|
|
4633
|
+
return /* @__PURE__ */ React12.createElement("span", { className: "ai-chat-agent-suggestion ai-chat-agent-suggestion--invalid" }, /* @__PURE__ */ React12.createElement("span", { className: "ai-chat-agent-suggestion__content" }, avatarUrl ? /* @__PURE__ */ React12.createElement(
|
|
4131
4634
|
"img",
|
|
4132
4635
|
{
|
|
4133
4636
|
src: avatarUrl,
|
|
4134
4637
|
alt: agentName,
|
|
4135
4638
|
className: "ai-chat-agent-suggestion__avatar"
|
|
4136
4639
|
}
|
|
4137
|
-
) : /* @__PURE__ */
|
|
4640
|
+
) : /* @__PURE__ */ React12.createElement("span", { className: "ai-chat-agent-suggestion__icon" }, /* @__PURE__ */ React12.createElement("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, /* @__PURE__ */ React12.createElement("path", { d: "M12 8V4H8" }), /* @__PURE__ */ React12.createElement("rect", { width: "16", height: "12", x: "4", y: "8", rx: "2" }), /* @__PURE__ */ React12.createElement("path", { d: "M2 14h2" }), /* @__PURE__ */ React12.createElement("path", { d: "M20 14h2" }), /* @__PURE__ */ React12.createElement("path", { d: "M15 13v2" }), /* @__PURE__ */ React12.createElement("path", { d: "M9 13v2" }))), /* @__PURE__ */ React12.createElement("span", { className: "ai-chat-agent-suggestion__text" }, /* @__PURE__ */ React12.createElement("span", { className: "ai-chat-agent-suggestion__label" }, "Suggested: ", agentName), reason && /* @__PURE__ */ React12.createElement("span", { className: "ai-chat-agent-suggestion__reason" }, reason))), /* @__PURE__ */ React12.createElement("span", { className: "ai-chat-agent-suggestion__unavailable" }, "Agent unavailable"));
|
|
4138
4641
|
}
|
|
4139
4642
|
if (isCurrentAgent) {
|
|
4140
|
-
return /* @__PURE__ */
|
|
4643
|
+
return /* @__PURE__ */ React12.createElement("span", { className: "ai-chat-agent-suggestion ai-chat-agent-suggestion--switched" }, /* @__PURE__ */ React12.createElement("span", { className: "ai-chat-agent-suggestion__content" }, avatarUrl ? /* @__PURE__ */ React12.createElement(
|
|
4141
4644
|
"img",
|
|
4142
4645
|
{
|
|
4143
4646
|
src: avatarUrl,
|
|
4144
4647
|
alt: agentName,
|
|
4145
4648
|
className: "ai-chat-agent-suggestion__avatar"
|
|
4146
4649
|
}
|
|
4147
|
-
) : /* @__PURE__ */
|
|
4650
|
+
) : /* @__PURE__ */ React12.createElement("span", { className: "ai-chat-agent-suggestion__icon ai-chat-agent-suggestion__icon--switched" }, /* @__PURE__ */ React12.createElement("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, /* @__PURE__ */ React12.createElement("polyline", { points: "20 6 9 17 4 12" }))), /* @__PURE__ */ React12.createElement("span", { className: "ai-chat-agent-suggestion__text" }, /* @__PURE__ */ React12.createElement("span", { className: "ai-chat-agent-suggestion__label" }, "Switched to ", agentName), reason && /* @__PURE__ */ React12.createElement("span", { className: "ai-chat-agent-suggestion__reason" }, reason))), /* @__PURE__ */ React12.createElement("span", { className: "ai-chat-agent-suggestion__switched-badge" }, /* @__PURE__ */ React12.createElement("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round" }, /* @__PURE__ */ React12.createElement("polyline", { points: "20 6 9 17 4 12" })), "Active"));
|
|
4148
4651
|
}
|
|
4149
|
-
return /* @__PURE__ */
|
|
4652
|
+
return /* @__PURE__ */ React12.createElement("span", { className: "ai-chat-agent-suggestion" }, /* @__PURE__ */ React12.createElement("span", { className: "ai-chat-agent-suggestion__content" }, avatarUrl ? /* @__PURE__ */ React12.createElement(
|
|
4150
4653
|
"img",
|
|
4151
4654
|
{
|
|
4152
4655
|
src: avatarUrl,
|
|
4153
4656
|
alt: agentName,
|
|
4154
4657
|
className: "ai-chat-agent-suggestion__avatar"
|
|
4155
4658
|
}
|
|
4156
|
-
) : /* @__PURE__ */
|
|
4659
|
+
) : /* @__PURE__ */ React12.createElement("span", { className: "ai-chat-agent-suggestion__icon" }, /* @__PURE__ */ React12.createElement("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, /* @__PURE__ */ React12.createElement("path", { d: "M12 8V4H8" }), /* @__PURE__ */ React12.createElement("rect", { width: "16", height: "12", x: "4", y: "8", rx: "2" }), /* @__PURE__ */ React12.createElement("path", { d: "M2 14h2" }), /* @__PURE__ */ React12.createElement("path", { d: "M20 14h2" }), /* @__PURE__ */ React12.createElement("path", { d: "M15 13v2" }), /* @__PURE__ */ React12.createElement("path", { d: "M9 13v2" }))), /* @__PURE__ */ React12.createElement("span", { className: "ai-chat-agent-suggestion__text" }, /* @__PURE__ */ React12.createElement("span", { className: "ai-chat-agent-suggestion__label" }, "Suggested: ", agentName), reason && /* @__PURE__ */ React12.createElement("span", { className: "ai-chat-agent-suggestion__reason" }, reason))), /* @__PURE__ */ React12.createElement(
|
|
4157
4660
|
Button,
|
|
4158
4661
|
{
|
|
4159
4662
|
variant: "default",
|
|
@@ -4162,23 +4665,22 @@ ${followOnPrompt}`;
|
|
|
4162
4665
|
onClick: () => {
|
|
4163
4666
|
onAgentChange(agentId);
|
|
4164
4667
|
setTimeout(() => {
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
}, 50);
|
|
4668
|
+
scrollToBottom();
|
|
4669
|
+
}, 100);
|
|
4168
4670
|
}
|
|
4169
4671
|
},
|
|
4170
4672
|
"Switch"
|
|
4171
4673
|
));
|
|
4172
|
-
}
|
|
4674
|
+
});
|
|
4173
4675
|
const markdownComponents = useMemo2(() => ({
|
|
4174
4676
|
code: CodeBlock,
|
|
4175
|
-
"agent-suggestion": (
|
|
4176
|
-
var _b =
|
|
4677
|
+
"agent-suggestion": (_a2) => {
|
|
4678
|
+
var _b = _a2, { node } = _b, props = __objRest(_b, ["node"]);
|
|
4177
4679
|
const agentId = props["data-agent-id"];
|
|
4178
4680
|
const agentName = props["data-agent-name"];
|
|
4179
4681
|
const reason = props["data-reason"];
|
|
4180
4682
|
if (!agentId) return null;
|
|
4181
|
-
return /* @__PURE__ */
|
|
4683
|
+
return /* @__PURE__ */ React12.createElement(
|
|
4182
4684
|
AgentSuggestionCard,
|
|
4183
4685
|
{
|
|
4184
4686
|
agentId,
|
|
@@ -4193,116 +4695,339 @@ ${followOnPrompt}`;
|
|
|
4193
4695
|
const currentBlock = thinkingBlocks[currentThinkingIndex];
|
|
4194
4696
|
if (!currentBlock) return null;
|
|
4195
4697
|
const isReasoning = currentBlock.type === "reasoning";
|
|
4196
|
-
const icon = isReasoning ? /* @__PURE__ */
|
|
4698
|
+
const icon = isReasoning ? /* @__PURE__ */ React12.createElement(BrainIcon, null) : /* @__PURE__ */ React12.createElement(SearchIcon, null);
|
|
4197
4699
|
const title2 = isReasoning ? "Reasoning" : "Searching";
|
|
4198
|
-
return /* @__PURE__ */
|
|
4700
|
+
return /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-thinking" }, /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-thinking__header" }, /* @__PURE__ */ React12.createElement("span", { className: "ai-chat-thinking__icon" }, icon), /* @__PURE__ */ React12.createElement("span", { className: "ai-chat-thinking__title" }, title2), thinkingBlocks.length > 1 && /* @__PURE__ */ React12.createElement("span", { className: "ai-chat-thinking__nav" }, /* @__PURE__ */ React12.createElement(
|
|
4199
4701
|
"button",
|
|
4200
4702
|
{
|
|
4201
4703
|
onClick: () => setCurrentThinkingIndex(Math.max(0, currentThinkingIndex - 1)),
|
|
4202
4704
|
disabled: currentThinkingIndex === 0
|
|
4203
4705
|
},
|
|
4204
4706
|
"\u2039"
|
|
4205
|
-
), /* @__PURE__ */
|
|
4707
|
+
), /* @__PURE__ */ React12.createElement("span", null, currentThinkingIndex + 1, " / ", thinkingBlocks.length), /* @__PURE__ */ React12.createElement(
|
|
4206
4708
|
"button",
|
|
4207
4709
|
{
|
|
4208
4710
|
onClick: () => setCurrentThinkingIndex(Math.min(thinkingBlocks.length - 1, currentThinkingIndex + 1)),
|
|
4209
4711
|
disabled: currentThinkingIndex === thinkingBlocks.length - 1
|
|
4210
4712
|
},
|
|
4211
4713
|
"\u203A"
|
|
4212
|
-
))), /* @__PURE__ */
|
|
4714
|
+
))), /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-thinking__content" }, cleanContentForDisplay(currentBlock.content)));
|
|
4213
4715
|
}, [thinkingBlocks, currentThinkingIndex, cleanContentForDisplay]);
|
|
4214
4716
|
const panelClasses = ["ai-chat-panel", theme === "dark" ? "dark-theme" : ""].filter(Boolean).join(" ");
|
|
4215
|
-
return /* @__PURE__ */
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4717
|
+
return /* @__PURE__ */ React12.createElement(
|
|
4718
|
+
"div",
|
|
4719
|
+
{
|
|
4720
|
+
className: panelClasses,
|
|
4721
|
+
style: __spreadValues(__spreadValues({}, width && { width }), height && { height })
|
|
4722
|
+
},
|
|
4723
|
+
title && /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-panel__title" }, title),
|
|
4724
|
+
error && /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-error-banner" }, /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-error-banner__icon" }, /* @__PURE__ */ React12.createElement(AlertCircleIcon, null)), /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-error-banner__content" }, /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-error-banner__message" }, error.message), error.code === "413" && /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-error-banner__hint" }, "Try starting a new conversation or reducing the amount of information being sent.")), /* @__PURE__ */ React12.createElement(
|
|
4725
|
+
"button",
|
|
4726
|
+
{
|
|
4727
|
+
className: "ai-chat-error-banner__close",
|
|
4728
|
+
onClick: () => setError(null),
|
|
4729
|
+
"aria-label": "Dismiss error"
|
|
4730
|
+
},
|
|
4731
|
+
/* @__PURE__ */ React12.createElement(CloseIcon, null)
|
|
4732
|
+
)),
|
|
4733
|
+
/* @__PURE__ */ React12.createElement(ScrollArea, { className: "ai-chat-panel__messages", ref: responseAreaRef }, initialMessage && /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-message ai-chat-message--assistant" }, /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-message__content" }, markdownClass ? /* @__PURE__ */ React12.createElement("div", { className: markdownClass }, /* @__PURE__ */ React12.createElement(
|
|
4221
4734
|
ReactMarkdown2,
|
|
4222
4735
|
{
|
|
4223
4736
|
remarkPlugins: [remarkGfm2],
|
|
4224
|
-
rehypePlugins: [rehypeRaw2]
|
|
4225
|
-
components: markdownComponents
|
|
4737
|
+
rehypePlugins: [rehypeRaw2]
|
|
4226
4738
|
},
|
|
4227
|
-
|
|
4228
|
-
)
|
|
4739
|
+
initialMessage
|
|
4740
|
+
)) : /* @__PURE__ */ React12.createElement(
|
|
4229
4741
|
ReactMarkdown2,
|
|
4230
4742
|
{
|
|
4231
4743
|
remarkPlugins: [remarkGfm2],
|
|
4232
|
-
rehypePlugins: [rehypeRaw2]
|
|
4233
|
-
components: markdownComponents
|
|
4744
|
+
rehypePlugins: [rehypeRaw2]
|
|
4234
4745
|
},
|
|
4235
|
-
|
|
4236
|
-
))),
|
|
4746
|
+
initialMessage
|
|
4747
|
+
))), Object.entries(history).map(([prompt, entry], index, entries) => {
|
|
4748
|
+
const isLastEntry = index === entries.length - 1;
|
|
4749
|
+
const isSystemMessage = prompt.startsWith("__system__:");
|
|
4750
|
+
const { cleanedText } = processThinkingTags(entry.content);
|
|
4751
|
+
const processedContent = processActions(cleanedText);
|
|
4752
|
+
return /* @__PURE__ */ React12.createElement("div", { key: index, className: "ai-chat-entry" }, !(hideInitialPrompt && index === 0) && !isSystemMessage && /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-message ai-chat-message--user" }, /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-message__content" }, formatPromptForDisplay(prompt))), /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-message ai-chat-message--assistant" }, /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-message__content" }, isLastEntry && (isLoading || !idle) && !justReset ? /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-streaming" }, thinkingBlocks.length > 0 && renderThinkingBlocks(), processedContent ? markdownClass ? /* @__PURE__ */ React12.createElement("div", { className: markdownClass }, /* @__PURE__ */ React12.createElement(
|
|
4753
|
+
ReactMarkdown2,
|
|
4754
|
+
{
|
|
4755
|
+
remarkPlugins: [remarkGfm2],
|
|
4756
|
+
rehypePlugins: [rehypeRaw2],
|
|
4757
|
+
components: markdownComponents
|
|
4758
|
+
},
|
|
4759
|
+
processedContent
|
|
4760
|
+
)) : /* @__PURE__ */ React12.createElement(
|
|
4761
|
+
ReactMarkdown2,
|
|
4762
|
+
{
|
|
4763
|
+
remarkPlugins: [remarkGfm2],
|
|
4764
|
+
rehypePlugins: [rehypeRaw2],
|
|
4765
|
+
components: markdownComponents
|
|
4766
|
+
},
|
|
4767
|
+
processedContent
|
|
4768
|
+
) : /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-loading" }, /* @__PURE__ */ React12.createElement("span", null, "Thinking"), /* @__PURE__ */ React12.createElement("span", { className: "ai-chat-loading__dots" }, /* @__PURE__ */ React12.createElement("span", { className: "ai-chat-loading__dot" }), /* @__PURE__ */ React12.createElement("span", { className: "ai-chat-loading__dot" }), /* @__PURE__ */ React12.createElement("span", { className: "ai-chat-loading__dot" })))) : /* @__PURE__ */ React12.createElement(React12.Fragment, null, isLastEntry && thinkingBlocks.length > 0 && renderThinkingBlocks(), markdownClass ? /* @__PURE__ */ React12.createElement("div", { className: markdownClass }, /* @__PURE__ */ React12.createElement(
|
|
4769
|
+
ReactMarkdown2,
|
|
4770
|
+
{
|
|
4771
|
+
remarkPlugins: [remarkGfm2],
|
|
4772
|
+
rehypePlugins: [rehypeRaw2],
|
|
4773
|
+
components: markdownComponents
|
|
4774
|
+
},
|
|
4775
|
+
processedContent
|
|
4776
|
+
)) : /* @__PURE__ */ React12.createElement(
|
|
4777
|
+
ReactMarkdown2,
|
|
4778
|
+
{
|
|
4779
|
+
remarkPlugins: [remarkGfm2],
|
|
4780
|
+
rehypePlugins: [rehypeRaw2],
|
|
4781
|
+
components: markdownComponents
|
|
4782
|
+
},
|
|
4783
|
+
processedContent
|
|
4784
|
+
))), (!isLastEntry || !isLoading) && /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-message__actions" }, /* @__PURE__ */ React12.createElement(
|
|
4785
|
+
"button",
|
|
4786
|
+
{
|
|
4787
|
+
className: "ai-chat-action-button",
|
|
4788
|
+
onClick: () => copyToClipboard(entry.content, entry.callId),
|
|
4789
|
+
title: copiedCallId === entry.callId ? "Copied!" : "Copy"
|
|
4790
|
+
},
|
|
4791
|
+
copiedCallId === entry.callId ? /* @__PURE__ */ React12.createElement("span", { style: { fontSize: "11px", fontWeight: 500 } }, "Copied!") : /* @__PURE__ */ React12.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: "ai-chat-icon-sm" }, /* @__PURE__ */ React12.createElement("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2", ry: "2" }), /* @__PURE__ */ React12.createElement("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" }))
|
|
4792
|
+
), /* @__PURE__ */ React12.createElement(
|
|
4793
|
+
"button",
|
|
4794
|
+
{
|
|
4795
|
+
className: "ai-chat-action-button",
|
|
4796
|
+
onClick: () => handleThumbsUp(entry.callId),
|
|
4797
|
+
title: (feedbackCallId == null ? void 0 : feedbackCallId.callId) === entry.callId && (feedbackCallId == null ? void 0 : feedbackCallId.type) === "up" ? "Thanks!" : "Good response",
|
|
4798
|
+
style: (feedbackCallId == null ? void 0 : feedbackCallId.callId) === entry.callId && (feedbackCallId == null ? void 0 : feedbackCallId.type) === "up" ? { color: "#22c55e" } : void 0
|
|
4799
|
+
},
|
|
4800
|
+
(feedbackCallId == null ? void 0 : feedbackCallId.callId) === entry.callId && (feedbackCallId == null ? void 0 : feedbackCallId.type) === "up" ? /* @__PURE__ */ React12.createElement("span", { style: { fontSize: "11px", fontWeight: 500 } }, "Thanks!") : /* @__PURE__ */ React12.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: "ai-chat-icon-sm" }, /* @__PURE__ */ React12.createElement("path", { d: "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" }))
|
|
4801
|
+
), /* @__PURE__ */ React12.createElement(
|
|
4802
|
+
"button",
|
|
4803
|
+
{
|
|
4804
|
+
className: "ai-chat-action-button",
|
|
4805
|
+
onClick: () => handleThumbsDown(entry.callId),
|
|
4806
|
+
title: (feedbackCallId == null ? void 0 : feedbackCallId.callId) === entry.callId && (feedbackCallId == null ? void 0 : feedbackCallId.type) === "down" ? "Thanks!" : "Poor response",
|
|
4807
|
+
style: (feedbackCallId == null ? void 0 : feedbackCallId.callId) === entry.callId && (feedbackCallId == null ? void 0 : feedbackCallId.type) === "down" ? { color: "#ef4444" } : void 0
|
|
4808
|
+
},
|
|
4809
|
+
(feedbackCallId == null ? void 0 : feedbackCallId.callId) === entry.callId && (feedbackCallId == null ? void 0 : feedbackCallId.type) === "down" ? /* @__PURE__ */ React12.createElement("span", { style: { fontSize: "11px", fontWeight: 500 } }, "Thanks!") : /* @__PURE__ */ React12.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: "ai-chat-icon-sm" }, /* @__PURE__ */ React12.createElement("path", { d: "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" }))
|
|
4810
|
+
), (entry.toolCalls || entry.toolResponses) && /* @__PURE__ */ React12.createElement(
|
|
4811
|
+
"button",
|
|
4812
|
+
{
|
|
4813
|
+
className: "ai-chat-action-button",
|
|
4814
|
+
onClick: () => {
|
|
4815
|
+
setToolInfoData({
|
|
4816
|
+
calls: entry.toolCalls || [],
|
|
4817
|
+
responses: entry.toolResponses || []
|
|
4818
|
+
});
|
|
4819
|
+
setIsToolInfoModalOpen(true);
|
|
4820
|
+
},
|
|
4821
|
+
title: "View tool information"
|
|
4822
|
+
},
|
|
4823
|
+
/* @__PURE__ */ React12.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: "ai-chat-icon-sm" }, /* @__PURE__ */ React12.createElement("circle", { cx: "12", cy: "12", r: "10" }), /* @__PURE__ */ React12.createElement("line", { x1: "12", x2: "12", y1: "16", y2: "12" }), /* @__PURE__ */ React12.createElement("line", { x1: "12", x2: "12.01", y1: "8", y2: "8" }))
|
|
4824
|
+
))));
|
|
4825
|
+
}), followOnQuestionsState.length > 0 && idle && !isLoading && /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-suggestions" }, followOnQuestionsState.map((question, index) => /* @__PURE__ */ React12.createElement(
|
|
4237
4826
|
Button,
|
|
4238
4827
|
{
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4828
|
+
key: index,
|
|
4829
|
+
variant: "outline",
|
|
4830
|
+
size: "sm",
|
|
4831
|
+
onClick: () => handleSuggestionClick(question),
|
|
4832
|
+
className: "ai-chat-suggestions__button"
|
|
4242
4833
|
},
|
|
4243
|
-
|
|
4244
|
-
)),
|
|
4834
|
+
question
|
|
4835
|
+
))), /* @__PURE__ */ React12.createElement("div", { ref: bottomRef })),
|
|
4836
|
+
pendingToolRequests.length > 0 && /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-approve-tools-panel" }, /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-approve-tools-header" }, "Tool Approval Required"), /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-approve-tools-description" }, "The AI wants to use the following tools:"), getUniqueToolNames().map((toolName) => /* @__PURE__ */ React12.createElement("div", { key: toolName, className: "ai-chat-approve-tool-item" }, /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-approve-tool-name" }, toolName), /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-approve-tools-buttons" }, /* @__PURE__ */ React12.createElement(
|
|
4245
4837
|
Button,
|
|
4246
4838
|
{
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4839
|
+
size: "sm",
|
|
4840
|
+
variant: "outline",
|
|
4841
|
+
className: "ai-chat-approve-tools-button",
|
|
4842
|
+
onClick: () => handleToolApproval(toolName, "once")
|
|
4250
4843
|
},
|
|
4251
|
-
|
|
4252
|
-
)
|
|
4844
|
+
"Once"
|
|
4845
|
+
), /* @__PURE__ */ React12.createElement(
|
|
4253
4846
|
Button,
|
|
4254
4847
|
{
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4848
|
+
size: "sm",
|
|
4849
|
+
variant: "outline",
|
|
4850
|
+
className: "ai-chat-approve-tools-button",
|
|
4851
|
+
onClick: () => handleToolApproval(toolName, "session")
|
|
4258
4852
|
},
|
|
4259
|
-
|
|
4260
|
-
)
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4853
|
+
"This Session"
|
|
4854
|
+
), /* @__PURE__ */ React12.createElement(
|
|
4855
|
+
Button,
|
|
4856
|
+
{
|
|
4857
|
+
size: "sm",
|
|
4858
|
+
variant: "default",
|
|
4859
|
+
className: "ai-chat-approve-tools-button",
|
|
4860
|
+
onClick: () => handleToolApproval(toolName, "always")
|
|
4861
|
+
},
|
|
4862
|
+
"Always"
|
|
4863
|
+
))))),
|
|
4864
|
+
(showSaveButton || showEmailButton || showCallToAction) && /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-button-container" }, showSaveButton && /* @__PURE__ */ React12.createElement(
|
|
4865
|
+
Button,
|
|
4866
|
+
{
|
|
4867
|
+
variant: "outline",
|
|
4868
|
+
size: "sm",
|
|
4869
|
+
onClick: saveAsHTMLFile,
|
|
4870
|
+
disabled: Object.keys(history).length === 0,
|
|
4871
|
+
className: "ai-chat-save-button"
|
|
4872
|
+
},
|
|
4873
|
+
"\u{1F4BE} Save"
|
|
4874
|
+
), showEmailButton && /* @__PURE__ */ React12.createElement(
|
|
4875
|
+
Button,
|
|
4876
|
+
{
|
|
4877
|
+
variant: "outline",
|
|
4878
|
+
size: "sm",
|
|
4879
|
+
onClick: () => {
|
|
4880
|
+
if (isEmailAddress(emailInput)) {
|
|
4881
|
+
setEmailInputSet(true);
|
|
4882
|
+
setEmailValid(true);
|
|
4883
|
+
handleSendEmail(emailInput, emailInput);
|
|
4884
|
+
setEmailClickedButNoEmail(false);
|
|
4885
|
+
} else {
|
|
4886
|
+
setShowEmailPanel(true);
|
|
4887
|
+
setEmailValid(false);
|
|
4888
|
+
setEmailClickedButNoEmail(true);
|
|
4889
|
+
}
|
|
4890
|
+
},
|
|
4891
|
+
disabled: Object.keys(history).length === 0 || isDisabledDueToNoEmail(),
|
|
4892
|
+
className: "ai-chat-email-button"
|
|
4893
|
+
},
|
|
4894
|
+
"\u{1F4E7} Email Conversation",
|
|
4895
|
+
emailSent ? " \u2713" : ""
|
|
4896
|
+
), showCallToAction && /* @__PURE__ */ React12.createElement(
|
|
4897
|
+
Button,
|
|
4898
|
+
{
|
|
4899
|
+
variant: callToActionSent ? "outline" : "default",
|
|
4900
|
+
size: "sm",
|
|
4901
|
+
onClick: () => {
|
|
4902
|
+
if (customerEmailCaptureMode !== "HIDE" && !emailInputSet) {
|
|
4903
|
+
setCTAClickedButNoEmail(true);
|
|
4904
|
+
setTimeout(() => setCTAClickedButNoEmail(false), 3e3);
|
|
4905
|
+
return;
|
|
4906
|
+
}
|
|
4907
|
+
const fromEmail = emailInput || (customer == null ? void 0 : customer.customer_user_email) || "";
|
|
4908
|
+
sendCallToActionEmail(fromEmail);
|
|
4909
|
+
},
|
|
4910
|
+
disabled: callToActionSent || Object.keys(history).length === 0,
|
|
4911
|
+
className: "ai-chat-cta-button"
|
|
4912
|
+
},
|
|
4913
|
+
callToActionSent ? "\u2713 Submitted" : callToActionButtonText
|
|
4914
|
+
)),
|
|
4915
|
+
showNewConversationButton && /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-panel__new-conversation" }, /* @__PURE__ */ React12.createElement(
|
|
4916
|
+
Button,
|
|
4917
|
+
{
|
|
4918
|
+
variant: newConversationConfirm ? "destructive" : "outline",
|
|
4919
|
+
size: "sm",
|
|
4920
|
+
onClick: handleNewConversation,
|
|
4921
|
+
className: "ai-chat-new-conversation"
|
|
4922
|
+
},
|
|
4923
|
+
newConversationConfirm ? "Click to Confirm" : "New Conversation"
|
|
4924
|
+
)),
|
|
4925
|
+
showEmailPanel && /* @__PURE__ */ React12.createElement(React12.Fragment, null, !emailValid && /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-email-input-message" }, isDisabledDueToNoEmail() ? "Let's get started - please enter your email" : CTAClickedButNoEmail || emailClickedButNoEmail ? "Sure, we just need an email address to contact you" : "Email address is invalid"), /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-email-input-container" }, /* @__PURE__ */ React12.createElement(
|
|
4926
|
+
"input",
|
|
4927
|
+
{
|
|
4928
|
+
type: "email",
|
|
4929
|
+
name: "email",
|
|
4930
|
+
id: "email",
|
|
4931
|
+
className: emailValid ? emailInputSet ? "ai-chat-email-input-set" : "ai-chat-email-input" : "ai-chat-email-input-invalid",
|
|
4932
|
+
placeholder: customerEmailCapturePlaceholder,
|
|
4933
|
+
value: emailInput,
|
|
4934
|
+
onChange: (e) => {
|
|
4935
|
+
const newEmail = e.target.value;
|
|
4936
|
+
setEmailInput(newEmail);
|
|
4937
|
+
if (!emailInputSet) {
|
|
4938
|
+
if (customerEmailCaptureMode === "REQUIRED" && newEmail !== "") {
|
|
4939
|
+
setEmailValid(isEmailAddress(newEmail));
|
|
4940
|
+
} else {
|
|
4941
|
+
setEmailValid(true);
|
|
4942
|
+
}
|
|
4943
|
+
}
|
|
4944
|
+
},
|
|
4945
|
+
onBlur: () => {
|
|
4946
|
+
if (emailInput && isEmailAddress(emailInput) && !emailInputSet) {
|
|
4947
|
+
setEmailInputSet(true);
|
|
4948
|
+
setEmailValid(true);
|
|
4949
|
+
interactionClicked("", "emailcapture", emailInput);
|
|
4950
|
+
if (CTAClickedButNoEmail) {
|
|
4951
|
+
sendCallToActionEmail(emailInput);
|
|
4952
|
+
setCTAClickedButNoEmail(false);
|
|
4953
|
+
}
|
|
4954
|
+
if (emailClickedButNoEmail) {
|
|
4955
|
+
handleSendEmail(emailInput, emailInput);
|
|
4956
|
+
setEmailClickedButNoEmail(false);
|
|
4957
|
+
}
|
|
4958
|
+
} else if (customerEmailCaptureMode === "REQUIRED" && emailInput !== "") {
|
|
4959
|
+
setEmailValid(isEmailAddress(emailInput));
|
|
4960
|
+
}
|
|
4961
|
+
},
|
|
4962
|
+
onKeyDown: (e) => {
|
|
4963
|
+
if (e.key === "Enter") {
|
|
4964
|
+
if (isEmailAddress(emailInput)) {
|
|
4965
|
+
setEmailInputSet(true);
|
|
4966
|
+
setEmailValid(true);
|
|
4967
|
+
interactionClicked("", "emailcapture", emailInput);
|
|
4968
|
+
if (CTAClickedButNoEmail) {
|
|
4969
|
+
sendCallToActionEmail(emailInput);
|
|
4970
|
+
setCTAClickedButNoEmail(false);
|
|
4971
|
+
}
|
|
4972
|
+
if (emailClickedButNoEmail) {
|
|
4973
|
+
handleSendEmail(emailInput, emailInput);
|
|
4974
|
+
setEmailClickedButNoEmail(false);
|
|
4975
|
+
}
|
|
4976
|
+
} else {
|
|
4977
|
+
setEmailValid(false);
|
|
4978
|
+
}
|
|
4979
|
+
}
|
|
4980
|
+
},
|
|
4981
|
+
disabled: false
|
|
4982
|
+
}
|
|
4983
|
+
), emailInputSet && /* @__PURE__ */ React12.createElement(
|
|
4984
|
+
"button",
|
|
4985
|
+
{
|
|
4986
|
+
className: "ai-chat-email-edit-button",
|
|
4987
|
+
onClick: () => {
|
|
4988
|
+
setEmailInputSet(false);
|
|
4989
|
+
setEmailValid(true);
|
|
4990
|
+
},
|
|
4991
|
+
title: "Edit email"
|
|
4992
|
+
},
|
|
4993
|
+
"\u270E"
|
|
4994
|
+
))),
|
|
4995
|
+
/* @__PURE__ */ React12.createElement(
|
|
4996
|
+
ChatInput,
|
|
4997
|
+
{
|
|
4998
|
+
placeholder,
|
|
4999
|
+
idle,
|
|
5000
|
+
onSubmit: continueChat,
|
|
5001
|
+
onStop: handleStop,
|
|
5002
|
+
agentOptions,
|
|
5003
|
+
currentAgentId,
|
|
5004
|
+
onAgentChange,
|
|
5005
|
+
agentsLoading,
|
|
5006
|
+
currentAgentLabel: currentAgentLabel || void 0,
|
|
5007
|
+
currentAgentAvatarUrl: currentAgentAvatarUrl || void 0,
|
|
5008
|
+
contextSections,
|
|
5009
|
+
totalContextTokens,
|
|
5010
|
+
maxContextTokens,
|
|
5011
|
+
enableContextDetailView
|
|
5012
|
+
}
|
|
5013
|
+
),
|
|
5014
|
+
showPoweredBy && /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-panel__footer" }, mcpServers && mcpServers.length > 0 && /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-tools-status" }, /* @__PURE__ */ React12.createElement(
|
|
5015
|
+
"span",
|
|
5016
|
+
{
|
|
5017
|
+
className: `ai-chat-tools-status__dot ${toolsLoading ? "loading" : toolsFetchError ? "error" : "ready"}`
|
|
5018
|
+
}
|
|
5019
|
+
), /* @__PURE__ */ React12.createElement("span", { className: "ai-chat-tools-status__text" }, toolsLoading ? "tools loading..." : toolsFetchError ? "tool fetch failed" : toolList.length > 0 ? `${toolList.length} tools ready` : "no tools found")), /* @__PURE__ */ React12.createElement("div", { className: "ai-chat-powered-by" }, /* @__PURE__ */ React12.createElement("span", null, "brought to you by"), /* @__PURE__ */ React12.createElement("a", { href: "https://llmasaservice.io", target: "_blank", rel: "noopener noreferrer" }, /* @__PURE__ */ React12.createElement(LLMAsAServiceLogo, null), /* @__PURE__ */ React12.createElement("span", null, "llmasaservice.io")))),
|
|
5020
|
+
/* @__PURE__ */ React12.createElement(
|
|
5021
|
+
ToolInfoModal_default2,
|
|
5022
|
+
{
|
|
5023
|
+
isOpen: isToolInfoModalOpen,
|
|
5024
|
+
onClose: () => setIsToolInfoModalOpen(false),
|
|
5025
|
+
data: toolInfoData
|
|
5026
|
+
}
|
|
5027
|
+
)
|
|
5028
|
+
);
|
|
4304
5029
|
};
|
|
4305
|
-
var AIChatPanel_default =
|
|
5030
|
+
var AIChatPanel_default = React12.memo(AIChatPanel);
|
|
4306
5031
|
|
|
4307
5032
|
// src/hooks/useAgentRegistry.ts
|
|
4308
5033
|
import { useState as useState7, useEffect as useEffect8, useCallback as useCallback3, useMemo as useMemo3 } from "react";
|
|
@@ -4504,15 +5229,15 @@ function extractAgentNameFromMessage(message) {
|
|
|
4504
5229
|
}
|
|
4505
5230
|
|
|
4506
5231
|
// src/AIAgentPanel.tsx
|
|
4507
|
-
var SearchIcon2 = () => /* @__PURE__ */
|
|
4508
|
-
var PlusIcon = () => /* @__PURE__ */
|
|
4509
|
-
var ChevronLeftIcon = () => /* @__PURE__ */
|
|
4510
|
-
var ChevronRightIcon = () => /* @__PURE__ */
|
|
4511
|
-
var MessageIcon = () => /* @__PURE__ */
|
|
4512
|
-
var
|
|
4513
|
-
var LoadingDotIcon = () => /* @__PURE__ */
|
|
4514
|
-
var SidebarIcon = () => /* @__PURE__ */
|
|
4515
|
-
var SparkleIcon = () => /* @__PURE__ */
|
|
5232
|
+
var SearchIcon2 = () => /* @__PURE__ */ React13.createElement("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React13.createElement("path", { d: "M7.333 12.667A5.333 5.333 0 1 0 7.333 2a5.333 5.333 0 0 0 0 10.667ZM14 14l-2.9-2.9", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }));
|
|
5233
|
+
var PlusIcon = () => /* @__PURE__ */ React13.createElement("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React13.createElement("path", { d: "M8 3.333v9.334M3.333 8h9.334", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }));
|
|
5234
|
+
var ChevronLeftIcon = () => /* @__PURE__ */ React13.createElement("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React13.createElement("path", { d: "M10 12L6 8l4-4", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }));
|
|
5235
|
+
var ChevronRightIcon = () => /* @__PURE__ */ React13.createElement("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React13.createElement("path", { d: "M6 12l4-4-4-4", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }));
|
|
5236
|
+
var MessageIcon = () => /* @__PURE__ */ React13.createElement("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React13.createElement("path", { d: "M14 10a1.333 1.333 0 0 1-1.333 1.333H4L2 14V3.333A1.333 1.333 0 0 1 3.333 2h9.334A1.333 1.333 0 0 1 14 3.333V10Z", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }));
|
|
5237
|
+
var CloseIcon2 = () => /* @__PURE__ */ React13.createElement("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React13.createElement("path", { d: "M9 3L3 9M3 3l6 6", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }));
|
|
5238
|
+
var LoadingDotIcon = () => /* @__PURE__ */ React13.createElement("span", { className: "ai-agent-panel__loading-dot" });
|
|
5239
|
+
var SidebarIcon = () => /* @__PURE__ */ React13.createElement("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React13.createElement("rect", { x: "2", y: "2", width: "12", height: "12", rx: "2", stroke: "currentColor", strokeWidth: "1.5" }), /* @__PURE__ */ React13.createElement("path", { d: "M6 2v12", stroke: "currentColor", strokeWidth: "1.5" }));
|
|
5240
|
+
var SparkleIcon = () => /* @__PURE__ */ React13.createElement("svg", { width: "14", height: "14", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React13.createElement("path", { d: "M8 1v3M8 12v3M3 8H0M16 8h-3M12.95 3.05l-2.12 2.12M5.17 10.83l-2.12 2.12M12.95 12.95l-2.12-2.12M5.17 5.17L3.05 3.05", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }), /* @__PURE__ */ React13.createElement("circle", { cx: "8", cy: "8", r: "2", fill: "currentColor" }));
|
|
4516
5241
|
var normalizeConversationListPayload = (payload) => {
|
|
4517
5242
|
if (!payload) return [];
|
|
4518
5243
|
const conversations = Array.isArray(payload) ? payload : payload.conversations || [];
|
|
@@ -4635,9 +5360,25 @@ var ChatPanelWrapper = ({
|
|
|
4635
5360
|
maxContextTokens,
|
|
4636
5361
|
enableContextDetailView,
|
|
4637
5362
|
onConversationCreated,
|
|
4638
|
-
conversationInitialPrompt
|
|
5363
|
+
conversationInitialPrompt,
|
|
5364
|
+
// New props from ChatPanel port
|
|
5365
|
+
cssUrl,
|
|
5366
|
+
markdownClass,
|
|
5367
|
+
width,
|
|
5368
|
+
height,
|
|
5369
|
+
scrollToEnd,
|
|
5370
|
+
prismStyle,
|
|
5371
|
+
showSaveButton,
|
|
5372
|
+
showEmailButton,
|
|
5373
|
+
messages,
|
|
5374
|
+
showCallToAction,
|
|
5375
|
+
callToActionButtonText,
|
|
5376
|
+
callToActionEmailAddress,
|
|
5377
|
+
callToActionEmailSubject,
|
|
5378
|
+
customerEmailCaptureMode,
|
|
5379
|
+
customerEmailCapturePlaceholder
|
|
4639
5380
|
}) => {
|
|
4640
|
-
var _a, _b;
|
|
5381
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
4641
5382
|
const convAgentProfile = getAgent(activeConv.agentId);
|
|
4642
5383
|
const convAgentMetadata = convAgentProfile == null ? void 0 : convAgentProfile.metadata;
|
|
4643
5384
|
const isVisible = currentConversationId === activeConv.conversationId;
|
|
@@ -4673,13 +5414,13 @@ var ChatPanelWrapper = ({
|
|
|
4673
5414
|
}, [convAgentProfile == null ? void 0 : convAgentProfile.mcpServers]);
|
|
4674
5415
|
const effectiveInitialPrompt = conversationInitialPrompt || initialPrompt;
|
|
4675
5416
|
if (!convAgentMetadata) return null;
|
|
4676
|
-
return /* @__PURE__ */
|
|
5417
|
+
return /* @__PURE__ */ React13.createElement(
|
|
4677
5418
|
"div",
|
|
4678
5419
|
{
|
|
4679
5420
|
className: "ai-agent-panel__chat-wrapper",
|
|
4680
5421
|
style: { display: isVisible ? "flex" : "none" }
|
|
4681
5422
|
},
|
|
4682
|
-
/* @__PURE__ */
|
|
5423
|
+
/* @__PURE__ */ React13.createElement(
|
|
4683
5424
|
AIChatPanel_default,
|
|
4684
5425
|
{
|
|
4685
5426
|
project_id: convAgentMetadata.projectId,
|
|
@@ -4704,7 +5445,7 @@ var ChatPanelWrapper = ({
|
|
|
4704
5445
|
customer: effectiveCustomer,
|
|
4705
5446
|
showPoweredBy,
|
|
4706
5447
|
showNewConversationButton: false,
|
|
4707
|
-
createConversationOnFirstChat: (_b =
|
|
5448
|
+
createConversationOnFirstChat: (_b = convAgentProfile == null ? void 0 : convAgentProfile.createConversationOnFirstChat) != null ? _b : true,
|
|
4708
5449
|
mcpServers,
|
|
4709
5450
|
actions,
|
|
4710
5451
|
followOnQuestions: effectiveFollowOnQuestions,
|
|
@@ -4719,13 +5460,28 @@ var ChatPanelWrapper = ({
|
|
|
4719
5460
|
totalContextTokens,
|
|
4720
5461
|
maxContextTokens,
|
|
4721
5462
|
enableContextDetailView,
|
|
4722
|
-
onConversationCreated: conversationCreatedCallback
|
|
5463
|
+
onConversationCreated: conversationCreatedCallback,
|
|
5464
|
+
cssUrl,
|
|
5465
|
+
markdownClass,
|
|
5466
|
+
width,
|
|
5467
|
+
height,
|
|
5468
|
+
scrollToEnd: scrollToEnd != null ? scrollToEnd : convAgentMetadata.displayAutoScroll,
|
|
5469
|
+
prismStyle,
|
|
5470
|
+
showSaveButton: (_c = showSaveButton != null ? showSaveButton : convAgentMetadata.displayShowSaveButton) != null ? _c : true,
|
|
5471
|
+
showEmailButton: (_d = showEmailButton != null ? showEmailButton : convAgentMetadata.displayShowEmailButton) != null ? _d : true,
|
|
5472
|
+
messages,
|
|
5473
|
+
showCallToAction: (_e = showCallToAction != null ? showCallToAction : convAgentMetadata.displayShowCallToAction) != null ? _e : false,
|
|
5474
|
+
callToActionButtonText: (_f = callToActionButtonText != null ? callToActionButtonText : convAgentMetadata.displayCallToActionButtonText) != null ? _f : "Submit",
|
|
5475
|
+
callToActionEmailAddress: (_g = callToActionEmailAddress != null ? callToActionEmailAddress : convAgentMetadata.displayCallToActionEmailAddress) != null ? _g : "",
|
|
5476
|
+
callToActionEmailSubject: (_h = callToActionEmailSubject != null ? callToActionEmailSubject : convAgentMetadata.displayCallToActionEmailSubject) != null ? _h : "Agent CTA submitted",
|
|
5477
|
+
customerEmailCaptureMode: (_i = customerEmailCaptureMode != null ? customerEmailCaptureMode : convAgentMetadata == null ? void 0 : convAgentMetadata.customerEmailCaptureMode) != null ? _i : "HIDE",
|
|
5478
|
+
customerEmailCapturePlaceholder: (_j = customerEmailCapturePlaceholder != null ? customerEmailCapturePlaceholder : convAgentMetadata == null ? void 0 : convAgentMetadata.customerEmailCapturePlaceholder) != null ? _j : "Please enter your email..."
|
|
4723
5479
|
}
|
|
4724
5480
|
)
|
|
4725
5481
|
);
|
|
4726
5482
|
};
|
|
4727
5483
|
ChatPanelWrapper.displayName = "ChatPanelWrapper";
|
|
4728
|
-
var AIAgentPanel =
|
|
5484
|
+
var AIAgentPanel = React13.forwardRef(({
|
|
4729
5485
|
agents,
|
|
4730
5486
|
defaultAgent,
|
|
4731
5487
|
customerId,
|
|
@@ -4764,7 +5520,23 @@ var AIAgentPanel = React12.forwardRef(({
|
|
|
4764
5520
|
followOnQuestions = [],
|
|
4765
5521
|
followOnPrompt = "",
|
|
4766
5522
|
historyListLimit = 50,
|
|
4767
|
-
showConversationHistory = true
|
|
5523
|
+
showConversationHistory = true,
|
|
5524
|
+
// New props from ChatPanel port
|
|
5525
|
+
cssUrl,
|
|
5526
|
+
markdownClass,
|
|
5527
|
+
width,
|
|
5528
|
+
height,
|
|
5529
|
+
scrollToEnd,
|
|
5530
|
+
prismStyle,
|
|
5531
|
+
showSaveButton,
|
|
5532
|
+
showEmailButton,
|
|
5533
|
+
messages,
|
|
5534
|
+
showCallToAction,
|
|
5535
|
+
callToActionButtonText,
|
|
5536
|
+
callToActionEmailAddress,
|
|
5537
|
+
callToActionEmailSubject,
|
|
5538
|
+
customerEmailCaptureMode,
|
|
5539
|
+
customerEmailCapturePlaceholder
|
|
4768
5540
|
}, ref) => {
|
|
4769
5541
|
var _a, _b, _c, _d;
|
|
4770
5542
|
const [isCollapsed, setIsCollapsed] = useState8(collapsible && defaultCollapsed);
|
|
@@ -4779,9 +5551,9 @@ var AIAgentPanel = React12.forwardRef(({
|
|
|
4779
5551
|
if (typeof window !== "undefined") {
|
|
4780
5552
|
const savedWidth = localStorage.getItem("ai-agent-panel-width");
|
|
4781
5553
|
if (savedWidth) {
|
|
4782
|
-
const
|
|
4783
|
-
if (
|
|
4784
|
-
return
|
|
5554
|
+
const width2 = parseInt(savedWidth, 10);
|
|
5555
|
+
if (width2 >= minWidth && width2 <= maxWidth) {
|
|
5556
|
+
return width2;
|
|
4785
5557
|
}
|
|
4786
5558
|
}
|
|
4787
5559
|
}
|
|
@@ -4847,7 +5619,7 @@ var AIAgentPanel = React12.forwardRef(({
|
|
|
4847
5619
|
activeConversationsRef.current = activeConversations;
|
|
4848
5620
|
const currentConversationIdRef = useRef6(currentConversationId);
|
|
4849
5621
|
currentConversationIdRef.current = currentConversationId;
|
|
4850
|
-
|
|
5622
|
+
React13.useImperativeHandle(ref, () => ({
|
|
4851
5623
|
startNewConversation: (prompt, agent) => {
|
|
4852
5624
|
const targetAgent = agent || currentAgentId;
|
|
4853
5625
|
const tempId = `new-${Date.now()}`;
|
|
@@ -5551,7 +6323,7 @@ var AIAgentPanel = React12.forwardRef(({
|
|
|
5551
6323
|
!showConversationHistory ? "ai-agent-panel--no-history" : ""
|
|
5552
6324
|
].filter(Boolean).join(" ");
|
|
5553
6325
|
if (collapsible && isCollapsed) {
|
|
5554
|
-
return /* @__PURE__ */
|
|
6326
|
+
return /* @__PURE__ */ React13.createElement("div", { className: panelClasses, ref: panelRef }, /* @__PURE__ */ React13.createElement(
|
|
5555
6327
|
"div",
|
|
5556
6328
|
{
|
|
5557
6329
|
className: "ai-agent-panel__collapsed-bar",
|
|
@@ -5562,9 +6334,9 @@ var AIAgentPanel = React12.forwardRef(({
|
|
|
5562
6334
|
},
|
|
5563
6335
|
title: "Click to expand"
|
|
5564
6336
|
},
|
|
5565
|
-
/* @__PURE__ */
|
|
5566
|
-
/* @__PURE__ */
|
|
5567
|
-
showConversationHistory && /* @__PURE__ */
|
|
6337
|
+
/* @__PURE__ */ React13.createElement(Tooltip, { content: "Expand Panel", side: "left" }, /* @__PURE__ */ React13.createElement(Button, { variant: "ghost", size: "icon", onClick: toggleCollapse }, position === "right" ? /* @__PURE__ */ React13.createElement(ChevronLeftIcon, null) : /* @__PURE__ */ React13.createElement(ChevronRightIcon, null))),
|
|
6338
|
+
/* @__PURE__ */ React13.createElement("div", { className: "ai-agent-panel__collapsed-divider" }),
|
|
6339
|
+
showConversationHistory && /* @__PURE__ */ React13.createElement(Tooltip, { content: "Search", side: "left" }, /* @__PURE__ */ React13.createElement(
|
|
5568
6340
|
Button,
|
|
5569
6341
|
{
|
|
5570
6342
|
variant: "ghost",
|
|
@@ -5574,9 +6346,9 @@ var AIAgentPanel = React12.forwardRef(({
|
|
|
5574
6346
|
setShowSearch(true);
|
|
5575
6347
|
}
|
|
5576
6348
|
},
|
|
5577
|
-
/* @__PURE__ */
|
|
6349
|
+
/* @__PURE__ */ React13.createElement(SearchIcon2, null)
|
|
5578
6350
|
)),
|
|
5579
|
-
/* @__PURE__ */
|
|
6351
|
+
/* @__PURE__ */ React13.createElement(Tooltip, { content: "New Chat", side: "left" }, /* @__PURE__ */ React13.createElement(
|
|
5580
6352
|
Button,
|
|
5581
6353
|
{
|
|
5582
6354
|
variant: "ghost",
|
|
@@ -5586,15 +6358,15 @@ var AIAgentPanel = React12.forwardRef(({
|
|
|
5586
6358
|
handleNewConversation();
|
|
5587
6359
|
}
|
|
5588
6360
|
},
|
|
5589
|
-
/* @__PURE__ */
|
|
6361
|
+
/* @__PURE__ */ React13.createElement(PlusIcon, null)
|
|
5590
6362
|
)),
|
|
5591
|
-
/* @__PURE__ */
|
|
6363
|
+
/* @__PURE__ */ React13.createElement("div", { className: "ai-agent-panel__collapsed-divider" }),
|
|
5592
6364
|
agentList.map((agent) => {
|
|
5593
6365
|
const activeConvForAgent = activeConversationsList.find(
|
|
5594
6366
|
(conv) => conv.agentId === agent.id
|
|
5595
6367
|
);
|
|
5596
6368
|
const hasActiveConversation = !!activeConvForAgent;
|
|
5597
|
-
return /* @__PURE__ */
|
|
6369
|
+
return /* @__PURE__ */ React13.createElement(Tooltip, { key: agent.id, content: agent.name, side: "left" }, /* @__PURE__ */ React13.createElement(
|
|
5598
6370
|
Button,
|
|
5599
6371
|
{
|
|
5600
6372
|
variant: agent.id === currentAgentId ? "secondary" : "ghost",
|
|
@@ -5628,7 +6400,7 @@ var AIAgentPanel = React12.forwardRef(({
|
|
|
5628
6400
|
},
|
|
5629
6401
|
className: `ai-agent-panel__agent-icon ${hasActiveConversation ? "ai-agent-panel__agent-icon--active" : ""}`
|
|
5630
6402
|
},
|
|
5631
|
-
agent.avatarUrl ? /* @__PURE__ */
|
|
6403
|
+
agent.avatarUrl ? /* @__PURE__ */ React13.createElement(
|
|
5632
6404
|
"img",
|
|
5633
6405
|
{
|
|
5634
6406
|
src: agent.avatarUrl,
|
|
@@ -5636,20 +6408,20 @@ var AIAgentPanel = React12.forwardRef(({
|
|
|
5636
6408
|
className: "ai-agent-panel__agent-avatar"
|
|
5637
6409
|
}
|
|
5638
6410
|
) : agent.name.charAt(0).toUpperCase(),
|
|
5639
|
-
hasActiveConversation && /* @__PURE__ */
|
|
6411
|
+
hasActiveConversation && /* @__PURE__ */ React13.createElement("span", { className: "ai-agent-panel__agent-active-indicator" })
|
|
5640
6412
|
));
|
|
5641
6413
|
}),
|
|
5642
|
-
/* @__PURE__ */
|
|
6414
|
+
/* @__PURE__ */ React13.createElement("div", { className: "ai-agent-panel__collapsed-spacer" })
|
|
5643
6415
|
));
|
|
5644
6416
|
}
|
|
5645
|
-
return /* @__PURE__ */
|
|
6417
|
+
return /* @__PURE__ */ React13.createElement(
|
|
5646
6418
|
"div",
|
|
5647
6419
|
{
|
|
5648
6420
|
className: panelClasses,
|
|
5649
6421
|
ref: panelRef,
|
|
5650
6422
|
style: { width: `${panelWidth}px` }
|
|
5651
6423
|
},
|
|
5652
|
-
/* @__PURE__ */
|
|
6424
|
+
/* @__PURE__ */ React13.createElement(
|
|
5653
6425
|
"div",
|
|
5654
6426
|
{
|
|
5655
6427
|
ref: resizeRef,
|
|
@@ -5661,9 +6433,9 @@ var AIAgentPanel = React12.forwardRef(({
|
|
|
5661
6433
|
tabIndex: 0
|
|
5662
6434
|
}
|
|
5663
6435
|
),
|
|
5664
|
-
showConversationHistory && /* @__PURE__ */
|
|
6436
|
+
showConversationHistory && /* @__PURE__ */ React13.createElement("div", { className: `ai-agent-panel__sidebar ${isHistoryCollapsed ? "ai-agent-panel__sidebar--collapsed" : ""}` }, isHistoryCollapsed ? (
|
|
5665
6437
|
// Collapsed history bar
|
|
5666
|
-
/* @__PURE__ */
|
|
6438
|
+
/* @__PURE__ */ React13.createElement(
|
|
5667
6439
|
"div",
|
|
5668
6440
|
{
|
|
5669
6441
|
className: "ai-agent-panel__history-collapsed-bar",
|
|
@@ -5674,32 +6446,32 @@ var AIAgentPanel = React12.forwardRef(({
|
|
|
5674
6446
|
},
|
|
5675
6447
|
title: "Click to expand history"
|
|
5676
6448
|
},
|
|
5677
|
-
/* @__PURE__ */
|
|
6449
|
+
/* @__PURE__ */ React13.createElement(Tooltip, { content: "Expand History", side: sidebarPosition === "left" ? "right" : "left" }, /* @__PURE__ */ React13.createElement(
|
|
5678
6450
|
Button,
|
|
5679
6451
|
{
|
|
5680
6452
|
variant: "ghost",
|
|
5681
6453
|
size: "icon",
|
|
5682
6454
|
onClick: toggleHistoryCollapse
|
|
5683
6455
|
},
|
|
5684
|
-
/* @__PURE__ */
|
|
6456
|
+
/* @__PURE__ */ React13.createElement(ChevronRightIcon, null)
|
|
5685
6457
|
)),
|
|
5686
|
-
/* @__PURE__ */
|
|
5687
|
-
/* @__PURE__ */
|
|
6458
|
+
/* @__PURE__ */ React13.createElement("div", { className: "ai-agent-panel__collapsed-divider" }),
|
|
6459
|
+
/* @__PURE__ */ React13.createElement(Tooltip, { content: "New Chat", side: sidebarPosition === "left" ? "right" : "left" }, /* @__PURE__ */ React13.createElement(
|
|
5688
6460
|
Button,
|
|
5689
6461
|
{
|
|
5690
6462
|
variant: "ghost",
|
|
5691
6463
|
size: "icon",
|
|
5692
6464
|
onClick: handleNewConversation
|
|
5693
6465
|
},
|
|
5694
|
-
/* @__PURE__ */
|
|
6466
|
+
/* @__PURE__ */ React13.createElement(PlusIcon, null)
|
|
5695
6467
|
)),
|
|
5696
|
-
/* @__PURE__ */
|
|
6468
|
+
/* @__PURE__ */ React13.createElement("div", { className: "ai-agent-panel__collapsed-divider" }),
|
|
5697
6469
|
agentList.map((agent) => {
|
|
5698
6470
|
const activeConvForAgent = activeConversationsList.find(
|
|
5699
6471
|
(conv) => conv.agentId === agent.id
|
|
5700
6472
|
);
|
|
5701
6473
|
const hasActiveConversation = !!activeConvForAgent;
|
|
5702
|
-
return /* @__PURE__ */
|
|
6474
|
+
return /* @__PURE__ */ React13.createElement(Tooltip, { key: agent.id, content: agent.name, side: sidebarPosition === "left" ? "right" : "left" }, /* @__PURE__ */ React13.createElement(
|
|
5703
6475
|
Button,
|
|
5704
6476
|
{
|
|
5705
6477
|
variant: agent.id === currentAgentId ? "secondary" : "ghost",
|
|
@@ -5732,7 +6504,7 @@ var AIAgentPanel = React12.forwardRef(({
|
|
|
5732
6504
|
},
|
|
5733
6505
|
className: `ai-agent-panel__agent-icon ${hasActiveConversation ? "ai-agent-panel__agent-icon--active" : ""}`
|
|
5734
6506
|
},
|
|
5735
|
-
agent.avatarUrl ? /* @__PURE__ */
|
|
6507
|
+
agent.avatarUrl ? /* @__PURE__ */ React13.createElement(
|
|
5736
6508
|
"img",
|
|
5737
6509
|
{
|
|
5738
6510
|
src: agent.avatarUrl,
|
|
@@ -5740,40 +6512,40 @@ var AIAgentPanel = React12.forwardRef(({
|
|
|
5740
6512
|
className: "ai-agent-panel__agent-avatar"
|
|
5741
6513
|
}
|
|
5742
6514
|
) : agent.name.charAt(0).toUpperCase(),
|
|
5743
|
-
hasActiveConversation && /* @__PURE__ */
|
|
6515
|
+
hasActiveConversation && /* @__PURE__ */ React13.createElement("span", { className: "ai-agent-panel__agent-active-indicator" })
|
|
5744
6516
|
));
|
|
5745
6517
|
}),
|
|
5746
|
-
/* @__PURE__ */
|
|
6518
|
+
/* @__PURE__ */ React13.createElement("div", { className: "ai-agent-panel__history-collapsed-spacer" })
|
|
5747
6519
|
)
|
|
5748
|
-
) : /* @__PURE__ */
|
|
6520
|
+
) : /* @__PURE__ */ React13.createElement(React13.Fragment, null, /* @__PURE__ */ React13.createElement("div", { className: "ai-agent-panel__header" }, /* @__PURE__ */ React13.createElement("div", { className: "ai-agent-panel__header-actions" }, showSearch ? /* @__PURE__ */ React13.createElement(
|
|
5749
6521
|
Input,
|
|
5750
6522
|
{
|
|
5751
6523
|
placeholder: "Search conversations...",
|
|
5752
6524
|
value: searchQuery,
|
|
5753
6525
|
onChange: (e) => setSearchQuery(e.target.value),
|
|
5754
|
-
icon: /* @__PURE__ */
|
|
6526
|
+
icon: /* @__PURE__ */ React13.createElement(SearchIcon2, null),
|
|
5755
6527
|
autoFocus: true,
|
|
5756
6528
|
onBlur: () => {
|
|
5757
6529
|
if (!searchQuery) setShowSearch(false);
|
|
5758
6530
|
}
|
|
5759
6531
|
}
|
|
5760
|
-
) : /* @__PURE__ */
|
|
6532
|
+
) : /* @__PURE__ */ React13.createElement(React13.Fragment, null, /* @__PURE__ */ React13.createElement(
|
|
5761
6533
|
Button,
|
|
5762
6534
|
{
|
|
5763
6535
|
variant: "ghost",
|
|
5764
6536
|
size: "icon",
|
|
5765
6537
|
onClick: () => setShowSearch(true)
|
|
5766
6538
|
},
|
|
5767
|
-
/* @__PURE__ */
|
|
5768
|
-
), /* @__PURE__ */
|
|
6539
|
+
/* @__PURE__ */ React13.createElement(SearchIcon2, null)
|
|
6540
|
+
), /* @__PURE__ */ React13.createElement(
|
|
5769
6541
|
Button,
|
|
5770
6542
|
{
|
|
5771
6543
|
variant: "ghost",
|
|
5772
6544
|
size: "icon",
|
|
5773
6545
|
onClick: handleNewConversation
|
|
5774
6546
|
},
|
|
5775
|
-
/* @__PURE__ */
|
|
5776
|
-
))), /* @__PURE__ */
|
|
6547
|
+
/* @__PURE__ */ React13.createElement(PlusIcon, null)
|
|
6548
|
+
))), /* @__PURE__ */ React13.createElement(Tooltip, { content: "Collapse History", side: "bottom" }, /* @__PURE__ */ React13.createElement(Button, { variant: "ghost", size: "icon", onClick: toggleHistoryCollapse }, /* @__PURE__ */ React13.createElement(SidebarIcon, null))), collapsible && /* @__PURE__ */ React13.createElement(Button, { variant: "ghost", size: "icon", onClick: toggleCollapse }, position === "right" ? /* @__PURE__ */ React13.createElement(ChevronRightIcon, null) : /* @__PURE__ */ React13.createElement(ChevronLeftIcon, null))), /* @__PURE__ */ React13.createElement(ScrollArea, { className: "ai-agent-panel__conversations" }, activeConversationsList.length > 0 && /* @__PURE__ */ React13.createElement("div", { className: "ai-agent-panel__group ai-agent-panel__group--active" }, /* @__PURE__ */ React13.createElement("div", { className: "ai-agent-panel__group-label" }, /* @__PURE__ */ React13.createElement("span", null, "Active (", activeConversationsList.length, ")")), activeConversationsList.map((activeConv) => /* @__PURE__ */ React13.createElement(
|
|
5777
6549
|
"div",
|
|
5778
6550
|
{
|
|
5779
6551
|
key: activeConv.stableKey,
|
|
@@ -5785,37 +6557,37 @@ var AIAgentPanel = React12.forwardRef(({
|
|
|
5785
6557
|
}
|
|
5786
6558
|
}
|
|
5787
6559
|
},
|
|
5788
|
-
/* @__PURE__ */
|
|
5789
|
-
/* @__PURE__ */
|
|
6560
|
+
/* @__PURE__ */ React13.createElement("div", { className: "ai-agent-panel__conversation-content" }, /* @__PURE__ */ React13.createElement("div", { className: "ai-agent-panel__conversation-title" }, activeConv.isLoading && /* @__PURE__ */ React13.createElement(LoadingDotIcon, null), /* @__PURE__ */ React13.createElement("span", null, activeConv.title))),
|
|
6561
|
+
/* @__PURE__ */ React13.createElement(
|
|
5790
6562
|
"button",
|
|
5791
6563
|
{
|
|
5792
6564
|
className: "ai-agent-panel__conversation-close",
|
|
5793
6565
|
onClick: (e) => handleCloseConversation(activeConv.conversationId, e),
|
|
5794
6566
|
title: "Close conversation"
|
|
5795
6567
|
},
|
|
5796
|
-
/* @__PURE__ */
|
|
6568
|
+
/* @__PURE__ */ React13.createElement(CloseIcon2, null)
|
|
5797
6569
|
)
|
|
5798
|
-
))), conversationsLoading ? /* @__PURE__ */
|
|
6570
|
+
))), conversationsLoading ? /* @__PURE__ */ React13.createElement("div", { className: "ai-agent-panel__loading" }, /* @__PURE__ */ React13.createElement("div", { className: "ai-agent-panel__loading-spinner" }), /* @__PURE__ */ React13.createElement("span", null, "Loading conversations...")) : conversationsError ? /* @__PURE__ */ React13.createElement("div", { className: "ai-agent-panel__empty" }, /* @__PURE__ */ React13.createElement("p", null, "Error: ", conversationsError), /* @__PURE__ */ React13.createElement(Button, { variant: "secondary", size: "sm", onClick: handleRefreshConversations }, "Retry")) : groupedConversations.length === 0 && activeConversationsList.length === 0 ? /* @__PURE__ */ React13.createElement("div", { className: "ai-agent-panel__empty" }, /* @__PURE__ */ React13.createElement(MessageIcon, null), /* @__PURE__ */ React13.createElement("p", null, "No conversations yet"), /* @__PURE__ */ React13.createElement("p", { className: "ai-agent-panel__empty-hint" }, "Start chatting to create your first conversation")) : /* @__PURE__ */ React13.createElement(React13.Fragment, null, activeConversationsList.length > 0 && groupedConversations.some((g) => g.count > 0) && /* @__PURE__ */ React13.createElement("div", { className: "ai-agent-panel__group-divider" }), groupedConversations.map((group) => /* @__PURE__ */ React13.createElement("div", { key: group.label, className: "ai-agent-panel__group" }, /* @__PURE__ */ React13.createElement(
|
|
5799
6571
|
"div",
|
|
5800
6572
|
{
|
|
5801
6573
|
className: "ai-agent-panel__group-label ai-agent-panel__group-label--clickable",
|
|
5802
6574
|
onClick: () => toggleSection(group.label)
|
|
5803
6575
|
},
|
|
5804
|
-
/* @__PURE__ */
|
|
5805
|
-
/* @__PURE__ */
|
|
6576
|
+
/* @__PURE__ */ React13.createElement("span", null, group.label, " ", group.count > 0 && `(${group.count})`),
|
|
6577
|
+
/* @__PURE__ */ React13.createElement("span", { className: "ai-agent-panel__group-chevron" }, expandedSections[group.label] ? "\u25BC" : "\u25B6")
|
|
5806
6578
|
), expandedSections[group.label] && group.conversations.length > 0 && group.conversations.map((conv) => {
|
|
5807
6579
|
const isActive = activeConversations.has(conv.conversationId);
|
|
5808
|
-
return /* @__PURE__ */
|
|
6580
|
+
return /* @__PURE__ */ React13.createElement(
|
|
5809
6581
|
"div",
|
|
5810
6582
|
{
|
|
5811
6583
|
key: conv.conversationId,
|
|
5812
6584
|
className: `ai-agent-panel__conversation ${currentConversationId === conv.conversationId ? "ai-agent-panel__conversation--current" : ""} ${isActive ? "ai-agent-panel__conversation--in-active" : ""}`,
|
|
5813
6585
|
onClick: () => handleConversationSelect(conv)
|
|
5814
6586
|
},
|
|
5815
|
-
/* @__PURE__ */
|
|
6587
|
+
/* @__PURE__ */ React13.createElement("div", { className: "ai-agent-panel__conversation-content" }, /* @__PURE__ */ React13.createElement("div", { className: "ai-agent-panel__conversation-title" }, isActive && /* @__PURE__ */ React13.createElement("span", { className: "ai-agent-panel__active-badge" }, "\u25CF"), conversationFirstPrompts[conv.conversationId] || conv.title))
|
|
5816
6588
|
);
|
|
5817
6589
|
}))))))),
|
|
5818
|
-
/* @__PURE__ */
|
|
6590
|
+
/* @__PURE__ */ React13.createElement("div", { className: "ai-agent-panel__chat" }, !showConversationHistory && collapsible && /* @__PURE__ */ React13.createElement("div", { className: "ai-agent-panel__chat-header" }, /* @__PURE__ */ React13.createElement("div", { className: "ai-agent-panel__chat-header-spacer" }), /* @__PURE__ */ React13.createElement(Tooltip, { content: "Collapse Panel", side: position === "right" ? "left" : "right" }, /* @__PURE__ */ React13.createElement(Button, { variant: "ghost", size: "icon", onClick: toggleCollapse }, position === "right" ? /* @__PURE__ */ React13.createElement(ChevronRightIcon, null) : /* @__PURE__ */ React13.createElement(ChevronLeftIcon, null)))), showContextNotification && /* @__PURE__ */ React13.createElement("div", { className: "ai-agent-panel__context-notification" }, /* @__PURE__ */ React13.createElement(SparkleIcon, null), /* @__PURE__ */ React13.createElement("span", null, "Agent now has new context")), activeConversationsList.map((activeConv) => /* @__PURE__ */ React13.createElement(
|
|
5819
6591
|
ChatPanelWrapper,
|
|
5820
6592
|
{
|
|
5821
6593
|
key: `${activeConv.stableKey}-${activeConv.agentId}`,
|
|
@@ -5847,10 +6619,25 @@ var AIAgentPanel = React12.forwardRef(({
|
|
|
5847
6619
|
maxContextTokens,
|
|
5848
6620
|
enableContextDetailView,
|
|
5849
6621
|
onConversationCreated: handleConversationCreated,
|
|
5850
|
-
conversationInitialPrompt: activeConv.conversationInitialPrompt
|
|
6622
|
+
conversationInitialPrompt: activeConv.conversationInitialPrompt,
|
|
6623
|
+
cssUrl,
|
|
6624
|
+
markdownClass,
|
|
6625
|
+
width,
|
|
6626
|
+
height,
|
|
6627
|
+
scrollToEnd,
|
|
6628
|
+
prismStyle,
|
|
6629
|
+
showSaveButton,
|
|
6630
|
+
showEmailButton,
|
|
6631
|
+
messages,
|
|
6632
|
+
showCallToAction,
|
|
6633
|
+
callToActionButtonText,
|
|
6634
|
+
callToActionEmailAddress,
|
|
6635
|
+
callToActionEmailSubject,
|
|
6636
|
+
customerEmailCaptureMode,
|
|
6637
|
+
customerEmailCapturePlaceholder
|
|
5851
6638
|
}
|
|
5852
|
-
)), loadingConversationId && /* @__PURE__ */
|
|
5853
|
-
/* @__PURE__ */
|
|
6639
|
+
)), loadingConversationId && /* @__PURE__ */ React13.createElement("div", { className: "ai-agent-panel__conversation-loading-overlay" }, /* @__PURE__ */ React13.createElement("div", { className: "ai-agent-panel__loading-spinner" }), /* @__PURE__ */ React13.createElement("p", null, "Loading conversation...")), currentAgentMetadata && activeConversationsList.length === 0 && !loadingConversationId && /* @__PURE__ */ React13.createElement("div", { className: "ai-agent-panel__empty-chat" }, /* @__PURE__ */ React13.createElement(MessageIcon, null), /* @__PURE__ */ React13.createElement("p", null, "Select a conversation or start a new one"), /* @__PURE__ */ React13.createElement(Button, { variant: "default", size: "sm", onClick: handleNewConversation }, "New Conversation")), agentsLoading && !currentAgentMetadata && /* @__PURE__ */ React13.createElement("div", { className: "ai-agent-panel__loading" }, /* @__PURE__ */ React13.createElement("div", { className: "ai-agent-panel__loading-spinner" }), /* @__PURE__ */ React13.createElement("p", null, "Loading agent..."))),
|
|
6640
|
+
/* @__PURE__ */ React13.createElement(
|
|
5854
6641
|
Dialog,
|
|
5855
6642
|
{
|
|
5856
6643
|
isOpen: showHandoffDialog,
|
|
@@ -5858,7 +6645,7 @@ var AIAgentPanel = React12.forwardRef(({
|
|
|
5858
6645
|
title: "Switch Agent?",
|
|
5859
6646
|
description: handoffSource === "page" ? `This page has a recommended agent: ${suggestedAgent ? ((_b = (_a = getAgent(suggestedAgent)) == null ? void 0 : _a.metadata) == null ? void 0 : _b.displayTitle) || suggestedAgent : "another agent"}. Would you like to switch?` : `The current agent suggests transferring this conversation to ${suggestedAgent ? ((_d = (_c = getAgent(suggestedAgent)) == null ? void 0 : _c.metadata) == null ? void 0 : _d.displayTitle) || suggestedAgent : "another agent"}.`
|
|
5860
6647
|
},
|
|
5861
|
-
/* @__PURE__ */
|
|
6648
|
+
/* @__PURE__ */ React13.createElement(DialogFooter, null, /* @__PURE__ */ React13.createElement(Button, { variant: "outline", onClick: handleHandoffCancel }, "Stay with current agent"), /* @__PURE__ */ React13.createElement(Button, { onClick: handleHandoffConfirm }, "Switch agent"))
|
|
5862
6649
|
)
|
|
5863
6650
|
);
|
|
5864
6651
|
});
|