@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
|
@@ -37,6 +37,7 @@ __export(components_exports, {
|
|
|
37
37
|
ConnectionStatus: () => ConnectionStatus,
|
|
38
38
|
MessageBubble: () => MessageBubble,
|
|
39
39
|
Spinner: () => Spinner,
|
|
40
|
+
TapToTalk: () => TapToTalk,
|
|
40
41
|
createWhisperVoiceConfig: () => createWhisperVoiceConfig,
|
|
41
42
|
transcribeAudio: () => transcribeAudio,
|
|
42
43
|
useAudioRecorder: () => useAudioRecorder,
|
|
@@ -428,6 +429,42 @@ var ChatInputArea = (0, import_react5.forwardRef)(({
|
|
|
428
429
|
const [isTranscribing, setIsTranscribing] = (0, import_react5.useState)(false);
|
|
429
430
|
const [voiceError, setVoiceError] = (0, import_react5.useState)(null);
|
|
430
431
|
const [isFocused, setIsFocused] = (0, import_react5.useState)(false);
|
|
432
|
+
const [showDebug, setShowDebug] = (0, import_react5.useState)(false);
|
|
433
|
+
const [logs, setLogs] = (0, import_react5.useState)([]);
|
|
434
|
+
const tapCountRef = (0, import_react5.useRef)({ count: 0, lastTap: 0 });
|
|
435
|
+
(0, import_react5.useEffect)(() => {
|
|
436
|
+
const originalLog = console.log;
|
|
437
|
+
const originalWarn = console.warn;
|
|
438
|
+
const originalError = console.error;
|
|
439
|
+
const addLog = (type, args) => {
|
|
440
|
+
try {
|
|
441
|
+
const msg = args.map((arg) => {
|
|
442
|
+
if (arg instanceof Error) return `${arg.name}: ${arg.message}`;
|
|
443
|
+
if (typeof arg === "object") return JSON.stringify(arg);
|
|
444
|
+
return String(arg);
|
|
445
|
+
}).join(" ");
|
|
446
|
+
setLogs((prev) => [`[${type}] ${msg}`, ...prev].slice(0, 50));
|
|
447
|
+
} catch (e) {
|
|
448
|
+
}
|
|
449
|
+
};
|
|
450
|
+
console.log = (...args) => {
|
|
451
|
+
originalLog(...args);
|
|
452
|
+
addLog("LOG", args);
|
|
453
|
+
};
|
|
454
|
+
console.warn = (...args) => {
|
|
455
|
+
originalWarn(...args);
|
|
456
|
+
addLog("WRN", args);
|
|
457
|
+
};
|
|
458
|
+
console.error = (...args) => {
|
|
459
|
+
originalError(...args);
|
|
460
|
+
addLog("ERR", args);
|
|
461
|
+
};
|
|
462
|
+
return () => {
|
|
463
|
+
console.log = originalLog;
|
|
464
|
+
console.warn = originalWarn;
|
|
465
|
+
console.error = originalError;
|
|
466
|
+
};
|
|
467
|
+
}, []);
|
|
431
468
|
const textareaRef = (0, import_react5.useRef)(null);
|
|
432
469
|
const measurementRef = (0, import_react5.useRef)(null);
|
|
433
470
|
const pendingSelectionRef = (0, import_react5.useRef)(null);
|
|
@@ -497,6 +534,12 @@ var ChatInputArea = (0, import_react5.forwardRef)(({
|
|
|
497
534
|
(_b2 = (_a2 = voiceConfigRef.current) == null ? void 0 : _a2.onVoiceEnd) == null ? void 0 : _b2.call(_a2);
|
|
498
535
|
}, []);
|
|
499
536
|
const nativeSpeech = useSpeechRecognition(handleVoiceResult, handleVoiceEnd, voiceConfig == null ? void 0 : voiceConfig.language);
|
|
537
|
+
(0, import_react5.useEffect)(() => {
|
|
538
|
+
if (nativeSpeech.error) {
|
|
539
|
+
setVoiceError(nativeSpeech.error);
|
|
540
|
+
console.error("[ChatInputArea] Native Speech Error:", nativeSpeech.error);
|
|
541
|
+
}
|
|
542
|
+
}, [nativeSpeech.error]);
|
|
500
543
|
const customRecorder = useAudioRecorder(async (blob) => {
|
|
501
544
|
var _a2, _b2, _c2;
|
|
502
545
|
setVoiceTrigger(null);
|
|
@@ -610,20 +653,40 @@ var ChatInputArea = (0, import_react5.forwardRef)(({
|
|
|
610
653
|
if (!showInputForm) {
|
|
611
654
|
return null;
|
|
612
655
|
}
|
|
613
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col w-full", children: [
|
|
656
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col w-full relative", children: [
|
|
657
|
+
showDebug && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("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: [
|
|
658
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex justify-between items-center bg-gray-800 p-1 mb-1", children: [
|
|
659
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: "Debug Logs" }),
|
|
660
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { onClick: () => setShowDebug(false), className: "text-white hover:text-red-400", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_outline.XMarkIcon, { className: "w-4 h-4" }) })
|
|
661
|
+
] }),
|
|
662
|
+
logs.map((log, i) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "mb-0.5 border-b border-gray-700/50 pb-0.5 break-all", children: log }, i)),
|
|
663
|
+
logs.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { children: "No logs yet..." })
|
|
664
|
+
] }),
|
|
614
665
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
615
666
|
voiceConfig && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
616
667
|
"button",
|
|
617
668
|
{
|
|
618
669
|
type: "button",
|
|
619
670
|
onClick: () => {
|
|
671
|
+
const now = Date.now();
|
|
672
|
+
if (now - tapCountRef.current.lastTap < 500) {
|
|
673
|
+
tapCountRef.current.count++;
|
|
674
|
+
} else {
|
|
675
|
+
tapCountRef.current.count = 1;
|
|
676
|
+
}
|
|
677
|
+
tapCountRef.current.lastTap = now;
|
|
678
|
+
if (tapCountRef.current.count >= 5) {
|
|
679
|
+
setShowDebug((prev) => !prev);
|
|
680
|
+
tapCountRef.current.count = 0;
|
|
681
|
+
return;
|
|
682
|
+
}
|
|
620
683
|
if (voiceTrigger) {
|
|
621
684
|
stopRecording();
|
|
622
685
|
} else if (!isTranscribing) {
|
|
623
686
|
startRecording("click");
|
|
624
687
|
}
|
|
625
688
|
},
|
|
626
|
-
className: `mb-1 p-2 rounded-full transition-all duration-300 flex-shrink-0 border ${
|
|
689
|
+
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" : ""}`,
|
|
627
690
|
disabled: isTranscribing,
|
|
628
691
|
title: isTranscribing ? "Transcribing..." : voiceTrigger ? "Stop Recording" : "Start Voice Input",
|
|
629
692
|
children: isTranscribing ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "animate-spin w-5 h-5 flex items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("svg", { className: "w-5 h-5 text-white", viewBox: "0 0 24 24", children: [
|
|
@@ -726,26 +789,214 @@ var ChatInputArea = (0, import_react5.forwardRef)(({
|
|
|
726
789
|
)
|
|
727
790
|
] }),
|
|
728
791
|
inputHint && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "text-sm text-red-500 bg-red-50 py-1 px-4 rounded-lg mt-1", children: inputHint }),
|
|
729
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "ml-[46px] mb-2 mt-0.5 min-h-[0.75rem]", style: { marginLeft: "48px" }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: `text-[10px] leading-tight transition-all duration-200 ${voiceError ? "text-red-500" :
|
|
792
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "ml-[46px] mb-2 mt-0.5 min-h-[0.75rem]", style: { marginLeft: "48px" }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("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__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "flex items-center gap-1 font-semibold italic", children: [
|
|
730
793
|
"Error: ",
|
|
731
794
|
voiceError
|
|
732
|
-
] }) : 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...") }) })
|
|
795
|
+
] }) : 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...") }) })
|
|
733
796
|
] });
|
|
734
797
|
});
|
|
735
798
|
ChatInputArea.displayName = "ChatInputArea";
|
|
736
799
|
|
|
800
|
+
// src/ui/react/components/TapToTalk.tsx
|
|
801
|
+
var import_react6 = __toESM(require("react"), 1);
|
|
802
|
+
var import_outline2 = require("@heroicons/react/24/outline");
|
|
803
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
804
|
+
var TapToTalk = ({
|
|
805
|
+
onResult,
|
|
806
|
+
voiceConfig: propVoiceConfig,
|
|
807
|
+
className = "",
|
|
808
|
+
disabled = false,
|
|
809
|
+
tooltip = "Tap to speak",
|
|
810
|
+
onFocusTarget,
|
|
811
|
+
accentColor = "bg-emerald-600"
|
|
812
|
+
}) => {
|
|
813
|
+
var _a;
|
|
814
|
+
const globalConfig = useChatConfig();
|
|
815
|
+
const voiceConfig = propVoiceConfig || ((_a = globalConfig.voice) == null ? void 0 : _a.config);
|
|
816
|
+
const [isTranscribing, setIsTranscribing] = (0, import_react6.useState)(false);
|
|
817
|
+
const [voiceTrigger, setVoiceTrigger] = (0, import_react6.useState)(null);
|
|
818
|
+
const [errorMsg, setErrorMsg] = (0, import_react6.useState)(null);
|
|
819
|
+
const [showDebug, setShowDebug] = (0, import_react6.useState)(false);
|
|
820
|
+
const [logs, setLogs] = (0, import_react6.useState)([]);
|
|
821
|
+
const tapCountRef = (0, import_react6.useRef)({ count: 0, lastTap: 0 });
|
|
822
|
+
import_react6.default.useEffect(() => {
|
|
823
|
+
const originalLog = console.log;
|
|
824
|
+
const originalWarn = console.warn;
|
|
825
|
+
const originalError = console.error;
|
|
826
|
+
const addLog = (type, args) => {
|
|
827
|
+
try {
|
|
828
|
+
const msg = args.map((arg) => {
|
|
829
|
+
if (arg instanceof Error) return `${arg.name}: ${arg.message}`;
|
|
830
|
+
if (typeof arg === "object") return JSON.stringify(arg);
|
|
831
|
+
return String(arg);
|
|
832
|
+
}).join(" ");
|
|
833
|
+
setLogs((prev) => [`[${type}] ${msg}`, ...prev].slice(0, 50));
|
|
834
|
+
} catch (e) {
|
|
835
|
+
}
|
|
836
|
+
};
|
|
837
|
+
console.log = (...args) => {
|
|
838
|
+
originalLog(...args);
|
|
839
|
+
addLog("LOG", args);
|
|
840
|
+
};
|
|
841
|
+
console.warn = (...args) => {
|
|
842
|
+
originalWarn(...args);
|
|
843
|
+
addLog("WRN", args);
|
|
844
|
+
};
|
|
845
|
+
console.error = (...args) => {
|
|
846
|
+
originalError(...args);
|
|
847
|
+
addLog("ERR", args);
|
|
848
|
+
};
|
|
849
|
+
return () => {
|
|
850
|
+
console.log = originalLog;
|
|
851
|
+
console.warn = originalWarn;
|
|
852
|
+
console.error = originalError;
|
|
853
|
+
};
|
|
854
|
+
}, []);
|
|
855
|
+
const handleVoiceResult = (0, import_react6.useCallback)((text, isFinal) => {
|
|
856
|
+
if (isFinal) {
|
|
857
|
+
onResult(text);
|
|
858
|
+
setErrorMsg(null);
|
|
859
|
+
setVoiceTrigger(null);
|
|
860
|
+
}
|
|
861
|
+
}, [onResult]);
|
|
862
|
+
const handleVoiceEnd = (0, import_react6.useCallback)(() => {
|
|
863
|
+
setVoiceTrigger(null);
|
|
864
|
+
}, []);
|
|
865
|
+
const nativeSpeech = useSpeechRecognition(handleVoiceResult, handleVoiceEnd, voiceConfig == null ? void 0 : voiceConfig.language);
|
|
866
|
+
import_react6.default.useEffect(() => {
|
|
867
|
+
if (nativeSpeech.error) {
|
|
868
|
+
setErrorMsg(nativeSpeech.error);
|
|
869
|
+
console.error("[TapToTalk] Native Speech Error:", nativeSpeech.error);
|
|
870
|
+
}
|
|
871
|
+
}, [nativeSpeech.error]);
|
|
872
|
+
const customRecorder = useAudioRecorder(async (blob) => {
|
|
873
|
+
setVoiceTrigger(null);
|
|
874
|
+
setIsTranscribing(true);
|
|
875
|
+
setErrorMsg(null);
|
|
876
|
+
if (blob.type === "audio/simulated") {
|
|
877
|
+
console.log("[TapToTalk] Handling simulated audio capture");
|
|
878
|
+
await new Promise((resolve) => setTimeout(resolve, 1500));
|
|
879
|
+
onResult("This is a simulated transcription for development testing.");
|
|
880
|
+
setIsTranscribing(false);
|
|
881
|
+
return;
|
|
882
|
+
}
|
|
883
|
+
if ((voiceConfig == null ? void 0 : voiceConfig.mode) === "custom" && voiceConfig.onAudioCapture) {
|
|
884
|
+
try {
|
|
885
|
+
const text = await voiceConfig.onAudioCapture(blob);
|
|
886
|
+
if (text) onResult(text);
|
|
887
|
+
} catch (error) {
|
|
888
|
+
console.error("[TapToTalk] Custom transcription failed:", error);
|
|
889
|
+
setErrorMsg(error.message || "Transcription failed");
|
|
890
|
+
} finally {
|
|
891
|
+
setIsTranscribing(false);
|
|
892
|
+
}
|
|
893
|
+
} else {
|
|
894
|
+
setIsTranscribing(false);
|
|
895
|
+
}
|
|
896
|
+
});
|
|
897
|
+
const isListening = !!voiceTrigger || nativeSpeech.isListening || customRecorder.isRecording;
|
|
898
|
+
const isActive = isListening || isTranscribing;
|
|
899
|
+
const toggleVoice = async () => {
|
|
900
|
+
const now = Date.now();
|
|
901
|
+
if (now - tapCountRef.current.lastTap < 500) {
|
|
902
|
+
tapCountRef.current.count++;
|
|
903
|
+
} else {
|
|
904
|
+
tapCountRef.current.count = 1;
|
|
905
|
+
}
|
|
906
|
+
tapCountRef.current.lastTap = now;
|
|
907
|
+
if (tapCountRef.current.count >= 5) {
|
|
908
|
+
setShowDebug((prev) => !prev);
|
|
909
|
+
tapCountRef.current.count = 0;
|
|
910
|
+
return;
|
|
911
|
+
}
|
|
912
|
+
if (isActive) {
|
|
913
|
+
if (isTranscribing && !isListening) return;
|
|
914
|
+
if ((voiceConfig == null ? void 0 : voiceConfig.mode) === "native") {
|
|
915
|
+
nativeSpeech.stop();
|
|
916
|
+
} else {
|
|
917
|
+
customRecorder.stop();
|
|
918
|
+
}
|
|
919
|
+
setVoiceTrigger(null);
|
|
920
|
+
} else {
|
|
921
|
+
setErrorMsg(null);
|
|
922
|
+
onFocusTarget == null ? void 0 : onFocusTarget();
|
|
923
|
+
setVoiceTrigger("click");
|
|
924
|
+
if ((voiceConfig == null ? void 0 : voiceConfig.mode) === "custom") {
|
|
925
|
+
try {
|
|
926
|
+
await customRecorder.start();
|
|
927
|
+
} catch (e) {
|
|
928
|
+
setErrorMsg("Mic access denied");
|
|
929
|
+
setVoiceTrigger(null);
|
|
930
|
+
}
|
|
931
|
+
} else {
|
|
932
|
+
if (!nativeSpeech.isSupported) {
|
|
933
|
+
setErrorMsg("Speech not supported");
|
|
934
|
+
setVoiceTrigger(null);
|
|
935
|
+
return;
|
|
936
|
+
}
|
|
937
|
+
nativeSpeech.start();
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
};
|
|
941
|
+
let bgColor = accentColor;
|
|
942
|
+
let label = "Tap to Talk";
|
|
943
|
+
let Icon = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_outline2.MicrophoneIcon, { className: "h-5 w-5" });
|
|
944
|
+
if (isListening) {
|
|
945
|
+
bgColor = "bg-orange-500";
|
|
946
|
+
label = "Listening ... Tap to stop";
|
|
947
|
+
Icon = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_outline2.MicrophoneIcon, { className: "h-5 w-5 animate-pulse" });
|
|
948
|
+
} else if (isTranscribing) {
|
|
949
|
+
bgColor = "bg-indigo-600";
|
|
950
|
+
label = "Transcribing ...";
|
|
951
|
+
Icon = /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("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: [
|
|
952
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
|
|
953
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("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" })
|
|
954
|
+
] });
|
|
955
|
+
}
|
|
956
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex flex-col w-full relative", children: [
|
|
957
|
+
showDebug && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("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: [
|
|
958
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex justify-between items-center bg-gray-800 p-1 mb-1", children: [
|
|
959
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "Debug Logs" }),
|
|
960
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { onClick: (e) => {
|
|
961
|
+
e.stopPropagation();
|
|
962
|
+
setShowDebug(false);
|
|
963
|
+
}, className: "text-white hover:text-red-400", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_outline2.XMarkIcon, { className: "w-4 h-4" }) })
|
|
964
|
+
] }),
|
|
965
|
+
logs.map((log, i) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "mb-0.5 border-b border-gray-700/50 pb-0.5 break-all", children: log }, i)),
|
|
966
|
+
logs.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { children: "No logs yet..." })
|
|
967
|
+
] }),
|
|
968
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
969
|
+
"button",
|
|
970
|
+
{
|
|
971
|
+
onClick: toggleVoice,
|
|
972
|
+
disabled: disabled || isTranscribing && !isListening,
|
|
973
|
+
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]
|
|
974
|
+
${bgColor} text-white
|
|
975
|
+
${disabled ? "opacity-50 cursor-not-allowed" : "cursor-pointer"}
|
|
976
|
+
${className}`,
|
|
977
|
+
title: label,
|
|
978
|
+
children: [
|
|
979
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "flex items-center justify-center shrink-0", children: Icon }),
|
|
980
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "truncate", children: label }),
|
|
981
|
+
errorMsg && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("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 })
|
|
982
|
+
]
|
|
983
|
+
}
|
|
984
|
+
)
|
|
985
|
+
] });
|
|
986
|
+
};
|
|
987
|
+
|
|
737
988
|
// src/ui/react/components/ChatMessageList.tsx
|
|
738
|
-
var
|
|
989
|
+
var import_react10 = require("react");
|
|
739
990
|
|
|
740
991
|
// src/ui/react/components/interactive/ConfirmInteraction.tsx
|
|
741
|
-
var
|
|
742
|
-
var
|
|
992
|
+
var import_react7 = require("react");
|
|
993
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
743
994
|
var ConfirmInteraction = ({
|
|
744
995
|
parameters,
|
|
745
996
|
onResponse,
|
|
746
997
|
isResponseSubmitted
|
|
747
998
|
}) => {
|
|
748
|
-
const [selectedOption, setSelectedOption] = (0,
|
|
999
|
+
const [selectedOption, setSelectedOption] = (0, import_react7.useState)(null);
|
|
749
1000
|
const params = parameters;
|
|
750
1001
|
const { yesPrompt, noPrompt } = params;
|
|
751
1002
|
console.log("[ConfirmInteraction] Parameters:", params);
|
|
@@ -754,8 +1005,8 @@ var ConfirmInteraction = ({
|
|
|
754
1005
|
setSelectedOption(buttonText);
|
|
755
1006
|
onResponse(value);
|
|
756
1007
|
};
|
|
757
|
-
return /* @__PURE__ */ (0,
|
|
758
|
-
/* @__PURE__ */ (0,
|
|
1008
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "mt-2 mb-4", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex space-x-2", children: [
|
|
1009
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
759
1010
|
"button",
|
|
760
1011
|
{
|
|
761
1012
|
onClick: () => handleOptionClick(true, yesPrompt),
|
|
@@ -764,7 +1015,7 @@ var ConfirmInteraction = ({
|
|
|
764
1015
|
children: yesPrompt
|
|
765
1016
|
}
|
|
766
1017
|
),
|
|
767
|
-
/* @__PURE__ */ (0,
|
|
1018
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
768
1019
|
"button",
|
|
769
1020
|
{
|
|
770
1021
|
onClick: () => handleOptionClick(false, noPrompt),
|
|
@@ -778,19 +1029,19 @@ var ConfirmInteraction = ({
|
|
|
778
1029
|
var ConfirmInteraction_default = ConfirmInteraction;
|
|
779
1030
|
|
|
780
1031
|
// src/ui/react/components/interactive/SelectInteraction.tsx
|
|
781
|
-
var
|
|
782
|
-
var
|
|
1032
|
+
var import_react8 = require("react");
|
|
1033
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
783
1034
|
var SelectInteraction = ({
|
|
784
1035
|
parameters,
|
|
785
1036
|
onResponse,
|
|
786
1037
|
isResponseSubmitted,
|
|
787
1038
|
message
|
|
788
1039
|
}) => {
|
|
789
|
-
const [selectedOption, setSelectedOption] = (0,
|
|
790
|
-
const [customOption, setCustomOption] = (0,
|
|
1040
|
+
const [selectedOption, setSelectedOption] = (0, import_react8.useState)(null);
|
|
1041
|
+
const [customOption, setCustomOption] = (0, import_react8.useState)(null);
|
|
791
1042
|
const params = parameters;
|
|
792
1043
|
const { question, options, placeholder } = params;
|
|
793
|
-
(0,
|
|
1044
|
+
(0, import_react8.useEffect)(() => {
|
|
794
1045
|
if (isResponseSubmitted && (message == null ? void 0 : message.responseValue)) {
|
|
795
1046
|
const responseValueStr = String(message.responseValue);
|
|
796
1047
|
setSelectedOption(responseValueStr);
|
|
@@ -805,8 +1056,8 @@ var SelectInteraction = ({
|
|
|
805
1056
|
setCustomOption(null);
|
|
806
1057
|
onResponse(option);
|
|
807
1058
|
};
|
|
808
|
-
return /* @__PURE__ */ (0,
|
|
809
|
-
/* @__PURE__ */ (0,
|
|
1059
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "mt-2 mb-4", children: [
|
|
1060
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "flex flex-wrap gap-2", children: options.map((option, index) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
810
1061
|
"button",
|
|
811
1062
|
{
|
|
812
1063
|
onClick: () => handleOptionClick(option),
|
|
@@ -816,9 +1067,9 @@ var SelectInteraction = ({
|
|
|
816
1067
|
},
|
|
817
1068
|
index
|
|
818
1069
|
)) }),
|
|
819
|
-
customOption && isResponseSubmitted && /* @__PURE__ */ (0,
|
|
1070
|
+
customOption && isResponseSubmitted && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "mt-2 text-sm text-amber-600 bg-amber-50 p-2 rounded", children: [
|
|
820
1071
|
"User provided custom option: ",
|
|
821
|
-
/* @__PURE__ */ (0,
|
|
1072
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { className: "font-semibold", children: [
|
|
822
1073
|
'"',
|
|
823
1074
|
customOption,
|
|
824
1075
|
'"'
|
|
@@ -829,20 +1080,20 @@ var SelectInteraction = ({
|
|
|
829
1080
|
var SelectInteraction_default = SelectInteraction;
|
|
830
1081
|
|
|
831
1082
|
// src/ui/react/components/interactive/FormInteraction.tsx
|
|
832
|
-
var
|
|
1083
|
+
var import_react9 = require("react");
|
|
833
1084
|
var import_lucide_react = require("lucide-react");
|
|
834
|
-
var
|
|
1085
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
835
1086
|
var FormInteraction = ({
|
|
836
1087
|
parameters,
|
|
837
1088
|
onResponse,
|
|
838
1089
|
isResponseSubmitted,
|
|
839
1090
|
submittedValues
|
|
840
1091
|
}) => {
|
|
841
|
-
const [isModalOpen, setIsModalOpen] = (0,
|
|
842
|
-
const [formValues, setFormValues] = (0,
|
|
843
|
-
const [isExpanded, setIsExpanded] = (0,
|
|
844
|
-
const [parsedFields, setParsedFields] = (0,
|
|
845
|
-
const formButtonsRef = (0,
|
|
1092
|
+
const [isModalOpen, setIsModalOpen] = (0, import_react9.useState)(false);
|
|
1093
|
+
const [formValues, setFormValues] = (0, import_react9.useState)({});
|
|
1094
|
+
const [isExpanded, setIsExpanded] = (0, import_react9.useState)(false);
|
|
1095
|
+
const [parsedFields, setParsedFields] = (0, import_react9.useState)([]);
|
|
1096
|
+
const formButtonsRef = (0, import_react9.useRef)(null);
|
|
846
1097
|
const parseParameters = () => {
|
|
847
1098
|
const { prompt, description, submitText = "Submit", cancelText = "Cancel" } = parameters;
|
|
848
1099
|
let fieldsArray = [];
|
|
@@ -903,7 +1154,7 @@ var FormInteraction = ({
|
|
|
903
1154
|
};
|
|
904
1155
|
};
|
|
905
1156
|
const params = parseParameters();
|
|
906
|
-
(0,
|
|
1157
|
+
(0, import_react9.useEffect)(() => {
|
|
907
1158
|
const processedParams = parseParameters();
|
|
908
1159
|
setParsedFields(processedParams.fields);
|
|
909
1160
|
const initialValues = {};
|
|
@@ -921,7 +1172,7 @@ var FormInteraction = ({
|
|
|
921
1172
|
setIsModalOpen(true);
|
|
922
1173
|
}
|
|
923
1174
|
}, [parameters, isResponseSubmitted]);
|
|
924
|
-
(0,
|
|
1175
|
+
(0, import_react9.useEffect)(() => {
|
|
925
1176
|
if (isModalOpen && formButtonsRef.current) {
|
|
926
1177
|
setTimeout(() => {
|
|
927
1178
|
var _a;
|
|
@@ -951,12 +1202,12 @@ var FormInteraction = ({
|
|
|
951
1202
|
case "email":
|
|
952
1203
|
case "number":
|
|
953
1204
|
case "password":
|
|
954
|
-
return /* @__PURE__ */ (0,
|
|
955
|
-
/* @__PURE__ */ (0,
|
|
1205
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "mb-4 flex items-center space-x-4", children: [
|
|
1206
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("label", { htmlFor: name, className: "text-sm font-medium text-gray-700 min-w-[120px]", children: [
|
|
956
1207
|
label,
|
|
957
|
-
required && /* @__PURE__ */ (0,
|
|
1208
|
+
required && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-red-500", children: "*" })
|
|
958
1209
|
] }),
|
|
959
|
-
/* @__PURE__ */ (0,
|
|
1210
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
960
1211
|
"input",
|
|
961
1212
|
{
|
|
962
1213
|
type: type === "string" ? "text" : type,
|
|
@@ -972,12 +1223,12 @@ var FormInteraction = ({
|
|
|
972
1223
|
)
|
|
973
1224
|
] }, name);
|
|
974
1225
|
case "textarea":
|
|
975
|
-
return /* @__PURE__ */ (0,
|
|
976
|
-
/* @__PURE__ */ (0,
|
|
1226
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "mb-4 flex items-start space-x-4", children: [
|
|
1227
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("label", { htmlFor: name, className: "text-sm font-medium text-gray-700 min-w-[120px] pt-2", children: [
|
|
977
1228
|
label,
|
|
978
|
-
required && /* @__PURE__ */ (0,
|
|
1229
|
+
required && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-red-500", children: "*" })
|
|
979
1230
|
] }),
|
|
980
|
-
/* @__PURE__ */ (0,
|
|
1231
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
981
1232
|
"textarea",
|
|
982
1233
|
{
|
|
983
1234
|
id: name,
|
|
@@ -993,12 +1244,12 @@ var FormInteraction = ({
|
|
|
993
1244
|
)
|
|
994
1245
|
] }, name);
|
|
995
1246
|
case "select":
|
|
996
|
-
return /* @__PURE__ */ (0,
|
|
997
|
-
/* @__PURE__ */ (0,
|
|
1247
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "mb-4 flex items-center space-x-4", children: [
|
|
1248
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("label", { htmlFor: name, className: "text-sm font-medium text-gray-700 min-w-[120px]", children: [
|
|
998
1249
|
label,
|
|
999
|
-
required && /* @__PURE__ */ (0,
|
|
1250
|
+
required && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-red-500", children: "*" })
|
|
1000
1251
|
] }),
|
|
1001
|
-
/* @__PURE__ */ (0,
|
|
1252
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1002
1253
|
"select",
|
|
1003
1254
|
{
|
|
1004
1255
|
id: name,
|
|
@@ -1009,17 +1260,17 @@ var FormInteraction = ({
|
|
|
1009
1260
|
disabled: isResponseSubmitted,
|
|
1010
1261
|
className: "flex-1 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",
|
|
1011
1262
|
children: [
|
|
1012
|
-
/* @__PURE__ */ (0,
|
|
1013
|
-
options == null ? void 0 : options.map((option, index) => /* @__PURE__ */ (0,
|
|
1263
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "", disabled: true, children: placeholder || "Select an option" }),
|
|
1264
|
+
options == null ? void 0 : options.map((option, index) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: option, children: option }, index))
|
|
1014
1265
|
]
|
|
1015
1266
|
}
|
|
1016
1267
|
)
|
|
1017
1268
|
] }, name);
|
|
1018
1269
|
case "checkbox":
|
|
1019
|
-
return /* @__PURE__ */ (0,
|
|
1020
|
-
/* @__PURE__ */ (0,
|
|
1021
|
-
/* @__PURE__ */ (0,
|
|
1022
|
-
/* @__PURE__ */ (0,
|
|
1270
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "mb-4 flex items-center space-x-4", children: [
|
|
1271
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "min-w-[120px]" }),
|
|
1272
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center", children: [
|
|
1273
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1023
1274
|
"input",
|
|
1024
1275
|
{
|
|
1025
1276
|
type: "checkbox",
|
|
@@ -1032,20 +1283,20 @@ var FormInteraction = ({
|
|
|
1032
1283
|
className: "h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500"
|
|
1033
1284
|
}
|
|
1034
1285
|
),
|
|
1035
|
-
/* @__PURE__ */ (0,
|
|
1286
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("label", { htmlFor: name, className: "ml-2 text-sm text-gray-700", children: [
|
|
1036
1287
|
label,
|
|
1037
|
-
required && /* @__PURE__ */ (0,
|
|
1288
|
+
required && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-red-500", children: "*" })
|
|
1038
1289
|
] })
|
|
1039
1290
|
] })
|
|
1040
1291
|
] }, name);
|
|
1041
1292
|
case "radio":
|
|
1042
|
-
return /* @__PURE__ */ (0,
|
|
1043
|
-
/* @__PURE__ */ (0,
|
|
1293
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "mb-4 flex space-x-4", children: [
|
|
1294
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "text-sm font-medium text-gray-700 min-w-[120px] pt-2", children: [
|
|
1044
1295
|
label,
|
|
1045
|
-
required && /* @__PURE__ */ (0,
|
|
1296
|
+
required && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-red-500", children: "*" })
|
|
1046
1297
|
] }),
|
|
1047
|
-
/* @__PURE__ */ (0,
|
|
1048
|
-
/* @__PURE__ */ (0,
|
|
1298
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex-1 space-y-2", children: options == null ? void 0 : options.map((option, index) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center", children: [
|
|
1299
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1049
1300
|
"input",
|
|
1050
1301
|
{
|
|
1051
1302
|
id: `${name}-${index}`,
|
|
@@ -1059,7 +1310,7 @@ var FormInteraction = ({
|
|
|
1059
1310
|
className: "h-4 w-4 text-blue-600 border-gray-300 focus:ring-blue-500"
|
|
1060
1311
|
}
|
|
1061
1312
|
),
|
|
1062
|
-
/* @__PURE__ */ (0,
|
|
1313
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { htmlFor: `${name}-${index}`, className: "ml-2 text-sm text-gray-700", children: option })
|
|
1063
1314
|
] }, index)) })
|
|
1064
1315
|
] }, name);
|
|
1065
1316
|
default:
|
|
@@ -1067,27 +1318,27 @@ var FormInteraction = ({
|
|
|
1067
1318
|
}
|
|
1068
1319
|
};
|
|
1069
1320
|
if (isResponseSubmitted) {
|
|
1070
|
-
return /* @__PURE__ */ (0,
|
|
1071
|
-
/* @__PURE__ */ (0,
|
|
1072
|
-
/* @__PURE__ */ (0,
|
|
1321
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "mt-2 bg-gray-50 p-3 rounded-md border border-gray-200", children: [
|
|
1322
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex justify-between items-center cursor-pointer", onClick: () => setIsExpanded(!isExpanded), children: [
|
|
1323
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "font-medium text-gray-700", children: [
|
|
1073
1324
|
isExpanded ? "Hide" : "Show",
|
|
1074
1325
|
" Form Responses"
|
|
1075
1326
|
] }),
|
|
1076
|
-
isExpanded ? /* @__PURE__ */ (0,
|
|
1327
|
+
isExpanded ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react.ChevronUpIcon, { className: "h-5 w-5 text-gray-500" }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react.ChevronDownIcon, { className: "h-5 w-5 text-gray-500" })
|
|
1077
1328
|
] }),
|
|
1078
|
-
isExpanded && /* @__PURE__ */ (0,
|
|
1079
|
-
/* @__PURE__ */ (0,
|
|
1329
|
+
isExpanded && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "mt-2 space-y-2", children: parsedFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex", children: [
|
|
1330
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "text-sm font-medium text-gray-600 mr-2", children: [
|
|
1080
1331
|
field.label,
|
|
1081
1332
|
":"
|
|
1082
1333
|
] }),
|
|
1083
|
-
/* @__PURE__ */ (0,
|
|
1334
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("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" })
|
|
1084
1335
|
] }, field.name)) })
|
|
1085
1336
|
] });
|
|
1086
1337
|
}
|
|
1087
|
-
return /* @__PURE__ */ (0,
|
|
1338
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "mt-2", children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "p-4", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("form", { onSubmit: handleSubmit, className: "mt-4", children: [
|
|
1088
1339
|
parsedFields.map((field) => renderField(field)),
|
|
1089
|
-
/* @__PURE__ */ (0,
|
|
1090
|
-
/* @__PURE__ */ (0,
|
|
1340
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { ref: formButtonsRef, className: "flex justify-end mt-4 space-x-2", children: [
|
|
1341
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1091
1342
|
"button",
|
|
1092
1343
|
{
|
|
1093
1344
|
type: "button",
|
|
@@ -1097,7 +1348,7 @@ var FormInteraction = ({
|
|
|
1097
1348
|
children: params.cancelText
|
|
1098
1349
|
}
|
|
1099
1350
|
),
|
|
1100
|
-
/* @__PURE__ */ (0,
|
|
1351
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1101
1352
|
"button",
|
|
1102
1353
|
{
|
|
1103
1354
|
type: "submit",
|
|
@@ -1112,12 +1363,12 @@ var FormInteraction = ({
|
|
|
1112
1363
|
var FormInteraction_default = FormInteraction;
|
|
1113
1364
|
|
|
1114
1365
|
// src/ui/react/components/interactive/PresentInteraction.tsx
|
|
1115
|
-
var
|
|
1366
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1116
1367
|
var ReactMarkdown2;
|
|
1117
1368
|
try {
|
|
1118
1369
|
ReactMarkdown2 = require("react-markdown");
|
|
1119
1370
|
} catch (error) {
|
|
1120
|
-
ReactMarkdown2 = ({ children }) => /* @__PURE__ */ (0,
|
|
1371
|
+
ReactMarkdown2 = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "whitespace-pre-wrap", children });
|
|
1121
1372
|
}
|
|
1122
1373
|
var PresentInteraction = ({
|
|
1123
1374
|
parameters
|
|
@@ -1155,15 +1406,15 @@ var PresentInteraction = ({
|
|
|
1155
1406
|
}
|
|
1156
1407
|
};
|
|
1157
1408
|
const styles = getLevelStyles();
|
|
1158
|
-
return /* @__PURE__ */ (0,
|
|
1159
|
-
title && /* @__PURE__ */ (0,
|
|
1160
|
-
/* @__PURE__ */ (0,
|
|
1409
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: `mt-2 mb-4 p-4 ${styles.container} border rounded-md`, children: [
|
|
1410
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: `font-medium ${styles.title} mb-2`, children: title }),
|
|
1411
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: `text-sm ${styles.content}`, children: format === "markdown" ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ReactMarkdown2, { className: "prose prose-sm max-w-none", children: content }) : format === "html" ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { dangerouslySetInnerHTML: { __html: content } }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "whitespace-pre-wrap", children: content }) })
|
|
1161
1412
|
] });
|
|
1162
1413
|
};
|
|
1163
1414
|
var PresentInteraction_default = PresentInteraction;
|
|
1164
1415
|
|
|
1165
1416
|
// src/ui/react/components/interactive/InteractiveMessageHandler.tsx
|
|
1166
|
-
var
|
|
1417
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1167
1418
|
var InteractiveMessageHandler = ({
|
|
1168
1419
|
message,
|
|
1169
1420
|
onResponse,
|
|
@@ -1174,7 +1425,7 @@ var InteractiveMessageHandler = ({
|
|
|
1174
1425
|
const submittedResponse = parentMessage == null ? void 0 : parentMessage.responseValue;
|
|
1175
1426
|
switch (functionType) {
|
|
1176
1427
|
case "confirm":
|
|
1177
|
-
return /* @__PURE__ */ (0,
|
|
1428
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1178
1429
|
ConfirmInteraction_default,
|
|
1179
1430
|
{
|
|
1180
1431
|
parameters,
|
|
@@ -1183,7 +1434,7 @@ var InteractiveMessageHandler = ({
|
|
|
1183
1434
|
}
|
|
1184
1435
|
);
|
|
1185
1436
|
case "select":
|
|
1186
|
-
return /* @__PURE__ */ (0,
|
|
1437
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1187
1438
|
SelectInteraction_default,
|
|
1188
1439
|
{
|
|
1189
1440
|
parameters,
|
|
@@ -1193,7 +1444,7 @@ var InteractiveMessageHandler = ({
|
|
|
1193
1444
|
}
|
|
1194
1445
|
);
|
|
1195
1446
|
case "form":
|
|
1196
|
-
return /* @__PURE__ */ (0,
|
|
1447
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1197
1448
|
FormInteraction_default,
|
|
1198
1449
|
{
|
|
1199
1450
|
parameters,
|
|
@@ -1203,7 +1454,7 @@ var InteractiveMessageHandler = ({
|
|
|
1203
1454
|
}
|
|
1204
1455
|
);
|
|
1205
1456
|
case "present":
|
|
1206
|
-
return /* @__PURE__ */ (0,
|
|
1457
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1207
1458
|
PresentInteraction_default,
|
|
1208
1459
|
{
|
|
1209
1460
|
parameters
|
|
@@ -1219,8 +1470,8 @@ var InteractiveMessageHandler = ({
|
|
|
1219
1470
|
var InteractiveMessageHandler_default = InteractiveMessageHandler;
|
|
1220
1471
|
|
|
1221
1472
|
// src/ui/react/components/ChatMessageList.tsx
|
|
1222
|
-
var
|
|
1223
|
-
var
|
|
1473
|
+
var import_outline3 = require("@heroicons/react/24/outline");
|
|
1474
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1224
1475
|
var ChatMessageList = ({
|
|
1225
1476
|
chatHistory,
|
|
1226
1477
|
isProcessing,
|
|
@@ -1229,10 +1480,10 @@ var ChatMessageList = ({
|
|
|
1229
1480
|
getContextExample,
|
|
1230
1481
|
onInteractiveResponse
|
|
1231
1482
|
}) => {
|
|
1232
|
-
const chatContainerRef = (0,
|
|
1233
|
-
const lastMessageRef = (0,
|
|
1234
|
-
const processingIndicatorRef = (0,
|
|
1235
|
-
(0,
|
|
1483
|
+
const chatContainerRef = (0, import_react10.useRef)(null);
|
|
1484
|
+
const lastMessageRef = (0, import_react10.useRef)(null);
|
|
1485
|
+
const processingIndicatorRef = (0, import_react10.useRef)(null);
|
|
1486
|
+
(0, import_react10.useEffect)(() => {
|
|
1236
1487
|
if (isProcessing && processingIndicatorRef.current) {
|
|
1237
1488
|
processingIndicatorRef.current.scrollIntoView({ behavior: "smooth" });
|
|
1238
1489
|
return;
|
|
@@ -1248,15 +1499,15 @@ var ChatMessageList = ({
|
|
|
1248
1499
|
onInteractiveResponse(messageId, response);
|
|
1249
1500
|
}
|
|
1250
1501
|
};
|
|
1251
|
-
return /* @__PURE__ */ (0,
|
|
1502
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
1252
1503
|
"div",
|
|
1253
1504
|
{
|
|
1254
1505
|
ref: chatContainerRef,
|
|
1255
1506
|
className: "flex-1 overflow-y-auto p-4 space-y-8 bg-gray-50",
|
|
1256
1507
|
children: [
|
|
1257
|
-
chatHistory.length === 0 && !isProcessing && /* @__PURE__ */ (0,
|
|
1258
|
-
/* @__PURE__ */ (0,
|
|
1259
|
-
/* @__PURE__ */ (0,
|
|
1508
|
+
chatHistory.length === 0 && !isProcessing && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "text-center py-8", children: [
|
|
1509
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h3", { className: "text-lg font-medium text-gray-700 mb-2", children: "How can I help you today?" }),
|
|
1510
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("p", { className: "text-sm text-gray-500 mb-4", children: [
|
|
1260
1511
|
"Try asking me something like ",
|
|
1261
1512
|
getContextExample()
|
|
1262
1513
|
] })
|
|
@@ -1265,14 +1516,14 @@ var ChatMessageList = ({
|
|
|
1265
1516
|
const isLastMessage = index === chatHistory.length - 1;
|
|
1266
1517
|
const isUser = message.role === "user";
|
|
1267
1518
|
const isError = message.role === "error";
|
|
1268
|
-
return /* @__PURE__ */ (0,
|
|
1519
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
1269
1520
|
"div",
|
|
1270
1521
|
{
|
|
1271
1522
|
ref: isLastMessage ? lastMessageRef : void 0,
|
|
1272
1523
|
className: `flex flex-col w-full ${isUser ? "items-end" : "items-start"}`,
|
|
1273
1524
|
children: [
|
|
1274
|
-
/* @__PURE__ */ (0,
|
|
1275
|
-
/* @__PURE__ */ (0,
|
|
1525
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "text-xs text-gray-400 mb-1 px-1", children: message.timestamp ? `${isUser ? "Sent" : "Received"} at ${new Date(message.timestamp).toLocaleString()}` : "" }),
|
|
1526
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "w-full", children: message.interactive && message.interactiveData ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: `max-w-[85%] ${isUser ? "ml-auto" : "mr-auto"}`, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1276
1527
|
InteractiveMessageHandler_default,
|
|
1277
1528
|
{
|
|
1278
1529
|
message: message.interactiveData,
|
|
@@ -1284,16 +1535,16 @@ var ChatMessageList = ({
|
|
|
1284
1535
|
isResponseSubmitted: !!message.isResponseSubmitted,
|
|
1285
1536
|
parentMessage: message
|
|
1286
1537
|
}
|
|
1287
|
-
) }) : /* @__PURE__ */ (0,
|
|
1538
|
+
) }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1288
1539
|
MessageBubble,
|
|
1289
1540
|
{
|
|
1290
1541
|
message,
|
|
1291
1542
|
isUser
|
|
1292
1543
|
}
|
|
1293
1544
|
) }),
|
|
1294
|
-
isUser && message.interactive && /* @__PURE__ */ (0,
|
|
1295
|
-
/* @__PURE__ */ (0,
|
|
1296
|
-
/* @__PURE__ */ (0,
|
|
1545
|
+
isUser && message.interactive && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex items-center mt-1 space-x-1 text-xs text-gray-500 italic", children: [
|
|
1546
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_outline3.InformationCircleIcon, { className: "h-3 w-3 text-blue-400" }),
|
|
1547
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { children: [
|
|
1297
1548
|
message.request === "form" && "Response to form submission",
|
|
1298
1549
|
message.request === "select" && "Response to selection prompt",
|
|
1299
1550
|
message.request === "confirm" && "Response to confirmation prompt"
|
|
@@ -1304,29 +1555,29 @@ var ChatMessageList = ({
|
|
|
1304
1555
|
message.id || `message-${index}`
|
|
1305
1556
|
);
|
|
1306
1557
|
}),
|
|
1307
|
-
isProcessing && /* @__PURE__ */ (0,
|
|
1558
|
+
isProcessing && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1308
1559
|
"div",
|
|
1309
1560
|
{
|
|
1310
1561
|
ref: processingIndicatorRef,
|
|
1311
1562
|
className: "flex justify-start my-4",
|
|
1312
|
-
children: /* @__PURE__ */ (0,
|
|
1313
|
-
/* @__PURE__ */ (0,
|
|
1314
|
-
/* @__PURE__ */ (0,
|
|
1315
|
-
/* @__PURE__ */ (0,
|
|
1316
|
-
/* @__PURE__ */ (0,
|
|
1317
|
-
/* @__PURE__ */ (0,
|
|
1563
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "bg-white text-gray-800 border border-gray-200 rounded-lg px-4 py-2 max-w-[85%]", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex items-center", children: [
|
|
1564
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "text-sm", children: processingHint }),
|
|
1565
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: "ml-2 flex space-x-1", children: [
|
|
1566
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "h-2 w-2 bg-gray-400 rounded-full animate-bounce", style: { animationDelay: "0ms" } }),
|
|
1567
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "h-2 w-2 bg-gray-400 rounded-full animate-bounce", style: { animationDelay: "150ms" } }),
|
|
1568
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "h-2 w-2 bg-gray-400 rounded-full animate-bounce", style: { animationDelay: "300ms" } })
|
|
1318
1569
|
] })
|
|
1319
1570
|
] }) })
|
|
1320
1571
|
}
|
|
1321
1572
|
),
|
|
1322
|
-
currentTask && !currentTask.complete && /* @__PURE__ */ (0,
|
|
1323
|
-
/* @__PURE__ */ (0,
|
|
1573
|
+
currentTask && !currentTask.complete && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "mt-4 bg-blue-50 border border-blue-100 rounded-lg p-3", children: [
|
|
1574
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "text-sm text-blue-800 mb-1", children: [
|
|
1324
1575
|
"Task in progress: Step ",
|
|
1325
1576
|
currentTask.currentStep,
|
|
1326
1577
|
" of ",
|
|
1327
1578
|
currentTask.steps
|
|
1328
1579
|
] }),
|
|
1329
|
-
/* @__PURE__ */ (0,
|
|
1580
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "w-full bg-blue-200 rounded-full h-2", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1330
1581
|
"div",
|
|
1331
1582
|
{
|
|
1332
1583
|
className: "bg-blue-500 h-2 rounded-full",
|
|
@@ -1341,34 +1592,34 @@ var ChatMessageList = ({
|
|
|
1341
1592
|
|
|
1342
1593
|
// src/ui/react/components/ConnectionStatus.tsx
|
|
1343
1594
|
var import_lucide_react2 = require("lucide-react");
|
|
1344
|
-
var
|
|
1595
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1345
1596
|
var ConnectionStatus = ({
|
|
1346
1597
|
connectionStatus,
|
|
1347
1598
|
onReconnect
|
|
1348
1599
|
}) => {
|
|
1349
|
-
return /* @__PURE__ */ (0,
|
|
1350
|
-
/* @__PURE__ */ (0,
|
|
1351
|
-
connectionStatus === "connected" && /* @__PURE__ */ (0,
|
|
1352
|
-
/* @__PURE__ */ (0,
|
|
1353
|
-
/* @__PURE__ */ (0,
|
|
1600
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "bg-amber-100 connection-status flex items-center justify-between px-4 py-1 text-xs", children: [
|
|
1601
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "text-gray-700 font-medium", children: "You are talking with your personal Content Strategist" }),
|
|
1602
|
+
connectionStatus === "connected" && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center text-green-600", children: [
|
|
1603
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react2.Wifi, { className: "w-3 h-3 mr-1" }),
|
|
1604
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: "Connected" })
|
|
1354
1605
|
] }),
|
|
1355
|
-
connectionStatus === "reconnecting" && /* @__PURE__ */ (0,
|
|
1356
|
-
/* @__PURE__ */ (0,
|
|
1357
|
-
/* @__PURE__ */ (0,
|
|
1606
|
+
connectionStatus === "reconnecting" && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center text-amber-600", children: [
|
|
1607
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react2.RefreshCw, { className: "w-3 h-3 mr-1 animate-spin" }),
|
|
1608
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: "Reconnecting..." })
|
|
1358
1609
|
] }),
|
|
1359
|
-
connectionStatus === "disconnected" && /* @__PURE__ */ (0,
|
|
1360
|
-
/* @__PURE__ */ (0,
|
|
1361
|
-
/* @__PURE__ */ (0,
|
|
1362
|
-
/* @__PURE__ */ (0,
|
|
1610
|
+
connectionStatus === "disconnected" && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
1611
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "text-red-600 flex items-center", children: [
|
|
1612
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react2.WifiOff, { className: "w-3 h-3 mr-1" }),
|
|
1613
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: "Disconnected" })
|
|
1363
1614
|
] }),
|
|
1364
|
-
/* @__PURE__ */ (0,
|
|
1615
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
1365
1616
|
"button",
|
|
1366
1617
|
{
|
|
1367
1618
|
onClick: onReconnect,
|
|
1368
1619
|
className: "text-blue-600 hover:text-blue-800 flex items-center",
|
|
1369
1620
|
children: [
|
|
1370
|
-
/* @__PURE__ */ (0,
|
|
1371
|
-
/* @__PURE__ */ (0,
|
|
1621
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react2.RefreshCw, { className: "w-3 h-3 mr-1" }),
|
|
1622
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: "Reconnect" })
|
|
1372
1623
|
]
|
|
1373
1624
|
}
|
|
1374
1625
|
)
|
|
@@ -1377,7 +1628,7 @@ var ConnectionStatus = ({
|
|
|
1377
1628
|
};
|
|
1378
1629
|
|
|
1379
1630
|
// src/ui/react/components/Spinner.tsx
|
|
1380
|
-
var
|
|
1631
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1381
1632
|
var Spinner = ({
|
|
1382
1633
|
size = "md",
|
|
1383
1634
|
className = "",
|
|
@@ -1389,7 +1640,7 @@ var Spinner = ({
|
|
|
1389
1640
|
lg: "h-8 w-8",
|
|
1390
1641
|
xl: "h-12 w-12"
|
|
1391
1642
|
};
|
|
1392
|
-
return /* @__PURE__ */ (0,
|
|
1643
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
1393
1644
|
"svg",
|
|
1394
1645
|
{
|
|
1395
1646
|
className: `animate-spin ${sizeClasses[size]} ${color} ${className}`,
|
|
@@ -1397,7 +1648,7 @@ var Spinner = ({
|
|
|
1397
1648
|
fill: "none",
|
|
1398
1649
|
viewBox: "0 0 24 24",
|
|
1399
1650
|
children: [
|
|
1400
|
-
/* @__PURE__ */ (0,
|
|
1651
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1401
1652
|
"circle",
|
|
1402
1653
|
{
|
|
1403
1654
|
className: "opacity-25",
|
|
@@ -1408,7 +1659,7 @@ var Spinner = ({
|
|
|
1408
1659
|
strokeWidth: "4"
|
|
1409
1660
|
}
|
|
1410
1661
|
),
|
|
1411
|
-
/* @__PURE__ */ (0,
|
|
1662
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1412
1663
|
"path",
|
|
1413
1664
|
{
|
|
1414
1665
|
className: "opacity-75",
|
|
@@ -1472,6 +1723,7 @@ function createWhisperVoiceConfig(config, callbacks) {
|
|
|
1472
1723
|
ConnectionStatus,
|
|
1473
1724
|
MessageBubble,
|
|
1474
1725
|
Spinner,
|
|
1726
|
+
TapToTalk,
|
|
1475
1727
|
createWhisperVoiceConfig,
|
|
1476
1728
|
transcribeAudio,
|
|
1477
1729
|
useAudioRecorder,
|