llmasaservice-ui 0.16.2 → 0.16.4
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 +4 -1
- package/dist/index.js +212 -153
- package/dist/index.mjs +212 -153
- package/package.json +1 -1
- package/src/AgentPanel.tsx +12 -3
- package/src/ChatPanel.css +6 -1
- package/src/ChatPanel.tsx +314 -186
- package/test-textarea-resize.html +0 -0
package/dist/index.css
CHANGED
|
@@ -166,12 +166,15 @@
|
|
|
166
166
|
border-radius: var(--border-radius);
|
|
167
167
|
min-height: var(--input-height);
|
|
168
168
|
max-height: 120px;
|
|
169
|
-
resize:
|
|
169
|
+
resize: vertical;
|
|
170
170
|
overflow-y: auto;
|
|
171
171
|
background-color: var(--input-background-color);
|
|
172
172
|
border: 1px solid var(--input-border-color);
|
|
173
173
|
transition: height 0.1s ease;
|
|
174
174
|
}
|
|
175
|
+
.llm-panel .chat-input.user-resized {
|
|
176
|
+
max-height: none;
|
|
177
|
+
}
|
|
175
178
|
.llm-panel .chat-input:focus,
|
|
176
179
|
.llm-panel input:focus {
|
|
177
180
|
outline: none;
|
package/dist/index.js
CHANGED
|
@@ -209,6 +209,12 @@ var ChatPanel = ({
|
|
|
209
209
|
progressiveActions = true
|
|
210
210
|
}) => {
|
|
211
211
|
var _a;
|
|
212
|
+
console.log("ChatPanel received actions:", {
|
|
213
|
+
actions,
|
|
214
|
+
actionsType: typeof actions,
|
|
215
|
+
actionsStringified: typeof actions === "string" ? actions : JSON.stringify(actions),
|
|
216
|
+
actionsLength: Array.isArray(actions) ? actions.length : "not array"
|
|
217
|
+
});
|
|
212
218
|
const isEmailAddress = (email) => {
|
|
213
219
|
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
214
220
|
return emailRegex.test(email);
|
|
@@ -261,6 +267,7 @@ var ChatPanel = ({
|
|
|
261
267
|
const [alwaysApprovedTools, setAlwaysApprovedTools] = (0, import_react3.useState)([]);
|
|
262
268
|
const [thinkingBlocks, setThinkingBlocks] = (0, import_react3.useState)([]);
|
|
263
269
|
const [currentThinkingIndex, setCurrentThinkingIndex] = (0, import_react3.useState)(0);
|
|
270
|
+
const [userResizedHeight, setUserResizedHeight] = (0, import_react3.useState)(null);
|
|
264
271
|
const [pendingButtonAttachments, setPendingButtonAttachments] = (0, import_react3.useState)([]);
|
|
265
272
|
const actionMatchRegistry = (0, import_react3.useRef)(/* @__PURE__ */ new Map());
|
|
266
273
|
const deferredActionsRef = (0, import_react3.useRef)(/* @__PURE__ */ new Map());
|
|
@@ -515,7 +522,6 @@ var ChatPanel = ({
|
|
|
515
522
|
const [toolsLoading, setToolsLoading] = (0, import_react3.useState)(false);
|
|
516
523
|
const [toolsFetchError, setToolsFetchError] = (0, import_react3.useState)(false);
|
|
517
524
|
(0, import_react3.useEffect)(() => {
|
|
518
|
-
console.log("MCP servers", mcpServers);
|
|
519
525
|
const fetchAndSetTools = () => __async(void 0, null, function* () {
|
|
520
526
|
if (!mcpServers || mcpServers.length === 0) {
|
|
521
527
|
setToolList([]);
|
|
@@ -562,7 +568,6 @@ var ChatPanel = ({
|
|
|
562
568
|
}));
|
|
563
569
|
const results = yield Promise.all(fetchPromises);
|
|
564
570
|
const allTools = results.flat();
|
|
565
|
-
console.log("Merged tools from all servers:", allTools);
|
|
566
571
|
setToolList(allTools);
|
|
567
572
|
setToolsFetchError(false);
|
|
568
573
|
} catch (error) {
|
|
@@ -591,6 +596,127 @@ var ChatPanel = ({
|
|
|
591
596
|
};
|
|
592
597
|
})
|
|
593
598
|
});
|
|
599
|
+
const processActionsOnContent = (0, import_react3.useCallback)((content, context) => {
|
|
600
|
+
let workingContent = content;
|
|
601
|
+
const buttonAttachments = [];
|
|
602
|
+
allActions.filter((a) => a.actionType === "tool").forEach((action) => {
|
|
603
|
+
try {
|
|
604
|
+
const regex = new RegExp(action.pattern, "gmi");
|
|
605
|
+
workingContent = workingContent.replace(regex, "");
|
|
606
|
+
} catch (e) {
|
|
607
|
+
console.warn("Invalid tool action regex", action.pattern, e);
|
|
608
|
+
}
|
|
609
|
+
});
|
|
610
|
+
if (context.type === "history") {
|
|
611
|
+
const { cleanedText } = processThinkingTags(workingContent);
|
|
612
|
+
workingContent = cleanedText;
|
|
613
|
+
}
|
|
614
|
+
const filteredActions = allActions.filter((a) => a.type !== "response" && a.actionType !== "tool");
|
|
615
|
+
console.log(`DEBUG: ${context.type} processing - filtered actions:`, filteredActions.length, "of", allActions.length);
|
|
616
|
+
filteredActions.forEach((action, actionIndex) => {
|
|
617
|
+
try {
|
|
618
|
+
const regex = new RegExp(action.pattern, "gmi");
|
|
619
|
+
const matches = workingContent.match(regex);
|
|
620
|
+
if (matches) {
|
|
621
|
+
console.log(`${context.type === "history" ? "History" : "Streaming"} processing: Found matches for pattern "${action.pattern}":`, matches, "in content:", workingContent.substring(0, 100));
|
|
622
|
+
}
|
|
623
|
+
workingContent = workingContent.replace(
|
|
624
|
+
regex,
|
|
625
|
+
(match, ...groups) => {
|
|
626
|
+
var _a2, _b, _c, _d, _e;
|
|
627
|
+
const actualMatch = groups[0] || match;
|
|
628
|
+
const restGroups = groups.slice(1);
|
|
629
|
+
let buttonId;
|
|
630
|
+
if (context.type === "history") {
|
|
631
|
+
const matchIndex = restGroups[restGroups.length - 2];
|
|
632
|
+
buttonId = `button-init-${context.historyIndex}-${actionIndex}-${matchIndex}`;
|
|
633
|
+
} else {
|
|
634
|
+
const offset = groups[groups.length - 2];
|
|
635
|
+
const matchOffset = typeof offset === "number" ? offset : 0;
|
|
636
|
+
const key = `${actionIndex}:${matchOffset}`;
|
|
637
|
+
let existingButtonId = actionMatchRegistry.current.get(key);
|
|
638
|
+
if (!existingButtonId) {
|
|
639
|
+
existingButtonId = `button-stable-${actionSequenceRef.current++}`;
|
|
640
|
+
actionMatchRegistry.current.set(key, existingButtonId);
|
|
641
|
+
}
|
|
642
|
+
buttonId = existingButtonId;
|
|
643
|
+
if (context.isProgressive && finalizedButtonsRef.current.has(buttonId)) {
|
|
644
|
+
return match;
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
const substituteTemplate = (template) => {
|
|
648
|
+
let html2 = template.replace(/\$match/gim, actualMatch);
|
|
649
|
+
restGroups.forEach((g, gi) => {
|
|
650
|
+
html2 = html2.replace(new RegExp(`\\$${gi + 1}`, "gmi"), g || "");
|
|
651
|
+
});
|
|
652
|
+
return html2;
|
|
653
|
+
};
|
|
654
|
+
let html = actualMatch;
|
|
655
|
+
if (action.type === "button" || action.type === "callback") {
|
|
656
|
+
if (context.type === "history") {
|
|
657
|
+
html = `<br /><button id="${buttonId}" ${action.style ? 'class="' + action.style + '"' : ""}>${(_a2 = action.markdown) != null ? _a2 : actualMatch}</button>`;
|
|
658
|
+
} else {
|
|
659
|
+
if (context.isProgressive && !context.isIdle) {
|
|
660
|
+
html = `<br /><button id="${buttonId}" data-pending="true" ${action.style ? 'class="' + action.style + '"' : ""}>${substituteTemplate((_b = action.markdown) != null ? _b : actualMatch)}</button>`;
|
|
661
|
+
} else {
|
|
662
|
+
html = `<br /><button id="${buttonId}" ${action.style ? 'class="' + action.style + '"' : ""}>${substituteTemplate((_c = action.markdown) != null ? _c : actualMatch)}</button>`;
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
} else if (action.type === "markdown" || action.type === "html") {
|
|
666
|
+
html = context.type === "history" ? (_d = action.markdown) != null ? _d : "" : substituteTemplate((_e = action.markdown) != null ? _e : "");
|
|
667
|
+
}
|
|
668
|
+
if (context.type === "history") {
|
|
669
|
+
html = html.replace(new RegExp("\\$match", "gmi"), actualMatch);
|
|
670
|
+
restGroups.forEach((group, gi) => {
|
|
671
|
+
html = html.replace(
|
|
672
|
+
new RegExp(`\\$${gi + 1}`, "gmi"),
|
|
673
|
+
group || ""
|
|
674
|
+
);
|
|
675
|
+
});
|
|
676
|
+
}
|
|
677
|
+
if (action.type === "button" || action.type === "callback") {
|
|
678
|
+
if (context.type === "history") {
|
|
679
|
+
buttonAttachments.push({
|
|
680
|
+
buttonId,
|
|
681
|
+
action,
|
|
682
|
+
match: actualMatch,
|
|
683
|
+
groups: restGroups
|
|
684
|
+
});
|
|
685
|
+
buttonActionRegistry.current.set(buttonId, {
|
|
686
|
+
action,
|
|
687
|
+
match: actualMatch,
|
|
688
|
+
groups: restGroups
|
|
689
|
+
});
|
|
690
|
+
} else {
|
|
691
|
+
if (!finalizedButtonsRef.current.has(buttonId)) {
|
|
692
|
+
deferredActionsRef.current.set(buttonId, {
|
|
693
|
+
action,
|
|
694
|
+
match: actualMatch,
|
|
695
|
+
groups: restGroups
|
|
696
|
+
});
|
|
697
|
+
if (!context.isProgressive) {
|
|
698
|
+
buttonAttachments.push({
|
|
699
|
+
buttonId,
|
|
700
|
+
action,
|
|
701
|
+
match: actualMatch,
|
|
702
|
+
groups: restGroups
|
|
703
|
+
});
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
return html;
|
|
709
|
+
}
|
|
710
|
+
);
|
|
711
|
+
} catch (e) {
|
|
712
|
+
console.warn("Invalid action regex", action.pattern, e);
|
|
713
|
+
}
|
|
714
|
+
});
|
|
715
|
+
return {
|
|
716
|
+
processedContent: workingContent,
|
|
717
|
+
buttonAttachments
|
|
718
|
+
};
|
|
719
|
+
}, [allActions, processThinkingTags, progressiveActions, idle]);
|
|
594
720
|
(0, import_react3.useEffect)(() => {
|
|
595
721
|
setShowEmailPanel(customerEmailCaptureMode !== "HIDE");
|
|
596
722
|
if (customerEmailCaptureMode === "REQUIRED") {
|
|
@@ -605,24 +731,12 @@ var ChatPanel = ({
|
|
|
605
731
|
if (action.type === "response" && action.pattern) {
|
|
606
732
|
const regex = new RegExp(action.pattern, "gi");
|
|
607
733
|
const matches = regex.exec(response);
|
|
608
|
-
console.log(
|
|
609
|
-
"action match",
|
|
610
|
-
matches,
|
|
611
|
-
action.pattern,
|
|
612
|
-
action.callback
|
|
613
|
-
);
|
|
614
734
|
if (matches && action.callback) {
|
|
615
735
|
action.callback(matches[0], matches.slice(1));
|
|
616
736
|
}
|
|
617
737
|
}
|
|
618
738
|
});
|
|
619
739
|
}
|
|
620
|
-
if (lastCallId && lastCallId !== "" && idle && Object.keys(history).length > 0) {
|
|
621
|
-
console.log("=== HISTORY FOR initialHistory prop ===");
|
|
622
|
-
console.log("Copy this object to use as initialHistory:");
|
|
623
|
-
console.log(JSON.stringify(history, null, 2));
|
|
624
|
-
console.log("=== END HISTORY ===");
|
|
625
|
-
}
|
|
626
740
|
if (responseCompleteCallback) {
|
|
627
741
|
if (lastCallId && lastCallId !== "" && idle)
|
|
628
742
|
responseCompleteCallback(lastCallId, lastPrompt != null ? lastPrompt : "", response);
|
|
@@ -659,13 +773,11 @@ var ChatPanel = ({
|
|
|
659
773
|
link.rel = "stylesheet";
|
|
660
774
|
link.setAttribute("data-source", "llmasaservice-ui");
|
|
661
775
|
document.head.appendChild(link);
|
|
662
|
-
console.log("Added CSS link", link);
|
|
663
776
|
} else {
|
|
664
777
|
const style = document.createElement("style");
|
|
665
778
|
style.textContent = cssUrl;
|
|
666
779
|
style.setAttribute("data-source", "llmasaservice-ui");
|
|
667
780
|
document.head.appendChild(style);
|
|
668
|
-
console.log("Added inline CSS");
|
|
669
781
|
}
|
|
670
782
|
}
|
|
671
783
|
return () => {
|
|
@@ -814,7 +926,6 @@ var ChatPanel = ({
|
|
|
814
926
|
});
|
|
815
927
|
}
|
|
816
928
|
} else {
|
|
817
|
-
console.warn("Invalid or missing callback in action:", action);
|
|
818
929
|
return null;
|
|
819
930
|
}
|
|
820
931
|
} else {
|
|
@@ -830,8 +941,14 @@ var ChatPanel = ({
|
|
|
830
941
|
};
|
|
831
942
|
(0, import_react3.useEffect)(() => {
|
|
832
943
|
const actionsString = typeof actions === "string" ? actions : JSON.stringify(actions);
|
|
944
|
+
const processedActions = getActionsArraySafely(actionsString);
|
|
945
|
+
console.log("DEBUG: Setting allActions:", {
|
|
946
|
+
actionsString,
|
|
947
|
+
processedActions,
|
|
948
|
+
totalActions: [...processedActions, anthropic_toolAction, openAI_toolAction, google_toolAction].length
|
|
949
|
+
});
|
|
833
950
|
setAllActions([
|
|
834
|
-
...
|
|
951
|
+
...processedActions,
|
|
835
952
|
anthropic_toolAction,
|
|
836
953
|
openAI_toolAction,
|
|
837
954
|
google_toolAction
|
|
@@ -852,63 +969,18 @@ var ChatPanel = ({
|
|
|
852
969
|
processedHistoryKeysRef.current.add(prompt);
|
|
853
970
|
return;
|
|
854
971
|
}
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
} catch (e) {
|
|
861
|
-
console.warn("Invalid tool action regex", action.pattern, e);
|
|
862
|
-
}
|
|
863
|
-
});
|
|
864
|
-
const { cleanedText } = processThinkingTags(workingContent);
|
|
865
|
-
workingContent = cleanedText;
|
|
866
|
-
allActions.filter((a) => a.type !== "response" && a.actionType !== "tool").forEach((action, actionIndex) => {
|
|
867
|
-
try {
|
|
868
|
-
const regex = new RegExp(action.pattern, "gmi");
|
|
869
|
-
workingContent = workingContent.replace(
|
|
870
|
-
regex,
|
|
871
|
-
(match, ...groups) => {
|
|
872
|
-
var _a2, _b;
|
|
873
|
-
const matchIndex = groups[groups.length - 2];
|
|
874
|
-
const buttonId = `button-init-${historyIndex}-${actionIndex}-${matchIndex}`;
|
|
875
|
-
let html = match;
|
|
876
|
-
if (action.type === "button" || action.type === "callback") {
|
|
877
|
-
html = `<br /><button id="${buttonId}" ${action.style ? 'class="' + action.style + '"' : ""}>${(_a2 = action.markdown) != null ? _a2 : match}</button>`;
|
|
878
|
-
} else if (action.type === "markdown" || action.type === "html") {
|
|
879
|
-
html = (_b = action.markdown) != null ? _b : "";
|
|
880
|
-
}
|
|
881
|
-
html = html.replace(new RegExp("\\$match", "gmi"), match);
|
|
882
|
-
groups.forEach((group, gi) => {
|
|
883
|
-
html = html.replace(
|
|
884
|
-
new RegExp(`\\$${gi + 1}`, "gmi"),
|
|
885
|
-
group
|
|
886
|
-
);
|
|
887
|
-
});
|
|
888
|
-
if (action.type === "button" || action.type === "callback") {
|
|
889
|
-
newButtonAttachments.push({
|
|
890
|
-
buttonId,
|
|
891
|
-
action,
|
|
892
|
-
match,
|
|
893
|
-
groups
|
|
894
|
-
});
|
|
895
|
-
buttonActionRegistry.current.set(buttonId, {
|
|
896
|
-
action,
|
|
897
|
-
match,
|
|
898
|
-
groups
|
|
899
|
-
});
|
|
900
|
-
}
|
|
901
|
-
return html;
|
|
902
|
-
}
|
|
903
|
-
);
|
|
904
|
-
} catch (e) {
|
|
905
|
-
console.warn("Invalid action regex", action.pattern, e);
|
|
972
|
+
const { processedContent, buttonAttachments } = processActionsOnContent(
|
|
973
|
+
entry.content,
|
|
974
|
+
{
|
|
975
|
+
type: "history",
|
|
976
|
+
historyIndex
|
|
906
977
|
}
|
|
907
|
-
|
|
908
|
-
if (
|
|
909
|
-
updated[prompt] = __spreadProps(__spreadValues({}, entry), { content:
|
|
978
|
+
);
|
|
979
|
+
if (processedContent !== entry.content) {
|
|
980
|
+
updated[prompt] = __spreadProps(__spreadValues({}, entry), { content: processedContent });
|
|
910
981
|
changed = true;
|
|
911
982
|
}
|
|
983
|
+
newButtonAttachments.push(...buttonAttachments);
|
|
912
984
|
processedHistoryKeysRef.current.add(prompt);
|
|
913
985
|
});
|
|
914
986
|
if (newButtonAttachments.length > 0) {
|
|
@@ -928,7 +1000,6 @@ var ChatPanel = ({
|
|
|
928
1000
|
if (!requests || requests.length === 0)
|
|
929
1001
|
requests = pendingToolRequestsRef.current;
|
|
930
1002
|
if (requests.length === 0) return;
|
|
931
|
-
console.log("processGivenToolRequests", requests);
|
|
932
1003
|
setIsLoading(true);
|
|
933
1004
|
const toolsToProcess = [...requests];
|
|
934
1005
|
setPendingToolRequests([]);
|
|
@@ -973,7 +1044,6 @@ var ChatPanel = ({
|
|
|
973
1044
|
var _a2;
|
|
974
1045
|
if (!item || !item.req) return null;
|
|
975
1046
|
const req = item.req;
|
|
976
|
-
console.log(`Processing tool ${req.toolName}`);
|
|
977
1047
|
const mcpTool = toolList.find((tool) => tool.name === req.toolName);
|
|
978
1048
|
if (!mcpTool) {
|
|
979
1049
|
console.error(`Tool ${req.toolName} not found in tool list`);
|
|
@@ -1120,7 +1190,6 @@ var ChatPanel = ({
|
|
|
1120
1190
|
});
|
|
1121
1191
|
}
|
|
1122
1192
|
if (toolRequests.length > 0) {
|
|
1123
|
-
console.log("toolRequests", toolRequests);
|
|
1124
1193
|
setPendingToolRequests(toolRequests);
|
|
1125
1194
|
} else {
|
|
1126
1195
|
setPendingToolRequests([]);
|
|
@@ -1135,66 +1204,16 @@ var ChatPanel = ({
|
|
|
1135
1204
|
const { cleanedText, thinkingBlocks: newThinkingBlocks } = processThinkingTags(responseWithoutTools);
|
|
1136
1205
|
setThinkingBlocks(newThinkingBlocks);
|
|
1137
1206
|
setCurrentThinkingIndex(Math.max(0, newThinkingBlocks.length - 1));
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
(match, ...groups) => {
|
|
1149
|
-
var _a2, _b, _c;
|
|
1150
|
-
const offset = groups[groups.length - 2];
|
|
1151
|
-
const matchOffset = typeof offset === "number" ? offset : 0;
|
|
1152
|
-
const key = `${actionIndex}:${matchOffset}`;
|
|
1153
|
-
let buttonId = actionMatchRegistry.current.get(key);
|
|
1154
|
-
if (!buttonId) {
|
|
1155
|
-
buttonId = `button-stable-${actionSequenceRef.current++}`;
|
|
1156
|
-
actionMatchRegistry.current.set(key, buttonId);
|
|
1157
|
-
}
|
|
1158
|
-
if (progressiveActions && finalizedButtonsRef.current.has(buttonId)) {
|
|
1159
|
-
return match;
|
|
1160
|
-
}
|
|
1161
|
-
const substituteTemplate = (template) => {
|
|
1162
|
-
let html = template.replace(/\$match/gim, match);
|
|
1163
|
-
groups.forEach((g, gi) => {
|
|
1164
|
-
html = html.replace(new RegExp(`\\$${gi + 1}`, "gmi"), g);
|
|
1165
|
-
});
|
|
1166
|
-
return html;
|
|
1167
|
-
};
|
|
1168
|
-
let htmlOut = match;
|
|
1169
|
-
if (action.type === "button" || action.type === "callback") {
|
|
1170
|
-
if (progressiveActions && !idle) {
|
|
1171
|
-
htmlOut = `<br /><button id="${buttonId}" data-pending="true" ${action.style ? 'class="' + action.style + '"' : ""}>${substituteTemplate((_a2 = action.markdown) != null ? _a2 : match)}</button>`;
|
|
1172
|
-
} else {
|
|
1173
|
-
htmlOut = `<br /><button id="${buttonId}" ${action.style ? 'class="' + action.style + '"' : ""}>${substituteTemplate((_b = action.markdown) != null ? _b : match)}</button>`;
|
|
1174
|
-
}
|
|
1175
|
-
} else if (action.type === "markdown" || action.type === "html") {
|
|
1176
|
-
htmlOut = substituteTemplate((_c = action.markdown) != null ? _c : "");
|
|
1177
|
-
}
|
|
1178
|
-
if ((action.type === "button" || action.type === "callback") && !finalizedButtonsRef.current.has(buttonId)) {
|
|
1179
|
-
deferredActionsRef.current.set(buttonId, {
|
|
1180
|
-
action,
|
|
1181
|
-
match,
|
|
1182
|
-
groups
|
|
1183
|
-
});
|
|
1184
|
-
if (!progressiveActions) {
|
|
1185
|
-
setPendingButtonAttachments((prev) => [
|
|
1186
|
-
...prev,
|
|
1187
|
-
{ buttonId, action, match, groups }
|
|
1188
|
-
]);
|
|
1189
|
-
}
|
|
1190
|
-
}
|
|
1191
|
-
return htmlOut;
|
|
1192
|
-
}
|
|
1193
|
-
);
|
|
1194
|
-
} catch (e) {
|
|
1195
|
-
console.warn("Invalid action regex", action.pattern, e);
|
|
1196
|
-
}
|
|
1197
|
-
});
|
|
1207
|
+
const { processedContent: newResponse, buttonAttachments } = processActionsOnContent(
|
|
1208
|
+
cleanedText,
|
|
1209
|
+
{
|
|
1210
|
+
type: "streaming",
|
|
1211
|
+
isProgressive: progressiveActions,
|
|
1212
|
+
isIdle: idle
|
|
1213
|
+
}
|
|
1214
|
+
);
|
|
1215
|
+
if (!progressiveActions && buttonAttachments.length > 0) {
|
|
1216
|
+
setPendingButtonAttachments((prev) => [...prev, ...buttonAttachments]);
|
|
1198
1217
|
}
|
|
1199
1218
|
setHistory((prevHistory) => {
|
|
1200
1219
|
const existingEntry = prevHistory[lastKey != null ? lastKey : ""] || {
|
|
@@ -1423,16 +1442,50 @@ var ChatPanel = ({
|
|
|
1423
1442
|
textarea.style.height = "auto";
|
|
1424
1443
|
const minHeight = 40;
|
|
1425
1444
|
const maxHeight = 120;
|
|
1445
|
+
const effectiveMinHeight = userResizedHeight ? Math.max(userResizedHeight, minHeight) : minHeight;
|
|
1446
|
+
const effectiveMaxHeight = userResizedHeight ? Number.MAX_SAFE_INTEGER : maxHeight;
|
|
1426
1447
|
const newHeight = Math.min(
|
|
1427
|
-
Math.max(textarea.scrollHeight,
|
|
1428
|
-
|
|
1448
|
+
Math.max(textarea.scrollHeight, effectiveMinHeight),
|
|
1449
|
+
effectiveMaxHeight
|
|
1429
1450
|
);
|
|
1430
1451
|
textarea.style.height = `${newHeight}px`;
|
|
1431
1452
|
}
|
|
1432
|
-
}, []);
|
|
1453
|
+
}, [userResizedHeight]);
|
|
1433
1454
|
(0, import_react3.useEffect)(() => {
|
|
1434
1455
|
autoResizeTextarea();
|
|
1435
1456
|
}, [nextPrompt, autoResizeTextarea]);
|
|
1457
|
+
(0, import_react3.useEffect)(() => {
|
|
1458
|
+
if (!textareaRef.current) return;
|
|
1459
|
+
const textarea = textareaRef.current;
|
|
1460
|
+
let heightBeforeInteraction = textarea.clientHeight;
|
|
1461
|
+
let userIsInteracting = false;
|
|
1462
|
+
const handleMouseDown = () => {
|
|
1463
|
+
heightBeforeInteraction = textarea.clientHeight;
|
|
1464
|
+
userIsInteracting = true;
|
|
1465
|
+
};
|
|
1466
|
+
const handleMouseUp = () => {
|
|
1467
|
+
if (userIsInteracting) {
|
|
1468
|
+
const currentHeight = textarea.clientHeight;
|
|
1469
|
+
if (Math.abs(currentHeight - heightBeforeInteraction) > 5) {
|
|
1470
|
+
setUserResizedHeight(currentHeight);
|
|
1471
|
+
}
|
|
1472
|
+
userIsInteracting = false;
|
|
1473
|
+
}
|
|
1474
|
+
};
|
|
1475
|
+
const handleGlobalMouseUp = () => {
|
|
1476
|
+
if (userIsInteracting) {
|
|
1477
|
+
handleMouseUp();
|
|
1478
|
+
}
|
|
1479
|
+
};
|
|
1480
|
+
textarea.addEventListener("mousedown", handleMouseDown);
|
|
1481
|
+
textarea.addEventListener("mouseup", handleMouseUp);
|
|
1482
|
+
document.addEventListener("mouseup", handleGlobalMouseUp);
|
|
1483
|
+
return () => {
|
|
1484
|
+
textarea.removeEventListener("mousedown", handleMouseDown);
|
|
1485
|
+
textarea.removeEventListener("mouseup", handleMouseUp);
|
|
1486
|
+
document.removeEventListener("mouseup", handleGlobalMouseUp);
|
|
1487
|
+
};
|
|
1488
|
+
}, []);
|
|
1436
1489
|
(0, import_react3.useEffect)(() => {
|
|
1437
1490
|
if (initialPrompt && initialPrompt !== "") {
|
|
1438
1491
|
if (initialPrompt !== lastPrompt) {
|
|
@@ -1500,7 +1553,6 @@ var ChatPanel = ({
|
|
|
1500
1553
|
}
|
|
1501
1554
|
}, [history, historyChangedCallback]);
|
|
1502
1555
|
(0, import_react3.useEffect)(() => {
|
|
1503
|
-
console.log("followOnPromptChanged detected");
|
|
1504
1556
|
if (followOnPrompt && followOnPrompt !== "") {
|
|
1505
1557
|
continueChat(followOnPrompt);
|
|
1506
1558
|
}
|
|
@@ -1549,7 +1601,6 @@ var ChatPanel = ({
|
|
|
1549
1601
|
return res.json();
|
|
1550
1602
|
})).then((newConvo) => {
|
|
1551
1603
|
if (newConvo == null ? void 0 : newConvo.id) {
|
|
1552
|
-
console.log("new conversation created", newConvo.id);
|
|
1553
1604
|
setCurrentConversation(newConvo.id);
|
|
1554
1605
|
return newConvo.id;
|
|
1555
1606
|
}
|
|
@@ -1593,11 +1644,6 @@ var ChatPanel = ({
|
|
|
1593
1644
|
if (needsUpdate && (updatedValues.customer_id !== currentCustomer.customer_id || updatedValues.customer_user_email !== currentCustomer.customer_user_email)) {
|
|
1594
1645
|
ensureConversation().then((convId) => {
|
|
1595
1646
|
if (convId && convId !== "") {
|
|
1596
|
-
console.log(
|
|
1597
|
-
"updating conversation with customer id and email",
|
|
1598
|
-
convId,
|
|
1599
|
-
updatedValues
|
|
1600
|
-
);
|
|
1601
1647
|
fetch(`${publicAPIUrl}/conversations/${convId}`, {
|
|
1602
1648
|
method: "POST",
|
|
1603
1649
|
headers: {
|
|
@@ -1617,7 +1663,6 @@ var ChatPanel = ({
|
|
|
1617
1663
|
}
|
|
1618
1664
|
}, [currentCustomer, project_id, agent, publicAPIUrl, emailInput]);
|
|
1619
1665
|
const continueChat = (suggestion) => {
|
|
1620
|
-
console.log("continueChat called");
|
|
1621
1666
|
setThinkingBlocks([]);
|
|
1622
1667
|
setCurrentThinkingIndex(0);
|
|
1623
1668
|
if (emailInput && isEmailAddress(emailInput) && !emailInputSet) {
|
|
@@ -1631,7 +1676,6 @@ var ChatPanel = ({
|
|
|
1631
1676
|
}
|
|
1632
1677
|
ensureConversation().then((convId) => {
|
|
1633
1678
|
var _a2, _b, _c;
|
|
1634
|
-
console.log("current customer", currentCustomer);
|
|
1635
1679
|
if (!idle) {
|
|
1636
1680
|
stop(lastController);
|
|
1637
1681
|
setHistory((prevHistory) => {
|
|
@@ -1700,7 +1744,6 @@ var ChatPanel = ({
|
|
|
1700
1744
|
}
|
|
1701
1745
|
}
|
|
1702
1746
|
}
|
|
1703
|
-
console.log("Sending for conversation", convId);
|
|
1704
1747
|
const controller = new AbortController();
|
|
1705
1748
|
send(
|
|
1706
1749
|
nextPromptToSend,
|
|
@@ -2427,7 +2470,7 @@ var ChatPanel = ({
|
|
|
2427
2470
|
"textarea",
|
|
2428
2471
|
{
|
|
2429
2472
|
ref: textareaRef,
|
|
2430
|
-
className:
|
|
2473
|
+
className: `chat-input${userResizedHeight ? " user-resized" : ""}`,
|
|
2431
2474
|
placeholder,
|
|
2432
2475
|
value: nextPrompt,
|
|
2433
2476
|
onChange: (e) => {
|
|
@@ -2446,7 +2489,14 @@ var ChatPanel = ({
|
|
|
2446
2489
|
}
|
|
2447
2490
|
}
|
|
2448
2491
|
},
|
|
2449
|
-
|
|
2492
|
+
onDoubleClick: () => {
|
|
2493
|
+
if (userResizedHeight) {
|
|
2494
|
+
setUserResizedHeight(null);
|
|
2495
|
+
setTimeout(autoResizeTextarea, 0);
|
|
2496
|
+
}
|
|
2497
|
+
},
|
|
2498
|
+
disabled: isDisabledDueToNoEmail(),
|
|
2499
|
+
title: userResizedHeight ? "Double-click to reset to auto-resize" : "Drag bottom-right corner to manually resize"
|
|
2450
2500
|
}
|
|
2451
2501
|
), /* @__PURE__ */ import_react3.default.createElement(
|
|
2452
2502
|
"button",
|
|
@@ -2774,8 +2824,8 @@ var AgentPanel = ({
|
|
|
2774
2824
|
markdownClass = null,
|
|
2775
2825
|
width,
|
|
2776
2826
|
height,
|
|
2777
|
-
url = "https://chat.llmasaservice.io",
|
|
2778
|
-
|
|
2827
|
+
//url = "https://chat.llmasaservice.io",
|
|
2828
|
+
url = "https://chat.llmasaservice.io/dev",
|
|
2779
2829
|
//scrollToEnd = false,
|
|
2780
2830
|
//initialMessage = "",
|
|
2781
2831
|
prismStyle = null,
|
|
@@ -2870,6 +2920,10 @@ var AgentPanel = ({
|
|
|
2870
2920
|
}
|
|
2871
2921
|
}, [agent, url]);
|
|
2872
2922
|
const getActionsArraySafely = (actionsString) => {
|
|
2923
|
+
console.log("AgentPanel getActionsArraySafely called with:", {
|
|
2924
|
+
actionsString,
|
|
2925
|
+
type: typeof actionsString
|
|
2926
|
+
});
|
|
2873
2927
|
let actions2 = [];
|
|
2874
2928
|
if (actionsString && actionsString !== "") {
|
|
2875
2929
|
try {
|
|
@@ -2877,7 +2931,9 @@ var AgentPanel = ({
|
|
|
2877
2931
|
if (!Array.isArray(actions2)) {
|
|
2878
2932
|
throw new Error("Parsed actions is not an array");
|
|
2879
2933
|
}
|
|
2934
|
+
console.log("AgentPanel parsed actions:", actions2);
|
|
2880
2935
|
} catch (error) {
|
|
2936
|
+
console.log("AgentPanel actions parsing error:", error);
|
|
2881
2937
|
actions2 = [];
|
|
2882
2938
|
}
|
|
2883
2939
|
}
|
|
@@ -2906,7 +2962,10 @@ var AgentPanel = ({
|
|
|
2906
2962
|
actions: [
|
|
2907
2963
|
...actions,
|
|
2908
2964
|
...getActionsArraySafely(agentData == null ? void 0 : agentData.displayActions)
|
|
2909
|
-
],
|
|
2965
|
+
].map((action, index) => {
|
|
2966
|
+
console.log(`AgentPanel action ${index}:`, action);
|
|
2967
|
+
return action;
|
|
2968
|
+
}),
|
|
2910
2969
|
followOnPrompt,
|
|
2911
2970
|
agent,
|
|
2912
2971
|
placeholder: (_j = agentData == null ? void 0 : agentData.displayPlaceholder) != null ? _j : "Type a message",
|