@assistant-ui/react 0.0.15 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js CHANGED
@@ -33,6 +33,7 @@ __export(src_exports, {
33
33
  ActionBarPrimitive: () => actionBar_exports,
34
34
  BranchPickerPrimitive: () => branchPicker_exports,
35
35
  ComposerPrimitive: () => composer_exports,
36
+ ContentPartPrimitive: () => contentPart_exports,
36
37
  MessagePrimitive: () => message_exports,
37
38
  ThreadPrimitive: () => thread_exports,
38
39
  VercelAIAssistantProvider: () => VercelAIAssistantProvider,
@@ -113,7 +114,7 @@ var import_react3 = require("react");
113
114
  var useOnResizeContent = (ref, callback) => {
114
115
  const callbackRef = (0, import_react3.useRef)(callback);
115
116
  callbackRef.current = callback;
116
- (0, import_react3.useLayoutEffect)(() => {
117
+ (0, import_react3.useEffect)(() => {
117
118
  const el = ref.current;
118
119
  if (!el) return;
119
120
  const resizeObserver = new ResizeObserver(() => {
@@ -217,7 +218,9 @@ var MessageContext = (0, import_react6.createContext)(null);
217
218
  var useMessageContext = () => {
218
219
  const context = (0, import_react6.useContext)(MessageContext);
219
220
  if (!context)
220
- throw new Error("This component must be used within a MessageProvider.");
221
+ throw new Error(
222
+ "This component must be used within a MessagePrimitive.Provider."
223
+ );
221
224
  return context;
222
225
  };
223
226
 
@@ -250,6 +253,7 @@ var message_exports = {};
250
253
  __export(message_exports, {
251
254
  Content: () => MessageContent,
252
255
  If: () => MessageIf,
256
+ Loading: () => MessageLoading,
253
257
  Provider: () => MessageProvider,
254
258
  Root: () => MessageRoot
255
259
  });
@@ -329,8 +333,12 @@ var useMessageContext2 = () => {
329
333
  parentId: null,
330
334
  branches: [],
331
335
  isLast: false,
336
+ loadingIndicator: null,
332
337
  isCopied: false,
333
338
  isHovering: false,
339
+ setLoadingIndicator: (value) => {
340
+ set({ loadingIndicator: value });
341
+ },
334
342
  setIsCopied: (value) => {
335
343
  set({ isCopied: value });
336
344
  },
@@ -432,10 +440,94 @@ var MessageIf = ({ children, ...query }) => {
432
440
  return result ? children : null;
433
441
  };
434
442
 
435
- // src/primitives/message/MessageContent.tsx
443
+ // src/utils/context/combined/useCombinedStore.ts
444
+ var import_react11 = require("react");
445
+
446
+ // src/utils/context/combined/createCombinedStore.ts
447
+ var import_react10 = require("react");
448
+ var createCombinedStore = (stores) => {
449
+ const subscribe = (callback) => {
450
+ const unsubscribes = stores.map((store) => store.subscribe(callback));
451
+ return () => {
452
+ for (const unsub of unsubscribes) {
453
+ unsub();
454
+ }
455
+ };
456
+ };
457
+ return (selector) => {
458
+ const getSnapshot = () => selector(...stores.map((store) => store.getState()));
459
+ return (0, import_react10.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
460
+ };
461
+ };
462
+
463
+ // src/utils/context/combined/useCombinedStore.ts
464
+ var useCombinedStore = (stores, selector) => {
465
+ const useCombined = (0, import_react11.useMemo)(() => createCombinedStore(stores), stores);
466
+ return useCombined(selector);
467
+ };
468
+
469
+ // src/utils/context/useContentPartContext.ts
470
+ var import_react12 = require("react");
471
+ var ContentPartContext = (0, import_react12.createContext)(null);
472
+ var useContentPartContext = () => {
473
+ const context = (0, import_react12.useContext)(ContentPartContext);
474
+ if (!context)
475
+ throw new Error(
476
+ "This component must be used within a ContentPartPrimitive.Provider."
477
+ );
478
+ return context;
479
+ };
480
+
481
+ // src/primitives/contentPart/ContentPartLoadingIndicator.tsx
482
+ var ContentPartLoadingIndicator = () => {
483
+ const { useMessage } = useMessageContext();
484
+ const { useContentPart } = useContentPartContext();
485
+ const loadingIndicator = useCombinedStore(
486
+ [useMessage, useContentPart],
487
+ (m, c) => c.isLoading ? m.loadingIndicator : null
488
+ );
489
+ return loadingIndicator;
490
+ };
491
+
492
+ // src/primitives/contentPart/ContentPartProvider.tsx
493
+ var import_react13 = require("react");
494
+ var import_zustand3 = require("zustand");
436
495
  var import_jsx_runtime6 = require("react/jsx-runtime");
496
+ var useContentPartContext2 = () => {
497
+ const [context] = (0, import_react13.useState)(() => {
498
+ const useContentPart = (0, import_zustand3.create)(() => ({
499
+ part: null,
500
+ isLoading: false
501
+ }));
502
+ return { useContentPart };
503
+ });
504
+ return context;
505
+ };
506
+ var ContentPartProvider = ({
507
+ part,
508
+ isLoading,
509
+ children
510
+ }) => {
511
+ const context = useContentPartContext2();
512
+ (0, import_react13.useMemo)(() => {
513
+ context.useContentPart.setState(
514
+ {
515
+ part,
516
+ isLoading
517
+ },
518
+ true
519
+ );
520
+ }, [context, part, isLoading]);
521
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ContentPartContext.Provider, { value: context, children });
522
+ };
523
+
524
+ // src/primitives/message/MessageContent.tsx
525
+ var import_jsx_runtime7 = require("react/jsx-runtime");
437
526
  var defaultComponents = {
438
- Text: ({ part }) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, { children: part.text }),
527
+ Text: ({ part }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
528
+ part.text,
529
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ContentPartLoadingIndicator, {})
530
+ ] }),
439
531
  Image: () => null,
440
532
  UI: ({ part }) => part.display,
441
533
  tools: {
@@ -450,29 +542,61 @@ var MessageContent = ({
450
542
  tools: { by_name = {}, Fallback = defaultComponents.tools.Fallback } = {}
451
543
  } = {}
452
544
  }) => {
545
+ const { useThread } = useAssistantContext();
453
546
  const { useMessage } = useMessageContext();
454
547
  const content = useMessage((s) => s.message.content);
455
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, { children: content.map((part, i) => {
548
+ const isLoading = useCombinedStore(
549
+ [useThread, useMessage],
550
+ (t, s) => s.isLast && t.isRunning
551
+ );
552
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx_runtime7.Fragment, { children: content.map((part, i) => {
456
553
  const key = i;
457
- switch (part.type) {
554
+ const type = part.type;
555
+ let component = null;
556
+ switch (type) {
458
557
  case "text":
459
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { part }, key);
558
+ component = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { part });
559
+ break;
460
560
  case "image":
461
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Image, { part }, key);
561
+ component = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Image, { part });
562
+ break;
462
563
  case "ui":
463
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UI, { part }, key);
564
+ component = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(UI, { part });
565
+ break;
464
566
  case "tool-call": {
465
567
  const Tool = by_name[part.name] || Fallback;
466
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Tool, { part }, key);
568
+ component = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Tool, { part });
569
+ break;
467
570
  }
468
571
  default:
469
- return null;
572
+ throw new Error(`Unknown content part type: ${type}`);
470
573
  }
574
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
575
+ ContentPartProvider,
576
+ {
577
+ part,
578
+ isLoading: i === content.length - 1 && isLoading,
579
+ children: component
580
+ },
581
+ key
582
+ );
471
583
  }) });
472
584
  };
473
585
 
586
+ // src/primitives/message/MessageLoading.tsx
587
+ var import_react_primitive4 = require("@radix-ui/react-primitive");
588
+ var import_react14 = require("react");
589
+ var import_jsx_runtime8 = require("react/jsx-runtime");
590
+ var MessageLoading = (0, import_react14.forwardRef)((props, ref) => {
591
+ const { useMessage } = useMessageContext();
592
+ (0, import_react14.useMemo)(() => {
593
+ useMessage.getState().setLoadingIndicator(/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_primitive4.Primitive.div, { ...props, ref }));
594
+ }, [useMessage, props, ref]);
595
+ return null;
596
+ });
597
+
474
598
  // src/primitives/thread/ThreadMessages.tsx
475
- var import_jsx_runtime7 = require("react/jsx-runtime");
599
+ var import_jsx_runtime9 = require("react/jsx-runtime");
476
600
  var getComponents = (components) => {
477
601
  return {
478
602
  EditComposer: components.EditComposer ?? components.UserMessage ?? components.Message,
@@ -486,19 +610,19 @@ var ThreadMessages = ({ components }) => {
486
610
  const messages = thread.messages;
487
611
  const { UserMessage, EditComposer, AssistantMessage } = getComponents(components);
488
612
  if (messages.length === 0) return null;
489
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx_runtime7.Fragment, { children: messages.map((message, idx) => {
613
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children: messages.map((message, idx) => {
490
614
  const parentId = messages[idx - 1]?.id ?? null;
491
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
615
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
492
616
  MessageProvider,
493
617
  {
494
618
  message,
495
619
  parentId,
496
620
  children: [
497
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(MessageIf, { user: true, children: [
498
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ComposerIf, { editing: false, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(UserMessage, {}) }),
499
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ComposerIf, { editing: true, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(EditComposer, {}) })
621
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(MessageIf, { user: true, children: [
622
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ComposerIf, { editing: false, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(UserMessage, {}) }),
623
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ComposerIf, { editing: true, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(EditComposer, {}) })
500
624
  ] }),
501
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(MessageIf, { assistant: true, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(AssistantMessage, {}) })
625
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(MessageIf, { assistant: true, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AssistantMessage, {}) })
502
626
  ]
503
627
  },
504
628
  parentId ?? "__ROOT__"
@@ -508,17 +632,17 @@ var ThreadMessages = ({ components }) => {
508
632
 
509
633
  // src/primitives/thread/ThreadScrollToBottom.tsx
510
634
  var import_primitive3 = require("@radix-ui/primitive");
511
- var import_react_primitive4 = require("@radix-ui/react-primitive");
512
- var import_react10 = require("react");
513
- var import_jsx_runtime8 = require("react/jsx-runtime");
514
- var ThreadScrollToBottom = (0, import_react10.forwardRef)(({ onClick, ...rest }, ref) => {
635
+ var import_react_primitive5 = require("@radix-ui/react-primitive");
636
+ var import_react15 = require("react");
637
+ var import_jsx_runtime10 = require("react/jsx-runtime");
638
+ var ThreadScrollToBottom = (0, import_react15.forwardRef)(({ onClick, ...rest }, ref) => {
515
639
  const { useViewport } = useAssistantContext();
516
640
  const isAtBottom = useViewport((s) => s.isAtBottom);
517
641
  const handleScrollToBottom = () => {
518
642
  useViewport.getState().scrollToBottom();
519
643
  };
520
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
521
- import_react_primitive4.Primitive.button,
644
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
645
+ import_react_primitive5.Primitive.button,
522
646
  {
523
647
  ...rest,
524
648
  disabled: isAtBottom,
@@ -530,10 +654,10 @@ var ThreadScrollToBottom = (0, import_react10.forwardRef)(({ onClick, ...rest },
530
654
 
531
655
  // src/primitives/thread/ThreadSuggestion.tsx
532
656
  var import_primitive4 = require("@radix-ui/primitive");
533
- var import_react_primitive5 = require("@radix-ui/react-primitive");
534
- var import_react11 = require("react");
535
- var import_jsx_runtime9 = require("react/jsx-runtime");
536
- var ThreadSuggestion = (0, import_react11.forwardRef)(({ onClick, prompt, method, autoSend: send, ...rest }, ref) => {
657
+ var import_react_primitive6 = require("@radix-ui/react-primitive");
658
+ var import_react16 = require("react");
659
+ var import_jsx_runtime11 = require("react/jsx-runtime");
660
+ var ThreadSuggestion = (0, import_react16.forwardRef)(({ onClick, prompt, method, autoSend: send, ...rest }, ref) => {
537
661
  const { useThread, useComposer } = useAssistantContext();
538
662
  const isDisabled = useThread((t) => t.isRunning);
539
663
  const handleApplySuggestion = () => {
@@ -544,8 +668,8 @@ var ThreadSuggestion = (0, import_react11.forwardRef)(({ onClick, prompt, method
544
668
  composer.send();
545
669
  }
546
670
  };
547
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
548
- import_react_primitive5.Primitive.button,
671
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
672
+ import_react_primitive6.Primitive.button,
549
673
  {
550
674
  ...rest,
551
675
  disabled: isDisabled,
@@ -568,14 +692,14 @@ __export(composer_exports, {
568
692
  // src/primitives/composer/ComposerRoot.tsx
569
693
  var import_primitive5 = require("@radix-ui/primitive");
570
694
  var import_react_compose_refs2 = require("@radix-ui/react-compose-refs");
571
- var import_react_primitive6 = require("@radix-ui/react-primitive");
572
- var import_react12 = require("react");
573
- var import_jsx_runtime10 = require("react/jsx-runtime");
574
- var ComposerRoot = (0, import_react12.forwardRef)(
695
+ var import_react_primitive7 = require("@radix-ui/react-primitive");
696
+ var import_react17 = require("react");
697
+ var import_jsx_runtime12 = require("react/jsx-runtime");
698
+ var ComposerRoot = (0, import_react17.forwardRef)(
575
699
  ({ onSubmit, ...rest }, forwardedRef) => {
576
700
  const { useViewport } = useAssistantContext();
577
701
  const { useComposer } = useComposerContext();
578
- const formRef = (0, import_react12.useRef)(null);
702
+ const formRef = (0, import_react17.useRef)(null);
579
703
  const ref = (0, import_react_compose_refs2.useComposedRefs)(forwardedRef, formRef);
580
704
  const handleSubmit = (e) => {
581
705
  const composerState = useComposer.getState();
@@ -584,8 +708,8 @@ var ComposerRoot = (0, import_react12.forwardRef)(
584
708
  composerState.send();
585
709
  useViewport.getState().scrollToBottom();
586
710
  };
587
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
588
- import_react_primitive6.Primitive.form,
711
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
712
+ import_react_primitive7.Primitive.form,
589
713
  {
590
714
  ...rest,
591
715
  ref,
@@ -599,10 +723,10 @@ var ComposerRoot = (0, import_react12.forwardRef)(
599
723
  var import_primitive6 = require("@radix-ui/primitive");
600
724
  var import_react_compose_refs3 = require("@radix-ui/react-compose-refs");
601
725
  var import_react_slot = require("@radix-ui/react-slot");
602
- var import_react13 = require("react");
726
+ var import_react18 = require("react");
603
727
  var import_react_textarea_autosize = __toESM(require("react-textarea-autosize"));
604
- var import_jsx_runtime11 = require("react/jsx-runtime");
605
- var ComposerInput = (0, import_react13.forwardRef)(
728
+ var import_jsx_runtime13 = require("react/jsx-runtime");
729
+ var ComposerInput = (0, import_react18.forwardRef)(
606
730
  ({ autoFocus = false, asChild, disabled, onChange, onKeyDown, ...rest }, forwardedRef) => {
607
731
  const { useThread, useViewport } = useAssistantContext();
608
732
  const { useComposer, type } = useComposerContext();
@@ -627,10 +751,10 @@ var ComposerInput = (0, import_react13.forwardRef)(
627
751
  }
628
752
  }
629
753
  };
630
- const textareaRef = (0, import_react13.useRef)(null);
754
+ const textareaRef = (0, import_react18.useRef)(null);
631
755
  const ref = (0, import_react_compose_refs3.useComposedRefs)(forwardedRef, textareaRef);
632
756
  const autoFocusEnabled = autoFocus && !disabled;
633
- const focus = (0, import_react13.useCallback)(() => {
757
+ const focus = (0, import_react18.useCallback)(() => {
634
758
  const textarea = textareaRef.current;
635
759
  if (!textarea || !autoFocusEnabled) return;
636
760
  textarea.focus();
@@ -639,13 +763,13 @@ var ComposerInput = (0, import_react13.forwardRef)(
639
763
  textareaRef.current.value.length
640
764
  );
641
765
  }, [autoFocusEnabled]);
642
- (0, import_react13.useEffect)(() => focus(), [focus]);
766
+ (0, import_react18.useEffect)(() => focus(), [focus]);
643
767
  useOnScrollToBottom(() => {
644
768
  if (type === "assistant") {
645
769
  focus();
646
770
  }
647
771
  });
648
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
772
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
649
773
  Component,
650
774
  {
651
775
  value,
@@ -664,15 +788,15 @@ var ComposerInput = (0, import_react13.forwardRef)(
664
788
  );
665
789
 
666
790
  // src/primitives/composer/ComposerSend.tsx
667
- var import_react_primitive7 = require("@radix-ui/react-primitive");
668
- var import_react14 = require("react");
669
- var import_jsx_runtime12 = require("react/jsx-runtime");
670
- var ComposerSend = (0, import_react14.forwardRef)(
791
+ var import_react_primitive8 = require("@radix-ui/react-primitive");
792
+ var import_react19 = require("react");
793
+ var import_jsx_runtime14 = require("react/jsx-runtime");
794
+ var ComposerSend = (0, import_react19.forwardRef)(
671
795
  ({ disabled, ...rest }, ref) => {
672
796
  const { useComposer } = useComposerContext();
673
797
  const hasValue = useComposer((c) => c.isEditing && c.value.length > 0);
674
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
675
- import_react_primitive7.Primitive.button,
798
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
799
+ import_react_primitive8.Primitive.button,
676
800
  {
677
801
  type: "submit",
678
802
  ...rest,
@@ -685,16 +809,16 @@ var ComposerSend = (0, import_react14.forwardRef)(
685
809
 
686
810
  // src/primitives/composer/ComposerCancel.tsx
687
811
  var import_primitive7 = require("@radix-ui/primitive");
688
- var import_react_primitive8 = require("@radix-ui/react-primitive");
689
- var import_react15 = require("react");
690
- var import_jsx_runtime13 = require("react/jsx-runtime");
691
- var ComposerCancel = (0, import_react15.forwardRef)(({ onClick, ...rest }, ref) => {
812
+ var import_react_primitive9 = require("@radix-ui/react-primitive");
813
+ var import_react20 = require("react");
814
+ var import_jsx_runtime15 = require("react/jsx-runtime");
815
+ var ComposerCancel = (0, import_react20.forwardRef)(({ onClick, ...rest }, ref) => {
692
816
  const { useComposer } = useComposerContext();
693
817
  const handleCancel = () => {
694
818
  useComposer.getState().cancel();
695
819
  };
696
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
697
- import_react_primitive8.Primitive.button,
820
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
821
+ import_react_primitive9.Primitive.button,
698
822
  {
699
823
  type: "button",
700
824
  ...rest,
@@ -714,32 +838,6 @@ __export(branchPicker_exports, {
714
838
  Root: () => BranchPickerRoot
715
839
  });
716
840
 
717
- // src/utils/context/combined/useCombinedStore.ts
718
- var import_react17 = require("react");
719
-
720
- // src/utils/context/combined/createCombinedStore.ts
721
- var import_react16 = require("react");
722
- var createCombinedStore = (stores) => {
723
- const subscribe = (callback) => {
724
- const unsubscribes = stores.map((store) => store.subscribe(callback));
725
- return () => {
726
- for (const unsub of unsubscribes) {
727
- unsub();
728
- }
729
- };
730
- };
731
- return (selector) => {
732
- const getSnapshot = () => selector(...stores.map((store) => store.getState()));
733
- return (0, import_react16.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
734
- };
735
- };
736
-
737
- // src/utils/context/combined/useCombinedStore.ts
738
- var useCombinedStore = (stores, selector) => {
739
- const useCombined = (0, import_react17.useMemo)(() => createCombinedStore(stores), stores);
740
- return useCombined(selector);
741
- };
742
-
743
841
  // src/actions/useGoToNextBranch.tsx
744
842
  var useGoToNextBranch = () => {
745
843
  const { useThread } = useAssistantContext();
@@ -757,15 +855,15 @@ var useGoToNextBranch = () => {
757
855
 
758
856
  // src/utils/createActionButton.tsx
759
857
  var import_primitive8 = require("@radix-ui/primitive");
760
- var import_react_primitive9 = require("@radix-ui/react-primitive");
761
- var import_react18 = require("react");
762
- var import_jsx_runtime14 = require("react/jsx-runtime");
858
+ var import_react_primitive10 = require("@radix-ui/react-primitive");
859
+ var import_react21 = require("react");
860
+ var import_jsx_runtime16 = require("react/jsx-runtime");
763
861
  var createActionButton = (useActionButton) => {
764
- return (0, import_react18.forwardRef)(
862
+ return (0, import_react21.forwardRef)(
765
863
  (props, forwardedRef) => {
766
864
  const onClick = useActionButton(props);
767
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
768
- import_react_primitive9.Primitive.button,
865
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
866
+ import_react_primitive10.Primitive.button,
769
867
  {
770
868
  type: "button",
771
869
  disabled: !onClick,
@@ -803,27 +901,27 @@ var useGoToPreviousBranch = () => {
803
901
  var BranchPickerPrevious = createActionButton(useGoToPreviousBranch);
804
902
 
805
903
  // src/primitives/branchPicker/BranchPickerCount.tsx
806
- var import_jsx_runtime15 = require("react/jsx-runtime");
904
+ var import_jsx_runtime17 = require("react/jsx-runtime");
807
905
  var BranchPickerCount = () => {
808
906
  const { useMessage } = useMessageContext();
809
907
  const branchCount = useMessage((s) => s.branches.length);
810
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_jsx_runtime15.Fragment, { children: branchCount });
908
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_jsx_runtime17.Fragment, { children: branchCount });
811
909
  };
812
910
 
813
911
  // src/primitives/branchPicker/BranchPickerNumber.tsx
814
- var import_jsx_runtime16 = require("react/jsx-runtime");
912
+ var import_jsx_runtime18 = require("react/jsx-runtime");
815
913
  var BranchPickerNumber = () => {
816
914
  const { useMessage } = useMessageContext();
817
915
  const branchIdx = useMessage((s) => s.branches.indexOf(s.message.id));
818
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_jsx_runtime16.Fragment, { children: branchIdx + 1 });
916
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_jsx_runtime18.Fragment, { children: branchIdx + 1 });
819
917
  };
820
918
 
821
919
  // src/primitives/branchPicker/BranchPickerRoot.tsx
822
- var import_react_primitive10 = require("@radix-ui/react-primitive");
823
- var import_react19 = require("react");
824
- var import_jsx_runtime17 = require("react/jsx-runtime");
825
- var BranchPickerRoot = (0, import_react19.forwardRef)(({ hideWhenSingleBranch, ...rest }, ref) => {
826
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(MessageIf, { hasBranches: hideWhenSingleBranch ? true : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_primitive10.Primitive.div, { ...rest, ref }) });
920
+ var import_react_primitive11 = require("@radix-ui/react-primitive");
921
+ var import_react22 = require("react");
922
+ var import_jsx_runtime19 = require("react/jsx-runtime");
923
+ var BranchPickerRoot = (0, import_react22.forwardRef)(({ hideWhenSingleBranch, ...rest }, ref) => {
924
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(MessageIf, { hasBranches: hideWhenSingleBranch ? true : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react_primitive11.Primitive.div, { ...rest, ref }) });
827
925
  });
828
926
 
829
927
  // src/primitives/actionBar/index.ts
@@ -836,10 +934,10 @@ __export(actionBar_exports, {
836
934
  });
837
935
 
838
936
  // src/primitives/actionBar/ActionBarRoot.tsx
839
- var import_react_primitive11 = require("@radix-ui/react-primitive");
840
- var import_react20 = require("react");
841
- var import_jsx_runtime18 = require("react/jsx-runtime");
842
- var ActionBarRoot = (0, import_react20.forwardRef)(({ hideWhenRunning, autohide, autohideFloat, ...rest }, ref) => {
937
+ var import_react_primitive12 = require("@radix-ui/react-primitive");
938
+ var import_react23 = require("react");
939
+ var import_jsx_runtime20 = require("react/jsx-runtime");
940
+ var ActionBarRoot = (0, import_react23.forwardRef)(({ hideWhenRunning, autohide, autohideFloat, ...rest }, ref) => {
843
941
  const { useThread } = useAssistantContext();
844
942
  const { useMessage } = useMessageContext();
845
943
  const hideAndfloatStatus = useCombinedStore(
@@ -855,8 +953,8 @@ var ActionBarRoot = (0, import_react20.forwardRef)(({ hideWhenRunning, autohide,
855
953
  }
856
954
  );
857
955
  if (hideAndfloatStatus === "hidden" /* Hidden */) return null;
858
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
859
- import_react_primitive11.Primitive.div,
956
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
957
+ import_react_primitive12.Primitive.div,
860
958
  {
861
959
  "data-floating": hideAndfloatStatus === "floating" /* Floating */,
862
960
  ...rest,
@@ -924,18 +1022,25 @@ var useBeginMessageEdit = () => {
924
1022
  // src/primitives/actionBar/ActionBarEdit.tsx
925
1023
  var ActionBarEdit = createActionButton(useBeginMessageEdit);
926
1024
 
1025
+ // src/primitives/contentPart/index.ts
1026
+ var contentPart_exports = {};
1027
+ __export(contentPart_exports, {
1028
+ LoadingIndicator: () => ContentPartLoadingIndicator,
1029
+ Provider: () => ContentPartProvider
1030
+ });
1031
+
927
1032
  // src/adapters/vercel/VercelAIAssistantProvider.tsx
928
- var import_react23 = require("react");
1033
+ var import_react26 = require("react");
929
1034
 
930
1035
  // src/adapters/vercel/useDummyAIAssistantContext.tsx
931
- var import_react21 = require("react");
932
- var import_zustand4 = require("zustand");
1036
+ var import_react24 = require("react");
1037
+ var import_zustand5 = require("zustand");
933
1038
 
934
1039
  // src/utils/context/stores/ViewportStore.tsx
935
- var import_zustand3 = require("zustand");
1040
+ var import_zustand4 = require("zustand");
936
1041
  var makeViewportStore = () => {
937
1042
  const scrollToBottomListeners = /* @__PURE__ */ new Set();
938
- return (0, import_zustand3.create)(() => ({
1043
+ return (0, import_zustand4.create)(() => ({
939
1044
  isAtBottom: true,
940
1045
  scrollToBottom: () => {
941
1046
  for (const listener of scrollToBottomListeners) {
@@ -953,7 +1058,7 @@ var makeViewportStore = () => {
953
1058
 
954
1059
  // src/adapters/vercel/useDummyAIAssistantContext.tsx
955
1060
  var makeDummyThreadStore = () => {
956
- return (0, import_zustand4.create)(() => ({
1061
+ return (0, import_zustand5.create)(() => ({
957
1062
  messages: [],
958
1063
  isRunning: false,
959
1064
  getBranches: () => {
@@ -974,7 +1079,7 @@ var makeDummyThreadStore = () => {
974
1079
  }));
975
1080
  };
976
1081
  var useDummyAIAssistantContext = () => {
977
- const [context] = (0, import_react21.useState)(() => {
1082
+ const [context] = (0, import_react24.useState)(() => {
978
1083
  const useThread = makeDummyThreadStore();
979
1084
  const useViewport = makeViewportStore();
980
1085
  const useComposer = makeThreadComposerStore(useThread);
@@ -984,7 +1089,7 @@ var useDummyAIAssistantContext = () => {
984
1089
  };
985
1090
 
986
1091
  // src/adapters/vercel/useVercelAIThreadState.tsx
987
- var import_react22 = require("react");
1092
+ var import_react25 = require("react");
988
1093
 
989
1094
  // src/adapters/MessageRepository.tsx
990
1095
  var import_non_secure = require("nanoid/non-secure");
@@ -1003,7 +1108,41 @@ var MessageRepository = class {
1003
1108
  messages = /* @__PURE__ */ new Map();
1004
1109
  // message_id -> item
1005
1110
  head = null;
1006
- rootChildren = [];
1111
+ root = {
1112
+ children: []
1113
+ };
1114
+ getFallbackChild(p) {
1115
+ const childId = p.children.at(-1);
1116
+ const child = childId ? this.messages.get(childId) : null;
1117
+ if (child === void 0)
1118
+ throw new Error(
1119
+ "MessageRepository(getFallbackChild): Child message not found. This is likely an internal bug in assistant-ui."
1120
+ );
1121
+ return child;
1122
+ }
1123
+ performOp(newParent, child, operation) {
1124
+ const parentOrRoot = child.prev ?? this.root;
1125
+ const newParentOrRoot = newParent ?? this.root;
1126
+ if (operation === "relink" && parentOrRoot === newParentOrRoot) return;
1127
+ if (operation !== "link") {
1128
+ parentOrRoot.children = parentOrRoot.children.filter(
1129
+ (m) => m !== child.current.id
1130
+ );
1131
+ if (child.prev?.next === child) {
1132
+ child.prev.next = this.getFallbackChild(child.prev);
1133
+ }
1134
+ }
1135
+ if (operation !== "cut") {
1136
+ newParentOrRoot.children = [
1137
+ ...newParentOrRoot.children,
1138
+ child.current.id
1139
+ ];
1140
+ if (newParent && (findHead(child) === this.head || newParent.next === null)) {
1141
+ newParent.next = child;
1142
+ }
1143
+ child.prev = newParent;
1144
+ }
1145
+ }
1007
1146
  getMessages() {
1008
1147
  const messages = new Array(this.head?.level ?? 0);
1009
1148
  for (let current = this.head; current; current = current.prev) {
@@ -1012,20 +1151,17 @@ var MessageRepository = class {
1012
1151
  return messages;
1013
1152
  }
1014
1153
  addOrUpdateMessage(parentId, message) {
1015
- const item = this.messages.get(message.id);
1016
- if (item) {
1017
- if ((item.prev?.current.id ?? null) !== parentId) {
1018
- this.deleteMessage(message.id);
1019
- } else {
1020
- item.current = message;
1021
- return;
1022
- }
1023
- }
1154
+ const existingItem = this.messages.get(message.id);
1024
1155
  const prev = parentId ? this.messages.get(parentId) : null;
1025
1156
  if (prev === void 0)
1026
1157
  throw new Error(
1027
1158
  "MessageRepository(addOrUpdateMessage): Parent message not found. This is likely an internal bug in assistant-ui."
1028
1159
  );
1160
+ if (existingItem) {
1161
+ existingItem.current = message;
1162
+ this.performOp(prev, existingItem, "relink");
1163
+ return;
1164
+ }
1029
1165
  const newItem = {
1030
1166
  prev,
1031
1167
  current: message,
@@ -1034,80 +1170,56 @@ var MessageRepository = class {
1034
1170
  level: prev ? prev.level + 1 : 0
1035
1171
  };
1036
1172
  this.messages.set(message.id, newItem);
1037
- if (prev) {
1038
- prev.children = [...prev.children, message.id];
1039
- prev.next = newItem;
1040
- } else {
1041
- this.rootChildren = [...this.rootChildren, message.id];
1042
- }
1043
1173
  if (this.head === prev) {
1044
1174
  this.head = newItem;
1045
1175
  }
1176
+ this.performOp(prev, newItem, "link");
1046
1177
  }
1047
- deleteMessage(messageId) {
1048
- const message = this.messages.get(messageId);
1049
- if (!message)
1050
- throw new Error(
1051
- "MessageRepository(deleteMessage): Message not found. This is likely an internal bug in assistant-ui."
1052
- );
1053
- if (message.children.length > 0) {
1054
- for (const child of message.children) {
1055
- this.deleteMessage(child);
1056
- }
1057
- }
1058
- this.messages.delete(messageId);
1059
- if (message.prev) {
1060
- message.prev.children = message.prev.children.filter(
1061
- (m) => m !== messageId
1062
- );
1063
- if (message.prev.next === message) {
1064
- const childId = message.prev.children.at(-1);
1065
- const child = childId ? this.messages.get(childId) : null;
1066
- if (child === void 0)
1067
- throw new Error(
1068
- "MessageRepository(deleteMessage): Child message not found. This is likely an internal bug in assistant-ui."
1069
- );
1070
- message.prev.next = child;
1071
- }
1072
- } else {
1073
- this.rootChildren = this.rootChildren.filter((m) => m !== messageId);
1074
- }
1075
- if (this.head === message) {
1076
- this.head = message.prev ? findHead(message.prev) : null;
1077
- }
1078
- }
1079
- getOptimisticId() {
1178
+ appendOptimisticMessage(parentId, message) {
1080
1179
  let optimisticId;
1081
1180
  do {
1082
1181
  optimisticId = generateOptimisticId();
1083
1182
  } while (this.messages.has(optimisticId));
1084
- return optimisticId;
1085
- }
1086
- commitOptimisticRun(parentId) {
1087
- const optimisticId = this.getOptimisticId();
1088
1183
  this.addOrUpdateMessage(parentId, {
1184
+ ...message,
1089
1185
  id: optimisticId,
1090
- role: "assistant",
1091
- content: [
1092
- {
1093
- type: "text",
1094
- text: ""
1095
- }
1096
- ],
1097
1186
  createdAt: /* @__PURE__ */ new Date()
1098
1187
  });
1099
1188
  return optimisticId;
1100
1189
  }
1190
+ deleteMessage(messageId, newParentId) {
1191
+ const message = this.messages.get(messageId);
1192
+ const newParent = newParentId ? this.messages.get(newParentId) : null;
1193
+ if (!message)
1194
+ throw new Error(
1195
+ "MessageRepository(deleteMessage): Optimistic message not found. This is likely an internal bug in assistant-ui."
1196
+ );
1197
+ if (newParent === void 0)
1198
+ throw new Error(
1199
+ "MessageRepository(deleteMessage): New message not found. This is likely an internal bug in assistant-ui."
1200
+ );
1201
+ for (const child of message.children) {
1202
+ const childMessage = this.messages.get(child);
1203
+ if (!childMessage)
1204
+ throw new Error(
1205
+ "MessageRepository(deleteMessage): Child message not found. This is likely an internal bug in assistant-ui."
1206
+ );
1207
+ this.performOp(newParent, childMessage, "relink");
1208
+ }
1209
+ this.messages.delete(messageId);
1210
+ if (this.head === message) {
1211
+ this.head = this.getFallbackChild(message.prev ?? this.root);
1212
+ }
1213
+ this.performOp(null, message, "cut");
1214
+ }
1101
1215
  getBranches(messageId) {
1102
1216
  const message = this.messages.get(messageId);
1103
1217
  if (!message)
1104
1218
  throw new Error(
1105
1219
  "MessageRepository(getBranches): Message not found. This is likely an internal bug in assistant-ui."
1106
1220
  );
1107
- if (message.prev) {
1108
- return message.prev.children;
1109
- }
1110
- return this.rootChildren;
1221
+ const { children } = message.prev ?? this.root;
1222
+ return children;
1111
1223
  }
1112
1224
  switchToBranch(messageId) {
1113
1225
  const message = this.messages.get(messageId);
@@ -1121,20 +1233,20 @@ var MessageRepository = class {
1121
1233
  this.head = findHead(message);
1122
1234
  }
1123
1235
  resetHead(messageId) {
1124
- if (messageId) {
1125
- const message = this.messages.get(messageId);
1126
- if (!message)
1127
- throw new Error(
1128
- "MessageRepository(resetHead): Branch not found. This is likely an internal bug in assistant-ui."
1129
- );
1130
- this.head = message;
1131
- for (let current = message; current; current = current.prev) {
1132
- if (current.prev) {
1133
- current.prev.next = current;
1134
- }
1135
- }
1136
- } else {
1236
+ if (messageId === null) {
1137
1237
  this.head = null;
1238
+ return;
1239
+ }
1240
+ const message = this.messages.get(messageId);
1241
+ if (!message)
1242
+ throw new Error(
1243
+ "MessageRepository(resetHead): Branch not found. This is likely an internal bug in assistant-ui."
1244
+ );
1245
+ this.head = message;
1246
+ for (let current = message; current; current = current.prev) {
1247
+ if (current.prev) {
1248
+ current.prev.next = current;
1249
+ }
1138
1250
  }
1139
1251
  }
1140
1252
  };
@@ -1198,12 +1310,12 @@ var getIsRunning = (vercel) => {
1198
1310
  return vercel.status === "in_progress";
1199
1311
  };
1200
1312
  var useVercelAIThreadState = (vercel) => {
1201
- const [data] = (0, import_react22.useState)(() => new MessageRepository());
1202
- const vercelRef = (0, import_react22.useRef)(vercel);
1313
+ const [data] = (0, import_react25.useState)(() => new MessageRepository());
1314
+ const vercelRef = (0, import_react25.useRef)(vercel);
1203
1315
  vercelRef.current = vercel;
1204
1316
  const isRunning = getIsRunning(vercelRef.current);
1205
- const assistantOptimisticIdRef = (0, import_react22.useRef)(null);
1206
- const messages = (0, import_react22.useMemo)(() => {
1317
+ const assistantOptimisticIdRef = (0, import_react25.useRef)(null);
1318
+ const messages = (0, import_react25.useMemo)(() => {
1207
1319
  const vm = converter.convertMessages(vercel.messages);
1208
1320
  for (let i = 0; i < vm.length; i++) {
1209
1321
  const message = vm[i];
@@ -1211,24 +1323,28 @@ var useVercelAIThreadState = (vercel) => {
1211
1323
  data.addOrUpdateMessage(parent?.id ?? null, message);
1212
1324
  }
1213
1325
  if (assistantOptimisticIdRef.current) {
1214
- data.deleteMessage(assistantOptimisticIdRef.current);
1326
+ data.deleteMessage(assistantOptimisticIdRef.current, null);
1215
1327
  assistantOptimisticIdRef.current = null;
1216
1328
  }
1217
1329
  if (hasUpcomingMessage(isRunning, vm)) {
1218
- assistantOptimisticIdRef.current = data.commitOptimisticRun(
1219
- vm.at(-1)?.id ?? null
1330
+ assistantOptimisticIdRef.current = data.appendOptimisticMessage(
1331
+ vm.at(-1)?.id ?? null,
1332
+ {
1333
+ role: "assistant",
1334
+ content: [{ type: "text", text: "" }]
1335
+ }
1220
1336
  );
1221
1337
  }
1222
1338
  data.resetHead(assistantOptimisticIdRef.current ?? vm.at(-1)?.id ?? null);
1223
1339
  return data.getMessages();
1224
1340
  }, [data, isRunning, vercel.messages]);
1225
- const getBranches2 = (0, import_react22.useCallback)(
1341
+ const getBranches2 = (0, import_react25.useCallback)(
1226
1342
  (messageId) => {
1227
1343
  return data.getBranches(messageId);
1228
1344
  },
1229
1345
  [data]
1230
1346
  );
1231
- const switchToBranch2 = (0, import_react22.useCallback)(
1347
+ const switchToBranch2 = (0, import_react25.useCallback)(
1232
1348
  (messageId) => {
1233
1349
  data.switchToBranch(messageId);
1234
1350
  vercelRef.current.setMessages(
@@ -1237,7 +1353,7 @@ var useVercelAIThreadState = (vercel) => {
1237
1353
  },
1238
1354
  [data]
1239
1355
  );
1240
- const startRun = (0, import_react22.useCallback)(async (parentId) => {
1356
+ const startRun = (0, import_react25.useCallback)(async (parentId) => {
1241
1357
  const reloadMaybe = "reload" in vercelRef.current ? vercelRef.current.reload : void 0;
1242
1358
  if (!reloadMaybe)
1243
1359
  throw new Error(
@@ -1250,7 +1366,7 @@ var useVercelAIThreadState = (vercel) => {
1250
1366
  vercelRef.current.setMessages(newMessages);
1251
1367
  await reloadMaybe();
1252
1368
  }, []);
1253
- const append = (0, import_react22.useCallback)(async (message) => {
1369
+ const append = (0, import_react25.useCallback)(async (message) => {
1254
1370
  if (message.content.length !== 1 || message.content[0]?.type !== "text")
1255
1371
  throw new Error("Only text content is supported by Vercel AI SDK.");
1256
1372
  const newMessages = sliceMessagesUntil(
@@ -1263,14 +1379,14 @@ var useVercelAIThreadState = (vercel) => {
1263
1379
  content: message.content[0].text
1264
1380
  });
1265
1381
  }, []);
1266
- const cancelRun2 = (0, import_react22.useCallback)(() => {
1382
+ const cancelRun2 = (0, import_react25.useCallback)(() => {
1267
1383
  const lastMessage = vercelRef.current.messages.at(-1);
1268
1384
  vercelRef.current.stop();
1269
1385
  if (lastMessage?.role === "user") {
1270
1386
  vercelRef.current.setInput(lastMessage.content);
1271
1387
  }
1272
1388
  }, []);
1273
- return (0, import_react22.useMemo)(
1389
+ return (0, import_react25.useMemo)(
1274
1390
  () => ({
1275
1391
  isRunning,
1276
1392
  messages,
@@ -1293,7 +1409,7 @@ var useVercelAIThreadState = (vercel) => {
1293
1409
  };
1294
1410
 
1295
1411
  // src/adapters/vercel/VercelAIAssistantProvider.tsx
1296
- var import_jsx_runtime19 = require("react/jsx-runtime");
1412
+ var import_jsx_runtime21 = require("react/jsx-runtime");
1297
1413
  var VercelAIAssistantProvider = ({
1298
1414
  children,
1299
1415
  ...rest
@@ -1301,21 +1417,21 @@ var VercelAIAssistantProvider = ({
1301
1417
  const context = useDummyAIAssistantContext();
1302
1418
  const vercel = "chat" in rest ? rest.chat : rest.assistant;
1303
1419
  const threadState = useVercelAIThreadState(vercel);
1304
- (0, import_react23.useMemo)(() => {
1420
+ (0, import_react26.useMemo)(() => {
1305
1421
  context.useThread.setState(threadState, true);
1306
1422
  }, [context, threadState]);
1307
- (0, import_react23.useMemo)(() => {
1423
+ (0, import_react26.useMemo)(() => {
1308
1424
  context.useComposer.setState({
1309
1425
  value: vercel.input,
1310
1426
  setValue: vercel.setInput
1311
1427
  });
1312
1428
  }, [context, vercel.input, vercel.setInput]);
1313
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(AssistantContext.Provider, { value: context, children });
1429
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(AssistantContext.Provider, { value: context, children });
1314
1430
  };
1315
1431
 
1316
1432
  // src/adapters/vercel/VercelRSCAssistantProvider.tsx
1317
- var import_react24 = require("react");
1318
- var import_jsx_runtime20 = require("react/jsx-runtime");
1433
+ var import_react27 = require("react");
1434
+ var import_jsx_runtime22 = require("react/jsx-runtime");
1319
1435
  var vercelToThreadMessage2 = (message) => {
1320
1436
  return {
1321
1437
  id: message.id,
@@ -1349,21 +1465,21 @@ var VercelRSCAssistantProvider = ({
1349
1465
  reload
1350
1466
  }) => {
1351
1467
  const context = useDummyAIAssistantContext();
1352
- const [isRunning, setIsRunning] = (0, import_react24.useState)(false);
1353
- const withRunning = (0, import_react24.useCallback)((callback) => {
1468
+ const [isRunning, setIsRunning] = (0, import_react27.useState)(false);
1469
+ const withRunning = (0, import_react27.useCallback)((callback) => {
1354
1470
  setIsRunning(true);
1355
1471
  return callback.finally(() => setIsRunning(false));
1356
1472
  }, []);
1357
- const converter2 = (0, import_react24.useMemo)(() => {
1473
+ const converter2 = (0, import_react27.useMemo)(() => {
1358
1474
  const rscConverter = convertMessage ?? ((m) => m);
1359
1475
  return new ThreadMessageConverter((m) => {
1360
1476
  return vercelToThreadMessage2(rscConverter(m));
1361
1477
  });
1362
1478
  }, [convertMessage]);
1363
- const messages = (0, import_react24.useMemo)(() => {
1479
+ const messages = (0, import_react27.useMemo)(() => {
1364
1480
  return converter2.convertMessages(vercelMessages);
1365
1481
  }, [converter2, vercelMessages]);
1366
- const append = (0, import_react24.useCallback)(
1482
+ const append = (0, import_react27.useCallback)(
1367
1483
  async (message) => {
1368
1484
  if (message.parentId !== (context.useThread.getState().messages.at(-1)?.id ?? null)) {
1369
1485
  if (!edit)
@@ -1377,7 +1493,7 @@ var VercelRSCAssistantProvider = ({
1377
1493
  },
1378
1494
  [context, withRunning, appendCallback, edit]
1379
1495
  );
1380
- const startRun = (0, import_react24.useCallback)(
1496
+ const startRun = (0, import_react27.useCallback)(
1381
1497
  async (parentId) => {
1382
1498
  if (!reload)
1383
1499
  throw new Error(
@@ -1387,7 +1503,7 @@ var VercelRSCAssistantProvider = ({
1387
1503
  },
1388
1504
  [withRunning, reload]
1389
1505
  );
1390
- (0, import_react24.useMemo)(() => {
1506
+ (0, import_react27.useMemo)(() => {
1391
1507
  context.useThread.setState(
1392
1508
  {
1393
1509
  messages,
@@ -1401,13 +1517,14 @@ var VercelRSCAssistantProvider = ({
1401
1517
  true
1402
1518
  );
1403
1519
  }, [context, messages, isRunning, append, startRun]);
1404
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(AssistantContext.Provider, { value: context, children });
1520
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(AssistantContext.Provider, { value: context, children });
1405
1521
  };
1406
1522
  // Annotate the CommonJS export names for ESM import in node:
1407
1523
  0 && (module.exports = {
1408
1524
  ActionBarPrimitive,
1409
1525
  BranchPickerPrimitive,
1410
1526
  ComposerPrimitive,
1527
+ ContentPartPrimitive,
1411
1528
  MessagePrimitive,
1412
1529
  ThreadPrimitive,
1413
1530
  VercelAIAssistantProvider,