@assistant-ui/react 0.5.83 → 0.5.84
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.d.mts +10 -8
- package/dist/index.d.ts +10 -8
- package/dist/index.js +141 -129
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +123 -111
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
@@ -465,22 +465,20 @@ import { useEffect as useEffect5 } from "react";
|
|
465
465
|
var useAssistantTool = (tool) => {
|
466
466
|
const assistantRuntime = useAssistantRuntime();
|
467
467
|
const toolUIsStore = useToolUIsStore();
|
468
|
+
useEffect5(() => {
|
469
|
+
return tool.render ? toolUIsStore.getState().setToolUI(tool.toolName, tool.render) : void 0;
|
470
|
+
}, [toolUIsStore, tool.toolName, tool.render]);
|
468
471
|
useEffect5(() => {
|
469
472
|
const { toolName, render, ...rest } = tool;
|
470
473
|
const config = {
|
471
474
|
tools: {
|
472
|
-
[
|
475
|
+
[toolName]: rest
|
473
476
|
}
|
474
477
|
};
|
475
|
-
|
478
|
+
return assistantRuntime.registerModelConfigProvider({
|
476
479
|
getModelConfig: () => config
|
477
480
|
});
|
478
|
-
|
479
|
-
return () => {
|
480
|
-
unsub1();
|
481
|
-
unsub2?.();
|
482
|
-
};
|
483
|
-
}, [assistantRuntime, toolUIsStore, tool]);
|
481
|
+
}, [assistantRuntime, tool]);
|
484
482
|
};
|
485
483
|
|
486
484
|
// src/model-config/makeAssistantTool.tsx
|
@@ -499,9 +497,8 @@ var useAssistantToolUI = (tool) => {
|
|
499
497
|
const toolUIsStore = useToolUIsStore();
|
500
498
|
useEffect6(() => {
|
501
499
|
if (!tool) return;
|
502
|
-
|
503
|
-
|
504
|
-
}, [toolUIsStore, tool]);
|
500
|
+
return toolUIsStore.getState().setToolUI(tool.toolName, tool.render);
|
501
|
+
}, [toolUIsStore, tool?.toolName, tool?.render]);
|
505
502
|
};
|
506
503
|
|
507
504
|
// src/model-config/makeAssistantToolUI.tsx
|
@@ -528,8 +525,22 @@ var useAssistantInstructions = (instruction) => {
|
|
528
525
|
}, [assistantRuntime, instruction]);
|
529
526
|
};
|
530
527
|
|
528
|
+
// src/model-config/useInlineRender.tsx
|
529
|
+
import { useCallback as useCallback3, useEffect as useEffect8, useState as useState5 } from "react";
|
530
|
+
import { create as create6 } from "zustand";
|
531
|
+
var useInlineRender = (toolUI) => {
|
532
|
+
const [useToolUI] = useState5(() => create6(() => toolUI));
|
533
|
+
useEffect8(() => {
|
534
|
+
useToolUI.setState(toolUI);
|
535
|
+
});
|
536
|
+
return useCallback3((args) => {
|
537
|
+
const toolUI2 = useToolUI();
|
538
|
+
return toolUI2(args);
|
539
|
+
}, []);
|
540
|
+
};
|
541
|
+
|
531
542
|
// src/primitive-hooks/actionBar/useActionBarCopy.tsx
|
532
|
-
import { useCallback as
|
543
|
+
import { useCallback as useCallback4 } from "react";
|
533
544
|
var useActionBarCopy = ({
|
534
545
|
copiedDuration = 3e3
|
535
546
|
} = {}) => {
|
@@ -539,7 +550,7 @@ var useActionBarCopy = ({
|
|
539
550
|
const hasCopyableContent = useMessage((message) => {
|
540
551
|
return (message.role !== "assistant" || message.status.type !== "running") && message.content.some((c) => c.type === "text" && c.text.length > 0);
|
541
552
|
});
|
542
|
-
const callback =
|
553
|
+
const callback = useCallback4(() => {
|
543
554
|
const { isEditing, text: composerValue } = composerRuntime.getState();
|
544
555
|
const valueToCopy = isEditing ? composerValue : messageRuntime.unstable_getCopyText();
|
545
556
|
navigator.clipboard.writeText(valueToCopy).then(() => {
|
@@ -552,11 +563,11 @@ var useActionBarCopy = ({
|
|
552
563
|
};
|
553
564
|
|
554
565
|
// src/primitive-hooks/actionBar/useActionBarEdit.tsx
|
555
|
-
import { useCallback as
|
566
|
+
import { useCallback as useCallback5 } from "react";
|
556
567
|
var useActionBarEdit = () => {
|
557
568
|
const messageRuntime = useMessageRuntime();
|
558
569
|
const disabled = useEditComposer((c) => c.isEditing);
|
559
|
-
const callback =
|
570
|
+
const callback = useCallback5(() => {
|
560
571
|
messageRuntime.composer.beginEdit();
|
561
572
|
}, [messageRuntime]);
|
562
573
|
if (disabled) return null;
|
@@ -564,7 +575,7 @@ var useActionBarEdit = () => {
|
|
564
575
|
};
|
565
576
|
|
566
577
|
// src/primitive-hooks/actionBar/useActionBarReload.tsx
|
567
|
-
import { useCallback as
|
578
|
+
import { useCallback as useCallback6 } from "react";
|
568
579
|
|
569
580
|
// src/utils/combined/useCombinedStore.ts
|
570
581
|
import { useMemo as useMemo4 } from "react";
|
@@ -600,7 +611,7 @@ var useActionBarReload = () => {
|
|
600
611
|
[threadRuntime, messageRuntime],
|
601
612
|
(t, m) => t.isRunning || t.isDisabled || m.role !== "assistant"
|
602
613
|
);
|
603
|
-
const callback =
|
614
|
+
const callback = useCallback6(() => {
|
604
615
|
messageRuntime.reload();
|
605
616
|
}, [messageRuntime]);
|
606
617
|
if (disabled) return null;
|
@@ -608,10 +619,10 @@ var useActionBarReload = () => {
|
|
608
619
|
};
|
609
620
|
|
610
621
|
// src/primitive-hooks/actionBar/useActionBarSpeak.tsx
|
611
|
-
import { useCallback as
|
622
|
+
import { useCallback as useCallback7 } from "react";
|
612
623
|
var useActionBarSpeak = () => {
|
613
624
|
const messageRunime = useMessageRuntime();
|
614
|
-
const callback =
|
625
|
+
const callback = useCallback7(async () => {
|
615
626
|
messageRunime.speak();
|
616
627
|
}, [messageRunime]);
|
617
628
|
const hasSpeakableContent = useMessage((m) => {
|
@@ -622,11 +633,11 @@ var useActionBarSpeak = () => {
|
|
622
633
|
};
|
623
634
|
|
624
635
|
// src/primitive-hooks/actionBar/useActionBarStopSpeaking.tsx
|
625
|
-
import { useCallback as
|
636
|
+
import { useCallback as useCallback8 } from "react";
|
626
637
|
var useActionBarStopSpeaking = () => {
|
627
638
|
const messageRuntime = useMessageRuntime();
|
628
639
|
const isSpeaking = useMessage((u) => u.speech != null);
|
629
|
-
const callback =
|
640
|
+
const callback = useCallback8(async () => {
|
630
641
|
messageRuntime.stopSpeaking();
|
631
642
|
}, [messageRuntime]);
|
632
643
|
if (!isSpeaking) return null;
|
@@ -634,20 +645,20 @@ var useActionBarStopSpeaking = () => {
|
|
634
645
|
};
|
635
646
|
|
636
647
|
// src/primitive-hooks/actionBar/useActionBarFeedbackPositive.tsx
|
637
|
-
import { useCallback as
|
648
|
+
import { useCallback as useCallback9 } from "react";
|
638
649
|
var useActionBarFeedbackPositive = () => {
|
639
650
|
const messageRuntime = useMessageRuntime();
|
640
|
-
const callback =
|
651
|
+
const callback = useCallback9(() => {
|
641
652
|
messageRuntime.submitFeedback({ type: "positive" });
|
642
653
|
}, [messageRuntime]);
|
643
654
|
return callback;
|
644
655
|
};
|
645
656
|
|
646
657
|
// src/primitive-hooks/actionBar/useActionBarFeedbackNegative.tsx
|
647
|
-
import { useCallback as
|
658
|
+
import { useCallback as useCallback10 } from "react";
|
648
659
|
var useActionBarFeedbackNegative = () => {
|
649
660
|
const messageRuntime = useMessageRuntime();
|
650
|
-
const callback =
|
661
|
+
const callback = useCallback10(() => {
|
651
662
|
messageRuntime.submitFeedback({ type: "negative" });
|
652
663
|
}, [messageRuntime]);
|
653
664
|
return callback;
|
@@ -660,11 +671,11 @@ var useBranchPickerCount = () => {
|
|
660
671
|
};
|
661
672
|
|
662
673
|
// src/primitive-hooks/branchPicker/useBranchPickerNext.tsx
|
663
|
-
import { useCallback as
|
674
|
+
import { useCallback as useCallback11 } from "react";
|
664
675
|
var useBranchPickerNext = () => {
|
665
676
|
const messageRuntime = useMessageRuntime();
|
666
677
|
const disabled = useMessage((m) => m.branchNumber >= m.branchCount);
|
667
|
-
const callback =
|
678
|
+
const callback = useCallback11(() => {
|
668
679
|
messageRuntime.switchToBranch({ position: "next" });
|
669
680
|
}, [messageRuntime]);
|
670
681
|
if (disabled) return null;
|
@@ -678,11 +689,11 @@ var useBranchPickerNumber = () => {
|
|
678
689
|
};
|
679
690
|
|
680
691
|
// src/primitive-hooks/branchPicker/useBranchPickerPrevious.tsx
|
681
|
-
import { useCallback as
|
692
|
+
import { useCallback as useCallback12 } from "react";
|
682
693
|
var useBranchPickerPrevious = () => {
|
683
694
|
const messageRuntime = useMessageRuntime();
|
684
695
|
const disabled = useMessage((m) => m.branchNumber <= 1);
|
685
|
-
const callback =
|
696
|
+
const callback = useCallback12(() => {
|
686
697
|
messageRuntime.switchToBranch({ position: "previous" });
|
687
698
|
}, [messageRuntime]);
|
688
699
|
if (disabled) return null;
|
@@ -690,11 +701,11 @@ var useBranchPickerPrevious = () => {
|
|
690
701
|
};
|
691
702
|
|
692
703
|
// src/primitive-hooks/composer/useComposerCancel.tsx
|
693
|
-
import { useCallback as
|
704
|
+
import { useCallback as useCallback13 } from "react";
|
694
705
|
var useComposerCancel = () => {
|
695
706
|
const composerRuntime = useComposerRuntime();
|
696
707
|
const disabled = useComposer((c) => !c.canCancel);
|
697
|
-
const callback =
|
708
|
+
const callback = useCallback13(() => {
|
698
709
|
composerRuntime.cancel();
|
699
710
|
}, [composerRuntime]);
|
700
711
|
if (disabled) return null;
|
@@ -711,7 +722,7 @@ var useComposerIf = (props) => {
|
|
711
722
|
};
|
712
723
|
|
713
724
|
// src/primitive-hooks/composer/useComposerSend.tsx
|
714
|
-
import { useCallback as
|
725
|
+
import { useCallback as useCallback14 } from "react";
|
715
726
|
var useComposerSend = () => {
|
716
727
|
const composerRuntime = useComposerRuntime();
|
717
728
|
const threadRuntime = useThreadRuntime();
|
@@ -719,7 +730,7 @@ var useComposerSend = () => {
|
|
719
730
|
[threadRuntime, composerRuntime],
|
720
731
|
(t, c) => t.isRunning || !c.isEditing || c.isEmpty
|
721
732
|
);
|
722
|
-
const callback =
|
733
|
+
const callback = useCallback14(() => {
|
723
734
|
if (!composerRuntime.getState().isEditing) return;
|
724
735
|
composerRuntime.send();
|
725
736
|
}, [threadRuntime]);
|
@@ -728,11 +739,11 @@ var useComposerSend = () => {
|
|
728
739
|
};
|
729
740
|
|
730
741
|
// src/primitive-hooks/composer/useComposerAddAttachment.tsx
|
731
|
-
import { useCallback as
|
742
|
+
import { useCallback as useCallback15 } from "react";
|
732
743
|
var useComposerAddAttachment = () => {
|
733
744
|
const disabled = useComposer((c) => !c.isEditing);
|
734
745
|
const composerRuntime = useComposerRuntime();
|
735
|
-
const callback =
|
746
|
+
const callback = useCallback15(() => {
|
736
747
|
const input = document.createElement("input");
|
737
748
|
input.type = "file";
|
738
749
|
const attachmentAccept = composerRuntime.getAttachmentAccept();
|
@@ -842,11 +853,11 @@ var useThreadEmpty = () => {
|
|
842
853
|
};
|
843
854
|
|
844
855
|
// src/primitive-hooks/thread/useThreadScrollToBottom.tsx
|
845
|
-
import { useCallback as
|
856
|
+
import { useCallback as useCallback16 } from "react";
|
846
857
|
var useThreadScrollToBottom = () => {
|
847
858
|
const isAtBottom = useThreadViewport((s) => s.isAtBottom);
|
848
859
|
const threadViewportStore = useThreadViewportStore();
|
849
|
-
const handleScrollToBottom =
|
860
|
+
const handleScrollToBottom = useCallback16(() => {
|
850
861
|
threadViewportStore.getState().scrollToBottom();
|
851
862
|
}, [threadViewportStore]);
|
852
863
|
if (isAtBottom) return null;
|
@@ -854,14 +865,14 @@ var useThreadScrollToBottom = () => {
|
|
854
865
|
};
|
855
866
|
|
856
867
|
// src/primitive-hooks/thread/useThreadSuggestion.tsx
|
857
|
-
import { useCallback as
|
868
|
+
import { useCallback as useCallback17 } from "react";
|
858
869
|
var useThreadSuggestion = ({
|
859
870
|
prompt,
|
860
871
|
autoSend
|
861
872
|
}) => {
|
862
873
|
const threadRuntime = useThreadRuntime();
|
863
874
|
const disabled = useThread((t) => t.isDisabled);
|
864
|
-
const callback =
|
875
|
+
const callback = useCallback17(() => {
|
865
876
|
if (autoSend && !threadRuntime.getState().isRunning) {
|
866
877
|
threadRuntime.append(prompt);
|
867
878
|
threadRuntime.composer.setText("");
|
@@ -1100,7 +1111,7 @@ __export(assistantModal_exports, {
|
|
1100
1111
|
});
|
1101
1112
|
|
1102
1113
|
// src/primitives/assistantModal/AssistantModalRoot.tsx
|
1103
|
-
import { useEffect as
|
1114
|
+
import { useEffect as useEffect9, useState as useState6 } from "react";
|
1104
1115
|
import * as PopoverPrimitive2 from "@radix-ui/react-popover";
|
1105
1116
|
import { composeEventHandlers as composeEventHandlers6 } from "@radix-ui/primitive";
|
1106
1117
|
|
@@ -1114,10 +1125,10 @@ var useAssistantModalOpenState = ({
|
|
1114
1125
|
defaultOpen = false,
|
1115
1126
|
unstable_openOnRunStart = true
|
1116
1127
|
}) => {
|
1117
|
-
const state =
|
1128
|
+
const state = useState6(defaultOpen);
|
1118
1129
|
const [, setOpen] = state;
|
1119
1130
|
const threadRuntime = useThreadRuntime();
|
1120
|
-
|
1131
|
+
useEffect9(() => {
|
1121
1132
|
if (!unstable_openOnRunStart) return void 0;
|
1122
1133
|
return threadRuntime.unstable_on("run-start", () => {
|
1123
1134
|
setOpen(true);
|
@@ -1311,10 +1322,10 @@ var AttachmentPrimitiveName = () => {
|
|
1311
1322
|
AttachmentPrimitiveName.displayName = "AttachmentPrimitive.Name";
|
1312
1323
|
|
1313
1324
|
// src/primitive-hooks/attachment/useAttachmentRemove.ts
|
1314
|
-
import { useCallback as
|
1325
|
+
import { useCallback as useCallback18 } from "react";
|
1315
1326
|
var useAttachmentRemove = () => {
|
1316
1327
|
const attachmentRuntime = useAttachmentRuntime();
|
1317
|
-
const handleRemoveAttachment =
|
1328
|
+
const handleRemoveAttachment = useCallback18(() => {
|
1318
1329
|
attachmentRuntime.remove();
|
1319
1330
|
}, [attachmentRuntime]);
|
1320
1331
|
return handleRemoveAttachment;
|
@@ -1382,14 +1393,14 @@ __export(message_exports, {
|
|
1382
1393
|
import { Primitive as Primitive9 } from "@radix-ui/react-primitive";
|
1383
1394
|
import {
|
1384
1395
|
forwardRef as forwardRef12,
|
1385
|
-
useCallback as
|
1396
|
+
useCallback as useCallback20
|
1386
1397
|
} from "react";
|
1387
1398
|
|
1388
1399
|
// src/utils/hooks/useManagedRef.ts
|
1389
|
-
import { useCallback as
|
1400
|
+
import { useCallback as useCallback19, useRef } from "react";
|
1390
1401
|
var useManagedRef = (callback) => {
|
1391
1402
|
const cleanupRef = useRef();
|
1392
|
-
const ref =
|
1403
|
+
const ref = useCallback19(
|
1393
1404
|
(el) => {
|
1394
1405
|
if (cleanupRef.current) {
|
1395
1406
|
cleanupRef.current();
|
@@ -1408,7 +1419,7 @@ import { useComposedRefs } from "@radix-ui/react-compose-refs";
|
|
1408
1419
|
import { jsx as jsx18 } from "react/jsx-runtime";
|
1409
1420
|
var useIsHoveringRef = () => {
|
1410
1421
|
const messageUtilsStore = useMessageUtilsStore();
|
1411
|
-
const callbackRef =
|
1422
|
+
const callbackRef = useCallback20(
|
1412
1423
|
(el) => {
|
1413
1424
|
const setIsHovering = messageUtilsStore.getState().setIsHovering;
|
1414
1425
|
const handleMouseEnter = () => {
|
@@ -1450,19 +1461,19 @@ MessagePrimitiveIf.displayName = "MessagePrimitive.If";
|
|
1450
1461
|
import { memo as memo2, useMemo as useMemo6 } from "react";
|
1451
1462
|
|
1452
1463
|
// src/context/providers/ContentPartRuntimeProvider.tsx
|
1453
|
-
import { useEffect as
|
1454
|
-
import { create as
|
1464
|
+
import { useEffect as useEffect10, useState as useState7 } from "react";
|
1465
|
+
import { create as create7 } from "zustand";
|
1455
1466
|
import { jsx as jsx19 } from "react/jsx-runtime";
|
1456
1467
|
var useContentPartRuntimeStore = (runtime) => {
|
1457
|
-
const [store] =
|
1458
|
-
|
1468
|
+
const [store] = useState7(() => create7(() => runtime));
|
1469
|
+
useEffect10(() => {
|
1459
1470
|
writableStore(store).setState(runtime, true);
|
1460
1471
|
}, [runtime, store]);
|
1461
1472
|
return store;
|
1462
1473
|
};
|
1463
1474
|
var useContentPartStore2 = (runtime) => {
|
1464
|
-
const [store] =
|
1465
|
-
|
1475
|
+
const [store] = useState7(() => create7(() => runtime.getState()));
|
1476
|
+
useEffect10(() => {
|
1466
1477
|
const updateState = () => writableStore(store).setState(runtime.getState(), true);
|
1467
1478
|
updateState();
|
1468
1479
|
return runtime.subscribe(updateState);
|
@@ -1475,7 +1486,7 @@ var ContentPartRuntimeProvider = ({
|
|
1475
1486
|
}) => {
|
1476
1487
|
const useContentPartRuntime2 = useContentPartRuntimeStore(runtime);
|
1477
1488
|
const useContentPart2 = useContentPartStore2(runtime);
|
1478
|
-
const [context] =
|
1489
|
+
const [context] = useState7(() => {
|
1479
1490
|
return { useContentPartRuntime: useContentPartRuntime2, useContentPart: useContentPart2 };
|
1480
1491
|
});
|
1481
1492
|
return /* @__PURE__ */ jsx19(ContentPartContext.Provider, { value: context, children });
|
@@ -1487,7 +1498,7 @@ import {
|
|
1487
1498
|
} from "react";
|
1488
1499
|
|
1489
1500
|
// src/utils/smooth/useSmooth.tsx
|
1490
|
-
import { useEffect as
|
1501
|
+
import { useEffect as useEffect11, useMemo as useMemo5, useRef as useRef2, useState as useState9 } from "react";
|
1491
1502
|
import { useCallbackRef } from "@radix-ui/react-use-callback-ref";
|
1492
1503
|
|
1493
1504
|
// src/utils/smooth/SmoothContext.tsx
|
@@ -1495,19 +1506,19 @@ import {
|
|
1495
1506
|
createContext as createContext6,
|
1496
1507
|
forwardRef as forwardRef13,
|
1497
1508
|
useContext as useContext3,
|
1498
|
-
useState as
|
1509
|
+
useState as useState8
|
1499
1510
|
} from "react";
|
1500
|
-
import { create as
|
1511
|
+
import { create as create8 } from "zustand";
|
1501
1512
|
import { jsx as jsx20 } from "react/jsx-runtime";
|
1502
1513
|
var SmoothContext = createContext6(null);
|
1503
1514
|
var makeSmoothContext = (initialState) => {
|
1504
|
-
const useSmoothStatus2 =
|
1515
|
+
const useSmoothStatus2 = create8(() => initialState);
|
1505
1516
|
return { useSmoothStatus: useSmoothStatus2 };
|
1506
1517
|
};
|
1507
1518
|
var SmoothContextProvider = ({ children }) => {
|
1508
1519
|
const outer = useSmoothContext({ optional: true });
|
1509
1520
|
const contentPartStore = useContentPartStore();
|
1510
|
-
const [context] =
|
1521
|
+
const [context] = useState8(
|
1511
1522
|
() => makeSmoothContext(contentPartStore.getState().status)
|
1512
1523
|
);
|
1513
1524
|
if (outer) return children;
|
@@ -1588,7 +1599,7 @@ var useSmooth = (state, smooth = false) => {
|
|
1588
1599
|
selector: (m) => m.id
|
1589
1600
|
});
|
1590
1601
|
const idRef = useRef2(id);
|
1591
|
-
const [displayedText, setDisplayedText] =
|
1602
|
+
const [displayedText, setDisplayedText] = useState9(text);
|
1592
1603
|
const smoothStatusStore = useSmoothStatusStore({ optional: true });
|
1593
1604
|
const setText = useCallbackRef((text2) => {
|
1594
1605
|
setDisplayedText(text2);
|
@@ -1598,17 +1609,17 @@ var useSmooth = (state, smooth = false) => {
|
|
1598
1609
|
);
|
1599
1610
|
}
|
1600
1611
|
});
|
1601
|
-
|
1612
|
+
useEffect11(() => {
|
1602
1613
|
if (smoothStatusStore) {
|
1603
1614
|
writableStore(smoothStatusStore).setState(
|
1604
1615
|
text !== state.text ? SMOOTH_STATUS : state.status
|
1605
1616
|
);
|
1606
1617
|
}
|
1607
1618
|
}, [smoothStatusStore, text, displayedText, state.status, state.text]);
|
1608
|
-
const [animatorRef] =
|
1619
|
+
const [animatorRef] = useState9(
|
1609
1620
|
new TextStreamAnimator(text, setText)
|
1610
1621
|
);
|
1611
|
-
|
1622
|
+
useEffect11(() => {
|
1612
1623
|
if (!smooth) {
|
1613
1624
|
animatorRef.stop();
|
1614
1625
|
return;
|
@@ -1624,7 +1635,7 @@ var useSmooth = (state, smooth = false) => {
|
|
1624
1635
|
animatorRef.targetText = text;
|
1625
1636
|
animatorRef.start();
|
1626
1637
|
}, [setText, animatorRef, id, smooth, text]);
|
1627
|
-
|
1638
|
+
useEffect11(() => {
|
1628
1639
|
return () => {
|
1629
1640
|
animatorRef.stop();
|
1630
1641
|
};
|
@@ -2391,22 +2402,22 @@ import { memo as memo3, useMemo as useMemo8 } from "react";
|
|
2391
2402
|
|
2392
2403
|
// src/context/providers/AttachmentRuntimeProvider.tsx
|
2393
2404
|
import {
|
2394
|
-
useEffect as
|
2405
|
+
useEffect as useEffect12,
|
2395
2406
|
useMemo as useMemo7,
|
2396
|
-
useState as
|
2407
|
+
useState as useState10
|
2397
2408
|
} from "react";
|
2398
|
-
import { create as
|
2409
|
+
import { create as create9 } from "zustand";
|
2399
2410
|
import { jsx as jsx24 } from "react/jsx-runtime";
|
2400
2411
|
var useAttachmentRuntimeStore = (runtime) => {
|
2401
|
-
const [store] =
|
2402
|
-
|
2412
|
+
const [store] = useState10(() => create9(() => runtime));
|
2413
|
+
useEffect12(() => {
|
2403
2414
|
writableStore(store).setState(runtime, true);
|
2404
2415
|
}, [runtime, store]);
|
2405
2416
|
return store;
|
2406
2417
|
};
|
2407
2418
|
var useAttachmentStore = (runtime) => {
|
2408
|
-
const [store] =
|
2409
|
-
|
2419
|
+
const [store] = useState10(() => create9(() => runtime.getState()));
|
2420
|
+
useEffect12(() => {
|
2410
2421
|
const updateState = () => writableStore(store).setState(runtime.getState(), true);
|
2411
2422
|
updateState();
|
2412
2423
|
return runtime.subscribe(updateState);
|
@@ -2531,8 +2542,8 @@ import { useComposedRefs as useComposedRefs2 } from "@radix-ui/react-compose-ref
|
|
2531
2542
|
import { Slot } from "@radix-ui/react-slot";
|
2532
2543
|
import {
|
2533
2544
|
forwardRef as forwardRef18,
|
2534
|
-
useCallback as
|
2535
|
-
useEffect as
|
2545
|
+
useCallback as useCallback21,
|
2546
|
+
useEffect as useEffect14,
|
2536
2547
|
useRef as useRef3
|
2537
2548
|
} from "react";
|
2538
2549
|
import TextareaAutosize from "react-textarea-autosize";
|
@@ -2540,11 +2551,11 @@ import { useEscapeKeydown as useEscapeKeydown2 } from "@radix-ui/react-use-escap
|
|
2540
2551
|
|
2541
2552
|
// src/utils/hooks/useOnScrollToBottom.tsx
|
2542
2553
|
import { useCallbackRef as useCallbackRef2 } from "@radix-ui/react-use-callback-ref";
|
2543
|
-
import { useEffect as
|
2554
|
+
import { useEffect as useEffect13 } from "react";
|
2544
2555
|
var useOnScrollToBottom = (callback) => {
|
2545
2556
|
const callbackRef = useCallbackRef2(callback);
|
2546
2557
|
const onScrollToBottom = useThreadViewport((vp) => vp.onScrollToBottom);
|
2547
|
-
|
2558
|
+
useEffect13(() => {
|
2548
2559
|
return onScrollToBottom(callbackRef);
|
2549
2560
|
}, [onScrollToBottom, callbackRef]);
|
2550
2561
|
};
|
@@ -2594,7 +2605,7 @@ var ComposerPrimitiveInput = forwardRef18(
|
|
2594
2605
|
}
|
2595
2606
|
};
|
2596
2607
|
const autoFocusEnabled = autoFocus && !isDisabled;
|
2597
|
-
const focus2 =
|
2608
|
+
const focus2 = useCallback21(() => {
|
2598
2609
|
const textarea = textareaRef.current;
|
2599
2610
|
if (!textarea || !autoFocusEnabled) return;
|
2600
2611
|
textarea.focus({ preventScroll: true });
|
@@ -2603,18 +2614,18 @@ var ComposerPrimitiveInput = forwardRef18(
|
|
2603
2614
|
textareaRef.current.value.length
|
2604
2615
|
);
|
2605
2616
|
}, [autoFocusEnabled]);
|
2606
|
-
|
2617
|
+
useEffect14(() => focus2(), [focus2]);
|
2607
2618
|
useOnScrollToBottom(() => {
|
2608
2619
|
if (composerRuntime.type === "thread" && unstable_focusOnScrollToBottom) {
|
2609
2620
|
focus2();
|
2610
2621
|
}
|
2611
2622
|
});
|
2612
|
-
|
2623
|
+
useEffect14(() => {
|
2613
2624
|
if (composerRuntime.type !== "thread" || !unstable_focusOnRunStart)
|
2614
2625
|
return void 0;
|
2615
2626
|
return threadRuntime.unstable_on("run-start", focus2);
|
2616
2627
|
}, [unstable_focusOnRunStart]);
|
2617
|
-
|
2628
|
+
useEffect14(() => {
|
2618
2629
|
if (composerRuntime.type !== "thread" || !unstable_focusOnThreadSwitched)
|
2619
2630
|
return void 0;
|
2620
2631
|
return threadRuntime.unstable_on("switched-to", focus2);
|
@@ -2771,14 +2782,14 @@ import { forwardRef as forwardRef20 } from "react";
|
|
2771
2782
|
|
2772
2783
|
// src/primitive-hooks/thread/useThreadViewportAutoScroll.tsx
|
2773
2784
|
import { useComposedRefs as useComposedRefs3 } from "@radix-ui/react-compose-refs";
|
2774
|
-
import { useEffect as
|
2785
|
+
import { useEffect as useEffect15, useRef as useRef4 } from "react";
|
2775
2786
|
|
2776
2787
|
// src/utils/hooks/useOnResizeContent.tsx
|
2777
2788
|
import { useCallbackRef as useCallbackRef3 } from "@radix-ui/react-use-callback-ref";
|
2778
|
-
import { useCallback as
|
2789
|
+
import { useCallback as useCallback22 } from "react";
|
2779
2790
|
var useOnResizeContent = (callback) => {
|
2780
2791
|
const callbackRef = useCallbackRef3(callback);
|
2781
|
-
const refCallback =
|
2792
|
+
const refCallback = useCallback22(
|
2782
2793
|
(el) => {
|
2783
2794
|
const resizeObserver = new ResizeObserver(() => {
|
2784
2795
|
callbackRef();
|
@@ -2863,7 +2874,7 @@ var useThreadViewportAutoScroll = ({
|
|
2863
2874
|
scrollToBottom("auto");
|
2864
2875
|
});
|
2865
2876
|
const threadRuntime = useThreadRuntime();
|
2866
|
-
|
2877
|
+
useEffect15(() => {
|
2867
2878
|
if (!unstable_scrollToBottomOnRunStart) return void 0;
|
2868
2879
|
return threadRuntime.unstable_on("run-start", focus);
|
2869
2880
|
}, [unstable_scrollToBottomOnRunStart]);
|
@@ -2885,12 +2896,12 @@ ThreadPrimitiveViewport.displayName = "ThreadPrimitive.Viewport";
|
|
2885
2896
|
import { memo as memo5, useMemo as useMemo10 } from "react";
|
2886
2897
|
|
2887
2898
|
// src/context/providers/MessageRuntimeProvider.tsx
|
2888
|
-
import { useEffect as
|
2889
|
-
import { create as
|
2899
|
+
import { useEffect as useEffect16, useState as useState11 } from "react";
|
2900
|
+
import { create as create11 } from "zustand";
|
2890
2901
|
|
2891
2902
|
// src/context/stores/MessageUtils.ts
|
2892
|
-
import { create as
|
2893
|
-
var makeMessageUtilsStore = () =>
|
2903
|
+
import { create as create10 } from "zustand";
|
2904
|
+
var makeMessageUtilsStore = () => create10((set) => {
|
2894
2905
|
return {
|
2895
2906
|
isCopied: false,
|
2896
2907
|
setIsCopied: (value) => {
|
@@ -2906,15 +2917,15 @@ var makeMessageUtilsStore = () => create9((set) => {
|
|
2906
2917
|
// src/context/providers/MessageRuntimeProvider.tsx
|
2907
2918
|
import { jsx as jsx32 } from "react/jsx-runtime";
|
2908
2919
|
var useMessageRuntimeStore = (runtime) => {
|
2909
|
-
const [store] =
|
2910
|
-
|
2920
|
+
const [store] = useState11(() => create11(() => runtime));
|
2921
|
+
useEffect16(() => {
|
2911
2922
|
writableStore(store).setState(runtime, true);
|
2912
2923
|
}, [runtime, store]);
|
2913
2924
|
return store;
|
2914
2925
|
};
|
2915
2926
|
var useMessageStore2 = (runtime) => {
|
2916
|
-
const [store] =
|
2917
|
-
|
2927
|
+
const [store] = useState11(() => create11(() => runtime.getState()));
|
2928
|
+
useEffect16(() => {
|
2918
2929
|
const updateState = () => writableStore(store).setState(runtime.getState(), true);
|
2919
2930
|
updateState();
|
2920
2931
|
return runtime.subscribe(updateState);
|
@@ -2922,13 +2933,13 @@ var useMessageStore2 = (runtime) => {
|
|
2922
2933
|
return store;
|
2923
2934
|
};
|
2924
2935
|
var useMessageUtilsStore2 = () => {
|
2925
|
-
const [store] =
|
2936
|
+
const [store] = useState11(() => makeMessageUtilsStore());
|
2926
2937
|
return store;
|
2927
2938
|
};
|
2928
2939
|
var useEditComposerStore2 = (useMessageRuntime2) => {
|
2929
2940
|
const runtime = useMessageRuntime2.getState().composer;
|
2930
|
-
const [store] =
|
2931
|
-
|
2941
|
+
const [store] = useState11(() => create11(() => runtime.getState()));
|
2942
|
+
useEffect16(() => {
|
2932
2943
|
const updateState = () => writableStore(store).setState(runtime.getState());
|
2933
2944
|
updateState();
|
2934
2945
|
return runtime.subscribe(updateState);
|
@@ -2943,7 +2954,7 @@ var MessageRuntimeProvider = ({
|
|
2943
2954
|
const useMessage2 = useMessageStore2(runtime);
|
2944
2955
|
const useMessageUtils2 = useMessageUtilsStore2();
|
2945
2956
|
const useEditComposer2 = useEditComposerStore2(useMessageRuntime2);
|
2946
|
-
const [context] =
|
2957
|
+
const [context] = useState11(() => {
|
2947
2958
|
return { useMessageRuntime: useMessageRuntime2, useMessage: useMessage2, useMessageUtils: useMessageUtils2, useEditComposer: useEditComposer2 };
|
2948
2959
|
});
|
2949
2960
|
return /* @__PURE__ */ jsx32(MessageContext.Provider, { value: context, children });
|
@@ -3050,7 +3061,7 @@ var subscribeToMainThread = (runtime, callback) => {
|
|
3050
3061
|
};
|
3051
3062
|
|
3052
3063
|
// src/runtimes/local/useLocalRuntime.tsx
|
3053
|
-
import { useEffect as
|
3064
|
+
import { useEffect as useEffect17, useMemo as useMemo11, useState as useState13 } from "react";
|
3054
3065
|
|
3055
3066
|
// src/utils/ProxyConfigProvider.ts
|
3056
3067
|
var ProxyConfigProvider = class {
|
@@ -4091,7 +4102,7 @@ var streamUtils = {
|
|
4091
4102
|
};
|
4092
4103
|
|
4093
4104
|
// src/runtimes/edge/useEdgeRuntime.ts
|
4094
|
-
import { useState as
|
4105
|
+
import { useState as useState12 } from "react";
|
4095
4106
|
|
4096
4107
|
// src/runtimes/edge/streams/assistantDecoderStream.ts
|
4097
4108
|
function assistantDecoderStream() {
|
@@ -4272,7 +4283,7 @@ var splitLocalRuntimeOptions = (options) => {
|
|
4272
4283
|
// src/runtimes/edge/useEdgeRuntime.ts
|
4273
4284
|
var useEdgeRuntime = (options) => {
|
4274
4285
|
const { localRuntimeOptions, otherOptions } = splitLocalRuntimeOptions(options);
|
4275
|
-
const [adapter] =
|
4286
|
+
const [adapter] = useState12(() => new EdgeChatAdapter(otherOptions));
|
4276
4287
|
return useLocalRuntime(adapter, localRuntimeOptions);
|
4277
4288
|
};
|
4278
4289
|
|
@@ -4812,15 +4823,15 @@ var useLocalRuntime = (adapter, options = {}) => {
|
|
4812
4823
|
chatModel: adapter
|
4813
4824
|
}
|
4814
4825
|
};
|
4815
|
-
const [runtime] =
|
4816
|
-
|
4826
|
+
const [runtime] = useState13(() => new LocalRuntimeCore(opt));
|
4827
|
+
useEffect17(() => {
|
4817
4828
|
runtime.setOptions(opt);
|
4818
4829
|
});
|
4819
4830
|
return useMemo11(() => LocalRuntimeImpl.create(runtime), [runtime]);
|
4820
4831
|
};
|
4821
4832
|
|
4822
4833
|
// src/runtimes/external-store/useExternalStoreRuntime.tsx
|
4823
|
-
import { useEffect as
|
4834
|
+
import { useEffect as useEffect18, useMemo as useMemo12, useState as useState14 } from "react";
|
4824
4835
|
|
4825
4836
|
// src/runtimes/external-store/ExternalStoreThreadManagementAdapter.tsx
|
4826
4837
|
var EMPTY_ARRAY2 = Object.freeze([]);
|
@@ -5206,8 +5217,8 @@ var ExternalStoreRuntimeCore = class extends BaseAssistantRuntimeCore {
|
|
5206
5217
|
|
5207
5218
|
// src/runtimes/external-store/useExternalStoreRuntime.tsx
|
5208
5219
|
var useExternalStoreRuntime = (store) => {
|
5209
|
-
const [runtime] =
|
5210
|
-
|
5220
|
+
const [runtime] = useState14(() => new ExternalStoreRuntimeCore(store));
|
5221
|
+
useEffect18(() => {
|
5211
5222
|
runtime.setStore(store);
|
5212
5223
|
});
|
5213
5224
|
return useMemo12(
|
@@ -5363,7 +5374,7 @@ var shallowArrayEqual = (a, b) => {
|
|
5363
5374
|
};
|
5364
5375
|
|
5365
5376
|
// src/runtimes/dangerous-in-browser/useDangerousInBrowserRuntime.ts
|
5366
|
-
import { useState as
|
5377
|
+
import { useState as useState15 } from "react";
|
5367
5378
|
|
5368
5379
|
// src/runtimes/dangerous-in-browser/DangerousInBrowserAdapter.ts
|
5369
5380
|
var DangerousInBrowserAdapter = class {
|
@@ -5392,7 +5403,7 @@ var DangerousInBrowserAdapter = class {
|
|
5392
5403
|
// src/runtimes/dangerous-in-browser/useDangerousInBrowserRuntime.ts
|
5393
5404
|
var useDangerousInBrowserRuntime = (options) => {
|
5394
5405
|
const { localRuntimeOptions, otherOptions } = splitLocalRuntimeOptions(options);
|
5395
|
-
const [adapter] =
|
5406
|
+
const [adapter] = useState15(() => new DangerousInBrowserAdapter(otherOptions));
|
5396
5407
|
return useLocalRuntime(adapter, localRuntimeOptions);
|
5397
5408
|
};
|
5398
5409
|
|
@@ -5978,8 +5989,8 @@ CircleStopIcon.displayName = "CircleStopIcon";
|
|
5978
5989
|
// src/ui/attachment.tsx
|
5979
5990
|
import {
|
5980
5991
|
forwardRef as forwardRef28,
|
5981
|
-
useEffect as
|
5982
|
-
useState as
|
5992
|
+
useEffect as useEffect19,
|
5993
|
+
useState as useState16
|
5983
5994
|
} from "react";
|
5984
5995
|
import { CircleXIcon, FileIcon } from "lucide-react";
|
5985
5996
|
|
@@ -6022,8 +6033,8 @@ var AttachmentRoot = withDefaults(attachment_exports.Root, {
|
|
6022
6033
|
});
|
6023
6034
|
AttachmentRoot.displayName = "AttachmentRoot";
|
6024
6035
|
var useFileSrc = (file) => {
|
6025
|
-
const [src, setSrc] =
|
6026
|
-
|
6036
|
+
const [src, setSrc] = useState16(void 0);
|
6037
|
+
useEffect19(() => {
|
6027
6038
|
if (!file) {
|
6028
6039
|
setSrc(void 0);
|
6029
6040
|
return;
|
@@ -6047,7 +6058,7 @@ var useAttachmentSrc = () => {
|
|
6047
6058
|
return useFileSrc(file) ?? src;
|
6048
6059
|
};
|
6049
6060
|
var AttachmentPreview = ({ src }) => {
|
6050
|
-
const [isLoaded, setIsLoaded] =
|
6061
|
+
const [isLoaded, setIsLoaded] = useState16(false);
|
6051
6062
|
return (
|
6052
6063
|
// eslint-disable-next-line @next/next/no-img-element
|
6053
6064
|
/* @__PURE__ */ jsx46(
|
@@ -6733,6 +6744,7 @@ export {
|
|
6733
6744
|
useEditComposerStore,
|
6734
6745
|
useExternalMessageConverter,
|
6735
6746
|
useExternalStoreRuntime,
|
6747
|
+
useInlineRender,
|
6736
6748
|
useLocalRuntime,
|
6737
6749
|
useMessage,
|
6738
6750
|
useMessageContext,
|