@assistant-ui/react 0.3.1 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.d.mts CHANGED
@@ -356,9 +356,15 @@ declare const useComposerIf: (props: UseComposerIfProps) => boolean;
356
356
 
357
357
  declare const useComposerSend: () => (() => void) | null;
358
358
 
359
- declare const useContentPartDisplay: () => react.ReactNode;
359
+ declare const useContentPartDisplay: () => Readonly<{
360
+ status: "in_progress" | "done" | "error";
361
+ part: UIContentPart;
362
+ }>;
360
363
 
361
- declare const useContentPartImage: () => string;
364
+ declare const useContentPartImage: () => Readonly<{
365
+ status: "in_progress" | "done" | "error";
366
+ part: ImageContentPart;
367
+ }>;
362
368
 
363
369
  declare const useContentPartText: () => Readonly<{
364
370
  status: "in_progress" | "done" | "error";
@@ -528,8 +534,16 @@ declare namespace index$3 {
528
534
  }
529
535
 
530
536
  type PrimitiveSpanProps$1 = ComponentPropsWithoutRef<typeof Primitive.span>;
531
- type ContentPartPrimitiveTextProps = Omit<PrimitiveSpanProps$1, "children">;
532
- declare const ContentPartPrimitiveText: react.ForwardRefExoticComponent<ContentPartPrimitiveTextProps & react.RefAttributes<HTMLSpanElement>>;
537
+ type ContentPartPrimitiveTextProps = Omit<PrimitiveSpanProps$1, "children"> & {
538
+ smooth?: boolean;
539
+ };
540
+ declare const ContentPartPrimitiveText: react.ForwardRefExoticComponent<Omit<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
541
+ ref?: ((instance: HTMLSpanElement | null) => void | react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | react.RefObject<HTMLSpanElement> | null | undefined;
542
+ } & {
543
+ asChild?: boolean;
544
+ }, "ref">, "children"> & {
545
+ smooth?: boolean;
546
+ } & react.RefAttributes<HTMLSpanElement>>;
533
547
 
534
548
  type PrimitiveImageProps = ComponentPropsWithoutRef<typeof Primitive.img>;
535
549
  type ContentPartPrimitiveImageProps = PrimitiveImageProps;
@@ -665,14 +679,17 @@ declare class MessageRepository {
665
679
  resetHead(messageId: string | null): void;
666
680
  }
667
681
 
682
+ declare const useSmooth: (text: string, smooth?: boolean) => string;
683
+
668
684
  type internal_BaseAssistantRuntime<TThreadRuntime extends ReactThreadRuntime> = BaseAssistantRuntime<TThreadRuntime>;
669
685
  declare const internal_BaseAssistantRuntime: typeof BaseAssistantRuntime;
670
686
  type internal_MessageRepository = MessageRepository;
671
687
  declare const internal_MessageRepository: typeof MessageRepository;
672
688
  type internal_ProxyConfigProvider = ProxyConfigProvider;
673
689
  declare const internal_ProxyConfigProvider: typeof ProxyConfigProvider;
690
+ declare const internal_useSmooth: typeof useSmooth;
674
691
  declare namespace internal {
675
- export { internal_BaseAssistantRuntime as BaseAssistantRuntime, internal_MessageRepository as MessageRepository, internal_ProxyConfigProvider as ProxyConfigProvider };
692
+ export { internal_BaseAssistantRuntime as BaseAssistantRuntime, internal_MessageRepository as MessageRepository, internal_ProxyConfigProvider as ProxyConfigProvider, internal_useSmooth as useSmooth };
676
693
  }
677
694
 
678
695
  export { index$6 as ActionBarPrimitive, type ActionBarPrimitiveCopyProps, type ActionBarPrimitiveEditProps, type ActionBarPrimitiveReloadProps, type ActionBarPrimitiveRootProps, type AppendContentPart, type AppendMessage, type AssistantContentPart, type AssistantContextValue, type AssistantMessage, index$5 as AssistantModalPrimitive, type AssistantModalPrimitiveContentProps, type AssistantModalPrimitiveRootProps, type AssistantModalPrimitiveTriggerProps, type AssistantModelConfigState, type AssistantRuntime, AssistantRuntimeProvider, type AssistantToolProps, type AssistantToolUIProps, index$4 as BranchPickerPrimitive, type BranchPickerPrimitiveCountProps, type BranchPickerPrimitiveNextProps, type BranchPickerPrimitiveNumberProps, type BranchPickerPrimitivePreviousProps, type BranchPickerPrimitiveRootProps, type ChatModelAdapter, type ChatModelRunOptions, type ComposerContextValue, index$3 as ComposerPrimitive, type ComposerPrimitiveCancelProps, type ComposerPrimitiveIfProps, type ComposerPrimitiveInputProps, type ComposerPrimitiveRootProps, type ComposerPrimitiveSendProps, type ComposerState, type ContentPartContextValue, index$2 as ContentPartPrimitive, type ContentPartPrimitiveDisplayProps, type ContentPartPrimitiveImageProps, type ContentPartPrimitiveInProgressProps, type ContentPartPrimitiveTextProps, type ContentPartState, type EditComposerState, internal as INTERNAL, type ImageContentPart, type ImageContentPartComponent, type ImageContentPartProps, type MessageContextValue, index$1 as MessagePrimitive, type MessagePrimitiveContentProps, type MessagePrimitiveIfProps, type MessagePrimitiveInProgressProps, type MessagePrimitiveRootProps, type MessageState, type ModelConfig, type ModelConfigProvider, type ReactThreadRuntime, type TextContentPart, type TextContentPartComponent, type TextContentPartProps, type ThreadContextValue, type ThreadMessage, index as ThreadPrimitive, type ThreadPrimitiveEmptyProps, type ThreadPrimitiveIfProps, type ThreadPrimitiveMessagesProps, type ThreadPrimitiveRootProps, type ThreadPrimitiveScrollToBottomProps, type ThreadPrimitiveSuggestionProps, type ThreadPrimitiveViewportProps, type ThreadRuntime, type ThreadState, type ThreadViewportState, type ToolCallContentPart, type ToolCallContentPartComponent, type ToolCallContentPartProps, type UIContentPart, type UIContentPartComponent, type UIContentPartProps, type Unsubscribe, type UserContentPart, type UserMessage, makeAssistantTool, makeAssistantToolUI, useActionBarCopy, useActionBarEdit, useActionBarReload, useAppendMessage, useAssistantContext, useAssistantInstructions, useAssistantTool, useAssistantToolUI, useBranchPickerCount, useBranchPickerNext, useBranchPickerNumber, useBranchPickerPrevious, useComposerCancel, useComposerContext, useComposerIf, useComposerSend, useContentPartContext, useContentPartDisplay, useContentPartImage, useContentPartText, useLocalRuntime, useMessageContext, useMessageIf, useSwitchToNewThread, useThreadContext, useThreadEmpty, useThreadIf, useThreadScrollToBottom, useThreadSuggestion };
package/dist/index.d.ts CHANGED
@@ -356,9 +356,15 @@ declare const useComposerIf: (props: UseComposerIfProps) => boolean;
356
356
 
357
357
  declare const useComposerSend: () => (() => void) | null;
358
358
 
359
- declare const useContentPartDisplay: () => react.ReactNode;
359
+ declare const useContentPartDisplay: () => Readonly<{
360
+ status: "in_progress" | "done" | "error";
361
+ part: UIContentPart;
362
+ }>;
360
363
 
361
- declare const useContentPartImage: () => string;
364
+ declare const useContentPartImage: () => Readonly<{
365
+ status: "in_progress" | "done" | "error";
366
+ part: ImageContentPart;
367
+ }>;
362
368
 
363
369
  declare const useContentPartText: () => Readonly<{
364
370
  status: "in_progress" | "done" | "error";
@@ -528,8 +534,16 @@ declare namespace index$3 {
528
534
  }
529
535
 
530
536
  type PrimitiveSpanProps$1 = ComponentPropsWithoutRef<typeof Primitive.span>;
531
- type ContentPartPrimitiveTextProps = Omit<PrimitiveSpanProps$1, "children">;
532
- declare const ContentPartPrimitiveText: react.ForwardRefExoticComponent<ContentPartPrimitiveTextProps & react.RefAttributes<HTMLSpanElement>>;
537
+ type ContentPartPrimitiveTextProps = Omit<PrimitiveSpanProps$1, "children"> & {
538
+ smooth?: boolean;
539
+ };
540
+ declare const ContentPartPrimitiveText: react.ForwardRefExoticComponent<Omit<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
541
+ ref?: ((instance: HTMLSpanElement | null) => void | react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | react.RefObject<HTMLSpanElement> | null | undefined;
542
+ } & {
543
+ asChild?: boolean;
544
+ }, "ref">, "children"> & {
545
+ smooth?: boolean;
546
+ } & react.RefAttributes<HTMLSpanElement>>;
533
547
 
534
548
  type PrimitiveImageProps = ComponentPropsWithoutRef<typeof Primitive.img>;
535
549
  type ContentPartPrimitiveImageProps = PrimitiveImageProps;
@@ -665,14 +679,17 @@ declare class MessageRepository {
665
679
  resetHead(messageId: string | null): void;
666
680
  }
667
681
 
682
+ declare const useSmooth: (text: string, smooth?: boolean) => string;
683
+
668
684
  type internal_BaseAssistantRuntime<TThreadRuntime extends ReactThreadRuntime> = BaseAssistantRuntime<TThreadRuntime>;
669
685
  declare const internal_BaseAssistantRuntime: typeof BaseAssistantRuntime;
670
686
  type internal_MessageRepository = MessageRepository;
671
687
  declare const internal_MessageRepository: typeof MessageRepository;
672
688
  type internal_ProxyConfigProvider = ProxyConfigProvider;
673
689
  declare const internal_ProxyConfigProvider: typeof ProxyConfigProvider;
690
+ declare const internal_useSmooth: typeof useSmooth;
674
691
  declare namespace internal {
675
- export { internal_BaseAssistantRuntime as BaseAssistantRuntime, internal_MessageRepository as MessageRepository, internal_ProxyConfigProvider as ProxyConfigProvider };
692
+ export { internal_BaseAssistantRuntime as BaseAssistantRuntime, internal_MessageRepository as MessageRepository, internal_ProxyConfigProvider as ProxyConfigProvider, internal_useSmooth as useSmooth };
676
693
  }
677
694
 
678
695
  export { index$6 as ActionBarPrimitive, type ActionBarPrimitiveCopyProps, type ActionBarPrimitiveEditProps, type ActionBarPrimitiveReloadProps, type ActionBarPrimitiveRootProps, type AppendContentPart, type AppendMessage, type AssistantContentPart, type AssistantContextValue, type AssistantMessage, index$5 as AssistantModalPrimitive, type AssistantModalPrimitiveContentProps, type AssistantModalPrimitiveRootProps, type AssistantModalPrimitiveTriggerProps, type AssistantModelConfigState, type AssistantRuntime, AssistantRuntimeProvider, type AssistantToolProps, type AssistantToolUIProps, index$4 as BranchPickerPrimitive, type BranchPickerPrimitiveCountProps, type BranchPickerPrimitiveNextProps, type BranchPickerPrimitiveNumberProps, type BranchPickerPrimitivePreviousProps, type BranchPickerPrimitiveRootProps, type ChatModelAdapter, type ChatModelRunOptions, type ComposerContextValue, index$3 as ComposerPrimitive, type ComposerPrimitiveCancelProps, type ComposerPrimitiveIfProps, type ComposerPrimitiveInputProps, type ComposerPrimitiveRootProps, type ComposerPrimitiveSendProps, type ComposerState, type ContentPartContextValue, index$2 as ContentPartPrimitive, type ContentPartPrimitiveDisplayProps, type ContentPartPrimitiveImageProps, type ContentPartPrimitiveInProgressProps, type ContentPartPrimitiveTextProps, type ContentPartState, type EditComposerState, internal as INTERNAL, type ImageContentPart, type ImageContentPartComponent, type ImageContentPartProps, type MessageContextValue, index$1 as MessagePrimitive, type MessagePrimitiveContentProps, type MessagePrimitiveIfProps, type MessagePrimitiveInProgressProps, type MessagePrimitiveRootProps, type MessageState, type ModelConfig, type ModelConfigProvider, type ReactThreadRuntime, type TextContentPart, type TextContentPartComponent, type TextContentPartProps, type ThreadContextValue, type ThreadMessage, index as ThreadPrimitive, type ThreadPrimitiveEmptyProps, type ThreadPrimitiveIfProps, type ThreadPrimitiveMessagesProps, type ThreadPrimitiveRootProps, type ThreadPrimitiveScrollToBottomProps, type ThreadPrimitiveSuggestionProps, type ThreadPrimitiveViewportProps, type ThreadRuntime, type ThreadState, type ThreadViewportState, type ToolCallContentPart, type ToolCallContentPartComponent, type ToolCallContentPartProps, type UIContentPart, type UIContentPartComponent, type UIContentPartProps, type Unsubscribe, type UserContentPart, type UserMessage, makeAssistantTool, makeAssistantToolUI, useActionBarCopy, useActionBarEdit, useActionBarReload, useAppendMessage, useAssistantContext, useAssistantInstructions, useAssistantTool, useAssistantToolUI, useBranchPickerCount, useBranchPickerNext, useBranchPickerNumber, useBranchPickerPrevious, useComposerCancel, useComposerContext, useComposerIf, useComposerSend, useContentPartContext, useContentPartDisplay, useContentPartImage, useContentPartText, useLocalRuntime, useMessageContext, useMessageIf, useSwitchToNewThread, useThreadContext, useThreadEmpty, useThreadIf, useThreadScrollToBottom, useThreadSuggestion };
package/dist/index.js CHANGED
@@ -730,7 +730,7 @@ var useContentPartDisplay = () => {
730
730
  throw new Error(
731
731
  "This component can only be used inside ui content parts."
732
732
  );
733
- return c.part.display;
733
+ return c;
734
734
  });
735
735
  return display;
736
736
  };
