@yourgpt/copilot-sdk 1.2.7 → 1.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ui/index.cjs +104 -197
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.d.cts +2 -3
- package/dist/ui/index.d.ts +2 -3
- package/dist/ui/index.js +62 -150
- package/dist/ui/index.js.map +1 -1
- package/package.json +3 -6
package/dist/ui/index.cjs
CHANGED
|
@@ -5,12 +5,9 @@ var chunkMTFU6EHR_cjs = require('../chunk-MTFU6EHR.cjs');
|
|
|
5
5
|
var clsx = require('clsx');
|
|
6
6
|
var tailwindMerge = require('tailwind-merge');
|
|
7
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var remarkBreaks = require('remark-breaks');
|
|
12
|
-
var remarkGfm = require('remark-gfm');
|
|
13
|
-
var shiki = require('shiki');
|
|
8
|
+
var React7 = require('react');
|
|
9
|
+
var streamdown = require('streamdown');
|
|
10
|
+
var code = require('@streamdown/code');
|
|
14
11
|
var reactSlot = require('@radix-ui/react-slot');
|
|
15
12
|
var classVarianceAuthority = require('class-variance-authority');
|
|
16
13
|
var useStickToBottom = require('use-stick-to-bottom');
|
|
@@ -19,8 +16,6 @@ var AvatarPrimitive = require('@radix-ui/react-avatar');
|
|
|
19
16
|
var HoverCardPrimitive = require('@radix-ui/react-hover-card');
|
|
20
17
|
var popover = require('@base-ui/react/popover');
|
|
21
18
|
|
|
22
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
23
|
-
|
|
24
19
|
function _interopNamespace(e) {
|
|
25
20
|
if (e && e.__esModule) return e;
|
|
26
21
|
var n = Object.create(null);
|
|
@@ -39,10 +34,7 @@ function _interopNamespace(e) {
|
|
|
39
34
|
return Object.freeze(n);
|
|
40
35
|
}
|
|
41
36
|
|
|
42
|
-
var
|
|
43
|
-
var ReactMarkdown__default = /*#__PURE__*/_interopDefault(ReactMarkdown);
|
|
44
|
-
var remarkBreaks__default = /*#__PURE__*/_interopDefault(remarkBreaks);
|
|
45
|
-
var remarkGfm__default = /*#__PURE__*/_interopDefault(remarkGfm);
|
|
37
|
+
var React7__namespace = /*#__PURE__*/_interopNamespace(React7);
|
|
46
38
|
var AvatarPrimitive__namespace = /*#__PURE__*/_interopNamespace(AvatarPrimitive);
|
|
47
39
|
var HoverCardPrimitive__namespace = /*#__PURE__*/_interopNamespace(HoverCardPrimitive);
|
|
48
40
|
|
|
@@ -444,6 +436,15 @@ function Loader({
|
|
|
444
436
|
return /* @__PURE__ */ jsxRuntime.jsx(CircularLoader, { size, className });
|
|
445
437
|
}
|
|
446
438
|
}
|
|
439
|
+
function MarkdownComponent({
|
|
440
|
+
children,
|
|
441
|
+
className,
|
|
442
|
+
isStreaming = false
|
|
443
|
+
}) {
|
|
444
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className, children: /* @__PURE__ */ jsxRuntime.jsx(streamdown.Streamdown, { plugins: { code: code.code }, isAnimating: isStreaming, children }) });
|
|
445
|
+
}
|
|
446
|
+
var Markdown = React7.memo(MarkdownComponent);
|
|
447
|
+
Markdown.displayName = "Markdown";
|
|
447
448
|
function CodeBlock({ children, className, ...props }) {
|
|
448
449
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
449
450
|
"div",
|
|
@@ -458,109 +459,6 @@ function CodeBlock({ children, className, ...props }) {
|
|
|
458
459
|
}
|
|
459
460
|
);
|
|
460
461
|
}
|
|
461
|
-
function CodeBlockCode({
|
|
462
|
-
code,
|
|
463
|
-
language = "tsx",
|
|
464
|
-
theme = "github-light",
|
|
465
|
-
className,
|
|
466
|
-
...props
|
|
467
|
-
}) {
|
|
468
|
-
const [highlightedHtml, setHighlightedHtml] = React8.useState(null);
|
|
469
|
-
React8.useEffect(() => {
|
|
470
|
-
async function highlight() {
|
|
471
|
-
if (!code) {
|
|
472
|
-
setHighlightedHtml("<pre><code></code></pre>");
|
|
473
|
-
return;
|
|
474
|
-
}
|
|
475
|
-
const html = await shiki.codeToHtml(code, { lang: language, theme });
|
|
476
|
-
setHighlightedHtml(html);
|
|
477
|
-
}
|
|
478
|
-
highlight();
|
|
479
|
-
}, [code, language, theme]);
|
|
480
|
-
const classNames = cn(
|
|
481
|
-
"w-full overflow-x-auto text-[13px] [&>pre]:px-4 [&>pre]:py-4",
|
|
482
|
-
className
|
|
483
|
-
);
|
|
484
|
-
return highlightedHtml ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
485
|
-
"div",
|
|
486
|
-
{
|
|
487
|
-
className: classNames,
|
|
488
|
-
dangerouslySetInnerHTML: { __html: highlightedHtml },
|
|
489
|
-
...props
|
|
490
|
-
}
|
|
491
|
-
) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: classNames, ...props, children: /* @__PURE__ */ jsxRuntime.jsx("pre", { children: /* @__PURE__ */ jsxRuntime.jsx("code", { children: code }) }) });
|
|
492
|
-
}
|
|
493
|
-
function parseMarkdownIntoBlocks(markdown) {
|
|
494
|
-
const tokens = marked.marked.lexer(markdown);
|
|
495
|
-
return tokens.map((token) => token.raw);
|
|
496
|
-
}
|
|
497
|
-
function extractLanguage(className) {
|
|
498
|
-
if (!className) return "plaintext";
|
|
499
|
-
const match = className.match(/language-(\w+)/);
|
|
500
|
-
return match ? match[1] : "plaintext";
|
|
501
|
-
}
|
|
502
|
-
var INITIAL_COMPONENTS = {
|
|
503
|
-
code: function CodeComponent({ className, children, ...props }) {
|
|
504
|
-
const isInline = !props.node?.position?.start.line || props.node?.position?.start.line === props.node?.position?.end.line;
|
|
505
|
-
if (isInline) {
|
|
506
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
507
|
-
"span",
|
|
508
|
-
{
|
|
509
|
-
className: cn(
|
|
510
|
-
"bg-primary-foreground rounded-sm px-1 font-mono text-sm",
|
|
511
|
-
className
|
|
512
|
-
),
|
|
513
|
-
...props,
|
|
514
|
-
children
|
|
515
|
-
}
|
|
516
|
-
);
|
|
517
|
-
}
|
|
518
|
-
const language = extractLanguage(className);
|
|
519
|
-
return /* @__PURE__ */ jsxRuntime.jsx(CodeBlock, { className, children: /* @__PURE__ */ jsxRuntime.jsx(CodeBlockCode, { code: children, language }) });
|
|
520
|
-
},
|
|
521
|
-
pre: function PreComponent({ children }) {
|
|
522
|
-
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
|
|
523
|
-
}
|
|
524
|
-
};
|
|
525
|
-
var MemoizedMarkdownBlock = React8.memo(
|
|
526
|
-
function MarkdownBlock({
|
|
527
|
-
content,
|
|
528
|
-
components = INITIAL_COMPONENTS
|
|
529
|
-
}) {
|
|
530
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
531
|
-
ReactMarkdown__default.default,
|
|
532
|
-
{
|
|
533
|
-
remarkPlugins: [remarkGfm__default.default, remarkBreaks__default.default],
|
|
534
|
-
components,
|
|
535
|
-
children: content
|
|
536
|
-
}
|
|
537
|
-
);
|
|
538
|
-
},
|
|
539
|
-
function propsAreEqual(prevProps, nextProps) {
|
|
540
|
-
return prevProps.content === nextProps.content;
|
|
541
|
-
}
|
|
542
|
-
);
|
|
543
|
-
MemoizedMarkdownBlock.displayName = "MemoizedMarkdownBlock";
|
|
544
|
-
function MarkdownComponent({
|
|
545
|
-
children,
|
|
546
|
-
id,
|
|
547
|
-
className,
|
|
548
|
-
components = INITIAL_COMPONENTS
|
|
549
|
-
}) {
|
|
550
|
-
const generatedId = React8.useId();
|
|
551
|
-
const blockId = id ?? generatedId;
|
|
552
|
-
const blocks = React8.useMemo(() => parseMarkdownIntoBlocks(children), [children]);
|
|
553
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className, children: blocks.map((block, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
554
|
-
MemoizedMarkdownBlock,
|
|
555
|
-
{
|
|
556
|
-
content: block,
|
|
557
|
-
components
|
|
558
|
-
},
|
|
559
|
-
`${blockId}-block-${index}`
|
|
560
|
-
)) });
|
|
561
|
-
}
|
|
562
|
-
var Markdown = React8.memo(MarkdownComponent);
|
|
563
|
-
Markdown.displayName = "Markdown";
|
|
564
462
|
var buttonVariants = classVarianceAuthority.cva(
|
|
565
463
|
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
|
566
464
|
{
|
|
@@ -586,7 +484,7 @@ var buttonVariants = classVarianceAuthority.cva(
|
|
|
586
484
|
}
|
|
587
485
|
}
|
|
588
486
|
);
|
|
589
|
-
var Button =
|
|
487
|
+
var Button = React7__namespace.forwardRef(
|
|
590
488
|
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
591
489
|
const Comp = asChild ? reactSlot.Slot : "button";
|
|
592
490
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -827,7 +725,7 @@ function TooltipTrigger({
|
|
|
827
725
|
disabled,
|
|
828
726
|
...props
|
|
829
727
|
}) {
|
|
830
|
-
if (asChild &&
|
|
728
|
+
if (asChild && React7__namespace.default.isValidElement(children)) {
|
|
831
729
|
return /* @__PURE__ */ jsxRuntime.jsx(tooltip.Tooltip.Trigger, { disabled, render: children, ...props });
|
|
832
730
|
}
|
|
833
731
|
return /* @__PURE__ */ jsxRuntime.jsx(tooltip.Tooltip.Trigger, { disabled, ...props, children });
|
|
@@ -856,7 +754,7 @@ function TooltipContent({
|
|
|
856
754
|
}
|
|
857
755
|
) }) });
|
|
858
756
|
}
|
|
859
|
-
var Avatar =
|
|
757
|
+
var Avatar = React7__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
860
758
|
AvatarPrimitive__namespace.Root,
|
|
861
759
|
{
|
|
862
760
|
ref,
|
|
@@ -868,7 +766,7 @@ var Avatar = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @
|
|
|
868
766
|
}
|
|
869
767
|
));
|
|
870
768
|
Avatar.displayName = AvatarPrimitive__namespace.Root.displayName;
|
|
871
|
-
var AvatarImage =
|
|
769
|
+
var AvatarImage = React7__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
872
770
|
AvatarPrimitive__namespace.Image,
|
|
873
771
|
{
|
|
874
772
|
ref,
|
|
@@ -877,7 +775,7 @@ var AvatarImage = React8__namespace.forwardRef(({ className, ...props }, ref) =>
|
|
|
877
775
|
}
|
|
878
776
|
));
|
|
879
777
|
AvatarImage.displayName = AvatarPrimitive__namespace.Image.displayName;
|
|
880
|
-
var AvatarFallback =
|
|
778
|
+
var AvatarFallback = React7__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
881
779
|
AvatarPrimitive__namespace.Fallback,
|
|
882
780
|
{
|
|
883
781
|
ref,
|
|
@@ -918,12 +816,21 @@ var MessageContent = ({
|
|
|
918
816
|
const classNames = cn(
|
|
919
817
|
"rounded-lg p-2 bg-secondary prose break-words whitespace-normal max-w-none",
|
|
920
818
|
"text-foreground prose-headings:text-foreground prose-p:text-foreground prose-strong:text-foreground prose-li:text-foreground prose-a:text-foreground prose-ol:text-foreground prose-ul:text-foreground prose-code:text-foreground",
|
|
819
|
+
// Compact spacing overrides
|
|
820
|
+
"prose-p:my-1 prose-p:leading-relaxed",
|
|
821
|
+
"prose-ul:my-1 prose-ol:my-1 prose-li:my-0.5",
|
|
822
|
+
"prose-headings:my-2 first:prose-headings:mt-0",
|
|
823
|
+
"prose-pre:my-2 prose-blockquote:my-2",
|
|
824
|
+
// Normalize headings for chat UI (same size, just bold)
|
|
825
|
+
"prose-headings:text-[1em] prose-headings:font-semibold",
|
|
826
|
+
// List styling overrides (fix Streamdown's list-inside)
|
|
827
|
+
"[&_ul]:list-outside [&_ol]:list-outside [&_ul]:pl-4 [&_ol]:pl-4 [&_li]:pl-0",
|
|
921
828
|
proseSizeMap[size],
|
|
922
829
|
className
|
|
923
830
|
);
|
|
924
831
|
return markdown ? /* @__PURE__ */ jsxRuntime.jsx(Markdown, { className: classNames, ...props, children }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: classNames, ...props, children });
|
|
925
832
|
};
|
|
926
|
-
var Textarea =
|
|
833
|
+
var Textarea = React7__namespace.forwardRef(({ className, ...props }, ref) => {
|
|
927
834
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
928
835
|
"textarea",
|
|
929
836
|
{
|
|
@@ -937,7 +844,7 @@ var Textarea = React8__namespace.forwardRef(({ className, ...props }, ref) => {
|
|
|
937
844
|
);
|
|
938
845
|
});
|
|
939
846
|
Textarea.displayName = "Textarea";
|
|
940
|
-
var PromptInputContext =
|
|
847
|
+
var PromptInputContext = React7.createContext({
|
|
941
848
|
isLoading: false,
|
|
942
849
|
value: "",
|
|
943
850
|
setValue: () => {
|
|
@@ -948,7 +855,7 @@ var PromptInputContext = React8.createContext({
|
|
|
948
855
|
textareaRef: { current: null }
|
|
949
856
|
});
|
|
950
857
|
function usePromptInput() {
|
|
951
|
-
return
|
|
858
|
+
return React7.useContext(PromptInputContext);
|
|
952
859
|
}
|
|
953
860
|
function PromptInput({
|
|
954
861
|
className,
|
|
@@ -962,8 +869,8 @@ function PromptInput({
|
|
|
962
869
|
onClick,
|
|
963
870
|
...props
|
|
964
871
|
}) {
|
|
965
|
-
const [internalValue, setInternalValue] =
|
|
966
|
-
const textareaRef =
|
|
872
|
+
const [internalValue, setInternalValue] = React7.useState(value || "");
|
|
873
|
+
const textareaRef = React7.useRef(null);
|
|
967
874
|
const handleChange = (newValue) => {
|
|
968
875
|
setInternalValue(newValue);
|
|
969
876
|
onValueChange?.(newValue);
|
|
@@ -1020,7 +927,7 @@ function PromptInputTextarea({
|
|
|
1020
927
|
textareaRef.current = el;
|
|
1021
928
|
adjustHeight(el);
|
|
1022
929
|
};
|
|
1023
|
-
|
|
930
|
+
React7.useLayoutEffect(() => {
|
|
1024
931
|
if (!textareaRef.current || disableAutosize) return;
|
|
1025
932
|
const el = textareaRef.current;
|
|
1026
933
|
el.style.height = "auto";
|
|
@@ -1087,7 +994,7 @@ function PromptInputAction({
|
|
|
1087
994
|
}
|
|
1088
995
|
var HoverCard = HoverCardPrimitive__namespace.Root;
|
|
1089
996
|
var HoverCardTrigger = HoverCardPrimitive__namespace.Trigger;
|
|
1090
|
-
var HoverCardContent =
|
|
997
|
+
var HoverCardContent = React7__namespace.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1091
998
|
HoverCardPrimitive__namespace.Content,
|
|
1092
999
|
{
|
|
1093
1000
|
ref,
|
|
@@ -1101,9 +1008,9 @@ var HoverCardContent = React8__namespace.forwardRef(({ className, align = "cente
|
|
|
1101
1008
|
}
|
|
1102
1009
|
));
|
|
1103
1010
|
HoverCardContent.displayName = HoverCardPrimitive__namespace.Content.displayName;
|
|
1104
|
-
var SourceContext =
|
|
1011
|
+
var SourceContext = React7.createContext(null);
|
|
1105
1012
|
function useSourceContext() {
|
|
1106
|
-
const ctx =
|
|
1013
|
+
const ctx = React7.useContext(SourceContext);
|
|
1107
1014
|
if (!ctx) throw new Error("Source.* must be used inside <Source>");
|
|
1108
1015
|
return ctx;
|
|
1109
1016
|
}
|
|
@@ -1187,11 +1094,11 @@ function SourceContent({
|
|
|
1187
1094
|
}
|
|
1188
1095
|
) });
|
|
1189
1096
|
}
|
|
1190
|
-
var ReasoningContext =
|
|
1097
|
+
var ReasoningContext = React7__namespace.createContext(
|
|
1191
1098
|
null
|
|
1192
1099
|
);
|
|
1193
1100
|
function useReasoningContext() {
|
|
1194
|
-
const context =
|
|
1101
|
+
const context = React7__namespace.useContext(ReasoningContext);
|
|
1195
1102
|
if (!context) {
|
|
1196
1103
|
throw new Error(
|
|
1197
1104
|
"Reasoning components must be used within a Reasoning provider"
|
|
@@ -1207,11 +1114,11 @@ function Reasoning({
|
|
|
1207
1114
|
defaultOpen = false,
|
|
1208
1115
|
className
|
|
1209
1116
|
}) {
|
|
1210
|
-
const [uncontrolledOpen, setUncontrolledOpen] =
|
|
1211
|
-
const prevStreamingRef =
|
|
1117
|
+
const [uncontrolledOpen, setUncontrolledOpen] = React7__namespace.useState(defaultOpen);
|
|
1118
|
+
const prevStreamingRef = React7__namespace.useRef(isStreaming);
|
|
1212
1119
|
const isControlled = controlledOpen !== void 0;
|
|
1213
1120
|
const isOpen = isControlled ? controlledOpen : uncontrolledOpen;
|
|
1214
|
-
const setIsOpen =
|
|
1121
|
+
const setIsOpen = React7__namespace.useCallback(
|
|
1215
1122
|
(open) => {
|
|
1216
1123
|
if (onOpenChange) {
|
|
1217
1124
|
onOpenChange(open);
|
|
@@ -1222,7 +1129,7 @@ function Reasoning({
|
|
|
1222
1129
|
},
|
|
1223
1130
|
[isControlled, onOpenChange]
|
|
1224
1131
|
);
|
|
1225
|
-
|
|
1132
|
+
React7__namespace.useEffect(() => {
|
|
1226
1133
|
if (isStreaming && !prevStreamingRef.current) {
|
|
1227
1134
|
setIsOpen(true);
|
|
1228
1135
|
} else if (!isStreaming && prevStreamingRef.current) {
|
|
@@ -1278,9 +1185,9 @@ function ReasoningContent({
|
|
|
1278
1185
|
className
|
|
1279
1186
|
}) {
|
|
1280
1187
|
const { isOpen } = useReasoningContext();
|
|
1281
|
-
const contentRef =
|
|
1282
|
-
const [height, setHeight] =
|
|
1283
|
-
|
|
1188
|
+
const contentRef = React7__namespace.useRef(null);
|
|
1189
|
+
const [height, setHeight] = React7__namespace.useState(0);
|
|
1190
|
+
React7__namespace.useEffect(() => {
|
|
1284
1191
|
if (contentRef.current) {
|
|
1285
1192
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
1286
1193
|
for (const entry of entries) {
|
|
@@ -1329,11 +1236,11 @@ function SimpleReasoning({
|
|
|
1329
1236
|
/* @__PURE__ */ jsxRuntime.jsx(ReasoningContent, { markdown, children: content })
|
|
1330
1237
|
] });
|
|
1331
1238
|
}
|
|
1332
|
-
var CopilotUIContext =
|
|
1239
|
+
var CopilotUIContext = React7__namespace.createContext(
|
|
1333
1240
|
null
|
|
1334
1241
|
);
|
|
1335
1242
|
function useCopilotUI() {
|
|
1336
|
-
const context =
|
|
1243
|
+
const context = React7__namespace.useContext(CopilotUIContext);
|
|
1337
1244
|
if (!context) {
|
|
1338
1245
|
return {
|
|
1339
1246
|
debug: false,
|
|
@@ -1348,7 +1255,7 @@ function CopilotUIProvider({
|
|
|
1348
1255
|
debug = false,
|
|
1349
1256
|
defaultDebugExpanded = false
|
|
1350
1257
|
}) {
|
|
1351
|
-
const value =
|
|
1258
|
+
const value = React7__namespace.useMemo(
|
|
1352
1259
|
() => ({
|
|
1353
1260
|
debug,
|
|
1354
1261
|
defaultDebugExpanded,
|
|
@@ -1490,7 +1397,7 @@ function ToolStep({
|
|
|
1490
1397
|
}) {
|
|
1491
1398
|
const { isDebug, defaultDebugExpanded } = useCopilotUI();
|
|
1492
1399
|
const debug = debugProp ?? isDebug;
|
|
1493
|
-
const [expanded, setExpanded] =
|
|
1400
|
+
const [expanded, setExpanded] = React7__namespace.useState(
|
|
1494
1401
|
defaultExpanded ?? defaultDebugExpanded ?? false
|
|
1495
1402
|
);
|
|
1496
1403
|
const displayTitle = getDisplayTitle(step);
|
|
@@ -1955,9 +1862,9 @@ function ArrowUpRightIcon({ className }) {
|
|
|
1955
1862
|
}
|
|
1956
1863
|
);
|
|
1957
1864
|
}
|
|
1958
|
-
var ConfirmationContext =
|
|
1865
|
+
var ConfirmationContext = React7__namespace.createContext(null);
|
|
1959
1866
|
function useConfirmationContext() {
|
|
1960
|
-
const context =
|
|
1867
|
+
const context = React7__namespace.useContext(ConfirmationContext);
|
|
1961
1868
|
if (!context) {
|
|
1962
1869
|
throw new Error(
|
|
1963
1870
|
"Confirmation components must be used within a Confirmation provider"
|
|
@@ -2129,8 +2036,8 @@ function PermissionConfirmation({
|
|
|
2129
2036
|
permissionOptions = DEFAULT_PERMISSION_OPTIONS,
|
|
2130
2037
|
className
|
|
2131
2038
|
}) {
|
|
2132
|
-
const [selectedPermission, setSelectedPermission] =
|
|
2133
|
-
const [showOptions, setShowOptions] =
|
|
2039
|
+
const [selectedPermission, setSelectedPermission] = React7__namespace.useState("ask");
|
|
2040
|
+
const [showOptions, setShowOptions] = React7__namespace.useState(false);
|
|
2134
2041
|
const handleApprove = () => {
|
|
2135
2042
|
onApprove?.(selectedPermission);
|
|
2136
2043
|
};
|
|
@@ -2260,7 +2167,7 @@ function CompactPermissionConfirmation({
|
|
|
2260
2167
|
onReject,
|
|
2261
2168
|
className
|
|
2262
2169
|
}) {
|
|
2263
|
-
const [rememberChoice, setRememberChoice] =
|
|
2170
|
+
const [rememberChoice, setRememberChoice] = React7__namespace.useState(false);
|
|
2264
2171
|
const handleApprove = () => {
|
|
2265
2172
|
onApprove?.(rememberChoice ? "allow_always" : "ask");
|
|
2266
2173
|
};
|
|
@@ -2377,8 +2284,8 @@ function DevLogger({
|
|
|
2377
2284
|
position = "bottom-right",
|
|
2378
2285
|
className
|
|
2379
2286
|
}) {
|
|
2380
|
-
const [isOpen, setIsOpen] =
|
|
2381
|
-
const [activeTab, setActiveTab] =
|
|
2287
|
+
const [isOpen, setIsOpen] = React7.useState(false);
|
|
2288
|
+
const [activeTab, setActiveTab] = React7.useState("chat");
|
|
2382
2289
|
const positionClasses = {
|
|
2383
2290
|
"bottom-left": "bottom-4 left-4",
|
|
2384
2291
|
"bottom-right": "bottom-4 right-4",
|
|
@@ -2803,9 +2710,9 @@ function ModelSelector({
|
|
|
2803
2710
|
showCapabilities = true,
|
|
2804
2711
|
className
|
|
2805
2712
|
}) {
|
|
2806
|
-
const [isOpen, setIsOpen] =
|
|
2807
|
-
const containerRef =
|
|
2808
|
-
|
|
2713
|
+
const [isOpen, setIsOpen] = React7__namespace.useState(false);
|
|
2714
|
+
const containerRef = React7__namespace.useRef(null);
|
|
2715
|
+
React7__namespace.useEffect(() => {
|
|
2809
2716
|
function handleClickOutside(event) {
|
|
2810
2717
|
if (containerRef.current && !containerRef.current.contains(event.target)) {
|
|
2811
2718
|
setIsOpen(false);
|
|
@@ -2814,7 +2721,7 @@ function ModelSelector({
|
|
|
2814
2721
|
document.addEventListener("mousedown", handleClickOutside);
|
|
2815
2722
|
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
2816
2723
|
}, []);
|
|
2817
|
-
const selectedModel =
|
|
2724
|
+
const selectedModel = React7__namespace.useMemo(() => {
|
|
2818
2725
|
if (!value) return null;
|
|
2819
2726
|
if (providers) {
|
|
2820
2727
|
for (const provider of providers) {
|
|
@@ -3040,7 +2947,7 @@ function PopoverTrigger({
|
|
|
3040
2947
|
className,
|
|
3041
2948
|
...props
|
|
3042
2949
|
}) {
|
|
3043
|
-
if (asChild &&
|
|
2950
|
+
if (asChild && React7__namespace.isValidElement(children)) {
|
|
3044
2951
|
return /* @__PURE__ */ jsxRuntime.jsx(popover.Popover.Trigger, { render: children, className, ...props });
|
|
3045
2952
|
}
|
|
3046
2953
|
return /* @__PURE__ */ jsxRuntime.jsx(popover.Popover.Trigger, { className, ...props, children });
|
|
@@ -3175,8 +3082,8 @@ function ThreadPicker({
|
|
|
3175
3082
|
itemClassName,
|
|
3176
3083
|
newButtonClassName
|
|
3177
3084
|
}) {
|
|
3178
|
-
const [isOpen, setIsOpen] =
|
|
3179
|
-
const selectedThread =
|
|
3085
|
+
const [isOpen, setIsOpen] = React7__namespace.useState(false);
|
|
3086
|
+
const selectedThread = React7__namespace.useMemo(() => {
|
|
3180
3087
|
if (!value) return null;
|
|
3181
3088
|
return threads.find((t) => t.id === value) ?? null;
|
|
3182
3089
|
}, [value, threads]);
|
|
@@ -3382,7 +3289,7 @@ function ThreadCard({
|
|
|
3382
3289
|
showDelete = true,
|
|
3383
3290
|
className
|
|
3384
3291
|
}) {
|
|
3385
|
-
const [isHovered, setIsHovered] =
|
|
3292
|
+
const [isHovered, setIsHovered] = React7__namespace.useState(false);
|
|
3386
3293
|
const handleDelete = (e) => {
|
|
3387
3294
|
e.stopPropagation();
|
|
3388
3295
|
onDelete?.();
|
|
@@ -3633,7 +3540,7 @@ function DefaultMessage({
|
|
|
3633
3540
|
}) {
|
|
3634
3541
|
const isUser = message.role === "user";
|
|
3635
3542
|
const isStreaming = isLastMessage && isLoading;
|
|
3636
|
-
const { cleanContent, followUps } =
|
|
3543
|
+
const { cleanContent, followUps } = React7__namespace.useMemo(() => {
|
|
3637
3544
|
if (isUser || !message.content) {
|
|
3638
3545
|
return { cleanContent: message.content, followUps: [] };
|
|
3639
3546
|
}
|
|
@@ -3771,7 +3678,7 @@ function DefaultMessage({
|
|
|
3771
3678
|
toolName: exec.name
|
|
3772
3679
|
};
|
|
3773
3680
|
const output = toolDef.render(renderProps);
|
|
3774
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3681
|
+
return /* @__PURE__ */ jsxRuntime.jsx(React7__namespace.Fragment, { children: output }, exec.id);
|
|
3775
3682
|
}
|
|
3776
3683
|
return null;
|
|
3777
3684
|
}) }),
|
|
@@ -3807,7 +3714,7 @@ function DefaultMessage({
|
|
|
3807
3714
|
approval: approvalCallbacks
|
|
3808
3715
|
};
|
|
3809
3716
|
const output = toolDef.render(renderProps);
|
|
3810
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3717
|
+
return /* @__PURE__ */ jsxRuntime.jsx(React7__namespace.Fragment, { children: output }, tool.id);
|
|
3811
3718
|
}
|
|
3812
3719
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3813
3720
|
PermissionConfirmation,
|
|
@@ -3839,7 +3746,7 @@ function DefaultMessage({
|
|
|
3839
3746
|
] });
|
|
3840
3747
|
}
|
|
3841
3748
|
function AttachmentPreview({ attachment }) {
|
|
3842
|
-
const [expanded, setExpanded] =
|
|
3749
|
+
const [expanded, setExpanded] = React7__namespace.useState(false);
|
|
3843
3750
|
if (attachment.type !== "image") {
|
|
3844
3751
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 rounded-lg border bg-muted/50 px-3 py-2 text-sm", children: [
|
|
3845
3752
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: attachment.type }),
|
|
@@ -3968,10 +3875,10 @@ function ChatWelcome({
|
|
|
3968
3875
|
processAttachment: processAttachmentProp,
|
|
3969
3876
|
classNames = {}
|
|
3970
3877
|
}) {
|
|
3971
|
-
const [input, setInput] =
|
|
3972
|
-
const [pendingAttachments, setPendingAttachments] =
|
|
3973
|
-
const fileInputRef =
|
|
3974
|
-
const fileInputId =
|
|
3878
|
+
const [input, setInput] = React7.useState("");
|
|
3879
|
+
const [pendingAttachments, setPendingAttachments] = React7.useState([]);
|
|
3880
|
+
const fileInputRef = React7.useRef(null);
|
|
3881
|
+
const fileInputId = React7.useId();
|
|
3975
3882
|
const title = config?.title ?? DEFAULT_TITLE;
|
|
3976
3883
|
const subtitle = config?.subtitle ?? DEFAULT_SUBTITLE;
|
|
3977
3884
|
const logo = config?.logo;
|
|
@@ -3980,7 +3887,7 @@ function ChatWelcome({
|
|
|
3980
3887
|
config?.recentChatsLabel ?? DEFAULT_RECENT_CHATS_LABEL;
|
|
3981
3888
|
const maxRecentChats = config?.maxRecentChats ?? DEFAULT_MAX_RECENT_CHATS;
|
|
3982
3889
|
config?.viewMoreLabel ?? DEFAULT_VIEW_MORE_LABEL;
|
|
3983
|
-
const isFileTypeAllowed =
|
|
3890
|
+
const isFileTypeAllowed = React7.useCallback(
|
|
3984
3891
|
(file) => {
|
|
3985
3892
|
for (const type of allowedFileTypes) {
|
|
3986
3893
|
if (type.endsWith("/*")) {
|
|
@@ -3994,7 +3901,7 @@ function ChatWelcome({
|
|
|
3994
3901
|
},
|
|
3995
3902
|
[allowedFileTypes]
|
|
3996
3903
|
);
|
|
3997
|
-
const handleFileSelect =
|
|
3904
|
+
const handleFileSelect = React7.useCallback(
|
|
3998
3905
|
async (files) => {
|
|
3999
3906
|
if (!files || !attachmentsEnabled) return;
|
|
4000
3907
|
for (const file of Array.from(files)) {
|
|
@@ -4057,7 +3964,7 @@ function ChatWelcome({
|
|
|
4057
3964
|
},
|
|
4058
3965
|
[attachmentsEnabled, maxFileSize, isFileTypeAllowed, processAttachmentProp]
|
|
4059
3966
|
);
|
|
4060
|
-
const handleInputChange =
|
|
3967
|
+
const handleInputChange = React7.useCallback(
|
|
4061
3968
|
(e) => {
|
|
4062
3969
|
handleFileSelect(e.target.files);
|
|
4063
3970
|
if (fileInputRef.current) {
|
|
@@ -4066,7 +3973,7 @@ function ChatWelcome({
|
|
|
4066
3973
|
},
|
|
4067
3974
|
[handleFileSelect]
|
|
4068
3975
|
);
|
|
4069
|
-
const removePendingAttachment =
|
|
3976
|
+
const removePendingAttachment = React7.useCallback((id) => {
|
|
4070
3977
|
setPendingAttachments((prev) => {
|
|
4071
3978
|
const att = prev.find((a) => a.id === id);
|
|
4072
3979
|
if (att) {
|
|
@@ -4075,7 +3982,7 @@ function ChatWelcome({
|
|
|
4075
3982
|
return prev.filter((a) => a.id !== id);
|
|
4076
3983
|
});
|
|
4077
3984
|
}, []);
|
|
4078
|
-
const handleSubmit =
|
|
3985
|
+
const handleSubmit = React7.useCallback(() => {
|
|
4079
3986
|
const hasContent = input.trim();
|
|
4080
3987
|
const hasAttachments = pendingAttachments.some(
|
|
4081
3988
|
(att) => att.status === "ready"
|
|
@@ -4087,7 +3994,7 @@ function ChatWelcome({
|
|
|
4087
3994
|
setPendingAttachments([]);
|
|
4088
3995
|
setInput("");
|
|
4089
3996
|
}, [input, isLoading, onSendMessage, pendingAttachments]);
|
|
4090
|
-
const handleSuggestionClick =
|
|
3997
|
+
const handleSuggestionClick = React7.useCallback(
|
|
4091
3998
|
(suggestion) => {
|
|
4092
3999
|
onSendMessage(suggestion);
|
|
4093
4000
|
},
|
|
@@ -4342,12 +4249,12 @@ function Chat({
|
|
|
4342
4249
|
className,
|
|
4343
4250
|
classNames = {}
|
|
4344
4251
|
}) {
|
|
4345
|
-
const [input, setInput] =
|
|
4346
|
-
const [pendingAttachments, setPendingAttachments] =
|
|
4347
|
-
const [isDragging, setIsDragging] =
|
|
4348
|
-
const fileInputRef =
|
|
4349
|
-
const fileInputId =
|
|
4350
|
-
const isFileTypeAllowed =
|
|
4252
|
+
const [input, setInput] = React7.useState("");
|
|
4253
|
+
const [pendingAttachments, setPendingAttachments] = React7.useState([]);
|
|
4254
|
+
const [isDragging, setIsDragging] = React7.useState(false);
|
|
4255
|
+
const fileInputRef = React7.useRef(null);
|
|
4256
|
+
const fileInputId = React7.useId();
|
|
4257
|
+
const isFileTypeAllowed = React7.useCallback(
|
|
4351
4258
|
(file) => {
|
|
4352
4259
|
for (const type of allowedFileTypes) {
|
|
4353
4260
|
if (type.endsWith("/*")) {
|
|
@@ -4361,7 +4268,7 @@ function Chat({
|
|
|
4361
4268
|
},
|
|
4362
4269
|
[allowedFileTypes]
|
|
4363
4270
|
);
|
|
4364
|
-
const handleFileSelect =
|
|
4271
|
+
const handleFileSelect = React7.useCallback(
|
|
4365
4272
|
async (files) => {
|
|
4366
4273
|
if (!files || !attachmentsEnabled) return;
|
|
4367
4274
|
for (const file of Array.from(files)) {
|
|
@@ -4424,7 +4331,7 @@ function Chat({
|
|
|
4424
4331
|
},
|
|
4425
4332
|
[attachmentsEnabled, maxFileSize, isFileTypeAllowed, processAttachmentProp]
|
|
4426
4333
|
);
|
|
4427
|
-
const handleInputChange =
|
|
4334
|
+
const handleInputChange = React7.useCallback(
|
|
4428
4335
|
(e) => {
|
|
4429
4336
|
handleFileSelect(e.target.files);
|
|
4430
4337
|
if (fileInputRef.current) {
|
|
@@ -4433,7 +4340,7 @@ function Chat({
|
|
|
4433
4340
|
},
|
|
4434
4341
|
[handleFileSelect]
|
|
4435
4342
|
);
|
|
4436
|
-
const removePendingAttachment =
|
|
4343
|
+
const removePendingAttachment = React7.useCallback((id) => {
|
|
4437
4344
|
setPendingAttachments((prev) => {
|
|
4438
4345
|
const att = prev.find((a) => a.id === id);
|
|
4439
4346
|
if (att) {
|
|
@@ -4442,7 +4349,7 @@ function Chat({
|
|
|
4442
4349
|
return prev.filter((a) => a.id !== id);
|
|
4443
4350
|
});
|
|
4444
4351
|
}, []);
|
|
4445
|
-
const handleDragOver =
|
|
4352
|
+
const handleDragOver = React7.useCallback(
|
|
4446
4353
|
(e) => {
|
|
4447
4354
|
e.preventDefault();
|
|
4448
4355
|
e.stopPropagation();
|
|
@@ -4452,12 +4359,12 @@ function Chat({
|
|
|
4452
4359
|
},
|
|
4453
4360
|
[attachmentsEnabled]
|
|
4454
4361
|
);
|
|
4455
|
-
const handleDragLeave =
|
|
4362
|
+
const handleDragLeave = React7.useCallback((e) => {
|
|
4456
4363
|
e.preventDefault();
|
|
4457
4364
|
e.stopPropagation();
|
|
4458
4365
|
setIsDragging(false);
|
|
4459
4366
|
}, []);
|
|
4460
|
-
const handleDrop =
|
|
4367
|
+
const handleDrop = React7.useCallback(
|
|
4461
4368
|
(e) => {
|
|
4462
4369
|
e.preventDefault();
|
|
4463
4370
|
e.stopPropagation();
|
|
@@ -4468,7 +4375,7 @@ function Chat({
|
|
|
4468
4375
|
},
|
|
4469
4376
|
[attachmentsEnabled, handleFileSelect]
|
|
4470
4377
|
);
|
|
4471
|
-
const handleSubmit =
|
|
4378
|
+
const handleSubmit = React7.useCallback(() => {
|
|
4472
4379
|
const hasContent = input.trim();
|
|
4473
4380
|
const hasAttachments = pendingAttachments.some(
|
|
4474
4381
|
(att) => att.status === "ready"
|
|
@@ -4480,7 +4387,7 @@ function Chat({
|
|
|
4480
4387
|
setPendingAttachments([]);
|
|
4481
4388
|
setInput("");
|
|
4482
4389
|
}, [input, isLoading, onSendMessage, pendingAttachments]);
|
|
4483
|
-
const handleSuggestionClick =
|
|
4390
|
+
const handleSuggestionClick = React7.useCallback(
|
|
4484
4391
|
(suggestion) => {
|
|
4485
4392
|
if (onSuggestionClick) {
|
|
4486
4393
|
onSuggestionClick(suggestion);
|
|
@@ -4590,7 +4497,7 @@ function Chat({
|
|
|
4590
4497
|
onSendMessage?.(question);
|
|
4591
4498
|
}
|
|
4592
4499
|
};
|
|
4593
|
-
return renderMessage ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
4500
|
+
return renderMessage ? /* @__PURE__ */ jsxRuntime.jsx(React7__namespace.default.Fragment, { children: renderMessage(messageWithExecutions, index) }, message.id) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
4594
4501
|
DefaultMessage,
|
|
4595
4502
|
{
|
|
4596
4503
|
message: messageWithExecutions,
|
|
@@ -4926,17 +4833,17 @@ function useInternalThreadManager(config = {}) {
|
|
|
4926
4833
|
refreshThreads
|
|
4927
4834
|
} = threadManager;
|
|
4928
4835
|
const { messages, setMessages, status, isLoading } = chunkMHLF2QXY_cjs.useCopilot();
|
|
4929
|
-
const isLoadingMessagesRef =
|
|
4930
|
-
const savingToThreadRef =
|
|
4931
|
-
const lastSavedSnapshotRef =
|
|
4932
|
-
const hasInitializedRef =
|
|
4933
|
-
const getMessageSnapshot =
|
|
4836
|
+
const isLoadingMessagesRef = React7.useRef(false);
|
|
4837
|
+
const savingToThreadRef = React7.useRef(null);
|
|
4838
|
+
const lastSavedSnapshotRef = React7.useRef("");
|
|
4839
|
+
const hasInitializedRef = React7.useRef(false);
|
|
4840
|
+
const getMessageSnapshot = React7.useCallback((msgs) => {
|
|
4934
4841
|
return msgs.map((m) => {
|
|
4935
4842
|
const contentPreview = (m.content ?? "").slice(0, 20);
|
|
4936
4843
|
return `${m.id}:${contentPreview}:${m.content?.length ?? 0}`;
|
|
4937
4844
|
}).join("|");
|
|
4938
4845
|
}, []);
|
|
4939
|
-
const convertToCore =
|
|
4846
|
+
const convertToCore = React7.useCallback((msgs) => {
|
|
4940
4847
|
return msgs.map((m) => ({
|
|
4941
4848
|
id: m.id,
|
|
4942
4849
|
role: m.role,
|
|
@@ -4950,7 +4857,7 @@ function useInternalThreadManager(config = {}) {
|
|
|
4950
4857
|
}
|
|
4951
4858
|
}));
|
|
4952
4859
|
}, []);
|
|
4953
|
-
const handleSwitchThread =
|
|
4860
|
+
const handleSwitchThread = React7.useCallback(
|
|
4954
4861
|
async (threadId) => {
|
|
4955
4862
|
isLoadingMessagesRef.current = true;
|
|
4956
4863
|
const thread = await switchThread(threadId);
|
|
@@ -4979,7 +4886,7 @@ function useInternalThreadManager(config = {}) {
|
|
|
4979
4886
|
},
|
|
4980
4887
|
[switchThread, setMessages, getMessageSnapshot, onThreadChange]
|
|
4981
4888
|
);
|
|
4982
|
-
const handleNewThread =
|
|
4889
|
+
const handleNewThread = React7.useCallback(async () => {
|
|
4983
4890
|
isLoadingMessagesRef.current = true;
|
|
4984
4891
|
clearCurrentThread();
|
|
4985
4892
|
lastSavedSnapshotRef.current = "";
|
|
@@ -4990,7 +4897,7 @@ function useInternalThreadManager(config = {}) {
|
|
|
4990
4897
|
isLoadingMessagesRef.current = false;
|
|
4991
4898
|
});
|
|
4992
4899
|
}, [clearCurrentThread, setMessages, onThreadChange]);
|
|
4993
|
-
|
|
4900
|
+
React7.useEffect(() => {
|
|
4994
4901
|
if (hasInitializedRef.current || !currentThread) {
|
|
4995
4902
|
return;
|
|
4996
4903
|
}
|
|
@@ -5018,7 +4925,7 @@ function useInternalThreadManager(config = {}) {
|
|
|
5018
4925
|
isLoadingMessagesRef.current = false;
|
|
5019
4926
|
});
|
|
5020
4927
|
}, [currentThread, setMessages, getMessageSnapshot, onThreadChange]);
|
|
5021
|
-
|
|
4928
|
+
React7.useEffect(() => {
|
|
5022
4929
|
if (isLoadingMessagesRef.current) {
|
|
5023
4930
|
return;
|
|
5024
4931
|
}
|
|
@@ -5258,7 +5165,7 @@ function CopilotChat(props) {
|
|
|
5258
5165
|
footer: classNames.footer
|
|
5259
5166
|
} : void 0;
|
|
5260
5167
|
const { threadManager, handleSwitchThread, handleNewThread, isBusy } = threadManagerResult;
|
|
5261
|
-
const handleDeleteThread =
|
|
5168
|
+
const handleDeleteThread = React7__namespace.default.useCallback(
|
|
5262
5169
|
(threadId) => {
|
|
5263
5170
|
const isCurrentThread = threadManager.currentThreadId === threadId;
|
|
5264
5171
|
threadManager.deleteThread(threadId);
|