@superinterface/react 2.1.2 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +926 -1226
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -690
- package/dist/index.d.ts +18 -690
- package/dist/index.js +893 -1173
- package/dist/index.js.map +1 -1
- package/dist/mutationFns.cjs +1 -161
- package/dist/mutationFns.cjs.map +1 -1
- package/dist/mutationFns.d.cts +6 -26
- package/dist/mutationFns.d.ts +6 -26
- package/dist/mutationFns.js +1 -153
- package/dist/mutationFns.js.map +1 -1
- package/dist/queryFns.cjs +8 -56
- package/dist/queryFns.cjs.map +1 -1
- package/dist/queryFns.d.cts +4 -20
- package/dist/queryFns.d.ts +4 -20
- package/dist/queryFns.js +8 -48
- package/dist/queryFns.js.map +1 -1
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.cts +4 -3
- package/dist/types/index.d.ts +4 -3
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +6 -2
- package/dist/utils.d.ts +6 -2
- package/dist/utils.js.map +1 -1
- package/package.json +10 -7
package/dist/index.js
CHANGED
|
@@ -654,8 +654,23 @@ var AssistantNameContext = createContext4("Assistant");
|
|
|
654
654
|
// src/components/threads/Thread/Messages/Content/MessageGroup/Content/index.tsx
|
|
655
655
|
import { Flex as Flex10 } from "@radix-ui/themes";
|
|
656
656
|
// src/components/threads/Thread/Message/index.tsx
|
|
657
|
-
import { useMemo as useMemo4 } from "react";
|
|
657
|
+
import { useMemo as useMemo4, Fragment } from "react";
|
|
658
658
|
import { Box as Box9 } from "@radix-ui/themes";
|
|
659
|
+
// src/components/skeletons/StartingContentSkeleton/index.tsx
|
|
660
|
+
import { Skeleton as Skeleton2 } from "@radix-ui/themes";
|
|
661
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
662
|
+
var StartingContentSkeleton = function() {
|
|
663
|
+
return /* @__PURE__ */ jsx7(Skeleton2, {
|
|
664
|
+
loading: true,
|
|
665
|
+
mt: "1",
|
|
666
|
+
height: "var(--space-4)",
|
|
667
|
+
width: "var(--space-4)",
|
|
668
|
+
style: {
|
|
669
|
+
borderRadius: "var(--radius-6)",
|
|
670
|
+
flexShrink: 0
|
|
671
|
+
}
|
|
672
|
+
});
|
|
673
|
+
};
|
|
659
674
|
// src/components/runSteps/RunSteps/index.tsx
|
|
660
675
|
import { Flex as Flex9 } from "@radix-ui/themes";
|
|
661
676
|
// src/components/runSteps/RunStep/ToolCalls/index.tsx
|
|
@@ -671,14 +686,14 @@ var FunctionComponentsContext = createContext5({});
|
|
|
671
686
|
import { PopoverRoot, PopoverContent } from "@radix-ui/themes";
|
|
672
687
|
// src/components/toolCalls/ToolCallBase/index.tsx
|
|
673
688
|
import { Flex as Flex5, Button, PopoverTrigger } from "@radix-ui/themes";
|
|
674
|
-
import { jsx as
|
|
689
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
675
690
|
var ToolCallBase = function(param) {
|
|
676
691
|
var children = param.children;
|
|
677
|
-
return /* @__PURE__ */
|
|
692
|
+
return /* @__PURE__ */ jsx8(Flex5, {
|
|
678
693
|
py: "1",
|
|
679
694
|
ml: "-2",
|
|
680
|
-
children: /* @__PURE__ */
|
|
681
|
-
children: /* @__PURE__ */
|
|
695
|
+
children: /* @__PURE__ */ jsx8(PopoverTrigger, {
|
|
696
|
+
children: /* @__PURE__ */ jsx8(Button, {
|
|
682
697
|
size: "1",
|
|
683
698
|
color: "gold",
|
|
684
699
|
variant: "outline",
|
|
@@ -692,31 +707,31 @@ var ToolCallBase = function(param) {
|
|
|
692
707
|
};
|
|
693
708
|
// src/components/toolCalls/ToolCallBase/ToolCallTitle.tsx
|
|
694
709
|
import { Text as Text2 } from "@radix-ui/themes";
|
|
695
|
-
import { jsx as
|
|
710
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
696
711
|
var ToolCallTitle = function(param) {
|
|
697
712
|
var children = param.children;
|
|
698
|
-
return /* @__PURE__ */
|
|
713
|
+
return /* @__PURE__ */ jsx9(Text2, {
|
|
699
714
|
weight: "regular",
|
|
700
715
|
children: children
|
|
701
716
|
});
|
|
702
717
|
};
|
|
703
718
|
// src/components/functions/FunctionBase/Icon.tsx
|
|
704
719
|
import { CircleIcon, CircleBackslashIcon, CheckCircledIcon } from "@radix-ui/react-icons";
|
|
705
|
-
import { jsx as
|
|
720
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
706
721
|
var Icon = function(param) {
|
|
707
722
|
var runStep = param.runStep;
|
|
708
723
|
if (runStep.completed_at) {
|
|
709
|
-
return /* @__PURE__ */
|
|
724
|
+
return /* @__PURE__ */ jsx10(CheckCircledIcon, {});
|
|
710
725
|
} else if (runStep.cancelled_at || runStep.failed_at || runStep.status === "expired") {
|
|
711
|
-
return /* @__PURE__ */
|
|
726
|
+
return /* @__PURE__ */ jsx10(CircleBackslashIcon, {});
|
|
712
727
|
} else {
|
|
713
|
-
return /* @__PURE__ */
|
|
728
|
+
return /* @__PURE__ */ jsx10(CircleIcon, {});
|
|
714
729
|
}
|
|
715
730
|
};
|
|
716
731
|
// src/components/functions/FunctionBase/Content.tsx
|
|
717
732
|
import { useMemo as useMemo3 } from "react";
|
|
718
733
|
import { Code, Box as Box2 } from "@radix-ui/themes";
|
|
719
|
-
import { jsx as
|
|
734
|
+
import { jsx as jsx11, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
720
735
|
var Content = function(param) {
|
|
721
736
|
var fn = param.fn;
|
|
722
737
|
var args = useMemo3(function() {
|
|
@@ -755,36 +770,36 @@ var Content = function(param) {
|
|
|
755
770
|
wordBreak: "break-word"
|
|
756
771
|
},
|
|
757
772
|
children: [
|
|
758
|
-
/* @__PURE__ */
|
|
773
|
+
/* @__PURE__ */ jsx11(Box2, {
|
|
759
774
|
children: args && JSON.stringify(args, null, 2)
|
|
760
775
|
}),
|
|
761
|
-
/* @__PURE__ */
|
|
776
|
+
/* @__PURE__ */ jsx11(Box2, {
|
|
762
777
|
children: output && JSON.stringify(output, null, 2)
|
|
763
778
|
})
|
|
764
779
|
]
|
|
765
780
|
});
|
|
766
781
|
};
|
|
767
782
|
// src/components/functions/FunctionBase/index.tsx
|
|
768
|
-
import { jsx as
|
|
783
|
+
import { jsx as jsx12, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
769
784
|
var FunctionBase = function(param) {
|
|
770
785
|
var fn = param.fn, runStep = param.runStep, title2 = param.title;
|
|
771
786
|
return /* @__PURE__ */ jsxs3(PopoverRoot, {
|
|
772
787
|
children: [
|
|
773
788
|
/* @__PURE__ */ jsxs3(ToolCallBase, {
|
|
774
789
|
children: [
|
|
775
|
-
/* @__PURE__ */
|
|
790
|
+
/* @__PURE__ */ jsx12(Icon, {
|
|
776
791
|
runStep: runStep
|
|
777
792
|
}),
|
|
778
|
-
/* @__PURE__ */
|
|
793
|
+
/* @__PURE__ */ jsx12(ToolCallTitle, {
|
|
779
794
|
children: title2
|
|
780
795
|
})
|
|
781
796
|
]
|
|
782
797
|
}),
|
|
783
|
-
/* @__PURE__ */
|
|
798
|
+
/* @__PURE__ */ jsx12(PopoverContent, {
|
|
784
799
|
style: {
|
|
785
|
-
maxHeight: "
|
|
800
|
+
maxHeight: "200px"
|
|
786
801
|
},
|
|
787
|
-
children: /* @__PURE__ */
|
|
802
|
+
children: /* @__PURE__ */ jsx12(Content, {
|
|
788
803
|
fn: fn
|
|
789
804
|
})
|
|
790
805
|
})
|
|
@@ -803,10 +818,10 @@ var title = function(param) {
|
|
|
803
818
|
}
|
|
804
819
|
};
|
|
805
820
|
// src/components/runSteps/RunStep/ToolCalls/ToolCall/Fn/DefaultFunction/index.tsx
|
|
806
|
-
import { jsx as
|
|
821
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
807
822
|
var DefaultFunction = function(param) {
|
|
808
823
|
var fn = param.fn, runStep = param.runStep;
|
|
809
|
-
return /* @__PURE__ */
|
|
824
|
+
return /* @__PURE__ */ jsx13(FunctionBase, {
|
|
810
825
|
fn: fn,
|
|
811
826
|
runStep: runStep,
|
|
812
827
|
title: title({
|
|
@@ -816,66 +831,66 @@ var DefaultFunction = function(param) {
|
|
|
816
831
|
});
|
|
817
832
|
};
|
|
818
833
|
// src/components/runSteps/RunStep/ToolCalls/ToolCall/Fn/index.tsx
|
|
819
|
-
import { jsx as
|
|
834
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
820
835
|
var Fn = function(param) {
|
|
821
836
|
var fn = param.fn, runStep = param.runStep;
|
|
822
837
|
var functionComponentsContext = useContext4(FunctionComponentsContext);
|
|
823
838
|
var Component = functionComponentsContext[fn.name] || DefaultFunction;
|
|
824
839
|
return(// @ts-ignore-next-line
|
|
825
|
-
/* @__PURE__ */
|
|
840
|
+
/* @__PURE__ */ jsx14(Component, {
|
|
826
841
|
fn: fn,
|
|
827
842
|
runStep: runStep
|
|
828
843
|
}));
|
|
829
844
|
};
|
|
830
845
|
// src/components/runSteps/RunStep/ToolCalls/ToolCall/CodeInterpreter/index.tsx
|
|
831
846
|
import { Flex as Flex6 } from "@radix-ui/themes";
|
|
832
|
-
import { jsx as
|
|
847
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
833
848
|
var CodeInterpreter = function(param) {
|
|
834
849
|
var codeInterpreter = param.codeInterpreter;
|
|
835
|
-
return /* @__PURE__ */
|
|
850
|
+
return /* @__PURE__ */ jsx15(Flex6, {
|
|
836
851
|
children: codeInterpreter.input
|
|
837
852
|
});
|
|
838
853
|
};
|
|
839
854
|
// src/components/runSteps/RunStep/ToolCalls/ToolCall/index.tsx
|
|
840
|
-
import { jsx as
|
|
855
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
841
856
|
var ToolCall = function(param) {
|
|
842
857
|
var toolCall = param.toolCall, runStep = param.runStep;
|
|
843
858
|
if (toolCall.type === "function") {
|
|
844
|
-
return /* @__PURE__ */
|
|
859
|
+
return /* @__PURE__ */ jsx16(Fn, {
|
|
845
860
|
fn: toolCall.function,
|
|
846
861
|
runStep: runStep
|
|
847
862
|
});
|
|
848
863
|
}
|
|
849
864
|
if (toolCall.type === "code_interpreter") {
|
|
850
|
-
return /* @__PURE__ */
|
|
865
|
+
return /* @__PURE__ */ jsx16(CodeInterpreter, {
|
|
851
866
|
codeInterpreter: toolCall.code_interpreter,
|
|
852
867
|
runStep: runStep
|
|
853
868
|
});
|
|
854
869
|
}
|
|
855
|
-
return /* @__PURE__ */
|
|
870
|
+
return /* @__PURE__ */ jsx16(Flex7, {
|
|
856
871
|
children: toolCall.type
|
|
857
872
|
});
|
|
858
873
|
};
|
|
859
874
|
// src/components/runSteps/RunStep/ToolCalls/Starting/index.tsx
|
|
860
875
|
import { PopoverRoot as PopoverRoot2, PopoverContent as PopoverContent2, Text as Text3 } from "@radix-ui/themes";
|
|
861
876
|
import { CircleIcon as CircleIcon2 } from "@radix-ui/react-icons";
|
|
862
|
-
import { jsx as
|
|
877
|
+
import { jsx as jsx17, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
863
878
|
var Starting = function() {
|
|
864
879
|
return /* @__PURE__ */ jsxs4(PopoverRoot2, {
|
|
865
880
|
children: [
|
|
866
881
|
/* @__PURE__ */ jsxs4(ToolCallBase, {
|
|
867
882
|
children: [
|
|
868
|
-
/* @__PURE__ */
|
|
869
|
-
/* @__PURE__ */
|
|
883
|
+
/* @__PURE__ */ jsx17(CircleIcon2, {}),
|
|
884
|
+
/* @__PURE__ */ jsx17(ToolCallTitle, {
|
|
870
885
|
children: "Starting actions"
|
|
871
886
|
})
|
|
872
887
|
]
|
|
873
888
|
}),
|
|
874
|
-
/* @__PURE__ */
|
|
889
|
+
/* @__PURE__ */ jsx17(PopoverContent2, {
|
|
875
890
|
style: {
|
|
876
891
|
maxHeight: "500px"
|
|
877
892
|
},
|
|
878
|
-
children: /* @__PURE__ */
|
|
893
|
+
children: /* @__PURE__ */ jsx17(Text3, {
|
|
879
894
|
children: "Getting ready to connect to domain API"
|
|
880
895
|
})
|
|
881
896
|
})
|
|
@@ -883,15 +898,15 @@ var Starting = function() {
|
|
|
883
898
|
});
|
|
884
899
|
};
|
|
885
900
|
// src/components/runSteps/RunStep/ToolCalls/index.tsx
|
|
886
|
-
import { jsx as
|
|
901
|
+
import { jsx as jsx18, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
887
902
|
var ToolCalls = function(param) {
|
|
888
903
|
var stepDetails = param.stepDetails, runStep = param.runStep;
|
|
889
904
|
return /* @__PURE__ */ jsxs5(Flex8, {
|
|
890
905
|
direction: "column",
|
|
891
906
|
children: [
|
|
892
|
-
!stepDetails.tool_calls.length && /* @__PURE__ */
|
|
907
|
+
!stepDetails.tool_calls.length && /* @__PURE__ */ jsx18(Starting, {}),
|
|
893
908
|
stepDetails.tool_calls.map(function(toolCall) {
|
|
894
|
-
return /* @__PURE__ */
|
|
909
|
+
return /* @__PURE__ */ jsx18(ToolCall, {
|
|
895
910
|
toolCall: toolCall,
|
|
896
911
|
runStep: runStep
|
|
897
912
|
}, toolCall.id);
|
|
@@ -900,11 +915,11 @@ var ToolCalls = function(param) {
|
|
|
900
915
|
});
|
|
901
916
|
};
|
|
902
917
|
// src/components/runSteps/RunStep/index.tsx
|
|
903
|
-
import { jsx as
|
|
918
|
+
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
904
919
|
var RunStep = function(param) {
|
|
905
920
|
var runStep = param.runStep;
|
|
906
921
|
if (runStep.step_details.type === "tool_calls") {
|
|
907
|
-
return /* @__PURE__ */
|
|
922
|
+
return /* @__PURE__ */ jsx19(ToolCalls, {
|
|
908
923
|
stepDetails: runStep.step_details,
|
|
909
924
|
runStep: runStep
|
|
910
925
|
});
|
|
@@ -912,13 +927,13 @@ var RunStep = function(param) {
|
|
|
912
927
|
return null;
|
|
913
928
|
};
|
|
914
929
|
// src/components/runSteps/RunSteps/index.tsx
|
|
915
|
-
import { jsx as
|
|
930
|
+
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
916
931
|
var RunSteps = function(param) {
|
|
917
932
|
var runSteps = param.runSteps;
|
|
918
|
-
return /* @__PURE__ */
|
|
933
|
+
return /* @__PURE__ */ jsx20(Flex9, {
|
|
919
934
|
direction: "column-reverse",
|
|
920
935
|
children: runSteps.map(function(runStep) {
|
|
921
|
-
return /* @__PURE__ */
|
|
936
|
+
return /* @__PURE__ */ jsx20(RunStep, {
|
|
922
937
|
runStep: runStep
|
|
923
938
|
}, runStep.id);
|
|
924
939
|
})
|
|
@@ -939,12 +954,12 @@ import { useContext as useContext5 } from "react";
|
|
|
939
954
|
import { createContext as createContext7 } from "react";
|
|
940
955
|
// src/contexts/markdown/MarkdownContext/lib/components/Paragraph.tsx
|
|
941
956
|
import { Box as Box3, Text as Text4 } from "@radix-ui/themes";
|
|
942
|
-
import { jsx as
|
|
957
|
+
import { jsx as jsx21 } from "react/jsx-runtime";
|
|
943
958
|
var Paragraph = function(param) {
|
|
944
959
|
var children = param.children;
|
|
945
|
-
return /* @__PURE__ */
|
|
960
|
+
return /* @__PURE__ */ jsx21(Box3, {
|
|
946
961
|
pb: "3",
|
|
947
|
-
children: /* @__PURE__ */
|
|
962
|
+
children: /* @__PURE__ */ jsx21(Text4, {
|
|
948
963
|
size: "3",
|
|
949
964
|
style: {
|
|
950
965
|
whiteSpace: "pre-line",
|
|
@@ -956,23 +971,23 @@ var Paragraph = function(param) {
|
|
|
956
971
|
};
|
|
957
972
|
// src/contexts/markdown/MarkdownContext/lib/components/Link.tsx
|
|
958
973
|
import { Link as RadixLink } from "@radix-ui/themes";
|
|
959
|
-
import { jsx as
|
|
974
|
+
import { jsx as jsx22 } from "react/jsx-runtime";
|
|
960
975
|
var Link = function(param) {
|
|
961
976
|
var children = param.children, href = param.href;
|
|
962
|
-
return /* @__PURE__ */
|
|
977
|
+
return /* @__PURE__ */ jsx22(RadixLink, {
|
|
963
978
|
href: href,
|
|
964
979
|
children: children
|
|
965
980
|
});
|
|
966
981
|
};
|
|
967
982
|
// src/contexts/markdown/MarkdownContext/lib/components/UnorderedList.tsx
|
|
968
983
|
import { Box as Box4 } from "@radix-ui/themes";
|
|
969
|
-
import { jsx as
|
|
984
|
+
import { jsx as jsx23 } from "react/jsx-runtime";
|
|
970
985
|
var UnorderedList = function(param) {
|
|
971
986
|
var children = param.children;
|
|
972
|
-
return /* @__PURE__ */
|
|
987
|
+
return /* @__PURE__ */ jsx23(Box4, {
|
|
973
988
|
pb: "3",
|
|
974
989
|
asChild: true,
|
|
975
|
-
children: /* @__PURE__ */
|
|
990
|
+
children: /* @__PURE__ */ jsx23("ul", {
|
|
976
991
|
style: {
|
|
977
992
|
listStylePosition: "inside"
|
|
978
993
|
},
|
|
@@ -982,13 +997,13 @@ var UnorderedList = function(param) {
|
|
|
982
997
|
};
|
|
983
998
|
// src/contexts/markdown/MarkdownContext/lib/components/OrderedList.tsx
|
|
984
999
|
import { Box as Box5 } from "@radix-ui/themes";
|
|
985
|
-
import { jsx as
|
|
1000
|
+
import { jsx as jsx24 } from "react/jsx-runtime";
|
|
986
1001
|
var OrderedList = function(param) {
|
|
987
1002
|
var children = param.children;
|
|
988
|
-
return /* @__PURE__ */
|
|
1003
|
+
return /* @__PURE__ */ jsx24(Box5, {
|
|
989
1004
|
pb: "3",
|
|
990
1005
|
asChild: true,
|
|
991
|
-
children: /* @__PURE__ */
|
|
1006
|
+
children: /* @__PURE__ */ jsx24("ol", {
|
|
992
1007
|
style: {
|
|
993
1008
|
listStylePosition: "inside"
|
|
994
1009
|
},
|
|
@@ -998,31 +1013,31 @@ var OrderedList = function(param) {
|
|
|
998
1013
|
};
|
|
999
1014
|
// src/contexts/markdown/MarkdownContext/lib/components/ListItem.tsx
|
|
1000
1015
|
import { Box as Box6 } from "@radix-ui/themes";
|
|
1001
|
-
import { jsx as
|
|
1016
|
+
import { jsx as jsx25 } from "react/jsx-runtime";
|
|
1002
1017
|
var ListItem = function(param) {
|
|
1003
1018
|
var children = param.children;
|
|
1004
|
-
return /* @__PURE__ */
|
|
1019
|
+
return /* @__PURE__ */ jsx25(Box6, {
|
|
1005
1020
|
pb: "1",
|
|
1006
|
-
children: /* @__PURE__ */
|
|
1021
|
+
children: /* @__PURE__ */ jsx25("li", {
|
|
1007
1022
|
children: children
|
|
1008
1023
|
})
|
|
1009
1024
|
});
|
|
1010
1025
|
};
|
|
1011
1026
|
// src/contexts/markdown/MarkdownContext/lib/components/Strong.tsx
|
|
1012
1027
|
import { Strong as RadixStrong } from "@radix-ui/themes";
|
|
1013
|
-
import { jsx as
|
|
1028
|
+
import { jsx as jsx26 } from "react/jsx-runtime";
|
|
1014
1029
|
var Strong = function(param) {
|
|
1015
1030
|
var children = param.children;
|
|
1016
|
-
return /* @__PURE__ */
|
|
1031
|
+
return /* @__PURE__ */ jsx26(RadixStrong, {
|
|
1017
1032
|
children: children
|
|
1018
1033
|
});
|
|
1019
1034
|
};
|
|
1020
1035
|
// src/contexts/markdown/MarkdownContext/lib/components/Pre.tsx
|
|
1021
1036
|
import { Box as Box7 } from "@radix-ui/themes";
|
|
1022
|
-
import { jsx as
|
|
1037
|
+
import { jsx as jsx27 } from "react/jsx-runtime";
|
|
1023
1038
|
var Pre = function(param) {
|
|
1024
1039
|
var children = param.children;
|
|
1025
|
-
return /* @__PURE__ */
|
|
1040
|
+
return /* @__PURE__ */ jsx27(Box7, {
|
|
1026
1041
|
style: {
|
|
1027
1042
|
whiteSpace: "pre-wrap",
|
|
1028
1043
|
wordBreak: "break-word"
|
|
@@ -1032,20 +1047,20 @@ var Pre = function(param) {
|
|
|
1032
1047
|
};
|
|
1033
1048
|
// src/contexts/markdown/MarkdownContext/lib/components/Code.tsx
|
|
1034
1049
|
import { Code as RadixCode } from "@radix-ui/themes";
|
|
1035
|
-
import { jsx as
|
|
1050
|
+
import { jsx as jsx28 } from "react/jsx-runtime";
|
|
1036
1051
|
var Code2 = function(param) {
|
|
1037
1052
|
var children = param.children;
|
|
1038
|
-
return /* @__PURE__ */
|
|
1053
|
+
return /* @__PURE__ */ jsx28(RadixCode, {
|
|
1039
1054
|
children: children
|
|
1040
1055
|
});
|
|
1041
1056
|
};
|
|
1042
1057
|
// src/contexts/markdown/MarkdownContext/lib/components/Img.tsx
|
|
1043
1058
|
import { Box as Box8 } from "@radix-ui/themes";
|
|
1044
|
-
import { jsx as
|
|
1059
|
+
import { jsx as jsx29 } from "react/jsx-runtime";
|
|
1045
1060
|
var Img = function(props) {
|
|
1046
|
-
return /* @__PURE__ */
|
|
1061
|
+
return /* @__PURE__ */ jsx29(Box8, {
|
|
1047
1062
|
pb: "3",
|
|
1048
|
-
children: /* @__PURE__ */
|
|
1063
|
+
children: /* @__PURE__ */ jsx29("img", _object_spread_props(_object_spread({}, props), {
|
|
1049
1064
|
style: {
|
|
1050
1065
|
maxWidth: "100%",
|
|
1051
1066
|
height: "auto"
|
|
@@ -1083,7 +1098,7 @@ var TextContent = function(param) {
|
|
|
1083
1098
|
return useRemarkSync(content.text.value, markdownContext);
|
|
1084
1099
|
};
|
|
1085
1100
|
// src/components/threads/Thread/Message/index.tsx
|
|
1086
|
-
import { jsx as
|
|
1101
|
+
import { jsx as jsx30, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1087
1102
|
var Message = function(param) {
|
|
1088
1103
|
var message = param.message;
|
|
1089
1104
|
var _useMemo4 = _sliced_to_array(useMemo4(function() {
|
|
@@ -1118,23 +1133,28 @@ var Message = function(param) {
|
|
|
1118
1133
|
}, [
|
|
1119
1134
|
message
|
|
1120
1135
|
]), 2), olderRunSteps = _useMemo4[0], laterRunSteps = _useMemo4[1];
|
|
1121
|
-
return /* @__PURE__ */
|
|
1136
|
+
return /* @__PURE__ */ jsx30(Provider, {
|
|
1122
1137
|
value: {
|
|
1123
1138
|
message: message
|
|
1124
1139
|
},
|
|
1125
1140
|
children: /* @__PURE__ */ jsxs6(Box9, {
|
|
1126
1141
|
children: [
|
|
1127
|
-
/* @__PURE__ */
|
|
1142
|
+
/* @__PURE__ */ jsx30(RunSteps, {
|
|
1128
1143
|
runSteps: olderRunSteps
|
|
1129
1144
|
}),
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1145
|
+
/* @__PURE__ */ jsxs6(Box9, {
|
|
1146
|
+
children: [
|
|
1147
|
+
message.content.map(function(content, index) {
|
|
1148
|
+
return /* @__PURE__ */ jsx30(Fragment, {
|
|
1149
|
+
children: content.type === "text" && /* @__PURE__ */ jsx30(TextContent, {
|
|
1150
|
+
content: content
|
|
1151
|
+
})
|
|
1152
|
+
}, index);
|
|
1153
|
+
}),
|
|
1154
|
+
message.status === "in_progress" && /* @__PURE__ */ jsx30(StartingContentSkeleton, {})
|
|
1155
|
+
]
|
|
1136
1156
|
}),
|
|
1137
|
-
/* @__PURE__ */
|
|
1157
|
+
/* @__PURE__ */ jsx30(RunSteps, {
|
|
1138
1158
|
runSteps: laterRunSteps
|
|
1139
1159
|
})
|
|
1140
1160
|
]
|
|
@@ -1142,36 +1162,36 @@ var Message = function(param) {
|
|
|
1142
1162
|
});
|
|
1143
1163
|
};
|
|
1144
1164
|
// src/components/threads/Thread/Messages/Content/MessageGroup/Content/index.tsx
|
|
1145
|
-
import { jsx as
|
|
1165
|
+
import { jsx as jsx31 } from "react/jsx-runtime";
|
|
1146
1166
|
var Content2 = function(param) {
|
|
1147
1167
|
var messageGroup = param.messageGroup;
|
|
1148
|
-
return /* @__PURE__ */
|
|
1168
|
+
return /* @__PURE__ */ jsx31(Flex10, {
|
|
1149
1169
|
direction: "column-reverse",
|
|
1150
1170
|
children: messageGroup.messages.map(function(message) {
|
|
1151
|
-
return /* @__PURE__ */
|
|
1171
|
+
return /* @__PURE__ */ jsx31(Message, {
|
|
1152
1172
|
message: message
|
|
1153
1173
|
}, message.id);
|
|
1154
1174
|
})
|
|
1155
1175
|
});
|
|
1156
1176
|
};
|
|
1157
1177
|
// src/components/threads/Thread/Messages/Content/MessageGroup/index.tsx
|
|
1158
|
-
import { jsx as
|
|
1178
|
+
import { jsx as jsx32, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1159
1179
|
var MessageGroup = function(param) {
|
|
1160
1180
|
var messageGroup = param.messageGroup;
|
|
1161
1181
|
var assistantNameContext = useContext6(AssistantNameContext);
|
|
1162
1182
|
return /* @__PURE__ */ jsxs7(MessageGroupBase, {
|
|
1163
1183
|
children: [
|
|
1164
|
-
messageGroup.role === "user" ? /* @__PURE__ */
|
|
1165
|
-
fallback: /* @__PURE__ */
|
|
1184
|
+
messageGroup.role === "user" ? /* @__PURE__ */ jsx32(Avatar3, {
|
|
1185
|
+
fallback: /* @__PURE__ */ jsx32(PersonIcon, {}),
|
|
1166
1186
|
size: "1"
|
|
1167
|
-
}) : /* @__PURE__ */
|
|
1187
|
+
}) : /* @__PURE__ */ jsx32(AssistantAvatar, {}),
|
|
1168
1188
|
/* @__PURE__ */ jsxs7(Box10, {
|
|
1169
1189
|
flexGrow: "1",
|
|
1170
1190
|
children: [
|
|
1171
|
-
/* @__PURE__ */
|
|
1191
|
+
/* @__PURE__ */ jsx32(Name, {
|
|
1172
1192
|
children: messageGroup.role === "user" ? "You" : assistantNameContext
|
|
1173
1193
|
}),
|
|
1174
|
-
/* @__PURE__ */
|
|
1194
|
+
/* @__PURE__ */ jsx32(Content2, {
|
|
1175
1195
|
messageGroup: messageGroup
|
|
1176
1196
|
})
|
|
1177
1197
|
]
|
|
@@ -1180,7 +1200,7 @@ var MessageGroup = function(param) {
|
|
|
1180
1200
|
});
|
|
1181
1201
|
};
|
|
1182
1202
|
// src/components/threads/Thread/Messages/Content/index.tsx
|
|
1183
|
-
import { Fragment, jsx as
|
|
1203
|
+
import { Fragment as Fragment2, jsx as jsx33 } from "react/jsx-runtime";
|
|
1184
1204
|
var Content3 = function() {
|
|
1185
1205
|
var _useMessages = useMessages(), messages2 = _useMessages.messages, isLoading = _useMessages.isLoading, isLoadingError = _useMessages.isLoadingError;
|
|
1186
1206
|
var addToast = useToasts().addToast;
|
|
@@ -1199,33 +1219,18 @@ var Content3 = function() {
|
|
|
1199
1219
|
addToast
|
|
1200
1220
|
]);
|
|
1201
1221
|
if (isLoading || isLoadingError) {
|
|
1202
|
-
return /* @__PURE__ */
|
|
1222
|
+
return /* @__PURE__ */ jsx33(MessagesSkeleton, {});
|
|
1203
1223
|
}
|
|
1204
|
-
return /* @__PURE__ */
|
|
1224
|
+
return /* @__PURE__ */ jsx33(Fragment2, {
|
|
1205
1225
|
children: messageGroups2.map(function(messageGroup) {
|
|
1206
|
-
return /* @__PURE__ */
|
|
1226
|
+
return /* @__PURE__ */ jsx33(MessageGroup, {
|
|
1207
1227
|
messageGroup: messageGroup
|
|
1208
1228
|
}, messageGroup.id);
|
|
1209
1229
|
})
|
|
1210
1230
|
});
|
|
1211
1231
|
};
|
|
1212
1232
|
// src/components/threads/Thread/Messages/Progress/index.tsx
|
|
1213
|
-
import {
|
|
1214
|
-
// src/components/skeletons/StartingContentSkeleton/index.tsx
|
|
1215
|
-
import { Skeleton as Skeleton2 } from "@radix-ui/themes";
|
|
1216
|
-
import { jsx as jsx33 } from "react/jsx-runtime";
|
|
1217
|
-
var StartingContentSkeleton = function() {
|
|
1218
|
-
return /* @__PURE__ */ jsx33(Skeleton2, {
|
|
1219
|
-
loading: true,
|
|
1220
|
-
mt: "1",
|
|
1221
|
-
height: "var(--space-4)",
|
|
1222
|
-
width: "var(--space-4)",
|
|
1223
|
-
style: {
|
|
1224
|
-
borderRadius: "var(--radius-6)",
|
|
1225
|
-
flexShrink: 0
|
|
1226
|
-
}
|
|
1227
|
-
});
|
|
1228
|
-
};
|
|
1233
|
+
import { useMemo as useMemo7 } from "react";
|
|
1229
1234
|
// src/components/skeletons/StartingSkeleton/index.tsx
|
|
1230
1235
|
import { useContext as useContext7 } from "react";
|
|
1231
1236
|
import { Box as Box11 } from "@radix-ui/themes";
|
|
@@ -1260,161 +1265,50 @@ var useLatestMessage = function() {
|
|
|
1260
1265
|
props
|
|
1261
1266
|
]);
|
|
1262
1267
|
};
|
|
1263
|
-
// src/
|
|
1264
|
-
import
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
// src/hooks/runs/useRuns/index.tsx
|
|
1269
|
-
import { useMemo as useMemo6 } from "react";
|
|
1270
|
-
import { useInfiniteQuery as useInfiniteQuery2, useQueryClient as useQueryClient3 } from "@tanstack/react-query";
|
|
1271
|
-
// src/lib/runs/runsQueryOptions.ts
|
|
1272
|
-
var runsQueryOptions = function(param) {
|
|
1273
|
-
var queryClient = param.queryClient, threadContext = param.threadContext, superinterfaceContext = param.superinterfaceContext;
|
|
1274
|
-
return queryOptions({
|
|
1275
|
-
queryKeyBase: [
|
|
1276
|
-
"runs"
|
|
1277
|
-
],
|
|
1278
|
-
path: "/runs",
|
|
1279
|
-
queryClient: queryClient,
|
|
1280
|
-
threadContext: threadContext,
|
|
1281
|
-
superinterfaceContext: superinterfaceContext
|
|
1282
|
-
});
|
|
1283
|
-
};
|
|
1284
|
-
// src/hooks/runs/useRuns/lib/getRuns.ts
|
|
1285
|
-
var getRuns = function(param) {
|
|
1286
|
-
var data3 = param.data;
|
|
1287
|
-
if (!data3) return [];
|
|
1288
|
-
return data3.pages.reduce(function(acc, page) {
|
|
1289
|
-
return acc.concat(page.data);
|
|
1290
|
-
}, []);
|
|
1291
|
-
};
|
|
1292
|
-
// src/hooks/runs/useRuns/index.tsx
|
|
1293
|
-
var useRuns = function() {
|
|
1294
|
-
var queryClient = useQueryClient3();
|
|
1295
|
-
var superinterfaceContext = useSuperinterfaceContext();
|
|
1296
|
-
var threadContext = useSuperinterfaceContext();
|
|
1297
|
-
var props = useInfiniteQuery2(runsQueryOptions({
|
|
1298
|
-
queryClient: queryClient,
|
|
1299
|
-
threadContext: threadContext,
|
|
1300
|
-
superinterfaceContext: superinterfaceContext
|
|
1301
|
-
}));
|
|
1302
|
-
return useMemo6(function() {
|
|
1303
|
-
return _object_spread_props(_object_spread({}, props), {
|
|
1304
|
-
// @ts-ignore-next-line
|
|
1305
|
-
runs: getRuns({
|
|
1306
|
-
data: props.data
|
|
1307
|
-
})
|
|
1308
|
-
});
|
|
1309
|
-
}, [
|
|
1310
|
-
props
|
|
1311
|
-
]);
|
|
1312
|
-
};
|
|
1313
|
-
// src/hooks/runs/useLatestRun/index.ts
|
|
1314
|
-
var useLatestRun = function() {
|
|
1315
|
-
var props = useRuns();
|
|
1316
|
-
return useMemo7(function() {
|
|
1317
|
-
return _object_spread_props(_object_spread({}, props), {
|
|
1318
|
-
latestRun: props.runs[0]
|
|
1319
|
-
});
|
|
1320
|
-
}, [
|
|
1321
|
-
props
|
|
1322
|
-
]);
|
|
1268
|
+
// src/lib/optimistic/isOptimistic.ts
|
|
1269
|
+
import _4 from "lodash";
|
|
1270
|
+
var isOptimistic = function(param) {
|
|
1271
|
+
var id = param.id;
|
|
1272
|
+
return _4.startsWith(id, "-");
|
|
1323
1273
|
};
|
|
1324
|
-
// src/hooks/
|
|
1325
|
-
import {
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
var PollingContext = createContext8({
|
|
1329
|
-
isPollRefetching: false,
|
|
1330
|
-
setIsPollRefetching: function() {}
|
|
1331
|
-
});
|
|
1332
|
-
// src/hooks/runs/usePollingContext/index.ts
|
|
1333
|
-
var usePollingContext = function() {
|
|
1334
|
-
return useContext8(PollingContext);
|
|
1335
|
-
};
|
|
1336
|
-
// src/hooks/runs/useIsRunActive/index.tsx
|
|
1337
|
-
var progressStatuses = [
|
|
1338
|
-
"queued",
|
|
1339
|
-
"in_progress",
|
|
1340
|
-
"cancelling",
|
|
1341
|
-
"requires_action"
|
|
1342
|
-
];
|
|
1343
|
-
var stoppedStatuses = [
|
|
1344
|
-
"expired",
|
|
1345
|
-
"cancelled",
|
|
1346
|
-
"failed"
|
|
1347
|
-
];
|
|
1348
|
-
var isRunActive = function(param) {
|
|
1349
|
-
var pollingContext = param.pollingContext, latestRunProps = param.latestRunProps, latestMessageProps = param.latestMessageProps, isMutating = param.isMutating;
|
|
1350
|
-
var _latestMessageProps_latestMessage_metadata, _latestMessageProps_latestMessage;
|
|
1351
|
-
if (pollingContext.isPollRefetching) return true;
|
|
1352
|
-
if ((_latestMessageProps_latestMessage = latestMessageProps.latestMessage) === null || _latestMessageProps_latestMessage === void 0 ? void 0 : (_latestMessageProps_latestMessage_metadata = _latestMessageProps_latestMessage.metadata) === null || _latestMessageProps_latestMessage_metadata === void 0 ? void 0 : _latestMessageProps_latestMessage_metadata.isBlocking) return false;
|
|
1353
|
-
if (isMutating) return true;
|
|
1354
|
-
if (!latestRunProps.latestRun) return false;
|
|
1355
|
-
if (progressStatuses.includes(latestRunProps.latestRun.status)) return true;
|
|
1356
|
-
if (stoppedStatuses.includes(latestRunProps.latestRun.status)) return false;
|
|
1357
|
-
return false;
|
|
1358
|
-
};
|
|
1359
|
-
var useIsRunActive = function() {
|
|
1360
|
-
var latestRunProps = useLatestRun();
|
|
1361
|
-
var latestMessageProps = useLatestMessage();
|
|
1274
|
+
// src/hooks/messages/useIsMutatingMessage/index.ts
|
|
1275
|
+
import { useMemo as useMemo6 } from "react";
|
|
1276
|
+
import { useIsMutating } from "@tanstack/react-query";
|
|
1277
|
+
var useIsMutatingMessage = function() {
|
|
1362
1278
|
var threadContext = useSuperinterfaceContext();
|
|
1363
|
-
var
|
|
1364
|
-
var isMutatingCreateRun = useIsMutating({
|
|
1365
|
-
mutationKey: [
|
|
1366
|
-
"createRun",
|
|
1367
|
-
threadContext.variables
|
|
1368
|
-
]
|
|
1369
|
-
});
|
|
1370
|
-
var isMutatingCreateMessage = useIsMutating({
|
|
1279
|
+
var mutatingMessagesCount = useIsMutating({
|
|
1371
1280
|
mutationKey: [
|
|
1372
1281
|
"createMessage",
|
|
1373
1282
|
threadContext.variables
|
|
1374
1283
|
]
|
|
1375
1284
|
});
|
|
1376
|
-
var
|
|
1377
|
-
|
|
1378
|
-
"handleAction",
|
|
1379
|
-
threadContext.variables
|
|
1380
|
-
]
|
|
1381
|
-
});
|
|
1382
|
-
return useMemo8(function() {
|
|
1383
|
-
return _object_spread_props(_object_spread({}, latestRunProps), {
|
|
1384
|
-
isRunActive: isRunActive({
|
|
1385
|
-
pollingContext: pollingContext,
|
|
1386
|
-
latestRunProps: latestRunProps,
|
|
1387
|
-
latestMessageProps: latestMessageProps,
|
|
1388
|
-
isMutating: isMutatingCreateRun > 0 || isMutatingCreateMessage > 0 || isMutatingCreateHandleAction > 0
|
|
1389
|
-
})
|
|
1390
|
-
});
|
|
1285
|
+
var isMutatingMessage = useMemo6(function() {
|
|
1286
|
+
return mutatingMessagesCount > 0;
|
|
1391
1287
|
}, [
|
|
1392
|
-
|
|
1393
|
-
latestMessageProps,
|
|
1394
|
-
pollingContext,
|
|
1395
|
-
isMutatingCreateRun,
|
|
1396
|
-
isMutatingCreateMessage,
|
|
1397
|
-
isMutatingCreateHandleAction
|
|
1288
|
+
mutatingMessagesCount
|
|
1398
1289
|
]);
|
|
1290
|
+
return isMutatingMessage;
|
|
1399
1291
|
};
|
|
1400
1292
|
// src/components/threads/Thread/Messages/Progress/index.tsx
|
|
1401
|
-
import { jsx as jsx35
|
|
1293
|
+
import { jsx as jsx35 } from "react/jsx-runtime";
|
|
1402
1294
|
var Progress = function() {
|
|
1403
|
-
var _useIsRunActive = useIsRunActive(), isRunActive2 = _useIsRunActive.isRunActive;
|
|
1404
1295
|
var latestMessage = useLatestMessage().latestMessage;
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1296
|
+
var isMutatingMessage = useIsMutatingMessage();
|
|
1297
|
+
var isVisible = useMemo7(function() {
|
|
1298
|
+
if (!latestMessage) return false;
|
|
1299
|
+
if (latestMessage.role !== "user") return false;
|
|
1300
|
+
if (latestMessage.status === "in_progress") return false;
|
|
1301
|
+
if (!isOptimistic({
|
|
1302
|
+
id: latestMessage.id
|
|
1303
|
+
})) return false;
|
|
1304
|
+
if (!isMutatingMessage) return false;
|
|
1305
|
+
return true;
|
|
1306
|
+
}, [
|
|
1307
|
+
latestMessage,
|
|
1308
|
+
isMutatingMessage
|
|
1309
|
+
]);
|
|
1310
|
+
if (!isVisible) return null;
|
|
1311
|
+
return /* @__PURE__ */ jsx35(StartingSkeleton, {});
|
|
1418
1312
|
};
|
|
1419
1313
|
// src/components/threads/Thread/Messages/Root/index.tsx
|
|
1420
1314
|
import { Flex as Flex11 } from "@radix-ui/themes";
|
|
@@ -1422,12 +1316,12 @@ import { Flex as Flex11 } from "@radix-ui/themes";
|
|
|
1422
1316
|
import { useRef as useRef2 } from "react";
|
|
1423
1317
|
import { useInView } from "react-intersection-observer";
|
|
1424
1318
|
// src/hooks/misc/useThrottledEffect/index.tsx
|
|
1425
|
-
import
|
|
1319
|
+
import _5 from "lodash";
|
|
1426
1320
|
import { useRef, useEffect as useEffect2, useCallback } from "react";
|
|
1427
1321
|
var useThrottledEffect = function(cb, delay, additionalDeps) {
|
|
1428
1322
|
var _cbRef;
|
|
1429
1323
|
var cbRef = useRef(cb);
|
|
1430
|
-
var throttledCb = useCallback(
|
|
1324
|
+
var throttledCb = useCallback(_5.throttle(function() {
|
|
1431
1325
|
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
1432
1326
|
args[_key] = arguments[_key];
|
|
1433
1327
|
}
|
|
@@ -1472,229 +1366,179 @@ var useInfiniteScroll = function(param) {
|
|
|
1472
1366
|
inView: inView
|
|
1473
1367
|
};
|
|
1474
1368
|
};
|
|
1475
|
-
// src/
|
|
1476
|
-
import {
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
case 0:
|
|
1503
|
-
if (!(response.status !== 200)) return [
|
|
1504
|
-
3,
|
|
1505
|
-
5
|
|
1506
|
-
];
|
|
1507
|
-
_state.label = 1;
|
|
1508
|
-
case 1:
|
|
1509
|
-
_state.trys.push([
|
|
1510
|
-
1,
|
|
1511
|
-
3,
|
|
1512
|
-
,
|
|
1513
|
-
4
|
|
1514
|
-
]);
|
|
1515
|
-
console.log("response", response);
|
|
1516
|
-
return [
|
|
1517
|
-
4,
|
|
1518
|
-
response.json()
|
|
1519
|
-
];
|
|
1520
|
-
case 2:
|
|
1521
|
-
errorResponse = _state.sent();
|
|
1522
|
-
return [
|
|
1523
|
-
3,
|
|
1524
|
-
4
|
|
1525
|
-
];
|
|
1526
|
-
case 3:
|
|
1527
|
-
error = _state.sent();
|
|
1528
|
-
throw new Error("Failed to fetch");
|
|
1529
|
-
case 4:
|
|
1530
|
-
throw new Error(errorResponse.error);
|
|
1531
|
-
case 5:
|
|
1532
|
-
return [
|
|
1533
|
-
2,
|
|
1534
|
-
response.json()
|
|
1535
|
-
];
|
|
1536
|
-
}
|
|
1537
|
-
});
|
|
1538
|
-
});
|
|
1539
|
-
return function(response) {
|
|
1540
|
-
return _ref.apply(this, arguments);
|
|
1541
|
-
};
|
|
1542
|
-
}());
|
|
1543
|
-
}
|
|
1544
|
-
}, threadContext.defaultOptions.mutations, queryClient.getMutationDefaults(mutationKey)), {
|
|
1545
|
-
mutationKey: mutationKey
|
|
1369
|
+
// src/components/threads/Thread/Messages/Root/index.tsx
|
|
1370
|
+
import { jsx as jsx36, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1371
|
+
var Root = function(param) {
|
|
1372
|
+
var children = param.children, _param_style = param.style, style = _param_style === void 0 ? {} : _param_style;
|
|
1373
|
+
var _useMessages = useMessages(), isFetchingNextPage = _useMessages.isFetchingNextPage, hasNextPage = _useMessages.hasNextPage, fetchNextPage = _useMessages.fetchNextPage;
|
|
1374
|
+
var _useInfiniteScroll = useInfiniteScroll({
|
|
1375
|
+
isFetchingNextPage: isFetchingNextPage,
|
|
1376
|
+
hasNextPage: hasNextPage,
|
|
1377
|
+
fetchNextPage: fetchNextPage
|
|
1378
|
+
}), containerRef = _useInfiniteScroll.containerRef, loaderRef = _useInfiniteScroll.loaderRef;
|
|
1379
|
+
return /* @__PURE__ */ jsxs9(Flex11, {
|
|
1380
|
+
ref: containerRef,
|
|
1381
|
+
direction: "column-reverse",
|
|
1382
|
+
flexGrow: "1",
|
|
1383
|
+
style: _object_spread_props(_object_spread({}, style), {
|
|
1384
|
+
overflow: "auto"
|
|
1385
|
+
}),
|
|
1386
|
+
children: [
|
|
1387
|
+
children,
|
|
1388
|
+
hasNextPage && /* @__PURE__ */ jsx36(Flex11, {
|
|
1389
|
+
ref: loaderRef
|
|
1390
|
+
}),
|
|
1391
|
+
/* @__PURE__ */ jsx36(Flex11, {
|
|
1392
|
+
flexShrink: "0",
|
|
1393
|
+
flexGrow: "1"
|
|
1394
|
+
})
|
|
1395
|
+
]
|
|
1546
1396
|
});
|
|
1547
1397
|
};
|
|
1548
|
-
// src/
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
return [
|
|
1555
|
-
2,
|
|
1556
|
-
queryClient.setQueryData([
|
|
1557
|
-
"runs",
|
|
1558
|
-
variables
|
|
1559
|
-
], function(prevData) {
|
|
1560
|
-
if (!prevData) {
|
|
1561
|
-
return {
|
|
1562
|
-
pageParams: [],
|
|
1563
|
-
pages: [
|
|
1564
|
-
{
|
|
1565
|
-
data: [
|
|
1566
|
-
data3.run
|
|
1567
|
-
],
|
|
1568
|
-
hasNextPage: false,
|
|
1569
|
-
lastId: data3.run.id
|
|
1570
|
-
}
|
|
1571
|
-
]
|
|
1572
|
-
};
|
|
1573
|
-
}
|
|
1574
|
-
var _prevData_pages = _to_array(prevData.pages), latestPage = _prevData_pages[0], pagesRest = _prevData_pages.slice(1);
|
|
1575
|
-
return _object_spread_props(_object_spread({}, prevData), {
|
|
1576
|
-
pages: [
|
|
1577
|
-
_object_spread_props(_object_spread({}, latestPage), {
|
|
1578
|
-
data: [
|
|
1579
|
-
data3.run
|
|
1580
|
-
].concat(_to_consumable_array(latestPage.data))
|
|
1581
|
-
})
|
|
1582
|
-
].concat(_to_consumable_array(pagesRest))
|
|
1583
|
-
});
|
|
1584
|
-
})
|
|
1585
|
-
];
|
|
1586
|
-
});
|
|
1587
|
-
});
|
|
1588
|
-
return function(data3, variables) {
|
|
1589
|
-
return _ref.apply(this, arguments);
|
|
1590
|
-
};
|
|
1591
|
-
}();
|
|
1592
|
-
};
|
|
1593
|
-
// src/hooks/runs/useCreateRun/lib/onSettled.ts
|
|
1594
|
-
var onSettled = function(param) {
|
|
1595
|
-
var queryClient = param.queryClient;
|
|
1596
|
-
return function() {
|
|
1597
|
-
var _ref = _async_to_generator(function(_data, _error, variables) {
|
|
1598
|
-
return _ts_generator(this, function(_state) {
|
|
1599
|
-
switch(_state.label){
|
|
1600
|
-
case 0:
|
|
1601
|
-
return [
|
|
1602
|
-
4,
|
|
1603
|
-
queryClient.invalidateQueries({
|
|
1604
|
-
queryKey: [
|
|
1605
|
-
"messages",
|
|
1606
|
-
variables
|
|
1607
|
-
]
|
|
1608
|
-
})
|
|
1609
|
-
];
|
|
1610
|
-
case 1:
|
|
1611
|
-
_state.sent();
|
|
1612
|
-
return [
|
|
1613
|
-
4,
|
|
1614
|
-
queryClient.invalidateQueries({
|
|
1615
|
-
queryKey: [
|
|
1616
|
-
"runs",
|
|
1617
|
-
variables
|
|
1618
|
-
]
|
|
1619
|
-
})
|
|
1620
|
-
];
|
|
1621
|
-
case 2:
|
|
1622
|
-
_state.sent();
|
|
1623
|
-
return [
|
|
1624
|
-
2
|
|
1625
|
-
];
|
|
1626
|
-
}
|
|
1627
|
-
});
|
|
1628
|
-
});
|
|
1629
|
-
return function(_data, _error, variables) {
|
|
1630
|
-
return _ref.apply(this, arguments);
|
|
1631
|
-
};
|
|
1632
|
-
}();
|
|
1633
|
-
};
|
|
1634
|
-
// src/lib/optimistic/optimisticId.ts
|
|
1635
|
-
import { uid } from "radash";
|
|
1636
|
-
var optimisticId = function() {
|
|
1637
|
-
return "-".concat(uid(24));
|
|
1638
|
-
};
|
|
1639
|
-
// src/hooks/runs/useCreateRun/lib/onMutate/data.ts
|
|
1640
|
-
var data = function(prevData) {
|
|
1641
|
-
var run = {
|
|
1642
|
-
id: optimisticId(),
|
|
1643
|
-
object: "thread.run",
|
|
1644
|
-
created_at: +/* @__PURE__ */ new Date(),
|
|
1645
|
-
assistant_id: null,
|
|
1646
|
-
thread_id: null,
|
|
1647
|
-
status: "in_progress",
|
|
1648
|
-
expires_at: +/* @__PURE__ */ new Date() + 1e3 * 60 * 60 * 24,
|
|
1649
|
-
cancelled_at: null,
|
|
1650
|
-
failed_at: null,
|
|
1651
|
-
completed_at: null,
|
|
1652
|
-
required_action: null,
|
|
1653
|
-
last_error: null,
|
|
1654
|
-
model: null,
|
|
1655
|
-
instructions: null,
|
|
1656
|
-
tools: [],
|
|
1657
|
-
file_ids: [],
|
|
1658
|
-
metadata: {},
|
|
1659
|
-
usage: null
|
|
1660
|
-
};
|
|
1661
|
-
if (!prevData) {
|
|
1662
|
-
return {
|
|
1663
|
-
pageParams: [],
|
|
1664
|
-
pages: [
|
|
1665
|
-
{
|
|
1666
|
-
data: [
|
|
1667
|
-
run
|
|
1668
|
-
],
|
|
1669
|
-
hasNextPage: false,
|
|
1670
|
-
lastId: run.id
|
|
1671
|
-
}
|
|
1672
|
-
]
|
|
1673
|
-
};
|
|
1398
|
+
// src/components/threads/Thread/Messages/NextPageSkeleton.tsx
|
|
1399
|
+
import { jsx as jsx37 } from "react/jsx-runtime";
|
|
1400
|
+
var NextPageSkeleton = function() {
|
|
1401
|
+
var hasNextPage = useMessages().hasNextPage;
|
|
1402
|
+
if (!hasNextPage) {
|
|
1403
|
+
return null;
|
|
1674
1404
|
}
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1405
|
+
return /* @__PURE__ */ jsx37(MessagesSkeleton, {});
|
|
1406
|
+
};
|
|
1407
|
+
// src/components/threads/Thread/Messages/index.tsx
|
|
1408
|
+
import { jsx as jsx38, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1409
|
+
var Messages = function(param) {
|
|
1410
|
+
var children = param.children, _param_style = param.style, style = _param_style === void 0 ? {} : _param_style;
|
|
1411
|
+
return /* @__PURE__ */ jsxs10(Root, {
|
|
1412
|
+
style: style,
|
|
1413
|
+
children: [
|
|
1414
|
+
/* @__PURE__ */ jsx38(Flex12, {
|
|
1415
|
+
flexShrink: "0",
|
|
1416
|
+
height: "var(--space-3)"
|
|
1417
|
+
}),
|
|
1418
|
+
/* @__PURE__ */ jsx38(Progress, {}),
|
|
1419
|
+
children,
|
|
1420
|
+
/* @__PURE__ */ jsx38(Content3, {}),
|
|
1421
|
+
/* @__PURE__ */ jsx38(NextPageSkeleton, {}),
|
|
1422
|
+
/* @__PURE__ */ jsx38(Flex12, {
|
|
1423
|
+
flexShrink: "0",
|
|
1424
|
+
flexGrow: "1"
|
|
1682
1425
|
})
|
|
1683
|
-
]
|
|
1426
|
+
]
|
|
1684
1427
|
});
|
|
1685
1428
|
};
|
|
1686
|
-
|
|
1687
|
-
|
|
1429
|
+
Messages.Root = Root;
|
|
1430
|
+
Messages.Message = Message;
|
|
1431
|
+
Messages.NextPageSkeleton = NextPageSkeleton;
|
|
1432
|
+
// src/components/threads/Thread/MessageForm/index.tsx
|
|
1433
|
+
import { Flex as Flex14, Text as Text5 } from "@radix-ui/themes";
|
|
1434
|
+
// src/components/threads/Thread/MessageForm/Submit/index.tsx
|
|
1435
|
+
import { ArrowUpIcon } from "@radix-ui/react-icons";
|
|
1436
|
+
import { IconButton, Spinner } from "@radix-ui/themes";
|
|
1437
|
+
// src/hooks/messages/useMessageFormContext/index.ts
|
|
1438
|
+
import { useContext as useContext8 } from "react";
|
|
1439
|
+
// src/contexts/messages/MessageFormContext/index.ts
|
|
1440
|
+
import { createContext as createContext8 } from "react";
|
|
1441
|
+
var MessageFormContext = createContext8({
|
|
1442
|
+
isDisabled: false,
|
|
1443
|
+
isLoading: false
|
|
1444
|
+
});
|
|
1445
|
+
// src/hooks/messages/useMessageFormContext/index.ts
|
|
1446
|
+
var useMessageFormContext = function() {
|
|
1447
|
+
return useContext8(MessageFormContext);
|
|
1448
|
+
};
|
|
1449
|
+
// src/components/threads/Thread/MessageForm/Submit/index.tsx
|
|
1450
|
+
import { jsx as jsx39 } from "react/jsx-runtime";
|
|
1451
|
+
var Submit = function() {
|
|
1452
|
+
var _useMessageFormContext = useMessageFormContext(), isDisabled = _useMessageFormContext.isDisabled, isLoading = _useMessageFormContext.isLoading;
|
|
1453
|
+
return /* @__PURE__ */ jsx39(IconButton, {
|
|
1454
|
+
type: "submit",
|
|
1455
|
+
disabled: isDisabled || isLoading,
|
|
1456
|
+
children: /* @__PURE__ */ jsx39(Spinner, {
|
|
1457
|
+
loading: isLoading,
|
|
1458
|
+
children: /* @__PURE__ */ jsx39(ArrowUpIcon, {})
|
|
1459
|
+
})
|
|
1460
|
+
});
|
|
1461
|
+
};
|
|
1462
|
+
// src/components/threads/Thread/MessageForm/Root/index.tsx
|
|
1463
|
+
import { useMemo as useMemo8 } from "react";
|
|
1464
|
+
import { useForm, FormProvider } from "react-hook-form";
|
|
1465
|
+
// src/hooks/messages/useCreateMessage/index.ts
|
|
1466
|
+
import { partob } from "radash";
|
|
1467
|
+
import { useMutation, useQueryClient as useQueryClient3 } from "@tanstack/react-query";
|
|
1468
|
+
// src/hooks/messages/useCreateMessage/lib/mutationOptions/onMutate/index.ts
|
|
1469
|
+
import { omit } from "radash";
|
|
1470
|
+
// src/hooks/messages/useCreateMessage/lib/mutationOptions/onMutate/data.ts
|
|
1471
|
+
import dayjs from "dayjs";
|
|
1472
|
+
// src/lib/optimistic/optimisticId.ts
|
|
1473
|
+
import { uid } from "radash";
|
|
1474
|
+
var optimisticId = function() {
|
|
1475
|
+
return "-".concat(uid(24));
|
|
1476
|
+
};
|
|
1477
|
+
// src/hooks/messages/useCreateMessage/lib/mutationOptions/onMutate/data.ts
|
|
1478
|
+
var data = function(param) {
|
|
1479
|
+
var newMessage = param.newMessage;
|
|
1480
|
+
return function(prevData) {
|
|
1481
|
+
var message = {
|
|
1482
|
+
id: optimisticId(),
|
|
1483
|
+
role: "user",
|
|
1484
|
+
created_at: dayjs().unix(),
|
|
1485
|
+
object: "thread.message",
|
|
1486
|
+
content: [
|
|
1487
|
+
{
|
|
1488
|
+
type: "text",
|
|
1489
|
+
text: {
|
|
1490
|
+
annotations: [],
|
|
1491
|
+
value: newMessage.content
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
],
|
|
1495
|
+
run_id: null,
|
|
1496
|
+
assistant_id: null,
|
|
1497
|
+
thread_id: null,
|
|
1498
|
+
file_ids: [],
|
|
1499
|
+
metadata: {},
|
|
1500
|
+
runSteps: []
|
|
1501
|
+
};
|
|
1502
|
+
if (!prevData) {
|
|
1503
|
+
return {
|
|
1504
|
+
pageParams: [],
|
|
1505
|
+
pages: [
|
|
1506
|
+
{
|
|
1507
|
+
data: [
|
|
1508
|
+
message
|
|
1509
|
+
],
|
|
1510
|
+
hasNextPage: false,
|
|
1511
|
+
lastId: message.id
|
|
1512
|
+
}
|
|
1513
|
+
]
|
|
1514
|
+
};
|
|
1515
|
+
}
|
|
1516
|
+
var _prevData_pages = _to_array(prevData.pages), latestPage = _prevData_pages[0], pagesRest = _prevData_pages.slice(1);
|
|
1517
|
+
return _object_spread_props(_object_spread({}, prevData), {
|
|
1518
|
+
pages: [
|
|
1519
|
+
_object_spread_props(_object_spread({}, latestPage), {
|
|
1520
|
+
data: [
|
|
1521
|
+
message
|
|
1522
|
+
].concat(_to_consumable_array(latestPage.data))
|
|
1523
|
+
})
|
|
1524
|
+
].concat(_to_consumable_array(pagesRest))
|
|
1525
|
+
});
|
|
1526
|
+
};
|
|
1527
|
+
};
|
|
1528
|
+
// src/hooks/messages/useCreateMessage/lib/mutationOptions/onMutate/index.ts
|
|
1529
|
+
var onMutate = function(param) {
|
|
1688
1530
|
var queryClient = param.queryClient;
|
|
1689
1531
|
return function() {
|
|
1690
|
-
var _ref = _async_to_generator(function(
|
|
1691
|
-
var queryKey,
|
|
1532
|
+
var _ref = _async_to_generator(function(newMessage) {
|
|
1533
|
+
var queryKey, prevMessages;
|
|
1692
1534
|
return _ts_generator(this, function(_state) {
|
|
1693
1535
|
switch(_state.label){
|
|
1694
1536
|
case 0:
|
|
1695
1537
|
queryKey = [
|
|
1696
|
-
"
|
|
1697
|
-
|
|
1538
|
+
"messages",
|
|
1539
|
+
omit(newMessage, [
|
|
1540
|
+
"content"
|
|
1541
|
+
])
|
|
1698
1542
|
];
|
|
1699
1543
|
return [
|
|
1700
1544
|
4,
|
|
@@ -1704,588 +1548,492 @@ var onMutate = function(param) {
|
|
|
1704
1548
|
];
|
|
1705
1549
|
case 1:
|
|
1706
1550
|
_state.sent();
|
|
1707
|
-
|
|
1708
|
-
queryClient.setQueryData(queryKey, data
|
|
1551
|
+
prevMessages = queryClient.getQueryData(queryKey);
|
|
1552
|
+
queryClient.setQueryData(queryKey, data({
|
|
1553
|
+
newMessage: newMessage
|
|
1554
|
+
}));
|
|
1709
1555
|
return [
|
|
1710
1556
|
2,
|
|
1711
1557
|
{
|
|
1712
|
-
|
|
1713
|
-
|
|
1558
|
+
prevMessages: prevMessages,
|
|
1559
|
+
newMessage: newMessage
|
|
1714
1560
|
}
|
|
1715
1561
|
];
|
|
1716
1562
|
}
|
|
1717
1563
|
});
|
|
1718
1564
|
});
|
|
1719
|
-
return function(
|
|
1565
|
+
return function(newMessage) {
|
|
1720
1566
|
return _ref.apply(this, arguments);
|
|
1721
1567
|
};
|
|
1722
1568
|
}();
|
|
1723
1569
|
};
|
|
1724
|
-
// src/hooks/
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
var
|
|
1730
|
-
var
|
|
1731
|
-
var
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
}),
|
|
1739
|
-
onMutate: onMutate({
|
|
1740
|
-
queryClient: queryClient
|
|
1741
|
-
}),
|
|
1742
|
-
onError: onError
|
|
1743
|
-
}, mutationOptions({
|
|
1744
|
-
mutationKeyBase: [
|
|
1745
|
-
"createRun"
|
|
1746
|
-
],
|
|
1747
|
-
path: "/runs",
|
|
1748
|
-
queryClient: queryClient,
|
|
1749
|
-
threadContext: threadContext,
|
|
1750
|
-
superinterfaceContext: superinterfaceContext
|
|
1751
|
-
})));
|
|
1752
|
-
return _object_spread_props(_object_spread({}, props), {
|
|
1753
|
-
createRun: partob(props.mutate, threadContext.variables)
|
|
1570
|
+
// src/hooks/messages/useCreateMessage/lib/mutationOptions/mutationFn/index.ts
|
|
1571
|
+
import { JSONParser } from "@streamparser/json-whatwg";
|
|
1572
|
+
// src/hooks/messages/useCreateMessage/lib/mutationOptions/mutationFn/handleResponse/handlers/extendMessage.ts
|
|
1573
|
+
import { last as last2 } from "radash";
|
|
1574
|
+
var extendMessage = function(param) {
|
|
1575
|
+
var message = param.message, messages2 = param.messages;
|
|
1576
|
+
var _last2, _last21;
|
|
1577
|
+
var prevRunMessages = messages2.filter(function(m) {
|
|
1578
|
+
return m.run_id === message.run_id;
|
|
1579
|
+
});
|
|
1580
|
+
var prevOptimitisticRunMessages = prevRunMessages.filter(function(m) {
|
|
1581
|
+
return isOptimistic({
|
|
1582
|
+
id: m.id
|
|
1583
|
+
});
|
|
1754
1584
|
});
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
var id = param.id;
|
|
1760
|
-
return _5.startsWith(id, "-");
|
|
1761
|
-
};
|
|
1762
|
-
// src/hooks/runs/useManageRuns/index.tsx
|
|
1763
|
-
var useManageRuns = function() {
|
|
1764
|
-
var addToast = useToasts().addToast;
|
|
1765
|
-
var queryClient = useQueryClient5();
|
|
1766
|
-
var latestRunProps = useLatestRun();
|
|
1767
|
-
var latestMessageProps = useLatestMessage();
|
|
1768
|
-
var createRunProps = useCreateRun({
|
|
1769
|
-
onError: function(error) {
|
|
1770
|
-
return addToast({
|
|
1771
|
-
type: "error",
|
|
1772
|
-
message: error.message
|
|
1773
|
-
});
|
|
1774
|
-
}
|
|
1585
|
+
var _last2_runSteps, _ref;
|
|
1586
|
+
var runSteps = (_ref = (_last2_runSteps = (_last2 = last2(prevOptimitisticRunMessages)) === null || _last2 === void 0 ? void 0 : _last2.runSteps) !== null && _last2_runSteps !== void 0 ? _last2_runSteps : (_last21 = last2(prevRunMessages)) === null || _last21 === void 0 ? void 0 : _last21.runSteps) !== null && _ref !== void 0 ? _ref : [];
|
|
1587
|
+
return _object_spread_props(_object_spread({}, message), {
|
|
1588
|
+
runSteps: runSteps
|
|
1775
1589
|
});
|
|
1776
|
-
var threadContext = useSuperinterfaceContext();
|
|
1777
|
-
var _useState = _sliced_to_array(useState([]), 2), toastedErrorRunIds = _useState[0], setToastedErrorRunIds = _useState[1];
|
|
1778
|
-
useEffect3(function() {
|
|
1779
|
-
var _latestRunProps_latestRun;
|
|
1780
|
-
if (((_latestRunProps_latestRun = latestRunProps.latestRun) === null || _latestRunProps_latestRun === void 0 ? void 0 : _latestRunProps_latestRun.status) !== "failed") return;
|
|
1781
|
-
if (toastedErrorRunIds.includes(latestRunProps.latestRun.id)) return;
|
|
1782
|
-
setToastedErrorRunIds(function(prev) {
|
|
1783
|
-
return _to_consumable_array(prev).concat([
|
|
1784
|
-
latestRunProps.latestRun.id
|
|
1785
|
-
]);
|
|
1786
|
-
});
|
|
1787
|
-
addToast({
|
|
1788
|
-
type: "error",
|
|
1789
|
-
message: "AI run failed. Please try again."
|
|
1790
|
-
});
|
|
1791
|
-
}, [
|
|
1792
|
-
latestRunProps,
|
|
1793
|
-
toastedErrorRunIds,
|
|
1794
|
-
addToast
|
|
1795
|
-
]);
|
|
1796
|
-
useEffect3(function() {
|
|
1797
|
-
if (createRunProps.isPending) return;
|
|
1798
|
-
if (latestRunProps.isFetching) return;
|
|
1799
|
-
if (latestMessageProps.isFetching) return;
|
|
1800
|
-
if (!latestMessageProps.latestMessage) return;
|
|
1801
|
-
if (latestMessageProps.latestMessage.role !== "user") return;
|
|
1802
|
-
if (isOptimistic({
|
|
1803
|
-
id: latestMessageProps.latestMessage.id
|
|
1804
|
-
})) return;
|
|
1805
|
-
if (latestRunProps.latestRun && latestRunProps.latestRun.created_at > latestMessageProps.latestMessage.created_at) {
|
|
1806
|
-
return;
|
|
1807
|
-
}
|
|
1808
|
-
var isMutating = queryClient.isMutating({
|
|
1809
|
-
mutationKey: [
|
|
1810
|
-
"createRun",
|
|
1811
|
-
threadContext.variables
|
|
1812
|
-
]
|
|
1813
|
-
});
|
|
1814
|
-
if (isMutating) return;
|
|
1815
|
-
createRunProps.createRun();
|
|
1816
|
-
}, [
|
|
1817
|
-
threadContext,
|
|
1818
|
-
queryClient,
|
|
1819
|
-
createRunProps,
|
|
1820
|
-
latestRunProps,
|
|
1821
|
-
latestMessageProps
|
|
1822
|
-
]);
|
|
1823
|
-
return null;
|
|
1824
1590
|
};
|
|
1825
|
-
// src/hooks/
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
var _ref = _async_to_generator(function(param) {
|
|
1832
|
-
var queryClient, threadContext, _threadContext_defaultOptions_queries_queryKey, _threadContext_defaultOptions_queries_queryKey1;
|
|
1833
|
-
return _ts_generator(this, function(_state) {
|
|
1834
|
-
switch(_state.label){
|
|
1835
|
-
case 0:
|
|
1836
|
-
queryClient = param.queryClient, threadContext = param.threadContext;
|
|
1837
|
-
return [
|
|
1838
|
-
4,
|
|
1839
|
-
queryClient.refetchQueries({
|
|
1840
|
-
queryKey: (_threadContext_defaultOptions_queries_queryKey = threadContext.defaultOptions.queries.queryKey) !== null && _threadContext_defaultOptions_queries_queryKey !== void 0 ? _threadContext_defaultOptions_queries_queryKey : [
|
|
1841
|
-
"messages",
|
|
1842
|
-
threadContext.variables
|
|
1843
|
-
]
|
|
1844
|
-
})
|
|
1845
|
-
];
|
|
1846
|
-
case 1:
|
|
1847
|
-
_state.sent();
|
|
1848
|
-
return [
|
|
1849
|
-
4,
|
|
1850
|
-
queryClient.refetchQueries({
|
|
1851
|
-
queryKey: (_threadContext_defaultOptions_queries_queryKey1 = threadContext.defaultOptions.queries.queryKey) !== null && _threadContext_defaultOptions_queries_queryKey1 !== void 0 ? _threadContext_defaultOptions_queries_queryKey1 : [
|
|
1852
|
-
"runs",
|
|
1853
|
-
threadContext.variables
|
|
1854
|
-
]
|
|
1855
|
-
})
|
|
1856
|
-
];
|
|
1857
|
-
case 2:
|
|
1858
|
-
_state.sent();
|
|
1859
|
-
return [
|
|
1860
|
-
2
|
|
1861
|
-
];
|
|
1862
|
-
}
|
|
1591
|
+
// src/hooks/messages/useCreateMessage/lib/mutationOptions/mutationFn/handleResponse/handlers/threadMessageCreated.ts
|
|
1592
|
+
var appendMessage = function(param) {
|
|
1593
|
+
var message = param.message, messages2 = param.messages;
|
|
1594
|
+
var prevMessages = messages2.filter(function(m) {
|
|
1595
|
+
return m.run_id != message.run_id || !isOptimistic({
|
|
1596
|
+
id: m.id
|
|
1863
1597
|
});
|
|
1864
1598
|
});
|
|
1865
|
-
return
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
// src/hooks/runs/usePolling/index.tsx
|
|
1870
|
-
var usePolling = function() {
|
|
1871
|
-
var threadContext = useSuperinterfaceContext();
|
|
1872
|
-
var queryClient = useQueryClient6();
|
|
1873
|
-
var _usePollingContext = usePollingContext(), isPollRefetching = _usePollingContext.isPollRefetching, setIsPollRefetching = _usePollingContext.setIsPollRefetching;
|
|
1874
|
-
var isRunActiveProps = useIsRunActive();
|
|
1875
|
-
useInterval(/*#__PURE__*/ _async_to_generator(function() {
|
|
1876
|
-
return _ts_generator(this, function(_state) {
|
|
1877
|
-
switch(_state.label){
|
|
1878
|
-
case 0:
|
|
1879
|
-
if (isPollRefetching) return [
|
|
1880
|
-
2
|
|
1881
|
-
];
|
|
1882
|
-
setIsPollRefetching(true);
|
|
1883
|
-
return [
|
|
1884
|
-
4,
|
|
1885
|
-
refetch({
|
|
1886
|
-
queryClient: queryClient,
|
|
1887
|
-
threadContext: threadContext
|
|
1888
|
-
})
|
|
1889
|
-
];
|
|
1890
|
-
case 1:
|
|
1891
|
-
_state.sent();
|
|
1892
|
-
setIsPollRefetching(false);
|
|
1893
|
-
console.log("Polling...");
|
|
1894
|
-
return [
|
|
1895
|
-
2
|
|
1896
|
-
];
|
|
1897
|
-
}
|
|
1898
|
-
});
|
|
1899
|
-
}), isRunActiveProps.isRunActive ? 3e3 : null);
|
|
1900
|
-
var prevIsRunActive = usePrevious(isRunActiveProps.isRunActive);
|
|
1901
|
-
useEffect4(function() {
|
|
1902
|
-
if (prevIsRunActive && !isRunActiveProps.isRunActive) {
|
|
1903
|
-
refetch({
|
|
1904
|
-
queryClient: queryClient,
|
|
1905
|
-
threadContext: threadContext
|
|
1906
|
-
});
|
|
1907
|
-
}
|
|
1908
|
-
}, [
|
|
1909
|
-
queryClient,
|
|
1910
|
-
threadContext,
|
|
1911
|
-
isRunActiveProps,
|
|
1912
|
-
prevIsRunActive
|
|
1913
|
-
]);
|
|
1914
|
-
return null;
|
|
1915
|
-
};
|
|
1916
|
-
// src/hooks/actions/useManageActions/index.tsx
|
|
1917
|
-
import { useEffect as useEffect5, useState as useState2 } from "react";
|
|
1918
|
-
// src/hooks/actions/useHandleAction/index.tsx
|
|
1919
|
-
import { partob as partob2 } from "radash";
|
|
1920
|
-
import { useMutation as useMutation2, useQueryClient as useQueryClient7 } from "@tanstack/react-query";
|
|
1921
|
-
// src/hooks/actions/useHandleAction/lib/onSettled.ts
|
|
1922
|
-
var onSettled2 = function(param) {
|
|
1923
|
-
var queryClient = param.queryClient;
|
|
1924
|
-
return function() {
|
|
1925
|
-
var _ref = _async_to_generator(function(_data, _error, variables) {
|
|
1926
|
-
return _ts_generator(this, function(_state) {
|
|
1927
|
-
switch(_state.label){
|
|
1928
|
-
case 0:
|
|
1929
|
-
return [
|
|
1930
|
-
4,
|
|
1931
|
-
queryClient.invalidateQueries({
|
|
1932
|
-
queryKey: [
|
|
1933
|
-
"messages",
|
|
1934
|
-
variables
|
|
1935
|
-
]
|
|
1936
|
-
})
|
|
1937
|
-
];
|
|
1938
|
-
case 1:
|
|
1939
|
-
_state.sent();
|
|
1940
|
-
return [
|
|
1941
|
-
4,
|
|
1942
|
-
queryClient.invalidateQueries({
|
|
1943
|
-
queryKey: [
|
|
1944
|
-
"runs",
|
|
1945
|
-
variables
|
|
1946
|
-
]
|
|
1947
|
-
})
|
|
1948
|
-
];
|
|
1949
|
-
case 2:
|
|
1950
|
-
_state.sent();
|
|
1951
|
-
return [
|
|
1952
|
-
2
|
|
1953
|
-
];
|
|
1954
|
-
}
|
|
1955
|
-
});
|
|
1956
|
-
});
|
|
1957
|
-
return function(_data, _error, variables) {
|
|
1958
|
-
return _ref.apply(this, arguments);
|
|
1959
|
-
};
|
|
1960
|
-
}();
|
|
1961
|
-
};
|
|
1962
|
-
// src/hooks/actions/useHandleAction/index.tsx
|
|
1963
|
-
var useHandleAction = function() {
|
|
1964
|
-
var queryClient = useQueryClient7();
|
|
1965
|
-
var superinterfaceContext = useSuperinterfaceContext();
|
|
1966
|
-
var threadContext = useSuperinterfaceContext();
|
|
1967
|
-
var props = useMutation2(_object_spread({
|
|
1968
|
-
onSettled: onSettled2({
|
|
1969
|
-
queryClient: queryClient
|
|
1599
|
+
return [
|
|
1600
|
+
extendMessage({
|
|
1601
|
+
message: message,
|
|
1602
|
+
messages: messages2
|
|
1970
1603
|
})
|
|
1971
|
-
|
|
1972
|
-
mutationKeyBase: [
|
|
1973
|
-
"handleAction"
|
|
1974
|
-
],
|
|
1975
|
-
path: "/actions",
|
|
1976
|
-
queryClient: queryClient,
|
|
1977
|
-
threadContext: threadContext,
|
|
1978
|
-
superinterfaceContext: superinterfaceContext
|
|
1979
|
-
})));
|
|
1980
|
-
return _object_spread_props(_object_spread({}, props), {
|
|
1981
|
-
handleAction: partob2(props.mutateAsync, threadContext.variables)
|
|
1982
|
-
});
|
|
1604
|
+
].concat(_to_consumable_array(prevMessages));
|
|
1983
1605
|
};
|
|
1984
|
-
|
|
1985
|
-
var
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
})
|
|
2004
|
-
|
|
2005
|
-
|
|
1606
|
+
var threadMessageCreated = function(param) {
|
|
1607
|
+
var value = param.value;
|
|
1608
|
+
return function(prevData) {
|
|
1609
|
+
if (!prevData) {
|
|
1610
|
+
return {
|
|
1611
|
+
pageParams: [],
|
|
1612
|
+
pages: [
|
|
1613
|
+
{
|
|
1614
|
+
data: appendMessage({
|
|
1615
|
+
message: value.data,
|
|
1616
|
+
messages: []
|
|
1617
|
+
}),
|
|
1618
|
+
hasNextPage: false,
|
|
1619
|
+
lastId: value.data.id
|
|
1620
|
+
}
|
|
1621
|
+
]
|
|
1622
|
+
};
|
|
1623
|
+
}
|
|
1624
|
+
var _prevData_pages = _to_array(prevData.pages), latestPage = _prevData_pages[0], pagesRest = _prevData_pages.slice(1);
|
|
1625
|
+
return _object_spread_props(_object_spread({}, prevData), {
|
|
1626
|
+
pages: [
|
|
1627
|
+
_object_spread_props(_object_spread({}, latestPage), {
|
|
1628
|
+
data: appendMessage({
|
|
1629
|
+
message: value.data,
|
|
1630
|
+
messages: latestPage.data
|
|
1631
|
+
})
|
|
1632
|
+
})
|
|
1633
|
+
].concat(_to_consumable_array(pagesRest))
|
|
2006
1634
|
});
|
|
2007
|
-
}
|
|
2008
|
-
handledRunIds,
|
|
2009
|
-
handleActionProps,
|
|
2010
|
-
latestRunProps
|
|
2011
|
-
]);
|
|
2012
|
-
return null;
|
|
2013
|
-
};
|
|
2014
|
-
// src/hooks/threads/useLifecycle/index.tsx
|
|
2015
|
-
var useLifecycle = function() {
|
|
2016
|
-
useManageRuns();
|
|
2017
|
-
useManageActions();
|
|
2018
|
-
usePolling();
|
|
2019
|
-
return null;
|
|
2020
|
-
};
|
|
2021
|
-
// src/components/threads/Thread/Messages/Root/index.tsx
|
|
2022
|
-
import { jsx as jsx36, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
2023
|
-
var Root = function(param) {
|
|
2024
|
-
var children = param.children, _param_style = param.style, style = _param_style === void 0 ? {} : _param_style;
|
|
2025
|
-
var _useMessages = useMessages(), isFetchingNextPage = _useMessages.isFetchingNextPage, hasNextPage = _useMessages.hasNextPage, fetchNextPage = _useMessages.fetchNextPage;
|
|
2026
|
-
useLifecycle();
|
|
2027
|
-
var _useInfiniteScroll = useInfiniteScroll({
|
|
2028
|
-
isFetchingNextPage: isFetchingNextPage,
|
|
2029
|
-
hasNextPage: hasNextPage,
|
|
2030
|
-
fetchNextPage: fetchNextPage
|
|
2031
|
-
}), containerRef = _useInfiniteScroll.containerRef, loaderRef = _useInfiniteScroll.loaderRef;
|
|
2032
|
-
return /* @__PURE__ */ jsxs10(Flex11, {
|
|
2033
|
-
ref: containerRef,
|
|
2034
|
-
direction: "column-reverse",
|
|
2035
|
-
flexGrow: "1",
|
|
2036
|
-
style: _object_spread_props(_object_spread({}, style), {
|
|
2037
|
-
overflow: "auto"
|
|
2038
|
-
}),
|
|
2039
|
-
children: [
|
|
2040
|
-
children,
|
|
2041
|
-
hasNextPage && /* @__PURE__ */ jsx36(Flex11, {
|
|
2042
|
-
ref: loaderRef
|
|
2043
|
-
}),
|
|
2044
|
-
/* @__PURE__ */ jsx36(Flex11, {
|
|
2045
|
-
flexShrink: "0",
|
|
2046
|
-
flexGrow: "1"
|
|
2047
|
-
})
|
|
2048
|
-
]
|
|
2049
|
-
});
|
|
1635
|
+
};
|
|
2050
1636
|
};
|
|
2051
|
-
// src/
|
|
2052
|
-
import
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
1637
|
+
// src/hooks/messages/useCreateMessage/lib/mutationOptions/mutationFn/handleResponse/handlers/threadMessageDelta.ts
|
|
1638
|
+
import _6 from "lodash";
|
|
1639
|
+
import { omit as omit2 } from "radash";
|
|
1640
|
+
var updatedContentPart = function(param) {
|
|
1641
|
+
var prevContentPart = param.prevContentPart, delta = param.delta;
|
|
1642
|
+
if (!prevContentPart) {
|
|
1643
|
+
return omit2(delta, [
|
|
1644
|
+
"index"
|
|
1645
|
+
]);
|
|
2057
1646
|
}
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
return /* @__PURE__ */ jsxs11(Root, {
|
|
2065
|
-
style: style,
|
|
2066
|
-
children: [
|
|
2067
|
-
/* @__PURE__ */ jsx38(Flex12, {
|
|
2068
|
-
flexShrink: "0",
|
|
2069
|
-
height: "var(--space-3)"
|
|
2070
|
-
}),
|
|
2071
|
-
/* @__PURE__ */ jsx38(Progress, {}),
|
|
2072
|
-
children,
|
|
2073
|
-
/* @__PURE__ */ jsx38(Content3, {}),
|
|
2074
|
-
/* @__PURE__ */ jsx38(NextPageSkeleton, {}),
|
|
2075
|
-
/* @__PURE__ */ jsx38(Flex12, {
|
|
2076
|
-
flexShrink: "0",
|
|
2077
|
-
flexGrow: "1"
|
|
1647
|
+
if (delta.type === "text" && delta.text && prevContentPart.type == "text" && prevContentPart.text) {
|
|
1648
|
+
var _prevContentPart_text_annotations, _delta_text_annotations;
|
|
1649
|
+
return _object_spread_props(_object_spread({}, prevContentPart), {
|
|
1650
|
+
text: _object_spread_props(_object_spread({}, prevContentPart.text), {
|
|
1651
|
+
value: "".concat(prevContentPart.text.value).concat(delta.text.value),
|
|
1652
|
+
annotations: _to_consumable_array((_prevContentPart_text_annotations = prevContentPart.text.annotations) !== null && _prevContentPart_text_annotations !== void 0 ? _prevContentPart_text_annotations : []).concat(_to_consumable_array((_delta_text_annotations = delta.text.annotations) !== null && _delta_text_annotations !== void 0 ? _delta_text_annotations : []))
|
|
2078
1653
|
})
|
|
2079
|
-
|
|
1654
|
+
});
|
|
1655
|
+
}
|
|
1656
|
+
return prevContentPart;
|
|
1657
|
+
};
|
|
1658
|
+
var updatedContent = function(param) {
|
|
1659
|
+
var content = param.content, value = param.value;
|
|
1660
|
+
if (!value.data.delta.content) return content;
|
|
1661
|
+
var result = _6.cloneDeep(content);
|
|
1662
|
+
value.data.delta.content.forEach(function(delta) {
|
|
1663
|
+
result[delta.index] = updatedContentPart({
|
|
1664
|
+
// @ts-ignore-next-line
|
|
1665
|
+
prevContentPart: result[delta.index],
|
|
1666
|
+
delta: delta
|
|
1667
|
+
});
|
|
2080
1668
|
});
|
|
1669
|
+
return result;
|
|
2081
1670
|
};
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
}
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
})
|
|
2113
|
-
}
|
|
1671
|
+
var threadMessageDelta = function(param) {
|
|
1672
|
+
var value = param.value;
|
|
1673
|
+
return function(prevData) {
|
|
1674
|
+
if (!prevData) {
|
|
1675
|
+
return {
|
|
1676
|
+
pageParams: [],
|
|
1677
|
+
pages: [
|
|
1678
|
+
{
|
|
1679
|
+
data: [],
|
|
1680
|
+
hasNextPage: false,
|
|
1681
|
+
lastId: null
|
|
1682
|
+
}
|
|
1683
|
+
]
|
|
1684
|
+
};
|
|
1685
|
+
}
|
|
1686
|
+
var _prevData_pages = _to_array(prevData.pages), latestPage = _prevData_pages[0], pagesRest = _prevData_pages.slice(1);
|
|
1687
|
+
var _latestPage_data = _to_array(latestPage.data), latestMessage = _latestPage_data[0], messagesRest = _latestPage_data.slice(1);
|
|
1688
|
+
return _object_spread_props(_object_spread({}, prevData), {
|
|
1689
|
+
pages: [
|
|
1690
|
+
_object_spread_props(_object_spread({}, latestPage), {
|
|
1691
|
+
data: [
|
|
1692
|
+
_object_spread_props(_object_spread({}, latestMessage), {
|
|
1693
|
+
content: updatedContent({
|
|
1694
|
+
content: latestMessage.content,
|
|
1695
|
+
value: value
|
|
1696
|
+
})
|
|
1697
|
+
})
|
|
1698
|
+
].concat(_to_consumable_array(messagesRest))
|
|
1699
|
+
})
|
|
1700
|
+
].concat(_to_consumable_array(pagesRest))
|
|
1701
|
+
});
|
|
1702
|
+
};
|
|
2114
1703
|
};
|
|
2115
|
-
// src/
|
|
2116
|
-
import {
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
import { partob as partob3 } from "radash";
|
|
2120
|
-
import { useMutation as useMutation3, useQueryClient as useQueryClient8 } from "@tanstack/react-query";
|
|
2121
|
-
// src/hooks/messages/useCreateMessage/lib/mutationOptions/onMutate/index.ts
|
|
2122
|
-
import { omit } from "radash";
|
|
2123
|
-
// src/hooks/messages/useCreateMessage/lib/mutationOptions/onMutate/data.ts
|
|
2124
|
-
var data2 = function(param) {
|
|
2125
|
-
var newMessage = param.newMessage;
|
|
1704
|
+
// src/hooks/messages/useCreateMessage/lib/mutationOptions/mutationFn/handleResponse/handlers/threadMessageCompleted.ts
|
|
1705
|
+
import { replace } from "radash";
|
|
1706
|
+
var threadMessageCompleted = function(param) {
|
|
1707
|
+
var value = param.value;
|
|
2126
1708
|
return function(prevData) {
|
|
2127
|
-
var message = {
|
|
2128
|
-
id: optimisticId(),
|
|
2129
|
-
role: "user",
|
|
2130
|
-
created_at: +/* @__PURE__ */ new Date(),
|
|
2131
|
-
object: "thread.message",
|
|
2132
|
-
content: [
|
|
2133
|
-
{
|
|
2134
|
-
type: "text",
|
|
2135
|
-
text: {
|
|
2136
|
-
annotations: [],
|
|
2137
|
-
value: newMessage.content
|
|
2138
|
-
}
|
|
2139
|
-
}
|
|
2140
|
-
],
|
|
2141
|
-
run_id: null,
|
|
2142
|
-
assistant_id: null,
|
|
2143
|
-
thread_id: null,
|
|
2144
|
-
file_ids: [],
|
|
2145
|
-
metadata: {},
|
|
2146
|
-
runSteps: []
|
|
2147
|
-
};
|
|
2148
1709
|
if (!prevData) {
|
|
2149
1710
|
return {
|
|
2150
1711
|
pageParams: [],
|
|
2151
1712
|
pages: [
|
|
2152
1713
|
{
|
|
2153
|
-
data: [
|
|
2154
|
-
message
|
|
2155
|
-
],
|
|
1714
|
+
data: [],
|
|
2156
1715
|
hasNextPage: false,
|
|
2157
|
-
lastId:
|
|
1716
|
+
lastId: null
|
|
2158
1717
|
}
|
|
2159
1718
|
]
|
|
2160
1719
|
};
|
|
2161
1720
|
}
|
|
2162
1721
|
var _prevData_pages = _to_array(prevData.pages), latestPage = _prevData_pages[0], pagesRest = _prevData_pages.slice(1);
|
|
1722
|
+
return _object_spread_props(_object_spread({}, prevData), {
|
|
1723
|
+
pages: [
|
|
1724
|
+
_object_spread_props(_object_spread({}, latestPage), {
|
|
1725
|
+
data: replace(latestPage.data, extendMessage({
|
|
1726
|
+
message: value.data,
|
|
1727
|
+
messages: latestPage.data
|
|
1728
|
+
}), function(m) {
|
|
1729
|
+
return m.id === value.data.id;
|
|
1730
|
+
})
|
|
1731
|
+
})
|
|
1732
|
+
].concat(_to_consumable_array(pagesRest))
|
|
1733
|
+
});
|
|
1734
|
+
};
|
|
1735
|
+
};
|
|
1736
|
+
// src/hooks/messages/useCreateMessage/lib/mutationOptions/mutationFn/handleResponse/handlers/threadRunCreated.ts
|
|
1737
|
+
var threadRunCreated = function(param) {
|
|
1738
|
+
var value = param.value;
|
|
1739
|
+
return function(prevData) {
|
|
1740
|
+
if (!prevData) return prevData;
|
|
1741
|
+
var _prevData_pages = _to_array(prevData.pages), latestPage = _prevData_pages[0], pagesRest = _prevData_pages.slice(1);
|
|
2163
1742
|
return _object_spread_props(_object_spread({}, prevData), {
|
|
2164
1743
|
pages: [
|
|
2165
1744
|
_object_spread_props(_object_spread({}, latestPage), {
|
|
2166
1745
|
data: [
|
|
2167
|
-
|
|
1746
|
+
{
|
|
1747
|
+
id: optimisticId(),
|
|
1748
|
+
assistant_id: value.data.assistant_id,
|
|
1749
|
+
content: [],
|
|
1750
|
+
created_at: value.data.created_at,
|
|
1751
|
+
file_ids: [],
|
|
1752
|
+
metadata: {},
|
|
1753
|
+
status: "in_progress",
|
|
1754
|
+
role: "assistant",
|
|
1755
|
+
runSteps: [],
|
|
1756
|
+
run_id: value.data.id,
|
|
1757
|
+
thread_id: value.data.thread_id
|
|
1758
|
+
}
|
|
2168
1759
|
].concat(_to_consumable_array(latestPage.data))
|
|
2169
1760
|
})
|
|
2170
1761
|
].concat(_to_consumable_array(pagesRest))
|
|
2171
1762
|
});
|
|
2172
1763
|
};
|
|
2173
1764
|
};
|
|
2174
|
-
// src/hooks/messages/useCreateMessage/lib/mutationOptions/
|
|
2175
|
-
var
|
|
2176
|
-
var
|
|
2177
|
-
return function() {
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
1765
|
+
// src/hooks/messages/useCreateMessage/lib/mutationOptions/mutationFn/handleResponse/handlers/threadRunStepCreated.ts
|
|
1766
|
+
var threadRunStepCreated = function(param) {
|
|
1767
|
+
var value = param.value;
|
|
1768
|
+
return function(prevData) {
|
|
1769
|
+
if (!prevData) return prevData;
|
|
1770
|
+
var _prevData_pages = _to_array(prevData.pages), latestPage = _prevData_pages[0], pagesRest = _prevData_pages.slice(1);
|
|
1771
|
+
return _object_spread_props(_object_spread({}, prevData), {
|
|
1772
|
+
pages: [
|
|
1773
|
+
_object_spread_props(_object_spread({}, latestPage), {
|
|
1774
|
+
data: latestPage.data.map(function(m) {
|
|
1775
|
+
if (m.run_id === value.data.run_id) {
|
|
1776
|
+
return _object_spread_props(_object_spread({}, m), {
|
|
1777
|
+
runSteps: [
|
|
1778
|
+
value.data
|
|
1779
|
+
].concat(_to_consumable_array(m.runSteps))
|
|
1780
|
+
});
|
|
1781
|
+
}
|
|
1782
|
+
return m;
|
|
1783
|
+
})
|
|
1784
|
+
})
|
|
1785
|
+
].concat(_to_consumable_array(pagesRest))
|
|
1786
|
+
});
|
|
1787
|
+
};
|
|
1788
|
+
};
|
|
1789
|
+
// src/hooks/messages/useCreateMessage/lib/mutationOptions/mutationFn/handleResponse/handlers/threadRunStepDelta.ts
|
|
1790
|
+
import _7 from "lodash";
|
|
1791
|
+
import { omit as omit3 } from "radash";
|
|
1792
|
+
var updatedToolCall = function(param) {
|
|
1793
|
+
var toolCall = param.toolCall, delta = param.delta;
|
|
1794
|
+
if (!toolCall) {
|
|
1795
|
+
return omit3(delta, [
|
|
1796
|
+
"index"
|
|
1797
|
+
]);
|
|
1798
|
+
}
|
|
1799
|
+
if (delta.type === "function" && delta.function && toolCall.type === "function" && toolCall.function) {
|
|
1800
|
+
var result = _7.cloneDeep(toolCall);
|
|
1801
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1802
|
+
try {
|
|
1803
|
+
for(var _iterator = Object.entries(delta.function)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1804
|
+
var _step_value = _sliced_to_array(_step.value, 2), key = _step_value[0], value = _step_value[1];
|
|
1805
|
+
var _result_function_key;
|
|
1806
|
+
result.function[key] = "".concat((_result_function_key = result.function[key]) !== null && _result_function_key !== void 0 ? _result_function_key : "").concat(value);
|
|
1807
|
+
}
|
|
1808
|
+
} catch (err) {
|
|
1809
|
+
_didIteratorError = true;
|
|
1810
|
+
_iteratorError = err;
|
|
1811
|
+
} finally{
|
|
1812
|
+
try {
|
|
1813
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1814
|
+
_iterator.return();
|
|
2208
1815
|
}
|
|
1816
|
+
} finally{
|
|
1817
|
+
if (_didIteratorError) {
|
|
1818
|
+
throw _iteratorError;
|
|
1819
|
+
}
|
|
1820
|
+
}
|
|
1821
|
+
}
|
|
1822
|
+
return result;
|
|
1823
|
+
}
|
|
1824
|
+
return toolCall;
|
|
1825
|
+
};
|
|
1826
|
+
var updatedRunStep = function(param) {
|
|
1827
|
+
var runStep = param.runStep, value = param.value;
|
|
1828
|
+
var _runStep_step_details, _value_data_delta_step_details, _value_data_delta;
|
|
1829
|
+
if (!(runStep === null || runStep === void 0 ? void 0 : (_runStep_step_details = runStep.step_details) === null || _runStep_step_details === void 0 ? void 0 : _runStep_step_details.tool_calls)) return runStep;
|
|
1830
|
+
if (((_value_data_delta = value.data.delta) === null || _value_data_delta === void 0 ? void 0 : (_value_data_delta_step_details = _value_data_delta.step_details) === null || _value_data_delta_step_details === void 0 ? void 0 : _value_data_delta_step_details.type) === "tool_calls") {
|
|
1831
|
+
if (!value.data.delta.step_details.tool_calls) return runStep;
|
|
1832
|
+
var newToolCalls = _7.cloneDeep(runStep.step_details.tool_calls);
|
|
1833
|
+
value.data.delta.step_details.tool_calls.forEach(function(delta) {
|
|
1834
|
+
return newToolCalls[delta.index] = updatedToolCall({
|
|
1835
|
+
toolCall: newToolCalls[delta.index],
|
|
1836
|
+
delta: delta
|
|
2209
1837
|
});
|
|
2210
1838
|
});
|
|
2211
|
-
return
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
1839
|
+
return _object_spread_props(_object_spread({}, runStep), {
|
|
1840
|
+
step_details: _object_spread_props(_object_spread({}, runStep.step_details, value.data.delta.step_details), {
|
|
1841
|
+
tool_calls: newToolCalls
|
|
1842
|
+
})
|
|
1843
|
+
});
|
|
1844
|
+
} else {
|
|
1845
|
+
return runStep;
|
|
1846
|
+
}
|
|
2215
1847
|
};
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
1848
|
+
var threadRunStepDelta = function(param) {
|
|
1849
|
+
var value = param.value;
|
|
1850
|
+
return function(prevData) {
|
|
1851
|
+
if (!prevData) return prevData;
|
|
1852
|
+
var _prevData_pages = _to_array(prevData.pages), latestPage = _prevData_pages[0], pagesRest = _prevData_pages.slice(1);
|
|
1853
|
+
return _object_spread_props(_object_spread({}, prevData), {
|
|
1854
|
+
pages: [
|
|
1855
|
+
_object_spread_props(_object_spread({}, latestPage), {
|
|
1856
|
+
data: latestPage.data.map(function(m) {
|
|
1857
|
+
if (m.run_id === value.data.run_id) {
|
|
1858
|
+
return _object_spread_props(_object_spread({}, m), {
|
|
1859
|
+
runSteps: m.runSteps.map(function(rs) {
|
|
1860
|
+
if (rs.id === value.data.id) {
|
|
1861
|
+
return updatedRunStep({
|
|
1862
|
+
runStep: rs,
|
|
1863
|
+
value: value
|
|
1864
|
+
});
|
|
1865
|
+
}
|
|
1866
|
+
return rs;
|
|
1867
|
+
})
|
|
1868
|
+
});
|
|
1869
|
+
}
|
|
1870
|
+
return m;
|
|
1871
|
+
})
|
|
1872
|
+
})
|
|
1873
|
+
].concat(_to_consumable_array(pagesRest))
|
|
1874
|
+
});
|
|
1875
|
+
};
|
|
1876
|
+
};
|
|
1877
|
+
// src/hooks/messages/useCreateMessage/lib/mutationOptions/mutationFn/handleResponse/handlers/threadRunStepCompleted.ts
|
|
1878
|
+
import { replace as replace2 } from "radash";
|
|
1879
|
+
var threadRunStepCompleted = function(param) {
|
|
1880
|
+
var value = param.value;
|
|
1881
|
+
return function(prevData) {
|
|
1882
|
+
if (!prevData) return prevData;
|
|
1883
|
+
var _prevData_pages = _to_array(prevData.pages), latestPage = _prevData_pages[0], pagesRest = _prevData_pages.slice(1);
|
|
1884
|
+
return _object_spread_props(_object_spread({}, prevData), {
|
|
1885
|
+
pages: [
|
|
1886
|
+
_object_spread_props(_object_spread({}, latestPage), {
|
|
1887
|
+
data: latestPage.data.map(function(m) {
|
|
1888
|
+
if (m.run_id === value.data.run_id) {
|
|
1889
|
+
return _object_spread_props(_object_spread({}, m), {
|
|
1890
|
+
runSteps: replace2(m.runSteps, value.data, function(rs) {
|
|
1891
|
+
return rs.id === value.data.id;
|
|
1892
|
+
})
|
|
1893
|
+
});
|
|
1894
|
+
}
|
|
1895
|
+
return m;
|
|
1896
|
+
})
|
|
1897
|
+
})
|
|
1898
|
+
].concat(_to_consumable_array(pagesRest))
|
|
1899
|
+
});
|
|
1900
|
+
};
|
|
1901
|
+
};
|
|
1902
|
+
// src/hooks/messages/useCreateMessage/lib/mutationOptions/mutationFn/handleResponse/handlers/index.ts
|
|
1903
|
+
var handlers = {
|
|
1904
|
+
"thread.message.created": threadMessageCreated,
|
|
1905
|
+
"thread.message.delta": threadMessageDelta,
|
|
1906
|
+
"thread.message.completed": threadMessageCompleted,
|
|
1907
|
+
"thread.run.created": threadRunCreated,
|
|
1908
|
+
"thread.run.step.created": threadRunStepCreated,
|
|
1909
|
+
"thread.run.step.delta": threadRunStepDelta,
|
|
1910
|
+
"thread.run.step.completed": threadRunStepCompleted
|
|
1911
|
+
};
|
|
1912
|
+
// src/hooks/messages/useCreateMessage/lib/mutationOptions/mutationFn/handleResponse/index.ts
|
|
1913
|
+
var handleResponse = function(param) {
|
|
1914
|
+
var value = param.value, messagesQueryKey = param.messagesQueryKey, queryClient = param.queryClient;
|
|
1915
|
+
var handler = handlers[value.value.event];
|
|
1916
|
+
if (!handler) {
|
|
1917
|
+
return console.log("Missing handler", {
|
|
1918
|
+
value: value
|
|
1919
|
+
});
|
|
1920
|
+
}
|
|
1921
|
+
return queryClient.setQueryData(messagesQueryKey, handler({
|
|
1922
|
+
value: value.value
|
|
1923
|
+
}));
|
|
1924
|
+
};
|
|
1925
|
+
// src/hooks/messages/useCreateMessage/lib/mutationOptions/mutationFn/index.ts
|
|
1926
|
+
var mutationFn = function(param) {
|
|
1927
|
+
var superinterfaceContext = param.superinterfaceContext, queryClient = param.queryClient, threadContext = param.threadContext;
|
|
2220
1928
|
return function() {
|
|
2221
|
-
var _ref = _async_to_generator(function(
|
|
1929
|
+
var _ref = _async_to_generator(function(variables) {
|
|
1930
|
+
var response, parser, reader, messagesQueryKey, _ref, done, value;
|
|
2222
1931
|
return _ts_generator(this, function(_state) {
|
|
2223
1932
|
switch(_state.label){
|
|
2224
1933
|
case 0:
|
|
2225
1934
|
return [
|
|
2226
1935
|
4,
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
1936
|
+
fetch("".concat(superinterfaceContext.baseUrl, "/messages"), _object_spread({
|
|
1937
|
+
method: "POST",
|
|
1938
|
+
body: JSON.stringify(variables),
|
|
1939
|
+
credentials: "include"
|
|
1940
|
+
}, superinterfaceContext.publicApiKey ? {
|
|
1941
|
+
headers: {
|
|
1942
|
+
Authorization: "Bearer ".concat(superinterfaceContext.publicApiKey)
|
|
1943
|
+
}
|
|
1944
|
+
} : {}))
|
|
2235
1945
|
];
|
|
2236
1946
|
case 1:
|
|
2237
|
-
_state.sent();
|
|
1947
|
+
response = _state.sent();
|
|
1948
|
+
if (response.body == null) {
|
|
1949
|
+
throw new Error("The response body is empty.");
|
|
1950
|
+
}
|
|
1951
|
+
parser = new JSONParser({
|
|
1952
|
+
stringBufferSize: void 0,
|
|
1953
|
+
paths: [
|
|
1954
|
+
"$"
|
|
1955
|
+
],
|
|
1956
|
+
separator: ""
|
|
1957
|
+
});
|
|
1958
|
+
reader = response.body.pipeThrough(parser).getReader();
|
|
1959
|
+
messagesQueryKey = [
|
|
1960
|
+
"messages",
|
|
1961
|
+
threadContext.variables
|
|
1962
|
+
];
|
|
1963
|
+
_state.label = 2;
|
|
1964
|
+
case 2:
|
|
1965
|
+
if (!true) return [
|
|
1966
|
+
3,
|
|
1967
|
+
4
|
|
1968
|
+
];
|
|
2238
1969
|
return [
|
|
2239
1970
|
4,
|
|
2240
|
-
|
|
2241
|
-
queryKey: [
|
|
2242
|
-
"runs",
|
|
2243
|
-
omit2(variables, [
|
|
2244
|
-
"content"
|
|
2245
|
-
])
|
|
2246
|
-
]
|
|
2247
|
-
})
|
|
1971
|
+
reader.read()
|
|
2248
1972
|
];
|
|
2249
|
-
case
|
|
2250
|
-
_state.sent();
|
|
1973
|
+
case 3:
|
|
1974
|
+
_ref = _state.sent(), done = _ref.done, value = _ref.value;
|
|
1975
|
+
if (done) return [
|
|
1976
|
+
3,
|
|
1977
|
+
4
|
|
1978
|
+
];
|
|
1979
|
+
handleResponse({
|
|
1980
|
+
value: value,
|
|
1981
|
+
messagesQueryKey: messagesQueryKey,
|
|
1982
|
+
queryClient: queryClient
|
|
1983
|
+
});
|
|
1984
|
+
return [
|
|
1985
|
+
3,
|
|
1986
|
+
2
|
|
1987
|
+
];
|
|
1988
|
+
case 4:
|
|
2251
1989
|
return [
|
|
2252
1990
|
2
|
|
2253
1991
|
];
|
|
2254
1992
|
}
|
|
2255
1993
|
});
|
|
2256
1994
|
});
|
|
2257
|
-
return function(
|
|
1995
|
+
return function(variables) {
|
|
2258
1996
|
return _ref.apply(this, arguments);
|
|
2259
1997
|
};
|
|
2260
1998
|
}();
|
|
2261
1999
|
};
|
|
2000
|
+
// src/hooks/messages/useCreateMessage/lib/mutationOptions/index.ts
|
|
2001
|
+
var mutationOptions = function(param) {
|
|
2002
|
+
var queryClient = param.queryClient, threadContext = param.threadContext, superinterfaceContext = param.superinterfaceContext, onError = param.onError;
|
|
2003
|
+
var mutationKey = [
|
|
2004
|
+
"createMessage",
|
|
2005
|
+
threadContext.variables
|
|
2006
|
+
];
|
|
2007
|
+
return _object_spread_props(_object_spread({
|
|
2008
|
+
mutationFn: mutationFn({
|
|
2009
|
+
queryClient: queryClient,
|
|
2010
|
+
superinterfaceContext: superinterfaceContext,
|
|
2011
|
+
threadContext: threadContext
|
|
2012
|
+
}),
|
|
2013
|
+
onMutate: onMutate({
|
|
2014
|
+
queryClient: queryClient
|
|
2015
|
+
}),
|
|
2016
|
+
onError: onError
|
|
2017
|
+
}, threadContext.defaultOptions.mutations, queryClient.getMutationDefaults(mutationKey)), {
|
|
2018
|
+
mutationKey: mutationKey
|
|
2019
|
+
});
|
|
2020
|
+
};
|
|
2262
2021
|
// src/hooks/messages/useCreateMessage/index.ts
|
|
2263
2022
|
var useCreateMessage = function() {
|
|
2264
2023
|
var _ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
|
|
2265
2024
|
onError: function() {}
|
|
2266
2025
|
}, _ref_onError = _ref.onError, onError = _ref_onError === void 0 ? function() {} : _ref_onError;
|
|
2267
|
-
var queryClient =
|
|
2026
|
+
var queryClient = useQueryClient3();
|
|
2268
2027
|
var superinterfaceContext = useSuperinterfaceContext();
|
|
2269
2028
|
var threadContext = useSuperinterfaceContext();
|
|
2270
|
-
var props =
|
|
2271
|
-
onMutate: onMutate2({
|
|
2272
|
-
queryClient: queryClient
|
|
2273
|
-
}),
|
|
2274
|
-
onSettled: onSettled3({
|
|
2275
|
-
queryClient: queryClient
|
|
2276
|
-
}),
|
|
2277
|
-
onError: onError
|
|
2278
|
-
}, mutationOptions({
|
|
2279
|
-
mutationKeyBase: [
|
|
2280
|
-
"createMessage"
|
|
2281
|
-
],
|
|
2282
|
-
path: "/messages",
|
|
2029
|
+
var props = useMutation(mutationOptions({
|
|
2283
2030
|
queryClient: queryClient,
|
|
2284
2031
|
threadContext: threadContext,
|
|
2285
|
-
superinterfaceContext: superinterfaceContext
|
|
2286
|
-
|
|
2032
|
+
superinterfaceContext: superinterfaceContext,
|
|
2033
|
+
onError: onError
|
|
2034
|
+
}));
|
|
2287
2035
|
return _object_spread_props(_object_spread({}, props), {
|
|
2288
|
-
createMessage:
|
|
2036
|
+
createMessage: partob(props.mutateAsync, threadContext.variables)
|
|
2289
2037
|
});
|
|
2290
2038
|
};
|
|
2291
2039
|
// src/components/threads/Thread/MessageForm/Root/lib/formOptions.ts
|
|
@@ -2303,13 +2051,6 @@ var Root2 = function(param) {
|
|
|
2303
2051
|
var children = param.children;
|
|
2304
2052
|
var formProps = useForm(formOptions);
|
|
2305
2053
|
var handleSubmit = formProps.handleSubmit, isSubmitting = formProps.formState.isSubmitting, reset = formProps.reset;
|
|
2306
|
-
var _useIsRunActive = useIsRunActive(), isRunActive2 = _useIsRunActive.isRunActive;
|
|
2307
|
-
var isLoading = useMemo9(function() {
|
|
2308
|
-
return isRunActive2 || isSubmitting;
|
|
2309
|
-
}, [
|
|
2310
|
-
isRunActive2,
|
|
2311
|
-
isSubmitting
|
|
2312
|
-
]);
|
|
2313
2054
|
var addToast = useToasts().addToast;
|
|
2314
2055
|
var createMessage = useCreateMessage({
|
|
2315
2056
|
onError: function(error) {
|
|
@@ -2319,8 +2060,15 @@ var Root2 = function(param) {
|
|
|
2319
2060
|
});
|
|
2320
2061
|
}
|
|
2321
2062
|
}).createMessage;
|
|
2063
|
+
var isMutatingMessage = useIsMutatingMessage();
|
|
2064
|
+
var isLoading = useMemo8(function() {
|
|
2065
|
+
return isMutatingMessage || isSubmitting;
|
|
2066
|
+
}, [
|
|
2067
|
+
isMutatingMessage,
|
|
2068
|
+
isSubmitting
|
|
2069
|
+
]);
|
|
2322
2070
|
var onSubmit = function() {
|
|
2323
|
-
var _ref = _async_to_generator(function(
|
|
2071
|
+
var _ref = _async_to_generator(function(data2) {
|
|
2324
2072
|
return _ts_generator(this, function(_state) {
|
|
2325
2073
|
switch(_state.label){
|
|
2326
2074
|
case 0:
|
|
@@ -2328,7 +2076,7 @@ var Root2 = function(param) {
|
|
|
2328
2076
|
return [
|
|
2329
2077
|
4,
|
|
2330
2078
|
createMessage({
|
|
2331
|
-
content:
|
|
2079
|
+
content: data2.content
|
|
2332
2080
|
})
|
|
2333
2081
|
];
|
|
2334
2082
|
case 1:
|
|
@@ -2339,12 +2087,12 @@ var Root2 = function(param) {
|
|
|
2339
2087
|
}
|
|
2340
2088
|
});
|
|
2341
2089
|
});
|
|
2342
|
-
return function onSubmit(
|
|
2090
|
+
return function onSubmit(data2) {
|
|
2343
2091
|
return _ref.apply(this, arguments);
|
|
2344
2092
|
};
|
|
2345
2093
|
}();
|
|
2346
2094
|
var latestMessage = useLatestMessage().latestMessage;
|
|
2347
|
-
var isDisabled =
|
|
2095
|
+
var isDisabled = useMemo8(function() {
|
|
2348
2096
|
var // @ts-ignore-next-line
|
|
2349
2097
|
_latestMessage_metadata;
|
|
2350
2098
|
return latestMessage === null || latestMessage === void 0 ? void 0 : (_latestMessage_metadata = latestMessage.metadata) === null || _latestMessage_metadata === void 0 ? void 0 : _latestMessage_metadata.isBlocking;
|
|
@@ -2366,15 +2114,15 @@ var Root2 = function(param) {
|
|
|
2366
2114
|
});
|
|
2367
2115
|
};
|
|
2368
2116
|
// src/components/threads/Thread/MessageForm/Field/index.tsx
|
|
2369
|
-
import { usePrevious
|
|
2370
|
-
import { useContext as
|
|
2117
|
+
import { usePrevious } from "react-use";
|
|
2118
|
+
import { useContext as useContext9, useMemo as useMemo9, useRef as useRef3, useEffect as useEffect3 } from "react";
|
|
2371
2119
|
// src/components/textareas/TextareaBase/index.tsx
|
|
2372
2120
|
import { forwardRef as forwardRef3 } from "react";
|
|
2373
2121
|
import TextareaAutosize from "react-textarea-autosize";
|
|
2374
|
-
import { Fragment as
|
|
2122
|
+
import { Fragment as Fragment3, jsx as jsx41, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
2375
2123
|
var UPSCALE_RATIO = 16 / 14;
|
|
2376
2124
|
var TextareaBase = forwardRef3(function TextareaBase2(props, ref) {
|
|
2377
|
-
return /* @__PURE__ */
|
|
2125
|
+
return /* @__PURE__ */ jsxs11(Fragment3, {
|
|
2378
2126
|
children: [
|
|
2379
2127
|
/* @__PURE__ */ jsx41("style", {
|
|
2380
2128
|
children: ".superinterface-textarea { min-height: inherit; height: 30px; }\n.superinterface-textarea::placeholder { color: var(--gray-a10); }"
|
|
@@ -2435,19 +2183,19 @@ var Root3 = function(param) {
|
|
|
2435
2183
|
});
|
|
2436
2184
|
};
|
|
2437
2185
|
var Control = function() {
|
|
2438
|
-
var assistantNameContext =
|
|
2186
|
+
var assistantNameContext = useContext9(AssistantNameContext);
|
|
2439
2187
|
var register = useFormContext().register;
|
|
2440
2188
|
var _useMessageFormContext = useMessageFormContext(), isDisabled = _useMessageFormContext.isDisabled, isLoading = _useMessageFormContext.isLoading;
|
|
2441
|
-
var isSubmitDisabled =
|
|
2189
|
+
var isSubmitDisabled = useMemo9(function() {
|
|
2442
2190
|
return isDisabled || isLoading;
|
|
2443
2191
|
}, [
|
|
2444
2192
|
isDisabled,
|
|
2445
2193
|
isLoading
|
|
2446
2194
|
]);
|
|
2447
|
-
var isDisabledPrevious =
|
|
2195
|
+
var isDisabledPrevious = usePrevious(isDisabled);
|
|
2448
2196
|
var textareaRef = useRef3(null);
|
|
2449
2197
|
var textareaProps = register("content");
|
|
2450
|
-
|
|
2198
|
+
useEffect3(function() {
|
|
2451
2199
|
if (isDisabled) return;
|
|
2452
2200
|
if (!isDisabledPrevious) return;
|
|
2453
2201
|
if (!textareaRef.current) return;
|
|
@@ -2481,10 +2229,10 @@ var Field = {
|
|
|
2481
2229
|
Control: Control
|
|
2482
2230
|
};
|
|
2483
2231
|
// src/components/threads/Thread/MessageForm/index.tsx
|
|
2484
|
-
import { jsx as jsx43, jsxs as
|
|
2232
|
+
import { jsx as jsx43, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
2485
2233
|
var MessageForm = function() {
|
|
2486
2234
|
return /* @__PURE__ */ jsx43(Root2, {
|
|
2487
|
-
children: /* @__PURE__ */
|
|
2235
|
+
children: /* @__PURE__ */ jsxs12(Field.Root, {
|
|
2488
2236
|
children: [
|
|
2489
2237
|
/* @__PURE__ */ jsx43(Text5, {
|
|
2490
2238
|
size: "2",
|
|
@@ -2511,35 +2259,16 @@ MessageForm.Field = Field;
|
|
|
2511
2259
|
MessageForm.Submit = Submit;
|
|
2512
2260
|
// src/components/threads/Thread/Root/index.tsx
|
|
2513
2261
|
import { Flex as Flex15 } from "@radix-ui/themes";
|
|
2514
|
-
// src/components/runs/PollingProvider/index.tsx
|
|
2515
|
-
import { useState as useState3 } from "react";
|
|
2516
|
-
import { jsx as jsx44 } from "react/jsx-runtime";
|
|
2517
|
-
var PollingProvider = function(param) {
|
|
2518
|
-
var children = param.children;
|
|
2519
|
-
var _useState3 = _sliced_to_array(useState3(false), 2), isPollRefetching = _useState3[0], setIsPollRefetching = _useState3[1];
|
|
2520
|
-
return /* @__PURE__ */ jsx44(PollingContext.Provider, {
|
|
2521
|
-
value: {
|
|
2522
|
-
isPollRefetching: isPollRefetching,
|
|
2523
|
-
setIsPollRefetching: setIsPollRefetching
|
|
2524
|
-
},
|
|
2525
|
-
children: children
|
|
2526
|
-
});
|
|
2527
|
-
};
|
|
2528
2262
|
// src/components/threads/Thread/Provider/index.tsx
|
|
2529
|
-
|
|
2530
|
-
var Provider2 = function(args) {
|
|
2531
|
-
return /* @__PURE__ */ jsx45(PollingProvider, {
|
|
2532
|
-
children: /* @__PURE__ */ jsx45(SuperinterfaceProvider, _object_spread({}, args))
|
|
2533
|
-
});
|
|
2534
|
-
};
|
|
2263
|
+
var Provider2 = SuperinterfaceProvider;
|
|
2535
2264
|
// src/components/threads/Thread/Root/index.tsx
|
|
2536
|
-
import { jsx as
|
|
2265
|
+
import { jsx as jsx44 } from "react/jsx-runtime";
|
|
2537
2266
|
var Root4 = function(_param) {
|
|
2538
2267
|
var children = _param.children, rest = _object_without_properties(_param, [
|
|
2539
2268
|
"children"
|
|
2540
2269
|
]);
|
|
2541
|
-
return /* @__PURE__ */
|
|
2542
|
-
children: /* @__PURE__ */
|
|
2270
|
+
return /* @__PURE__ */ jsx44(Provider2, _object_spread_props(_object_spread({}, rest), {
|
|
2271
|
+
children: /* @__PURE__ */ jsx44(Flex15, {
|
|
2543
2272
|
direction: "column",
|
|
2544
2273
|
flexGrow: "1",
|
|
2545
2274
|
children: children
|
|
@@ -2547,12 +2276,12 @@ var Root4 = function(_param) {
|
|
|
2547
2276
|
}));
|
|
2548
2277
|
};
|
|
2549
2278
|
// src/components/threads/Thread/index.tsx
|
|
2550
|
-
import { jsx as
|
|
2279
|
+
import { jsx as jsx45, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
2551
2280
|
var Thread = function(props) {
|
|
2552
|
-
return /* @__PURE__ */
|
|
2281
|
+
return /* @__PURE__ */ jsxs13(Root4, _object_spread_props(_object_spread({}, props), {
|
|
2553
2282
|
children: [
|
|
2554
|
-
/* @__PURE__ */
|
|
2555
|
-
/* @__PURE__ */
|
|
2283
|
+
/* @__PURE__ */ jsx45(Messages, {}),
|
|
2284
|
+
/* @__PURE__ */ jsx45(MessageForm, {})
|
|
2556
2285
|
]
|
|
2557
2286
|
}));
|
|
2558
2287
|
};
|
|
@@ -2560,30 +2289,30 @@ Thread.Root = Root4;
|
|
|
2560
2289
|
Thread.Messages = Messages;
|
|
2561
2290
|
Thread.MessageForm = MessageForm;
|
|
2562
2291
|
// src/hooks/messages/useMessageContext/index.ts
|
|
2563
|
-
import { useContext as
|
|
2292
|
+
import { useContext as useContext10 } from "react";
|
|
2564
2293
|
var useMessageContext = function() {
|
|
2565
|
-
return
|
|
2294
|
+
return useContext10(MessageContext);
|
|
2566
2295
|
};
|
|
2567
2296
|
// src/components/threads/ThreadDialog/Provider/index.tsx
|
|
2568
|
-
import { useState
|
|
2297
|
+
import { useState } from "react";
|
|
2569
2298
|
// src/contexts/threads/ThreadDialogContext/index.ts
|
|
2570
|
-
import { createContext as
|
|
2571
|
-
var ThreadDialogContext =
|
|
2299
|
+
import { createContext as createContext9 } from "react";
|
|
2300
|
+
var ThreadDialogContext = createContext9({
|
|
2572
2301
|
isOpen: false,
|
|
2573
2302
|
setIsOpen: function() {}
|
|
2574
2303
|
});
|
|
2575
2304
|
// src/hooks/threads/useThreadDialogContext/index.ts
|
|
2576
|
-
import { useContext as
|
|
2305
|
+
import { useContext as useContext11 } from "react";
|
|
2577
2306
|
var useThreadDialogContext = function() {
|
|
2578
|
-
return
|
|
2307
|
+
return useContext11(ThreadDialogContext);
|
|
2579
2308
|
};
|
|
2580
2309
|
// src/components/threads/ThreadDialog/Provider/index.tsx
|
|
2581
|
-
import { jsx as
|
|
2310
|
+
import { jsx as jsx46 } from "react/jsx-runtime";
|
|
2582
2311
|
var Provider3 = function(param) {
|
|
2583
2312
|
var children = param.children;
|
|
2584
2313
|
var threadDialogContext = useThreadDialogContext();
|
|
2585
|
-
var
|
|
2586
|
-
return /* @__PURE__ */
|
|
2314
|
+
var _useState = _sliced_to_array(useState(threadDialogContext.isOpen), 2), isOpen = _useState[0], setIsOpen = _useState[1];
|
|
2315
|
+
return /* @__PURE__ */ jsx46(ThreadDialogContext.Provider, {
|
|
2587
2316
|
value: {
|
|
2588
2317
|
isOpen: isOpen,
|
|
2589
2318
|
setIsOpen: setIsOpen
|
|
@@ -2592,31 +2321,31 @@ var Provider3 = function(param) {
|
|
|
2592
2321
|
});
|
|
2593
2322
|
};
|
|
2594
2323
|
// src/components/toasts/ToastsProvider/index.tsx
|
|
2595
|
-
import { useState as
|
|
2324
|
+
import { useState as useState2, useCallback as useCallback2 } from "react";
|
|
2596
2325
|
import * as Toast2 from "@radix-ui/react-toast";
|
|
2597
2326
|
// src/components/toasts/ToastsProvider/CustomToast.tsx
|
|
2598
2327
|
import * as Toast from "@radix-ui/react-toast";
|
|
2599
2328
|
import { Card, Text as Text6, Flex as Flex16 } from "@radix-ui/themes";
|
|
2600
2329
|
import { CheckCircledIcon as CheckCircledIcon2, CrossCircledIcon } from "@radix-ui/react-icons";
|
|
2601
|
-
import { jsx as
|
|
2330
|
+
import { jsx as jsx47, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
2602
2331
|
var CustomToast = function(param) {
|
|
2603
2332
|
var toast = param.toast;
|
|
2604
|
-
return /* @__PURE__ */
|
|
2605
|
-
children: /* @__PURE__ */
|
|
2606
|
-
children: /* @__PURE__ */
|
|
2607
|
-
children: /* @__PURE__ */
|
|
2333
|
+
return /* @__PURE__ */ jsx47(Toast.Root, {
|
|
2334
|
+
children: /* @__PURE__ */ jsx47(Card, {
|
|
2335
|
+
children: /* @__PURE__ */ jsx47(Toast.Title, {
|
|
2336
|
+
children: /* @__PURE__ */ jsxs14(Flex16, {
|
|
2608
2337
|
children: [
|
|
2609
|
-
/* @__PURE__ */
|
|
2338
|
+
/* @__PURE__ */ jsx47(Flex16, {
|
|
2610
2339
|
pr: "2",
|
|
2611
2340
|
height: "14px",
|
|
2612
2341
|
align: "center",
|
|
2613
|
-
children: toast.type === "success" ? /* @__PURE__ */
|
|
2342
|
+
children: toast.type === "success" ? /* @__PURE__ */ jsx47(CheckCircledIcon2, {
|
|
2614
2343
|
color: "var(--mint-9)"
|
|
2615
|
-
}) : /* @__PURE__ */
|
|
2344
|
+
}) : /* @__PURE__ */ jsx47(CrossCircledIcon, {
|
|
2616
2345
|
color: "var(--red-9)"
|
|
2617
2346
|
})
|
|
2618
2347
|
}),
|
|
2619
|
-
/* @__PURE__ */
|
|
2348
|
+
/* @__PURE__ */ jsx47(Text6, {
|
|
2620
2349
|
weight: "medium",
|
|
2621
2350
|
size: "1",
|
|
2622
2351
|
children: toast.message
|
|
@@ -2628,10 +2357,10 @@ var CustomToast = function(param) {
|
|
|
2628
2357
|
});
|
|
2629
2358
|
};
|
|
2630
2359
|
// src/components/toasts/ToastsProvider/index.tsx
|
|
2631
|
-
import { jsx as
|
|
2360
|
+
import { jsx as jsx48, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
2632
2361
|
var ToastsProvider = function(param) {
|
|
2633
2362
|
var children = param.children;
|
|
2634
|
-
var
|
|
2363
|
+
var _useState2 = _sliced_to_array(useState2([]), 2), toasts = _useState2[0], setToasts = _useState2[1];
|
|
2635
2364
|
var addToast = useCallback2(function(toast) {
|
|
2636
2365
|
return setToasts(function(prevToasts) {
|
|
2637
2366
|
return _to_consumable_array(prevToasts).concat([
|
|
@@ -2639,20 +2368,20 @@ var ToastsProvider = function(param) {
|
|
|
2639
2368
|
]);
|
|
2640
2369
|
});
|
|
2641
2370
|
}, []);
|
|
2642
|
-
return /* @__PURE__ */
|
|
2371
|
+
return /* @__PURE__ */ jsx48(ToastsContext.Provider, {
|
|
2643
2372
|
value: {
|
|
2644
2373
|
toasts: toasts,
|
|
2645
2374
|
addToast: addToast
|
|
2646
2375
|
},
|
|
2647
|
-
children: /* @__PURE__ */
|
|
2376
|
+
children: /* @__PURE__ */ jsxs15(Toast2.Provider, {
|
|
2648
2377
|
children: [
|
|
2649
2378
|
children,
|
|
2650
2379
|
Array.from(toasts).map(function(toast, index) {
|
|
2651
|
-
return /* @__PURE__ */
|
|
2380
|
+
return /* @__PURE__ */ jsx48(CustomToast, {
|
|
2652
2381
|
toast: toast
|
|
2653
2382
|
}, index);
|
|
2654
2383
|
}),
|
|
2655
|
-
/* @__PURE__ */
|
|
2384
|
+
/* @__PURE__ */ jsx48(Toast2.Viewport, {
|
|
2656
2385
|
style: {
|
|
2657
2386
|
position: "absolute",
|
|
2658
2387
|
bottom: 0,
|
|
@@ -2674,22 +2403,22 @@ var ToastsProvider = function(param) {
|
|
|
2674
2403
|
});
|
|
2675
2404
|
};
|
|
2676
2405
|
// src/components/threads/ThreadDialog/Root/index.tsx
|
|
2677
|
-
import { jsx as
|
|
2406
|
+
import { jsx as jsx49 } from "react/jsx-runtime";
|
|
2678
2407
|
var Root6 = function(param) {
|
|
2679
|
-
var children = param.children
|
|
2680
|
-
return /* @__PURE__ */
|
|
2681
|
-
children: /* @__PURE__ */
|
|
2408
|
+
var children = param.children;
|
|
2409
|
+
return /* @__PURE__ */ jsx49(ToastsProvider, {
|
|
2410
|
+
children: /* @__PURE__ */ jsx49(Provider3, {
|
|
2682
2411
|
children: children
|
|
2683
2412
|
})
|
|
2684
2413
|
});
|
|
2685
2414
|
};
|
|
2686
2415
|
// src/components/threads/ThreadDialog/Trigger/index.tsx
|
|
2687
2416
|
import { Flex as Flex17 } from "@radix-ui/themes";
|
|
2688
|
-
import { jsx as
|
|
2417
|
+
import { jsx as jsx50 } from "react/jsx-runtime";
|
|
2689
2418
|
var Trigger = function(param) {
|
|
2690
2419
|
var children = param.children, _param_style = param.style, style = _param_style === void 0 ? {} : _param_style;
|
|
2691
2420
|
var _useThreadDialogContext = useThreadDialogContext(), setIsOpen = _useThreadDialogContext.setIsOpen, isOpen = _useThreadDialogContext.isOpen;
|
|
2692
|
-
return /* @__PURE__ */
|
|
2421
|
+
return /* @__PURE__ */ jsx50(Flex17, {
|
|
2693
2422
|
display: {
|
|
2694
2423
|
initial: isOpen ? "none" : "flex",
|
|
2695
2424
|
sm: "flex"
|
|
@@ -2715,12 +2444,12 @@ var Trigger = function(param) {
|
|
|
2715
2444
|
// src/components/threads/ThreadDialog/Button/index.tsx
|
|
2716
2445
|
import { IconButton as IconButton2 } from "@radix-ui/themes";
|
|
2717
2446
|
import { ChatBubbleIcon } from "@radix-ui/react-icons";
|
|
2718
|
-
import { jsx as
|
|
2447
|
+
import { jsx as jsx51 } from "react/jsx-runtime";
|
|
2719
2448
|
var Button2 = function() {
|
|
2720
|
-
return /* @__PURE__ */
|
|
2449
|
+
return /* @__PURE__ */ jsx51(IconButton2, {
|
|
2721
2450
|
size: "4",
|
|
2722
2451
|
radius: "full",
|
|
2723
|
-
children: /* @__PURE__ */
|
|
2452
|
+
children: /* @__PURE__ */ jsx51(ChatBubbleIcon, {})
|
|
2724
2453
|
});
|
|
2725
2454
|
};
|
|
2726
2455
|
// src/components/threads/ThreadDialog/Content/index.tsx
|
|
@@ -2728,10 +2457,10 @@ import { Card as Card2, Inset, Flex as Flex19 } from "@radix-ui/themes";
|
|
|
2728
2457
|
// src/components/threads/ThreadDialog/Close/index.tsx
|
|
2729
2458
|
import { Cross1Icon } from "@radix-ui/react-icons";
|
|
2730
2459
|
import { IconButton as IconButton3, Flex as Flex18 } from "@radix-ui/themes";
|
|
2731
|
-
import { jsx as
|
|
2460
|
+
import { jsx as jsx52 } from "react/jsx-runtime";
|
|
2732
2461
|
var Close = function() {
|
|
2733
2462
|
var _useThreadDialogContext = useThreadDialogContext(), setIsOpen = _useThreadDialogContext.setIsOpen, isOpen = _useThreadDialogContext.isOpen;
|
|
2734
|
-
return /* @__PURE__ */
|
|
2463
|
+
return /* @__PURE__ */ jsx52(Flex18, {
|
|
2735
2464
|
display: {
|
|
2736
2465
|
initial: isOpen ? "flex" : "none",
|
|
2737
2466
|
sm: "none"
|
|
@@ -2751,20 +2480,20 @@ var Close = function() {
|
|
|
2751
2480
|
style: {
|
|
2752
2481
|
zIndex: 9999999999
|
|
2753
2482
|
},
|
|
2754
|
-
children: /* @__PURE__ */
|
|
2483
|
+
children: /* @__PURE__ */ jsx52(IconButton3, {
|
|
2755
2484
|
size: "2",
|
|
2756
2485
|
variant: "soft",
|
|
2757
|
-
children: /* @__PURE__ */
|
|
2486
|
+
children: /* @__PURE__ */ jsx52(Cross1Icon, {})
|
|
2758
2487
|
})
|
|
2759
2488
|
});
|
|
2760
2489
|
};
|
|
2761
2490
|
// src/components/threads/ThreadDialog/Content/index.tsx
|
|
2762
|
-
import { jsx as
|
|
2491
|
+
import { jsx as jsx53, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
2763
2492
|
var Root7 = function(param) {
|
|
2764
2493
|
var children = param.children, _param_style = param.style, style = _param_style === void 0 ? {} : _param_style;
|
|
2765
2494
|
var isOpen = useThreadDialogContext().isOpen;
|
|
2766
2495
|
if (!isOpen) return null;
|
|
2767
|
-
return /* @__PURE__ */
|
|
2496
|
+
return /* @__PURE__ */ jsx53(Flex19, {
|
|
2768
2497
|
direction: "column",
|
|
2769
2498
|
justify: "end",
|
|
2770
2499
|
position: "fixed",
|
|
@@ -2792,7 +2521,7 @@ var Root7 = function(param) {
|
|
|
2792
2521
|
style: _object_spread({
|
|
2793
2522
|
zIndex: 9999999999
|
|
2794
2523
|
}, style),
|
|
2795
|
-
children: /* @__PURE__ */
|
|
2524
|
+
children: /* @__PURE__ */ jsxs16(Card2, {
|
|
2796
2525
|
mb: {
|
|
2797
2526
|
initial: void 0,
|
|
2798
2527
|
sm: "3"
|
|
@@ -2803,7 +2532,7 @@ var Root7 = function(param) {
|
|
|
2803
2532
|
flexGrow: 1
|
|
2804
2533
|
},
|
|
2805
2534
|
children: [
|
|
2806
|
-
/* @__PURE__ */
|
|
2535
|
+
/* @__PURE__ */ jsx53(Inset, {
|
|
2807
2536
|
clip: "padding-box",
|
|
2808
2537
|
side: "all",
|
|
2809
2538
|
pb: "current",
|
|
@@ -2813,31 +2542,31 @@ var Root7 = function(param) {
|
|
|
2813
2542
|
},
|
|
2814
2543
|
children: children
|
|
2815
2544
|
}),
|
|
2816
|
-
/* @__PURE__ */
|
|
2545
|
+
/* @__PURE__ */ jsx53(Close, {})
|
|
2817
2546
|
]
|
|
2818
2547
|
})
|
|
2819
2548
|
});
|
|
2820
2549
|
};
|
|
2821
2550
|
var Content4 = function(param) {
|
|
2822
2551
|
var _param_style = param.style, style = _param_style === void 0 ? {} : _param_style;
|
|
2823
|
-
return /* @__PURE__ */
|
|
2552
|
+
return /* @__PURE__ */ jsx53(Root7, {
|
|
2824
2553
|
style: style,
|
|
2825
|
-
children: /* @__PURE__ */
|
|
2554
|
+
children: /* @__PURE__ */ jsxs16(Thread.Root, {
|
|
2826
2555
|
children: [
|
|
2827
|
-
/* @__PURE__ */
|
|
2556
|
+
/* @__PURE__ */ jsx53(Thread.Messages, {
|
|
2828
2557
|
style: {
|
|
2829
2558
|
paddingTop: "var(--space-5)",
|
|
2830
2559
|
paddingRight: "var(--space-5)",
|
|
2831
2560
|
paddingLeft: "var(--space-5)"
|
|
2832
2561
|
}
|
|
2833
2562
|
}),
|
|
2834
|
-
/* @__PURE__ */
|
|
2563
|
+
/* @__PURE__ */ jsx53(Flex19, {
|
|
2835
2564
|
direction: "column",
|
|
2836
2565
|
pl: "5",
|
|
2837
2566
|
pr: "5",
|
|
2838
2567
|
pb: "3",
|
|
2839
2568
|
flexShrink: "0",
|
|
2840
|
-
children: /* @__PURE__ */
|
|
2569
|
+
children: /* @__PURE__ */ jsx53(Thread.MessageForm, {})
|
|
2841
2570
|
})
|
|
2842
2571
|
]
|
|
2843
2572
|
})
|
|
@@ -2845,13 +2574,13 @@ var Content4 = function(param) {
|
|
|
2845
2574
|
};
|
|
2846
2575
|
Content4.Root = Root7;
|
|
2847
2576
|
// src/components/threads/ThreadDialog/index.tsx
|
|
2848
|
-
import { jsx as
|
|
2577
|
+
import { jsx as jsx54, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
2849
2578
|
var ThreadDialog = function() {
|
|
2850
|
-
return /* @__PURE__ */
|
|
2579
|
+
return /* @__PURE__ */ jsxs17(Root6, {
|
|
2851
2580
|
children: [
|
|
2852
|
-
/* @__PURE__ */
|
|
2853
|
-
/* @__PURE__ */
|
|
2854
|
-
children: /* @__PURE__ */
|
|
2581
|
+
/* @__PURE__ */ jsx54(Content4, {}),
|
|
2582
|
+
/* @__PURE__ */ jsx54(Trigger, {
|
|
2583
|
+
children: /* @__PURE__ */ jsx54(Button2, {})
|
|
2855
2584
|
})
|
|
2856
2585
|
]
|
|
2857
2586
|
});
|
|
@@ -2864,8 +2593,8 @@ ThreadDialog.Content = Content4;
|
|
|
2864
2593
|
import "regenerator-runtime/runtime";
|
|
2865
2594
|
import { Flex as Flex20 } from "@radix-ui/themes";
|
|
2866
2595
|
// src/contexts/threads/AudioThreadContext/index.ts
|
|
2867
|
-
import { createContext as
|
|
2868
|
-
var AudioThreadContext =
|
|
2596
|
+
import { createContext as createContext10 } from "react";
|
|
2597
|
+
var AudioThreadContext = createContext10({
|
|
2869
2598
|
status: "idle",
|
|
2870
2599
|
recorderProps: {
|
|
2871
2600
|
status: "idle",
|
|
@@ -2933,14 +2662,12 @@ var blobToData = function(blob) {
|
|
|
2933
2662
|
});
|
|
2934
2663
|
};
|
|
2935
2664
|
// src/hooks/audioThreads/useStatus/index.ts
|
|
2936
|
-
import { useMemo as
|
|
2665
|
+
import { useMemo as useMemo10 } from "react";
|
|
2937
2666
|
var useStatus = function(param) {
|
|
2938
2667
|
var messageAudioProps = param.messageAudioProps, recorderProps = param.recorderProps, createMessageProps = param.createMessageProps;
|
|
2939
|
-
var
|
|
2940
|
-
var status = useMemo11(function() {
|
|
2668
|
+
var status = useMemo10(function() {
|
|
2941
2669
|
if (recorderProps.status === "recording") return "recording";
|
|
2942
2670
|
if (createMessageProps.isPending) return "creatingMessage";
|
|
2943
|
-
if (isRunActiveProps.isRunActive) return "runActive";
|
|
2944
2671
|
if (messageAudioProps.playing) return "playing";
|
|
2945
2672
|
if (messageAudioProps.paused) return "playerPaused";
|
|
2946
2673
|
if (!messageAudioProps.isReady) return "loading";
|
|
@@ -2950,29 +2677,28 @@ var useStatus = function(param) {
|
|
|
2950
2677
|
}, [
|
|
2951
2678
|
messageAudioProps,
|
|
2952
2679
|
recorderProps,
|
|
2953
|
-
createMessageProps
|
|
2954
|
-
isRunActiveProps
|
|
2680
|
+
createMessageProps
|
|
2955
2681
|
]);
|
|
2956
2682
|
return {
|
|
2957
2683
|
status: status
|
|
2958
2684
|
};
|
|
2959
2685
|
};
|
|
2960
2686
|
// src/hooks/audioThreads/useRecorder/index.ts
|
|
2961
|
-
import
|
|
2687
|
+
import dayjs2 from "dayjs";
|
|
2962
2688
|
import { useAudioCapture } from "use-audio-capture";
|
|
2963
|
-
import { useMemo as
|
|
2689
|
+
import { useMemo as useMemo11, useRef as useRef4, useState as useState3, useCallback as useCallback3, useEffect as useEffect4 } from "react";
|
|
2964
2690
|
import { useAudioPlayer } from "react-use-audio-player";
|
|
2965
|
-
import { useInterval
|
|
2691
|
+
import { useInterval } from "react-use";
|
|
2966
2692
|
var useRecorder = function(param) {
|
|
2967
2693
|
var isStopOnSilence = param.isStopOnSilence, onStart = param.onStart, onStop = param.onStop;
|
|
2968
|
-
var
|
|
2969
|
-
var
|
|
2970
|
-
var
|
|
2971
|
-
var
|
|
2694
|
+
var _useState3 = _sliced_to_array(useState3(null), 2), silenceStart = _useState3[0], setSilenceStart = _useState3[1];
|
|
2695
|
+
var _useState31 = _sliced_to_array(useState3(null), 2), noiseStart = _useState31[0], setNoiseStart = _useState31[1];
|
|
2696
|
+
var _useState32 = _sliced_to_array(useState3(null), 2), mediaStream = _useState32[0], setMediaStream = _useState32[1];
|
|
2697
|
+
var _useState33 = _sliced_to_array(useState3("idle"), 2), status = _useState33[0], setStatus = _useState33[1];
|
|
2972
2698
|
var startAudioPlayer = useAudioPlayer();
|
|
2973
2699
|
var endAudioPlayer = useAudioPlayer();
|
|
2974
|
-
var
|
|
2975
|
-
|
|
2700
|
+
var _useState34 = _sliced_to_array(useState3(false), 2), isLoaded = _useState34[0], setIsLoaded = _useState34[1];
|
|
2701
|
+
useEffect4(function() {
|
|
2976
2702
|
if (isLoaded) return;
|
|
2977
2703
|
setIsLoaded(true);
|
|
2978
2704
|
}, [
|
|
@@ -3030,9 +2756,9 @@ var useRecorder = function(param) {
|
|
|
3030
2756
|
setNoiseStart(null);
|
|
3031
2757
|
}
|
|
3032
2758
|
});
|
|
3033
|
-
var
|
|
2759
|
+
var _useState35 = _sliced_to_array(useState3(null), 2), audioEngine = _useState35[0], setAudioEngine = _useState35[1];
|
|
3034
2760
|
var isInited = useRef4(false);
|
|
3035
|
-
|
|
2761
|
+
useEffect4(function() {
|
|
3036
2762
|
if (!mediaStream) return;
|
|
3037
2763
|
if (isInited.current) return;
|
|
3038
2764
|
isInited.current = true;
|
|
@@ -3045,7 +2771,7 @@ var useRecorder = function(param) {
|
|
|
3045
2771
|
isInited,
|
|
3046
2772
|
mediaStream
|
|
3047
2773
|
]);
|
|
3048
|
-
var visualizationAnalyser =
|
|
2774
|
+
var visualizationAnalyser = useMemo11(function() {
|
|
3049
2775
|
if (!audioEngine) return null;
|
|
3050
2776
|
var result = audioEngine.audioContext.createAnalyser();
|
|
3051
2777
|
audioEngine.source.connect(result);
|
|
@@ -3053,7 +2779,7 @@ var useRecorder = function(param) {
|
|
|
3053
2779
|
}, [
|
|
3054
2780
|
audioEngine
|
|
3055
2781
|
]);
|
|
3056
|
-
var silenceAnalyser =
|
|
2782
|
+
var silenceAnalyser = useMemo11(function() {
|
|
3057
2783
|
if (!audioEngine) return null;
|
|
3058
2784
|
var result = audioEngine.audioContext.createAnalyser();
|
|
3059
2785
|
result.minDecibels = -45;
|
|
@@ -3070,12 +2796,12 @@ var useRecorder = function(param) {
|
|
|
3070
2796
|
return f === 0;
|
|
3071
2797
|
});
|
|
3072
2798
|
setSilenceStart(function(silenceStart2) {
|
|
3073
|
-
if (isSilent) return silenceStart2 ||
|
|
2799
|
+
if (isSilent) return silenceStart2 || dayjs2();
|
|
3074
2800
|
return null;
|
|
3075
2801
|
});
|
|
3076
2802
|
setNoiseStart(function(noiseStart2) {
|
|
3077
2803
|
if (isSilent) return noiseStart2;
|
|
3078
|
-
return noiseStart2 ||
|
|
2804
|
+
return noiseStart2 || dayjs2();
|
|
3079
2805
|
});
|
|
3080
2806
|
requestAnimationFrame(function() {
|
|
3081
2807
|
return handleSilence();
|
|
@@ -3085,7 +2811,7 @@ var useRecorder = function(param) {
|
|
|
3085
2811
|
setNoiseStart,
|
|
3086
2812
|
setSilenceStart
|
|
3087
2813
|
]);
|
|
3088
|
-
|
|
2814
|
+
useEffect4(function() {
|
|
3089
2815
|
if (!isStopOnSilence) return;
|
|
3090
2816
|
requestAnimationFrame(function() {
|
|
3091
2817
|
return handleSilence();
|
|
@@ -3094,12 +2820,12 @@ var useRecorder = function(param) {
|
|
|
3094
2820
|
handleSilence,
|
|
3095
2821
|
isStopOnSilence
|
|
3096
2822
|
]);
|
|
3097
|
-
|
|
2823
|
+
useInterval(function() {
|
|
3098
2824
|
if (!isStopOnSilence) return;
|
|
3099
2825
|
if (status !== "recording") return;
|
|
3100
2826
|
if (!silenceStart) return;
|
|
3101
2827
|
if (!noiseStart) return;
|
|
3102
|
-
if (!silenceStart.isBefore(
|
|
2828
|
+
if (!silenceStart.isBefore(dayjs2().subtract(1, "second"))) return;
|
|
3103
2829
|
audioCaptureProps.stop();
|
|
3104
2830
|
}, 100);
|
|
3105
2831
|
return _object_spread_props(_object_spread({}, audioCaptureProps), {
|
|
@@ -3108,7 +2834,7 @@ var useRecorder = function(param) {
|
|
|
3108
2834
|
});
|
|
3109
2835
|
};
|
|
3110
2836
|
// src/hooks/audioThreads/useMessageAudio/index.ts
|
|
3111
|
-
import { useMemo as
|
|
2837
|
+
import { useMemo as useMemo12, useRef as useRef5, useState as useState4, useEffect as useEffect5 } from "react";
|
|
3112
2838
|
import { Howler } from "howler";
|
|
3113
2839
|
import { useAudioPlayer as useAudioPlayer2 } from "react-use-audio-player";
|
|
3114
2840
|
// src/hooks/audioThreads/useMessageAudio/lib/input.ts
|
|
@@ -3134,11 +2860,11 @@ var isHtmlAudioSupported = !unsupportedNames.includes(((_detect = detect()) ===
|
|
|
3134
2860
|
// src/hooks/audioThreads/useMessageAudio/index.ts
|
|
3135
2861
|
var useMessageAudio = function(param) {
|
|
3136
2862
|
var onEnd = param.onEnd;
|
|
3137
|
-
var
|
|
2863
|
+
var _useState4 = _sliced_to_array(useState4([]), 2), playedMessages = _useState4[0], setPlayedMessages = _useState4[1];
|
|
3138
2864
|
var audioPlayer = useAudioPlayer2();
|
|
3139
2865
|
var superinterfaceContext = useSuperinterfaceContext();
|
|
3140
2866
|
var latestMessageProps = useLatestMessage();
|
|
3141
|
-
|
|
2867
|
+
useEffect5(function() {
|
|
3142
2868
|
if (audioPlayer.playing) return;
|
|
3143
2869
|
if (!latestMessageProps.latestMessage) return;
|
|
3144
2870
|
if (latestMessageProps.latestMessage.role !== "assistant") return;
|
|
@@ -3178,8 +2904,8 @@ var useMessageAudio = function(param) {
|
|
|
3178
2904
|
onEnd
|
|
3179
2905
|
]);
|
|
3180
2906
|
var isInited = useRef5(false);
|
|
3181
|
-
var
|
|
3182
|
-
|
|
2907
|
+
var _useState41 = _sliced_to_array(useState4(null), 2), audioEngine = _useState41[0], setAudioEngine = _useState41[1];
|
|
2908
|
+
useEffect5(function() {
|
|
3183
2909
|
if (!audioPlayer.playing) return;
|
|
3184
2910
|
if (isInited.current) return;
|
|
3185
2911
|
isInited.current = true;
|
|
@@ -3200,7 +2926,7 @@ var useMessageAudio = function(param) {
|
|
|
3200
2926
|
audioPlayer,
|
|
3201
2927
|
isInited
|
|
3202
2928
|
]);
|
|
3203
|
-
var visualizationAnalyser =
|
|
2929
|
+
var visualizationAnalyser = useMemo12(function() {
|
|
3204
2930
|
if (!audioEngine) return null;
|
|
3205
2931
|
var result = audioEngine.audioContext.createAnalyser();
|
|
3206
2932
|
audioEngine.source.connect(audioEngine.audioContext.destination);
|
|
@@ -3214,10 +2940,9 @@ var useMessageAudio = function(param) {
|
|
|
3214
2940
|
});
|
|
3215
2941
|
};
|
|
3216
2942
|
// src/components/threads/AudioThread/Root/index.tsx
|
|
3217
|
-
import { jsx as
|
|
2943
|
+
import { jsx as jsx55 } from "react/jsx-runtime";
|
|
3218
2944
|
var Root8 = function(param) {
|
|
3219
2945
|
var children = param.children;
|
|
3220
|
-
useLifecycle();
|
|
3221
2946
|
var createMessageProps = useCreateMessage();
|
|
3222
2947
|
var recorderProps = useRecorder({
|
|
3223
2948
|
isStopOnSilence: true,
|
|
@@ -3274,13 +2999,13 @@ var Root8 = function(param) {
|
|
|
3274
2999
|
createMessageProps: createMessageProps,
|
|
3275
3000
|
messageAudioProps: messageAudioProps
|
|
3276
3001
|
}).status;
|
|
3277
|
-
return /* @__PURE__ */
|
|
3002
|
+
return /* @__PURE__ */ jsx55(AudioThreadContext.Provider, {
|
|
3278
3003
|
value: {
|
|
3279
3004
|
status: status,
|
|
3280
3005
|
recorderProps: recorderProps,
|
|
3281
3006
|
messageAudioProps: messageAudioProps
|
|
3282
3007
|
},
|
|
3283
|
-
children: /* @__PURE__ */
|
|
3008
|
+
children: /* @__PURE__ */ jsx55(Flex20, {
|
|
3284
3009
|
direction: "column",
|
|
3285
3010
|
flexGrow: "1",
|
|
3286
3011
|
p: "9",
|
|
@@ -3291,20 +3016,20 @@ var Root8 = function(param) {
|
|
|
3291
3016
|
// src/components/threads/AudioThread/Visualization/index.tsx
|
|
3292
3017
|
import { Flex as Flex22 } from "@radix-ui/themes";
|
|
3293
3018
|
// src/hooks/threads/useAudioThreadContext/index.ts
|
|
3294
|
-
import { useContext as
|
|
3019
|
+
import { useContext as useContext12 } from "react";
|
|
3295
3020
|
var useAudioThreadContext = function() {
|
|
3296
|
-
return
|
|
3021
|
+
return useContext12(AudioThreadContext);
|
|
3297
3022
|
};
|
|
3298
3023
|
// src/components/threads/AudioThread/BarsVisualizer/index.tsx
|
|
3299
|
-
import
|
|
3024
|
+
import _8 from "lodash";
|
|
3300
3025
|
import { Flex as Flex21, Grid } from "@radix-ui/themes";
|
|
3301
|
-
import { useState as
|
|
3026
|
+
import { useState as useState5, useEffect as useEffect6, useCallback as useCallback4 } from "react";
|
|
3302
3027
|
import { cluster } from "radash";
|
|
3303
|
-
import { jsx as
|
|
3028
|
+
import { jsx as jsx56 } from "react/jsx-runtime";
|
|
3304
3029
|
var barCount = 4;
|
|
3305
3030
|
var BarsVisualizer = function(param) {
|
|
3306
3031
|
var visualizationAnalyser = param.visualizationAnalyser, color = param.color, height = param.height, barWidth = param.barWidth;
|
|
3307
|
-
var
|
|
3032
|
+
var _useState5 = _sliced_to_array(useState5(null), 2), cachedEmptyVisualizer = _useState5[0], setCachedEmptyVisualizer = _useState5[1];
|
|
3308
3033
|
var getEmptyVisualizer = useCallback4(function() {
|
|
3309
3034
|
var result = new AudioContext().createAnalyser();
|
|
3310
3035
|
setCachedEmptyVisualizer(result);
|
|
@@ -3312,14 +3037,14 @@ var BarsVisualizer = function(param) {
|
|
|
3312
3037
|
}, [
|
|
3313
3038
|
cachedEmptyVisualizer
|
|
3314
3039
|
]);
|
|
3315
|
-
var
|
|
3040
|
+
var _useState51 = _sliced_to_array(useState5([]), 2), barHeights = _useState51[0], setBarHeights = _useState51[1];
|
|
3316
3041
|
var draw = useCallback4(function(param) {
|
|
3317
3042
|
var visualizationAnalyser2 = param.visualizationAnalyser;
|
|
3318
3043
|
var frequencyData = new Uint8Array(visualizationAnalyser2.frequencyBinCount / 15);
|
|
3319
3044
|
visualizationAnalyser2.getByteFrequencyData(frequencyData);
|
|
3320
3045
|
var clusteredFrequencyData = cluster(frequencyData, frequencyData.length / barCount);
|
|
3321
3046
|
setBarHeights(clusteredFrequencyData.map(function(frequencyDataCluster) {
|
|
3322
|
-
return
|
|
3047
|
+
return _8.mean(frequencyDataCluster) / 255 * 100;
|
|
3323
3048
|
}));
|
|
3324
3049
|
requestAnimationFrame(function() {
|
|
3325
3050
|
return draw({
|
|
@@ -3327,7 +3052,7 @@ var BarsVisualizer = function(param) {
|
|
|
3327
3052
|
});
|
|
3328
3053
|
});
|
|
3329
3054
|
}, []);
|
|
3330
|
-
|
|
3055
|
+
useEffect6(function() {
|
|
3331
3056
|
draw({
|
|
3332
3057
|
visualizationAnalyser: visualizationAnalyser || cachedEmptyVisualizer || getEmptyVisualizer()
|
|
3333
3058
|
});
|
|
@@ -3337,7 +3062,7 @@ var BarsVisualizer = function(param) {
|
|
|
3337
3062
|
cachedEmptyVisualizer,
|
|
3338
3063
|
getEmptyVisualizer
|
|
3339
3064
|
]);
|
|
3340
|
-
return /* @__PURE__ */
|
|
3065
|
+
return /* @__PURE__ */ jsx56(Grid, {
|
|
3341
3066
|
columns: "".concat(barCount),
|
|
3342
3067
|
gap: "1",
|
|
3343
3068
|
width: "auto",
|
|
@@ -3346,12 +3071,12 @@ var BarsVisualizer = function(param) {
|
|
|
3346
3071
|
gridTemplateColumns: "repeat(4, minmax(0, 1fr))"
|
|
3347
3072
|
},
|
|
3348
3073
|
children: barHeights.map(function(barHeight, index) {
|
|
3349
|
-
return /* @__PURE__ */
|
|
3074
|
+
return /* @__PURE__ */ jsx56(Flex21, {
|
|
3350
3075
|
direction: "column",
|
|
3351
3076
|
align: "center",
|
|
3352
3077
|
justify: "center",
|
|
3353
3078
|
height: height,
|
|
3354
|
-
children: /* @__PURE__ */
|
|
3079
|
+
children: /* @__PURE__ */ jsx56(Flex21, {
|
|
3355
3080
|
minHeight: "50%",
|
|
3356
3081
|
maxHeight: "100%",
|
|
3357
3082
|
height: "".concat(barHeight + 20, "%"),
|
|
@@ -3366,16 +3091,16 @@ var BarsVisualizer = function(param) {
|
|
|
3366
3091
|
});
|
|
3367
3092
|
};
|
|
3368
3093
|
// src/components/threads/AudioThread/Visualization/index.tsx
|
|
3369
|
-
import { jsx as
|
|
3094
|
+
import { jsx as jsx57 } from "react/jsx-runtime";
|
|
3370
3095
|
var Visualization = function() {
|
|
3371
3096
|
var audioThreadContext = useAudioThreadContext();
|
|
3372
|
-
return /* @__PURE__ */
|
|
3097
|
+
return /* @__PURE__ */ jsx57(Flex22, {
|
|
3373
3098
|
direction: "column",
|
|
3374
3099
|
align: "center",
|
|
3375
3100
|
justify: "center",
|
|
3376
3101
|
mb: "3",
|
|
3377
3102
|
flexGrow: "1",
|
|
3378
|
-
children: /* @__PURE__ */
|
|
3103
|
+
children: /* @__PURE__ */ jsx57(Flex22, {
|
|
3379
3104
|
align: "center",
|
|
3380
3105
|
justify: "center",
|
|
3381
3106
|
height: "200px",
|
|
@@ -3384,7 +3109,7 @@ var Visualization = function() {
|
|
|
3384
3109
|
backgroundColor: "var(--".concat(audioThreadContext.status === "playing" ? "mint" : "gray", "-4)"),
|
|
3385
3110
|
borderRadius: "9999px"
|
|
3386
3111
|
},
|
|
3387
|
-
children: /* @__PURE__ */
|
|
3112
|
+
children: /* @__PURE__ */ jsx57(BarsVisualizer, {
|
|
3388
3113
|
visualizationAnalyser: audioThreadContext.messageAudioProps.visualizationAnalyser,
|
|
3389
3114
|
color: audioThreadContext.status === "playing" ? "mint" : "gray",
|
|
3390
3115
|
height: "40px",
|
|
@@ -3399,25 +3124,25 @@ import { Flex as Flex24 } from "@radix-ui/themes";
|
|
|
3399
3124
|
// src/components/threads/AudioThread/Form/ActionButton/index.tsx
|
|
3400
3125
|
import { Flex as Flex23, IconButton as IconButton4 } from "@radix-ui/themes";
|
|
3401
3126
|
import { PauseIcon, ArrowUpIcon as ArrowUpIcon2, ResumeIcon } from "@radix-ui/react-icons";
|
|
3402
|
-
import { jsx as
|
|
3127
|
+
import { jsx as jsx58, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
3403
3128
|
var ActionButton = function() {
|
|
3404
3129
|
var audioThreadContext = useAudioThreadContext();
|
|
3405
3130
|
if (audioThreadContext.status === "recording") {
|
|
3406
|
-
return /* @__PURE__ */
|
|
3131
|
+
return /* @__PURE__ */ jsxs18(Flex23, {
|
|
3407
3132
|
align: "center",
|
|
3408
3133
|
children: [
|
|
3409
|
-
/* @__PURE__ */
|
|
3134
|
+
/* @__PURE__ */ jsx58(Flex23, {
|
|
3410
3135
|
mr: "3",
|
|
3411
3136
|
ml: "-7",
|
|
3412
|
-
children: /* @__PURE__ */
|
|
3137
|
+
children: /* @__PURE__ */ jsx58(IconButton4, {
|
|
3413
3138
|
onClick: audioThreadContext.recorderProps.pause,
|
|
3414
3139
|
color: "gray",
|
|
3415
3140
|
radius: "full",
|
|
3416
3141
|
size: "1",
|
|
3417
|
-
children: /* @__PURE__ */
|
|
3142
|
+
children: /* @__PURE__ */ jsx58(PauseIcon, {})
|
|
3418
3143
|
})
|
|
3419
3144
|
}),
|
|
3420
|
-
/* @__PURE__ */
|
|
3145
|
+
/* @__PURE__ */ jsx58(IconButton4, {
|
|
3421
3146
|
onClick: audioThreadContext.recorderProps.stop,
|
|
3422
3147
|
color: "gray",
|
|
3423
3148
|
highContrast: true,
|
|
@@ -3426,13 +3151,13 @@ var ActionButton = function() {
|
|
|
3426
3151
|
style: {
|
|
3427
3152
|
border: "2px solid var(--gray-8)"
|
|
3428
3153
|
},
|
|
3429
|
-
children: /* @__PURE__ */
|
|
3154
|
+
children: /* @__PURE__ */ jsx58(ArrowUpIcon2, {})
|
|
3430
3155
|
})
|
|
3431
3156
|
]
|
|
3432
3157
|
});
|
|
3433
3158
|
}
|
|
3434
3159
|
if (audioThreadContext.status === "recorderPaused") {
|
|
3435
|
-
return /* @__PURE__ */
|
|
3160
|
+
return /* @__PURE__ */ jsx58(IconButton4, {
|
|
3436
3161
|
onClick: audioThreadContext.recorderProps.resume,
|
|
3437
3162
|
color: "red",
|
|
3438
3163
|
radius: "full",
|
|
@@ -3440,11 +3165,11 @@ var ActionButton = function() {
|
|
|
3440
3165
|
style: {
|
|
3441
3166
|
border: "2px solid var(--gray-8)"
|
|
3442
3167
|
},
|
|
3443
|
-
children: /* @__PURE__ */
|
|
3168
|
+
children: /* @__PURE__ */ jsx58(ResumeIcon, {})
|
|
3444
3169
|
});
|
|
3445
3170
|
}
|
|
3446
3171
|
if (audioThreadContext.status === "idle") {
|
|
3447
|
-
return /* @__PURE__ */
|
|
3172
|
+
return /* @__PURE__ */ jsx58(IconButton4, {
|
|
3448
3173
|
onClick: function() {
|
|
3449
3174
|
return audioThreadContext.recorderProps.start();
|
|
3450
3175
|
},
|
|
@@ -3457,7 +3182,7 @@ var ActionButton = function() {
|
|
|
3457
3182
|
});
|
|
3458
3183
|
}
|
|
3459
3184
|
if (audioThreadContext.status === "playing") {
|
|
3460
|
-
return /* @__PURE__ */
|
|
3185
|
+
return /* @__PURE__ */ jsx58(IconButton4, {
|
|
3461
3186
|
onClick: function() {
|
|
3462
3187
|
return audioThreadContext.messageAudioProps.pause();
|
|
3463
3188
|
},
|
|
@@ -3467,11 +3192,11 @@ var ActionButton = function() {
|
|
|
3467
3192
|
style: {
|
|
3468
3193
|
border: "2px solid var(--gray-8)"
|
|
3469
3194
|
},
|
|
3470
|
-
children: /* @__PURE__ */
|
|
3195
|
+
children: /* @__PURE__ */ jsx58(PauseIcon, {})
|
|
3471
3196
|
});
|
|
3472
3197
|
}
|
|
3473
3198
|
if (audioThreadContext.status === "playerPaused") {
|
|
3474
|
-
return /* @__PURE__ */
|
|
3199
|
+
return /* @__PURE__ */ jsx58(IconButton4, {
|
|
3475
3200
|
onClick: function() {
|
|
3476
3201
|
return audioThreadContext.messageAudioProps.play();
|
|
3477
3202
|
},
|
|
@@ -3481,10 +3206,10 @@ var ActionButton = function() {
|
|
|
3481
3206
|
style: {
|
|
3482
3207
|
border: "2px solid var(--gray-8)"
|
|
3483
3208
|
},
|
|
3484
|
-
children: /* @__PURE__ */
|
|
3209
|
+
children: /* @__PURE__ */ jsx58(ResumeIcon, {})
|
|
3485
3210
|
});
|
|
3486
3211
|
}
|
|
3487
|
-
return /* @__PURE__ */
|
|
3212
|
+
return /* @__PURE__ */ jsx58(IconButton4, {
|
|
3488
3213
|
size: "4",
|
|
3489
3214
|
color: "red",
|
|
3490
3215
|
radius: "full",
|
|
@@ -3495,35 +3220,35 @@ var ActionButton = function() {
|
|
|
3495
3220
|
});
|
|
3496
3221
|
};
|
|
3497
3222
|
// src/components/threads/AudioThread/Form/index.tsx
|
|
3498
|
-
import { jsx as
|
|
3223
|
+
import { jsx as jsx59, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
3499
3224
|
var Form = function() {
|
|
3500
3225
|
var audioThreadContext = useAudioThreadContext();
|
|
3501
|
-
return /* @__PURE__ */
|
|
3226
|
+
return /* @__PURE__ */ jsxs19(Flex24, {
|
|
3502
3227
|
direction: "column",
|
|
3503
3228
|
align: "center",
|
|
3504
3229
|
children: [
|
|
3505
|
-
/* @__PURE__ */
|
|
3230
|
+
/* @__PURE__ */ jsxs19(Flex24, {
|
|
3506
3231
|
pb: "3",
|
|
3507
3232
|
align: "center",
|
|
3508
3233
|
children: [
|
|
3509
|
-
/* @__PURE__ */
|
|
3234
|
+
/* @__PURE__ */ jsx59(Flex24, {
|
|
3510
3235
|
ml: "-5",
|
|
3511
3236
|
mr: "2",
|
|
3512
3237
|
align: "center",
|
|
3513
|
-
children: /* @__PURE__ */
|
|
3238
|
+
children: /* @__PURE__ */ jsx59(SpeakerModerateIcon, {
|
|
3514
3239
|
style: {
|
|
3515
3240
|
color: "var(--".concat(audioThreadContext.status === "recording" ? "mint" : "gray", "-12)")
|
|
3516
3241
|
}
|
|
3517
3242
|
})
|
|
3518
3243
|
}),
|
|
3519
|
-
/* @__PURE__ */
|
|
3244
|
+
/* @__PURE__ */ jsx59(Flex24, {
|
|
3520
3245
|
px: "2",
|
|
3521
3246
|
py: "1",
|
|
3522
3247
|
style: {
|
|
3523
3248
|
backgroundColor: "var(--".concat(audioThreadContext.status === "recording" ? "mint" : "gray", "-4)"),
|
|
3524
3249
|
borderRadius: "var(--radius-6)"
|
|
3525
3250
|
},
|
|
3526
|
-
children: /* @__PURE__ */
|
|
3251
|
+
children: /* @__PURE__ */ jsx59(BarsVisualizer, {
|
|
3527
3252
|
visualizationAnalyser: audioThreadContext.recorderProps.visualizationAnalyser,
|
|
3528
3253
|
color: audioThreadContext.status === "recording" ? "mint" : "gray",
|
|
3529
3254
|
height: "20px",
|
|
@@ -3532,17 +3257,17 @@ var Form = function() {
|
|
|
3532
3257
|
})
|
|
3533
3258
|
]
|
|
3534
3259
|
}),
|
|
3535
|
-
/* @__PURE__ */
|
|
3260
|
+
/* @__PURE__ */ jsx59(ActionButton, {})
|
|
3536
3261
|
]
|
|
3537
3262
|
});
|
|
3538
3263
|
};
|
|
3539
3264
|
// src/components/threads/AudioThread/index.tsx
|
|
3540
|
-
import { jsx as
|
|
3265
|
+
import { jsx as jsx60, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
3541
3266
|
var AudioThread = function(props) {
|
|
3542
|
-
return /* @__PURE__ */
|
|
3267
|
+
return /* @__PURE__ */ jsxs20(Root8, _object_spread_props(_object_spread({}, props), {
|
|
3543
3268
|
children: [
|
|
3544
|
-
/* @__PURE__ */
|
|
3545
|
-
/* @__PURE__ */
|
|
3269
|
+
/* @__PURE__ */ jsx60(Visualization, {}),
|
|
3270
|
+
/* @__PURE__ */ jsx60(Form, {})
|
|
3546
3271
|
]
|
|
3547
3272
|
}));
|
|
3548
3273
|
};
|
|
@@ -3550,15 +3275,15 @@ AudioThread.Root = Root8;
|
|
|
3550
3275
|
AudioThread.Visualization = Visualization;
|
|
3551
3276
|
AudioThread.Form = Form;
|
|
3552
3277
|
// src/components/threads/AudioThreadDialog/index.tsx
|
|
3553
|
-
import { jsx as
|
|
3278
|
+
import { jsx as jsx61, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
3554
3279
|
var AudioThreadDialog = function() {
|
|
3555
|
-
return /* @__PURE__ */
|
|
3280
|
+
return /* @__PURE__ */ jsxs21(Root6, {
|
|
3556
3281
|
children: [
|
|
3557
|
-
/* @__PURE__ */
|
|
3558
|
-
children: /* @__PURE__ */
|
|
3282
|
+
/* @__PURE__ */ jsx61(Content4.Root, {
|
|
3283
|
+
children: /* @__PURE__ */ jsx61(AudioThread, {})
|
|
3559
3284
|
}),
|
|
3560
|
-
/* @__PURE__ */
|
|
3561
|
-
children: /* @__PURE__ */
|
|
3285
|
+
/* @__PURE__ */ jsx61(Trigger, {
|
|
3286
|
+
children: /* @__PURE__ */ jsx61(Button2, {})
|
|
3562
3287
|
})
|
|
3563
3288
|
]
|
|
3564
3289
|
});
|
|
@@ -3568,20 +3293,20 @@ AudioThreadDialog.Trigger = Trigger;
|
|
|
3568
3293
|
AudioThreadDialog.Button = Button2;
|
|
3569
3294
|
AudioThreadDialog.Content = Content4;
|
|
3570
3295
|
// src/components/suggestions/Suggestions/index.tsx
|
|
3571
|
-
import { useMemo as useMemo16 } from "react";
|
|
3572
|
-
// src/components/suggestions/Suggestions/Content.tsx
|
|
3573
3296
|
import { useMemo as useMemo15 } from "react";
|
|
3297
|
+
// src/components/suggestions/Suggestions/Content.tsx
|
|
3298
|
+
import { useMemo as useMemo14 } from "react";
|
|
3574
3299
|
import { isEmpty as isEmpty2 } from "radash";
|
|
3575
3300
|
import { onlyText } from "react-children-utilities";
|
|
3576
3301
|
import { Flex as Flex25 } from "@radix-ui/themes";
|
|
3577
3302
|
// src/components/suggestions/Suggestions/Item.tsx
|
|
3578
3303
|
import { ArrowUpIcon as ArrowUpIcon3 } from "@radix-ui/react-icons";
|
|
3579
3304
|
import { Text as Text7, Button as Button3, Spinner as Spinner2 } from "@radix-ui/themes";
|
|
3580
|
-
import { jsx as
|
|
3305
|
+
import { jsx as jsx62, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
3581
3306
|
var Item = function(param) {
|
|
3582
3307
|
var suggestion = param.suggestion, isDisabled = param.isDisabled;
|
|
3583
3308
|
var _useCreateMessage = useCreateMessage(), createMessage = _useCreateMessage.createMessage, isPending = _useCreateMessage.isPending;
|
|
3584
|
-
return /* @__PURE__ */
|
|
3309
|
+
return /* @__PURE__ */ jsx62(Content5, {
|
|
3585
3310
|
onClick: function() {
|
|
3586
3311
|
createMessage({
|
|
3587
3312
|
// @ts-ignore-next-line
|
|
@@ -3595,7 +3320,7 @@ var Item = function(param) {
|
|
|
3595
3320
|
};
|
|
3596
3321
|
var Content5 = function(param) {
|
|
3597
3322
|
var onClick = param.onClick, isDisabled = param.isDisabled, isPending = param.isPending, children = param.children;
|
|
3598
|
-
return /* @__PURE__ */
|
|
3323
|
+
return /* @__PURE__ */ jsxs22(Button3, {
|
|
3599
3324
|
variant: "soft",
|
|
3600
3325
|
onClick: onClick,
|
|
3601
3326
|
disabled: isDisabled,
|
|
@@ -3605,14 +3330,14 @@ var Content5 = function(param) {
|
|
|
3605
3330
|
flexShrink: 1
|
|
3606
3331
|
},
|
|
3607
3332
|
children: [
|
|
3608
|
-
/* @__PURE__ */
|
|
3333
|
+
/* @__PURE__ */ jsx62(Text7, {
|
|
3609
3334
|
size: "1",
|
|
3610
3335
|
weight: "regular",
|
|
3611
3336
|
children: children
|
|
3612
3337
|
}),
|
|
3613
|
-
/* @__PURE__ */
|
|
3338
|
+
/* @__PURE__ */ jsx62(Spinner2, {
|
|
3614
3339
|
loading: isPending,
|
|
3615
|
-
children: /* @__PURE__ */
|
|
3340
|
+
children: /* @__PURE__ */ jsx62(ArrowUpIcon3, {
|
|
3616
3341
|
style: {
|
|
3617
3342
|
flexShrink: 0
|
|
3618
3343
|
}
|
|
@@ -3623,11 +3348,11 @@ var Content5 = function(param) {
|
|
|
3623
3348
|
};
|
|
3624
3349
|
Item.Content = Content5;
|
|
3625
3350
|
// src/components/suggestions/Suggestions/Content.tsx
|
|
3626
|
-
import { jsx as
|
|
3351
|
+
import { jsx as jsx63 } from "react/jsx-runtime";
|
|
3627
3352
|
var Content6 = function(param) {
|
|
3628
3353
|
var children = param.children;
|
|
3629
|
-
var
|
|
3630
|
-
var suggestions =
|
|
3354
|
+
var isMutatingMessage = useIsMutatingMessage();
|
|
3355
|
+
var suggestions = useMemo14(function() {
|
|
3631
3356
|
return onlyText(children).split(/\r?\n/).filter(function(c) {
|
|
3632
3357
|
return !isEmpty2(c);
|
|
3633
3358
|
}).map(function(c) {
|
|
@@ -3636,30 +3361,25 @@ var Content6 = function(param) {
|
|
|
3636
3361
|
}, [
|
|
3637
3362
|
children
|
|
3638
3363
|
]);
|
|
3639
|
-
var isDisabled = useMemo15(function() {
|
|
3640
|
-
return isRunActiveProps.isRunActive;
|
|
3641
|
-
}, [
|
|
3642
|
-
isRunActiveProps
|
|
3643
|
-
]);
|
|
3644
3364
|
if (isEmpty2(suggestions)) return null;
|
|
3645
|
-
return /* @__PURE__ */
|
|
3365
|
+
return /* @__PURE__ */ jsx63(Flex25, {
|
|
3646
3366
|
gap: "2",
|
|
3647
3367
|
py: "2",
|
|
3648
3368
|
wrap: "wrap",
|
|
3649
3369
|
children: suggestions.map(function(suggestion) {
|
|
3650
|
-
return /* @__PURE__ */
|
|
3370
|
+
return /* @__PURE__ */ jsx63(Item, {
|
|
3651
3371
|
suggestion: suggestion,
|
|
3652
|
-
isDisabled:
|
|
3372
|
+
isDisabled: isMutatingMessage
|
|
3653
3373
|
}, suggestion);
|
|
3654
3374
|
})
|
|
3655
3375
|
});
|
|
3656
3376
|
};
|
|
3657
3377
|
// src/components/suggestions/Suggestions/index.tsx
|
|
3658
|
-
import { jsx as
|
|
3378
|
+
import { jsx as jsx64 } from "react/jsx-runtime";
|
|
3659
3379
|
var Suggestions = function(param) {
|
|
3660
3380
|
var children = param.children;
|
|
3661
3381
|
var latestMessageProps = useLatestMessage();
|
|
3662
|
-
var isDisabled =
|
|
3382
|
+
var isDisabled = useMemo15(function() {
|
|
3663
3383
|
var // @ts-ignore-next-line
|
|
3664
3384
|
_latestMessageProps_latestMessage_metadata, _latestMessageProps_latestMessage;
|
|
3665
3385
|
return (_latestMessageProps_latestMessage = latestMessageProps.latestMessage) === null || _latestMessageProps_latestMessage === void 0 ? void 0 : (_latestMessageProps_latestMessage_metadata = _latestMessageProps_latestMessage.metadata) === null || _latestMessageProps_latestMessage_metadata === void 0 ? void 0 : _latestMessageProps_latestMessage_metadata.isBlocking;
|
|
@@ -3668,29 +3388,29 @@ var Suggestions = function(param) {
|
|
|
3668
3388
|
]);
|
|
3669
3389
|
if (latestMessageProps.isLoading) return null;
|
|
3670
3390
|
if (isDisabled) return null;
|
|
3671
|
-
return /* @__PURE__ */
|
|
3391
|
+
return /* @__PURE__ */ jsx64(Content6, {
|
|
3672
3392
|
children: children
|
|
3673
3393
|
});
|
|
3674
3394
|
};
|
|
3675
3395
|
Suggestions.Item = Item;
|
|
3676
3396
|
// src/components/markdown/MarkdownProvider/index.tsx
|
|
3677
|
-
import { useMemo as
|
|
3678
|
-
import { jsx as
|
|
3397
|
+
import { useMemo as useMemo16 } from "react";
|
|
3398
|
+
import { jsx as jsx65 } from "react/jsx-runtime";
|
|
3679
3399
|
var MarkdownProvider = function(_param) {
|
|
3680
3400
|
var children = _param.children, rest = _object_without_properties(_param, [
|
|
3681
3401
|
"children"
|
|
3682
3402
|
]);
|
|
3683
3403
|
var prevMarkdownContext = useMarkdownContext();
|
|
3684
|
-
var value =
|
|
3404
|
+
var value = useMemo16(function() {
|
|
3685
3405
|
return merge(prevMarkdownContext, rest);
|
|
3686
3406
|
}, [
|
|
3687
3407
|
rest,
|
|
3688
3408
|
prevMarkdownContext
|
|
3689
3409
|
]);
|
|
3690
|
-
return /* @__PURE__ */
|
|
3410
|
+
return /* @__PURE__ */ jsx65(MarkdownContext.Provider, {
|
|
3691
3411
|
value: value,
|
|
3692
3412
|
children: children
|
|
3693
3413
|
});
|
|
3694
3414
|
};
|
|
3695
|
-
export { AssistantAvatarContext, AssistantNameContext, AudioThread, AudioThreadDialog, FunctionBase, FunctionComponentsContext, MarkdownContext, MarkdownProvider, Suggestions, SuperinterfaceProvider, Thread, ThreadDialog, ThreadDialogContext, useCreateMessage,
|
|
3415
|
+
export { AssistantAvatarContext, AssistantNameContext, AudioThread, AudioThreadDialog, FunctionBase, FunctionComponentsContext, MarkdownContext, MarkdownProvider, Suggestions, SuperinterfaceProvider, Thread, ThreadDialog, ThreadDialogContext, useCreateMessage, useLatestMessage, useMarkdownContext, useMessageContext, useMessages, useSuperinterfaceContext, useSuperinterfaceContext as useThreadContext };
|
|
3696
3416
|
//# sourceMappingURL=index.js.map
|