@contentgrowth/llm-service 0.9.2 → 0.9.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/ui/react/components/index.cjs +375 -123
- package/dist/ui/react/components/index.cjs.map +1 -1
- package/dist/ui/react/components/index.d.cts +12 -1
- package/dist/ui/react/components/index.d.ts +12 -1
- package/dist/ui/react/components/index.js +370 -119
- package/dist/ui/react/components/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -149,7 +149,7 @@ function ChatHeader({
|
|
|
149
149
|
|
|
150
150
|
// src/ui/react/components/ChatInputArea.tsx
|
|
151
151
|
import { useState as useState3, useRef as useRef3, useImperativeHandle, forwardRef, useEffect as useEffect3, useCallback as useCallback3, useLayoutEffect } from "react";
|
|
152
|
-
import { MicrophoneIcon, StopIcon, PaperAirplaneIcon } from "@heroicons/react/24/outline";
|
|
152
|
+
import { MicrophoneIcon, StopIcon, PaperAirplaneIcon, XMarkIcon } from "@heroicons/react/24/outline";
|
|
153
153
|
|
|
154
154
|
// src/ui/react/hooks/useSpeechRecognition.ts
|
|
155
155
|
import { useState, useEffect, useCallback, useRef } from "react";
|
|
@@ -387,6 +387,42 @@ var ChatInputArea = forwardRef(({
|
|
|
387
387
|
const [isTranscribing, setIsTranscribing] = useState3(false);
|
|
388
388
|
const [voiceError, setVoiceError] = useState3(null);
|
|
389
389
|
const [isFocused, setIsFocused] = useState3(false);
|
|
390
|
+
const [showDebug, setShowDebug] = useState3(false);
|
|
391
|
+
const [logs, setLogs] = useState3([]);
|
|
392
|
+
const tapCountRef = useRef3({ count: 0, lastTap: 0 });
|
|
393
|
+
useEffect3(() => {
|
|
394
|
+
const originalLog = console.log;
|
|
395
|
+
const originalWarn = console.warn;
|
|
396
|
+
const originalError = console.error;
|
|
397
|
+
const addLog = (type, args) => {
|
|
398
|
+
try {
|
|
399
|
+
const msg = args.map((arg) => {
|
|
400
|
+
if (arg instanceof Error) return `${arg.name}: ${arg.message}`;
|
|
401
|
+
if (typeof arg === "object") return JSON.stringify(arg);
|
|
402
|
+
return String(arg);
|
|
403
|
+
}).join(" ");
|
|
404
|
+
setLogs((prev) => [`[${type}] ${msg}`, ...prev].slice(0, 50));
|
|
405
|
+
} catch (e) {
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
console.log = (...args) => {
|
|
409
|
+
originalLog(...args);
|
|
410
|
+
addLog("LOG", args);
|
|
411
|
+
};
|
|
412
|
+
console.warn = (...args) => {
|
|
413
|
+
originalWarn(...args);
|
|
414
|
+
addLog("WRN", args);
|
|
415
|
+
};
|
|
416
|
+
console.error = (...args) => {
|
|
417
|
+
originalError(...args);
|
|
418
|
+
addLog("ERR", args);
|
|
419
|
+
};
|
|
420
|
+
return () => {
|
|
421
|
+
console.log = originalLog;
|
|
422
|
+
console.warn = originalWarn;
|
|
423
|
+
console.error = originalError;
|
|
424
|
+
};
|
|
425
|
+
}, []);
|
|
390
426
|
const textareaRef = useRef3(null);
|
|
391
427
|
const measurementRef = useRef3(null);
|
|
392
428
|
const pendingSelectionRef = useRef3(null);
|
|
@@ -456,6 +492,12 @@ var ChatInputArea = forwardRef(({
|
|
|
456
492
|
(_b2 = (_a2 = voiceConfigRef.current) == null ? void 0 : _a2.onVoiceEnd) == null ? void 0 : _b2.call(_a2);
|
|
457
493
|
}, []);
|
|
458
494
|
const nativeSpeech = useSpeechRecognition(handleVoiceResult, handleVoiceEnd, voiceConfig == null ? void 0 : voiceConfig.language);
|
|
495
|
+
useEffect3(() => {
|
|
496
|
+
if (nativeSpeech.error) {
|
|
497
|
+
setVoiceError(nativeSpeech.error);
|
|
498
|
+
console.error("[ChatInputArea] Native Speech Error:", nativeSpeech.error);
|
|
499
|
+
}
|
|
500
|
+
}, [nativeSpeech.error]);
|
|
459
501
|
const customRecorder = useAudioRecorder(async (blob) => {
|
|
460
502
|
var _a2, _b2, _c2;
|
|
461
503
|
setVoiceTrigger(null);
|
|
@@ -569,20 +611,40 @@ var ChatInputArea = forwardRef(({
|
|
|
569
611
|
if (!showInputForm) {
|
|
570
612
|
return null;
|
|
571
613
|
}
|
|
572
|
-
return /* @__PURE__ */ jsxs3("div", { className: "flex flex-col w-full", children: [
|
|
614
|
+
return /* @__PURE__ */ jsxs3("div", { className: "flex flex-col w-full relative", children: [
|
|
615
|
+
showDebug && /* @__PURE__ */ jsxs3("div", { className: "absolute bottom-full left-0 right-0 mb-2 p-2 bg-black/80 text-green-400 text-xs font-mono h-48 overflow-y-auto rounded z-50 pointer-events-auto", children: [
|
|
616
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex justify-between items-center bg-gray-800 p-1 mb-1", children: [
|
|
617
|
+
/* @__PURE__ */ jsx5("span", { children: "Debug Logs" }),
|
|
618
|
+
/* @__PURE__ */ jsx5("button", { onClick: () => setShowDebug(false), className: "text-white hover:text-red-400", children: /* @__PURE__ */ jsx5(XMarkIcon, { className: "w-4 h-4" }) })
|
|
619
|
+
] }),
|
|
620
|
+
logs.map((log, i) => /* @__PURE__ */ jsx5("div", { className: "mb-0.5 border-b border-gray-700/50 pb-0.5 break-all", children: log }, i)),
|
|
621
|
+
logs.length === 0 && /* @__PURE__ */ jsx5("div", { children: "No logs yet..." })
|
|
622
|
+
] }),
|
|
573
623
|
/* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-2", children: [
|
|
574
624
|
voiceConfig && /* @__PURE__ */ jsx5(
|
|
575
625
|
"button",
|
|
576
626
|
{
|
|
577
627
|
type: "button",
|
|
578
628
|
onClick: () => {
|
|
629
|
+
const now = Date.now();
|
|
630
|
+
if (now - tapCountRef.current.lastTap < 500) {
|
|
631
|
+
tapCountRef.current.count++;
|
|
632
|
+
} else {
|
|
633
|
+
tapCountRef.current.count = 1;
|
|
634
|
+
}
|
|
635
|
+
tapCountRef.current.lastTap = now;
|
|
636
|
+
if (tapCountRef.current.count >= 5) {
|
|
637
|
+
setShowDebug((prev) => !prev);
|
|
638
|
+
tapCountRef.current.count = 0;
|
|
639
|
+
return;
|
|
640
|
+
}
|
|
579
641
|
if (voiceTrigger) {
|
|
580
642
|
stopRecording();
|
|
581
643
|
} else if (!isTranscribing) {
|
|
582
644
|
startRecording("click");
|
|
583
645
|
}
|
|
584
646
|
},
|
|
585
|
-
className: `mb-1 p-2 rounded-full transition-all duration-300 flex-shrink-0 border ${
|
|
647
|
+
className: `mb-1 p-2 rounded-full transition-all duration-300 flex-shrink-0 border ${isTranscribing ? "text-white border-indigo-500 bg-indigo-600 scale-110 shadow-lg" : voiceTrigger ? "text-white border-orange-400 bg-orange-500 scale-110 shadow-lg" : "text-gray-500 border-gray-300 bg-white hover:text-gray-700 hover:bg-gray-100"} ${voiceTrigger ? "animate-pulse" : ""} ${isTranscribing ? "cursor-wait" : ""}`,
|
|
586
648
|
disabled: isTranscribing,
|
|
587
649
|
title: isTranscribing ? "Transcribing..." : voiceTrigger ? "Stop Recording" : "Start Voice Input",
|
|
588
650
|
children: isTranscribing ? /* @__PURE__ */ jsx5("div", { className: "animate-spin w-5 h-5 flex items-center justify-center", children: /* @__PURE__ */ jsxs3("svg", { className: "w-5 h-5 text-white", viewBox: "0 0 24 24", children: [
|
|
@@ -685,26 +747,214 @@ var ChatInputArea = forwardRef(({
|
|
|
685
747
|
)
|
|
686
748
|
] }),
|
|
687
749
|
inputHint && /* @__PURE__ */ jsx5("div", { className: "text-sm text-red-500 bg-red-50 py-1 px-4 rounded-lg mt-1", children: inputHint }),
|
|
688
|
-
/* @__PURE__ */ jsx5("div", { className: "ml-[46px] mb-2 mt-0.5 min-h-[0.75rem]", style: { marginLeft: "48px" }, children: /* @__PURE__ */ jsx5("p", { className: `text-[10px] leading-tight transition-all duration-200 ${voiceError ? "text-red-500" :
|
|
750
|
+
/* @__PURE__ */ jsx5("div", { className: "ml-[46px] mb-2 mt-0.5 min-h-[0.75rem]", style: { marginLeft: "48px" }, children: /* @__PURE__ */ jsx5("p", { className: `text-[10px] leading-tight transition-all duration-200 ${voiceError ? "text-red-500" : isTranscribing ? "text-indigo-600 font-bold" : voiceTrigger ? "text-orange-600 font-medium" : "text-gray-400"}`, children: voiceError ? /* @__PURE__ */ jsxs3("span", { className: "flex items-center gap-1 font-semibold italic", children: [
|
|
689
751
|
"Error: ",
|
|
690
752
|
voiceError
|
|
691
|
-
] }) : isTranscribing ? "Transcribing, please wait..." : voiceTrigger ? "Listening... tap mic icon again to stop" : hintText || (voiceConfig ? "Type in text or tap mic icon to talk" : "Type your message...") }) })
|
|
753
|
+
] }) : isTranscribing ? "Transcribing... please wait" : voiceTrigger ? "Transcribing, please wait..." : voiceTrigger ? "Listening... tap mic icon again to stop" : hintText || (voiceConfig ? "Type in text or tap mic icon to talk" : "Type your message...") }) })
|
|
692
754
|
] });
|
|
693
755
|
});
|
|
694
756
|
ChatInputArea.displayName = "ChatInputArea";
|
|
695
757
|
|
|
758
|
+
// src/ui/react/components/TapToTalk.tsx
|
|
759
|
+
import React3, { useState as useState4, useCallback as useCallback4, useRef as useRef4 } from "react";
|
|
760
|
+
import { MicrophoneIcon as MicrophoneIcon2, XMarkIcon as XMarkIcon2 } from "@heroicons/react/24/outline";
|
|
761
|
+
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
762
|
+
var TapToTalk = ({
|
|
763
|
+
onResult,
|
|
764
|
+
voiceConfig: propVoiceConfig,
|
|
765
|
+
className = "",
|
|
766
|
+
disabled = false,
|
|
767
|
+
tooltip = "Tap to speak",
|
|
768
|
+
onFocusTarget,
|
|
769
|
+
accentColor = "bg-emerald-600"
|
|
770
|
+
}) => {
|
|
771
|
+
var _a;
|
|
772
|
+
const globalConfig = useChatConfig();
|
|
773
|
+
const voiceConfig = propVoiceConfig || ((_a = globalConfig.voice) == null ? void 0 : _a.config);
|
|
774
|
+
const [isTranscribing, setIsTranscribing] = useState4(false);
|
|
775
|
+
const [voiceTrigger, setVoiceTrigger] = useState4(null);
|
|
776
|
+
const [errorMsg, setErrorMsg] = useState4(null);
|
|
777
|
+
const [showDebug, setShowDebug] = useState4(false);
|
|
778
|
+
const [logs, setLogs] = useState4([]);
|
|
779
|
+
const tapCountRef = useRef4({ count: 0, lastTap: 0 });
|
|
780
|
+
React3.useEffect(() => {
|
|
781
|
+
const originalLog = console.log;
|
|
782
|
+
const originalWarn = console.warn;
|
|
783
|
+
const originalError = console.error;
|
|
784
|
+
const addLog = (type, args) => {
|
|
785
|
+
try {
|
|
786
|
+
const msg = args.map((arg) => {
|
|
787
|
+
if (arg instanceof Error) return `${arg.name}: ${arg.message}`;
|
|
788
|
+
if (typeof arg === "object") return JSON.stringify(arg);
|
|
789
|
+
return String(arg);
|
|
790
|
+
}).join(" ");
|
|
791
|
+
setLogs((prev) => [`[${type}] ${msg}`, ...prev].slice(0, 50));
|
|
792
|
+
} catch (e) {
|
|
793
|
+
}
|
|
794
|
+
};
|
|
795
|
+
console.log = (...args) => {
|
|
796
|
+
originalLog(...args);
|
|
797
|
+
addLog("LOG", args);
|
|
798
|
+
};
|
|
799
|
+
console.warn = (...args) => {
|
|
800
|
+
originalWarn(...args);
|
|
801
|
+
addLog("WRN", args);
|
|
802
|
+
};
|
|
803
|
+
console.error = (...args) => {
|
|
804
|
+
originalError(...args);
|
|
805
|
+
addLog("ERR", args);
|
|
806
|
+
};
|
|
807
|
+
return () => {
|
|
808
|
+
console.log = originalLog;
|
|
809
|
+
console.warn = originalWarn;
|
|
810
|
+
console.error = originalError;
|
|
811
|
+
};
|
|
812
|
+
}, []);
|
|
813
|
+
const handleVoiceResult = useCallback4((text, isFinal) => {
|
|
814
|
+
if (isFinal) {
|
|
815
|
+
onResult(text);
|
|
816
|
+
setErrorMsg(null);
|
|
817
|
+
setVoiceTrigger(null);
|
|
818
|
+
}
|
|
819
|
+
}, [onResult]);
|
|
820
|
+
const handleVoiceEnd = useCallback4(() => {
|
|
821
|
+
setVoiceTrigger(null);
|
|
822
|
+
}, []);
|
|
823
|
+
const nativeSpeech = useSpeechRecognition(handleVoiceResult, handleVoiceEnd, voiceConfig == null ? void 0 : voiceConfig.language);
|
|
824
|
+
React3.useEffect(() => {
|
|
825
|
+
if (nativeSpeech.error) {
|
|
826
|
+
setErrorMsg(nativeSpeech.error);
|
|
827
|
+
console.error("[TapToTalk] Native Speech Error:", nativeSpeech.error);
|
|
828
|
+
}
|
|
829
|
+
}, [nativeSpeech.error]);
|
|
830
|
+
const customRecorder = useAudioRecorder(async (blob) => {
|
|
831
|
+
setVoiceTrigger(null);
|
|
832
|
+
setIsTranscribing(true);
|
|
833
|
+
setErrorMsg(null);
|
|
834
|
+
if (blob.type === "audio/simulated") {
|
|
835
|
+
console.log("[TapToTalk] Handling simulated audio capture");
|
|
836
|
+
await new Promise((resolve) => setTimeout(resolve, 1500));
|
|
837
|
+
onResult("This is a simulated transcription for development testing.");
|
|
838
|
+
setIsTranscribing(false);
|
|
839
|
+
return;
|
|
840
|
+
}
|
|
841
|
+
if ((voiceConfig == null ? void 0 : voiceConfig.mode) === "custom" && voiceConfig.onAudioCapture) {
|
|
842
|
+
try {
|
|
843
|
+
const text = await voiceConfig.onAudioCapture(blob);
|
|
844
|
+
if (text) onResult(text);
|
|
845
|
+
} catch (error) {
|
|
846
|
+
console.error("[TapToTalk] Custom transcription failed:", error);
|
|
847
|
+
setErrorMsg(error.message || "Transcription failed");
|
|
848
|
+
} finally {
|
|
849
|
+
setIsTranscribing(false);
|
|
850
|
+
}
|
|
851
|
+
} else {
|
|
852
|
+
setIsTranscribing(false);
|
|
853
|
+
}
|
|
854
|
+
});
|
|
855
|
+
const isListening = !!voiceTrigger || nativeSpeech.isListening || customRecorder.isRecording;
|
|
856
|
+
const isActive = isListening || isTranscribing;
|
|
857
|
+
const toggleVoice = async () => {
|
|
858
|
+
const now = Date.now();
|
|
859
|
+
if (now - tapCountRef.current.lastTap < 500) {
|
|
860
|
+
tapCountRef.current.count++;
|
|
861
|
+
} else {
|
|
862
|
+
tapCountRef.current.count = 1;
|
|
863
|
+
}
|
|
864
|
+
tapCountRef.current.lastTap = now;
|
|
865
|
+
if (tapCountRef.current.count >= 5) {
|
|
866
|
+
setShowDebug((prev) => !prev);
|
|
867
|
+
tapCountRef.current.count = 0;
|
|
868
|
+
return;
|
|
869
|
+
}
|
|
870
|
+
if (isActive) {
|
|
871
|
+
if (isTranscribing && !isListening) return;
|
|
872
|
+
if ((voiceConfig == null ? void 0 : voiceConfig.mode) === "native") {
|
|
873
|
+
nativeSpeech.stop();
|
|
874
|
+
} else {
|
|
875
|
+
customRecorder.stop();
|
|
876
|
+
}
|
|
877
|
+
setVoiceTrigger(null);
|
|
878
|
+
} else {
|
|
879
|
+
setErrorMsg(null);
|
|
880
|
+
onFocusTarget == null ? void 0 : onFocusTarget();
|
|
881
|
+
setVoiceTrigger("click");
|
|
882
|
+
if ((voiceConfig == null ? void 0 : voiceConfig.mode) === "custom") {
|
|
883
|
+
try {
|
|
884
|
+
await customRecorder.start();
|
|
885
|
+
} catch (e) {
|
|
886
|
+
setErrorMsg("Mic access denied");
|
|
887
|
+
setVoiceTrigger(null);
|
|
888
|
+
}
|
|
889
|
+
} else {
|
|
890
|
+
if (!nativeSpeech.isSupported) {
|
|
891
|
+
setErrorMsg("Speech not supported");
|
|
892
|
+
setVoiceTrigger(null);
|
|
893
|
+
return;
|
|
894
|
+
}
|
|
895
|
+
nativeSpeech.start();
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
};
|
|
899
|
+
let bgColor = accentColor;
|
|
900
|
+
let label = "Tap to Talk";
|
|
901
|
+
let Icon = /* @__PURE__ */ jsx6(MicrophoneIcon2, { className: "h-5 w-5" });
|
|
902
|
+
if (isListening) {
|
|
903
|
+
bgColor = "bg-orange-500";
|
|
904
|
+
label = "Listening ... Tap to stop";
|
|
905
|
+
Icon = /* @__PURE__ */ jsx6(MicrophoneIcon2, { className: "h-5 w-5 animate-pulse" });
|
|
906
|
+
} else if (isTranscribing) {
|
|
907
|
+
bgColor = "bg-indigo-600";
|
|
908
|
+
label = "Transcribing ...";
|
|
909
|
+
Icon = /* @__PURE__ */ jsxs4("svg", { className: "animate-spin h-5 w-5 text-white", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [
|
|
910
|
+
/* @__PURE__ */ jsx6("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
|
|
911
|
+
/* @__PURE__ */ jsx6("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })
|
|
912
|
+
] });
|
|
913
|
+
}
|
|
914
|
+
return /* @__PURE__ */ jsxs4("div", { className: "flex flex-col w-full relative", children: [
|
|
915
|
+
showDebug && /* @__PURE__ */ jsxs4("div", { className: "absolute bottom-full left-0 right-0 mb-2 p-2 bg-black/80 text-green-400 text-xs font-mono h-48 overflow-y-auto rounded z-50 pointer-events-auto", children: [
|
|
916
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex justify-between items-center bg-gray-800 p-1 mb-1", children: [
|
|
917
|
+
/* @__PURE__ */ jsx6("span", { children: "Debug Logs" }),
|
|
918
|
+
/* @__PURE__ */ jsx6("button", { onClick: (e) => {
|
|
919
|
+
e.stopPropagation();
|
|
920
|
+
setShowDebug(false);
|
|
921
|
+
}, className: "text-white hover:text-red-400", children: /* @__PURE__ */ jsx6(XMarkIcon2, { className: "w-4 h-4" }) })
|
|
922
|
+
] }),
|
|
923
|
+
logs.map((log, i) => /* @__PURE__ */ jsx6("div", { className: "mb-0.5 border-b border-gray-700/50 pb-0.5 break-all", children: log }, i)),
|
|
924
|
+
logs.length === 0 && /* @__PURE__ */ jsx6("div", { children: "No logs yet..." })
|
|
925
|
+
] }),
|
|
926
|
+
/* @__PURE__ */ jsxs4(
|
|
927
|
+
"button",
|
|
928
|
+
{
|
|
929
|
+
onClick: toggleVoice,
|
|
930
|
+
disabled: disabled || isTranscribing && !isListening,
|
|
931
|
+
className: `flex items-center justify-center gap-3 px-6 py-3 rounded-xl transition-all duration-300 w-full font-medium shadow-md active:scale-[0.98]
|
|
932
|
+
${bgColor} text-white
|
|
933
|
+
${disabled ? "opacity-50 cursor-not-allowed" : "cursor-pointer"}
|
|
934
|
+
${className}`,
|
|
935
|
+
title: label,
|
|
936
|
+
children: [
|
|
937
|
+
/* @__PURE__ */ jsx6("div", { className: "flex items-center justify-center shrink-0", children: Icon }),
|
|
938
|
+
/* @__PURE__ */ jsx6("span", { className: "truncate", children: label }),
|
|
939
|
+
errorMsg && /* @__PURE__ */ jsx6("span", { className: "text-[10px] bg-white/20 px-1.5 py-0.5 rounded text-red-100 animate-in fade-in slide-in-from-right-1", children: errorMsg })
|
|
940
|
+
]
|
|
941
|
+
}
|
|
942
|
+
)
|
|
943
|
+
] });
|
|
944
|
+
};
|
|
945
|
+
|
|
696
946
|
// src/ui/react/components/ChatMessageList.tsx
|
|
697
|
-
import { useEffect as useEffect6, useRef as
|
|
947
|
+
import { useEffect as useEffect6, useRef as useRef6 } from "react";
|
|
698
948
|
|
|
699
949
|
// src/ui/react/components/interactive/ConfirmInteraction.tsx
|
|
700
|
-
import { useState as
|
|
701
|
-
import { jsx as
|
|
950
|
+
import { useState as useState5 } from "react";
|
|
951
|
+
import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
702
952
|
var ConfirmInteraction = ({
|
|
703
953
|
parameters,
|
|
704
954
|
onResponse,
|
|
705
955
|
isResponseSubmitted
|
|
706
956
|
}) => {
|
|
707
|
-
const [selectedOption, setSelectedOption] =
|
|
957
|
+
const [selectedOption, setSelectedOption] = useState5(null);
|
|
708
958
|
const params = parameters;
|
|
709
959
|
const { yesPrompt, noPrompt } = params;
|
|
710
960
|
console.log("[ConfirmInteraction] Parameters:", params);
|
|
@@ -713,8 +963,8 @@ var ConfirmInteraction = ({
|
|
|
713
963
|
setSelectedOption(buttonText);
|
|
714
964
|
onResponse(value);
|
|
715
965
|
};
|
|
716
|
-
return /* @__PURE__ */
|
|
717
|
-
/* @__PURE__ */
|
|
966
|
+
return /* @__PURE__ */ jsx7("div", { className: "mt-2 mb-4", children: /* @__PURE__ */ jsxs5("div", { className: "flex space-x-2", children: [
|
|
967
|
+
/* @__PURE__ */ jsx7(
|
|
718
968
|
"button",
|
|
719
969
|
{
|
|
720
970
|
onClick: () => handleOptionClick(true, yesPrompt),
|
|
@@ -723,7 +973,7 @@ var ConfirmInteraction = ({
|
|
|
723
973
|
children: yesPrompt
|
|
724
974
|
}
|
|
725
975
|
),
|
|
726
|
-
/* @__PURE__ */
|
|
976
|
+
/* @__PURE__ */ jsx7(
|
|
727
977
|
"button",
|
|
728
978
|
{
|
|
729
979
|
onClick: () => handleOptionClick(false, noPrompt),
|
|
@@ -737,16 +987,16 @@ var ConfirmInteraction = ({
|
|
|
737
987
|
var ConfirmInteraction_default = ConfirmInteraction;
|
|
738
988
|
|
|
739
989
|
// src/ui/react/components/interactive/SelectInteraction.tsx
|
|
740
|
-
import { useState as
|
|
741
|
-
import { jsx as
|
|
990
|
+
import { useState as useState6, useEffect as useEffect4 } from "react";
|
|
991
|
+
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
742
992
|
var SelectInteraction = ({
|
|
743
993
|
parameters,
|
|
744
994
|
onResponse,
|
|
745
995
|
isResponseSubmitted,
|
|
746
996
|
message
|
|
747
997
|
}) => {
|
|
748
|
-
const [selectedOption, setSelectedOption] =
|
|
749
|
-
const [customOption, setCustomOption] =
|
|
998
|
+
const [selectedOption, setSelectedOption] = useState6(null);
|
|
999
|
+
const [customOption, setCustomOption] = useState6(null);
|
|
750
1000
|
const params = parameters;
|
|
751
1001
|
const { question, options, placeholder } = params;
|
|
752
1002
|
useEffect4(() => {
|
|
@@ -764,8 +1014,8 @@ var SelectInteraction = ({
|
|
|
764
1014
|
setCustomOption(null);
|
|
765
1015
|
onResponse(option);
|
|
766
1016
|
};
|
|
767
|
-
return /* @__PURE__ */
|
|
768
|
-
/* @__PURE__ */
|
|
1017
|
+
return /* @__PURE__ */ jsxs6("div", { className: "mt-2 mb-4", children: [
|
|
1018
|
+
/* @__PURE__ */ jsx8("div", { className: "flex flex-wrap gap-2", children: options.map((option, index) => /* @__PURE__ */ jsx8(
|
|
769
1019
|
"button",
|
|
770
1020
|
{
|
|
771
1021
|
onClick: () => handleOptionClick(option),
|
|
@@ -775,9 +1025,9 @@ var SelectInteraction = ({
|
|
|
775
1025
|
},
|
|
776
1026
|
index
|
|
777
1027
|
)) }),
|
|
778
|
-
customOption && isResponseSubmitted && /* @__PURE__ */
|
|
1028
|
+
customOption && isResponseSubmitted && /* @__PURE__ */ jsxs6("div", { className: "mt-2 text-sm text-amber-600 bg-amber-50 p-2 rounded", children: [
|
|
779
1029
|
"User provided custom option: ",
|
|
780
|
-
/* @__PURE__ */
|
|
1030
|
+
/* @__PURE__ */ jsxs6("span", { className: "font-semibold", children: [
|
|
781
1031
|
'"',
|
|
782
1032
|
customOption,
|
|
783
1033
|
'"'
|
|
@@ -788,20 +1038,20 @@ var SelectInteraction = ({
|
|
|
788
1038
|
var SelectInteraction_default = SelectInteraction;
|
|
789
1039
|
|
|
790
1040
|
// src/ui/react/components/interactive/FormInteraction.tsx
|
|
791
|
-
import { useState as
|
|
1041
|
+
import { useState as useState7, useEffect as useEffect5, useRef as useRef5 } from "react";
|
|
792
1042
|
import { ChevronDownIcon, ChevronUpIcon } from "lucide-react";
|
|
793
|
-
import { jsx as
|
|
1043
|
+
import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
794
1044
|
var FormInteraction = ({
|
|
795
1045
|
parameters,
|
|
796
1046
|
onResponse,
|
|
797
1047
|
isResponseSubmitted,
|
|
798
1048
|
submittedValues
|
|
799
1049
|
}) => {
|
|
800
|
-
const [isModalOpen, setIsModalOpen] =
|
|
801
|
-
const [formValues, setFormValues] =
|
|
802
|
-
const [isExpanded, setIsExpanded] =
|
|
803
|
-
const [parsedFields, setParsedFields] =
|
|
804
|
-
const formButtonsRef =
|
|
1050
|
+
const [isModalOpen, setIsModalOpen] = useState7(false);
|
|
1051
|
+
const [formValues, setFormValues] = useState7({});
|
|
1052
|
+
const [isExpanded, setIsExpanded] = useState7(false);
|
|
1053
|
+
const [parsedFields, setParsedFields] = useState7([]);
|
|
1054
|
+
const formButtonsRef = useRef5(null);
|
|
805
1055
|
const parseParameters = () => {
|
|
806
1056
|
const { prompt, description, submitText = "Submit", cancelText = "Cancel" } = parameters;
|
|
807
1057
|
let fieldsArray = [];
|
|
@@ -910,12 +1160,12 @@ var FormInteraction = ({
|
|
|
910
1160
|
case "email":
|
|
911
1161
|
case "number":
|
|
912
1162
|
case "password":
|
|
913
|
-
return /* @__PURE__ */
|
|
914
|
-
/* @__PURE__ */
|
|
1163
|
+
return /* @__PURE__ */ jsxs7("div", { className: "mb-4 flex items-center space-x-4", children: [
|
|
1164
|
+
/* @__PURE__ */ jsxs7("label", { htmlFor: name, className: "text-sm font-medium text-gray-700 min-w-[120px]", children: [
|
|
915
1165
|
label,
|
|
916
|
-
required && /* @__PURE__ */
|
|
1166
|
+
required && /* @__PURE__ */ jsx9("span", { className: "text-red-500", children: "*" })
|
|
917
1167
|
] }),
|
|
918
|
-
/* @__PURE__ */
|
|
1168
|
+
/* @__PURE__ */ jsx9(
|
|
919
1169
|
"input",
|
|
920
1170
|
{
|
|
921
1171
|
type: type === "string" ? "text" : type,
|
|
@@ -931,12 +1181,12 @@ var FormInteraction = ({
|
|
|
931
1181
|
)
|
|
932
1182
|
] }, name);
|
|
933
1183
|
case "textarea":
|
|
934
|
-
return /* @__PURE__ */
|
|
935
|
-
/* @__PURE__ */
|
|
1184
|
+
return /* @__PURE__ */ jsxs7("div", { className: "mb-4 flex items-start space-x-4", children: [
|
|
1185
|
+
/* @__PURE__ */ jsxs7("label", { htmlFor: name, className: "text-sm font-medium text-gray-700 min-w-[120px] pt-2", children: [
|
|
936
1186
|
label,
|
|
937
|
-
required && /* @__PURE__ */
|
|
1187
|
+
required && /* @__PURE__ */ jsx9("span", { className: "text-red-500", children: "*" })
|
|
938
1188
|
] }),
|
|
939
|
-
/* @__PURE__ */
|
|
1189
|
+
/* @__PURE__ */ jsx9(
|
|
940
1190
|
"textarea",
|
|
941
1191
|
{
|
|
942
1192
|
id: name,
|
|
@@ -952,12 +1202,12 @@ var FormInteraction = ({
|
|
|
952
1202
|
)
|
|
953
1203
|
] }, name);
|
|
954
1204
|
case "select":
|
|
955
|
-
return /* @__PURE__ */
|
|
956
|
-
/* @__PURE__ */
|
|
1205
|
+
return /* @__PURE__ */ jsxs7("div", { className: "mb-4 flex items-center space-x-4", children: [
|
|
1206
|
+
/* @__PURE__ */ jsxs7("label", { htmlFor: name, className: "text-sm font-medium text-gray-700 min-w-[120px]", children: [
|
|
957
1207
|
label,
|
|
958
|
-
required && /* @__PURE__ */
|
|
1208
|
+
required && /* @__PURE__ */ jsx9("span", { className: "text-red-500", children: "*" })
|
|
959
1209
|
] }),
|
|
960
|
-
/* @__PURE__ */
|
|
1210
|
+
/* @__PURE__ */ jsxs7(
|
|
961
1211
|
"select",
|
|
962
1212
|
{
|
|
963
1213
|
id: name,
|
|
@@ -968,17 +1218,17 @@ var FormInteraction = ({
|
|
|
968
1218
|
disabled: isResponseSubmitted,
|
|
969
1219
|
className: "flex-1 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",
|
|
970
1220
|
children: [
|
|
971
|
-
/* @__PURE__ */
|
|
972
|
-
options == null ? void 0 : options.map((option, index) => /* @__PURE__ */
|
|
1221
|
+
/* @__PURE__ */ jsx9("option", { value: "", disabled: true, children: placeholder || "Select an option" }),
|
|
1222
|
+
options == null ? void 0 : options.map((option, index) => /* @__PURE__ */ jsx9("option", { value: option, children: option }, index))
|
|
973
1223
|
]
|
|
974
1224
|
}
|
|
975
1225
|
)
|
|
976
1226
|
] }, name);
|
|
977
1227
|
case "checkbox":
|
|
978
|
-
return /* @__PURE__ */
|
|
979
|
-
/* @__PURE__ */
|
|
980
|
-
/* @__PURE__ */
|
|
981
|
-
/* @__PURE__ */
|
|
1228
|
+
return /* @__PURE__ */ jsxs7("div", { className: "mb-4 flex items-center space-x-4", children: [
|
|
1229
|
+
/* @__PURE__ */ jsx9("div", { className: "min-w-[120px]" }),
|
|
1230
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex items-center", children: [
|
|
1231
|
+
/* @__PURE__ */ jsx9(
|
|
982
1232
|
"input",
|
|
983
1233
|
{
|
|
984
1234
|
type: "checkbox",
|
|
@@ -991,20 +1241,20 @@ var FormInteraction = ({
|
|
|
991
1241
|
className: "h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500"
|
|
992
1242
|
}
|
|
993
1243
|
),
|
|
994
|
-
/* @__PURE__ */
|
|
1244
|
+
/* @__PURE__ */ jsxs7("label", { htmlFor: name, className: "ml-2 text-sm text-gray-700", children: [
|
|
995
1245
|
label,
|
|
996
|
-
required && /* @__PURE__ */
|
|
1246
|
+
required && /* @__PURE__ */ jsx9("span", { className: "text-red-500", children: "*" })
|
|
997
1247
|
] })
|
|
998
1248
|
] })
|
|
999
1249
|
] }, name);
|
|
1000
1250
|
case "radio":
|
|
1001
|
-
return /* @__PURE__ */
|
|
1002
|
-
/* @__PURE__ */
|
|
1251
|
+
return /* @__PURE__ */ jsxs7("div", { className: "mb-4 flex space-x-4", children: [
|
|
1252
|
+
/* @__PURE__ */ jsxs7("div", { className: "text-sm font-medium text-gray-700 min-w-[120px] pt-2", children: [
|
|
1003
1253
|
label,
|
|
1004
|
-
required && /* @__PURE__ */
|
|
1254
|
+
required && /* @__PURE__ */ jsx9("span", { className: "text-red-500", children: "*" })
|
|
1005
1255
|
] }),
|
|
1006
|
-
/* @__PURE__ */
|
|
1007
|
-
/* @__PURE__ */
|
|
1256
|
+
/* @__PURE__ */ jsx9("div", { className: "flex-1 space-y-2", children: options == null ? void 0 : options.map((option, index) => /* @__PURE__ */ jsxs7("div", { className: "flex items-center", children: [
|
|
1257
|
+
/* @__PURE__ */ jsx9(
|
|
1008
1258
|
"input",
|
|
1009
1259
|
{
|
|
1010
1260
|
id: `${name}-${index}`,
|
|
@@ -1018,7 +1268,7 @@ var FormInteraction = ({
|
|
|
1018
1268
|
className: "h-4 w-4 text-blue-600 border-gray-300 focus:ring-blue-500"
|
|
1019
1269
|
}
|
|
1020
1270
|
),
|
|
1021
|
-
/* @__PURE__ */
|
|
1271
|
+
/* @__PURE__ */ jsx9("label", { htmlFor: `${name}-${index}`, className: "ml-2 text-sm text-gray-700", children: option })
|
|
1022
1272
|
] }, index)) })
|
|
1023
1273
|
] }, name);
|
|
1024
1274
|
default:
|
|
@@ -1026,27 +1276,27 @@ var FormInteraction = ({
|
|
|
1026
1276
|
}
|
|
1027
1277
|
};
|
|
1028
1278
|
if (isResponseSubmitted) {
|
|
1029
|
-
return /* @__PURE__ */
|
|
1030
|
-
/* @__PURE__ */
|
|
1031
|
-
/* @__PURE__ */
|
|
1279
|
+
return /* @__PURE__ */ jsxs7("div", { className: "mt-2 bg-gray-50 p-3 rounded-md border border-gray-200", children: [
|
|
1280
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex justify-between items-center cursor-pointer", onClick: () => setIsExpanded(!isExpanded), children: [
|
|
1281
|
+
/* @__PURE__ */ jsxs7("span", { className: "font-medium text-gray-700", children: [
|
|
1032
1282
|
isExpanded ? "Hide" : "Show",
|
|
1033
1283
|
" Form Responses"
|
|
1034
1284
|
] }),
|
|
1035
|
-
isExpanded ? /* @__PURE__ */
|
|
1285
|
+
isExpanded ? /* @__PURE__ */ jsx9(ChevronUpIcon, { className: "h-5 w-5 text-gray-500" }) : /* @__PURE__ */ jsx9(ChevronDownIcon, { className: "h-5 w-5 text-gray-500" })
|
|
1036
1286
|
] }),
|
|
1037
|
-
isExpanded && /* @__PURE__ */
|
|
1038
|
-
/* @__PURE__ */
|
|
1287
|
+
isExpanded && /* @__PURE__ */ jsx9("div", { className: "mt-2 space-y-2", children: parsedFields.map((field) => /* @__PURE__ */ jsxs7("div", { className: "flex", children: [
|
|
1288
|
+
/* @__PURE__ */ jsxs7("span", { className: "text-sm font-medium text-gray-600 mr-2", children: [
|
|
1039
1289
|
field.label,
|
|
1040
1290
|
":"
|
|
1041
1291
|
] }),
|
|
1042
|
-
/* @__PURE__ */
|
|
1292
|
+
/* @__PURE__ */ jsx9("span", { className: "text-sm text-gray-800", children: typeof (submittedValues == null ? void 0 : submittedValues[field.name]) === "boolean" ? submittedValues[field.name] ? "Yes" : "No" : (submittedValues == null ? void 0 : submittedValues[field.name]) || "Not provided" })
|
|
1043
1293
|
] }, field.name)) })
|
|
1044
1294
|
] });
|
|
1045
1295
|
}
|
|
1046
|
-
return /* @__PURE__ */
|
|
1296
|
+
return /* @__PURE__ */ jsx9("div", { className: "mt-2", children: isModalOpen && /* @__PURE__ */ jsx9("div", { className: "p-4", children: /* @__PURE__ */ jsxs7("form", { onSubmit: handleSubmit, className: "mt-4", children: [
|
|
1047
1297
|
parsedFields.map((field) => renderField(field)),
|
|
1048
|
-
/* @__PURE__ */
|
|
1049
|
-
/* @__PURE__ */
|
|
1298
|
+
/* @__PURE__ */ jsxs7("div", { ref: formButtonsRef, className: "flex justify-end mt-4 space-x-2", children: [
|
|
1299
|
+
/* @__PURE__ */ jsx9(
|
|
1050
1300
|
"button",
|
|
1051
1301
|
{
|
|
1052
1302
|
type: "button",
|
|
@@ -1056,7 +1306,7 @@ var FormInteraction = ({
|
|
|
1056
1306
|
children: params.cancelText
|
|
1057
1307
|
}
|
|
1058
1308
|
),
|
|
1059
|
-
/* @__PURE__ */
|
|
1309
|
+
/* @__PURE__ */ jsx9(
|
|
1060
1310
|
"button",
|
|
1061
1311
|
{
|
|
1062
1312
|
type: "submit",
|
|
@@ -1071,12 +1321,12 @@ var FormInteraction = ({
|
|
|
1071
1321
|
var FormInteraction_default = FormInteraction;
|
|
1072
1322
|
|
|
1073
1323
|
// src/ui/react/components/interactive/PresentInteraction.tsx
|
|
1074
|
-
import { jsx as
|
|
1324
|
+
import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1075
1325
|
var ReactMarkdown2;
|
|
1076
1326
|
try {
|
|
1077
1327
|
ReactMarkdown2 = __require("react-markdown");
|
|
1078
1328
|
} catch (error) {
|
|
1079
|
-
ReactMarkdown2 = ({ children }) => /* @__PURE__ */
|
|
1329
|
+
ReactMarkdown2 = ({ children }) => /* @__PURE__ */ jsx10("div", { className: "whitespace-pre-wrap", children });
|
|
1080
1330
|
}
|
|
1081
1331
|
var PresentInteraction = ({
|
|
1082
1332
|
parameters
|
|
@@ -1114,15 +1364,15 @@ var PresentInteraction = ({
|
|
|
1114
1364
|
}
|
|
1115
1365
|
};
|
|
1116
1366
|
const styles = getLevelStyles();
|
|
1117
|
-
return /* @__PURE__ */
|
|
1118
|
-
title && /* @__PURE__ */
|
|
1119
|
-
/* @__PURE__ */
|
|
1367
|
+
return /* @__PURE__ */ jsxs8("div", { className: `mt-2 mb-4 p-4 ${styles.container} border rounded-md`, children: [
|
|
1368
|
+
title && /* @__PURE__ */ jsx10("div", { className: `font-medium ${styles.title} mb-2`, children: title }),
|
|
1369
|
+
/* @__PURE__ */ jsx10("div", { className: `text-sm ${styles.content}`, children: format === "markdown" ? /* @__PURE__ */ jsx10(ReactMarkdown2, { className: "prose prose-sm max-w-none", children: content }) : format === "html" ? /* @__PURE__ */ jsx10("div", { dangerouslySetInnerHTML: { __html: content } }) : /* @__PURE__ */ jsx10("div", { className: "whitespace-pre-wrap", children: content }) })
|
|
1120
1370
|
] });
|
|
1121
1371
|
};
|
|
1122
1372
|
var PresentInteraction_default = PresentInteraction;
|
|
1123
1373
|
|
|
1124
1374
|
// src/ui/react/components/interactive/InteractiveMessageHandler.tsx
|
|
1125
|
-
import { jsx as
|
|
1375
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
1126
1376
|
var InteractiveMessageHandler = ({
|
|
1127
1377
|
message,
|
|
1128
1378
|
onResponse,
|
|
@@ -1133,7 +1383,7 @@ var InteractiveMessageHandler = ({
|
|
|
1133
1383
|
const submittedResponse = parentMessage == null ? void 0 : parentMessage.responseValue;
|
|
1134
1384
|
switch (functionType) {
|
|
1135
1385
|
case "confirm":
|
|
1136
|
-
return /* @__PURE__ */
|
|
1386
|
+
return /* @__PURE__ */ jsx11(
|
|
1137
1387
|
ConfirmInteraction_default,
|
|
1138
1388
|
{
|
|
1139
1389
|
parameters,
|
|
@@ -1142,7 +1392,7 @@ var InteractiveMessageHandler = ({
|
|
|
1142
1392
|
}
|
|
1143
1393
|
);
|
|
1144
1394
|
case "select":
|
|
1145
|
-
return /* @__PURE__ */
|
|
1395
|
+
return /* @__PURE__ */ jsx11(
|
|
1146
1396
|
SelectInteraction_default,
|
|
1147
1397
|
{
|
|
1148
1398
|
parameters,
|
|
@@ -1152,7 +1402,7 @@ var InteractiveMessageHandler = ({
|
|
|
1152
1402
|
}
|
|
1153
1403
|
);
|
|
1154
1404
|
case "form":
|
|
1155
|
-
return /* @__PURE__ */
|
|
1405
|
+
return /* @__PURE__ */ jsx11(
|
|
1156
1406
|
FormInteraction_default,
|
|
1157
1407
|
{
|
|
1158
1408
|
parameters,
|
|
@@ -1162,7 +1412,7 @@ var InteractiveMessageHandler = ({
|
|
|
1162
1412
|
}
|
|
1163
1413
|
);
|
|
1164
1414
|
case "present":
|
|
1165
|
-
return /* @__PURE__ */
|
|
1415
|
+
return /* @__PURE__ */ jsx11(
|
|
1166
1416
|
PresentInteraction_default,
|
|
1167
1417
|
{
|
|
1168
1418
|
parameters
|
|
@@ -1179,7 +1429,7 @@ var InteractiveMessageHandler_default = InteractiveMessageHandler;
|
|
|
1179
1429
|
|
|
1180
1430
|
// src/ui/react/components/ChatMessageList.tsx
|
|
1181
1431
|
import { InformationCircleIcon } from "@heroicons/react/24/outline";
|
|
1182
|
-
import { jsx as
|
|
1432
|
+
import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1183
1433
|
var ChatMessageList = ({
|
|
1184
1434
|
chatHistory,
|
|
1185
1435
|
isProcessing,
|
|
@@ -1188,9 +1438,9 @@ var ChatMessageList = ({
|
|
|
1188
1438
|
getContextExample,
|
|
1189
1439
|
onInteractiveResponse
|
|
1190
1440
|
}) => {
|
|
1191
|
-
const chatContainerRef =
|
|
1192
|
-
const lastMessageRef =
|
|
1193
|
-
const processingIndicatorRef =
|
|
1441
|
+
const chatContainerRef = useRef6(null);
|
|
1442
|
+
const lastMessageRef = useRef6(null);
|
|
1443
|
+
const processingIndicatorRef = useRef6(null);
|
|
1194
1444
|
useEffect6(() => {
|
|
1195
1445
|
if (isProcessing && processingIndicatorRef.current) {
|
|
1196
1446
|
processingIndicatorRef.current.scrollIntoView({ behavior: "smooth" });
|
|
@@ -1207,15 +1457,15 @@ var ChatMessageList = ({
|
|
|
1207
1457
|
onInteractiveResponse(messageId, response);
|
|
1208
1458
|
}
|
|
1209
1459
|
};
|
|
1210
|
-
return /* @__PURE__ */
|
|
1460
|
+
return /* @__PURE__ */ jsxs9(
|
|
1211
1461
|
"div",
|
|
1212
1462
|
{
|
|
1213
1463
|
ref: chatContainerRef,
|
|
1214
1464
|
className: "flex-1 overflow-y-auto p-4 space-y-8 bg-gray-50",
|
|
1215
1465
|
children: [
|
|
1216
|
-
chatHistory.length === 0 && !isProcessing && /* @__PURE__ */
|
|
1217
|
-
/* @__PURE__ */
|
|
1218
|
-
/* @__PURE__ */
|
|
1466
|
+
chatHistory.length === 0 && !isProcessing && /* @__PURE__ */ jsxs9("div", { className: "text-center py-8", children: [
|
|
1467
|
+
/* @__PURE__ */ jsx12("h3", { className: "text-lg font-medium text-gray-700 mb-2", children: "How can I help you today?" }),
|
|
1468
|
+
/* @__PURE__ */ jsxs9("p", { className: "text-sm text-gray-500 mb-4", children: [
|
|
1219
1469
|
"Try asking me something like ",
|
|
1220
1470
|
getContextExample()
|
|
1221
1471
|
] })
|
|
@@ -1224,14 +1474,14 @@ var ChatMessageList = ({
|
|
|
1224
1474
|
const isLastMessage = index === chatHistory.length - 1;
|
|
1225
1475
|
const isUser = message.role === "user";
|
|
1226
1476
|
const isError = message.role === "error";
|
|
1227
|
-
return /* @__PURE__ */
|
|
1477
|
+
return /* @__PURE__ */ jsxs9(
|
|
1228
1478
|
"div",
|
|
1229
1479
|
{
|
|
1230
1480
|
ref: isLastMessage ? lastMessageRef : void 0,
|
|
1231
1481
|
className: `flex flex-col w-full ${isUser ? "items-end" : "items-start"}`,
|
|
1232
1482
|
children: [
|
|
1233
|
-
/* @__PURE__ */
|
|
1234
|
-
/* @__PURE__ */
|
|
1483
|
+
/* @__PURE__ */ jsx12("div", { className: "text-xs text-gray-400 mb-1 px-1", children: message.timestamp ? `${isUser ? "Sent" : "Received"} at ${new Date(message.timestamp).toLocaleString()}` : "" }),
|
|
1484
|
+
/* @__PURE__ */ jsx12("div", { className: "w-full", children: message.interactive && message.interactiveData ? /* @__PURE__ */ jsx12("div", { className: `max-w-[85%] ${isUser ? "ml-auto" : "mr-auto"}`, children: /* @__PURE__ */ jsx12(
|
|
1235
1485
|
InteractiveMessageHandler_default,
|
|
1236
1486
|
{
|
|
1237
1487
|
message: message.interactiveData,
|
|
@@ -1243,16 +1493,16 @@ var ChatMessageList = ({
|
|
|
1243
1493
|
isResponseSubmitted: !!message.isResponseSubmitted,
|
|
1244
1494
|
parentMessage: message
|
|
1245
1495
|
}
|
|
1246
|
-
) }) : /* @__PURE__ */
|
|
1496
|
+
) }) : /* @__PURE__ */ jsx12(
|
|
1247
1497
|
MessageBubble,
|
|
1248
1498
|
{
|
|
1249
1499
|
message,
|
|
1250
1500
|
isUser
|
|
1251
1501
|
}
|
|
1252
1502
|
) }),
|
|
1253
|
-
isUser && message.interactive && /* @__PURE__ */
|
|
1254
|
-
/* @__PURE__ */
|
|
1255
|
-
/* @__PURE__ */
|
|
1503
|
+
isUser && message.interactive && /* @__PURE__ */ jsxs9("div", { className: "flex items-center mt-1 space-x-1 text-xs text-gray-500 italic", children: [
|
|
1504
|
+
/* @__PURE__ */ jsx12(InformationCircleIcon, { className: "h-3 w-3 text-blue-400" }),
|
|
1505
|
+
/* @__PURE__ */ jsxs9("span", { children: [
|
|
1256
1506
|
message.request === "form" && "Response to form submission",
|
|
1257
1507
|
message.request === "select" && "Response to selection prompt",
|
|
1258
1508
|
message.request === "confirm" && "Response to confirmation prompt"
|
|
@@ -1263,29 +1513,29 @@ var ChatMessageList = ({
|
|
|
1263
1513
|
message.id || `message-${index}`
|
|
1264
1514
|
);
|
|
1265
1515
|
}),
|
|
1266
|
-
isProcessing && /* @__PURE__ */
|
|
1516
|
+
isProcessing && /* @__PURE__ */ jsx12(
|
|
1267
1517
|
"div",
|
|
1268
1518
|
{
|
|
1269
1519
|
ref: processingIndicatorRef,
|
|
1270
1520
|
className: "flex justify-start my-4",
|
|
1271
|
-
children: /* @__PURE__ */
|
|
1272
|
-
/* @__PURE__ */
|
|
1273
|
-
/* @__PURE__ */
|
|
1274
|
-
/* @__PURE__ */
|
|
1275
|
-
/* @__PURE__ */
|
|
1276
|
-
/* @__PURE__ */
|
|
1521
|
+
children: /* @__PURE__ */ jsx12("div", { className: "bg-white text-gray-800 border border-gray-200 rounded-lg px-4 py-2 max-w-[85%]", children: /* @__PURE__ */ jsxs9("div", { className: "flex items-center", children: [
|
|
1522
|
+
/* @__PURE__ */ jsx12("span", { className: "text-sm", children: processingHint }),
|
|
1523
|
+
/* @__PURE__ */ jsxs9("span", { className: "ml-2 flex space-x-1", children: [
|
|
1524
|
+
/* @__PURE__ */ jsx12("span", { className: "h-2 w-2 bg-gray-400 rounded-full animate-bounce", style: { animationDelay: "0ms" } }),
|
|
1525
|
+
/* @__PURE__ */ jsx12("span", { className: "h-2 w-2 bg-gray-400 rounded-full animate-bounce", style: { animationDelay: "150ms" } }),
|
|
1526
|
+
/* @__PURE__ */ jsx12("span", { className: "h-2 w-2 bg-gray-400 rounded-full animate-bounce", style: { animationDelay: "300ms" } })
|
|
1277
1527
|
] })
|
|
1278
1528
|
] }) })
|
|
1279
1529
|
}
|
|
1280
1530
|
),
|
|
1281
|
-
currentTask && !currentTask.complete && /* @__PURE__ */
|
|
1282
|
-
/* @__PURE__ */
|
|
1531
|
+
currentTask && !currentTask.complete && /* @__PURE__ */ jsxs9("div", { className: "mt-4 bg-blue-50 border border-blue-100 rounded-lg p-3", children: [
|
|
1532
|
+
/* @__PURE__ */ jsxs9("div", { className: "text-sm text-blue-800 mb-1", children: [
|
|
1283
1533
|
"Task in progress: Step ",
|
|
1284
1534
|
currentTask.currentStep,
|
|
1285
1535
|
" of ",
|
|
1286
1536
|
currentTask.steps
|
|
1287
1537
|
] }),
|
|
1288
|
-
/* @__PURE__ */
|
|
1538
|
+
/* @__PURE__ */ jsx12("div", { className: "w-full bg-blue-200 rounded-full h-2", children: /* @__PURE__ */ jsx12(
|
|
1289
1539
|
"div",
|
|
1290
1540
|
{
|
|
1291
1541
|
className: "bg-blue-500 h-2 rounded-full",
|
|
@@ -1300,34 +1550,34 @@ var ChatMessageList = ({
|
|
|
1300
1550
|
|
|
1301
1551
|
// src/ui/react/components/ConnectionStatus.tsx
|
|
1302
1552
|
import { Wifi, WifiOff, RefreshCw } from "lucide-react";
|
|
1303
|
-
import { jsx as
|
|
1553
|
+
import { jsx as jsx13, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1304
1554
|
var ConnectionStatus = ({
|
|
1305
1555
|
connectionStatus,
|
|
1306
1556
|
onReconnect
|
|
1307
1557
|
}) => {
|
|
1308
|
-
return /* @__PURE__ */
|
|
1309
|
-
/* @__PURE__ */
|
|
1310
|
-
connectionStatus === "connected" && /* @__PURE__ */
|
|
1311
|
-
/* @__PURE__ */
|
|
1312
|
-
/* @__PURE__ */
|
|
1558
|
+
return /* @__PURE__ */ jsxs10("div", { className: "bg-amber-100 connection-status flex items-center justify-between px-4 py-1 text-xs", children: [
|
|
1559
|
+
/* @__PURE__ */ jsx13("div", { className: "text-gray-700 font-medium", children: "You are talking with your personal Content Strategist" }),
|
|
1560
|
+
connectionStatus === "connected" && /* @__PURE__ */ jsxs10("div", { className: "flex items-center text-green-600", children: [
|
|
1561
|
+
/* @__PURE__ */ jsx13(Wifi, { className: "w-3 h-3 mr-1" }),
|
|
1562
|
+
/* @__PURE__ */ jsx13("span", { children: "Connected" })
|
|
1313
1563
|
] }),
|
|
1314
|
-
connectionStatus === "reconnecting" && /* @__PURE__ */
|
|
1315
|
-
/* @__PURE__ */
|
|
1316
|
-
/* @__PURE__ */
|
|
1564
|
+
connectionStatus === "reconnecting" && /* @__PURE__ */ jsxs10("div", { className: "flex items-center text-amber-600", children: [
|
|
1565
|
+
/* @__PURE__ */ jsx13(RefreshCw, { className: "w-3 h-3 mr-1 animate-spin" }),
|
|
1566
|
+
/* @__PURE__ */ jsx13("span", { children: "Reconnecting..." })
|
|
1317
1567
|
] }),
|
|
1318
|
-
connectionStatus === "disconnected" && /* @__PURE__ */
|
|
1319
|
-
/* @__PURE__ */
|
|
1320
|
-
/* @__PURE__ */
|
|
1321
|
-
/* @__PURE__ */
|
|
1568
|
+
connectionStatus === "disconnected" && /* @__PURE__ */ jsxs10("div", { className: "flex items-center gap-2", children: [
|
|
1569
|
+
/* @__PURE__ */ jsxs10("div", { className: "text-red-600 flex items-center", children: [
|
|
1570
|
+
/* @__PURE__ */ jsx13(WifiOff, { className: "w-3 h-3 mr-1" }),
|
|
1571
|
+
/* @__PURE__ */ jsx13("span", { children: "Disconnected" })
|
|
1322
1572
|
] }),
|
|
1323
|
-
/* @__PURE__ */
|
|
1573
|
+
/* @__PURE__ */ jsxs10(
|
|
1324
1574
|
"button",
|
|
1325
1575
|
{
|
|
1326
1576
|
onClick: onReconnect,
|
|
1327
1577
|
className: "text-blue-600 hover:text-blue-800 flex items-center",
|
|
1328
1578
|
children: [
|
|
1329
|
-
/* @__PURE__ */
|
|
1330
|
-
/* @__PURE__ */
|
|
1579
|
+
/* @__PURE__ */ jsx13(RefreshCw, { className: "w-3 h-3 mr-1" }),
|
|
1580
|
+
/* @__PURE__ */ jsx13("span", { children: "Reconnect" })
|
|
1331
1581
|
]
|
|
1332
1582
|
}
|
|
1333
1583
|
)
|
|
@@ -1336,7 +1586,7 @@ var ConnectionStatus = ({
|
|
|
1336
1586
|
};
|
|
1337
1587
|
|
|
1338
1588
|
// src/ui/react/components/Spinner.tsx
|
|
1339
|
-
import { jsx as
|
|
1589
|
+
import { jsx as jsx14, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1340
1590
|
var Spinner = ({
|
|
1341
1591
|
size = "md",
|
|
1342
1592
|
className = "",
|
|
@@ -1348,7 +1598,7 @@ var Spinner = ({
|
|
|
1348
1598
|
lg: "h-8 w-8",
|
|
1349
1599
|
xl: "h-12 w-12"
|
|
1350
1600
|
};
|
|
1351
|
-
return /* @__PURE__ */
|
|
1601
|
+
return /* @__PURE__ */ jsxs11(
|
|
1352
1602
|
"svg",
|
|
1353
1603
|
{
|
|
1354
1604
|
className: `animate-spin ${sizeClasses[size]} ${color} ${className}`,
|
|
@@ -1356,7 +1606,7 @@ var Spinner = ({
|
|
|
1356
1606
|
fill: "none",
|
|
1357
1607
|
viewBox: "0 0 24 24",
|
|
1358
1608
|
children: [
|
|
1359
|
-
/* @__PURE__ */
|
|
1609
|
+
/* @__PURE__ */ jsx14(
|
|
1360
1610
|
"circle",
|
|
1361
1611
|
{
|
|
1362
1612
|
className: "opacity-25",
|
|
@@ -1367,7 +1617,7 @@ var Spinner = ({
|
|
|
1367
1617
|
strokeWidth: "4"
|
|
1368
1618
|
}
|
|
1369
1619
|
),
|
|
1370
|
-
/* @__PURE__ */
|
|
1620
|
+
/* @__PURE__ */ jsx14(
|
|
1371
1621
|
"path",
|
|
1372
1622
|
{
|
|
1373
1623
|
className: "opacity-75",
|
|
@@ -1430,6 +1680,7 @@ export {
|
|
|
1430
1680
|
ConnectionStatus,
|
|
1431
1681
|
MessageBubble,
|
|
1432
1682
|
Spinner,
|
|
1683
|
+
TapToTalk,
|
|
1433
1684
|
createWhisperVoiceConfig,
|
|
1434
1685
|
transcribeAudio,
|
|
1435
1686
|
useAudioRecorder,
|