@hef2024/llmasaservice-ui 0.16.8 → 0.16.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +1951 -1886
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +333 -105
- package/dist/index.mjs +334 -106
- package/package.json +4 -4
- package/src/AIAgentPanel.css +79 -1
- package/src/AIAgentPanel.tsx +236 -23
- package/src/AIChatPanel.tsx +259 -109
- package/src/AgentPanel.tsx +1 -3
- package/src/ChatPanel.tsx +1 -7
- package/src/components/ui/Button.tsx +2 -0
- package/src/components/ui/Dialog.tsx +2 -0
- package/src/components/ui/Input.tsx +2 -0
- package/src/components/ui/Select.tsx +2 -0
- package/src/components/ui/Tooltip.tsx +2 -0
- package/src/components/ui/index.ts +2 -0
- package/src/hooks/useAgentRegistry.ts +1 -4
package/dist/index.js
CHANGED
|
@@ -521,10 +521,7 @@ var ChatPanel = ({
|
|
|
521
521
|
{ key: "--userLanguage", data: browserInfo == null ? void 0 : browserInfo.userLanguage }
|
|
522
522
|
];
|
|
523
523
|
};
|
|
524
|
-
|
|
525
|
-
if (window.location.hostname === "localhost" || window.location.hostname === "dev.llmasaservice.io") {
|
|
526
|
-
publicAPIUrl = "https://8ftw8droff.execute-api.us-east-1.amazonaws.com/dev";
|
|
527
|
-
}
|
|
524
|
+
const publicAPIUrl = "https://api.llmasaservice.io";
|
|
528
525
|
const [toolList, setToolList] = (0, import_react3.useState)([]);
|
|
529
526
|
const [toolsLoading, setToolsLoading] = (0, import_react3.useState)(false);
|
|
530
527
|
const [toolsFetchError, setToolsFetchError] = (0, import_react3.useState)(false);
|
|
@@ -2894,7 +2891,7 @@ var AgentPanel = ({
|
|
|
2894
2891
|
(0, import_react4.useEffect)(() => {
|
|
2895
2892
|
const fetchAgentData = () => __async(void 0, null, function* () {
|
|
2896
2893
|
try {
|
|
2897
|
-
const fetchUrl =
|
|
2894
|
+
const fetchUrl = `https://api.llmasaservice.io/agents/${agent}`;
|
|
2898
2895
|
const response = yield fetch(fetchUrl, {
|
|
2899
2896
|
method: "GET",
|
|
2900
2897
|
headers: {
|
|
@@ -3646,8 +3643,10 @@ var AIChatPanel = ({
|
|
|
3646
3643
|
contextSections = [],
|
|
3647
3644
|
totalContextTokens = 0,
|
|
3648
3645
|
maxContextTokens = 8e3,
|
|
3649
|
-
enableContextDetailView = false
|
|
3646
|
+
enableContextDetailView = false,
|
|
3647
|
+
onConversationCreated
|
|
3650
3648
|
}) => {
|
|
3649
|
+
const publicAPIUrl = "https://api.llmasaservice.io";
|
|
3651
3650
|
const [lastController, setLastController] = (0, import_react11.useState)(new AbortController());
|
|
3652
3651
|
const [lastMessages, setLastMessages] = (0, import_react11.useState)([]);
|
|
3653
3652
|
const [history, setHistory] = (0, import_react11.useState)(initialHistory);
|
|
@@ -3670,6 +3669,24 @@ var AIChatPanel = ({
|
|
|
3670
3669
|
const prevIdleRef = (0, import_react11.useRef)(true);
|
|
3671
3670
|
const hasNotifiedCompletionRef = (0, import_react11.useRef)(true);
|
|
3672
3671
|
const latestHistoryRef = (0, import_react11.useRef)(initialHistory);
|
|
3672
|
+
(0, import_react11.useEffect)(() => {
|
|
3673
|
+
if (!initialHistory) return;
|
|
3674
|
+
setHistory((prev) => {
|
|
3675
|
+
const currentKeys = Object.keys(prev);
|
|
3676
|
+
const newEntries = {};
|
|
3677
|
+
let hasNewEntries = false;
|
|
3678
|
+
for (const [key, value] of Object.entries(initialHistory)) {
|
|
3679
|
+
if (!currentKeys.includes(key)) {
|
|
3680
|
+
newEntries[key] = value;
|
|
3681
|
+
hasNewEntries = true;
|
|
3682
|
+
}
|
|
3683
|
+
}
|
|
3684
|
+
if (hasNewEntries) {
|
|
3685
|
+
return __spreadValues(__spreadValues({}, prev), newEntries);
|
|
3686
|
+
}
|
|
3687
|
+
return prev;
|
|
3688
|
+
});
|
|
3689
|
+
}, [initialHistory]);
|
|
3673
3690
|
const llmResult = (0, import_llmasaservice_client2.useLLM)(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
|
|
3674
3691
|
project_id,
|
|
3675
3692
|
customer
|
|
@@ -3709,6 +3726,60 @@ var AIChatPanel = ({
|
|
|
3709
3726
|
userLanguage: navigator.language
|
|
3710
3727
|
};
|
|
3711
3728
|
}, []);
|
|
3729
|
+
const ensureConversation = (0, import_react11.useCallback)(() => {
|
|
3730
|
+
var _a, _b;
|
|
3731
|
+
console.log("ensureConversation - called with:", {
|
|
3732
|
+
currentConversation,
|
|
3733
|
+
createConversationOnFirstChat,
|
|
3734
|
+
project_id,
|
|
3735
|
+
publicAPIUrl
|
|
3736
|
+
});
|
|
3737
|
+
if ((!currentConversation || currentConversation === "") && createConversationOnFirstChat) {
|
|
3738
|
+
if (!project_id) {
|
|
3739
|
+
console.error("ensureConversation - Cannot create conversation without project_id");
|
|
3740
|
+
return Promise.resolve("");
|
|
3741
|
+
}
|
|
3742
|
+
const requestBody = {
|
|
3743
|
+
project_id,
|
|
3744
|
+
agentId: agent,
|
|
3745
|
+
customerId: (_a = customer == null ? void 0 : customer.customer_id) != null ? _a : null,
|
|
3746
|
+
customerEmail: (_b = customer == null ? void 0 : customer.customer_user_email) != null ? _b : null,
|
|
3747
|
+
timezone: browserInfo == null ? void 0 : browserInfo.userTimezone,
|
|
3748
|
+
language: browserInfo == null ? void 0 : browserInfo.userLanguage
|
|
3749
|
+
};
|
|
3750
|
+
console.log("ensureConversation - Creating conversation with:", requestBody);
|
|
3751
|
+
console.log("ensureConversation - API URL:", `${publicAPIUrl}/conversations`);
|
|
3752
|
+
return fetch(`${publicAPIUrl}/conversations`, {
|
|
3753
|
+
method: "POST",
|
|
3754
|
+
headers: {
|
|
3755
|
+
"Content-Type": "application/json"
|
|
3756
|
+
},
|
|
3757
|
+
body: JSON.stringify(requestBody)
|
|
3758
|
+
}).then((res) => __async(void 0, null, function* () {
|
|
3759
|
+
if (!res.ok) {
|
|
3760
|
+
const errorText = yield res.text();
|
|
3761
|
+
throw new Error(
|
|
3762
|
+
`HTTP error! status: ${res.status}, message: ${errorText}`
|
|
3763
|
+
);
|
|
3764
|
+
}
|
|
3765
|
+
return res.json();
|
|
3766
|
+
})).then((newConvo) => {
|
|
3767
|
+
console.log("ensureConversation - API response:", newConvo);
|
|
3768
|
+
if (newConvo == null ? void 0 : newConvo.id) {
|
|
3769
|
+
console.log("ensureConversation - New conversation ID:", newConvo.id);
|
|
3770
|
+
setCurrentConversation(newConvo.id);
|
|
3771
|
+
return newConvo.id;
|
|
3772
|
+
}
|
|
3773
|
+
console.warn("ensureConversation - No ID in response");
|
|
3774
|
+
return "";
|
|
3775
|
+
}).catch((error) => {
|
|
3776
|
+
console.error("Error creating new conversation", error);
|
|
3777
|
+
return "";
|
|
3778
|
+
});
|
|
3779
|
+
}
|
|
3780
|
+
console.log("ensureConversation - using existing conversation:", currentConversation);
|
|
3781
|
+
return Promise.resolve(currentConversation);
|
|
3782
|
+
}, [currentConversation, createConversationOnFirstChat, publicAPIUrl, project_id, agent, customer, browserInfo]);
|
|
3712
3783
|
const dataWithExtras = (0, import_react11.useCallback)(() => {
|
|
3713
3784
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
3714
3785
|
return [
|
|
@@ -3822,6 +3893,7 @@ var AIChatPanel = ({
|
|
|
3822
3893
|
lastScrollTimeRef.current = now;
|
|
3823
3894
|
}, []);
|
|
3824
3895
|
const continueChat = (0, import_react11.useCallback)((promptText) => {
|
|
3896
|
+
console.log("AIChatPanel.continueChat called with:", promptText);
|
|
3825
3897
|
setThinkingBlocks([]);
|
|
3826
3898
|
setCurrentThinkingIndex(0);
|
|
3827
3899
|
setUserHasScrolled(false);
|
|
@@ -3841,58 +3913,68 @@ var AIChatPanel = ({
|
|
|
3841
3913
|
const promptToSend = promptText;
|
|
3842
3914
|
if (!promptToSend || !promptToSend.trim()) return;
|
|
3843
3915
|
setIsLoading(true);
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
const
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3916
|
+
console.log("AIChatPanel.continueChat - about to call ensureConversation");
|
|
3917
|
+
ensureConversation().then((convId) => {
|
|
3918
|
+
console.log("AIChatPanel.continueChat - ensureConversation resolved with:", convId);
|
|
3919
|
+
const messagesAndHistory = [];
|
|
3920
|
+
Object.entries(history).forEach(([historyPrompt, historyEntry]) => {
|
|
3921
|
+
let promptForHistory = historyPrompt;
|
|
3922
|
+
const isoTimestampRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z:/;
|
|
3923
|
+
if (isoTimestampRegex.test(historyPrompt)) {
|
|
3924
|
+
const colonIndex = historyPrompt.indexOf(":", 19);
|
|
3925
|
+
promptForHistory = historyPrompt.substring(colonIndex + 1);
|
|
3926
|
+
} else if (/^\d+:/.test(historyPrompt)) {
|
|
3927
|
+
const colonIndex = historyPrompt.indexOf(":");
|
|
3928
|
+
promptForHistory = historyPrompt.substring(colonIndex + 1);
|
|
3929
|
+
}
|
|
3930
|
+
messagesAndHistory.push({ role: "user", content: promptForHistory });
|
|
3931
|
+
messagesAndHistory.push({ role: "assistant", content: historyEntry.content });
|
|
3932
|
+
});
|
|
3933
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
3934
|
+
const promptKey = `${timestamp}:${promptToSend.trim()}`;
|
|
3935
|
+
setHistory((prevHistory) => __spreadProps(__spreadValues({}, prevHistory), {
|
|
3936
|
+
[promptKey]: { content: "", callId: "" }
|
|
3937
|
+
}));
|
|
3938
|
+
let fullPromptToSend = promptToSend.trim();
|
|
3939
|
+
if (Object.keys(history).length === 0 && promptTemplate) {
|
|
3940
|
+
fullPromptToSend = promptTemplate.replace("{{prompt}}", fullPromptToSend);
|
|
3854
3941
|
}
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
});
|
|
3858
|
-
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
3859
|
-
const promptKey = `${timestamp}:${promptToSend.trim()}`;
|
|
3860
|
-
setHistory((prevHistory) => __spreadProps(__spreadValues({}, prevHistory), {
|
|
3861
|
-
[promptKey]: { content: "", callId: "" }
|
|
3862
|
-
}));
|
|
3863
|
-
let fullPromptToSend = promptToSend.trim();
|
|
3864
|
-
if (Object.keys(history).length === 0 && promptTemplate) {
|
|
3865
|
-
fullPromptToSend = promptTemplate.replace("{{prompt}}", fullPromptToSend);
|
|
3866
|
-
}
|
|
3867
|
-
if (followOnPrompt) {
|
|
3868
|
-
fullPromptToSend += `
|
|
3942
|
+
if (followOnPrompt) {
|
|
3943
|
+
fullPromptToSend += `
|
|
3869
3944
|
|
|
3870
3945
|
${followOnPrompt}`;
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3946
|
+
}
|
|
3947
|
+
const newController = new AbortController();
|
|
3948
|
+
setLastController(newController);
|
|
3949
|
+
send(
|
|
3950
|
+
fullPromptToSend,
|
|
3951
|
+
messagesAndHistory,
|
|
3952
|
+
[
|
|
3953
|
+
...dataWithExtras(),
|
|
3954
|
+
{ key: "--messages", data: messagesAndHistory.length.toString() }
|
|
3955
|
+
],
|
|
3956
|
+
true,
|
|
3957
|
+
// stream
|
|
3958
|
+
true,
|
|
3959
|
+
// includeHistory
|
|
3960
|
+
service,
|
|
3961
|
+
// group_id from agent config
|
|
3962
|
+
convId,
|
|
3963
|
+
// Use the conversation ID from ensureConversation
|
|
3964
|
+
newController
|
|
3965
|
+
);
|
|
3966
|
+
setLastPrompt(promptToSend.trim());
|
|
3967
|
+
setLastMessages(messagesAndHistory);
|
|
3968
|
+
setLastKey(promptKey);
|
|
3969
|
+
if (convId && onConversationCreated) {
|
|
3970
|
+
setTimeout(() => {
|
|
3971
|
+
onConversationCreated(convId);
|
|
3972
|
+
}, 100);
|
|
3973
|
+
}
|
|
3974
|
+
setTimeout(() => {
|
|
3975
|
+
scrollToBottom();
|
|
3976
|
+
}, 0);
|
|
3977
|
+
});
|
|
3896
3978
|
}, [
|
|
3897
3979
|
idle,
|
|
3898
3980
|
stop,
|
|
@@ -3907,9 +3989,10 @@ ${followOnPrompt}`;
|
|
|
3907
3989
|
followOnPrompt,
|
|
3908
3990
|
send,
|
|
3909
3991
|
service,
|
|
3910
|
-
|
|
3992
|
+
ensureConversation,
|
|
3911
3993
|
dataWithExtras,
|
|
3912
|
-
scrollToBottom
|
|
3994
|
+
scrollToBottom,
|
|
3995
|
+
onConversationCreated
|
|
3913
3996
|
]);
|
|
3914
3997
|
const handleSuggestionClick = (0, import_react11.useCallback)((question) => {
|
|
3915
3998
|
continueChat(question);
|
|
@@ -3951,18 +4034,18 @@ ${followOnPrompt}`;
|
|
|
3951
4034
|
(0, import_react11.useEffect)(() => {
|
|
3952
4035
|
if (!response || !lastKey || justReset) return;
|
|
3953
4036
|
const { cleanedText, blocks } = processThinkingTags(response);
|
|
3954
|
-
const processedContent = processActions(cleanedText);
|
|
3955
4037
|
setThinkingBlocks(blocks);
|
|
3956
4038
|
setHistory((prev) => {
|
|
3957
4039
|
const newHistory = __spreadValues({}, prev);
|
|
3958
4040
|
newHistory[lastKey] = {
|
|
3959
|
-
content:
|
|
4041
|
+
content: cleanedText,
|
|
4042
|
+
// Store raw content, not processed
|
|
3960
4043
|
callId: lastCallId || ""
|
|
3961
4044
|
};
|
|
3962
4045
|
latestHistoryRef.current = newHistory;
|
|
3963
4046
|
return newHistory;
|
|
3964
4047
|
});
|
|
3965
|
-
}, [response, lastKey, lastCallId, processThinkingTags,
|
|
4048
|
+
}, [response, lastKey, lastCallId, processThinkingTags, justReset]);
|
|
3966
4049
|
(0, import_react11.useEffect)(() => {
|
|
3967
4050
|
const wasStreaming = !prevIdleRef.current;
|
|
3968
4051
|
const isNowIdle = idle;
|
|
@@ -4046,38 +4129,49 @@ ${followOnPrompt}`;
|
|
|
4046
4129
|
}, []);
|
|
4047
4130
|
(0, import_react11.useEffect)(() => {
|
|
4048
4131
|
const hasLoadedHistory = initialHistory && Object.keys(initialHistory).length > 0;
|
|
4132
|
+
if (!project_id) {
|
|
4133
|
+
return;
|
|
4134
|
+
}
|
|
4049
4135
|
if (initialPrompt && initialPrompt !== "" && initialPrompt !== lastPrompt && !hasLoadedHistory) {
|
|
4050
4136
|
setIsLoading(true);
|
|
4051
4137
|
setThinkingBlocks([]);
|
|
4052
4138
|
setCurrentThinkingIndex(0);
|
|
4053
4139
|
setUserHasScrolled(false);
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4140
|
+
ensureConversation().then((convId) => {
|
|
4141
|
+
const controller = new AbortController();
|
|
4142
|
+
setLastController(controller);
|
|
4143
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
4144
|
+
const promptKey = `${timestamp}:${initialPrompt}`;
|
|
4145
|
+
setHistory({ [promptKey]: { content: "", callId: "" } });
|
|
4146
|
+
let fullPrompt = initialPrompt;
|
|
4147
|
+
if (promptTemplate) {
|
|
4148
|
+
fullPrompt = promptTemplate.replace("{{prompt}}", initialPrompt);
|
|
4149
|
+
}
|
|
4150
|
+
send(
|
|
4151
|
+
fullPrompt,
|
|
4152
|
+
[],
|
|
4153
|
+
[
|
|
4154
|
+
...dataWithExtras(),
|
|
4155
|
+
{ key: "--messages", data: "0" }
|
|
4156
|
+
],
|
|
4157
|
+
true,
|
|
4158
|
+
true,
|
|
4159
|
+
service,
|
|
4160
|
+
convId,
|
|
4161
|
+
// Use conversation ID from ensureConversation
|
|
4162
|
+
controller
|
|
4163
|
+
);
|
|
4164
|
+
setLastPrompt(initialPrompt);
|
|
4165
|
+
setLastMessages([]);
|
|
4166
|
+
setLastKey(promptKey);
|
|
4167
|
+
if (convId && onConversationCreated) {
|
|
4168
|
+
setTimeout(() => {
|
|
4169
|
+
onConversationCreated(convId);
|
|
4170
|
+
}, 100);
|
|
4171
|
+
}
|
|
4172
|
+
});
|
|
4079
4173
|
}
|
|
4080
|
-
}, [initialPrompt, initialHistory]);
|
|
4174
|
+
}, [initialPrompt, initialHistory, ensureConversation, promptTemplate, send, dataWithExtras, service, lastPrompt, project_id, onConversationCreated]);
|
|
4081
4175
|
const CodeBlock = (0, import_react11.useCallback)((_a) => {
|
|
4082
4176
|
var _b = _a, { node, inline, className, children } = _b, props = __objRest(_b, ["node", "inline", "className", "children"]);
|
|
4083
4177
|
const match = /language-(\w+)/.exec(className || "");
|
|
@@ -4132,7 +4226,13 @@ ${followOnPrompt}`;
|
|
|
4132
4226
|
variant: "default",
|
|
4133
4227
|
size: "sm",
|
|
4134
4228
|
className: "ai-chat-agent-suggestion__button",
|
|
4135
|
-
onClick: () =>
|
|
4229
|
+
onClick: () => {
|
|
4230
|
+
onAgentChange(agentId);
|
|
4231
|
+
setTimeout(() => {
|
|
4232
|
+
var _a;
|
|
4233
|
+
(_a = bottomRef.current) == null ? void 0 : _a.scrollIntoView({ behavior: "auto" });
|
|
4234
|
+
}, 50);
|
|
4235
|
+
}
|
|
4136
4236
|
},
|
|
4137
4237
|
"Switch"
|
|
4138
4238
|
));
|
|
@@ -4181,15 +4281,17 @@ ${followOnPrompt}`;
|
|
|
4181
4281
|
const panelClasses = ["ai-chat-panel", theme === "dark" ? "dark-theme" : ""].filter(Boolean).join(" ");
|
|
4182
4282
|
return /* @__PURE__ */ import_react11.default.createElement("div", { className: panelClasses }, title && /* @__PURE__ */ import_react11.default.createElement("div", { className: "ai-chat-panel__title" }, title), /* @__PURE__ */ import_react11.default.createElement(ScrollArea, { className: "ai-chat-panel__messages", ref: responseAreaRef }, initialMessage && /* @__PURE__ */ import_react11.default.createElement("div", { className: "ai-chat-message ai-chat-message--assistant" }, /* @__PURE__ */ import_react11.default.createElement("div", { className: "ai-chat-message__content" }, /* @__PURE__ */ import_react11.default.createElement(import_react_markdown2.default, { remarkPlugins: [import_remark_gfm2.default], rehypePlugins: [import_rehype_raw2.default] }, initialMessage))), Object.entries(history).map(([prompt, entry], index) => {
|
|
4183
4283
|
const isLastEntry = index === Object.keys(history).length - 1;
|
|
4284
|
+
const isSystemMessage = prompt.startsWith("__system__:");
|
|
4184
4285
|
const { cleanedText } = processThinkingTags(entry.content);
|
|
4185
|
-
|
|
4286
|
+
const processedContent = processActions(cleanedText);
|
|
4287
|
+
return /* @__PURE__ */ import_react11.default.createElement("div", { key: index, className: "ai-chat-entry" }, !(hideInitialPrompt && index === 0) && !isSystemMessage && /* @__PURE__ */ import_react11.default.createElement("div", { className: "ai-chat-message ai-chat-message--user" }, /* @__PURE__ */ import_react11.default.createElement("div", { className: "ai-chat-message__content" }, formatPromptForDisplay(prompt))), /* @__PURE__ */ import_react11.default.createElement("div", { className: "ai-chat-message ai-chat-message--assistant" }, /* @__PURE__ */ import_react11.default.createElement("div", { className: "ai-chat-message__content" }, isLastEntry && (isLoading || !idle) && !justReset ? /* @__PURE__ */ import_react11.default.createElement("div", { className: "ai-chat-streaming" }, thinkingBlocks.length > 0 && renderThinkingBlocks(), processedContent ? /* @__PURE__ */ import_react11.default.createElement(
|
|
4186
4288
|
import_react_markdown2.default,
|
|
4187
4289
|
{
|
|
4188
4290
|
remarkPlugins: [import_remark_gfm2.default],
|
|
4189
4291
|
rehypePlugins: [import_rehype_raw2.default],
|
|
4190
4292
|
components: markdownComponents
|
|
4191
4293
|
},
|
|
4192
|
-
|
|
4294
|
+
processedContent
|
|
4193
4295
|
) : /* @__PURE__ */ import_react11.default.createElement("div", { className: "ai-chat-loading" }, /* @__PURE__ */ import_react11.default.createElement("span", null, "Thinking"), /* @__PURE__ */ import_react11.default.createElement("span", { className: "ai-chat-loading__dots" }, /* @__PURE__ */ import_react11.default.createElement("span", { className: "ai-chat-loading__dot" }), /* @__PURE__ */ import_react11.default.createElement("span", { className: "ai-chat-loading__dot" }), /* @__PURE__ */ import_react11.default.createElement("span", { className: "ai-chat-loading__dot" })))) : /* @__PURE__ */ import_react11.default.createElement(import_react11.default.Fragment, null, isLastEntry && thinkingBlocks.length > 0 && renderThinkingBlocks(), /* @__PURE__ */ import_react11.default.createElement(
|
|
4194
4296
|
import_react_markdown2.default,
|
|
4195
4297
|
{
|
|
@@ -4197,7 +4299,7 @@ ${followOnPrompt}`;
|
|
|
4197
4299
|
rehypePlugins: [import_rehype_raw2.default],
|
|
4198
4300
|
components: markdownComponents
|
|
4199
4301
|
},
|
|
4200
|
-
|
|
4302
|
+
processedContent
|
|
4201
4303
|
))), idle && !isLoading && /* @__PURE__ */ import_react11.default.createElement("div", { className: "ai-chat-message__actions" }, /* @__PURE__ */ import_react11.default.createElement(Tooltip, { content: copiedCallId === entry.callId ? "Copied!" : "Copy" }, /* @__PURE__ */ import_react11.default.createElement(
|
|
4202
4304
|
Button,
|
|
4203
4305
|
{
|
|
@@ -4272,8 +4374,7 @@ var AIChatPanel_default = import_react11.default.memo(AIChatPanel);
|
|
|
4272
4374
|
// src/hooks/useAgentRegistry.ts
|
|
4273
4375
|
var import_react12 = require("react");
|
|
4274
4376
|
var resolveApiEndpoint = (baseUrl, agentId) => {
|
|
4275
|
-
|
|
4276
|
-
return `${apiRoot}/agents/${agentId}`;
|
|
4377
|
+
return `https://api.llmasaservice.io/agents/${agentId}`;
|
|
4277
4378
|
};
|
|
4278
4379
|
function useAgentRegistry(agentIds, options = {}) {
|
|
4279
4380
|
const { url = "https://chat.llmasaservice.io", autoFetch = true, localOverrides = {} } = options;
|
|
@@ -4478,6 +4579,7 @@ var MessageIcon = () => /* @__PURE__ */ import_react13.default.createElement("sv
|
|
|
4478
4579
|
var CloseIcon = () => /* @__PURE__ */ import_react13.default.createElement("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ import_react13.default.createElement("path", { d: "M9 3L3 9M3 3l6 6", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }));
|
|
4479
4580
|
var LoadingDotIcon = () => /* @__PURE__ */ import_react13.default.createElement("span", { className: "ai-agent-panel__loading-dot" });
|
|
4480
4581
|
var SidebarIcon = () => /* @__PURE__ */ import_react13.default.createElement("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ import_react13.default.createElement("rect", { x: "2", y: "2", width: "12", height: "12", rx: "2", stroke: "currentColor", strokeWidth: "1.5" }), /* @__PURE__ */ import_react13.default.createElement("path", { d: "M6 2v12", stroke: "currentColor", strokeWidth: "1.5" }));
|
|
4582
|
+
var SparkleIcon = () => /* @__PURE__ */ import_react13.default.createElement("svg", { width: "14", height: "14", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ import_react13.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_react13.default.createElement("circle", { cx: "8", cy: "8", r: "2", fill: "currentColor" }));
|
|
4481
4583
|
var normalizeConversationListPayload = (payload) => {
|
|
4482
4584
|
if (!payload) return [];
|
|
4483
4585
|
const conversations = Array.isArray(payload) ? payload : payload.conversations || [];
|
|
@@ -4595,7 +4697,8 @@ var ChatPanelWrapper = ({
|
|
|
4595
4697
|
contextSections,
|
|
4596
4698
|
totalContextTokens,
|
|
4597
4699
|
maxContextTokens,
|
|
4598
|
-
enableContextDetailView
|
|
4700
|
+
enableContextDetailView,
|
|
4701
|
+
onConversationCreated
|
|
4599
4702
|
}) => {
|
|
4600
4703
|
var _a, _b;
|
|
4601
4704
|
const convAgentProfile = getAgent(activeConv.agentId);
|
|
@@ -4613,6 +4716,12 @@ var ChatPanelWrapper = ({
|
|
|
4613
4716
|
},
|
|
4614
4717
|
[handleLoadingChange, activeConv.conversationId]
|
|
4615
4718
|
);
|
|
4719
|
+
const conversationCreatedCallback = (0, import_react13.useCallback)(
|
|
4720
|
+
(realConversationId) => {
|
|
4721
|
+
onConversationCreated(activeConv.conversationId, realConversationId);
|
|
4722
|
+
},
|
|
4723
|
+
[onConversationCreated, activeConv.conversationId]
|
|
4724
|
+
);
|
|
4616
4725
|
const agentStatus = convAgentProfile == null ? void 0 : convAgentProfile.status;
|
|
4617
4726
|
const promptsString = (convAgentMetadata == null ? void 0 : convAgentMetadata.displayFollowOnPrompts) || "";
|
|
4618
4727
|
let effectiveFollowOnQuestions;
|
|
@@ -4671,7 +4780,8 @@ var ChatPanelWrapper = ({
|
|
|
4671
4780
|
contextSections,
|
|
4672
4781
|
totalContextTokens,
|
|
4673
4782
|
maxContextTokens,
|
|
4674
|
-
enableContextDetailView
|
|
4783
|
+
enableContextDetailView,
|
|
4784
|
+
onConversationCreated: conversationCreatedCallback
|
|
4675
4785
|
}
|
|
4676
4786
|
)
|
|
4677
4787
|
);
|
|
@@ -4711,9 +4821,10 @@ var AIAgentPanel = ({
|
|
|
4711
4821
|
actions = [],
|
|
4712
4822
|
followOnQuestions = [],
|
|
4713
4823
|
followOnPrompt = "",
|
|
4714
|
-
historyListLimit = 50
|
|
4824
|
+
historyListLimit = 50,
|
|
4825
|
+
showConversationHistory = true
|
|
4715
4826
|
}) => {
|
|
4716
|
-
var _a, _b;
|
|
4827
|
+
var _a, _b, _c, _d;
|
|
4717
4828
|
const [isCollapsed, setIsCollapsed] = (0, import_react13.useState)(defaultCollapsed);
|
|
4718
4829
|
const [isHistoryCollapsed, setIsHistoryCollapsed] = (0, import_react13.useState)(() => {
|
|
4719
4830
|
if (typeof window !== "undefined") {
|
|
@@ -4738,6 +4849,7 @@ var AIAgentPanel = ({
|
|
|
4738
4849
|
const [showSearch, setShowSearch] = (0, import_react13.useState)(false);
|
|
4739
4850
|
const [showHandoffDialog, setShowHandoffDialog] = (0, import_react13.useState)(false);
|
|
4740
4851
|
const [suggestedAgent, setSuggestedAgent] = (0, import_react13.useState)(null);
|
|
4852
|
+
const [handoffSource, setHandoffSource] = (0, import_react13.useState)("agent");
|
|
4741
4853
|
const panelRef = (0, import_react13.useRef)(null);
|
|
4742
4854
|
const resizeRef = (0, import_react13.useRef)(null);
|
|
4743
4855
|
const { agentIds, localOverrides } = (0, import_react13.useMemo)(() => {
|
|
@@ -4793,6 +4905,10 @@ var AIAgentPanel = ({
|
|
|
4793
4905
|
activeConversationsRef.current = activeConversations;
|
|
4794
4906
|
const currentConversationIdRef = (0, import_react13.useRef)(currentConversationId);
|
|
4795
4907
|
currentConversationIdRef.current = currentConversationId;
|
|
4908
|
+
const [showContextNotification, setShowContextNotification] = (0, import_react13.useState)(false);
|
|
4909
|
+
const prevContextRef = (0, import_react13.useRef)(null);
|
|
4910
|
+
const contextNotificationTimeoutRef = (0, import_react13.useRef)(null);
|
|
4911
|
+
const prevDefaultAgentRef = (0, import_react13.useRef)(null);
|
|
4796
4912
|
const fetchFirstPrompt = (0, import_react13.useCallback)((conversationId, agentIdForConversation) => __async(void 0, null, function* () {
|
|
4797
4913
|
var _a2, _b2;
|
|
4798
4914
|
if (checkedPromptsRef.current.has(conversationId)) {
|
|
@@ -4893,6 +5009,9 @@ var AIAgentPanel = ({
|
|
|
4893
5009
|
fetchInProgressRef.current = true;
|
|
4894
5010
|
setConversationsLoading(true);
|
|
4895
5011
|
setConversationsError(null);
|
|
5012
|
+
console.log("projectId", projectId);
|
|
5013
|
+
console.log("customerId", customerId);
|
|
5014
|
+
console.log("apiKey", apiKey);
|
|
4896
5015
|
try {
|
|
4897
5016
|
console.log("fetchConversations - customerId:", customerId);
|
|
4898
5017
|
const url2 = `https://api.llmasaservice.io/conversations?customer_id=${customerId}`;
|
|
@@ -5012,6 +5131,8 @@ var AIAgentPanel = ({
|
|
|
5012
5131
|
const next = new Map(prev);
|
|
5013
5132
|
next.set(conversationId, {
|
|
5014
5133
|
conversationId,
|
|
5134
|
+
stableKey: conversationId,
|
|
5135
|
+
// Use real ID as stable key when loading from API
|
|
5015
5136
|
agentId: agentIdToUse,
|
|
5016
5137
|
history,
|
|
5017
5138
|
isLoading: false,
|
|
@@ -5035,6 +5156,7 @@ var AIAgentPanel = ({
|
|
|
5035
5156
|
}, [currentAgentId, fetchConversations]);
|
|
5036
5157
|
(0, import_react13.useEffect)(() => {
|
|
5037
5158
|
var _a2;
|
|
5159
|
+
if (!showConversationHistory) return;
|
|
5038
5160
|
if (!agentsLoading && currentAgentId && apiKey) {
|
|
5039
5161
|
const agentProfile = getAgent(currentAgentId);
|
|
5040
5162
|
const projectId = (_a2 = agentProfile == null ? void 0 : agentProfile.metadata) == null ? void 0 : _a2.projectId;
|
|
@@ -5043,13 +5165,15 @@ var AIAgentPanel = ({
|
|
|
5043
5165
|
fetchConversations(currentAgentId);
|
|
5044
5166
|
}
|
|
5045
5167
|
}
|
|
5046
|
-
}, [agentsLoading, currentAgentId, apiKey, fetchConversations, getAgent]);
|
|
5168
|
+
}, [agentsLoading, currentAgentId, apiKey, fetchConversations, getAgent, showConversationHistory]);
|
|
5047
5169
|
const handleNewConversation = (0, import_react13.useCallback)(() => {
|
|
5048
5170
|
const tempId = `new-${Date.now()}`;
|
|
5049
5171
|
setActiveConversations((prev) => {
|
|
5050
5172
|
const next = new Map(prev);
|
|
5051
5173
|
next.set(tempId, {
|
|
5052
5174
|
conversationId: tempId,
|
|
5175
|
+
stableKey: tempId,
|
|
5176
|
+
// Stable key never changes even when conversationId updates
|
|
5053
5177
|
agentId: currentAgentId,
|
|
5054
5178
|
history: {},
|
|
5055
5179
|
isLoading: false,
|
|
@@ -5199,6 +5323,80 @@ var AIAgentPanel = ({
|
|
|
5199
5323
|
totalTokens
|
|
5200
5324
|
};
|
|
5201
5325
|
}, [context, sharedContextSections, pageContextSections, contextDataSources]);
|
|
5326
|
+
(0, import_react13.useEffect)(() => {
|
|
5327
|
+
const contextString = JSON.stringify(mergedContext.sections.map((s) => ({ id: s.id, data: s.data })));
|
|
5328
|
+
if (prevContextRef.current === null) {
|
|
5329
|
+
prevContextRef.current = contextString;
|
|
5330
|
+
return;
|
|
5331
|
+
}
|
|
5332
|
+
if (prevContextRef.current !== contextString) {
|
|
5333
|
+
console.log("AIAgentPanel - Context changed, showing notification");
|
|
5334
|
+
prevContextRef.current = contextString;
|
|
5335
|
+
if (contextNotificationTimeoutRef.current) {
|
|
5336
|
+
clearTimeout(contextNotificationTimeoutRef.current);
|
|
5337
|
+
contextNotificationTimeoutRef.current = null;
|
|
5338
|
+
}
|
|
5339
|
+
setShowContextNotification(true);
|
|
5340
|
+
contextNotificationTimeoutRef.current = setTimeout(() => {
|
|
5341
|
+
setShowContextNotification(false);
|
|
5342
|
+
contextNotificationTimeoutRef.current = null;
|
|
5343
|
+
}, 3e3);
|
|
5344
|
+
}
|
|
5345
|
+
}, [mergedContext.sections]);
|
|
5346
|
+
(0, import_react13.useEffect)(() => {
|
|
5347
|
+
return () => {
|
|
5348
|
+
if (contextNotificationTimeoutRef.current) {
|
|
5349
|
+
clearTimeout(contextNotificationTimeoutRef.current);
|
|
5350
|
+
}
|
|
5351
|
+
};
|
|
5352
|
+
}, []);
|
|
5353
|
+
(0, import_react13.useEffect)(() => {
|
|
5354
|
+
var _a2, _b2;
|
|
5355
|
+
let foundDefaultAgent = null;
|
|
5356
|
+
for (const section of pageContextSections) {
|
|
5357
|
+
if (section.data && typeof section.data === "object" && "defaultAgent" in section.data) {
|
|
5358
|
+
const defaultAgentValue = section.data.defaultAgent;
|
|
5359
|
+
if (typeof defaultAgentValue === "string" && defaultAgentValue) {
|
|
5360
|
+
foundDefaultAgent = defaultAgentValue;
|
|
5361
|
+
break;
|
|
5362
|
+
}
|
|
5363
|
+
}
|
|
5364
|
+
}
|
|
5365
|
+
if (!foundDefaultAgent || foundDefaultAgent === prevDefaultAgentRef.current) {
|
|
5366
|
+
return;
|
|
5367
|
+
}
|
|
5368
|
+
if (foundDefaultAgent === currentAgentId) {
|
|
5369
|
+
prevDefaultAgentRef.current = foundDefaultAgent;
|
|
5370
|
+
return;
|
|
5371
|
+
}
|
|
5372
|
+
const isAvailable = agentIds.includes(foundDefaultAgent);
|
|
5373
|
+
const agentProfile = getAgent(foundDefaultAgent);
|
|
5374
|
+
const isReady = (agentProfile == null ? void 0 : agentProfile.status) === "ready";
|
|
5375
|
+
if (isAvailable && isReady && currentConversationIdRef.current) {
|
|
5376
|
+
const agentName = ((_a2 = agentProfile == null ? void 0 : agentProfile.metadata) == null ? void 0 : _a2.displayTitle) || ((_b2 = localOverrides[foundDefaultAgent]) == null ? void 0 : _b2.localName) || foundDefaultAgent;
|
|
5377
|
+
const suggestionMessage = `This page recommends a different agent for better assistance.
|
|
5378
|
+
|
|
5379
|
+
[SUGGEST_AGENT:${foundDefaultAgent}|${agentName}|Recommended for this page]`;
|
|
5380
|
+
const syntheticKey = `__system__:page_suggestion_${foundDefaultAgent}_${Date.now()}`;
|
|
5381
|
+
prevDefaultAgentRef.current = foundDefaultAgent;
|
|
5382
|
+
setActiveConversations((prev) => {
|
|
5383
|
+
const conversationId = currentConversationIdRef.current;
|
|
5384
|
+
if (!conversationId) return prev;
|
|
5385
|
+
const existing = prev.get(conversationId);
|
|
5386
|
+
if (!existing) return prev;
|
|
5387
|
+
const next = new Map(prev);
|
|
5388
|
+
next.set(conversationId, __spreadProps(__spreadValues({}, existing), {
|
|
5389
|
+
history: __spreadProps(__spreadValues({}, existing.history), {
|
|
5390
|
+
[syntheticKey]: {
|
|
5391
|
+
content: suggestionMessage,
|
|
5392
|
+
callId: `page-suggestion-${Date.now()}`
|
|
5393
|
+
}
|
|
5394
|
+
})
|
|
5395
|
+
}));
|
|
5396
|
+
return next;
|
|
5397
|
+
});
|
|
5398
|
+
}
|
|
5399
|
+
}, [pageContextSections, currentAgentId, agentIds, getAgent, localOverrides]);
|
|
5202
5400
|
const chatPanelData = (0, import_react13.useMemo)(() => {
|
|
5203
5401
|
const contextData = mergedContext.sections.map((section) => ({
|
|
5204
5402
|
key: section.id,
|
|
@@ -5301,6 +5499,7 @@ var AIAgentPanel = ({
|
|
|
5301
5499
|
const suggestedId = handoffMatch[1];
|
|
5302
5500
|
if (suggestedId && suggestedId !== currentAgentId && agents.includes(suggestedId)) {
|
|
5303
5501
|
setSuggestedAgent(suggestedId);
|
|
5502
|
+
setHandoffSource("agent");
|
|
5304
5503
|
setShowHandoffDialog(true);
|
|
5305
5504
|
}
|
|
5306
5505
|
}
|
|
@@ -5337,11 +5536,34 @@ var AIAgentPanel = ({
|
|
|
5337
5536
|
}
|
|
5338
5537
|
setShowHandoffDialog(false);
|
|
5339
5538
|
setSuggestedAgent(null);
|
|
5539
|
+
setHandoffSource("agent");
|
|
5340
5540
|
}, [suggestedAgent, handleAgentSwitch]);
|
|
5341
5541
|
const handleHandoffCancel = (0, import_react13.useCallback)(() => {
|
|
5342
5542
|
setShowHandoffDialog(false);
|
|
5343
5543
|
setSuggestedAgent(null);
|
|
5544
|
+
setHandoffSource("agent");
|
|
5344
5545
|
}, []);
|
|
5546
|
+
const handleConversationCreated = (0, import_react13.useCallback)((tempId, realId) => {
|
|
5547
|
+
console.log("Conversation created:", tempId, "->", realId);
|
|
5548
|
+
setActiveConversations((prev) => {
|
|
5549
|
+
const existing = prev.get(tempId);
|
|
5550
|
+
if (existing) {
|
|
5551
|
+
const next = new Map(prev);
|
|
5552
|
+
next.delete(tempId);
|
|
5553
|
+
next.set(realId, __spreadProps(__spreadValues({}, existing), {
|
|
5554
|
+
conversationId: realId
|
|
5555
|
+
}));
|
|
5556
|
+
return next;
|
|
5557
|
+
}
|
|
5558
|
+
return prev;
|
|
5559
|
+
});
|
|
5560
|
+
if (currentConversationIdRef.current === tempId) {
|
|
5561
|
+
setCurrentConversationId(realId);
|
|
5562
|
+
if (onConversationChange) {
|
|
5563
|
+
onConversationChange(realId);
|
|
5564
|
+
}
|
|
5565
|
+
}
|
|
5566
|
+
}, [onConversationChange]);
|
|
5345
5567
|
const toggleCollapse = (0, import_react13.useCallback)(() => {
|
|
5346
5568
|
setIsCollapsed((prev) => !prev);
|
|
5347
5569
|
}, []);
|
|
@@ -5357,7 +5579,8 @@ var AIAgentPanel = ({
|
|
|
5357
5579
|
theme === "dark" ? "dark-theme" : "",
|
|
5358
5580
|
isCollapsed ? "ai-agent-panel--collapsed" : "",
|
|
5359
5581
|
position === "left" ? "ai-agent-panel--left" : "ai-agent-panel--right",
|
|
5360
|
-
sidebarPosition === "right" ? "ai-agent-panel--sidebar-right" : "ai-agent-panel--sidebar-left"
|
|
5582
|
+
sidebarPosition === "right" ? "ai-agent-panel--sidebar-right" : "ai-agent-panel--sidebar-left",
|
|
5583
|
+
!showConversationHistory ? "ai-agent-panel--no-history" : ""
|
|
5361
5584
|
].filter(Boolean).join(" ");
|
|
5362
5585
|
if (isCollapsed) {
|
|
5363
5586
|
return /* @__PURE__ */ import_react13.default.createElement("div", { className: panelClasses, ref: panelRef }, /* @__PURE__ */ import_react13.default.createElement(
|
|
@@ -5373,7 +5596,7 @@ var AIAgentPanel = ({
|
|
|
5373
5596
|
},
|
|
5374
5597
|
/* @__PURE__ */ import_react13.default.createElement(Tooltip, { content: "Expand Panel", side: "left" }, /* @__PURE__ */ import_react13.default.createElement(Button, { variant: "ghost", size: "icon", onClick: toggleCollapse }, position === "right" ? /* @__PURE__ */ import_react13.default.createElement(ChevronLeftIcon, null) : /* @__PURE__ */ import_react13.default.createElement(ChevronRightIcon, null))),
|
|
5375
5598
|
/* @__PURE__ */ import_react13.default.createElement("div", { className: "ai-agent-panel__collapsed-divider" }),
|
|
5376
|
-
/* @__PURE__ */ import_react13.default.createElement(Tooltip, { content: "Search", side: "left" }, /* @__PURE__ */ import_react13.default.createElement(
|
|
5599
|
+
showConversationHistory && /* @__PURE__ */ import_react13.default.createElement(Tooltip, { content: "Search", side: "left" }, /* @__PURE__ */ import_react13.default.createElement(
|
|
5377
5600
|
Button,
|
|
5378
5601
|
{
|
|
5379
5602
|
variant: "ghost",
|
|
@@ -5422,6 +5645,8 @@ var AIAgentPanel = ({
|
|
|
5422
5645
|
const next = new Map(prev);
|
|
5423
5646
|
next.set(tempId, {
|
|
5424
5647
|
conversationId: tempId,
|
|
5648
|
+
stableKey: tempId,
|
|
5649
|
+
// Stable key never changes
|
|
5425
5650
|
agentId: agent.id,
|
|
5426
5651
|
history: {},
|
|
5427
5652
|
isLoading: false,
|
|
@@ -5468,7 +5693,7 @@ var AIAgentPanel = ({
|
|
|
5468
5693
|
tabIndex: 0
|
|
5469
5694
|
}
|
|
5470
5695
|
),
|
|
5471
|
-
/* @__PURE__ */ import_react13.default.createElement("div", { className: `ai-agent-panel__sidebar ${isHistoryCollapsed ? "ai-agent-panel__sidebar--collapsed" : ""}` }, isHistoryCollapsed ? (
|
|
5696
|
+
showConversationHistory && /* @__PURE__ */ import_react13.default.createElement("div", { className: `ai-agent-panel__sidebar ${isHistoryCollapsed ? "ai-agent-panel__sidebar--collapsed" : ""}` }, isHistoryCollapsed ? (
|
|
5472
5697
|
// Collapsed history bar
|
|
5473
5698
|
/* @__PURE__ */ import_react13.default.createElement(
|
|
5474
5699
|
"div",
|
|
@@ -5524,6 +5749,8 @@ var AIAgentPanel = ({
|
|
|
5524
5749
|
const next = new Map(prev);
|
|
5525
5750
|
next.set(tempId, {
|
|
5526
5751
|
conversationId: tempId,
|
|
5752
|
+
stableKey: tempId,
|
|
5753
|
+
// Stable key never changes
|
|
5527
5754
|
agentId: agent.id,
|
|
5528
5755
|
history: {},
|
|
5529
5756
|
isLoading: false,
|
|
@@ -5581,7 +5808,7 @@ var AIAgentPanel = ({
|
|
|
5581
5808
|
))), /* @__PURE__ */ import_react13.default.createElement(Tooltip, { content: "Collapse History", side: "bottom" }, /* @__PURE__ */ import_react13.default.createElement(Button, { variant: "ghost", size: "icon", onClick: toggleHistoryCollapse }, /* @__PURE__ */ import_react13.default.createElement(SidebarIcon, null))), /* @__PURE__ */ import_react13.default.createElement(Button, { variant: "ghost", size: "icon", onClick: toggleCollapse }, position === "right" ? /* @__PURE__ */ import_react13.default.createElement(ChevronRightIcon, null) : /* @__PURE__ */ import_react13.default.createElement(ChevronLeftIcon, null))), /* @__PURE__ */ import_react13.default.createElement(ScrollArea, { className: "ai-agent-panel__conversations" }, activeConversationsList.length > 0 && /* @__PURE__ */ import_react13.default.createElement("div", { className: "ai-agent-panel__group ai-agent-panel__group--active" }, /* @__PURE__ */ import_react13.default.createElement("div", { className: "ai-agent-panel__group-label" }, /* @__PURE__ */ import_react13.default.createElement("span", null, "Active (", activeConversationsList.length, ")")), activeConversationsList.map((activeConv) => /* @__PURE__ */ import_react13.default.createElement(
|
|
5582
5809
|
"div",
|
|
5583
5810
|
{
|
|
5584
|
-
key: activeConv.
|
|
5811
|
+
key: activeConv.stableKey,
|
|
5585
5812
|
className: `ai-agent-panel__conversation ai-agent-panel__conversation--active-item ${currentConversationId === activeConv.conversationId ? "ai-agent-panel__conversation--current" : ""}`,
|
|
5586
5813
|
onClick: () => {
|
|
5587
5814
|
setCurrentConversationId(activeConv.conversationId);
|
|
@@ -5620,10 +5847,10 @@ var AIAgentPanel = ({
|
|
|
5620
5847
|
/* @__PURE__ */ import_react13.default.createElement("div", { className: "ai-agent-panel__conversation-content" }, /* @__PURE__ */ import_react13.default.createElement("div", { className: "ai-agent-panel__conversation-title" }, isActive && /* @__PURE__ */ import_react13.default.createElement("span", { className: "ai-agent-panel__active-badge" }, "\u25CF"), conversationFirstPrompts[conv.conversationId] || conv.title))
|
|
5621
5848
|
);
|
|
5622
5849
|
}))))))),
|
|
5623
|
-
/* @__PURE__ */ import_react13.default.createElement("div", { className: "ai-agent-panel__chat" }, activeConversationsList.map((activeConv) => /* @__PURE__ */ import_react13.default.createElement(
|
|
5850
|
+
/* @__PURE__ */ import_react13.default.createElement("div", { className: "ai-agent-panel__chat" }, showContextNotification && /* @__PURE__ */ import_react13.default.createElement("div", { className: "ai-agent-panel__context-notification" }, /* @__PURE__ */ import_react13.default.createElement(SparkleIcon, null), /* @__PURE__ */ import_react13.default.createElement("span", null, "Agent now has new context")), activeConversationsList.map((activeConv) => /* @__PURE__ */ import_react13.default.createElement(
|
|
5624
5851
|
ChatPanelWrapper,
|
|
5625
5852
|
{
|
|
5626
|
-
key: `${activeConv.
|
|
5853
|
+
key: `${activeConv.stableKey}-${activeConv.agentId}`,
|
|
5627
5854
|
activeConv,
|
|
5628
5855
|
currentConversationId,
|
|
5629
5856
|
getAgent,
|
|
@@ -5647,7 +5874,8 @@ var AIAgentPanel = ({
|
|
|
5647
5874
|
contextSections: mergedContext.sections,
|
|
5648
5875
|
totalContextTokens: mergedContext.totalTokens || 0,
|
|
5649
5876
|
maxContextTokens,
|
|
5650
|
-
enableContextDetailView
|
|
5877
|
+
enableContextDetailView,
|
|
5878
|
+
onConversationCreated: handleConversationCreated
|
|
5651
5879
|
}
|
|
5652
5880
|
)), loadingConversationId && /* @__PURE__ */ import_react13.default.createElement("div", { className: "ai-agent-panel__conversation-loading-overlay" }, /* @__PURE__ */ import_react13.default.createElement("div", { className: "ai-agent-panel__loading-spinner" }), /* @__PURE__ */ import_react13.default.createElement("p", null, "Loading conversation...")), currentAgentMetadata && activeConversationsList.length === 0 && !loadingConversationId && /* @__PURE__ */ import_react13.default.createElement("div", { className: "ai-agent-panel__empty-chat" }, /* @__PURE__ */ import_react13.default.createElement(MessageIcon, null), /* @__PURE__ */ import_react13.default.createElement("p", null, "Select a conversation or start a new one"), /* @__PURE__ */ import_react13.default.createElement(Button, { variant: "default", size: "sm", onClick: handleNewConversation }, "New Conversation")), agentsLoading && !currentAgentMetadata && /* @__PURE__ */ import_react13.default.createElement("div", { className: "ai-agent-panel__loading" }, /* @__PURE__ */ import_react13.default.createElement("div", { className: "ai-agent-panel__loading-spinner" }), /* @__PURE__ */ import_react13.default.createElement("p", null, "Loading agent..."))),
|
|
5653
5881
|
/* @__PURE__ */ import_react13.default.createElement(
|
|
@@ -5656,7 +5884,7 @@ var AIAgentPanel = ({
|
|
|
5656
5884
|
isOpen: showHandoffDialog,
|
|
5657
5885
|
onClose: handleHandoffCancel,
|
|
5658
5886
|
title: "Switch Agent?",
|
|
5659
|
-
description: `The current agent suggests transferring this conversation to ${suggestedAgent ? ((
|
|
5887
|
+
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"}.`
|
|
5660
5888
|
},
|
|
5661
5889
|
/* @__PURE__ */ import_react13.default.createElement(DialogFooter, null, /* @__PURE__ */ import_react13.default.createElement(Button, { variant: "outline", onClick: handleHandoffCancel }, "Stay with current agent"), /* @__PURE__ */ import_react13.default.createElement(Button, { onClick: handleHandoffConfirm }, "Switch agent"))
|
|
5662
5890
|
)
|