@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.js
CHANGED
|
@@ -273,6 +273,7 @@ var ChatPanel = ({
|
|
|
273
273
|
const [alwaysApprovedTools, setAlwaysApprovedTools] = (0, import_react3.useState)([]);
|
|
274
274
|
const [thinkingBlocks, setThinkingBlocks] = (0, import_react3.useState)([]);
|
|
275
275
|
const [currentThinkingIndex, setCurrentThinkingIndex] = (0, import_react3.useState)(0);
|
|
276
|
+
const [error, setError] = (0, import_react3.useState)(null);
|
|
276
277
|
const [userResizedHeight, setUserResizedHeight] = (0, import_react3.useState)(null);
|
|
277
278
|
const [pendingButtonAttachments, setPendingButtonAttachments] = (0, import_react3.useState)([]);
|
|
278
279
|
const actionMatchRegistry = (0, import_react3.useRef)(/* @__PURE__ */ new Map());
|
|
@@ -574,10 +575,10 @@ var ChatPanel = ({
|
|
|
574
575
|
const allTools = results.flat();
|
|
575
576
|
setToolList(allTools);
|
|
576
577
|
setToolsFetchError(false);
|
|
577
|
-
} catch (
|
|
578
|
+
} catch (error2) {
|
|
578
579
|
console.error(
|
|
579
580
|
"An error occurred while processing tool fetches:",
|
|
580
|
-
|
|
581
|
+
error2
|
|
581
582
|
);
|
|
582
583
|
setToolList([]);
|
|
583
584
|
setToolsFetchError(true);
|
|
@@ -587,7 +588,7 @@ var ChatPanel = ({
|
|
|
587
588
|
});
|
|
588
589
|
fetchAndSetTools();
|
|
589
590
|
}, [mcpServers, publicAPIUrl]);
|
|
590
|
-
const
|
|
591
|
+
const llmResult = (0, import_llmasaservice_client.useLLM)({
|
|
591
592
|
project_id,
|
|
592
593
|
customer: currentCustomer,
|
|
593
594
|
url,
|
|
@@ -600,6 +601,41 @@ var ChatPanel = ({
|
|
|
600
601
|
};
|
|
601
602
|
})
|
|
602
603
|
});
|
|
604
|
+
const { send, response, idle, stop, lastCallId, setResponse, error: llmError } = llmResult;
|
|
605
|
+
const handleError = (0, import_react3.useCallback)((errorMessage, historyKey) => {
|
|
606
|
+
console.log("[ChatPanel] Error detected:", errorMessage);
|
|
607
|
+
if (errorMessage.includes("413") || errorMessage.toLowerCase().includes("content too large")) {
|
|
608
|
+
setError({
|
|
609
|
+
message: "The context is too large to process. Please start a new conversation or reduce the amount of context.",
|
|
610
|
+
code: "413"
|
|
611
|
+
});
|
|
612
|
+
} else if (errorMessage.toLowerCase().includes("network error") || errorMessage.toLowerCase().includes("fetch")) {
|
|
613
|
+
setError({
|
|
614
|
+
message: "Network error. Please check your connection and try again.",
|
|
615
|
+
code: "NETWORK_ERROR"
|
|
616
|
+
});
|
|
617
|
+
} else {
|
|
618
|
+
setError({
|
|
619
|
+
message: errorMessage,
|
|
620
|
+
code: "UNKNOWN_ERROR"
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
setIsLoading(false);
|
|
624
|
+
const keyToUse = historyKey || lastKey;
|
|
625
|
+
if (keyToUse) {
|
|
626
|
+
setHistory((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
627
|
+
[keyToUse]: {
|
|
628
|
+
content: `Error: ${errorMessage}`,
|
|
629
|
+
callId: lastCallId || ""
|
|
630
|
+
}
|
|
631
|
+
}));
|
|
632
|
+
}
|
|
633
|
+
}, [lastKey, lastCallId]);
|
|
634
|
+
(0, import_react3.useEffect)(() => {
|
|
635
|
+
if (llmError && llmError.trim()) {
|
|
636
|
+
handleError(llmError);
|
|
637
|
+
}
|
|
638
|
+
}, [llmError, handleError]);
|
|
603
639
|
const processActionsOnContent = (0, import_react3.useCallback)((content, context) => {
|
|
604
640
|
let workingContent = content;
|
|
605
641
|
const buttonAttachments = [];
|
|
@@ -936,8 +972,8 @@ var ChatPanel = ({
|
|
|
936
972
|
return action;
|
|
937
973
|
}
|
|
938
974
|
}).filter(Boolean);
|
|
939
|
-
} catch (
|
|
940
|
-
console.error("Error parsing actions string:",
|
|
975
|
+
} catch (error2) {
|
|
976
|
+
console.error("Error parsing actions string:", error2);
|
|
941
977
|
actions2 = [];
|
|
942
978
|
}
|
|
943
979
|
}
|
|
@@ -1125,8 +1161,8 @@ var ChatPanel = ({
|
|
|
1125
1161
|
console.error(`No content returned from tool ${req.toolName}`);
|
|
1126
1162
|
return null;
|
|
1127
1163
|
}
|
|
1128
|
-
} catch (
|
|
1129
|
-
console.error(`Error processing tool ${req.toolName}:`,
|
|
1164
|
+
} catch (error2) {
|
|
1165
|
+
console.error(`Error processing tool ${req.toolName}:`, error2);
|
|
1130
1166
|
return null;
|
|
1131
1167
|
}
|
|
1132
1168
|
}));
|
|
@@ -1168,10 +1204,14 @@ var ChatPanel = ({
|
|
|
1168
1204
|
true,
|
|
1169
1205
|
service,
|
|
1170
1206
|
currentConversation,
|
|
1171
|
-
lastController
|
|
1207
|
+
lastController,
|
|
1208
|
+
void 0,
|
|
1209
|
+
// onComplete
|
|
1210
|
+
(errorMsg) => handleError(errorMsg)
|
|
1211
|
+
// onError
|
|
1172
1212
|
);
|
|
1173
|
-
} catch (
|
|
1174
|
-
console.error("Error in processing all tools:",
|
|
1213
|
+
} catch (error2) {
|
|
1214
|
+
console.error("Error in processing all tools:", error2);
|
|
1175
1215
|
setIsLoading(false);
|
|
1176
1216
|
}
|
|
1177
1217
|
});
|
|
@@ -1303,8 +1343,8 @@ var ChatPanel = ({
|
|
|
1303
1343
|
if (typeof interactionClicked === "function") {
|
|
1304
1344
|
interactionClicked(lastCallId, "action");
|
|
1305
1345
|
}
|
|
1306
|
-
} catch (
|
|
1307
|
-
console.error("Error executing clickCode:",
|
|
1346
|
+
} catch (error2) {
|
|
1347
|
+
console.error("Error executing clickCode:", error2);
|
|
1308
1348
|
}
|
|
1309
1349
|
}
|
|
1310
1350
|
};
|
|
@@ -1399,10 +1439,10 @@ var ChatPanel = ({
|
|
|
1399
1439
|
if (typeof interactionClicked === "function") {
|
|
1400
1440
|
interactionClicked(lastCallId, "action");
|
|
1401
1441
|
}
|
|
1402
|
-
} catch (
|
|
1442
|
+
} catch (error2) {
|
|
1403
1443
|
console.error(
|
|
1404
1444
|
"Error executing clickCode via delegation:",
|
|
1405
|
-
|
|
1445
|
+
error2
|
|
1406
1446
|
);
|
|
1407
1447
|
}
|
|
1408
1448
|
}
|
|
@@ -1514,7 +1554,11 @@ var ChatPanel = ({
|
|
|
1514
1554
|
true,
|
|
1515
1555
|
service,
|
|
1516
1556
|
convId,
|
|
1517
|
-
controller
|
|
1557
|
+
controller,
|
|
1558
|
+
void 0,
|
|
1559
|
+
// onComplete
|
|
1560
|
+
(errorMsg) => handleError(errorMsg)
|
|
1561
|
+
// onError
|
|
1518
1562
|
);
|
|
1519
1563
|
setLastPrompt(initialPrompt);
|
|
1520
1564
|
setLastMessages(messages);
|
|
@@ -1610,8 +1654,8 @@ var ChatPanel = ({
|
|
|
1610
1654
|
return newConvo.id;
|
|
1611
1655
|
}
|
|
1612
1656
|
return "";
|
|
1613
|
-
}).catch((
|
|
1614
|
-
console.error("Error creating new conversation",
|
|
1657
|
+
}).catch((error2) => {
|
|
1658
|
+
console.error("Error creating new conversation", error2);
|
|
1615
1659
|
return "";
|
|
1616
1660
|
});
|
|
1617
1661
|
}
|
|
@@ -1660,7 +1704,7 @@ var ChatPanel = ({
|
|
|
1660
1704
|
customerEmail: updatedValues.customer_user_email
|
|
1661
1705
|
})
|
|
1662
1706
|
}).catch(
|
|
1663
|
-
(
|
|
1707
|
+
(error2) => console.error("Failed to update conversation:", error2)
|
|
1664
1708
|
);
|
|
1665
1709
|
}
|
|
1666
1710
|
});
|
|
@@ -1670,6 +1714,7 @@ var ChatPanel = ({
|
|
|
1670
1714
|
const continueChat = (suggestion) => {
|
|
1671
1715
|
setThinkingBlocks([]);
|
|
1672
1716
|
setCurrentThinkingIndex(0);
|
|
1717
|
+
setError(null);
|
|
1673
1718
|
setResponse("");
|
|
1674
1719
|
if (emailInput && isEmailAddress(emailInput) && !emailInputSet) {
|
|
1675
1720
|
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;
|
|
@@ -1765,7 +1810,11 @@ var ChatPanel = ({
|
|
|
1765
1810
|
true,
|
|
1766
1811
|
service,
|
|
1767
1812
|
convId,
|
|
1768
|
-
controller
|
|
1813
|
+
controller,
|
|
1814
|
+
void 0,
|
|
1815
|
+
// onComplete
|
|
1816
|
+
(errorMsg) => handleError(errorMsg)
|
|
1817
|
+
// onError
|
|
1769
1818
|
);
|
|
1770
1819
|
setLastPrompt(nextPromptToSend);
|
|
1771
1820
|
setLastMessages(messagesAndHistory);
|
|
@@ -1855,16 +1904,16 @@ var ChatPanel = ({
|
|
|
1855
1904
|
return /* @__PURE__ */ import_react3.default.createElement("a", __spreadValues({ href, target: "_blank", rel: "noopener noreferrer" }, props), children);
|
|
1856
1905
|
};
|
|
1857
1906
|
const convertMarkdownToHTML = (markdown) => {
|
|
1907
|
+
const markdownContent = /* @__PURE__ */ import_react3.default.createElement(
|
|
1908
|
+
import_react_markdown.default,
|
|
1909
|
+
{
|
|
1910
|
+
remarkPlugins: [import_remark_gfm.default],
|
|
1911
|
+
rehypePlugins: [import_rehype_raw.default]
|
|
1912
|
+
},
|
|
1913
|
+
markdown
|
|
1914
|
+
);
|
|
1858
1915
|
const html = import_server.default.renderToStaticMarkup(
|
|
1859
|
-
/* @__PURE__ */ import_react3.default.createElement(
|
|
1860
|
-
import_react_markdown.default,
|
|
1861
|
-
{
|
|
1862
|
-
className: markdownClass,
|
|
1863
|
-
remarkPlugins: [import_remark_gfm.default],
|
|
1864
|
-
rehypePlugins: [import_rehype_raw.default]
|
|
1865
|
-
},
|
|
1866
|
-
markdown
|
|
1867
|
-
)
|
|
1916
|
+
markdownClass ? /* @__PURE__ */ import_react3.default.createElement("div", { className: markdownClass }, markdownContent) : markdownContent
|
|
1868
1917
|
);
|
|
1869
1918
|
return html;
|
|
1870
1919
|
};
|
|
@@ -2084,10 +2133,25 @@ var ChatPanel = ({
|
|
|
2084
2133
|
className: "llm-panel" + (theme === "light" ? "" : " dark-theme")
|
|
2085
2134
|
},
|
|
2086
2135
|
title && title !== "" ? /* @__PURE__ */ import_react3.default.createElement("div", { className: "title" }, title) : null,
|
|
2087
|
-
/* @__PURE__ */ import_react3.default.createElement("div", { className: "
|
|
2136
|
+
error && /* @__PURE__ */ import_react3.default.createElement("div", { className: "error-banner" }, /* @__PURE__ */ import_react3.default.createElement("div", { className: "error-banner__icon" }, /* @__PURE__ */ import_react3.default.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__ */ import_react3.default.createElement("circle", { cx: "12", cy: "12", r: "10" }), /* @__PURE__ */ import_react3.default.createElement("line", { x1: "12", x2: "12", y1: "8", y2: "12" }), /* @__PURE__ */ import_react3.default.createElement("line", { x1: "12", x2: "12.01", y1: "16", y2: "16" }))), /* @__PURE__ */ import_react3.default.createElement("div", { className: "error-banner__content" }, /* @__PURE__ */ import_react3.default.createElement("div", { className: "error-banner__message" }, error.message), error.code === "413" && /* @__PURE__ */ import_react3.default.createElement("div", { className: "error-banner__hint" }, "Try starting a new conversation or reducing the amount of information being sent.")), /* @__PURE__ */ import_react3.default.createElement(
|
|
2137
|
+
"button",
|
|
2138
|
+
{
|
|
2139
|
+
className: "error-banner__close",
|
|
2140
|
+
onClick: () => setError(null),
|
|
2141
|
+
"aria-label": "Dismiss error"
|
|
2142
|
+
},
|
|
2143
|
+
/* @__PURE__ */ import_react3.default.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__ */ import_react3.default.createElement("line", { x1: "18", x2: "6", y1: "6", y2: "18" }), /* @__PURE__ */ import_react3.default.createElement("line", { x1: "6", x2: "18", y1: "6", y2: "18" }))
|
|
2144
|
+
)),
|
|
2145
|
+
/* @__PURE__ */ import_react3.default.createElement("div", { className: "responseArea", ref: responseAreaRef }, initialMessage && initialMessage !== "" ? /* @__PURE__ */ import_react3.default.createElement("div", { className: "history-entry" }, /* @__PURE__ */ import_react3.default.createElement("div", { className: "response" }, markdownClass ? /* @__PURE__ */ import_react3.default.createElement("div", { className: markdownClass }, /* @__PURE__ */ import_react3.default.createElement(
|
|
2146
|
+
import_react_markdown.default,
|
|
2147
|
+
{
|
|
2148
|
+
remarkPlugins: [import_remark_gfm.default],
|
|
2149
|
+
rehypePlugins: [import_rehype_raw.default]
|
|
2150
|
+
},
|
|
2151
|
+
initialMessage
|
|
2152
|
+
)) : /* @__PURE__ */ import_react3.default.createElement(
|
|
2088
2153
|
import_react_markdown.default,
|
|
2089
2154
|
{
|
|
2090
|
-
className: markdownClass,
|
|
2091
2155
|
remarkPlugins: [import_remark_gfm.default],
|
|
2092
2156
|
rehypePlugins: [import_rehype_raw.default]
|
|
2093
2157
|
},
|
|
@@ -2112,10 +2176,9 @@ var ChatPanel = ({
|
|
|
2112
2176
|
return null;
|
|
2113
2177
|
})(), (() => {
|
|
2114
2178
|
if (lastKey && history[lastKey] && history[lastKey].content) {
|
|
2115
|
-
|
|
2179
|
+
const content = /* @__PURE__ */ import_react3.default.createElement(
|
|
2116
2180
|
import_react_markdown.default,
|
|
2117
2181
|
{
|
|
2118
|
-
className: markdownClass,
|
|
2119
2182
|
remarkPlugins: [import_remark_gfm.default],
|
|
2120
2183
|
rehypePlugins: [import_rehype_raw.default],
|
|
2121
2184
|
components: {
|
|
@@ -2125,27 +2188,41 @@ var ChatPanel = ({
|
|
|
2125
2188
|
},
|
|
2126
2189
|
history[lastKey].content
|
|
2127
2190
|
);
|
|
2191
|
+
return markdownClass ? /* @__PURE__ */ import_react3.default.createElement("div", { className: markdownClass }, content) : content;
|
|
2128
2192
|
}
|
|
2129
2193
|
const { cleanedText } = processThinkingTags(
|
|
2130
2194
|
response || ""
|
|
2131
2195
|
);
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2196
|
+
if (cleanedText && cleanedText.length > 0) {
|
|
2197
|
+
const content = /* @__PURE__ */ import_react3.default.createElement(
|
|
2198
|
+
import_react_markdown.default,
|
|
2199
|
+
{
|
|
2200
|
+
remarkPlugins: [import_remark_gfm.default],
|
|
2201
|
+
rehypePlugins: [import_rehype_raw.default],
|
|
2202
|
+
components: {
|
|
2203
|
+
/*a: CustomLink,*/
|
|
2204
|
+
code: CodeBlock
|
|
2205
|
+
}
|
|
2206
|
+
},
|
|
2207
|
+
cleanedText
|
|
2208
|
+
);
|
|
2209
|
+
return markdownClass ? /* @__PURE__ */ import_react3.default.createElement("div", { className: markdownClass }, content) : content;
|
|
2210
|
+
}
|
|
2211
|
+
return null;
|
|
2212
|
+
})()) : /* @__PURE__ */ import_react3.default.createElement("div", null, isLastEntry && thinkingBlocks.length > 0 && renderThinkingBlocks(), markdownClass ? /* @__PURE__ */ import_react3.default.createElement("div", { className: markdownClass }, /* @__PURE__ */ import_react3.default.createElement(
|
|
2213
|
+
import_react_markdown.default,
|
|
2214
|
+
{
|
|
2215
|
+
remarkPlugins: [import_remark_gfm.default],
|
|
2216
|
+
rehypePlugins: [import_rehype_raw.default],
|
|
2217
|
+
components: {
|
|
2218
|
+
/*a: CustomLink,*/
|
|
2219
|
+
code: CodeBlock
|
|
2220
|
+
}
|
|
2221
|
+
},
|
|
2222
|
+
processThinkingTags(historyEntry.content).cleanedText
|
|
2223
|
+
)) : /* @__PURE__ */ import_react3.default.createElement(
|
|
2146
2224
|
import_react_markdown.default,
|
|
2147
2225
|
{
|
|
2148
|
-
className: markdownClass,
|
|
2149
2226
|
remarkPlugins: [import_remark_gfm.default],
|
|
2150
2227
|
rehypePlugins: [import_rehype_raw.default],
|
|
2151
2228
|
components: {
|
|
@@ -2393,6 +2470,7 @@ var ChatPanel = ({
|
|
|
2393
2470
|
setIsToolInfoModalOpen(false);
|
|
2394
2471
|
setToolInfoData(null);
|
|
2395
2472
|
setJustReset(true);
|
|
2473
|
+
setError(null);
|
|
2396
2474
|
setLastController(new AbortController());
|
|
2397
2475
|
buttonActionRegistry.current.clear();
|
|
2398
2476
|
setTimeout(() => {
|
|
@@ -2892,7 +2970,7 @@ var AgentPanel = ({
|
|
|
2892
2970
|
(0, import_react4.useEffect)(() => {
|
|
2893
2971
|
const fetchAgentData = () => __async(void 0, null, function* () {
|
|
2894
2972
|
try {
|
|
2895
|
-
const fetchUrl = `https://api.llmasaservice.io/agents/${agent}`;
|
|
2973
|
+
const fetchUrl = url.endsWith("dev") ? `https://8ftw8droff.execute-api.us-east-1.amazonaws.com/dev/agents/${agent}` : `https://api.llmasaservice.io/agents/${agent}`;
|
|
2896
2974
|
const response = yield fetch(fetchUrl, {
|
|
2897
2975
|
method: "GET",
|
|
2898
2976
|
headers: {
|
|
@@ -3000,10 +3078,11 @@ var AgentPanel = ({
|
|
|
3000
3078
|
var AgentPanel_default = AgentPanel;
|
|
3001
3079
|
|
|
3002
3080
|
// src/AIAgentPanel.tsx
|
|
3003
|
-
var
|
|
3081
|
+
var import_react14 = __toESM(require("react"));
|
|
3004
3082
|
|
|
3005
3083
|
// src/AIChatPanel.tsx
|
|
3006
|
-
var
|
|
3084
|
+
var import_react12 = __toESM(require("react"));
|
|
3085
|
+
var import_server2 = __toESM(require("react-dom/server"));
|
|
3007
3086
|
var import_llmasaservice_client2 = require("llmasaservice-client");
|
|
3008
3087
|
var import_react_markdown2 = __toESM(require("react-markdown"));
|
|
3009
3088
|
var import_remark_gfm2 = __toESM(require("remark-gfm"));
|
|
@@ -3345,20 +3424,69 @@ var DialogFooter = ({
|
|
|
3345
3424
|
return /* @__PURE__ */ import_react10.default.createElement("div", { className: `ai-dialog-footer ${className}` }, children);
|
|
3346
3425
|
};
|
|
3347
3426
|
|
|
3427
|
+
// src/components/ui/ToolInfoModal.tsx
|
|
3428
|
+
var import_react11 = __toESM(require("react"));
|
|
3429
|
+
var ToolInfoModal2 = ({
|
|
3430
|
+
isOpen,
|
|
3431
|
+
onClose,
|
|
3432
|
+
data
|
|
3433
|
+
}) => {
|
|
3434
|
+
if (!isOpen || !data) return null;
|
|
3435
|
+
return /* @__PURE__ */ import_react11.default.createElement("div", { className: "ai-chat-modal-overlay", onClick: onClose }, /* @__PURE__ */ import_react11.default.createElement(
|
|
3436
|
+
"div",
|
|
3437
|
+
{
|
|
3438
|
+
className: "ai-chat-modal-content ai-chat-tool-info-modal",
|
|
3439
|
+
onClick: (e) => e.stopPropagation()
|
|
3440
|
+
},
|
|
3441
|
+
/* @__PURE__ */ import_react11.default.createElement("div", { className: "ai-chat-modal-header" }, /* @__PURE__ */ import_react11.default.createElement("h3", null, "Tool Information"), /* @__PURE__ */ import_react11.default.createElement(
|
|
3442
|
+
"button",
|
|
3443
|
+
{
|
|
3444
|
+
className: "ai-chat-modal-close",
|
|
3445
|
+
onClick: onClose,
|
|
3446
|
+
"aria-label": "Close"
|
|
3447
|
+
},
|
|
3448
|
+
"\xD7"
|
|
3449
|
+
)),
|
|
3450
|
+
/* @__PURE__ */ import_react11.default.createElement("div", { className: "ai-chat-modal-body ai-chat-tool-info-container" }, /* @__PURE__ */ import_react11.default.createElement("div", { className: "ai-chat-tool-info-section" }, /* @__PURE__ */ import_react11.default.createElement("h4", null, "Tool Calls"), /* @__PURE__ */ import_react11.default.createElement(
|
|
3451
|
+
"textarea",
|
|
3452
|
+
{
|
|
3453
|
+
className: "ai-chat-tool-info-json",
|
|
3454
|
+
readOnly: true,
|
|
3455
|
+
value: JSON.stringify(data.calls, null, 2)
|
|
3456
|
+
}
|
|
3457
|
+
)), /* @__PURE__ */ import_react11.default.createElement("div", { className: "ai-chat-tool-info-section" }, /* @__PURE__ */ import_react11.default.createElement("h4", null, "Tool Responses"), /* @__PURE__ */ import_react11.default.createElement(
|
|
3458
|
+
"textarea",
|
|
3459
|
+
{
|
|
3460
|
+
className: "ai-chat-tool-info-json",
|
|
3461
|
+
readOnly: true,
|
|
3462
|
+
value: JSON.stringify(data.responses, null, 2)
|
|
3463
|
+
}
|
|
3464
|
+
))),
|
|
3465
|
+
/* @__PURE__ */ import_react11.default.createElement("div", { className: "ai-chat-modal-footer" }, /* @__PURE__ */ import_react11.default.createElement(
|
|
3466
|
+
"button",
|
|
3467
|
+
{
|
|
3468
|
+
className: "ai-chat-modal-button ai-chat-modal-button--primary",
|
|
3469
|
+
onClick: onClose
|
|
3470
|
+
},
|
|
3471
|
+
"Close"
|
|
3472
|
+
))
|
|
3473
|
+
));
|
|
3474
|
+
};
|
|
3475
|
+
var ToolInfoModal_default2 = ToolInfoModal2;
|
|
3476
|
+
|
|
3348
3477
|
// src/AIChatPanel.tsx
|
|
3349
|
-
var ArrowUpIcon = () => /* @__PURE__ */
|
|
3350
|
-
var StopIcon = () => /* @__PURE__ */
|
|
3351
|
-
var
|
|
3352
|
-
var
|
|
3353
|
-
var
|
|
3354
|
-
var
|
|
3355
|
-
var
|
|
3356
|
-
var
|
|
3357
|
-
var
|
|
3358
|
-
var
|
|
3359
|
-
var
|
|
3360
|
-
var
|
|
3361
|
-
var ChatInput = import_react11.default.memo(({
|
|
3478
|
+
var ArrowUpIcon = () => /* @__PURE__ */ import_react12.default.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__ */ import_react12.default.createElement("path", { d: "M12 19V5M5 12l7-7 7 7" }));
|
|
3479
|
+
var StopIcon = () => /* @__PURE__ */ import_react12.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", className: "ai-chat-icon" }, /* @__PURE__ */ import_react12.default.createElement("rect", { x: "6", y: "6", width: "12", height: "12", rx: "2" }));
|
|
3480
|
+
var ChevronDownIcon = () => /* @__PURE__ */ import_react12.default.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__ */ import_react12.default.createElement("path", { d: "m6 9 6 6 6-6" }));
|
|
3481
|
+
var ChevronUpIcon = () => /* @__PURE__ */ import_react12.default.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__ */ import_react12.default.createElement("path", { d: "m18 15-6-6-6 6" }));
|
|
3482
|
+
var AgentIcon = () => /* @__PURE__ */ import_react12.default.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__ */ import_react12.default.createElement("path", { d: "M12 8V4H8" }), /* @__PURE__ */ import_react12.default.createElement("rect", { width: "16", height: "12", x: "4", y: "8", rx: "2" }), /* @__PURE__ */ import_react12.default.createElement("path", { d: "M2 14h2" }), /* @__PURE__ */ import_react12.default.createElement("path", { d: "M20 14h2" }), /* @__PURE__ */ import_react12.default.createElement("path", { d: "M15 13v2" }), /* @__PURE__ */ import_react12.default.createElement("path", { d: "M9 13v2" }));
|
|
3483
|
+
var CheckIcon = () => /* @__PURE__ */ import_react12.default.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__ */ import_react12.default.createElement("polyline", { points: "20 6 9 17 4 12" }));
|
|
3484
|
+
var BrainIcon = () => /* @__PURE__ */ import_react12.default.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__ */ import_react12.default.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__ */ import_react12.default.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" }));
|
|
3485
|
+
var SearchIcon = () => /* @__PURE__ */ import_react12.default.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__ */ import_react12.default.createElement("circle", { cx: "11", cy: "11", r: "8" }), /* @__PURE__ */ import_react12.default.createElement("path", { d: "m21 21-4.3-4.3" }));
|
|
3486
|
+
var LLMAsAServiceLogo = () => /* @__PURE__ */ import_react12.default.createElement("svg", { width: "16", height: "16", viewBox: "0 0 72 72", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ import_react12.default.createElement("ellipse", { cx: "14.0868", cy: "59.2146", rx: "7.8261", ry: "7.7854", fill: "#2487D8" }), /* @__PURE__ */ import_react12.default.createElement("ellipse", { cx: "24.9013", cy: "43.0776", rx: "6.11858", ry: "6.08676", fill: "#2487D8" }), /* @__PURE__ */ import_react12.default.createElement("ellipse", { cx: "45.391", cy: "43.0776", rx: "6.11858", ry: "6.08676", fill: "#2487D8" }), /* @__PURE__ */ import_react12.default.createElement("ellipse", { cx: "65.8813", cy: "43.0776", rx: "6.11858", ry: "6.08676", fill: "#2487D8" }), /* @__PURE__ */ import_react12.default.createElement("ellipse", { cx: "35.1461", cy: "26.5327", rx: "4.41103", ry: "4.3878", fill: "#2487D8" }), /* @__PURE__ */ import_react12.default.createElement("ellipse", { cx: "55.6364", cy: "26.5327", rx: "4.41103", ry: "4.3878", fill: "#2487D8" }), /* @__PURE__ */ import_react12.default.createElement("ellipse", { cx: "45.391", cy: "10.3959", rx: "2.70351", ry: "2.68919", fill: "#2487D8" }));
|
|
3487
|
+
var AlertCircleIcon = () => /* @__PURE__ */ import_react12.default.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__ */ import_react12.default.createElement("circle", { cx: "12", cy: "12", r: "10" }), /* @__PURE__ */ import_react12.default.createElement("line", { x1: "12", x2: "12", y1: "8", y2: "12" }), /* @__PURE__ */ import_react12.default.createElement("line", { x1: "12", x2: "12.01", y1: "16", y2: "16" }));
|
|
3488
|
+
var CloseIcon = () => /* @__PURE__ */ import_react12.default.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__ */ import_react12.default.createElement("line", { x1: "18", x2: "6", y1: "6", y2: "18" }), /* @__PURE__ */ import_react12.default.createElement("line", { x1: "6", x2: "18", y1: "6", y2: "18" }));
|
|
3489
|
+
var ChatInput = import_react12.default.memo(({
|
|
3362
3490
|
placeholder,
|
|
3363
3491
|
idle,
|
|
3364
3492
|
onSubmit,
|
|
@@ -3374,21 +3502,21 @@ var ChatInput = import_react11.default.memo(({
|
|
|
3374
3502
|
maxContextTokens = 8e3,
|
|
3375
3503
|
enableContextDetailView = false
|
|
3376
3504
|
}) => {
|
|
3377
|
-
const [inputValue, setInputValue] = (0,
|
|
3378
|
-
const [dropdownOpen, setDropdownOpen] = (0,
|
|
3379
|
-
const [contextViewerOpen, setContextViewerOpen] = (0,
|
|
3380
|
-
const [contextViewMode, setContextViewMode] = (0,
|
|
3381
|
-
const textareaRef = (0,
|
|
3382
|
-
const containerRef = (0,
|
|
3383
|
-
const contextPopoverRef = (0,
|
|
3384
|
-
const autoResize = (0,
|
|
3505
|
+
const [inputValue, setInputValue] = (0, import_react12.useState)("");
|
|
3506
|
+
const [dropdownOpen, setDropdownOpen] = (0, import_react12.useState)(false);
|
|
3507
|
+
const [contextViewerOpen, setContextViewerOpen] = (0, import_react12.useState)(false);
|
|
3508
|
+
const [contextViewMode, setContextViewMode] = (0, import_react12.useState)("summary");
|
|
3509
|
+
const textareaRef = (0, import_react12.useRef)(null);
|
|
3510
|
+
const containerRef = (0, import_react12.useRef)(null);
|
|
3511
|
+
const contextPopoverRef = (0, import_react12.useRef)(null);
|
|
3512
|
+
const autoResize = (0, import_react12.useCallback)(() => {
|
|
3385
3513
|
const textarea = textareaRef.current;
|
|
3386
3514
|
if (textarea) {
|
|
3387
3515
|
textarea.style.height = "auto";
|
|
3388
3516
|
textarea.style.height = `${Math.min(textarea.scrollHeight, 200)}px`;
|
|
3389
3517
|
}
|
|
3390
3518
|
}, []);
|
|
3391
|
-
const handleSubmit = (0,
|
|
3519
|
+
const handleSubmit = (0, import_react12.useCallback)(() => {
|
|
3392
3520
|
const trimmed = inputValue.trim();
|
|
3393
3521
|
if (trimmed && idle) {
|
|
3394
3522
|
onSubmit(trimmed);
|
|
@@ -3398,7 +3526,7 @@ var ChatInput = import_react11.default.memo(({
|
|
|
3398
3526
|
}
|
|
3399
3527
|
}
|
|
3400
3528
|
}, [inputValue, idle, onSubmit]);
|
|
3401
|
-
(0,
|
|
3529
|
+
(0, import_react12.useEffect)(() => {
|
|
3402
3530
|
const handleClickOutside = (event) => {
|
|
3403
3531
|
if (containerRef.current && !containerRef.current.contains(event.target)) {
|
|
3404
3532
|
setDropdownOpen(false);
|
|
@@ -3409,7 +3537,7 @@ var ChatInput = import_react11.default.memo(({
|
|
|
3409
3537
|
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
3410
3538
|
}
|
|
3411
3539
|
}, [dropdownOpen]);
|
|
3412
|
-
(0,
|
|
3540
|
+
(0, import_react12.useEffect)(() => {
|
|
3413
3541
|
const handleClickOutside = (event) => {
|
|
3414
3542
|
if (contextPopoverRef.current && !contextPopoverRef.current.contains(event.target)) {
|
|
3415
3543
|
setContextViewerOpen(false);
|
|
@@ -3441,13 +3569,13 @@ var ChatInput = import_react11.default.memo(({
|
|
|
3441
3569
|
if (typeof data === "string") return data;
|
|
3442
3570
|
return JSON.stringify(data, null, 2);
|
|
3443
3571
|
};
|
|
3444
|
-
return /* @__PURE__ */
|
|
3572
|
+
return /* @__PURE__ */ import_react12.default.createElement(
|
|
3445
3573
|
"div",
|
|
3446
3574
|
{
|
|
3447
3575
|
className: `ai-chat-panel__input-container ${dropdownOpen ? "ai-chat-panel__input-container--dropdown-open" : ""}`,
|
|
3448
3576
|
ref: containerRef
|
|
3449
3577
|
},
|
|
3450
|
-
/* @__PURE__ */
|
|
3578
|
+
/* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-panel__input" }, /* @__PURE__ */ import_react12.default.createElement(
|
|
3451
3579
|
"textarea",
|
|
3452
3580
|
{
|
|
3453
3581
|
ref: textareaRef,
|
|
@@ -3467,24 +3595,24 @@ var ChatInput = import_react11.default.memo(({
|
|
|
3467
3595
|
rows: 1
|
|
3468
3596
|
}
|
|
3469
3597
|
)),
|
|
3470
|
-
/* @__PURE__ */
|
|
3598
|
+
/* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-panel__input-footer" }, agentOptions.length > 0 ? /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-agent-selector" }, /* @__PURE__ */ import_react12.default.createElement(
|
|
3471
3599
|
"button",
|
|
3472
3600
|
{
|
|
3473
3601
|
className: "ai-chat-agent-selector__trigger",
|
|
3474
3602
|
onClick: () => setDropdownOpen(!dropdownOpen),
|
|
3475
3603
|
disabled: agentsLoading
|
|
3476
3604
|
},
|
|
3477
|
-
currentAgentAvatarUrl ? /* @__PURE__ */
|
|
3605
|
+
currentAgentAvatarUrl ? /* @__PURE__ */ import_react12.default.createElement(
|
|
3478
3606
|
"img",
|
|
3479
3607
|
{
|
|
3480
3608
|
src: currentAgentAvatarUrl,
|
|
3481
3609
|
alt: currentAgentLabel || "Agent",
|
|
3482
3610
|
className: "ai-chat-agent-selector__avatar"
|
|
3483
3611
|
}
|
|
3484
|
-
) : /* @__PURE__ */
|
|
3485
|
-
/* @__PURE__ */
|
|
3486
|
-
dropdownOpen ? /* @__PURE__ */
|
|
3487
|
-
)) : /* @__PURE__ */
|
|
3612
|
+
) : /* @__PURE__ */ import_react12.default.createElement(AgentIcon, null),
|
|
3613
|
+
/* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-agent-selector__label" }, agentsLoading ? "Loading..." : currentAgentLabel || "Select agent"),
|
|
3614
|
+
dropdownOpen ? /* @__PURE__ */ import_react12.default.createElement(ChevronUpIcon, null) : /* @__PURE__ */ import_react12.default.createElement(ChevronDownIcon, null)
|
|
3615
|
+
)) : /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-panel__input-footer-spacer" }), contextSections.length > 0 && /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-context-pill-wrapper" }, /* @__PURE__ */ import_react12.default.createElement(
|
|
3488
3616
|
"button",
|
|
3489
3617
|
{
|
|
3490
3618
|
className: `ai-chat-context-pill ${contextViewerOpen ? "ai-chat-context-pill--active" : ""} ${isOverLimit ? "ai-chat-context-pill--warning" : ""}`,
|
|
@@ -3500,15 +3628,15 @@ var ChatInput = import_react11.default.memo(({
|
|
|
3500
3628
|
type: "button",
|
|
3501
3629
|
title: "View context"
|
|
3502
3630
|
},
|
|
3503
|
-
/* @__PURE__ */
|
|
3504
|
-
), contextViewerOpen && /* @__PURE__ */
|
|
3631
|
+
/* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-context-pill__label" }, "context: ", contextSections.length, " ", contextSections.length === 1 ? "section" : "sections")
|
|
3632
|
+
), contextViewerOpen && /* @__PURE__ */ import_react12.default.createElement(
|
|
3505
3633
|
"div",
|
|
3506
3634
|
{
|
|
3507
3635
|
className: `ai-chat-context-popover ${contextViewMode === "detail" ? "ai-chat-context-popover--detail" : ""}`,
|
|
3508
3636
|
ref: contextPopoverRef,
|
|
3509
3637
|
onClick: (e) => e.stopPropagation()
|
|
3510
3638
|
},
|
|
3511
|
-
contextViewMode === "summary" && /* @__PURE__ */
|
|
3639
|
+
contextViewMode === "summary" && /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-context-popover__summary" }, /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-context-popover__header" }, /* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-context-popover__title" }, "Context"), /* @__PURE__ */ import_react12.default.createElement(
|
|
3512
3640
|
"button",
|
|
3513
3641
|
{
|
|
3514
3642
|
className: "ai-chat-context-popover__close",
|
|
@@ -3516,13 +3644,13 @@ var ChatInput = import_react11.default.memo(({
|
|
|
3516
3644
|
type: "button"
|
|
3517
3645
|
},
|
|
3518
3646
|
"\xD7"
|
|
3519
|
-
)), /* @__PURE__ */
|
|
3647
|
+
)), /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-context-popover__token-bar" }, /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-context-popover__token-info" }, /* @__PURE__ */ import_react12.default.createElement("span", { className: isOverLimit ? "ai-chat-context-popover__tokens--warning" : "" }, formatTokens(totalContextTokens), " tokens"), /* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-context-popover__token-limit" }, "/ ", formatTokens(maxContextTokens), " limit")), /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-context-popover__progress" }, /* @__PURE__ */ import_react12.default.createElement(
|
|
3520
3648
|
"div",
|
|
3521
3649
|
{
|
|
3522
3650
|
className: `ai-chat-context-popover__progress-bar ${isOverLimit ? "ai-chat-context-popover__progress-bar--warning" : ""}`,
|
|
3523
3651
|
style: { width: `${Math.min(tokenPercentage, 100)}%` }
|
|
3524
3652
|
}
|
|
3525
|
-
))), /* @__PURE__ */
|
|
3653
|
+
))), /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-context-popover__sections" }, contextSections.map((section) => /* @__PURE__ */ import_react12.default.createElement(
|
|
3526
3654
|
"div",
|
|
3527
3655
|
{
|
|
3528
3656
|
key: section.id,
|
|
@@ -3533,10 +3661,10 @@ var ChatInput = import_react11.default.memo(({
|
|
|
3533
3661
|
}
|
|
3534
3662
|
}
|
|
3535
3663
|
},
|
|
3536
|
-
/* @__PURE__ */
|
|
3537
|
-
/* @__PURE__ */
|
|
3538
|
-
/* @__PURE__ */
|
|
3539
|
-
))), enableContextDetailView && /* @__PURE__ */
|
|
3664
|
+
/* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-context-popover__section-icon" }, "\u{1F4C4}"),
|
|
3665
|
+
/* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-context-popover__section-title" }, section.title),
|
|
3666
|
+
/* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-context-popover__section-tokens" }, section.tokens || Math.ceil(JSON.stringify(section.data).length / 4))
|
|
3667
|
+
))), enableContextDetailView && /* @__PURE__ */ import_react12.default.createElement(
|
|
3540
3668
|
"button",
|
|
3541
3669
|
{
|
|
3542
3670
|
className: "ai-chat-context-popover__expand-btn",
|
|
@@ -3545,7 +3673,7 @@ var ChatInput = import_react11.default.memo(({
|
|
|
3545
3673
|
},
|
|
3546
3674
|
"View details \u2192"
|
|
3547
3675
|
)),
|
|
3548
|
-
contextViewMode === "detail" && enableContextDetailView && /* @__PURE__ */
|
|
3676
|
+
contextViewMode === "detail" && enableContextDetailView && /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-context-popover__detail" }, /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-context-popover__header" }, /* @__PURE__ */ import_react12.default.createElement(
|
|
3549
3677
|
"button",
|
|
3550
3678
|
{
|
|
3551
3679
|
className: "ai-chat-context-popover__back",
|
|
@@ -3553,7 +3681,7 @@ var ChatInput = import_react11.default.memo(({
|
|
|
3553
3681
|
type: "button"
|
|
3554
3682
|
},
|
|
3555
3683
|
"\u2190 Back"
|
|
3556
|
-
), /* @__PURE__ */
|
|
3684
|
+
), /* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-context-popover__title" }, "Context Details"), /* @__PURE__ */ import_react12.default.createElement(
|
|
3557
3685
|
"button",
|
|
3558
3686
|
{
|
|
3559
3687
|
className: "ai-chat-context-popover__close",
|
|
@@ -3561,26 +3689,26 @@ var ChatInput = import_react11.default.memo(({
|
|
|
3561
3689
|
type: "button"
|
|
3562
3690
|
},
|
|
3563
3691
|
"\xD7"
|
|
3564
|
-
)), /* @__PURE__ */
|
|
3692
|
+
)), /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-context-popover__token-bar" }, /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-context-popover__token-info" }, /* @__PURE__ */ import_react12.default.createElement("span", { className: isOverLimit ? "ai-chat-context-popover__tokens--warning" : "" }, formatTokens(totalContextTokens), " tokens"), /* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-context-popover__token-limit" }, "/ ", formatTokens(maxContextTokens), " limit")), /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-context-popover__progress" }, /* @__PURE__ */ import_react12.default.createElement(
|
|
3565
3693
|
"div",
|
|
3566
3694
|
{
|
|
3567
3695
|
className: `ai-chat-context-popover__progress-bar ${isOverLimit ? "ai-chat-context-popover__progress-bar--warning" : ""}`,
|
|
3568
3696
|
style: { width: `${Math.min(tokenPercentage, 100)}%` }
|
|
3569
3697
|
}
|
|
3570
|
-
))), /* @__PURE__ */
|
|
3698
|
+
))), /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-context-popover__detail-sections" }, contextSections.map((section) => {
|
|
3571
3699
|
const format = detectFormat(section.data);
|
|
3572
|
-
return /* @__PURE__ */
|
|
3700
|
+
return /* @__PURE__ */ import_react12.default.createElement("details", { key: section.id, className: "ai-chat-context-popover__detail-section", open: true }, /* @__PURE__ */ import_react12.default.createElement("summary", { className: "ai-chat-context-popover__detail-section-header" }, /* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-context-popover__detail-section-title" }, section.title), /* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-context-popover__detail-section-meta" }, /* @__PURE__ */ import_react12.default.createElement("code", null, `{{${section.id}}}`), /* @__PURE__ */ import_react12.default.createElement("span", null, "~", section.tokens || Math.ceil(JSON.stringify(section.data).length / 4)))), /* @__PURE__ */ import_react12.default.createElement("pre", { className: "ai-chat-context-popover__detail-content" }, /* @__PURE__ */ import_react12.default.createElement("code", null, formatContent(section.data, format))));
|
|
3573
3701
|
})))
|
|
3574
|
-
)), /* @__PURE__ */
|
|
3702
|
+
)), /* @__PURE__ */ import_react12.default.createElement(
|
|
3575
3703
|
"button",
|
|
3576
3704
|
{
|
|
3577
3705
|
className: `ai-chat-send-button ${idle && !inputValue.trim() ? "ai-chat-send-button--disabled" : ""} ${!idle ? "ai-chat-send-button--stop" : ""}`,
|
|
3578
3706
|
onClick: () => idle ? handleSubmit() : onStop(),
|
|
3579
3707
|
disabled: idle && !inputValue.trim()
|
|
3580
3708
|
},
|
|
3581
|
-
idle ? /* @__PURE__ */
|
|
3709
|
+
idle ? /* @__PURE__ */ import_react12.default.createElement(ArrowUpIcon, null) : /* @__PURE__ */ import_react12.default.createElement(StopIcon, null)
|
|
3582
3710
|
)),
|
|
3583
|
-
agentOptions.length > 0 && dropdownOpen && /* @__PURE__ */
|
|
3711
|
+
agentOptions.length > 0 && dropdownOpen && /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-agent-selector__dropdown-inside" }, agentOptions.map((option) => /* @__PURE__ */ import_react12.default.createElement(
|
|
3584
3712
|
"button",
|
|
3585
3713
|
{
|
|
3586
3714
|
key: option.value,
|
|
@@ -3592,16 +3720,16 @@ var ChatInput = import_react11.default.memo(({
|
|
|
3592
3720
|
setDropdownOpen(false);
|
|
3593
3721
|
}
|
|
3594
3722
|
},
|
|
3595
|
-
option.avatarUrl ? /* @__PURE__ */
|
|
3723
|
+
option.avatarUrl ? /* @__PURE__ */ import_react12.default.createElement(
|
|
3596
3724
|
"img",
|
|
3597
3725
|
{
|
|
3598
3726
|
src: option.avatarUrl,
|
|
3599
3727
|
alt: option.label,
|
|
3600
3728
|
className: "ai-chat-agent-selector__option-avatar"
|
|
3601
3729
|
}
|
|
3602
|
-
) : option.icon ? /* @__PURE__ */
|
|
3603
|
-
/* @__PURE__ */
|
|
3604
|
-
option.value === currentAgentId && /* @__PURE__ */
|
|
3730
|
+
) : option.icon ? /* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-agent-selector__option-icon" }, option.icon) : null,
|
|
3731
|
+
/* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-agent-selector__option-content" }, /* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-agent-selector__option-label" }, option.label), option.description && /* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-agent-selector__option-description" }, option.description)),
|
|
3732
|
+
option.value === currentAgentId && /* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-agent-selector__option-check" }, /* @__PURE__ */ import_react12.default.createElement(CheckIcon, null))
|
|
3605
3733
|
)))
|
|
3606
3734
|
);
|
|
3607
3735
|
});
|
|
@@ -3645,33 +3773,77 @@ var AIChatPanel = ({
|
|
|
3645
3773
|
totalContextTokens = 0,
|
|
3646
3774
|
maxContextTokens = 8e3,
|
|
3647
3775
|
enableContextDetailView = false,
|
|
3648
|
-
onConversationCreated
|
|
3776
|
+
onConversationCreated,
|
|
3777
|
+
// UI Customization Props
|
|
3778
|
+
cssUrl,
|
|
3779
|
+
markdownClass,
|
|
3780
|
+
width,
|
|
3781
|
+
height,
|
|
3782
|
+
scrollToEnd = false,
|
|
3783
|
+
prismStyle,
|
|
3784
|
+
// Email & Save Props
|
|
3785
|
+
showSaveButton = true,
|
|
3786
|
+
showEmailButton = true,
|
|
3787
|
+
messages = [],
|
|
3788
|
+
// Call-to-Action Props
|
|
3789
|
+
showCallToAction = false,
|
|
3790
|
+
callToActionButtonText = "Submit",
|
|
3791
|
+
callToActionEmailAddress = "",
|
|
3792
|
+
callToActionEmailSubject = "Agent CTA submitted",
|
|
3793
|
+
// Customer Email Capture Props
|
|
3794
|
+
customerEmailCaptureMode = "HIDE",
|
|
3795
|
+
customerEmailCapturePlaceholder = "Please enter your email..."
|
|
3649
3796
|
}) => {
|
|
3797
|
+
var _a;
|
|
3650
3798
|
const publicAPIUrl = "https://api.llmasaservice.io";
|
|
3651
|
-
const [lastController, setLastController] = (0,
|
|
3652
|
-
const [lastMessages, setLastMessages] = (0,
|
|
3653
|
-
const [history, setHistory] = (0,
|
|
3654
|
-
const [isLoading, setIsLoading] = (0,
|
|
3655
|
-
const [lastPrompt, setLastPrompt] = (0,
|
|
3656
|
-
const [lastKey, setLastKey] = (0,
|
|
3657
|
-
const [currentConversation, setCurrentConversation] = (0,
|
|
3658
|
-
const [followOnQuestionsState, setFollowOnQuestionsState] = (0,
|
|
3659
|
-
const [thinkingBlocks, setThinkingBlocks] = (0,
|
|
3660
|
-
const [currentThinkingIndex, setCurrentThinkingIndex] = (0,
|
|
3661
|
-
const [newConversationConfirm, setNewConversationConfirm] = (0,
|
|
3662
|
-
const [justReset, setJustReset] = (0,
|
|
3663
|
-
const [copiedCallId, setCopiedCallId] = (0,
|
|
3664
|
-
const
|
|
3665
|
-
const
|
|
3666
|
-
const [
|
|
3667
|
-
const
|
|
3668
|
-
const
|
|
3669
|
-
const
|
|
3670
|
-
const
|
|
3671
|
-
const
|
|
3672
|
-
const
|
|
3673
|
-
const
|
|
3674
|
-
(0,
|
|
3799
|
+
const [lastController, setLastController] = (0, import_react12.useState)(new AbortController());
|
|
3800
|
+
const [lastMessages, setLastMessages] = (0, import_react12.useState)([]);
|
|
3801
|
+
const [history, setHistory] = (0, import_react12.useState)(initialHistory);
|
|
3802
|
+
const [isLoading, setIsLoading] = (0, import_react12.useState)(false);
|
|
3803
|
+
const [lastPrompt, setLastPrompt] = (0, import_react12.useState)(null);
|
|
3804
|
+
const [lastKey, setLastKey] = (0, import_react12.useState)(null);
|
|
3805
|
+
const [currentConversation, setCurrentConversation] = (0, import_react12.useState)(conversation);
|
|
3806
|
+
const [followOnQuestionsState, setFollowOnQuestionsState] = (0, import_react12.useState)(followOnQuestions);
|
|
3807
|
+
const [thinkingBlocks, setThinkingBlocks] = (0, import_react12.useState)([]);
|
|
3808
|
+
const [currentThinkingIndex, setCurrentThinkingIndex] = (0, import_react12.useState)(0);
|
|
3809
|
+
const [newConversationConfirm, setNewConversationConfirm] = (0, import_react12.useState)(false);
|
|
3810
|
+
const [justReset, setJustReset] = (0, import_react12.useState)(false);
|
|
3811
|
+
const [copiedCallId, setCopiedCallId] = (0, import_react12.useState)(null);
|
|
3812
|
+
const [feedbackCallId, setFeedbackCallId] = (0, import_react12.useState)(null);
|
|
3813
|
+
const [error, setError] = (0, import_react12.useState)(null);
|
|
3814
|
+
const [emailSent, setEmailSent] = (0, import_react12.useState)(false);
|
|
3815
|
+
const [isToolInfoModalOpen, setIsToolInfoModalOpen] = (0, import_react12.useState)(false);
|
|
3816
|
+
const [toolInfoData, setToolInfoData] = (0, import_react12.useState)(null);
|
|
3817
|
+
const [callToActionSent, setCallToActionSent] = (0, import_react12.useState)(false);
|
|
3818
|
+
const [CTAClickedButNoEmail, setCTAClickedButNoEmail] = (0, import_react12.useState)(false);
|
|
3819
|
+
const [emailInput, setEmailInput] = (0, import_react12.useState)((_a = customer == null ? void 0 : customer.customer_user_email) != null ? _a : "");
|
|
3820
|
+
const [emailInputSet, setEmailInputSet] = (0, import_react12.useState)(false);
|
|
3821
|
+
const [emailValid, setEmailValid] = (0, import_react12.useState)(true);
|
|
3822
|
+
const [showEmailPanel, setShowEmailPanel] = (0, import_react12.useState)(customerEmailCaptureMode !== "HIDE");
|
|
3823
|
+
const [emailClickedButNoEmail, setEmailClickedButNoEmail] = (0, import_react12.useState)(false);
|
|
3824
|
+
const [pendingToolRequests, setPendingToolRequests] = (0, import_react12.useState)([]);
|
|
3825
|
+
const [sessionApprovedTools, setSessionApprovedTools] = (0, import_react12.useState)([]);
|
|
3826
|
+
const [alwaysApprovedTools, setAlwaysApprovedTools] = (0, import_react12.useState)([]);
|
|
3827
|
+
(0, import_react12.useEffect)(() => {
|
|
3828
|
+
setShowEmailPanel(customerEmailCaptureMode !== "HIDE");
|
|
3829
|
+
if (customerEmailCaptureMode === "REQUIRED") {
|
|
3830
|
+
if (!isEmailAddress(emailInput)) {
|
|
3831
|
+
setEmailValid(false);
|
|
3832
|
+
}
|
|
3833
|
+
}
|
|
3834
|
+
}, [customerEmailCaptureMode, emailInput]);
|
|
3835
|
+
const bottomRef = (0, import_react12.useRef)(null);
|
|
3836
|
+
const responseAreaRef = (0, import_react12.useRef)(null);
|
|
3837
|
+
const [userHasScrolled, setUserHasScrolled] = (0, import_react12.useState)(false);
|
|
3838
|
+
const lastScrollTopRef = (0, import_react12.useRef)(0);
|
|
3839
|
+
const scrollRAFRef = (0, import_react12.useRef)(null);
|
|
3840
|
+
const lastScrollTimeRef = (0, import_react12.useRef)(0);
|
|
3841
|
+
const prevIdleRef = (0, import_react12.useRef)(true);
|
|
3842
|
+
const hasNotifiedCompletionRef = (0, import_react12.useRef)(true);
|
|
3843
|
+
const latestHistoryRef = (0, import_react12.useRef)(initialHistory);
|
|
3844
|
+
const initialPromptSentRef = (0, import_react12.useRef)(false);
|
|
3845
|
+
const lastFollowOnPromptRef = (0, import_react12.useRef)("");
|
|
3846
|
+
(0, import_react12.useEffect)(() => {
|
|
3675
3847
|
if (!initialHistory) return;
|
|
3676
3848
|
setHistory((prev) => {
|
|
3677
3849
|
const currentKeys = Object.keys(prev);
|
|
@@ -3699,28 +3871,29 @@ var AIChatPanel = ({
|
|
|
3699
3871
|
idle,
|
|
3700
3872
|
lastCallId,
|
|
3701
3873
|
stop,
|
|
3702
|
-
setResponse
|
|
3874
|
+
setResponse,
|
|
3875
|
+
error: llmError
|
|
3703
3876
|
} = llmResult;
|
|
3704
3877
|
const toolList = llmResult.toolList || [];
|
|
3705
3878
|
const toolsLoading = llmResult.toolsLoading || false;
|
|
3706
3879
|
const toolsFetchError = llmResult.toolsFetchError || null;
|
|
3707
|
-
const historyCallbackRef = (0,
|
|
3708
|
-
const responseCompleteCallbackRef = (0,
|
|
3709
|
-
const responseRef = (0,
|
|
3710
|
-
const lastKeyRef = (0,
|
|
3711
|
-
const lastCallIdRef = (0,
|
|
3712
|
-
const lastPromptRef = (0,
|
|
3880
|
+
const historyCallbackRef = (0, import_react12.useRef)(historyChangedCallback);
|
|
3881
|
+
const responseCompleteCallbackRef = (0, import_react12.useRef)(responseCompleteCallback);
|
|
3882
|
+
const responseRef = (0, import_react12.useRef)(response);
|
|
3883
|
+
const lastKeyRef = (0, import_react12.useRef)(lastKey);
|
|
3884
|
+
const lastCallIdRef = (0, import_react12.useRef)(lastCallId);
|
|
3885
|
+
const lastPromptRef = (0, import_react12.useRef)(lastPrompt);
|
|
3713
3886
|
historyCallbackRef.current = historyChangedCallback;
|
|
3714
3887
|
responseCompleteCallbackRef.current = responseCompleteCallback;
|
|
3715
3888
|
responseRef.current = response;
|
|
3716
3889
|
lastKeyRef.current = lastKey;
|
|
3717
3890
|
lastCallIdRef.current = lastCallId;
|
|
3718
3891
|
lastPromptRef.current = lastPrompt;
|
|
3719
|
-
const
|
|
3720
|
-
() => theme === "light" ? import_material_light3.default : import_material_dark3.default,
|
|
3721
|
-
[theme]
|
|
3892
|
+
const effectivePrismStyle = (0, import_react12.useMemo)(
|
|
3893
|
+
() => prismStyle != null ? prismStyle : theme === "light" ? import_material_light3.default : import_material_dark3.default,
|
|
3894
|
+
[prismStyle, theme]
|
|
3722
3895
|
);
|
|
3723
|
-
const browserInfo = (0,
|
|
3896
|
+
const browserInfo = (0, import_react12.useMemo)(() => {
|
|
3724
3897
|
if (typeof window === "undefined") return null;
|
|
3725
3898
|
return {
|
|
3726
3899
|
currentTimeUTC: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -3728,8 +3901,8 @@ var AIChatPanel = ({
|
|
|
3728
3901
|
userLanguage: navigator.language
|
|
3729
3902
|
};
|
|
3730
3903
|
}, []);
|
|
3731
|
-
const ensureConversation = (0,
|
|
3732
|
-
var
|
|
3904
|
+
const ensureConversation = (0, import_react12.useCallback)(() => {
|
|
3905
|
+
var _a2, _b;
|
|
3733
3906
|
console.log("ensureConversation - called with:", {
|
|
3734
3907
|
currentConversation,
|
|
3735
3908
|
createConversationOnFirstChat,
|
|
@@ -3744,7 +3917,7 @@ var AIChatPanel = ({
|
|
|
3744
3917
|
const requestBody = {
|
|
3745
3918
|
project_id,
|
|
3746
3919
|
agentId: agent,
|
|
3747
|
-
customerId: (
|
|
3920
|
+
customerId: (_a2 = customer == null ? void 0 : customer.customer_id) != null ? _a2 : null,
|
|
3748
3921
|
customerEmail: (_b = customer == null ? void 0 : customer.customer_user_email) != null ? _b : null,
|
|
3749
3922
|
timezone: browserInfo == null ? void 0 : browserInfo.userTimezone,
|
|
3750
3923
|
language: browserInfo == null ? void 0 : browserInfo.userLanguage
|
|
@@ -3774,19 +3947,19 @@ var AIChatPanel = ({
|
|
|
3774
3947
|
}
|
|
3775
3948
|
console.warn("ensureConversation - No ID in response");
|
|
3776
3949
|
return "";
|
|
3777
|
-
}).catch((
|
|
3778
|
-
console.error("Error creating new conversation",
|
|
3950
|
+
}).catch((error2) => {
|
|
3951
|
+
console.error("Error creating new conversation", error2);
|
|
3779
3952
|
return "";
|
|
3780
3953
|
});
|
|
3781
3954
|
}
|
|
3782
3955
|
console.log("ensureConversation - using existing conversation:", currentConversation);
|
|
3783
3956
|
return Promise.resolve(currentConversation);
|
|
3784
3957
|
}, [currentConversation, createConversationOnFirstChat, publicAPIUrl, project_id, agent, customer, browserInfo]);
|
|
3785
|
-
const dataWithExtras = (0,
|
|
3786
|
-
var
|
|
3958
|
+
const dataWithExtras = (0, import_react12.useCallback)(() => {
|
|
3959
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
3787
3960
|
return [
|
|
3788
3961
|
...data,
|
|
3789
|
-
{ key: "--customer_id", data: (
|
|
3962
|
+
{ key: "--customer_id", data: (_a2 = customer == null ? void 0 : customer.customer_id) != null ? _a2 : "" },
|
|
3790
3963
|
{ key: "--customer_name", data: (_b = customer == null ? void 0 : customer.customer_name) != null ? _b : "" },
|
|
3791
3964
|
{ key: "--customer_user_id", data: (_c = customer == null ? void 0 : customer.customer_user_id) != null ? _c : "" },
|
|
3792
3965
|
{ key: "--customer_user_name", data: (_d = customer == null ? void 0 : customer.customer_user_name) != null ? _d : "" },
|
|
@@ -3796,7 +3969,7 @@ var AIChatPanel = ({
|
|
|
3796
3969
|
{ key: "--userLanguage", data: (_h = browserInfo == null ? void 0 : browserInfo.userLanguage) != null ? _h : "" }
|
|
3797
3970
|
];
|
|
3798
3971
|
}, [data, customer, browserInfo]);
|
|
3799
|
-
const currentAgentInfo = (0,
|
|
3972
|
+
const currentAgentInfo = (0, import_react12.useMemo)(() => {
|
|
3800
3973
|
if (!currentAgentId || agentOptions.length === 0) return { label: null, avatarUrl: null };
|
|
3801
3974
|
const currentAgent = agentOptions.find((a) => a.value === currentAgentId);
|
|
3802
3975
|
return {
|
|
@@ -3806,21 +3979,191 @@ var AIChatPanel = ({
|
|
|
3806
3979
|
}, [currentAgentId, agentOptions]);
|
|
3807
3980
|
const currentAgentLabel = currentAgentInfo.label;
|
|
3808
3981
|
const currentAgentAvatarUrl = currentAgentInfo.avatarUrl;
|
|
3809
|
-
const
|
|
3982
|
+
const isEmailAddress = (email) => {
|
|
3983
|
+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
3984
|
+
return emailRegex.test(email);
|
|
3985
|
+
};
|
|
3986
|
+
const convertMarkdownToHTML = (markdown) => {
|
|
3987
|
+
const html = import_server2.default.renderToStaticMarkup(
|
|
3988
|
+
/* @__PURE__ */ import_react12.default.createElement("div", { className: markdownClass }, /* @__PURE__ */ import_react12.default.createElement(
|
|
3989
|
+
import_react_markdown2.default,
|
|
3990
|
+
{
|
|
3991
|
+
remarkPlugins: [import_remark_gfm2.default],
|
|
3992
|
+
rehypePlugins: [import_rehype_raw2.default]
|
|
3993
|
+
},
|
|
3994
|
+
markdown
|
|
3995
|
+
))
|
|
3996
|
+
);
|
|
3997
|
+
return html;
|
|
3998
|
+
};
|
|
3999
|
+
const convertHistoryToHTML = (history2) => {
|
|
4000
|
+
const stylesheet = `
|
|
4001
|
+
<style>
|
|
4002
|
+
.conversation-history {
|
|
4003
|
+
font-family: Arial, sans-serif;
|
|
4004
|
+
line-height: 1.5;
|
|
4005
|
+
}
|
|
4006
|
+
.history-entry {
|
|
4007
|
+
margin-bottom: 15px;
|
|
4008
|
+
}
|
|
4009
|
+
.prompt-container, .response-container {
|
|
4010
|
+
margin-bottom: 10px;
|
|
4011
|
+
}
|
|
4012
|
+
.prompt, .response {
|
|
4013
|
+
display: block;
|
|
4014
|
+
margin: 5px 0;
|
|
4015
|
+
padding: 10px;
|
|
4016
|
+
border-radius: 5px;
|
|
4017
|
+
max-width: 80%;
|
|
4018
|
+
}
|
|
4019
|
+
.prompt {
|
|
4020
|
+
background-color: #efefef;
|
|
4021
|
+
margin-left: 0;
|
|
4022
|
+
}
|
|
4023
|
+
.response {
|
|
4024
|
+
background-color: #f0fcfd;
|
|
4025
|
+
margin-left: 25px;
|
|
4026
|
+
}
|
|
4027
|
+
</style>
|
|
4028
|
+
`;
|
|
4029
|
+
let html = `
|
|
4030
|
+
<html>
|
|
4031
|
+
<head>
|
|
4032
|
+
${stylesheet}
|
|
4033
|
+
</head>
|
|
4034
|
+
<body>
|
|
4035
|
+
<h1>Conversation History (${(/* @__PURE__ */ new Date()).toLocaleString()})</h1>
|
|
4036
|
+
<div class="conversation-history">
|
|
4037
|
+
`;
|
|
4038
|
+
Object.entries(history2).forEach(([prompt, response2], index) => {
|
|
4039
|
+
if (hideInitialPrompt && index === 0) {
|
|
4040
|
+
html += `
|
|
4041
|
+
<div class="history-entry">
|
|
4042
|
+
<div class="response-container">
|
|
4043
|
+
<div class="response">${convertMarkdownToHTML(response2.content)}</div>
|
|
4044
|
+
</div>
|
|
4045
|
+
</div>
|
|
4046
|
+
`;
|
|
4047
|
+
} else {
|
|
4048
|
+
html += `
|
|
4049
|
+
<div class="history-entry">
|
|
4050
|
+
<div class="prompt-container">
|
|
4051
|
+
<div class="prompt">${convertMarkdownToHTML(
|
|
4052
|
+
formatPromptForDisplay(prompt)
|
|
4053
|
+
)}</div>
|
|
4054
|
+
</div>
|
|
4055
|
+
<div class="response-container">
|
|
4056
|
+
<div class="response">${convertMarkdownToHTML(response2.content)}</div>
|
|
4057
|
+
</div>
|
|
4058
|
+
</div>
|
|
4059
|
+
`;
|
|
4060
|
+
}
|
|
4061
|
+
});
|
|
4062
|
+
html += `
|
|
4063
|
+
</div>
|
|
4064
|
+
</body>
|
|
4065
|
+
</html>
|
|
4066
|
+
`;
|
|
4067
|
+
return html;
|
|
4068
|
+
};
|
|
4069
|
+
const saveHTMLToFile = (html, filename) => {
|
|
4070
|
+
const blob = new Blob([html], { type: "text/html" });
|
|
4071
|
+
const link = document.createElement("a");
|
|
4072
|
+
link.href = URL.createObjectURL(blob);
|
|
4073
|
+
link.download = filename;
|
|
4074
|
+
document.body.appendChild(link);
|
|
4075
|
+
link.click();
|
|
4076
|
+
document.body.removeChild(link);
|
|
4077
|
+
};
|
|
4078
|
+
const saveAsHTMLFile = (0, import_react12.useCallback)(() => {
|
|
4079
|
+
saveHTMLToFile(
|
|
4080
|
+
convertHistoryToHTML(history),
|
|
4081
|
+
`conversation-${(/* @__PURE__ */ new Date()).toISOString()}.html`
|
|
4082
|
+
);
|
|
4083
|
+
interactionClicked(lastCallId || "", "save");
|
|
4084
|
+
}, [history, lastCallId]);
|
|
4085
|
+
const handleSendEmail = (to, from) => {
|
|
4086
|
+
sendConversationsViaEmail(to, `Conversation History from ${title}`, from);
|
|
4087
|
+
interactionClicked(lastCallId || "", "email", to);
|
|
4088
|
+
setEmailSent(true);
|
|
4089
|
+
};
|
|
4090
|
+
const sendConversationsViaEmail = (_0, ..._1) => __async(void 0, [_0, ..._1], function* (to, subject = `Conversation History from ${title}`, from = "") {
|
|
4091
|
+
fetch(`${publicAPIUrl}/share/email`, {
|
|
4092
|
+
method: "POST",
|
|
4093
|
+
headers: {
|
|
4094
|
+
"Content-Type": "application/json"
|
|
4095
|
+
},
|
|
4096
|
+
body: JSON.stringify({
|
|
4097
|
+
to,
|
|
4098
|
+
from,
|
|
4099
|
+
subject,
|
|
4100
|
+
html: convertHistoryToHTML(history),
|
|
4101
|
+
project_id: project_id != null ? project_id : "",
|
|
4102
|
+
customer,
|
|
4103
|
+
history,
|
|
4104
|
+
title
|
|
4105
|
+
})
|
|
4106
|
+
});
|
|
4107
|
+
yield interactionClicked(lastCallId || "", "email", from);
|
|
4108
|
+
});
|
|
4109
|
+
const sendCallToActionEmail = (0, import_react12.useCallback)((from) => __async(void 0, null, function* () {
|
|
4110
|
+
try {
|
|
4111
|
+
yield fetch(`${publicAPIUrl}/share/email`, {
|
|
4112
|
+
method: "POST",
|
|
4113
|
+
headers: {
|
|
4114
|
+
"Content-Type": "application/json"
|
|
4115
|
+
},
|
|
4116
|
+
body: JSON.stringify({
|
|
4117
|
+
to: callToActionEmailAddress,
|
|
4118
|
+
from,
|
|
4119
|
+
subject: `${callToActionEmailSubject} from ${from}`,
|
|
4120
|
+
html: convertHistoryToHTML(history),
|
|
4121
|
+
project_id: project_id != null ? project_id : "",
|
|
4122
|
+
customer,
|
|
4123
|
+
history,
|
|
4124
|
+
title
|
|
4125
|
+
})
|
|
4126
|
+
});
|
|
4127
|
+
yield interactionClicked(lastCallId || "", "cta", from);
|
|
4128
|
+
setCallToActionSent(true);
|
|
4129
|
+
} catch (err) {
|
|
4130
|
+
console.error("[AIChatPanel] Failed to send CTA email:", err);
|
|
4131
|
+
}
|
|
4132
|
+
}), [history, title, project_id, customer, lastCallId, publicAPIUrl, callToActionEmailAddress, callToActionEmailSubject]);
|
|
4133
|
+
const isDisabledDueToNoEmail = (0, import_react12.useCallback)(() => {
|
|
4134
|
+
if (customerEmailCaptureMode === "REQUIRED" && !emailInputSet) {
|
|
4135
|
+
return true;
|
|
4136
|
+
}
|
|
4137
|
+
return false;
|
|
4138
|
+
}, [customerEmailCaptureMode, emailInputSet]);
|
|
4139
|
+
const handleToolApproval = (0, import_react12.useCallback)((toolName, scope) => {
|
|
4140
|
+
if (scope === "session" || scope === "always") {
|
|
4141
|
+
setSessionApprovedTools((prev) => Array.from(/* @__PURE__ */ new Set([...prev, toolName])));
|
|
4142
|
+
}
|
|
4143
|
+
if (scope === "always") {
|
|
4144
|
+
setAlwaysApprovedTools((prev) => Array.from(/* @__PURE__ */ new Set([...prev, toolName])));
|
|
4145
|
+
}
|
|
4146
|
+
setPendingToolRequests((prev) => prev.filter((r) => r.toolName !== toolName));
|
|
4147
|
+
console.log(`[AIChatPanel] Tool "${toolName}" approved with scope: ${scope}`);
|
|
4148
|
+
}, []);
|
|
4149
|
+
const getUniqueToolNames = (0, import_react12.useCallback)(() => {
|
|
4150
|
+
return Array.from(new Set(pendingToolRequests.map((r) => r.toolName)));
|
|
4151
|
+
}, [pendingToolRequests]);
|
|
4152
|
+
const cleanContentForDisplay = (0, import_react12.useCallback)((content) => {
|
|
3810
4153
|
let cleaned = content.replace(/\*\*(.*?)\*\*/g, "$1").replace(/\*(.*?)\*/g, "$1").replace(/\n+/g, " ").replace(/\s+/g, " ").trim();
|
|
3811
4154
|
if (cleaned.length > 100) {
|
|
3812
4155
|
cleaned = cleaned.substring(0, 100) + "...";
|
|
3813
4156
|
}
|
|
3814
4157
|
return cleaned || "Thinking";
|
|
3815
4158
|
}, []);
|
|
3816
|
-
const processThinkingTags = (0,
|
|
3817
|
-
var
|
|
4159
|
+
const processThinkingTags = (0, import_react12.useCallback)((text) => {
|
|
4160
|
+
var _a2, _b;
|
|
3818
4161
|
const blocks = [];
|
|
3819
4162
|
let index = 0;
|
|
3820
4163
|
const reasoningRegex = /<reasoning>([\s\S]*?)<\/reasoning>/gi;
|
|
3821
4164
|
let match;
|
|
3822
4165
|
while ((match = reasoningRegex.exec(text)) !== null) {
|
|
3823
|
-
blocks.push({ type: "reasoning", content: (
|
|
4166
|
+
blocks.push({ type: "reasoning", content: (_a2 = match[1]) != null ? _a2 : "", index: index++ });
|
|
3824
4167
|
}
|
|
3825
4168
|
const searchingRegex = /<searching>([\s\S]*?)<\/searching>/gi;
|
|
3826
4169
|
while ((match = searchingRegex.exec(text)) !== null) {
|
|
@@ -3834,7 +4177,7 @@ var AIChatPanel = ({
|
|
|
3834
4177
|
pattern: "\\[SUGGEST_AGENT:([^|\\]]+)\\|([^|\\]]+)\\|([^\\]]+)\\]",
|
|
3835
4178
|
markdown: '<agent-suggestion data-agent-id="$1" data-agent-name="$2" data-reason="$3"></agent-suggestion>'
|
|
3836
4179
|
};
|
|
3837
|
-
const processActions = (0,
|
|
4180
|
+
const processActions = (0, import_react12.useCallback)((content) => {
|
|
3838
4181
|
const allActions = [AGENT_SUGGESTION_ACTION, ...actions || []];
|
|
3839
4182
|
let processed = content;
|
|
3840
4183
|
allActions.forEach((action) => {
|
|
@@ -3849,7 +4192,7 @@ var AIChatPanel = ({
|
|
|
3849
4192
|
});
|
|
3850
4193
|
return processed;
|
|
3851
4194
|
}, [actions]);
|
|
3852
|
-
const formatPromptForDisplay = (0,
|
|
4195
|
+
const formatPromptForDisplay = (0, import_react12.useCallback)((prompt) => {
|
|
3853
4196
|
let displayPrompt = prompt;
|
|
3854
4197
|
const isoTimestampRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z:/;
|
|
3855
4198
|
if (isoTimestampRegex.test(displayPrompt)) {
|
|
@@ -3867,37 +4210,81 @@ var AIChatPanel = ({
|
|
|
3867
4210
|
}
|
|
3868
4211
|
return displayPrompt;
|
|
3869
4212
|
}, [hideRagContextInPrompt]);
|
|
3870
|
-
const
|
|
4213
|
+
const interactionClicked = (0, import_react12.useCallback)((callId, action, emailaddress = "", comment = "") => __async(void 0, null, function* () {
|
|
4214
|
+
var _a2, _b;
|
|
4215
|
+
console.log(`[AIChatPanel] Interaction: ${action} for callId: ${callId}`);
|
|
4216
|
+
const convId = currentConversation || (yield ensureConversation());
|
|
4217
|
+
const finalCallId = callId || convId;
|
|
4218
|
+
const isEmailAddress2 = (str) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(str);
|
|
4219
|
+
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 : "";
|
|
3871
4220
|
try {
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
4221
|
+
yield fetch(`${publicAPIUrl}/feedback/${finalCallId}/${action}`, {
|
|
4222
|
+
method: "POST",
|
|
4223
|
+
headers: {
|
|
4224
|
+
"Content-Type": "application/json"
|
|
4225
|
+
},
|
|
4226
|
+
body: JSON.stringify({
|
|
4227
|
+
project_id: project_id != null ? project_id : "",
|
|
4228
|
+
conversation_id: convId != null ? convId : "",
|
|
4229
|
+
email,
|
|
4230
|
+
comment
|
|
4231
|
+
})
|
|
4232
|
+
});
|
|
4233
|
+
} catch (err) {
|
|
4234
|
+
console.error("[AIChatPanel] Failed to send feedback:", err);
|
|
4235
|
+
}
|
|
4236
|
+
}), [currentConversation, ensureConversation, customer, project_id, publicAPIUrl]);
|
|
4237
|
+
const copyToClipboard = (0, import_react12.useCallback)((text, callId) => __async(void 0, null, function* () {
|
|
4238
|
+
try {
|
|
4239
|
+
const cleanText = text.replace(/<[^>]*>/g, "").replace(/\*\*(.*?)\*\*/g, "$1").replace(/\*(.*?)\*/g, "$1").replace(/#{1,6}\s/g, "").replace(/\[([^\]]+)\]\([^)]+\)/g, "$1");
|
|
4240
|
+
yield navigator.clipboard.writeText(cleanText);
|
|
4241
|
+
setCopiedCallId(callId);
|
|
4242
|
+
setTimeout(() => setCopiedCallId(null), 2e3);
|
|
4243
|
+
yield interactionClicked(callId, "copy");
|
|
4244
|
+
} catch (err) {
|
|
4245
|
+
console.error("Failed to copy:", err);
|
|
4246
|
+
}
|
|
4247
|
+
}), [interactionClicked]);
|
|
4248
|
+
const handleThumbsUp = (0, import_react12.useCallback)((callId) => __async(void 0, null, function* () {
|
|
4249
|
+
console.log("[AIChatPanel] Thumbs up clicked:", callId);
|
|
4250
|
+
setFeedbackCallId({ callId, type: "up" });
|
|
4251
|
+
setTimeout(() => setFeedbackCallId(null), 2e3);
|
|
4252
|
+
yield interactionClicked(callId, "thumbsup");
|
|
4253
|
+
if (thumbsUpClick) {
|
|
4254
|
+
thumbsUpClick(callId);
|
|
4255
|
+
}
|
|
4256
|
+
}), [thumbsUpClick, interactionClicked]);
|
|
4257
|
+
const handleThumbsDown = (0, import_react12.useCallback)((callId) => __async(void 0, null, function* () {
|
|
4258
|
+
console.log("[AIChatPanel] Thumbs down clicked:", callId);
|
|
4259
|
+
setFeedbackCallId({ callId, type: "down" });
|
|
4260
|
+
setTimeout(() => setFeedbackCallId(null), 2e3);
|
|
4261
|
+
yield interactionClicked(callId, "thumbsdown");
|
|
4262
|
+
if (thumbsDownClick) {
|
|
4263
|
+
thumbsDownClick(callId);
|
|
4264
|
+
}
|
|
4265
|
+
}), [thumbsDownClick, interactionClicked]);
|
|
4266
|
+
const scrollToBottom = (0, import_react12.useCallback)(() => {
|
|
4267
|
+
var _a2;
|
|
3882
4268
|
if (scrollRAFRef.current) {
|
|
3883
4269
|
cancelAnimationFrame(scrollRAFRef.current);
|
|
3884
4270
|
}
|
|
3885
4271
|
const now = Date.now();
|
|
3886
4272
|
if (now - lastScrollTimeRef.current < 100) {
|
|
3887
4273
|
scrollRAFRef.current = requestAnimationFrame(() => {
|
|
3888
|
-
var
|
|
3889
|
-
(
|
|
4274
|
+
var _a3;
|
|
4275
|
+
(_a3 = bottomRef.current) == null ? void 0 : _a3.scrollIntoView({ behavior: "auto" });
|
|
3890
4276
|
lastScrollTimeRef.current = Date.now();
|
|
3891
4277
|
});
|
|
3892
4278
|
return;
|
|
3893
4279
|
}
|
|
3894
|
-
(
|
|
4280
|
+
(_a2 = bottomRef.current) == null ? void 0 : _a2.scrollIntoView({ behavior: "auto" });
|
|
3895
4281
|
lastScrollTimeRef.current = now;
|
|
3896
4282
|
}, []);
|
|
3897
|
-
const continueChat = (0,
|
|
4283
|
+
const continueChat = (0, import_react12.useCallback)((promptText) => {
|
|
3898
4284
|
console.log("AIChatPanel.continueChat called with:", promptText);
|
|
3899
4285
|
setThinkingBlocks([]);
|
|
3900
4286
|
setCurrentThinkingIndex(0);
|
|
4287
|
+
setError(null);
|
|
3901
4288
|
setUserHasScrolled(false);
|
|
3902
4289
|
setResponse("");
|
|
3903
4290
|
if (!idle) {
|
|
@@ -3948,11 +4335,6 @@ var AIChatPanel = ({
|
|
|
3948
4335
|
if (messagesAndHistory.length === 0 && promptTemplate) {
|
|
3949
4336
|
fullPromptToSend = promptTemplate.replace("{{prompt}}", fullPromptToSend);
|
|
3950
4337
|
}
|
|
3951
|
-
if (followOnPrompt) {
|
|
3952
|
-
fullPromptToSend += `
|
|
3953
|
-
|
|
3954
|
-
${followOnPrompt}`;
|
|
3955
|
-
}
|
|
3956
4338
|
const newController = new AbortController();
|
|
3957
4339
|
setLastController(newController);
|
|
3958
4340
|
send(
|
|
@@ -3970,7 +4352,37 @@ ${followOnPrompt}`;
|
|
|
3970
4352
|
// group_id from agent config
|
|
3971
4353
|
convId,
|
|
3972
4354
|
// Use the conversation ID from ensureConversation
|
|
3973
|
-
newController
|
|
4355
|
+
newController,
|
|
4356
|
+
void 0,
|
|
4357
|
+
// onComplete
|
|
4358
|
+
(errorMsg) => {
|
|
4359
|
+
console.log("[AIChatPanel] Error callback triggered:", errorMsg);
|
|
4360
|
+
if (errorMsg.includes("413") || errorMsg.toLowerCase().includes("content too large")) {
|
|
4361
|
+
setError({
|
|
4362
|
+
message: "The context is too large to process. Please start a new conversation or reduce the amount of context.",
|
|
4363
|
+
code: "413"
|
|
4364
|
+
});
|
|
4365
|
+
} else if (errorMsg.toLowerCase().includes("network error") || errorMsg.toLowerCase().includes("fetch")) {
|
|
4366
|
+
setError({
|
|
4367
|
+
message: "Network error. Please check your connection and try again.",
|
|
4368
|
+
code: "NETWORK_ERROR"
|
|
4369
|
+
});
|
|
4370
|
+
} else {
|
|
4371
|
+
setError({
|
|
4372
|
+
message: errorMsg,
|
|
4373
|
+
code: "UNKNOWN_ERROR"
|
|
4374
|
+
});
|
|
4375
|
+
}
|
|
4376
|
+
setIsLoading(false);
|
|
4377
|
+
if (promptKey) {
|
|
4378
|
+
setHistory((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
4379
|
+
[promptKey]: {
|
|
4380
|
+
content: `Error: ${errorMsg}`,
|
|
4381
|
+
callId: lastCallId || ""
|
|
4382
|
+
}
|
|
4383
|
+
}));
|
|
4384
|
+
}
|
|
4385
|
+
}
|
|
3974
4386
|
);
|
|
3975
4387
|
setLastMessages(messagesAndHistory);
|
|
3976
4388
|
if (convId && onConversationCreated) {
|
|
@@ -3990,7 +4402,6 @@ ${followOnPrompt}`;
|
|
|
3990
4402
|
clearFollowOnQuestionsNextPrompt,
|
|
3991
4403
|
history,
|
|
3992
4404
|
promptTemplate,
|
|
3993
|
-
followOnPrompt,
|
|
3994
4405
|
send,
|
|
3995
4406
|
service,
|
|
3996
4407
|
ensureConversation,
|
|
@@ -3999,13 +4410,13 @@ ${followOnPrompt}`;
|
|
|
3999
4410
|
onConversationCreated,
|
|
4000
4411
|
setResponse
|
|
4001
4412
|
]);
|
|
4002
|
-
const handleSuggestionClick = (0,
|
|
4413
|
+
const handleSuggestionClick = (0, import_react12.useCallback)((question) => {
|
|
4003
4414
|
continueChat(question);
|
|
4004
4415
|
}, [continueChat]);
|
|
4005
|
-
const handleStop = (0,
|
|
4416
|
+
const handleStop = (0, import_react12.useCallback)(() => {
|
|
4006
4417
|
stop(lastController);
|
|
4007
4418
|
}, [stop, lastController]);
|
|
4008
|
-
const handleNewConversation = (0,
|
|
4419
|
+
const handleNewConversation = (0, import_react12.useCallback)(() => {
|
|
4009
4420
|
if (!newConversationConfirm) {
|
|
4010
4421
|
setNewConversationConfirm(true);
|
|
4011
4422
|
setTimeout(() => setNewConversationConfirm(false), 3e3);
|
|
@@ -4030,13 +4441,14 @@ ${followOnPrompt}`;
|
|
|
4030
4441
|
setJustReset(true);
|
|
4031
4442
|
setLastController(new AbortController());
|
|
4032
4443
|
setUserHasScrolled(false);
|
|
4444
|
+
setError(null);
|
|
4033
4445
|
setTimeout(() => {
|
|
4034
|
-
var
|
|
4446
|
+
var _a2;
|
|
4035
4447
|
setJustReset(false);
|
|
4036
|
-
(
|
|
4448
|
+
(_a2 = responseAreaRef.current) == null ? void 0 : _a2.scrollTo({ top: 0, behavior: "smooth" });
|
|
4037
4449
|
}, 100);
|
|
4038
4450
|
}, [newConversationConfirm, idle, stop, lastController, setResponse, followOnQuestions]);
|
|
4039
|
-
(0,
|
|
4451
|
+
(0, import_react12.useEffect)(() => {
|
|
4040
4452
|
if (!response || !lastKey || justReset) return;
|
|
4041
4453
|
const { cleanedText, blocks } = processThinkingTags(response);
|
|
4042
4454
|
setThinkingBlocks(blocks);
|
|
@@ -4051,12 +4463,13 @@ ${followOnPrompt}`;
|
|
|
4051
4463
|
return newHistory;
|
|
4052
4464
|
});
|
|
4053
4465
|
}, [response, lastKey, lastCallId, processThinkingTags, justReset]);
|
|
4054
|
-
(0,
|
|
4466
|
+
(0, import_react12.useEffect)(() => {
|
|
4055
4467
|
const wasStreaming = !prevIdleRef.current;
|
|
4056
4468
|
const isNowIdle = idle;
|
|
4057
4469
|
prevIdleRef.current = idle;
|
|
4058
4470
|
if (wasStreaming && isNowIdle && !hasNotifiedCompletionRef.current) {
|
|
4059
4471
|
hasNotifiedCompletionRef.current = true;
|
|
4472
|
+
setIsLoading(false);
|
|
4060
4473
|
const currentHistory = latestHistoryRef.current;
|
|
4061
4474
|
const currentLastKey = lastKeyRef.current;
|
|
4062
4475
|
const currentLastCallId = lastCallIdRef.current;
|
|
@@ -4075,16 +4488,17 @@ ${followOnPrompt}`;
|
|
|
4075
4488
|
hasNotifiedCompletionRef.current = false;
|
|
4076
4489
|
}
|
|
4077
4490
|
}, [idle]);
|
|
4078
|
-
(0,
|
|
4079
|
-
|
|
4491
|
+
(0, import_react12.useEffect)(() => {
|
|
4492
|
+
const shouldAutoScroll = scrollToEnd || !userHasScrolled;
|
|
4493
|
+
if (!idle && shouldAutoScroll && response) {
|
|
4080
4494
|
scrollToBottom();
|
|
4081
4495
|
}
|
|
4082
|
-
}, [response, scrollToBottom, idle, userHasScrolled]);
|
|
4083
|
-
const idleRef = (0,
|
|
4496
|
+
}, [response, scrollToBottom, idle, userHasScrolled, scrollToEnd]);
|
|
4497
|
+
const idleRef = (0, import_react12.useRef)(idle);
|
|
4084
4498
|
idleRef.current = idle;
|
|
4085
|
-
const userHasScrolledRef = (0,
|
|
4499
|
+
const userHasScrolledRef = (0, import_react12.useRef)(userHasScrolled);
|
|
4086
4500
|
userHasScrolledRef.current = userHasScrolled;
|
|
4087
|
-
(0,
|
|
4501
|
+
(0, import_react12.useEffect)(() => {
|
|
4088
4502
|
const scrollArea = responseAreaRef.current;
|
|
4089
4503
|
if (!scrollArea) return;
|
|
4090
4504
|
const scrollViewport = scrollArea.querySelector("[data-radix-scroll-area-viewport]");
|
|
@@ -4103,16 +4517,16 @@ ${followOnPrompt}`;
|
|
|
4103
4517
|
scrollElement.addEventListener("scroll", handleScroll, { passive: true });
|
|
4104
4518
|
return () => scrollElement.removeEventListener("scroll", handleScroll);
|
|
4105
4519
|
}, []);
|
|
4106
|
-
(0,
|
|
4520
|
+
(0, import_react12.useEffect)(() => {
|
|
4107
4521
|
setFollowOnQuestionsState(followOnQuestions);
|
|
4108
4522
|
}, [followOnQuestions]);
|
|
4109
|
-
(0,
|
|
4523
|
+
(0, import_react12.useEffect)(() => {
|
|
4110
4524
|
const currentlyLoading = isLoading || !idle;
|
|
4111
4525
|
if (onLoadingChange) {
|
|
4112
4526
|
onLoadingChange(currentlyLoading);
|
|
4113
4527
|
}
|
|
4114
4528
|
}, [isLoading, idle, onLoadingChange]);
|
|
4115
|
-
(0,
|
|
4529
|
+
(0, import_react12.useEffect)(() => {
|
|
4116
4530
|
return () => {
|
|
4117
4531
|
if (scrollRAFRef.current) {
|
|
4118
4532
|
cancelAnimationFrame(scrollRAFRef.current);
|
|
@@ -4132,26 +4546,115 @@ ${followOnPrompt}`;
|
|
|
4132
4546
|
}
|
|
4133
4547
|
};
|
|
4134
4548
|
}, []);
|
|
4135
|
-
(0,
|
|
4549
|
+
(0, import_react12.useEffect)(() => {
|
|
4136
4550
|
if (initialPrompt && initialPrompt !== "" && !initialPromptSentRef.current) {
|
|
4137
4551
|
initialPromptSentRef.current = true;
|
|
4138
4552
|
continueChat(initialPrompt);
|
|
4139
4553
|
}
|
|
4140
4554
|
}, [initialPrompt, continueChat]);
|
|
4141
|
-
|
|
4142
|
-
|
|
4555
|
+
(0, import_react12.useEffect)(() => {
|
|
4556
|
+
if (followOnPrompt && followOnPrompt !== "" && followOnPrompt !== lastFollowOnPromptRef.current) {
|
|
4557
|
+
lastFollowOnPromptRef.current = followOnPrompt;
|
|
4558
|
+
continueChat(followOnPrompt);
|
|
4559
|
+
}
|
|
4560
|
+
}, [followOnPrompt, continueChat]);
|
|
4561
|
+
(0, import_react12.useEffect)(() => {
|
|
4562
|
+
if (llmError && llmError.trim()) {
|
|
4563
|
+
console.log("[AIChatPanel] Error detected:", llmError);
|
|
4564
|
+
const errorMessage = llmError;
|
|
4565
|
+
if (errorMessage.includes("413") || errorMessage.toLowerCase().includes("content too large")) {
|
|
4566
|
+
setError({
|
|
4567
|
+
message: "The context is too large to process. Please start a new conversation or reduce the amount of context.",
|
|
4568
|
+
code: "413"
|
|
4569
|
+
});
|
|
4570
|
+
} else if (errorMessage.toLowerCase().includes("network error") || errorMessage.toLowerCase().includes("fetch")) {
|
|
4571
|
+
setError({
|
|
4572
|
+
message: "Network error. Please check your connection and try again.",
|
|
4573
|
+
code: "NETWORK_ERROR"
|
|
4574
|
+
});
|
|
4575
|
+
} else {
|
|
4576
|
+
setError({
|
|
4577
|
+
message: errorMessage,
|
|
4578
|
+
code: "UNKNOWN_ERROR"
|
|
4579
|
+
});
|
|
4580
|
+
}
|
|
4581
|
+
setIsLoading(false);
|
|
4582
|
+
if (lastKey) {
|
|
4583
|
+
setHistory((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
4584
|
+
[lastKey]: {
|
|
4585
|
+
content: `Error: ${errorMessage}`,
|
|
4586
|
+
callId: lastCallId || ""
|
|
4587
|
+
}
|
|
4588
|
+
}));
|
|
4589
|
+
}
|
|
4590
|
+
}
|
|
4591
|
+
}, [llmError, lastKey, lastCallId]);
|
|
4592
|
+
(0, import_react12.useEffect)(() => {
|
|
4593
|
+
const existingLinks = document.querySelectorAll(
|
|
4594
|
+
'link[data-source="ai-chat-panel"]'
|
|
4595
|
+
);
|
|
4596
|
+
existingLinks.forEach((link) => {
|
|
4597
|
+
var _a2;
|
|
4598
|
+
return (_a2 = link.parentNode) == null ? void 0 : _a2.removeChild(link);
|
|
4599
|
+
});
|
|
4600
|
+
const existingStyles = document.querySelectorAll(
|
|
4601
|
+
'style[data-source="ai-chat-panel"]'
|
|
4602
|
+
);
|
|
4603
|
+
existingStyles.forEach((style) => {
|
|
4604
|
+
var _a2;
|
|
4605
|
+
return (_a2 = style.parentNode) == null ? void 0 : _a2.removeChild(style);
|
|
4606
|
+
});
|
|
4607
|
+
if (cssUrl) {
|
|
4608
|
+
if (cssUrl.startsWith("http://") || cssUrl.startsWith("https://")) {
|
|
4609
|
+
const link = document.createElement("link");
|
|
4610
|
+
link.href = cssUrl;
|
|
4611
|
+
link.rel = "stylesheet";
|
|
4612
|
+
link.setAttribute("data-source", "ai-chat-panel");
|
|
4613
|
+
document.head.appendChild(link);
|
|
4614
|
+
} else {
|
|
4615
|
+
const style = document.createElement("style");
|
|
4616
|
+
style.textContent = cssUrl;
|
|
4617
|
+
style.setAttribute("data-source", "ai-chat-panel");
|
|
4618
|
+
document.head.appendChild(style);
|
|
4619
|
+
}
|
|
4620
|
+
}
|
|
4621
|
+
return () => {
|
|
4622
|
+
const links = document.querySelectorAll(
|
|
4623
|
+
'link[data-source="ai-chat-panel"]'
|
|
4624
|
+
);
|
|
4625
|
+
links.forEach((link) => {
|
|
4626
|
+
var _a2;
|
|
4627
|
+
return (_a2 = link.parentNode) == null ? void 0 : _a2.removeChild(link);
|
|
4628
|
+
});
|
|
4629
|
+
const styles = document.querySelectorAll(
|
|
4630
|
+
'style[data-source="ai-chat-panel"]'
|
|
4631
|
+
);
|
|
4632
|
+
styles.forEach((style) => {
|
|
4633
|
+
var _a2;
|
|
4634
|
+
return (_a2 = style.parentNode) == null ? void 0 : _a2.removeChild(style);
|
|
4635
|
+
});
|
|
4636
|
+
};
|
|
4637
|
+
}, [cssUrl]);
|
|
4638
|
+
const CodeBlock = (0, import_react12.useCallback)((_b) => {
|
|
4639
|
+
var _c = _b, { node, inline, className, children } = _c, props = __objRest(_c, ["node", "inline", "className", "children"]);
|
|
4143
4640
|
const match = /language-(\w+)/.exec(className || "");
|
|
4144
|
-
return !inline && match ? /* @__PURE__ */
|
|
4641
|
+
return !inline && match ? /* @__PURE__ */ import_react12.default.createElement(
|
|
4145
4642
|
import_react_syntax_highlighter2.Prism,
|
|
4146
4643
|
__spreadValues({
|
|
4147
|
-
style:
|
|
4644
|
+
style: effectivePrismStyle,
|
|
4148
4645
|
language: match[1],
|
|
4149
4646
|
PreTag: "div"
|
|
4150
4647
|
}, props),
|
|
4151
4648
|
String(children).replace(/\n$/, "")
|
|
4152
|
-
) : /* @__PURE__ */
|
|
4153
|
-
}, [
|
|
4154
|
-
const AgentSuggestionCard =
|
|
4649
|
+
) : /* @__PURE__ */ import_react12.default.createElement("code", __spreadValues({ className }, props), children);
|
|
4650
|
+
}, [effectivePrismStyle]);
|
|
4651
|
+
const AgentSuggestionCard = import_react12.default.memo(({ agentId, agentName, reason }) => {
|
|
4652
|
+
(0, import_react12.useEffect)(() => {
|
|
4653
|
+
const timer = setTimeout(() => {
|
|
4654
|
+
scrollToBottom();
|
|
4655
|
+
}, 100);
|
|
4656
|
+
return () => clearTimeout(timer);
|
|
4657
|
+
}, []);
|
|
4155
4658
|
if (!agentId || !onAgentChange) return null;
|
|
4156
4659
|
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);
|
|
4157
4660
|
const agentOption = agentOptions.find((opt) => opt.value === agentId);
|
|
@@ -4160,33 +4663,33 @@ ${followOnPrompt}`;
|
|
|
4160
4663
|
const avatarUrl = agentOption == null ? void 0 : agentOption.avatarUrl;
|
|
4161
4664
|
const isCurrentAgent = currentAgentId === agentId;
|
|
4162
4665
|
if (!isValidAgent || agentId.includes("{") || agentId.includes("$")) {
|
|
4163
|
-
return /* @__PURE__ */
|
|
4666
|
+
return /* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-agent-suggestion ai-chat-agent-suggestion--invalid" }, /* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-agent-suggestion__content" }, avatarUrl ? /* @__PURE__ */ import_react12.default.createElement(
|
|
4164
4667
|
"img",
|
|
4165
4668
|
{
|
|
4166
4669
|
src: avatarUrl,
|
|
4167
4670
|
alt: agentName,
|
|
4168
4671
|
className: "ai-chat-agent-suggestion__avatar"
|
|
4169
4672
|
}
|
|
4170
|
-
) : /* @__PURE__ */
|
|
4673
|
+
) : /* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-agent-suggestion__icon" }, /* @__PURE__ */ import_react12.default.createElement("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, /* @__PURE__ */ import_react12.default.createElement("path", { d: "M12 8V4H8" }), /* @__PURE__ */ import_react12.default.createElement("rect", { width: "16", height: "12", x: "4", y: "8", rx: "2" }), /* @__PURE__ */ import_react12.default.createElement("path", { d: "M2 14h2" }), /* @__PURE__ */ import_react12.default.createElement("path", { d: "M20 14h2" }), /* @__PURE__ */ import_react12.default.createElement("path", { d: "M15 13v2" }), /* @__PURE__ */ import_react12.default.createElement("path", { d: "M9 13v2" }))), /* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-agent-suggestion__text" }, /* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-agent-suggestion__label" }, "Suggested: ", agentName), reason && /* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-agent-suggestion__reason" }, reason))), /* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-agent-suggestion__unavailable" }, "Agent unavailable"));
|
|
4171
4674
|
}
|
|
4172
4675
|
if (isCurrentAgent) {
|
|
4173
|
-
return /* @__PURE__ */
|
|
4676
|
+
return /* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-agent-suggestion ai-chat-agent-suggestion--switched" }, /* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-agent-suggestion__content" }, avatarUrl ? /* @__PURE__ */ import_react12.default.createElement(
|
|
4174
4677
|
"img",
|
|
4175
4678
|
{
|
|
4176
4679
|
src: avatarUrl,
|
|
4177
4680
|
alt: agentName,
|
|
4178
4681
|
className: "ai-chat-agent-suggestion__avatar"
|
|
4179
4682
|
}
|
|
4180
|
-
) : /* @__PURE__ */
|
|
4683
|
+
) : /* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-agent-suggestion__icon ai-chat-agent-suggestion__icon--switched" }, /* @__PURE__ */ import_react12.default.createElement("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, /* @__PURE__ */ import_react12.default.createElement("polyline", { points: "20 6 9 17 4 12" }))), /* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-agent-suggestion__text" }, /* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-agent-suggestion__label" }, "Switched to ", agentName), reason && /* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-agent-suggestion__reason" }, reason))), /* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-agent-suggestion__switched-badge" }, /* @__PURE__ */ import_react12.default.createElement("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round" }, /* @__PURE__ */ import_react12.default.createElement("polyline", { points: "20 6 9 17 4 12" })), "Active"));
|
|
4181
4684
|
}
|
|
4182
|
-
return /* @__PURE__ */
|
|
4685
|
+
return /* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-agent-suggestion" }, /* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-agent-suggestion__content" }, avatarUrl ? /* @__PURE__ */ import_react12.default.createElement(
|
|
4183
4686
|
"img",
|
|
4184
4687
|
{
|
|
4185
4688
|
src: avatarUrl,
|
|
4186
4689
|
alt: agentName,
|
|
4187
4690
|
className: "ai-chat-agent-suggestion__avatar"
|
|
4188
4691
|
}
|
|
4189
|
-
) : /* @__PURE__ */
|
|
4692
|
+
) : /* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-agent-suggestion__icon" }, /* @__PURE__ */ import_react12.default.createElement("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, /* @__PURE__ */ import_react12.default.createElement("path", { d: "M12 8V4H8" }), /* @__PURE__ */ import_react12.default.createElement("rect", { width: "16", height: "12", x: "4", y: "8", rx: "2" }), /* @__PURE__ */ import_react12.default.createElement("path", { d: "M2 14h2" }), /* @__PURE__ */ import_react12.default.createElement("path", { d: "M20 14h2" }), /* @__PURE__ */ import_react12.default.createElement("path", { d: "M15 13v2" }), /* @__PURE__ */ import_react12.default.createElement("path", { d: "M9 13v2" }))), /* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-agent-suggestion__text" }, /* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-agent-suggestion__label" }, "Suggested: ", agentName), reason && /* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-agent-suggestion__reason" }, reason))), /* @__PURE__ */ import_react12.default.createElement(
|
|
4190
4693
|
Button,
|
|
4191
4694
|
{
|
|
4192
4695
|
variant: "default",
|
|
@@ -4195,23 +4698,22 @@ ${followOnPrompt}`;
|
|
|
4195
4698
|
onClick: () => {
|
|
4196
4699
|
onAgentChange(agentId);
|
|
4197
4700
|
setTimeout(() => {
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
}, 50);
|
|
4701
|
+
scrollToBottom();
|
|
4702
|
+
}, 100);
|
|
4201
4703
|
}
|
|
4202
4704
|
},
|
|
4203
4705
|
"Switch"
|
|
4204
4706
|
));
|
|
4205
|
-
}
|
|
4206
|
-
const markdownComponents = (0,
|
|
4707
|
+
});
|
|
4708
|
+
const markdownComponents = (0, import_react12.useMemo)(() => ({
|
|
4207
4709
|
code: CodeBlock,
|
|
4208
|
-
"agent-suggestion": (
|
|
4209
|
-
var _b =
|
|
4710
|
+
"agent-suggestion": (_a2) => {
|
|
4711
|
+
var _b = _a2, { node } = _b, props = __objRest(_b, ["node"]);
|
|
4210
4712
|
const agentId = props["data-agent-id"];
|
|
4211
4713
|
const agentName = props["data-agent-name"];
|
|
4212
4714
|
const reason = props["data-reason"];
|
|
4213
4715
|
if (!agentId) return null;
|
|
4214
|
-
return /* @__PURE__ */
|
|
4716
|
+
return /* @__PURE__ */ import_react12.default.createElement(
|
|
4215
4717
|
AgentSuggestionCard,
|
|
4216
4718
|
{
|
|
4217
4719
|
agentId,
|
|
@@ -4221,135 +4723,358 @@ ${followOnPrompt}`;
|
|
|
4221
4723
|
);
|
|
4222
4724
|
}
|
|
4223
4725
|
}), [CodeBlock, AgentSuggestionCard]);
|
|
4224
|
-
const renderThinkingBlocks = (0,
|
|
4726
|
+
const renderThinkingBlocks = (0, import_react12.useCallback)(() => {
|
|
4225
4727
|
if (thinkingBlocks.length === 0) return null;
|
|
4226
4728
|
const currentBlock = thinkingBlocks[currentThinkingIndex];
|
|
4227
4729
|
if (!currentBlock) return null;
|
|
4228
4730
|
const isReasoning = currentBlock.type === "reasoning";
|
|
4229
|
-
const icon = isReasoning ? /* @__PURE__ */
|
|
4731
|
+
const icon = isReasoning ? /* @__PURE__ */ import_react12.default.createElement(BrainIcon, null) : /* @__PURE__ */ import_react12.default.createElement(SearchIcon, null);
|
|
4230
4732
|
const title2 = isReasoning ? "Reasoning" : "Searching";
|
|
4231
|
-
return /* @__PURE__ */
|
|
4733
|
+
return /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-thinking" }, /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-thinking__header" }, /* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-thinking__icon" }, icon), /* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-thinking__title" }, title2), thinkingBlocks.length > 1 && /* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-thinking__nav" }, /* @__PURE__ */ import_react12.default.createElement(
|
|
4232
4734
|
"button",
|
|
4233
4735
|
{
|
|
4234
4736
|
onClick: () => setCurrentThinkingIndex(Math.max(0, currentThinkingIndex - 1)),
|
|
4235
4737
|
disabled: currentThinkingIndex === 0
|
|
4236
4738
|
},
|
|
4237
4739
|
"\u2039"
|
|
4238
|
-
), /* @__PURE__ */
|
|
4740
|
+
), /* @__PURE__ */ import_react12.default.createElement("span", null, currentThinkingIndex + 1, " / ", thinkingBlocks.length), /* @__PURE__ */ import_react12.default.createElement(
|
|
4239
4741
|
"button",
|
|
4240
4742
|
{
|
|
4241
4743
|
onClick: () => setCurrentThinkingIndex(Math.min(thinkingBlocks.length - 1, currentThinkingIndex + 1)),
|
|
4242
4744
|
disabled: currentThinkingIndex === thinkingBlocks.length - 1
|
|
4243
4745
|
},
|
|
4244
4746
|
"\u203A"
|
|
4245
|
-
))), /* @__PURE__ */
|
|
4747
|
+
))), /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-thinking__content" }, cleanContentForDisplay(currentBlock.content)));
|
|
4246
4748
|
}, [thinkingBlocks, currentThinkingIndex, cleanContentForDisplay]);
|
|
4247
4749
|
const panelClasses = ["ai-chat-panel", theme === "dark" ? "dark-theme" : ""].filter(Boolean).join(" ");
|
|
4248
|
-
return /* @__PURE__ */
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4750
|
+
return /* @__PURE__ */ import_react12.default.createElement(
|
|
4751
|
+
"div",
|
|
4752
|
+
{
|
|
4753
|
+
className: panelClasses,
|
|
4754
|
+
style: __spreadValues(__spreadValues({}, width && { width }), height && { height })
|
|
4755
|
+
},
|
|
4756
|
+
title && /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-panel__title" }, title),
|
|
4757
|
+
error && /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-error-banner" }, /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-error-banner__icon" }, /* @__PURE__ */ import_react12.default.createElement(AlertCircleIcon, null)), /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-error-banner__content" }, /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-error-banner__message" }, error.message), error.code === "413" && /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-error-banner__hint" }, "Try starting a new conversation or reducing the amount of information being sent.")), /* @__PURE__ */ import_react12.default.createElement(
|
|
4758
|
+
"button",
|
|
4759
|
+
{
|
|
4760
|
+
className: "ai-chat-error-banner__close",
|
|
4761
|
+
onClick: () => setError(null),
|
|
4762
|
+
"aria-label": "Dismiss error"
|
|
4763
|
+
},
|
|
4764
|
+
/* @__PURE__ */ import_react12.default.createElement(CloseIcon, null)
|
|
4765
|
+
)),
|
|
4766
|
+
/* @__PURE__ */ import_react12.default.createElement(ScrollArea, { className: "ai-chat-panel__messages", ref: responseAreaRef }, initialMessage && /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-message ai-chat-message--assistant" }, /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-message__content" }, markdownClass ? /* @__PURE__ */ import_react12.default.createElement("div", { className: markdownClass }, /* @__PURE__ */ import_react12.default.createElement(
|
|
4254
4767
|
import_react_markdown2.default,
|
|
4255
4768
|
{
|
|
4256
4769
|
remarkPlugins: [import_remark_gfm2.default],
|
|
4257
|
-
rehypePlugins: [import_rehype_raw2.default]
|
|
4258
|
-
components: markdownComponents
|
|
4770
|
+
rehypePlugins: [import_rehype_raw2.default]
|
|
4259
4771
|
},
|
|
4260
|
-
|
|
4261
|
-
)
|
|
4772
|
+
initialMessage
|
|
4773
|
+
)) : /* @__PURE__ */ import_react12.default.createElement(
|
|
4262
4774
|
import_react_markdown2.default,
|
|
4263
4775
|
{
|
|
4264
4776
|
remarkPlugins: [import_remark_gfm2.default],
|
|
4265
|
-
rehypePlugins: [import_rehype_raw2.default]
|
|
4266
|
-
components: markdownComponents
|
|
4777
|
+
rehypePlugins: [import_rehype_raw2.default]
|
|
4267
4778
|
},
|
|
4268
|
-
|
|
4269
|
-
))),
|
|
4779
|
+
initialMessage
|
|
4780
|
+
))), Object.entries(history).map(([prompt, entry], index, entries) => {
|
|
4781
|
+
const isLastEntry = index === entries.length - 1;
|
|
4782
|
+
const isSystemMessage = prompt.startsWith("__system__:");
|
|
4783
|
+
const { cleanedText } = processThinkingTags(entry.content);
|
|
4784
|
+
const processedContent = processActions(cleanedText);
|
|
4785
|
+
return /* @__PURE__ */ import_react12.default.createElement("div", { key: index, className: "ai-chat-entry" }, !(hideInitialPrompt && index === 0) && !isSystemMessage && /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-message ai-chat-message--user" }, /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-message__content" }, formatPromptForDisplay(prompt))), /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-message ai-chat-message--assistant" }, /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-message__content" }, isLastEntry && (isLoading || !idle) && !justReset ? /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-streaming" }, thinkingBlocks.length > 0 && renderThinkingBlocks(), processedContent ? markdownClass ? /* @__PURE__ */ import_react12.default.createElement("div", { className: markdownClass }, /* @__PURE__ */ import_react12.default.createElement(
|
|
4786
|
+
import_react_markdown2.default,
|
|
4787
|
+
{
|
|
4788
|
+
remarkPlugins: [import_remark_gfm2.default],
|
|
4789
|
+
rehypePlugins: [import_rehype_raw2.default],
|
|
4790
|
+
components: markdownComponents
|
|
4791
|
+
},
|
|
4792
|
+
processedContent
|
|
4793
|
+
)) : /* @__PURE__ */ import_react12.default.createElement(
|
|
4794
|
+
import_react_markdown2.default,
|
|
4795
|
+
{
|
|
4796
|
+
remarkPlugins: [import_remark_gfm2.default],
|
|
4797
|
+
rehypePlugins: [import_rehype_raw2.default],
|
|
4798
|
+
components: markdownComponents
|
|
4799
|
+
},
|
|
4800
|
+
processedContent
|
|
4801
|
+
) : /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-loading" }, /* @__PURE__ */ import_react12.default.createElement("span", null, "Thinking"), /* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-loading__dots" }, /* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-loading__dot" }), /* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-loading__dot" }), /* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-loading__dot" })))) : /* @__PURE__ */ import_react12.default.createElement(import_react12.default.Fragment, null, isLastEntry && thinkingBlocks.length > 0 && renderThinkingBlocks(), markdownClass ? /* @__PURE__ */ import_react12.default.createElement("div", { className: markdownClass }, /* @__PURE__ */ import_react12.default.createElement(
|
|
4802
|
+
import_react_markdown2.default,
|
|
4803
|
+
{
|
|
4804
|
+
remarkPlugins: [import_remark_gfm2.default],
|
|
4805
|
+
rehypePlugins: [import_rehype_raw2.default],
|
|
4806
|
+
components: markdownComponents
|
|
4807
|
+
},
|
|
4808
|
+
processedContent
|
|
4809
|
+
)) : /* @__PURE__ */ import_react12.default.createElement(
|
|
4810
|
+
import_react_markdown2.default,
|
|
4811
|
+
{
|
|
4812
|
+
remarkPlugins: [import_remark_gfm2.default],
|
|
4813
|
+
rehypePlugins: [import_rehype_raw2.default],
|
|
4814
|
+
components: markdownComponents
|
|
4815
|
+
},
|
|
4816
|
+
processedContent
|
|
4817
|
+
))), (!isLastEntry || !isLoading) && /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-message__actions" }, /* @__PURE__ */ import_react12.default.createElement(
|
|
4818
|
+
"button",
|
|
4819
|
+
{
|
|
4820
|
+
className: "ai-chat-action-button",
|
|
4821
|
+
onClick: () => copyToClipboard(entry.content, entry.callId),
|
|
4822
|
+
title: copiedCallId === entry.callId ? "Copied!" : "Copy"
|
|
4823
|
+
},
|
|
4824
|
+
copiedCallId === entry.callId ? /* @__PURE__ */ import_react12.default.createElement("span", { style: { fontSize: "11px", fontWeight: 500 } }, "Copied!") : /* @__PURE__ */ import_react12.default.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__ */ import_react12.default.createElement("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2", ry: "2" }), /* @__PURE__ */ import_react12.default.createElement("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" }))
|
|
4825
|
+
), /* @__PURE__ */ import_react12.default.createElement(
|
|
4826
|
+
"button",
|
|
4827
|
+
{
|
|
4828
|
+
className: "ai-chat-action-button",
|
|
4829
|
+
onClick: () => handleThumbsUp(entry.callId),
|
|
4830
|
+
title: (feedbackCallId == null ? void 0 : feedbackCallId.callId) === entry.callId && (feedbackCallId == null ? void 0 : feedbackCallId.type) === "up" ? "Thanks!" : "Good response",
|
|
4831
|
+
style: (feedbackCallId == null ? void 0 : feedbackCallId.callId) === entry.callId && (feedbackCallId == null ? void 0 : feedbackCallId.type) === "up" ? { color: "#22c55e" } : void 0
|
|
4832
|
+
},
|
|
4833
|
+
(feedbackCallId == null ? void 0 : feedbackCallId.callId) === entry.callId && (feedbackCallId == null ? void 0 : feedbackCallId.type) === "up" ? /* @__PURE__ */ import_react12.default.createElement("span", { style: { fontSize: "11px", fontWeight: 500 } }, "Thanks!") : /* @__PURE__ */ import_react12.default.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__ */ import_react12.default.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" }))
|
|
4834
|
+
), /* @__PURE__ */ import_react12.default.createElement(
|
|
4835
|
+
"button",
|
|
4836
|
+
{
|
|
4837
|
+
className: "ai-chat-action-button",
|
|
4838
|
+
onClick: () => handleThumbsDown(entry.callId),
|
|
4839
|
+
title: (feedbackCallId == null ? void 0 : feedbackCallId.callId) === entry.callId && (feedbackCallId == null ? void 0 : feedbackCallId.type) === "down" ? "Thanks!" : "Poor response",
|
|
4840
|
+
style: (feedbackCallId == null ? void 0 : feedbackCallId.callId) === entry.callId && (feedbackCallId == null ? void 0 : feedbackCallId.type) === "down" ? { color: "#ef4444" } : void 0
|
|
4841
|
+
},
|
|
4842
|
+
(feedbackCallId == null ? void 0 : feedbackCallId.callId) === entry.callId && (feedbackCallId == null ? void 0 : feedbackCallId.type) === "down" ? /* @__PURE__ */ import_react12.default.createElement("span", { style: { fontSize: "11px", fontWeight: 500 } }, "Thanks!") : /* @__PURE__ */ import_react12.default.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__ */ import_react12.default.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" }))
|
|
4843
|
+
), (entry.toolCalls || entry.toolResponses) && /* @__PURE__ */ import_react12.default.createElement(
|
|
4844
|
+
"button",
|
|
4845
|
+
{
|
|
4846
|
+
className: "ai-chat-action-button",
|
|
4847
|
+
onClick: () => {
|
|
4848
|
+
setToolInfoData({
|
|
4849
|
+
calls: entry.toolCalls || [],
|
|
4850
|
+
responses: entry.toolResponses || []
|
|
4851
|
+
});
|
|
4852
|
+
setIsToolInfoModalOpen(true);
|
|
4853
|
+
},
|
|
4854
|
+
title: "View tool information"
|
|
4855
|
+
},
|
|
4856
|
+
/* @__PURE__ */ import_react12.default.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__ */ import_react12.default.createElement("circle", { cx: "12", cy: "12", r: "10" }), /* @__PURE__ */ import_react12.default.createElement("line", { x1: "12", x2: "12", y1: "16", y2: "12" }), /* @__PURE__ */ import_react12.default.createElement("line", { x1: "12", x2: "12.01", y1: "8", y2: "8" }))
|
|
4857
|
+
))));
|
|
4858
|
+
}), followOnQuestionsState.length > 0 && idle && !isLoading && /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-suggestions" }, followOnQuestionsState.map((question, index) => /* @__PURE__ */ import_react12.default.createElement(
|
|
4270
4859
|
Button,
|
|
4271
4860
|
{
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4861
|
+
key: index,
|
|
4862
|
+
variant: "outline",
|
|
4863
|
+
size: "sm",
|
|
4864
|
+
onClick: () => handleSuggestionClick(question),
|
|
4865
|
+
className: "ai-chat-suggestions__button"
|
|
4275
4866
|
},
|
|
4276
|
-
|
|
4277
|
-
)),
|
|
4867
|
+
question
|
|
4868
|
+
))), /* @__PURE__ */ import_react12.default.createElement("div", { ref: bottomRef })),
|
|
4869
|
+
pendingToolRequests.length > 0 && /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-approve-tools-panel" }, /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-approve-tools-header" }, "Tool Approval Required"), /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-approve-tools-description" }, "The AI wants to use the following tools:"), getUniqueToolNames().map((toolName) => /* @__PURE__ */ import_react12.default.createElement("div", { key: toolName, className: "ai-chat-approve-tool-item" }, /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-approve-tool-name" }, toolName), /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-approve-tools-buttons" }, /* @__PURE__ */ import_react12.default.createElement(
|
|
4278
4870
|
Button,
|
|
4279
4871
|
{
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4872
|
+
size: "sm",
|
|
4873
|
+
variant: "outline",
|
|
4874
|
+
className: "ai-chat-approve-tools-button",
|
|
4875
|
+
onClick: () => handleToolApproval(toolName, "once")
|
|
4283
4876
|
},
|
|
4284
|
-
|
|
4285
|
-
)
|
|
4877
|
+
"Once"
|
|
4878
|
+
), /* @__PURE__ */ import_react12.default.createElement(
|
|
4286
4879
|
Button,
|
|
4287
4880
|
{
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4881
|
+
size: "sm",
|
|
4882
|
+
variant: "outline",
|
|
4883
|
+
className: "ai-chat-approve-tools-button",
|
|
4884
|
+
onClick: () => handleToolApproval(toolName, "session")
|
|
4291
4885
|
},
|
|
4292
|
-
|
|
4293
|
-
)
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4886
|
+
"This Session"
|
|
4887
|
+
), /* @__PURE__ */ import_react12.default.createElement(
|
|
4888
|
+
Button,
|
|
4889
|
+
{
|
|
4890
|
+
size: "sm",
|
|
4891
|
+
variant: "default",
|
|
4892
|
+
className: "ai-chat-approve-tools-button",
|
|
4893
|
+
onClick: () => handleToolApproval(toolName, "always")
|
|
4894
|
+
},
|
|
4895
|
+
"Always"
|
|
4896
|
+
))))),
|
|
4897
|
+
(showSaveButton || showEmailButton || showCallToAction) && /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-button-container" }, showSaveButton && /* @__PURE__ */ import_react12.default.createElement(
|
|
4898
|
+
Button,
|
|
4899
|
+
{
|
|
4900
|
+
variant: "outline",
|
|
4901
|
+
size: "sm",
|
|
4902
|
+
onClick: saveAsHTMLFile,
|
|
4903
|
+
disabled: Object.keys(history).length === 0,
|
|
4904
|
+
className: "ai-chat-save-button"
|
|
4905
|
+
},
|
|
4906
|
+
"\u{1F4BE} Save"
|
|
4907
|
+
), showEmailButton && /* @__PURE__ */ import_react12.default.createElement(
|
|
4908
|
+
Button,
|
|
4909
|
+
{
|
|
4910
|
+
variant: "outline",
|
|
4911
|
+
size: "sm",
|
|
4912
|
+
onClick: () => {
|
|
4913
|
+
if (isEmailAddress(emailInput)) {
|
|
4914
|
+
setEmailInputSet(true);
|
|
4915
|
+
setEmailValid(true);
|
|
4916
|
+
handleSendEmail(emailInput, emailInput);
|
|
4917
|
+
setEmailClickedButNoEmail(false);
|
|
4918
|
+
} else {
|
|
4919
|
+
setShowEmailPanel(true);
|
|
4920
|
+
setEmailValid(false);
|
|
4921
|
+
setEmailClickedButNoEmail(true);
|
|
4922
|
+
}
|
|
4923
|
+
},
|
|
4924
|
+
disabled: Object.keys(history).length === 0 || isDisabledDueToNoEmail(),
|
|
4925
|
+
className: "ai-chat-email-button"
|
|
4926
|
+
},
|
|
4927
|
+
"\u{1F4E7} Email Conversation",
|
|
4928
|
+
emailSent ? " \u2713" : ""
|
|
4929
|
+
), showCallToAction && /* @__PURE__ */ import_react12.default.createElement(
|
|
4930
|
+
Button,
|
|
4931
|
+
{
|
|
4932
|
+
variant: callToActionSent ? "outline" : "default",
|
|
4933
|
+
size: "sm",
|
|
4934
|
+
onClick: () => {
|
|
4935
|
+
if (customerEmailCaptureMode !== "HIDE" && !emailInputSet) {
|
|
4936
|
+
setCTAClickedButNoEmail(true);
|
|
4937
|
+
setTimeout(() => setCTAClickedButNoEmail(false), 3e3);
|
|
4938
|
+
return;
|
|
4939
|
+
}
|
|
4940
|
+
const fromEmail = emailInput || (customer == null ? void 0 : customer.customer_user_email) || "";
|
|
4941
|
+
sendCallToActionEmail(fromEmail);
|
|
4942
|
+
},
|
|
4943
|
+
disabled: callToActionSent || Object.keys(history).length === 0,
|
|
4944
|
+
className: "ai-chat-cta-button"
|
|
4945
|
+
},
|
|
4946
|
+
callToActionSent ? "\u2713 Submitted" : callToActionButtonText
|
|
4947
|
+
)),
|
|
4948
|
+
showNewConversationButton && /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-panel__new-conversation" }, /* @__PURE__ */ import_react12.default.createElement(
|
|
4949
|
+
Button,
|
|
4950
|
+
{
|
|
4951
|
+
variant: newConversationConfirm ? "destructive" : "outline",
|
|
4952
|
+
size: "sm",
|
|
4953
|
+
onClick: handleNewConversation,
|
|
4954
|
+
className: "ai-chat-new-conversation"
|
|
4955
|
+
},
|
|
4956
|
+
newConversationConfirm ? "Click to Confirm" : "New Conversation"
|
|
4957
|
+
)),
|
|
4958
|
+
showEmailPanel && /* @__PURE__ */ import_react12.default.createElement(import_react12.default.Fragment, null, !emailValid && /* @__PURE__ */ import_react12.default.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__ */ import_react12.default.createElement("div", { className: "ai-chat-email-input-container" }, /* @__PURE__ */ import_react12.default.createElement(
|
|
4959
|
+
"input",
|
|
4960
|
+
{
|
|
4961
|
+
type: "email",
|
|
4962
|
+
name: "email",
|
|
4963
|
+
id: "email",
|
|
4964
|
+
className: emailValid ? emailInputSet ? "ai-chat-email-input-set" : "ai-chat-email-input" : "ai-chat-email-input-invalid",
|
|
4965
|
+
placeholder: customerEmailCapturePlaceholder,
|
|
4966
|
+
value: emailInput,
|
|
4967
|
+
onChange: (e) => {
|
|
4968
|
+
const newEmail = e.target.value;
|
|
4969
|
+
setEmailInput(newEmail);
|
|
4970
|
+
if (!emailInputSet) {
|
|
4971
|
+
if (customerEmailCaptureMode === "REQUIRED" && newEmail !== "") {
|
|
4972
|
+
setEmailValid(isEmailAddress(newEmail));
|
|
4973
|
+
} else {
|
|
4974
|
+
setEmailValid(true);
|
|
4975
|
+
}
|
|
4976
|
+
}
|
|
4977
|
+
},
|
|
4978
|
+
onBlur: () => {
|
|
4979
|
+
if (emailInput && isEmailAddress(emailInput) && !emailInputSet) {
|
|
4980
|
+
setEmailInputSet(true);
|
|
4981
|
+
setEmailValid(true);
|
|
4982
|
+
interactionClicked("", "emailcapture", emailInput);
|
|
4983
|
+
if (CTAClickedButNoEmail) {
|
|
4984
|
+
sendCallToActionEmail(emailInput);
|
|
4985
|
+
setCTAClickedButNoEmail(false);
|
|
4986
|
+
}
|
|
4987
|
+
if (emailClickedButNoEmail) {
|
|
4988
|
+
handleSendEmail(emailInput, emailInput);
|
|
4989
|
+
setEmailClickedButNoEmail(false);
|
|
4990
|
+
}
|
|
4991
|
+
} else if (customerEmailCaptureMode === "REQUIRED" && emailInput !== "") {
|
|
4992
|
+
setEmailValid(isEmailAddress(emailInput));
|
|
4993
|
+
}
|
|
4994
|
+
},
|
|
4995
|
+
onKeyDown: (e) => {
|
|
4996
|
+
if (e.key === "Enter") {
|
|
4997
|
+
if (isEmailAddress(emailInput)) {
|
|
4998
|
+
setEmailInputSet(true);
|
|
4999
|
+
setEmailValid(true);
|
|
5000
|
+
interactionClicked("", "emailcapture", emailInput);
|
|
5001
|
+
if (CTAClickedButNoEmail) {
|
|
5002
|
+
sendCallToActionEmail(emailInput);
|
|
5003
|
+
setCTAClickedButNoEmail(false);
|
|
5004
|
+
}
|
|
5005
|
+
if (emailClickedButNoEmail) {
|
|
5006
|
+
handleSendEmail(emailInput, emailInput);
|
|
5007
|
+
setEmailClickedButNoEmail(false);
|
|
5008
|
+
}
|
|
5009
|
+
} else {
|
|
5010
|
+
setEmailValid(false);
|
|
5011
|
+
}
|
|
5012
|
+
}
|
|
5013
|
+
},
|
|
5014
|
+
disabled: false
|
|
5015
|
+
}
|
|
5016
|
+
), emailInputSet && /* @__PURE__ */ import_react12.default.createElement(
|
|
5017
|
+
"button",
|
|
5018
|
+
{
|
|
5019
|
+
className: "ai-chat-email-edit-button",
|
|
5020
|
+
onClick: () => {
|
|
5021
|
+
setEmailInputSet(false);
|
|
5022
|
+
setEmailValid(true);
|
|
5023
|
+
},
|
|
5024
|
+
title: "Edit email"
|
|
5025
|
+
},
|
|
5026
|
+
"\u270E"
|
|
5027
|
+
))),
|
|
5028
|
+
/* @__PURE__ */ import_react12.default.createElement(
|
|
5029
|
+
ChatInput,
|
|
5030
|
+
{
|
|
5031
|
+
placeholder,
|
|
5032
|
+
idle,
|
|
5033
|
+
onSubmit: continueChat,
|
|
5034
|
+
onStop: handleStop,
|
|
5035
|
+
agentOptions,
|
|
5036
|
+
currentAgentId,
|
|
5037
|
+
onAgentChange,
|
|
5038
|
+
agentsLoading,
|
|
5039
|
+
currentAgentLabel: currentAgentLabel || void 0,
|
|
5040
|
+
currentAgentAvatarUrl: currentAgentAvatarUrl || void 0,
|
|
5041
|
+
contextSections,
|
|
5042
|
+
totalContextTokens,
|
|
5043
|
+
maxContextTokens,
|
|
5044
|
+
enableContextDetailView
|
|
5045
|
+
}
|
|
5046
|
+
),
|
|
5047
|
+
showPoweredBy && /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-panel__footer" }, mcpServers && mcpServers.length > 0 && /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-tools-status" }, /* @__PURE__ */ import_react12.default.createElement(
|
|
5048
|
+
"span",
|
|
5049
|
+
{
|
|
5050
|
+
className: `ai-chat-tools-status__dot ${toolsLoading ? "loading" : toolsFetchError ? "error" : "ready"}`
|
|
5051
|
+
}
|
|
5052
|
+
), /* @__PURE__ */ import_react12.default.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__ */ import_react12.default.createElement("div", { className: "ai-chat-powered-by" }, /* @__PURE__ */ import_react12.default.createElement("span", null, "brought to you by"), /* @__PURE__ */ import_react12.default.createElement("a", { href: "https://llmasaservice.io", target: "_blank", rel: "noopener noreferrer" }, /* @__PURE__ */ import_react12.default.createElement(LLMAsAServiceLogo, null), /* @__PURE__ */ import_react12.default.createElement("span", null, "llmasaservice.io")))),
|
|
5053
|
+
/* @__PURE__ */ import_react12.default.createElement(
|
|
5054
|
+
ToolInfoModal_default2,
|
|
5055
|
+
{
|
|
5056
|
+
isOpen: isToolInfoModalOpen,
|
|
5057
|
+
onClose: () => setIsToolInfoModalOpen(false),
|
|
5058
|
+
data: toolInfoData
|
|
5059
|
+
}
|
|
5060
|
+
)
|
|
5061
|
+
);
|
|
4337
5062
|
};
|
|
4338
|
-
var AIChatPanel_default =
|
|
5063
|
+
var AIChatPanel_default = import_react12.default.memo(AIChatPanel);
|
|
4339
5064
|
|
|
4340
5065
|
// src/hooks/useAgentRegistry.ts
|
|
4341
|
-
var
|
|
5066
|
+
var import_react13 = require("react");
|
|
4342
5067
|
var resolveApiEndpoint = (baseUrl, agentId) => {
|
|
4343
5068
|
return `https://api.llmasaservice.io/agents/${agentId}`;
|
|
4344
5069
|
};
|
|
4345
5070
|
function useAgentRegistry(agentIds, options = {}) {
|
|
4346
5071
|
const { url = "https://chat.llmasaservice.io", autoFetch = true, localOverrides = {} } = options;
|
|
4347
|
-
const [state, setState] = (0,
|
|
5072
|
+
const [state, setState] = (0, import_react13.useState)({
|
|
4348
5073
|
agents: {},
|
|
4349
5074
|
isLoading: false,
|
|
4350
5075
|
error: null
|
|
4351
5076
|
});
|
|
4352
|
-
const fetchAgentMetadata = (0,
|
|
5077
|
+
const fetchAgentMetadata = (0, import_react13.useCallback)(
|
|
4353
5078
|
(agentId, signal) => __async(this, null, function* () {
|
|
4354
5079
|
const endpoint = resolveApiEndpoint(url, agentId);
|
|
4355
5080
|
try {
|
|
@@ -4400,7 +5125,7 @@ function useAgentRegistry(agentIds, options = {}) {
|
|
|
4400
5125
|
}),
|
|
4401
5126
|
[url]
|
|
4402
5127
|
);
|
|
4403
|
-
const fetchAllAgents = (0,
|
|
5128
|
+
const fetchAllAgents = (0, import_react13.useCallback)(() => __async(this, null, function* () {
|
|
4404
5129
|
if (agentIds.length === 0) return;
|
|
4405
5130
|
setState((prev) => __spreadProps(__spreadValues({}, prev), { isLoading: true, error: null }));
|
|
4406
5131
|
const controller = new AbortController();
|
|
@@ -4427,7 +5152,7 @@ function useAgentRegistry(agentIds, options = {}) {
|
|
|
4427
5152
|
});
|
|
4428
5153
|
return () => controller.abort();
|
|
4429
5154
|
}), [agentIds, fetchAgentMetadata]);
|
|
4430
|
-
(0,
|
|
5155
|
+
(0, import_react13.useEffect)(() => {
|
|
4431
5156
|
if (!autoFetch) return;
|
|
4432
5157
|
const abortController = new AbortController();
|
|
4433
5158
|
const agentsToFetch = agentIds.filter(
|
|
@@ -4437,20 +5162,20 @@ function useAgentRegistry(agentIds, options = {}) {
|
|
|
4437
5162
|
fetchAllAgents();
|
|
4438
5163
|
return () => abortController.abort();
|
|
4439
5164
|
}, [agentIds.join(","), autoFetch]);
|
|
4440
|
-
const getAgent = (0,
|
|
5165
|
+
const getAgent = (0, import_react13.useCallback)(
|
|
4441
5166
|
(agentId) => {
|
|
4442
5167
|
return state.agents[agentId];
|
|
4443
5168
|
},
|
|
4444
5169
|
[state.agents]
|
|
4445
5170
|
);
|
|
4446
|
-
const isAgentReady = (0,
|
|
5171
|
+
const isAgentReady = (0, import_react13.useCallback)(
|
|
4447
5172
|
(agentId) => {
|
|
4448
5173
|
var _a;
|
|
4449
5174
|
return ((_a = state.agents[agentId]) == null ? void 0 : _a.status) === "ready";
|
|
4450
5175
|
},
|
|
4451
5176
|
[state.agents]
|
|
4452
5177
|
);
|
|
4453
|
-
const buildAgentAwarenessInstructions = (0,
|
|
5178
|
+
const buildAgentAwarenessInstructions = (0, import_react13.useCallback)(
|
|
4454
5179
|
(currentAgentId) => {
|
|
4455
5180
|
const otherAgents = agentIds.filter((id) => id !== currentAgentId).map((id) => {
|
|
4456
5181
|
const profile = state.agents[id];
|
|
@@ -4482,13 +5207,13 @@ Example: "I think ${(exampleAgent == null ? void 0 : exampleAgent.name) || "anot
|
|
|
4482
5207
|
},
|
|
4483
5208
|
[agentIds, state.agents, localOverrides]
|
|
4484
5209
|
);
|
|
4485
|
-
const readyAgents = (0,
|
|
5210
|
+
const readyAgents = (0, import_react13.useMemo)(() => {
|
|
4486
5211
|
return agentIds.filter((id) => {
|
|
4487
5212
|
var _a;
|
|
4488
5213
|
return ((_a = state.agents[id]) == null ? void 0 : _a.status) === "ready";
|
|
4489
5214
|
});
|
|
4490
5215
|
}, [agentIds, state.agents]);
|
|
4491
|
-
const agentList = (0,
|
|
5216
|
+
const agentList = (0, import_react13.useMemo)(() => {
|
|
4492
5217
|
return agentIds.map((id) => {
|
|
4493
5218
|
const profile = state.agents[id];
|
|
4494
5219
|
const metadata = profile == null ? void 0 : profile.metadata;
|
|
@@ -4537,15 +5262,15 @@ function extractAgentNameFromMessage(message) {
|
|
|
4537
5262
|
}
|
|
4538
5263
|
|
|
4539
5264
|
// src/AIAgentPanel.tsx
|
|
4540
|
-
var SearchIcon2 = () => /* @__PURE__ */
|
|
4541
|
-
var PlusIcon = () => /* @__PURE__ */
|
|
4542
|
-
var ChevronLeftIcon = () => /* @__PURE__ */
|
|
4543
|
-
var ChevronRightIcon = () => /* @__PURE__ */
|
|
4544
|
-
var MessageIcon = () => /* @__PURE__ */
|
|
4545
|
-
var
|
|
4546
|
-
var LoadingDotIcon = () => /* @__PURE__ */
|
|
4547
|
-
var SidebarIcon = () => /* @__PURE__ */
|
|
4548
|
-
var SparkleIcon = () => /* @__PURE__ */
|
|
5265
|
+
var SearchIcon2 = () => /* @__PURE__ */ import_react14.default.createElement("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ import_react14.default.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" }));
|
|
5266
|
+
var PlusIcon = () => /* @__PURE__ */ import_react14.default.createElement("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ import_react14.default.createElement("path", { d: "M8 3.333v9.334M3.333 8h9.334", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }));
|
|
5267
|
+
var ChevronLeftIcon = () => /* @__PURE__ */ import_react14.default.createElement("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ import_react14.default.createElement("path", { d: "M10 12L6 8l4-4", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }));
|
|
5268
|
+
var ChevronRightIcon = () => /* @__PURE__ */ import_react14.default.createElement("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ import_react14.default.createElement("path", { d: "M6 12l4-4-4-4", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }));
|
|
5269
|
+
var MessageIcon = () => /* @__PURE__ */ import_react14.default.createElement("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ import_react14.default.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" }));
|
|
5270
|
+
var CloseIcon2 = () => /* @__PURE__ */ import_react14.default.createElement("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ import_react14.default.createElement("path", { d: "M9 3L3 9M3 3l6 6", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }));
|
|
5271
|
+
var LoadingDotIcon = () => /* @__PURE__ */ import_react14.default.createElement("span", { className: "ai-agent-panel__loading-dot" });
|
|
5272
|
+
var SidebarIcon = () => /* @__PURE__ */ import_react14.default.createElement("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ import_react14.default.createElement("rect", { x: "2", y: "2", width: "12", height: "12", rx: "2", stroke: "currentColor", strokeWidth: "1.5" }), /* @__PURE__ */ import_react14.default.createElement("path", { d: "M6 2v12", stroke: "currentColor", strokeWidth: "1.5" }));
|
|
5273
|
+
var SparkleIcon = () => /* @__PURE__ */ import_react14.default.createElement("svg", { width: "14", height: "14", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ import_react14.default.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__ */ import_react14.default.createElement("circle", { cx: "8", cy: "8", r: "2", fill: "currentColor" }));
|
|
4549
5274
|
var normalizeConversationListPayload = (payload) => {
|
|
4550
5275
|
if (!payload) return [];
|
|
4551
5276
|
const conversations = Array.isArray(payload) ? payload : payload.conversations || [];
|
|
@@ -4668,25 +5393,41 @@ var ChatPanelWrapper = ({
|
|
|
4668
5393
|
maxContextTokens,
|
|
4669
5394
|
enableContextDetailView,
|
|
4670
5395
|
onConversationCreated,
|
|
4671
|
-
conversationInitialPrompt
|
|
5396
|
+
conversationInitialPrompt,
|
|
5397
|
+
// New props from ChatPanel port
|
|
5398
|
+
cssUrl,
|
|
5399
|
+
markdownClass,
|
|
5400
|
+
width,
|
|
5401
|
+
height,
|
|
5402
|
+
scrollToEnd,
|
|
5403
|
+
prismStyle,
|
|
5404
|
+
showSaveButton,
|
|
5405
|
+
showEmailButton,
|
|
5406
|
+
messages,
|
|
5407
|
+
showCallToAction,
|
|
5408
|
+
callToActionButtonText,
|
|
5409
|
+
callToActionEmailAddress,
|
|
5410
|
+
callToActionEmailSubject,
|
|
5411
|
+
customerEmailCaptureMode,
|
|
5412
|
+
customerEmailCapturePlaceholder
|
|
4672
5413
|
}) => {
|
|
4673
|
-
var _a, _b;
|
|
5414
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
4674
5415
|
const convAgentProfile = getAgent(activeConv.agentId);
|
|
4675
5416
|
const convAgentMetadata = convAgentProfile == null ? void 0 : convAgentProfile.metadata;
|
|
4676
5417
|
const isVisible = currentConversationId === activeConv.conversationId;
|
|
4677
|
-
const historyCallback = (0,
|
|
5418
|
+
const historyCallback = (0, import_react14.useCallback)(
|
|
4678
5419
|
(history) => {
|
|
4679
5420
|
handleHistoryChanged(history, activeConv.conversationId);
|
|
4680
5421
|
},
|
|
4681
5422
|
[handleHistoryChanged, activeConv.conversationId]
|
|
4682
5423
|
);
|
|
4683
|
-
const loadingCallback = (0,
|
|
5424
|
+
const loadingCallback = (0, import_react14.useCallback)(
|
|
4684
5425
|
(loading) => {
|
|
4685
5426
|
handleLoadingChange(loading, activeConv.conversationId);
|
|
4686
5427
|
},
|
|
4687
5428
|
[handleLoadingChange, activeConv.conversationId]
|
|
4688
5429
|
);
|
|
4689
|
-
const conversationCreatedCallback = (0,
|
|
5430
|
+
const conversationCreatedCallback = (0, import_react14.useCallback)(
|
|
4690
5431
|
(realConversationId) => {
|
|
4691
5432
|
onConversationCreated(activeConv.conversationId, realConversationId);
|
|
4692
5433
|
},
|
|
@@ -4701,18 +5442,18 @@ var ChatPanelWrapper = ({
|
|
|
4701
5442
|
const prompts = promptsString ? promptsString.split("|").filter((p) => p.trim()) : [];
|
|
4702
5443
|
effectiveFollowOnQuestions = [...prompts];
|
|
4703
5444
|
}
|
|
4704
|
-
const mcpServers = (0,
|
|
5445
|
+
const mcpServers = (0, import_react14.useMemo)(() => {
|
|
4705
5446
|
return (convAgentProfile == null ? void 0 : convAgentProfile.mcpServers) || EMPTY_ARRAY;
|
|
4706
5447
|
}, [convAgentProfile == null ? void 0 : convAgentProfile.mcpServers]);
|
|
4707
5448
|
const effectiveInitialPrompt = conversationInitialPrompt || initialPrompt;
|
|
4708
5449
|
if (!convAgentMetadata) return null;
|
|
4709
|
-
return /* @__PURE__ */
|
|
5450
|
+
return /* @__PURE__ */ import_react14.default.createElement(
|
|
4710
5451
|
"div",
|
|
4711
5452
|
{
|
|
4712
5453
|
className: "ai-agent-panel__chat-wrapper",
|
|
4713
5454
|
style: { display: isVisible ? "flex" : "none" }
|
|
4714
5455
|
},
|
|
4715
|
-
/* @__PURE__ */
|
|
5456
|
+
/* @__PURE__ */ import_react14.default.createElement(
|
|
4716
5457
|
AIChatPanel_default,
|
|
4717
5458
|
{
|
|
4718
5459
|
project_id: convAgentMetadata.projectId,
|
|
@@ -4737,7 +5478,7 @@ var ChatPanelWrapper = ({
|
|
|
4737
5478
|
customer: effectiveCustomer,
|
|
4738
5479
|
showPoweredBy,
|
|
4739
5480
|
showNewConversationButton: false,
|
|
4740
|
-
createConversationOnFirstChat: (_b =
|
|
5481
|
+
createConversationOnFirstChat: (_b = convAgentProfile == null ? void 0 : convAgentProfile.createConversationOnFirstChat) != null ? _b : true,
|
|
4741
5482
|
mcpServers,
|
|
4742
5483
|
actions,
|
|
4743
5484
|
followOnQuestions: effectiveFollowOnQuestions,
|
|
@@ -4752,13 +5493,28 @@ var ChatPanelWrapper = ({
|
|
|
4752
5493
|
totalContextTokens,
|
|
4753
5494
|
maxContextTokens,
|
|
4754
5495
|
enableContextDetailView,
|
|
4755
|
-
onConversationCreated: conversationCreatedCallback
|
|
5496
|
+
onConversationCreated: conversationCreatedCallback,
|
|
5497
|
+
cssUrl,
|
|
5498
|
+
markdownClass,
|
|
5499
|
+
width,
|
|
5500
|
+
height,
|
|
5501
|
+
scrollToEnd: scrollToEnd != null ? scrollToEnd : convAgentMetadata.displayAutoScroll,
|
|
5502
|
+
prismStyle,
|
|
5503
|
+
showSaveButton: (_c = showSaveButton != null ? showSaveButton : convAgentMetadata.displayShowSaveButton) != null ? _c : true,
|
|
5504
|
+
showEmailButton: (_d = showEmailButton != null ? showEmailButton : convAgentMetadata.displayShowEmailButton) != null ? _d : true,
|
|
5505
|
+
messages,
|
|
5506
|
+
showCallToAction: (_e = showCallToAction != null ? showCallToAction : convAgentMetadata.displayShowCallToAction) != null ? _e : false,
|
|
5507
|
+
callToActionButtonText: (_f = callToActionButtonText != null ? callToActionButtonText : convAgentMetadata.displayCallToActionButtonText) != null ? _f : "Submit",
|
|
5508
|
+
callToActionEmailAddress: (_g = callToActionEmailAddress != null ? callToActionEmailAddress : convAgentMetadata.displayCallToActionEmailAddress) != null ? _g : "",
|
|
5509
|
+
callToActionEmailSubject: (_h = callToActionEmailSubject != null ? callToActionEmailSubject : convAgentMetadata.displayCallToActionEmailSubject) != null ? _h : "Agent CTA submitted",
|
|
5510
|
+
customerEmailCaptureMode: (_i = customerEmailCaptureMode != null ? customerEmailCaptureMode : convAgentMetadata == null ? void 0 : convAgentMetadata.customerEmailCaptureMode) != null ? _i : "HIDE",
|
|
5511
|
+
customerEmailCapturePlaceholder: (_j = customerEmailCapturePlaceholder != null ? customerEmailCapturePlaceholder : convAgentMetadata == null ? void 0 : convAgentMetadata.customerEmailCapturePlaceholder) != null ? _j : "Please enter your email..."
|
|
4756
5512
|
}
|
|
4757
5513
|
)
|
|
4758
5514
|
);
|
|
4759
5515
|
};
|
|
4760
5516
|
ChatPanelWrapper.displayName = "ChatPanelWrapper";
|
|
4761
|
-
var AIAgentPanel =
|
|
5517
|
+
var AIAgentPanel = import_react14.default.forwardRef(({
|
|
4762
5518
|
agents,
|
|
4763
5519
|
defaultAgent,
|
|
4764
5520
|
customerId,
|
|
@@ -4797,37 +5553,53 @@ var AIAgentPanel = import_react13.default.forwardRef(({
|
|
|
4797
5553
|
followOnQuestions = [],
|
|
4798
5554
|
followOnPrompt = "",
|
|
4799
5555
|
historyListLimit = 50,
|
|
4800
|
-
showConversationHistory = true
|
|
5556
|
+
showConversationHistory = true,
|
|
5557
|
+
// New props from ChatPanel port
|
|
5558
|
+
cssUrl,
|
|
5559
|
+
markdownClass,
|
|
5560
|
+
width,
|
|
5561
|
+
height,
|
|
5562
|
+
scrollToEnd,
|
|
5563
|
+
prismStyle,
|
|
5564
|
+
showSaveButton,
|
|
5565
|
+
showEmailButton,
|
|
5566
|
+
messages,
|
|
5567
|
+
showCallToAction,
|
|
5568
|
+
callToActionButtonText,
|
|
5569
|
+
callToActionEmailAddress,
|
|
5570
|
+
callToActionEmailSubject,
|
|
5571
|
+
customerEmailCaptureMode,
|
|
5572
|
+
customerEmailCapturePlaceholder
|
|
4801
5573
|
}, ref) => {
|
|
4802
5574
|
var _a, _b, _c, _d;
|
|
4803
|
-
const [isCollapsed, setIsCollapsed] = (0,
|
|
4804
|
-
const [isHistoryCollapsed, setIsHistoryCollapsed] = (0,
|
|
5575
|
+
const [isCollapsed, setIsCollapsed] = (0, import_react14.useState)(collapsible && defaultCollapsed);
|
|
5576
|
+
const [isHistoryCollapsed, setIsHistoryCollapsed] = (0, import_react14.useState)(() => {
|
|
4805
5577
|
if (typeof window !== "undefined") {
|
|
4806
5578
|
const saved = localStorage.getItem("ai-agent-panel-history-collapsed");
|
|
4807
5579
|
return saved === "true";
|
|
4808
5580
|
}
|
|
4809
5581
|
return false;
|
|
4810
5582
|
});
|
|
4811
|
-
const [panelWidth, setPanelWidth] = (0,
|
|
5583
|
+
const [panelWidth, setPanelWidth] = (0, import_react14.useState)(() => {
|
|
4812
5584
|
if (typeof window !== "undefined") {
|
|
4813
5585
|
const savedWidth = localStorage.getItem("ai-agent-panel-width");
|
|
4814
5586
|
if (savedWidth) {
|
|
4815
|
-
const
|
|
4816
|
-
if (
|
|
4817
|
-
return
|
|
5587
|
+
const width2 = parseInt(savedWidth, 10);
|
|
5588
|
+
if (width2 >= minWidth && width2 <= maxWidth) {
|
|
5589
|
+
return width2;
|
|
4818
5590
|
}
|
|
4819
5591
|
}
|
|
4820
5592
|
}
|
|
4821
5593
|
return defaultWidth;
|
|
4822
5594
|
});
|
|
4823
|
-
const [isResizing, setIsResizing] = (0,
|
|
4824
|
-
const [showSearch, setShowSearch] = (0,
|
|
4825
|
-
const [showHandoffDialog, setShowHandoffDialog] = (0,
|
|
4826
|
-
const [suggestedAgent, setSuggestedAgent] = (0,
|
|
4827
|
-
const [handoffSource, setHandoffSource] = (0,
|
|
4828
|
-
const panelRef = (0,
|
|
4829
|
-
const resizeRef = (0,
|
|
4830
|
-
const { agentIds, localOverrides } = (0,
|
|
5595
|
+
const [isResizing, setIsResizing] = (0, import_react14.useState)(false);
|
|
5596
|
+
const [showSearch, setShowSearch] = (0, import_react14.useState)(false);
|
|
5597
|
+
const [showHandoffDialog, setShowHandoffDialog] = (0, import_react14.useState)(false);
|
|
5598
|
+
const [suggestedAgent, setSuggestedAgent] = (0, import_react14.useState)(null);
|
|
5599
|
+
const [handoffSource, setHandoffSource] = (0, import_react14.useState)("agent");
|
|
5600
|
+
const panelRef = (0, import_react14.useRef)(null);
|
|
5601
|
+
const resizeRef = (0, import_react14.useRef)(null);
|
|
5602
|
+
const { agentIds, localOverrides } = (0, import_react14.useMemo)(() => {
|
|
4831
5603
|
const ids = [];
|
|
4832
5604
|
const overrides = {};
|
|
4833
5605
|
for (const agent of agents) {
|
|
@@ -4845,19 +5617,19 @@ var AIAgentPanel = import_react13.default.forwardRef(({
|
|
|
4845
5617
|
}
|
|
4846
5618
|
return { agentIds: ids, localOverrides: overrides };
|
|
4847
5619
|
}, [agents]);
|
|
4848
|
-
const [currentAgentId, setCurrentAgentId] = (0,
|
|
5620
|
+
const [currentAgentId, setCurrentAgentId] = (0, import_react14.useState)(
|
|
4849
5621
|
defaultAgent || agentIds[0] || ""
|
|
4850
5622
|
);
|
|
4851
|
-
const [apiConversations, setApiConversations] = (0,
|
|
4852
|
-
const [conversationsLoading, setConversationsLoading] = (0,
|
|
4853
|
-
const [conversationsError, setConversationsError] = (0,
|
|
4854
|
-
const [searchQuery, setSearchQuery] = (0,
|
|
4855
|
-
const [activeConversations, setActiveConversations] = (0,
|
|
4856
|
-
const [currentConversationId, setCurrentConversationId] = (0,
|
|
4857
|
-
const [conversationFirstPrompts, setConversationFirstPrompts] = (0,
|
|
4858
|
-
const [loadingPrompts, setLoadingPrompts] = (0,
|
|
4859
|
-
const [loadingConversationId, setLoadingConversationId] = (0,
|
|
4860
|
-
const [expandedSections, setExpandedSections] = (0,
|
|
5623
|
+
const [apiConversations, setApiConversations] = (0, import_react14.useState)([]);
|
|
5624
|
+
const [conversationsLoading, setConversationsLoading] = (0, import_react14.useState)(false);
|
|
5625
|
+
const [conversationsError, setConversationsError] = (0, import_react14.useState)(null);
|
|
5626
|
+
const [searchQuery, setSearchQuery] = (0, import_react14.useState)("");
|
|
5627
|
+
const [activeConversations, setActiveConversations] = (0, import_react14.useState)(/* @__PURE__ */ new Map());
|
|
5628
|
+
const [currentConversationId, setCurrentConversationId] = (0, import_react14.useState)(conversation || null);
|
|
5629
|
+
const [conversationFirstPrompts, setConversationFirstPrompts] = (0, import_react14.useState)({});
|
|
5630
|
+
const [loadingPrompts, setLoadingPrompts] = (0, import_react14.useState)(/* @__PURE__ */ new Set());
|
|
5631
|
+
const [loadingConversationId, setLoadingConversationId] = (0, import_react14.useState)(null);
|
|
5632
|
+
const [expandedSections, setExpandedSections] = (0, import_react14.useState)({
|
|
4861
5633
|
"Today": true,
|
|
4862
5634
|
"Yesterday": true,
|
|
4863
5635
|
"This Week": false,
|
|
@@ -4871,16 +5643,16 @@ var AIAgentPanel = import_react13.default.forwardRef(({
|
|
|
4871
5643
|
buildAgentAwarenessInstructions,
|
|
4872
5644
|
agentList
|
|
4873
5645
|
} = useAgentRegistry(agentIds, { url, localOverrides });
|
|
4874
|
-
const fetchInProgressRef = (0,
|
|
4875
|
-
const lastFetchedAgentRef = (0,
|
|
4876
|
-
const checkedPromptsRef = (0,
|
|
4877
|
-
const fetchingPromptsRef = (0,
|
|
4878
|
-
const failedPromptsRef = (0,
|
|
4879
|
-
const activeConversationsRef = (0,
|
|
5646
|
+
const fetchInProgressRef = (0, import_react14.useRef)(false);
|
|
5647
|
+
const lastFetchedAgentRef = (0, import_react14.useRef)(null);
|
|
5648
|
+
const checkedPromptsRef = (0, import_react14.useRef)(/* @__PURE__ */ new Set());
|
|
5649
|
+
const fetchingPromptsRef = (0, import_react14.useRef)(/* @__PURE__ */ new Set());
|
|
5650
|
+
const failedPromptsRef = (0, import_react14.useRef)(/* @__PURE__ */ new Map());
|
|
5651
|
+
const activeConversationsRef = (0, import_react14.useRef)(activeConversations);
|
|
4880
5652
|
activeConversationsRef.current = activeConversations;
|
|
4881
|
-
const currentConversationIdRef = (0,
|
|
5653
|
+
const currentConversationIdRef = (0, import_react14.useRef)(currentConversationId);
|
|
4882
5654
|
currentConversationIdRef.current = currentConversationId;
|
|
4883
|
-
|
|
5655
|
+
import_react14.default.useImperativeHandle(ref, () => ({
|
|
4884
5656
|
startNewConversation: (prompt, agent) => {
|
|
4885
5657
|
const targetAgent = agent || currentAgentId;
|
|
4886
5658
|
const tempId = `new-${Date.now()}`;
|
|
@@ -4903,11 +5675,11 @@ var AIAgentPanel = import_react13.default.forwardRef(({
|
|
|
4903
5675
|
}
|
|
4904
5676
|
}
|
|
4905
5677
|
}), [currentAgentId, onConversationChange]);
|
|
4906
|
-
const [showContextNotification, setShowContextNotification] = (0,
|
|
4907
|
-
const prevContextRef = (0,
|
|
4908
|
-
const contextNotificationTimeoutRef = (0,
|
|
4909
|
-
const prevDefaultAgentRef = (0,
|
|
4910
|
-
const fetchFirstPrompt = (0,
|
|
5678
|
+
const [showContextNotification, setShowContextNotification] = (0, import_react14.useState)(false);
|
|
5679
|
+
const prevContextRef = (0, import_react14.useRef)(null);
|
|
5680
|
+
const contextNotificationTimeoutRef = (0, import_react14.useRef)(null);
|
|
5681
|
+
const prevDefaultAgentRef = (0, import_react14.useRef)(null);
|
|
5682
|
+
const fetchFirstPrompt = (0, import_react14.useCallback)((conversationId, agentIdForConversation) => __async(void 0, null, function* () {
|
|
4911
5683
|
var _a2, _b2;
|
|
4912
5684
|
if (checkedPromptsRef.current.has(conversationId)) {
|
|
4913
5685
|
return;
|
|
@@ -4993,7 +5765,7 @@ var AIAgentPanel = import_react13.default.forwardRef(({
|
|
|
4993
5765
|
});
|
|
4994
5766
|
}
|
|
4995
5767
|
}), [apiKey, currentAgentId, getAgent]);
|
|
4996
|
-
const fetchConversations = (0,
|
|
5768
|
+
const fetchConversations = (0, import_react14.useCallback)((agentId, signal) => __async(void 0, null, function* () {
|
|
4997
5769
|
var _a2;
|
|
4998
5770
|
const agentProfile = getAgent(agentId);
|
|
4999
5771
|
const projectId = (_a2 = agentProfile == null ? void 0 : agentProfile.metadata) == null ? void 0 : _a2.projectId;
|
|
@@ -5049,7 +5821,7 @@ var AIAgentPanel = import_react13.default.forwardRef(({
|
|
|
5049
5821
|
}
|
|
5050
5822
|
}
|
|
5051
5823
|
}), [apiKey, customerId, getAgent, fetchFirstPrompt]);
|
|
5052
|
-
const stripContextFromPrompt = (0,
|
|
5824
|
+
const stripContextFromPrompt = (0, import_react14.useCallback)((prompt) => {
|
|
5053
5825
|
let cleanPrompt = prompt;
|
|
5054
5826
|
const contextIndex = cleanPrompt.indexOf("---context---");
|
|
5055
5827
|
if (contextIndex !== -1) {
|
|
@@ -5065,7 +5837,7 @@ var AIAgentPanel = import_react13.default.forwardRef(({
|
|
|
5065
5837
|
}
|
|
5066
5838
|
return cleanPrompt.trim();
|
|
5067
5839
|
}, []);
|
|
5068
|
-
const loadConversationTranscript = (0,
|
|
5840
|
+
const loadConversationTranscript = (0, import_react14.useCallback)((conversationId, agentIdForConversation, title) => __async(void 0, null, function* () {
|
|
5069
5841
|
var _a2;
|
|
5070
5842
|
const existingActive = activeConversationsRef.current.get(conversationId);
|
|
5071
5843
|
if (existingActive) {
|
|
@@ -5149,10 +5921,10 @@ var AIAgentPanel = import_react13.default.forwardRef(({
|
|
|
5149
5921
|
setLoadingConversationId(null);
|
|
5150
5922
|
}
|
|
5151
5923
|
}), [apiKey, currentAgentId, getAgent, onConversationChange, stripContextFromPrompt]);
|
|
5152
|
-
const handleRefreshConversations = (0,
|
|
5924
|
+
const handleRefreshConversations = (0, import_react14.useCallback)(() => {
|
|
5153
5925
|
fetchConversations(currentAgentId);
|
|
5154
5926
|
}, [currentAgentId, fetchConversations]);
|
|
5155
|
-
(0,
|
|
5927
|
+
(0, import_react14.useEffect)(() => {
|
|
5156
5928
|
var _a2;
|
|
5157
5929
|
if (!showConversationHistory) return;
|
|
5158
5930
|
if (!agentsLoading && currentAgentId && apiKey) {
|
|
@@ -5164,7 +5936,7 @@ var AIAgentPanel = import_react13.default.forwardRef(({
|
|
|
5164
5936
|
}
|
|
5165
5937
|
}
|
|
5166
5938
|
}, [agentsLoading, currentAgentId, apiKey, fetchConversations, getAgent, showConversationHistory]);
|
|
5167
|
-
const handleNewConversation = (0,
|
|
5939
|
+
const handleNewConversation = (0, import_react14.useCallback)(() => {
|
|
5168
5940
|
const tempId = `new-${Date.now()}`;
|
|
5169
5941
|
setActiveConversations((prev) => {
|
|
5170
5942
|
const next = new Map(prev);
|
|
@@ -5181,7 +5953,7 @@ var AIAgentPanel = import_react13.default.forwardRef(({
|
|
|
5181
5953
|
});
|
|
5182
5954
|
setCurrentConversationId(tempId);
|
|
5183
5955
|
}, [currentAgentId]);
|
|
5184
|
-
(0,
|
|
5956
|
+
(0, import_react14.useEffect)(() => {
|
|
5185
5957
|
var _a2;
|
|
5186
5958
|
const agentProfile = getAgent(currentAgentId);
|
|
5187
5959
|
const isAgentReady = (_a2 = agentProfile == null ? void 0 : agentProfile.metadata) == null ? void 0 : _a2.projectId;
|
|
@@ -5189,7 +5961,7 @@ var AIAgentPanel = import_react13.default.forwardRef(({
|
|
|
5189
5961
|
handleNewConversation();
|
|
5190
5962
|
}
|
|
5191
5963
|
}, [currentAgentId, agentsLoading, activeConversations.size, getAgent, handleNewConversation]);
|
|
5192
|
-
const handleCloseConversation = (0,
|
|
5964
|
+
const handleCloseConversation = (0, import_react14.useCallback)((conversationId, e) => {
|
|
5193
5965
|
var _a2;
|
|
5194
5966
|
if (e) {
|
|
5195
5967
|
e.stopPropagation();
|
|
@@ -5205,10 +5977,10 @@ var AIAgentPanel = import_react13.default.forwardRef(({
|
|
|
5205
5977
|
setCurrentConversationId(nextId);
|
|
5206
5978
|
}
|
|
5207
5979
|
}, []);
|
|
5208
|
-
const handleSelectConversation = (0,
|
|
5980
|
+
const handleSelectConversation = (0, import_react14.useCallback)((conversationId) => {
|
|
5209
5981
|
loadConversationTranscript(conversationId);
|
|
5210
5982
|
}, [loadConversationTranscript]);
|
|
5211
|
-
const toggleSection = (0,
|
|
5983
|
+
const toggleSection = (0, import_react14.useCallback)((sectionLabel) => {
|
|
5212
5984
|
setExpandedSections((prev) => {
|
|
5213
5985
|
const isExpanding = !prev[sectionLabel];
|
|
5214
5986
|
if (isExpanding) {
|
|
@@ -5242,7 +6014,7 @@ var AIAgentPanel = import_react13.default.forwardRef(({
|
|
|
5242
6014
|
});
|
|
5243
6015
|
});
|
|
5244
6016
|
}, [apiConversations, fetchFirstPrompt]);
|
|
5245
|
-
const groupedConversations = (0,
|
|
6017
|
+
const groupedConversations = (0, import_react14.useMemo)(() => {
|
|
5246
6018
|
let filtered = apiConversations;
|
|
5247
6019
|
if (searchQuery) {
|
|
5248
6020
|
const query = searchQuery.toLowerCase();
|
|
@@ -5257,12 +6029,12 @@ var AIAgentPanel = import_react13.default.forwardRef(({
|
|
|
5257
6029
|
}
|
|
5258
6030
|
return groupConversationsByTime(filtered, true);
|
|
5259
6031
|
}, [apiConversations, searchQuery, conversationFirstPrompts]);
|
|
5260
|
-
const effectiveCustomer = (0,
|
|
6032
|
+
const effectiveCustomer = (0, import_react14.useMemo)(() => {
|
|
5261
6033
|
return __spreadProps(__spreadValues({}, customer), {
|
|
5262
6034
|
customer_id: customerId
|
|
5263
6035
|
});
|
|
5264
6036
|
}, [customer, customerId]);
|
|
5265
|
-
const handleResizeStart = (0,
|
|
6037
|
+
const handleResizeStart = (0, import_react14.useCallback)((e) => {
|
|
5266
6038
|
e.preventDefault();
|
|
5267
6039
|
setIsResizing(true);
|
|
5268
6040
|
let currentWidth = panelWidth;
|
|
@@ -5282,18 +6054,18 @@ var AIAgentPanel = import_react13.default.forwardRef(({
|
|
|
5282
6054
|
document.addEventListener("mousemove", handleMouseMove);
|
|
5283
6055
|
document.addEventListener("mouseup", handleMouseUp);
|
|
5284
6056
|
}, [panelWidth, minWidth, maxWidth, position]);
|
|
5285
|
-
const currentAgentProfile = (0,
|
|
6057
|
+
const currentAgentProfile = (0, import_react14.useMemo)(() => {
|
|
5286
6058
|
return getAgent(currentAgentId);
|
|
5287
6059
|
}, [currentAgentId, getAgent]);
|
|
5288
6060
|
const currentAgentMetadata = currentAgentProfile == null ? void 0 : currentAgentProfile.metadata;
|
|
5289
|
-
const currentActiveConversation = (0,
|
|
6061
|
+
const currentActiveConversation = (0, import_react14.useMemo)(() => {
|
|
5290
6062
|
if (!currentConversationId) return null;
|
|
5291
6063
|
return activeConversations.get(currentConversationId) || null;
|
|
5292
6064
|
}, [currentConversationId, activeConversations]);
|
|
5293
|
-
const activeConversationsList = (0,
|
|
6065
|
+
const activeConversationsList = (0, import_react14.useMemo)(() => {
|
|
5294
6066
|
return Array.from(activeConversations.values());
|
|
5295
6067
|
}, [activeConversations]);
|
|
5296
|
-
const agentOptions = (0,
|
|
6068
|
+
const agentOptions = (0, import_react14.useMemo)(() => {
|
|
5297
6069
|
return agentList.map((agent) => ({
|
|
5298
6070
|
value: agent.id,
|
|
5299
6071
|
label: agent.name,
|
|
@@ -5301,7 +6073,7 @@ var AIAgentPanel = import_react13.default.forwardRef(({
|
|
|
5301
6073
|
avatarUrl: agent.avatarUrl
|
|
5302
6074
|
}));
|
|
5303
6075
|
}, [agentList]);
|
|
5304
|
-
const mergedContext = (0,
|
|
6076
|
+
const mergedContext = (0, import_react14.useMemo)(() => {
|
|
5305
6077
|
const sections = [
|
|
5306
6078
|
...sharedContextSections,
|
|
5307
6079
|
...pageContextSections,
|
|
@@ -5323,7 +6095,7 @@ var AIAgentPanel = import_react13.default.forwardRef(({
|
|
|
5323
6095
|
totalTokens
|
|
5324
6096
|
};
|
|
5325
6097
|
}, [context, sharedContextSections, pageContextSections, contextDataSources]);
|
|
5326
|
-
(0,
|
|
6098
|
+
(0, import_react14.useEffect)(() => {
|
|
5327
6099
|
const contextString = JSON.stringify(mergedContext.sections.map((s) => ({ id: s.id, data: s.data })));
|
|
5328
6100
|
if (prevContextRef.current === null) {
|
|
5329
6101
|
prevContextRef.current = contextString;
|
|
@@ -5343,14 +6115,14 @@ var AIAgentPanel = import_react13.default.forwardRef(({
|
|
|
5343
6115
|
}, 3e3);
|
|
5344
6116
|
}
|
|
5345
6117
|
}, [mergedContext.sections]);
|
|
5346
|
-
(0,
|
|
6118
|
+
(0, import_react14.useEffect)(() => {
|
|
5347
6119
|
return () => {
|
|
5348
6120
|
if (contextNotificationTimeoutRef.current) {
|
|
5349
6121
|
clearTimeout(contextNotificationTimeoutRef.current);
|
|
5350
6122
|
}
|
|
5351
6123
|
};
|
|
5352
6124
|
}, []);
|
|
5353
|
-
(0,
|
|
6125
|
+
(0, import_react14.useEffect)(() => {
|
|
5354
6126
|
var _a2, _b2;
|
|
5355
6127
|
let foundDefaultAgent = null;
|
|
5356
6128
|
for (const section of pageContextSections) {
|
|
@@ -5397,7 +6169,7 @@ var AIAgentPanel = import_react13.default.forwardRef(({
|
|
|
5397
6169
|
});
|
|
5398
6170
|
}
|
|
5399
6171
|
}, [pageContextSections, currentAgentId, agentIds, getAgent, localOverrides]);
|
|
5400
|
-
const chatPanelData = (0,
|
|
6172
|
+
const chatPanelData = (0, import_react14.useMemo)(() => {
|
|
5401
6173
|
const contextData = mergedContext.sections.map((section) => ({
|
|
5402
6174
|
key: section.id,
|
|
5403
6175
|
data: JSON.stringify(section.data)
|
|
@@ -5413,7 +6185,7 @@ var AIAgentPanel = import_react13.default.forwardRef(({
|
|
|
5413
6185
|
}
|
|
5414
6186
|
return [...data, ...contextData];
|
|
5415
6187
|
}, [data, mergedContext.sections, buildAgentAwarenessInstructions, currentAgentId, enableAgentSuggestions]);
|
|
5416
|
-
const handleAgentSwitch = (0,
|
|
6188
|
+
const handleAgentSwitch = (0, import_react14.useCallback)(
|
|
5417
6189
|
(newAgentId) => {
|
|
5418
6190
|
const oldAgentId = currentAgentId;
|
|
5419
6191
|
setCurrentAgentId(newAgentId);
|
|
@@ -5436,7 +6208,7 @@ var AIAgentPanel = import_react13.default.forwardRef(({
|
|
|
5436
6208
|
},
|
|
5437
6209
|
[currentAgentId, onAgentSwitch]
|
|
5438
6210
|
);
|
|
5439
|
-
const handleConversationSelect = (0,
|
|
6211
|
+
const handleConversationSelect = (0, import_react14.useCallback)(
|
|
5440
6212
|
(conv) => {
|
|
5441
6213
|
let agentIdToUse = conv.agentId || currentAgentId;
|
|
5442
6214
|
const targetAgent = getAgent(agentIdToUse);
|
|
@@ -5462,7 +6234,7 @@ var AIAgentPanel = import_react13.default.forwardRef(({
|
|
|
5462
6234
|
},
|
|
5463
6235
|
[currentAgentId, loadConversationTranscript, getAgent, agentList, conversationFirstPrompts]
|
|
5464
6236
|
);
|
|
5465
|
-
const handleHistoryChanged = (0,
|
|
6237
|
+
const handleHistoryChanged = (0, import_react14.useCallback)(
|
|
5466
6238
|
(history, conversationId) => {
|
|
5467
6239
|
const targetConversationId = conversationId || currentConversationIdRef.current;
|
|
5468
6240
|
if (targetConversationId) {
|
|
@@ -5514,7 +6286,7 @@ var AIAgentPanel = import_react13.default.forwardRef(({
|
|
|
5514
6286
|
agents
|
|
5515
6287
|
]
|
|
5516
6288
|
);
|
|
5517
|
-
const handleLoadingChange = (0,
|
|
6289
|
+
const handleLoadingChange = (0, import_react14.useCallback)((isLoading, conversationId) => {
|
|
5518
6290
|
const targetConversationId = conversationId || currentConversationIdRef.current;
|
|
5519
6291
|
if (targetConversationId) {
|
|
5520
6292
|
setActiveConversations((prev) => {
|
|
@@ -5530,7 +6302,7 @@ var AIAgentPanel = import_react13.default.forwardRef(({
|
|
|
5530
6302
|
});
|
|
5531
6303
|
}
|
|
5532
6304
|
}, []);
|
|
5533
|
-
const handleHandoffConfirm = (0,
|
|
6305
|
+
const handleHandoffConfirm = (0, import_react14.useCallback)(() => {
|
|
5534
6306
|
if (suggestedAgent) {
|
|
5535
6307
|
handleAgentSwitch(suggestedAgent);
|
|
5536
6308
|
}
|
|
@@ -5538,12 +6310,12 @@ var AIAgentPanel = import_react13.default.forwardRef(({
|
|
|
5538
6310
|
setSuggestedAgent(null);
|
|
5539
6311
|
setHandoffSource("agent");
|
|
5540
6312
|
}, [suggestedAgent, handleAgentSwitch]);
|
|
5541
|
-
const handleHandoffCancel = (0,
|
|
6313
|
+
const handleHandoffCancel = (0, import_react14.useCallback)(() => {
|
|
5542
6314
|
setShowHandoffDialog(false);
|
|
5543
6315
|
setSuggestedAgent(null);
|
|
5544
6316
|
setHandoffSource("agent");
|
|
5545
6317
|
}, []);
|
|
5546
|
-
const handleConversationCreated = (0,
|
|
6318
|
+
const handleConversationCreated = (0, import_react14.useCallback)((tempId, realId) => {
|
|
5547
6319
|
console.log("Conversation created:", tempId, "->", realId);
|
|
5548
6320
|
setActiveConversations((prev) => {
|
|
5549
6321
|
const existing = prev.get(tempId);
|
|
@@ -5564,11 +6336,11 @@ var AIAgentPanel = import_react13.default.forwardRef(({
|
|
|
5564
6336
|
}
|
|
5565
6337
|
}
|
|
5566
6338
|
}, [onConversationChange]);
|
|
5567
|
-
const toggleCollapse = (0,
|
|
6339
|
+
const toggleCollapse = (0, import_react14.useCallback)(() => {
|
|
5568
6340
|
if (!collapsible) return;
|
|
5569
6341
|
setIsCollapsed((prev) => !prev);
|
|
5570
6342
|
}, [collapsible]);
|
|
5571
|
-
const toggleHistoryCollapse = (0,
|
|
6343
|
+
const toggleHistoryCollapse = (0, import_react14.useCallback)(() => {
|
|
5572
6344
|
setIsHistoryCollapsed((prev) => {
|
|
5573
6345
|
const next = !prev;
|
|
5574
6346
|
localStorage.setItem("ai-agent-panel-history-collapsed", String(next));
|
|
@@ -5584,7 +6356,7 @@ var AIAgentPanel = import_react13.default.forwardRef(({
|
|
|
5584
6356
|
!showConversationHistory ? "ai-agent-panel--no-history" : ""
|
|
5585
6357
|
].filter(Boolean).join(" ");
|
|
5586
6358
|
if (collapsible && isCollapsed) {
|
|
5587
|
-
return /* @__PURE__ */
|
|
6359
|
+
return /* @__PURE__ */ import_react14.default.createElement("div", { className: panelClasses, ref: panelRef }, /* @__PURE__ */ import_react14.default.createElement(
|
|
5588
6360
|
"div",
|
|
5589
6361
|
{
|
|
5590
6362
|
className: "ai-agent-panel__collapsed-bar",
|
|
@@ -5595,9 +6367,9 @@ var AIAgentPanel = import_react13.default.forwardRef(({
|
|
|
5595
6367
|
},
|
|
5596
6368
|
title: "Click to expand"
|
|
5597
6369
|
},
|
|
5598
|
-
/* @__PURE__ */
|
|
5599
|
-
/* @__PURE__ */
|
|
5600
|
-
showConversationHistory && /* @__PURE__ */
|
|
6370
|
+
/* @__PURE__ */ import_react14.default.createElement(Tooltip, { content: "Expand Panel", side: "left" }, /* @__PURE__ */ import_react14.default.createElement(Button, { variant: "ghost", size: "icon", onClick: toggleCollapse }, position === "right" ? /* @__PURE__ */ import_react14.default.createElement(ChevronLeftIcon, null) : /* @__PURE__ */ import_react14.default.createElement(ChevronRightIcon, null))),
|
|
6371
|
+
/* @__PURE__ */ import_react14.default.createElement("div", { className: "ai-agent-panel__collapsed-divider" }),
|
|
6372
|
+
showConversationHistory && /* @__PURE__ */ import_react14.default.createElement(Tooltip, { content: "Search", side: "left" }, /* @__PURE__ */ import_react14.default.createElement(
|
|
5601
6373
|
Button,
|
|
5602
6374
|
{
|
|
5603
6375
|
variant: "ghost",
|
|
@@ -5607,9 +6379,9 @@ var AIAgentPanel = import_react13.default.forwardRef(({
|
|
|
5607
6379
|
setShowSearch(true);
|
|
5608
6380
|
}
|
|
5609
6381
|
},
|
|
5610
|
-
/* @__PURE__ */
|
|
6382
|
+
/* @__PURE__ */ import_react14.default.createElement(SearchIcon2, null)
|
|
5611
6383
|
)),
|
|
5612
|
-
/* @__PURE__ */
|
|
6384
|
+
/* @__PURE__ */ import_react14.default.createElement(Tooltip, { content: "New Chat", side: "left" }, /* @__PURE__ */ import_react14.default.createElement(
|
|
5613
6385
|
Button,
|
|
5614
6386
|
{
|
|
5615
6387
|
variant: "ghost",
|
|
@@ -5619,15 +6391,15 @@ var AIAgentPanel = import_react13.default.forwardRef(({
|
|
|
5619
6391
|
handleNewConversation();
|
|
5620
6392
|
}
|
|
5621
6393
|
},
|
|
5622
|
-
/* @__PURE__ */
|
|
6394
|
+
/* @__PURE__ */ import_react14.default.createElement(PlusIcon, null)
|
|
5623
6395
|
)),
|
|
5624
|
-
/* @__PURE__ */
|
|
6396
|
+
/* @__PURE__ */ import_react14.default.createElement("div", { className: "ai-agent-panel__collapsed-divider" }),
|
|
5625
6397
|
agentList.map((agent) => {
|
|
5626
6398
|
const activeConvForAgent = activeConversationsList.find(
|
|
5627
6399
|
(conv) => conv.agentId === agent.id
|
|
5628
6400
|
);
|
|
5629
6401
|
const hasActiveConversation = !!activeConvForAgent;
|
|
5630
|
-
return /* @__PURE__ */
|
|
6402
|
+
return /* @__PURE__ */ import_react14.default.createElement(Tooltip, { key: agent.id, content: agent.name, side: "left" }, /* @__PURE__ */ import_react14.default.createElement(
|
|
5631
6403
|
Button,
|
|
5632
6404
|
{
|
|
5633
6405
|
variant: agent.id === currentAgentId ? "secondary" : "ghost",
|
|
@@ -5661,7 +6433,7 @@ var AIAgentPanel = import_react13.default.forwardRef(({
|
|
|
5661
6433
|
},
|
|
5662
6434
|
className: `ai-agent-panel__agent-icon ${hasActiveConversation ? "ai-agent-panel__agent-icon--active" : ""}`
|
|
5663
6435
|
},
|
|
5664
|
-
agent.avatarUrl ? /* @__PURE__ */
|
|
6436
|
+
agent.avatarUrl ? /* @__PURE__ */ import_react14.default.createElement(
|
|
5665
6437
|
"img",
|
|
5666
6438
|
{
|
|
5667
6439
|
src: agent.avatarUrl,
|
|
@@ -5669,20 +6441,20 @@ var AIAgentPanel = import_react13.default.forwardRef(({
|
|
|
5669
6441
|
className: "ai-agent-panel__agent-avatar"
|
|
5670
6442
|
}
|
|
5671
6443
|
) : agent.name.charAt(0).toUpperCase(),
|
|
5672
|
-
hasActiveConversation && /* @__PURE__ */
|
|
6444
|
+
hasActiveConversation && /* @__PURE__ */ import_react14.default.createElement("span", { className: "ai-agent-panel__agent-active-indicator" })
|
|
5673
6445
|
));
|
|
5674
6446
|
}),
|
|
5675
|
-
/* @__PURE__ */
|
|
6447
|
+
/* @__PURE__ */ import_react14.default.createElement("div", { className: "ai-agent-panel__collapsed-spacer" })
|
|
5676
6448
|
));
|
|
5677
6449
|
}
|
|
5678
|
-
return /* @__PURE__ */
|
|
6450
|
+
return /* @__PURE__ */ import_react14.default.createElement(
|
|
5679
6451
|
"div",
|
|
5680
6452
|
{
|
|
5681
6453
|
className: panelClasses,
|
|
5682
6454
|
ref: panelRef,
|
|
5683
6455
|
style: { width: `${panelWidth}px` }
|
|
5684
6456
|
},
|
|
5685
|
-
/* @__PURE__ */
|
|
6457
|
+
/* @__PURE__ */ import_react14.default.createElement(
|
|
5686
6458
|
"div",
|
|
5687
6459
|
{
|
|
5688
6460
|
ref: resizeRef,
|
|
@@ -5694,9 +6466,9 @@ var AIAgentPanel = import_react13.default.forwardRef(({
|
|
|
5694
6466
|
tabIndex: 0
|
|
5695
6467
|
}
|
|
5696
6468
|
),
|
|
5697
|
-
showConversationHistory && /* @__PURE__ */
|
|
6469
|
+
showConversationHistory && /* @__PURE__ */ import_react14.default.createElement("div", { className: `ai-agent-panel__sidebar ${isHistoryCollapsed ? "ai-agent-panel__sidebar--collapsed" : ""}` }, isHistoryCollapsed ? (
|
|
5698
6470
|
// Collapsed history bar
|
|
5699
|
-
/* @__PURE__ */
|
|
6471
|
+
/* @__PURE__ */ import_react14.default.createElement(
|
|
5700
6472
|
"div",
|
|
5701
6473
|
{
|
|
5702
6474
|
className: "ai-agent-panel__history-collapsed-bar",
|
|
@@ -5707,32 +6479,32 @@ var AIAgentPanel = import_react13.default.forwardRef(({
|
|
|
5707
6479
|
},
|
|
5708
6480
|
title: "Click to expand history"
|
|
5709
6481
|
},
|
|
5710
|
-
/* @__PURE__ */
|
|
6482
|
+
/* @__PURE__ */ import_react14.default.createElement(Tooltip, { content: "Expand History", side: sidebarPosition === "left" ? "right" : "left" }, /* @__PURE__ */ import_react14.default.createElement(
|
|
5711
6483
|
Button,
|
|
5712
6484
|
{
|
|
5713
6485
|
variant: "ghost",
|
|
5714
6486
|
size: "icon",
|
|
5715
6487
|
onClick: toggleHistoryCollapse
|
|
5716
6488
|
},
|
|
5717
|
-
/* @__PURE__ */
|
|
6489
|
+
/* @__PURE__ */ import_react14.default.createElement(ChevronRightIcon, null)
|
|
5718
6490
|
)),
|
|
5719
|
-
/* @__PURE__ */
|
|
5720
|
-
/* @__PURE__ */
|
|
6491
|
+
/* @__PURE__ */ import_react14.default.createElement("div", { className: "ai-agent-panel__collapsed-divider" }),
|
|
6492
|
+
/* @__PURE__ */ import_react14.default.createElement(Tooltip, { content: "New Chat", side: sidebarPosition === "left" ? "right" : "left" }, /* @__PURE__ */ import_react14.default.createElement(
|
|
5721
6493
|
Button,
|
|
5722
6494
|
{
|
|
5723
6495
|
variant: "ghost",
|
|
5724
6496
|
size: "icon",
|
|
5725
6497
|
onClick: handleNewConversation
|
|
5726
6498
|
},
|
|
5727
|
-
/* @__PURE__ */
|
|
6499
|
+
/* @__PURE__ */ import_react14.default.createElement(PlusIcon, null)
|
|
5728
6500
|
)),
|
|
5729
|
-
/* @__PURE__ */
|
|
6501
|
+
/* @__PURE__ */ import_react14.default.createElement("div", { className: "ai-agent-panel__collapsed-divider" }),
|
|
5730
6502
|
agentList.map((agent) => {
|
|
5731
6503
|
const activeConvForAgent = activeConversationsList.find(
|
|
5732
6504
|
(conv) => conv.agentId === agent.id
|
|
5733
6505
|
);
|
|
5734
6506
|
const hasActiveConversation = !!activeConvForAgent;
|
|
5735
|
-
return /* @__PURE__ */
|
|
6507
|
+
return /* @__PURE__ */ import_react14.default.createElement(Tooltip, { key: agent.id, content: agent.name, side: sidebarPosition === "left" ? "right" : "left" }, /* @__PURE__ */ import_react14.default.createElement(
|
|
5736
6508
|
Button,
|
|
5737
6509
|
{
|
|
5738
6510
|
variant: agent.id === currentAgentId ? "secondary" : "ghost",
|
|
@@ -5765,7 +6537,7 @@ var AIAgentPanel = import_react13.default.forwardRef(({
|
|
|
5765
6537
|
},
|
|
5766
6538
|
className: `ai-agent-panel__agent-icon ${hasActiveConversation ? "ai-agent-panel__agent-icon--active" : ""}`
|
|
5767
6539
|
},
|
|
5768
|
-
agent.avatarUrl ? /* @__PURE__ */
|
|
6540
|
+
agent.avatarUrl ? /* @__PURE__ */ import_react14.default.createElement(
|
|
5769
6541
|
"img",
|
|
5770
6542
|
{
|
|
5771
6543
|
src: agent.avatarUrl,
|
|
@@ -5773,40 +6545,40 @@ var AIAgentPanel = import_react13.default.forwardRef(({
|
|
|
5773
6545
|
className: "ai-agent-panel__agent-avatar"
|
|
5774
6546
|
}
|
|
5775
6547
|
) : agent.name.charAt(0).toUpperCase(),
|
|
5776
|
-
hasActiveConversation && /* @__PURE__ */
|
|
6548
|
+
hasActiveConversation && /* @__PURE__ */ import_react14.default.createElement("span", { className: "ai-agent-panel__agent-active-indicator" })
|
|
5777
6549
|
));
|
|
5778
6550
|
}),
|
|
5779
|
-
/* @__PURE__ */
|
|
6551
|
+
/* @__PURE__ */ import_react14.default.createElement("div", { className: "ai-agent-panel__history-collapsed-spacer" })
|
|
5780
6552
|
)
|
|
5781
|
-
) : /* @__PURE__ */
|
|
6553
|
+
) : /* @__PURE__ */ import_react14.default.createElement(import_react14.default.Fragment, null, /* @__PURE__ */ import_react14.default.createElement("div", { className: "ai-agent-panel__header" }, /* @__PURE__ */ import_react14.default.createElement("div", { className: "ai-agent-panel__header-actions" }, showSearch ? /* @__PURE__ */ import_react14.default.createElement(
|
|
5782
6554
|
Input,
|
|
5783
6555
|
{
|
|
5784
6556
|
placeholder: "Search conversations...",
|
|
5785
6557
|
value: searchQuery,
|
|
5786
6558
|
onChange: (e) => setSearchQuery(e.target.value),
|
|
5787
|
-
icon: /* @__PURE__ */
|
|
6559
|
+
icon: /* @__PURE__ */ import_react14.default.createElement(SearchIcon2, null),
|
|
5788
6560
|
autoFocus: true,
|
|
5789
6561
|
onBlur: () => {
|
|
5790
6562
|
if (!searchQuery) setShowSearch(false);
|
|
5791
6563
|
}
|
|
5792
6564
|
}
|
|
5793
|
-
) : /* @__PURE__ */
|
|
6565
|
+
) : /* @__PURE__ */ import_react14.default.createElement(import_react14.default.Fragment, null, /* @__PURE__ */ import_react14.default.createElement(
|
|
5794
6566
|
Button,
|
|
5795
6567
|
{
|
|
5796
6568
|
variant: "ghost",
|
|
5797
6569
|
size: "icon",
|
|
5798
6570
|
onClick: () => setShowSearch(true)
|
|
5799
6571
|
},
|
|
5800
|
-
/* @__PURE__ */
|
|
5801
|
-
), /* @__PURE__ */
|
|
6572
|
+
/* @__PURE__ */ import_react14.default.createElement(SearchIcon2, null)
|
|
6573
|
+
), /* @__PURE__ */ import_react14.default.createElement(
|
|
5802
6574
|
Button,
|
|
5803
6575
|
{
|
|
5804
6576
|
variant: "ghost",
|
|
5805
6577
|
size: "icon",
|
|
5806
6578
|
onClick: handleNewConversation
|
|
5807
6579
|
},
|
|
5808
|
-
/* @__PURE__ */
|
|
5809
|
-
))), /* @__PURE__ */
|
|
6580
|
+
/* @__PURE__ */ import_react14.default.createElement(PlusIcon, null)
|
|
6581
|
+
))), /* @__PURE__ */ import_react14.default.createElement(Tooltip, { content: "Collapse History", side: "bottom" }, /* @__PURE__ */ import_react14.default.createElement(Button, { variant: "ghost", size: "icon", onClick: toggleHistoryCollapse }, /* @__PURE__ */ import_react14.default.createElement(SidebarIcon, null))), collapsible && /* @__PURE__ */ import_react14.default.createElement(Button, { variant: "ghost", size: "icon", onClick: toggleCollapse }, position === "right" ? /* @__PURE__ */ import_react14.default.createElement(ChevronRightIcon, null) : /* @__PURE__ */ import_react14.default.createElement(ChevronLeftIcon, null))), /* @__PURE__ */ import_react14.default.createElement(ScrollArea, { className: "ai-agent-panel__conversations" }, activeConversationsList.length > 0 && /* @__PURE__ */ import_react14.default.createElement("div", { className: "ai-agent-panel__group ai-agent-panel__group--active" }, /* @__PURE__ */ import_react14.default.createElement("div", { className: "ai-agent-panel__group-label" }, /* @__PURE__ */ import_react14.default.createElement("span", null, "Active (", activeConversationsList.length, ")")), activeConversationsList.map((activeConv) => /* @__PURE__ */ import_react14.default.createElement(
|
|
5810
6582
|
"div",
|
|
5811
6583
|
{
|
|
5812
6584
|
key: activeConv.stableKey,
|
|
@@ -5818,37 +6590,37 @@ var AIAgentPanel = import_react13.default.forwardRef(({
|
|
|
5818
6590
|
}
|
|
5819
6591
|
}
|
|
5820
6592
|
},
|
|
5821
|
-
/* @__PURE__ */
|
|
5822
|
-
/* @__PURE__ */
|
|
6593
|
+
/* @__PURE__ */ import_react14.default.createElement("div", { className: "ai-agent-panel__conversation-content" }, /* @__PURE__ */ import_react14.default.createElement("div", { className: "ai-agent-panel__conversation-title" }, activeConv.isLoading && /* @__PURE__ */ import_react14.default.createElement(LoadingDotIcon, null), /* @__PURE__ */ import_react14.default.createElement("span", null, activeConv.title))),
|
|
6594
|
+
/* @__PURE__ */ import_react14.default.createElement(
|
|
5823
6595
|
"button",
|
|
5824
6596
|
{
|
|
5825
6597
|
className: "ai-agent-panel__conversation-close",
|
|
5826
6598
|
onClick: (e) => handleCloseConversation(activeConv.conversationId, e),
|
|
5827
6599
|
title: "Close conversation"
|
|
5828
6600
|
},
|
|
5829
|
-
/* @__PURE__ */
|
|
6601
|
+
/* @__PURE__ */ import_react14.default.createElement(CloseIcon2, null)
|
|
5830
6602
|
)
|
|
5831
|
-
))), conversationsLoading ? /* @__PURE__ */
|
|
6603
|
+
))), conversationsLoading ? /* @__PURE__ */ import_react14.default.createElement("div", { className: "ai-agent-panel__loading" }, /* @__PURE__ */ import_react14.default.createElement("div", { className: "ai-agent-panel__loading-spinner" }), /* @__PURE__ */ import_react14.default.createElement("span", null, "Loading conversations...")) : conversationsError ? /* @__PURE__ */ import_react14.default.createElement("div", { className: "ai-agent-panel__empty" }, /* @__PURE__ */ import_react14.default.createElement("p", null, "Error: ", conversationsError), /* @__PURE__ */ import_react14.default.createElement(Button, { variant: "secondary", size: "sm", onClick: handleRefreshConversations }, "Retry")) : groupedConversations.length === 0 && activeConversationsList.length === 0 ? /* @__PURE__ */ import_react14.default.createElement("div", { className: "ai-agent-panel__empty" }, /* @__PURE__ */ import_react14.default.createElement(MessageIcon, null), /* @__PURE__ */ import_react14.default.createElement("p", null, "No conversations yet"), /* @__PURE__ */ import_react14.default.createElement("p", { className: "ai-agent-panel__empty-hint" }, "Start chatting to create your first conversation")) : /* @__PURE__ */ import_react14.default.createElement(import_react14.default.Fragment, null, activeConversationsList.length > 0 && groupedConversations.some((g) => g.count > 0) && /* @__PURE__ */ import_react14.default.createElement("div", { className: "ai-agent-panel__group-divider" }), groupedConversations.map((group) => /* @__PURE__ */ import_react14.default.createElement("div", { key: group.label, className: "ai-agent-panel__group" }, /* @__PURE__ */ import_react14.default.createElement(
|
|
5832
6604
|
"div",
|
|
5833
6605
|
{
|
|
5834
6606
|
className: "ai-agent-panel__group-label ai-agent-panel__group-label--clickable",
|
|
5835
6607
|
onClick: () => toggleSection(group.label)
|
|
5836
6608
|
},
|
|
5837
|
-
/* @__PURE__ */
|
|
5838
|
-
/* @__PURE__ */
|
|
6609
|
+
/* @__PURE__ */ import_react14.default.createElement("span", null, group.label, " ", group.count > 0 && `(${group.count})`),
|
|
6610
|
+
/* @__PURE__ */ import_react14.default.createElement("span", { className: "ai-agent-panel__group-chevron" }, expandedSections[group.label] ? "\u25BC" : "\u25B6")
|
|
5839
6611
|
), expandedSections[group.label] && group.conversations.length > 0 && group.conversations.map((conv) => {
|
|
5840
6612
|
const isActive = activeConversations.has(conv.conversationId);
|
|
5841
|
-
return /* @__PURE__ */
|
|
6613
|
+
return /* @__PURE__ */ import_react14.default.createElement(
|
|
5842
6614
|
"div",
|
|
5843
6615
|
{
|
|
5844
6616
|
key: conv.conversationId,
|
|
5845
6617
|
className: `ai-agent-panel__conversation ${currentConversationId === conv.conversationId ? "ai-agent-panel__conversation--current" : ""} ${isActive ? "ai-agent-panel__conversation--in-active" : ""}`,
|
|
5846
6618
|
onClick: () => handleConversationSelect(conv)
|
|
5847
6619
|
},
|
|
5848
|
-
/* @__PURE__ */
|
|
6620
|
+
/* @__PURE__ */ import_react14.default.createElement("div", { className: "ai-agent-panel__conversation-content" }, /* @__PURE__ */ import_react14.default.createElement("div", { className: "ai-agent-panel__conversation-title" }, isActive && /* @__PURE__ */ import_react14.default.createElement("span", { className: "ai-agent-panel__active-badge" }, "\u25CF"), conversationFirstPrompts[conv.conversationId] || conv.title))
|
|
5849
6621
|
);
|
|
5850
6622
|
}))))))),
|
|
5851
|
-
/* @__PURE__ */
|
|
6623
|
+
/* @__PURE__ */ import_react14.default.createElement("div", { className: "ai-agent-panel__chat" }, !showConversationHistory && collapsible && /* @__PURE__ */ import_react14.default.createElement("div", { className: "ai-agent-panel__chat-header" }, /* @__PURE__ */ import_react14.default.createElement("div", { className: "ai-agent-panel__chat-header-spacer" }), /* @__PURE__ */ import_react14.default.createElement(Tooltip, { content: "Collapse Panel", side: position === "right" ? "left" : "right" }, /* @__PURE__ */ import_react14.default.createElement(Button, { variant: "ghost", size: "icon", onClick: toggleCollapse }, position === "right" ? /* @__PURE__ */ import_react14.default.createElement(ChevronRightIcon, null) : /* @__PURE__ */ import_react14.default.createElement(ChevronLeftIcon, null)))), showContextNotification && /* @__PURE__ */ import_react14.default.createElement("div", { className: "ai-agent-panel__context-notification" }, /* @__PURE__ */ import_react14.default.createElement(SparkleIcon, null), /* @__PURE__ */ import_react14.default.createElement("span", null, "Agent now has new context")), activeConversationsList.map((activeConv) => /* @__PURE__ */ import_react14.default.createElement(
|
|
5852
6624
|
ChatPanelWrapper,
|
|
5853
6625
|
{
|
|
5854
6626
|
key: `${activeConv.stableKey}-${activeConv.agentId}`,
|
|
@@ -5880,10 +6652,25 @@ var AIAgentPanel = import_react13.default.forwardRef(({
|
|
|
5880
6652
|
maxContextTokens,
|
|
5881
6653
|
enableContextDetailView,
|
|
5882
6654
|
onConversationCreated: handleConversationCreated,
|
|
5883
|
-
conversationInitialPrompt: activeConv.conversationInitialPrompt
|
|
6655
|
+
conversationInitialPrompt: activeConv.conversationInitialPrompt,
|
|
6656
|
+
cssUrl,
|
|
6657
|
+
markdownClass,
|
|
6658
|
+
width,
|
|
6659
|
+
height,
|
|
6660
|
+
scrollToEnd,
|
|
6661
|
+
prismStyle,
|
|
6662
|
+
showSaveButton,
|
|
6663
|
+
showEmailButton,
|
|
6664
|
+
messages,
|
|
6665
|
+
showCallToAction,
|
|
6666
|
+
callToActionButtonText,
|
|
6667
|
+
callToActionEmailAddress,
|
|
6668
|
+
callToActionEmailSubject,
|
|
6669
|
+
customerEmailCaptureMode,
|
|
6670
|
+
customerEmailCapturePlaceholder
|
|
5884
6671
|
}
|
|
5885
|
-
)), loadingConversationId && /* @__PURE__ */
|
|
5886
|
-
/* @__PURE__ */
|
|
6672
|
+
)), loadingConversationId && /* @__PURE__ */ import_react14.default.createElement("div", { className: "ai-agent-panel__conversation-loading-overlay" }, /* @__PURE__ */ import_react14.default.createElement("div", { className: "ai-agent-panel__loading-spinner" }), /* @__PURE__ */ import_react14.default.createElement("p", null, "Loading conversation...")), currentAgentMetadata && activeConversationsList.length === 0 && !loadingConversationId && /* @__PURE__ */ import_react14.default.createElement("div", { className: "ai-agent-panel__empty-chat" }, /* @__PURE__ */ import_react14.default.createElement(MessageIcon, null), /* @__PURE__ */ import_react14.default.createElement("p", null, "Select a conversation or start a new one"), /* @__PURE__ */ import_react14.default.createElement(Button, { variant: "default", size: "sm", onClick: handleNewConversation }, "New Conversation")), agentsLoading && !currentAgentMetadata && /* @__PURE__ */ import_react14.default.createElement("div", { className: "ai-agent-panel__loading" }, /* @__PURE__ */ import_react14.default.createElement("div", { className: "ai-agent-panel__loading-spinner" }), /* @__PURE__ */ import_react14.default.createElement("p", null, "Loading agent..."))),
|
|
6673
|
+
/* @__PURE__ */ import_react14.default.createElement(
|
|
5887
6674
|
Dialog,
|
|
5888
6675
|
{
|
|
5889
6676
|
isOpen: showHandoffDialog,
|
|
@@ -5891,7 +6678,7 @@ var AIAgentPanel = import_react13.default.forwardRef(({
|
|
|
5891
6678
|
title: "Switch Agent?",
|
|
5892
6679
|
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"}.`
|
|
5893
6680
|
},
|
|
5894
|
-
/* @__PURE__ */
|
|
6681
|
+
/* @__PURE__ */ import_react14.default.createElement(DialogFooter, null, /* @__PURE__ */ import_react14.default.createElement(Button, { variant: "outline", onClick: handleHandoffCancel }, "Stay with current agent"), /* @__PURE__ */ import_react14.default.createElement(Button, { onClick: handleHandoffConfirm }, "Switch agent"))
|
|
5895
6682
|
)
|
|
5896
6683
|
);
|
|
5897
6684
|
});
|
|
@@ -5899,7 +6686,7 @@ AIAgentPanel.displayName = "AIAgentPanel";
|
|
|
5899
6686
|
var AIAgentPanel_default = AIAgentPanel;
|
|
5900
6687
|
|
|
5901
6688
|
// src/hooks/useConversationStore.ts
|
|
5902
|
-
var
|
|
6689
|
+
var import_react15 = require("react");
|
|
5903
6690
|
var STORAGE_VERSION = "v1";
|
|
5904
6691
|
var generateId = () => {
|
|
5905
6692
|
if (typeof crypto !== "undefined" && "randomUUID" in crypto) {
|
|
@@ -5992,25 +6779,25 @@ function useConversationStore(options = {}) {
|
|
|
5992
6779
|
maxConversations = 50,
|
|
5993
6780
|
autoPersist = true
|
|
5994
6781
|
} = options;
|
|
5995
|
-
const [conversations, setConversations] = (0,
|
|
6782
|
+
const [conversations, setConversations] = (0, import_react15.useState)(
|
|
5996
6783
|
() => readFromStorage(namespace)
|
|
5997
6784
|
);
|
|
5998
|
-
const [activeConversationId, setActiveConversationId] = (0,
|
|
5999
|
-
const [searchQuery, setSearchQuery] = (0,
|
|
6000
|
-
(0,
|
|
6785
|
+
const [activeConversationId, setActiveConversationId] = (0, import_react15.useState)(null);
|
|
6786
|
+
const [searchQuery, setSearchQuery] = (0, import_react15.useState)("");
|
|
6787
|
+
(0, import_react15.useEffect)(() => {
|
|
6001
6788
|
if (autoPersist) {
|
|
6002
6789
|
writeToStorage(namespace, conversations);
|
|
6003
6790
|
}
|
|
6004
6791
|
}, [conversations, namespace, autoPersist]);
|
|
6005
|
-
(0,
|
|
6792
|
+
(0, import_react15.useEffect)(() => {
|
|
6006
6793
|
setConversations(readFromStorage(namespace));
|
|
6007
6794
|
setActiveConversationId(null);
|
|
6008
6795
|
}, [namespace]);
|
|
6009
|
-
const activeConversation = (0,
|
|
6796
|
+
const activeConversation = (0, import_react15.useMemo)(() => {
|
|
6010
6797
|
if (!activeConversationId) return null;
|
|
6011
6798
|
return conversations.find((c) => c.id === activeConversationId) || null;
|
|
6012
6799
|
}, [conversations, activeConversationId]);
|
|
6013
|
-
const filteredConversations = (0,
|
|
6800
|
+
const filteredConversations = (0, import_react15.useMemo)(() => {
|
|
6014
6801
|
if (!searchQuery.trim()) return conversations;
|
|
6015
6802
|
const query = searchQuery.toLowerCase().trim();
|
|
6016
6803
|
return conversations.filter((conv) => {
|
|
@@ -6018,13 +6805,13 @@ function useConversationStore(options = {}) {
|
|
|
6018
6805
|
return searchable.includes(query);
|
|
6019
6806
|
});
|
|
6020
6807
|
}, [conversations, searchQuery]);
|
|
6021
|
-
const groupedConversations = (0,
|
|
6808
|
+
const groupedConversations = (0, import_react15.useMemo)(() => {
|
|
6022
6809
|
const sorted = [...filteredConversations].sort(
|
|
6023
6810
|
(a, b) => new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime()
|
|
6024
6811
|
);
|
|
6025
6812
|
return groupByTimePeriod(sorted);
|
|
6026
6813
|
}, [filteredConversations]);
|
|
6027
|
-
const createConversation = (0,
|
|
6814
|
+
const createConversation = (0, import_react15.useCallback)(
|
|
6028
6815
|
(agentId, initialHistory) => {
|
|
6029
6816
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
6030
6817
|
const history = initialHistory || {};
|
|
@@ -6046,7 +6833,7 @@ function useConversationStore(options = {}) {
|
|
|
6046
6833
|
},
|
|
6047
6834
|
[maxConversations]
|
|
6048
6835
|
);
|
|
6049
|
-
const updateConversationHistory = (0,
|
|
6836
|
+
const updateConversationHistory = (0, import_react15.useCallback)(
|
|
6050
6837
|
(conversationId, history) => {
|
|
6051
6838
|
setConversations(
|
|
6052
6839
|
(prev) => prev.map((conv) => {
|
|
@@ -6062,26 +6849,26 @@ function useConversationStore(options = {}) {
|
|
|
6062
6849
|
},
|
|
6063
6850
|
[]
|
|
6064
6851
|
);
|
|
6065
|
-
const deleteConversation = (0,
|
|
6852
|
+
const deleteConversation = (0, import_react15.useCallback)((conversationId) => {
|
|
6066
6853
|
setConversations((prev) => prev.filter((c) => c.id !== conversationId));
|
|
6067
6854
|
if (activeConversationId === conversationId) {
|
|
6068
6855
|
setActiveConversationId(null);
|
|
6069
6856
|
}
|
|
6070
6857
|
}, [activeConversationId]);
|
|
6071
|
-
const selectConversation = (0,
|
|
6858
|
+
const selectConversation = (0, import_react15.useCallback)((conversationId) => {
|
|
6072
6859
|
setActiveConversationId(conversationId);
|
|
6073
6860
|
}, []);
|
|
6074
|
-
const getConversationsForAgent = (0,
|
|
6861
|
+
const getConversationsForAgent = (0, import_react15.useCallback)(
|
|
6075
6862
|
(agentId) => {
|
|
6076
6863
|
return conversations.filter((c) => c.agentId === agentId);
|
|
6077
6864
|
},
|
|
6078
6865
|
[conversations]
|
|
6079
6866
|
);
|
|
6080
|
-
const clearAllConversations = (0,
|
|
6867
|
+
const clearAllConversations = (0, import_react15.useCallback)(() => {
|
|
6081
6868
|
setConversations([]);
|
|
6082
6869
|
setActiveConversationId(null);
|
|
6083
6870
|
}, []);
|
|
6084
|
-
const startNewConversation = (0,
|
|
6871
|
+
const startNewConversation = (0, import_react15.useCallback)(() => {
|
|
6085
6872
|
setActiveConversationId(null);
|
|
6086
6873
|
}, []);
|
|
6087
6874
|
return {
|