@@ -743,7 +743,7 @@ var useContentPartImage = () => {
743
743
  throw new Error(
744
744
  "ContentPartImage can only be used inside image content parts."
745
745
  );
746
- return c.part.image;
746
+ return c;
747
747
  });
748
748
  return image;
749
749
  };
@@ -1097,7 +1097,7 @@ BranchPickerPrimitiveNumber.displayName = "BranchPickerPrimitive.Number";
1097
1097
 
1098
1098
  // src/primitives/branchPicker/BranchPickerRoot.tsx
1099
1099
  var import_react_primitive6 = require("@radix-ui/react-primitive");
1100
- var import_react38 = require("react");
1100
+ var import_react39 = require("react");
1101
1101
 
1102
1102
  // src/primitives/message/index.ts
1103
1103
  var message_exports = {};
@@ -1174,7 +1174,7 @@ var MessagePrimitiveIf = ({
1174
1174
  MessagePrimitiveIf.displayName = "MessagePrimitive.If";
1175
1175
 
1176
1176
  // src/primitives/message/MessageContent.tsx
1177
- var import_react37 = require("react");
1177
+ var import_react38 = require("react");
1178
1178
 
1179
1179
  // src/context/providers/ContentPartProvider.tsx
1180
1180
  var import_react34 = require("react");
@@ -1221,30 +1221,113 @@ var ContentPartProvider = ({
1221
1221
 
1222
1222
  // src/primitives/contentPart/ContentPartText.tsx
1223
1223
  var import_react_primitive4 = require("@radix-ui/react-primitive");
1224
+ var import_react36 = require("react");
1225
+
1226
+ // src/utils/hooks/useSmooth.tsx
1224
1227
  var import_react35 = require("react");
1228
+ var TextStreamAnimator = class {
1229
+ constructor(setText) {
1230
+ this.setText = setText;
1231
+ }
1232
+ animationFrameId = null;
1233
+ lastUpdateTime = Date.now();
1234
+ targetText = "";
1235
+ start() {
1236
+ if (this.animationFrameId !== null) return;
1237
+ this.lastUpdateTime = Date.now();
1238
+ this.animate();
1239
+ }
1240
+ stop() {
1241
+ if (this.animationFrameId !== null) {
1242
+ cancelAnimationFrame(this.animationFrameId);
1243
+ this.animationFrameId = null;
1244
+ }
1245
+ }
1246
+ animate = () => {
1247
+ const currentTime = Date.now();
1248
+ const deltaTime = currentTime - this.lastUpdateTime;
1249
+ let timeToConsume = deltaTime;
1250
+ this.setText((currentText) => {
1251
+ const targetText = this.targetText;
1252
+ if (currentText === targetText) {
1253
+ this.animationFrameId = null;
1254
+ return currentText;
1255
+ }
1256
+ const remainingChars = targetText.length - currentText.length;
1257
+ const baseTimePerChar = Math.min(5, 250 / remainingChars);
1258
+ let charsToAdd = 0;
1259
+ while (timeToConsume >= baseTimePerChar && charsToAdd < remainingChars) {
1260
+ charsToAdd++;
1261
+ timeToConsume -= baseTimePerChar;
1262
+ }
1263
+ this.animationFrameId = requestAnimationFrame(this.animate);
1264
+ if (charsToAdd === 0) {
1265
+ return currentText;
1266
+ }
1267
+ const newText = targetText.slice(0, currentText.length + charsToAdd);
1268
+ this.lastUpdateTime = currentTime - timeToConsume;
1269
+ return newText;
1270
+ });
1271
+ };
1272
+ };
1273
+ var useSmooth = (text, smooth = false) => {
1274
+ const [displayedText, setDisplayedText] = (0, import_react35.useState)(text);
1275
+ const [animatorRef] = (0, import_react35.useState)(
1276
+ new TextStreamAnimator(setDisplayedText)
1277
+ );
1278
+ (0, import_react35.useEffect)(() => {
1279
+ console.log("smooth", smooth);
1280
+ if (!smooth) {
1281
+ animatorRef.stop();
1282
+ return;
1283
+ }
1284
+ if (!text.startsWith(animatorRef.targetText)) {
1285
+ setDisplayedText(text);
1286
+ animatorRef.targetText = text;
1287
+ animatorRef.stop();
1288
+ return;
1289
+ }
1290
+ animatorRef.targetText = text;
1291
+ animatorRef.start();
1292
+ console.log("animating");
1293
+ }, [animatorRef, smooth, text]);
1294
+ (0, import_react35.useEffect)(() => {
1295
+ return () => {
1296
+ animatorRef.stop();
1297
+ };
1298
+ }, [animatorRef]);
1299
+ return smooth ? displayedText : text;
1300
+ };
1301
+
1302
+ // src/primitives/contentPart/ContentPartText.tsx
1225
1303
  var import_jsx_runtime14 = require("react/jsx-runtime");
1226
- var ContentPartPrimitiveText = (0, import_react35.forwardRef)((props, forwardedRef) => {
1304
+ var ContentPartPrimitiveText = (0, import_react36.forwardRef)(({ smooth = true, ...rest }, forwardedRef) => {
1227
1305
  const {
1228
- part: { text },
1229
- status
1306
+ status,
1307
+ part: { text }
1230
1308
  } = useContentPartText();
1231
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_primitive4.Primitive.span, { "data-status": status, ...props, ref: forwardedRef, children: text });
1309
+ const smoothText = useSmooth(text, smooth);
1310
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_primitive4.Primitive.span, { "data-status": status, ...rest, ref: forwardedRef, children: smoothText });
1232
1311
  });
1233
1312
  ContentPartPrimitiveText.displayName = "ContentPartPrimitive.Text";
1234
1313
 
1235
1314
  // src/primitives/contentPart/ContentPartImage.tsx
1236
1315
  var import_react_primitive5 = require("@radix-ui/react-primitive");
1237
- var import_react36 = require("react");
1316
+ var import_react37 = require("react");
1238
1317
  var import_jsx_runtime15 = require("react/jsx-runtime");
1239
- var ContentPartPrimitiveImage = (0, import_react36.forwardRef)((props, forwardedRef) => {
1240
- const image = useContentPartImage();
1318
+ var ContentPartPrimitiveImage = (0, import_react37.forwardRef)((props, forwardedRef) => {
1319
+ const {
1320
+ part: { image }
1321
+ } = useContentPartImage();
1241
1322
  return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react_primitive5.Primitive.img, { src: image, ...props, ref: forwardedRef });
1242
1323
  });
1243
1324
  ContentPartPrimitiveImage.displayName = "ContentPartPrimitive.Image";
1244
1325
 
1245
1326
  // src/primitives/contentPart/ContentPartDisplay.tsx
1246
1327
  var ContentPartPrimitiveDisplay = () => {
1247
- const display = useContentPartDisplay();
1328
+ const {
1329
+ part: { display }
1330
+ } = useContentPartDisplay();
1248
1331
  return display ?? null;
1249
1332
  };
1250
1333
  ContentPartPrimitiveDisplay.displayName = "ContentPartPrimitive.Display";
@@ -1312,7 +1395,7 @@ var MessageContentPartImpl = ({
1312
1395
  }) => {
1313
1396
  return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ContentPartProvider, { partIndex, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(MessageContentPartComponent, { components }) });
1314
1397
  };
1315
- var MessageContentPart = (0, import_react37.memo)(
1398
+ var MessageContentPart = (0, import_react38.memo)(
1316
1399
  MessageContentPartImpl,
1317
1400
  (prev, next) => prev.partIndex === next.partIndex && prev.components?.Text === next.components?.Text && prev.components?.Image === next.components?.Image && prev.components?.UI === next.components?.UI && prev.components?.tools === next.components?.tools
1318
1401
  );
@@ -1343,7 +1426,7 @@ MessagePrimitiveInProgress.displayName = "MessagePrimitive.InProgress";
1343
1426
 
1344
1427
  // src/primitives/branchPicker/BranchPickerRoot.tsx
1345
1428
  var import_jsx_runtime17 = require("react/jsx-runtime");
1346
- var BranchPickerPrimitiveRoot = (0, import_react38.forwardRef)(({ hideWhenSingleBranch, ...rest }, ref) => {
1429
+ var BranchPickerPrimitiveRoot = (0, import_react39.forwardRef)(({ hideWhenSingleBranch, ...rest }, ref) => {
1347
1430
  return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(MessagePrimitiveIf, { hasBranches: hideWhenSingleBranch ? true : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_primitive6.Primitive.div, { ...rest, ref }) });
1348
1431
  });
1349
1432
  BranchPickerPrimitiveRoot.displayName = "BranchPickerPrimitive.Root";
@@ -1361,9 +1444,9 @@ __export(composer_exports, {
1361
1444
  // src/primitives/composer/ComposerRoot.tsx
1362
1445
  var import_primitive4 = require("@radix-ui/primitive");
1363
1446
  var import_react_primitive7 = require("@radix-ui/react-primitive");
1364
- var import_react39 = require("react");
1447
+ var import_react40 = require("react");
1365
1448
  var import_jsx_runtime18 = require("react/jsx-runtime");
1366
- var ComposerPrimitiveRoot = (0, import_react39.forwardRef)(({ onSubmit, ...rest }, forwardedRef) => {
1449
+ var ComposerPrimitiveRoot = (0, import_react40.forwardRef)(({ onSubmit, ...rest }, forwardedRef) => {
1367
1450
  const send = useComposerSend();
1368
1451
  const handleSubmit = (e) => {
1369
1452
  e.preventDefault();
@@ -1385,11 +1468,11 @@ ComposerPrimitiveRoot.displayName = "ComposerPrimitive.Root";
1385
1468
  var import_primitive5 = require("@radix-ui/primitive");
1386
1469
  var import_react_compose_refs2 = require("@radix-ui/react-compose-refs");
1387
1470
  var import_react_slot = require("@radix-ui/react-slot");
1388
- var import_react40 = require("react");
1471
+ var import_react41 = require("react");
1389
1472
  var import_react_textarea_autosize = __toESM(require("react-textarea-autosize"));
1390
1473
  var import_react_use_escape_keydown = require("@radix-ui/react-use-escape-keydown");
1391
1474
  var import_jsx_runtime19 = require("react/jsx-runtime");
1392
- var ComposerPrimitiveInput = (0, import_react40.forwardRef)(
1475
+ var ComposerPrimitiveInput = (0, import_react41.forwardRef)(
1393
1476
  ({ autoFocus = false, asChild, disabled, onChange, onKeyDown, ...rest }, forwardedRef) => {
1394
1477
  const { useThread } = useThreadContext();
1395
1478
  const { useComposer, type } = useComposerContext();
@@ -1398,7 +1481,7 @@ var ComposerPrimitiveInput = (0, import_react40.forwardRef)(
1398
1481
  return c.value;
1399
1482
  });
1400
1483
  const Component = asChild ? import_react_slot.Slot : import_react_textarea_autosize.default;
1401
- const textareaRef = (0, import_react40.useRef)(null);
1484
+ const textareaRef = (0, import_react41.useRef)(null);
1402
1485
  const ref = (0, import_react_compose_refs2.useComposedRefs)(forwardedRef, textareaRef);
1403
1486
  (0, import_react_use_escape_keydown.useEscapeKeydown)((e) => {
1404
1487
  const composer = useComposer.getState();
@@ -1418,7 +1501,7 @@ var ComposerPrimitiveInput = (0, import_react40.forwardRef)(
1418
1501
  }
1419
1502
  };
1420
1503
  const autoFocusEnabled = autoFocus && !disabled;
1421
- const focus = (0, import_react40.useCallback)(() => {
1504
+ const focus = (0, import_react41.useCallback)(() => {
1422
1505
  const textarea = textareaRef.current;
1423
1506
  if (!textarea || !autoFocusEnabled) return;
1424
1507
  textarea.focus({ preventScroll: true });
@@ -1427,7 +1510,7 @@ var ComposerPrimitiveInput = (0, import_react40.forwardRef)(
1427
1510
  textareaRef.current.value.length
1428
1511
  );
1429
1512
  }, [autoFocusEnabled]);
1430
- (0, import_react40.useEffect)(() => focus(), [focus]);
1513
+ (0, import_react41.useEffect)(() => focus(), [focus]);
1431
1514
  useOnComposerFocus(() => {
1432
1515
  if (type === "new") {
1433
1516
  focus();
@@ -1454,10 +1537,10 @@ var ComposerPrimitiveInput = (0, import_react40.forwardRef)(
1454
1537
  ComposerPrimitiveInput.displayName = "ComposerPrimitive.Input";
1455
1538
 
1456
1539
  // src/primitives/composer/ComposerSend.tsx
1457
- var import_react41 = require("react");
1540
+ var import_react42 = require("react");
1458
1541
  var import_react_primitive8 = require("@radix-ui/react-primitive");
1459
1542
  var import_jsx_runtime20 = require("react/jsx-runtime");
1460
- var ComposerPrimitiveSend = (0, import_react41.forwardRef)(({ disabled, ...rest }, ref) => {
1543
+ var ComposerPrimitiveSend = (0, import_react42.forwardRef)(({ disabled, ...rest }, ref) => {
1461
1544
  const { useComposer } = useComposerContext();
1462
1545
  const hasValue = useComposer((c) => c.isEditing && c.value.length > 0);
1463
1546
  return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
@@ -1511,9 +1594,9 @@ __export(thread_exports, {
1511
1594
 
1512
1595
  // src/primitives/thread/ThreadRoot.tsx
1513
1596
  var import_react_primitive9 = require("@radix-ui/react-primitive");
1514
- var import_react42 = require("react");
1597
+ var import_react43 = require("react");
1515
1598
  var import_jsx_runtime21 = require("react/jsx-runtime");
1516
- var ThreadPrimitiveRoot = (0, import_react42.forwardRef)((props, ref) => {
1599
+ var ThreadPrimitiveRoot = (0, import_react43.forwardRef)((props, ref) => {
1517
1600
  return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_react_primitive9.Primitive.div, { ...props, ref });
1518
1601
  });
1519
1602
  ThreadPrimitiveRoot.displayName = "ThreadPrimitive.Root";
@@ -1540,18 +1623,18 @@ ThreadPrimitiveIf.displayName = "ThreadPrimitive.If";
1540
1623
  // src/primitives/thread/ThreadViewport.tsx
1541
1624
  var import_react_compose_refs4 = require("@radix-ui/react-compose-refs");
1542
1625
  var import_react_primitive10 = require("@radix-ui/react-primitive");
1543
- var import_react46 = require("react");
1626
+ var import_react47 = require("react");
1544
1627
 
1545
1628
  // src/primitive-hooks/thread/useThreadViewportAutoScroll.tsx
1546
1629
  var import_react_compose_refs3 = require("@radix-ui/react-compose-refs");
1547
- var import_react45 = require("react");
1630
+ var import_react46 = require("react");
1548
1631
 
1549
1632
  // src/utils/hooks/useOnResizeContent.tsx
1550
1633
  var import_react_use_callback_ref2 = require("@radix-ui/react-use-callback-ref");
1551
- var import_react43 = require("react");
1634
+ var import_react44 = require("react");
1552
1635
  var useOnResizeContent = (callback) => {
1553
1636
  const callbackRef = (0, import_react_use_callback_ref2.useCallbackRef)(callback);
1554
- const refCallback = (0, import_react43.useCallback)(
1637
+ const refCallback = (0, import_react44.useCallback)(
1555
1638
  (el) => {
1556
1639
  const resizeObserver = new ResizeObserver(() => {
1557
1640
  callbackRef();
@@ -1588,11 +1671,11 @@ var useOnResizeContent = (callback) => {
1588
1671
 
1589
1672
  // src/utils/hooks/useOnScrollToBottom.tsx
1590
1673
  var import_react_use_callback_ref3 = require("@radix-ui/react-use-callback-ref");
1591
- var import_react44 = require("react");
1674
+ var import_react45 = require("react");
1592
1675
  var useOnScrollToBottom = (callback) => {
1593
1676
  const callbackRef = (0, import_react_use_callback_ref3.useCallbackRef)(callback);
1594
1677
  const { useViewport } = useThreadContext();
1595
- (0, import_react44.useEffect)(() => {
1678
+ (0, import_react45.useEffect)(() => {
1596
1679
  return useViewport.getState().onScrollToBottom(() => {
1597
1680
  callbackRef();
1598
1681
  });
@@ -1603,11 +1686,11 @@ var useOnScrollToBottom = (callback) => {
1603
1686
  var useThreadViewportAutoScroll = ({
1604
1687
  autoScroll = true
1605
1688
  }) => {
1606
- const divRef = (0, import_react45.useRef)(null);
1689
+ const divRef = (0, import_react46.useRef)(null);
1607
1690
  const { useViewport } = useThreadContext();
1608
- const firstRenderRef = (0, import_react45.useRef)(true);
1609
- const lastScrollTop = (0, import_react45.useRef)(0);
1610
- const isScrollingToBottomRef = (0, import_react45.useRef)(false);
1691
+ const firstRenderRef = (0, import_react46.useRef)(true);
1692
+ const lastScrollTop = (0, import_react46.useRef)(0);
1693
+ const isScrollingToBottomRef = (0, import_react46.useRef)(false);
1611
1694
  const scrollToBottom = () => {
1612
1695
  const div = divRef.current;
1613
1696
  if (!div || !autoScroll) return;
@@ -1654,7 +1737,7 @@ var useThreadViewportAutoScroll = ({
1654
1737
 
1655
1738
  // src/primitives/thread/ThreadViewport.tsx
1656
1739
  var import_jsx_runtime22 = require("react/jsx-runtime");
1657
- var ThreadPrimitiveViewport = (0, import_react46.forwardRef)(({ autoScroll, onScroll, children, ...rest }, forwardedRef) => {
1740
+ var ThreadPrimitiveViewport = (0, import_react47.forwardRef)(({ autoScroll, onScroll, children, ...rest }, forwardedRef) => {
1658
1741
  const autoScrollRef = useThreadViewportAutoScroll({
1659
1742
  autoScroll
1660
1743
  });
@@ -1664,10 +1747,10 @@ var ThreadPrimitiveViewport = (0, import_react46.forwardRef)(({ autoScroll, onSc
1664
1747
  ThreadPrimitiveViewport.displayName = "ThreadPrimitive.Viewport";
1665
1748
 
1666
1749
  // src/primitives/thread/ThreadMessages.tsx
1667
- var import_react48 = require("react");
1750
+ var import_react49 = require("react");
1668
1751
 
1669
1752
  // src/context/providers/MessageProvider.tsx
1670
- var import_react47 = require("react");
1753
+ var import_react48 = require("react");
1671
1754
  var import_zustand12 = require("zustand");
1672
1755
 
1673
1756
  // src/context/stores/EditComposer.ts
@@ -1729,7 +1812,7 @@ var syncMessage = (messages, getBranches, useMessage, messageIndex) => {
1729
1812
  };
1730
1813
  var useMessageContext2 = (messageIndex) => {
1731
1814
  const { useThreadMessages, useThreadActions } = useThreadContext();
1732
- const [context] = (0, import_react47.useState)(() => {
1815
+ const [context] = (0, import_react48.useState)(() => {
1733
1816
  const useMessage = (0, import_zustand12.create)(() => ({}));
1734
1817
  const useMessageUtils = makeMessageUtilsStore();
1735
1818
  const useEditComposer = makeEditComposerStore({
@@ -1766,7 +1849,7 @@ var useMessageContext2 = (messageIndex) => {
1766
1849
  );
1767
1850
  return { useMessage, useMessageUtils, useEditComposer };
1768
1851
  });
1769
- (0, import_react47.useEffect)(() => {
1852
+ (0, import_react48.useEffect)(() => {
1770
1853
  return useThreadMessages.subscribe((thread) => {
1771
1854
  syncMessage(
1772
1855
  thread,
@@ -1808,7 +1891,7 @@ var ThreadMessageImpl = ({
1808
1891
  /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(MessagePrimitiveIf, { assistant: true, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(AssistantMessage, {}) })
1809
1892
  ] });
1810
1893
  };
1811
- var ThreadMessage = (0, import_react48.memo)(
1894
+ var ThreadMessage = (0, import_react49.memo)(
1812
1895
  ThreadMessageImpl,
1813
1896
  (prev, next) => prev.messageIndex === next.messageIndex && prev.components.Message === next.components.Message && prev.components.UserMessage === next.components.UserMessage && prev.components.EditComposer === next.components.EditComposer && prev.components.AssistantMessage === next.components.AssistantMessage
1814
1897
  );
@@ -1831,7 +1914,7 @@ var ThreadPrimitiveMessagesImpl = ({
1831
1914
  });
1832
1915
  };
1833
1916
  ThreadPrimitiveMessagesImpl.displayName = "ThreadPrimitive.Messages";
1834
- var ThreadPrimitiveMessages = (0, import_react48.memo)(
1917
+ var ThreadPrimitiveMessages = (0, import_react49.memo)(
1835
1918
  ThreadPrimitiveMessagesImpl,
1836
1919
  (prev, next) => prev.components?.Message === next.components?.Message && prev.components?.UserMessage === next.components?.UserMessage && prev.components?.EditComposer === next.components?.EditComposer && prev.components?.AssistantMessage === next.components?.AssistantMessage
1837
1920
  );
@@ -1849,7 +1932,7 @@ var ThreadPrimitiveSuggestion = createActionButton(
1849
1932
  );
1850
1933
 
1851
1934
  // src/runtime/local/useLocalRuntime.tsx
1852
- var import_react49 = require("react");
1935
+ var import_react50 = require("react");
1853
1936
 
1854
1937
  // src/runtime/utils/idUtils.tsx
1855
1938
  var import_non_secure = require("nanoid/non-secure");
@@ -2191,8 +2274,8 @@ var LocalThreadRuntime = class {
2191
2274
 
2192
2275
  // src/runtime/local/useLocalRuntime.tsx
2193
2276
  var useLocalRuntime = (adapter) => {
2194
- const [runtime] = (0, import_react49.useState)(() => new LocalRuntime(adapter));
2195
- (0, import_react49.useInsertionEffect)(() => {
2277
+ const [runtime] = (0, import_react50.useState)(() => new LocalRuntime(adapter));
2278
+ (0, import_react50.useInsertionEffect)(() => {
2196
2279
  runtime.adapter = adapter;
2197
2280
  });
2198
2281
  return runtime;
@@ -2203,7 +2286,8 @@ var internal_exports = {};
2203
2286
  __export(internal_exports, {
2204
2287
  BaseAssistantRuntime: () => BaseAssistantRuntime,
2205
2288
  MessageRepository: () => MessageRepository,
2206
- ProxyConfigProvider: () => ProxyConfigProvider
2289
+ ProxyConfigProvider: () => ProxyConfigProvider,
2290
+ useSmooth: () => useSmooth
2207
2291
  });
2208
2292
  // Annotate the CommonJS export names for ESM import in node:
2209
2293
  0 && (module.exports = {