@assistant-ui/react 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.d.mts CHANGED
@@ -428,8 +428,10 @@ declare const AssistantModalPrimitiveContent: react.ForwardRefExoticComponent<Om
428
428
  dissmissOnInteractOutside?: boolean;
429
429
  } & react.RefAttributes<HTMLDivElement>>;
430
430
 
431
+ declare const AssistantModalPrimitiveAnchor: react.ForwardRefExoticComponent<Omit<PopoverPrimitive.PopoverAnchorProps & react.RefAttributes<HTMLDivElement>, "ref"> & react.RefAttributes<HTMLDivElement>>;
432
+
431
433
  declare namespace index$5 {
432
- export { AssistantModalPrimitiveContent as Content, AssistantModalPrimitiveRoot as Root, AssistantModalPrimitiveTrigger as Trigger };
434
+ export { AssistantModalPrimitiveAnchor as Anchor, AssistantModalPrimitiveContent as Content, AssistantModalPrimitiveRoot as Root, AssistantModalPrimitiveTrigger as Trigger };
433
435
  }
434
436
 
435
437
  type BranchPickerPrimitiveNextProps = ActionButtonProps<typeof useBranchPickerNext>;
package/dist/index.d.ts CHANGED
@@ -428,8 +428,10 @@ declare const AssistantModalPrimitiveContent: react.ForwardRefExoticComponent<Om
428
428
  dissmissOnInteractOutside?: boolean;
429
429
  } & react.RefAttributes<HTMLDivElement>>;
430
430
 
431
+ declare const AssistantModalPrimitiveAnchor: react.ForwardRefExoticComponent<Omit<PopoverPrimitive.PopoverAnchorProps & react.RefAttributes<HTMLDivElement>, "ref"> & react.RefAttributes<HTMLDivElement>>;
432
+
431
433
  declare namespace index$5 {
432
- export { AssistantModalPrimitiveContent as Content, AssistantModalPrimitiveRoot as Root, AssistantModalPrimitiveTrigger as Trigger };
434
+ export { AssistantModalPrimitiveAnchor as Anchor, AssistantModalPrimitiveContent as Content, AssistantModalPrimitiveRoot as Root, AssistantModalPrimitiveTrigger as Trigger };
433
435
  }
434
436
 
435
437
  type BranchPickerPrimitiveNextProps = ActionButtonProps<typeof useBranchPickerNext>;
package/dist/index.js CHANGED
@@ -933,6 +933,7 @@ var ActionBarPrimitiveEdit = createActionButton(
933
933
  // src/primitives/assistantModal/index.ts
934
934
  var assistantModal_exports = {};
935
935
  __export(assistantModal_exports, {
936
+ Anchor: () => AssistantModalPrimitiveAnchor,
936
937
  Content: () => AssistantModalPrimitiveContent,
937
938
  Root: () => AssistantModalPrimitiveRoot,
938
939
  Trigger: () => AssistantModalPrimitiveTrigger
@@ -1039,6 +1040,21 @@ var AssistantModalPrimitiveContent = (0, import_react30.forwardRef)(
1039
1040
  );
1040
1041
  AssistantModalPrimitiveContent.displayName = "AssistantModalPrimitive.Content";
1041
1042
 
1043
+ // src/primitives/assistantModal/AssistantModalAnchor.tsx
1044
+ var import_react31 = require("react");
1045
+ var PopoverPrimitive5 = __toESM(require("@radix-ui/react-popover"));
1046
+ var import_jsx_runtime9 = require("react/jsx-runtime");
1047
+ var AssistantModalPrimitiveAnchor = (0, import_react31.forwardRef)(
1048
+ ({
1049
+ __scopeAssistantModal,
1050
+ ...rest
1051
+ }, ref) => {
1052
+ const scope = usePopoverScope(__scopeAssistantModal);
1053
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(PopoverPrimitive5.Anchor, { ...scope, ...rest, ref });
1054
+ }
1055
+ );
1056
+ AssistantModalPrimitiveAnchor.displayName = "AssistantModalPrimitive.Anchor";
1057
+
1042
1058
  // src/primitives/branchPicker/index.ts
1043
1059
  var branchPicker_exports = {};
1044
1060
  __export(branchPicker_exports, {
@@ -1062,24 +1078,24 @@ var BranchPickerPrevious = createActionButton(
1062
1078
  );
1063
1079
 
1064
1080
  // src/primitives/branchPicker/BranchPickerCount.tsx
1065
- var import_jsx_runtime9 = require("react/jsx-runtime");
1081
+ var import_jsx_runtime10 = require("react/jsx-runtime");
1066
1082
  var BranchPickerPrimitiveCount = () => {
1067
1083
  const branchCount = useBranchPickerCount();
1068
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children: branchCount });
1084
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx_runtime10.Fragment, { children: branchCount });
1069
1085
  };
1070
1086
  BranchPickerPrimitiveCount.displayName = "BranchPickerPrimitive.Count";
1071
1087
 
1072
1088
  // src/primitives/branchPicker/BranchPickerNumber.tsx
1073
- var import_jsx_runtime10 = require("react/jsx-runtime");
1089
+ var import_jsx_runtime11 = require("react/jsx-runtime");
1074
1090
  var BranchPickerPrimitiveNumber = () => {
1075
1091
  const branchNumber = useBranchPickerNumber();
1076
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx_runtime10.Fragment, { children: branchNumber });
1092
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_jsx_runtime11.Fragment, { children: branchNumber });
1077
1093
  };
1078
1094
  BranchPickerPrimitiveNumber.displayName = "BranchPickerPrimitive.Number";
1079
1095
 
1080
1096
  // src/primitives/branchPicker/BranchPickerRoot.tsx
1081
1097
  var import_react_primitive6 = require("@radix-ui/react-primitive");
1082
- var import_react37 = require("react");
1098
+ var import_react38 = require("react");
1083
1099
 
1084
1100
  // src/primitives/message/index.ts
1085
1101
  var message_exports = {};
@@ -1093,9 +1109,9 @@ __export(message_exports, {
1093
1109
  // src/primitives/message/MessageRoot.tsx
1094
1110
  var import_primitive4 = require("@radix-ui/primitive");
1095
1111
  var import_react_primitive3 = require("@radix-ui/react-primitive");
1096
- var import_react31 = require("react");
1097
- var import_jsx_runtime11 = require("react/jsx-runtime");
1098
- var MessagePrimitiveRoot = (0, import_react31.forwardRef)(({ onMouseEnter, onMouseLeave, ...rest }, ref) => {
1112
+ var import_react32 = require("react");
1113
+ var import_jsx_runtime12 = require("react/jsx-runtime");
1114
+ var MessagePrimitiveRoot = (0, import_react32.forwardRef)(({ onMouseEnter, onMouseLeave, ...rest }, ref) => {
1099
1115
  const { useMessageUtils } = useMessageContext();
1100
1116
  const setIsHovering = useMessageUtils((s) => s.setIsHovering);
1101
1117
  const handleMouseEnter = () => {
@@ -1104,7 +1120,7 @@ var MessagePrimitiveRoot = (0, import_react31.forwardRef)(({ onMouseEnter, onMou
1104
1120
  const handleMouseLeave = () => {
1105
1121
  setIsHovering(false);
1106
1122
  };
1107
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1123
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1108
1124
  import_react_primitive3.Primitive.div,
1109
1125
  {
1110
1126
  ...rest,
@@ -1127,12 +1143,12 @@ var MessagePrimitiveIf = ({
1127
1143
  MessagePrimitiveIf.displayName = "MessagePrimitive.If";
1128
1144
 
1129
1145
  // src/primitives/message/MessageContent.tsx
1130
- var import_react35 = require("react");
1146
+ var import_react36 = require("react");
1131
1147
 
1132
1148
  // src/context/providers/ContentPartProvider.tsx
1133
- var import_react32 = require("react");
1149
+ var import_react33 = require("react");
1134
1150
  var import_zustand9 = require("zustand");
1135
- var import_jsx_runtime12 = require("react/jsx-runtime");
1151
+ var import_jsx_runtime13 = require("react/jsx-runtime");
1136
1152
  var syncContentPart = ({ message }, useContentPart, partIndex) => {
1137
1153
  const part = message.content[partIndex];
1138
1154
  if (!part) return;
@@ -1149,14 +1165,14 @@ var syncContentPart = ({ message }, useContentPart, partIndex) => {
1149
1165
  };
1150
1166
  var useContentPartContext2 = (partIndex) => {
1151
1167
  const { useMessage } = useMessageContext();
1152
- const [context] = (0, import_react32.useState)(() => {
1168
+ const [context] = (0, import_react33.useState)(() => {
1153
1169
  const useContentPart = (0, import_zustand9.create)(
1154
1170
  () => ({})
1155
1171
  );
1156
1172
  syncContentPart(useMessage.getState(), useContentPart, partIndex);
1157
1173
  return { useContentPart };
1158
1174
  });
1159
- (0, import_react32.useEffect)(() => {
1175
+ (0, import_react33.useEffect)(() => {
1160
1176
  syncContentPart(useMessage.getState(), context.useContentPart, partIndex);
1161
1177
  return useMessage.subscribe((message) => {
1162
1178
  syncContentPart(message, context.useContentPart, partIndex);
@@ -1169,7 +1185,7 @@ var ContentPartProvider = ({
1169
1185
  children
1170
1186
  }) => {
1171
1187
  const context = useContentPartContext2(partIndex);
1172
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ContentPartContext.Provider, { value: context, children });
1188
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ContentPartContext.Provider, { value: context, children });
1173
1189
  };
1174
1190
 
1175
1191
  // src/primitives/contentPart/ContentPartDisplay.tsx
@@ -1180,11 +1196,11 @@ var ContentPartPrimitiveDisplay = () => {
1180
1196
  ContentPartPrimitiveDisplay.displayName = "ContentPartPrimitive.Display";
1181
1197
 
1182
1198
  // src/utils/OutPortal.tsx
1183
- var import_react33 = require("react");
1184
- var import_jsx_runtime13 = require("react/jsx-runtime");
1199
+ var import_react34 = require("react");
1200
+ var import_jsx_runtime14 = require("react/jsx-runtime");
1185
1201
  var OutPortal = ({ node }) => {
1186
- const parentRef = (0, import_react33.useRef)(null);
1187
- (0, import_react33.useLayoutEffect)(() => {
1202
+ const parentRef = (0, import_react34.useRef)(null);
1203
+ (0, import_react34.useLayoutEffect)(() => {
1188
1204
  const parent = parentRef.current;
1189
1205
  if (!parent || !node) return;
1190
1206
  parent.appendChild(node);
@@ -1193,11 +1209,11 @@ var OutPortal = ({ node }) => {
1193
1209
  };
1194
1210
  }, [node]);
1195
1211
  if (!node) return null;
1196
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { ref: parentRef });
1212
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { ref: parentRef });
1197
1213
  };
1198
1214
 
1199
1215
  // src/primitives/contentPart/ContentPartInProgressIndicator.tsx
1200
- var import_jsx_runtime14 = require("react/jsx-runtime");
1216
+ var import_jsx_runtime15 = require("react/jsx-runtime");
1201
1217
  var ContentPartPrimitiveInProgressIndicator = () => {
1202
1218
  const { useMessageUtils } = useMessageContext();
1203
1219
  const { useContentPart } = useContentPartContext();
@@ -1205,35 +1221,35 @@ var ContentPartPrimitiveInProgressIndicator = () => {
1205
1221
  [useMessageUtils, useContentPart],
1206
1222
  (m, c) => c.status === "in_progress" ? m.inProgressIndicator : null
1207
1223
  );
1208
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(OutPortal, { node: indicator });
1224
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(OutPortal, { node: indicator });
1209
1225
  };
1210
1226
  ContentPartPrimitiveInProgressIndicator.displayName = "ContentPartPrimitive.InProgressIndicator";
1211
1227
 
1212
1228
  // src/primitives/contentPart/ContentPartText.tsx
1213
1229
  var import_react_primitive4 = require("@radix-ui/react-primitive");
1214
- var import_react34 = require("react");
1215
- var import_jsx_runtime15 = require("react/jsx-runtime");
1216
- var ContentPartPrimitiveText = (0, import_react34.forwardRef)((props, forwardedRef) => {
1230
+ var import_react35 = require("react");
1231
+ var import_jsx_runtime16 = require("react/jsx-runtime");
1232
+ var ContentPartPrimitiveText = (0, import_react35.forwardRef)((props, forwardedRef) => {
1217
1233
  const text = useContentPartText();
1218
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react_primitive4.Primitive.span, { ...props, ref: forwardedRef, children: text });
1234
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react_primitive4.Primitive.span, { ...props, ref: forwardedRef, children: text });
1219
1235
  });
1220
1236
  ContentPartPrimitiveText.displayName = "ContentPartPrimitive.Text";
1221
1237
 
1222
1238
  // src/primitives/message/MessageContent.tsx
1223
- var import_jsx_runtime16 = require("react/jsx-runtime");
1239
+ var import_jsx_runtime17 = require("react/jsx-runtime");
1224
1240
  var defaultComponents = {
1225
- Text: () => /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("p", { style: { whiteSpace: "pre-line" }, children: [
1226
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ContentPartPrimitiveText, {}),
1227
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ContentPartPrimitiveInProgressIndicator, {})
1241
+ Text: () => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("p", { style: { whiteSpace: "pre-line" }, children: [
1242
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ContentPartPrimitiveText, {}),
1243
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ContentPartPrimitiveInProgressIndicator, {})
1228
1244
  ] }),
1229
1245
  Image: () => null,
1230
- UI: () => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ContentPartPrimitiveDisplay, {}),
1246
+ UI: () => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ContentPartPrimitiveDisplay, {}),
1231
1247
  tools: {
1232
1248
  Fallback: (props) => {
1233
1249
  const { useToolUIs } = useAssistantContext();
1234
1250
  const Render = useToolUIs((s) => s.getToolUI(props.part.toolName));
1235
1251
  if (!Render) return null;
1236
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Render, { ...props });
1252
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Render, { ...props });
1237
1253
  }
1238
1254
  }
1239
1255
  };
@@ -1252,15 +1268,15 @@ var MessageContentPartComponent = ({
1252
1268
  const type = part.type;
1253
1269
  switch (type) {
1254
1270
  case "text":
1255
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Text, { part, status });
1271
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Text, { part, status });
1256
1272
  case "image":
1257
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Image, { part, status });
1273
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Image, { part, status });
1258
1274
  case "ui":
1259
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(UI, { part, status });
1275
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(UI, { part, status });
1260
1276
  case "tool-call": {
1261
1277
  const Tool = by_name[part.toolName] || Fallback;
1262
1278
  const addResult = (result) => addToolResult(part.toolCallId, result);
1263
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Tool, { part, status, addResult });
1279
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Tool, { part, status, addResult });
1264
1280
  }
1265
1281
  default:
1266
1282
  throw new Error(`Unknown content part type: ${type}`);
@@ -1270,9 +1286,9 @@ var MessageContentPartImpl = ({
1270
1286
  partIndex,
1271
1287
  components
1272
1288
  }) => {
1273
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ContentPartProvider, { partIndex, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(MessageContentPartComponent, { components }) });
1289
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ContentPartProvider, { partIndex, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(MessageContentPartComponent, { components }) });
1274
1290
  };
1275
- var MessageContentPart = (0, import_react35.memo)(
1291
+ var MessageContentPart = (0, import_react36.memo)(
1276
1292
  MessageContentPartImpl,
1277
1293
  (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
1278
1294
  );
@@ -1283,7 +1299,7 @@ var MessagePrimitiveContent = ({
1283
1299
  const contentLength = useMessage((s) => s.message.content.length);
1284
1300
  return new Array(contentLength).fill(null).map((_, idx) => {
1285
1301
  const partIndex = idx;
1286
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1302
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1287
1303
  MessageContentPart,
1288
1304
  {
1289
1305
  partIndex,
@@ -1298,19 +1314,19 @@ MessagePrimitiveContent.displayName = "MessagePrimitive.Content";
1298
1314
  // src/primitives/message/MessageInProgress.tsx
1299
1315
  var import_react_dom = require("react-dom");
1300
1316
  var import_react_primitive5 = require("@radix-ui/react-primitive");
1301
- var import_react36 = require("react");
1302
- var import_jsx_runtime17 = require("react/jsx-runtime");
1303
- var MessagePrimitiveInProgress = (0, import_react36.forwardRef)((props, ref) => {
1317
+ var import_react37 = require("react");
1318
+ var import_jsx_runtime18 = require("react/jsx-runtime");
1319
+ var MessagePrimitiveInProgress = (0, import_react37.forwardRef)((props, ref) => {
1304
1320
  const { useMessageUtils } = useMessageContext();
1305
1321
  const portalNode = useMessageUtils((s) => s.inProgressIndicator);
1306
- return (0, import_react_dom.createPortal)(/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_primitive5.Primitive.span, { ...props, ref }), portalNode);
1322
+ return (0, import_react_dom.createPortal)(/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react_primitive5.Primitive.span, { ...props, ref }), portalNode);
1307
1323
  });
1308
1324
  MessagePrimitiveInProgress.displayName = "MessagePrimitive.InProgress";
1309
1325
 
1310
1326
  // src/primitives/branchPicker/BranchPickerRoot.tsx
1311
- var import_jsx_runtime18 = require("react/jsx-runtime");
1312
- var BranchPickerPrimitiveRoot = (0, import_react37.forwardRef)(({ hideWhenSingleBranch, ...rest }, ref) => {
1313
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(MessagePrimitiveIf, { hasBranches: hideWhenSingleBranch ? true : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react_primitive6.Primitive.div, { ...rest, ref }) });
1327
+ var import_jsx_runtime19 = require("react/jsx-runtime");
1328
+ var BranchPickerPrimitiveRoot = (0, import_react38.forwardRef)(({ hideWhenSingleBranch, ...rest }, ref) => {
1329
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(MessagePrimitiveIf, { hasBranches: hideWhenSingleBranch ? true : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react_primitive6.Primitive.div, { ...rest, ref }) });
1314
1330
  });
1315
1331
  BranchPickerPrimitiveRoot.displayName = "BranchPickerPrimitive.Root";
1316
1332
 
@@ -1327,16 +1343,16 @@ __export(composer_exports, {
1327
1343
  // src/primitives/composer/ComposerRoot.tsx
1328
1344
  var import_primitive5 = require("@radix-ui/primitive");
1329
1345
  var import_react_primitive7 = require("@radix-ui/react-primitive");
1330
- var import_react38 = require("react");
1331
- var import_jsx_runtime19 = require("react/jsx-runtime");
1332
- var ComposerPrimitiveRoot = (0, import_react38.forwardRef)(({ onSubmit, ...rest }, forwardedRef) => {
1346
+ var import_react39 = require("react");
1347
+ var import_jsx_runtime20 = require("react/jsx-runtime");
1348
+ var ComposerPrimitiveRoot = (0, import_react39.forwardRef)(({ onSubmit, ...rest }, forwardedRef) => {
1333
1349
  const send = useComposerSend();
1334
1350
  const handleSubmit = (e) => {
1335
1351
  e.preventDefault();
1336
1352
  if (!send) return;
1337
1353
  send();
1338
1354
  };
1339
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1355
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
1340
1356
  import_react_primitive7.Primitive.form,
1341
1357
  {
1342
1358
  ...rest,
@@ -1351,11 +1367,11 @@ ComposerPrimitiveRoot.displayName = "ComposerPrimitive.Root";
1351
1367
  var import_primitive6 = require("@radix-ui/primitive");
1352
1368
  var import_react_compose_refs = require("@radix-ui/react-compose-refs");
1353
1369
  var import_react_slot = require("@radix-ui/react-slot");
1354
- var import_react39 = require("react");
1370
+ var import_react40 = require("react");
1355
1371
  var import_react_textarea_autosize = __toESM(require("react-textarea-autosize"));
1356
1372
  var import_react_use_escape_keydown = require("@radix-ui/react-use-escape-keydown");
1357
- var import_jsx_runtime20 = require("react/jsx-runtime");
1358
- var ComposerPrimitiveInput = (0, import_react39.forwardRef)(
1373
+ var import_jsx_runtime21 = require("react/jsx-runtime");
1374
+ var ComposerPrimitiveInput = (0, import_react40.forwardRef)(
1359
1375
  ({ autoFocus = false, asChild, disabled, onChange, onKeyDown, ...rest }, forwardedRef) => {
1360
1376
  const { useThread } = useThreadContext();
1361
1377
  const { useComposer, type } = useComposerContext();
@@ -1364,7 +1380,7 @@ var ComposerPrimitiveInput = (0, import_react39.forwardRef)(
1364
1380
  return c.value;
1365
1381
  });
1366
1382
  const Component = asChild ? import_react_slot.Slot : import_react_textarea_autosize.default;
1367
- const textareaRef = (0, import_react39.useRef)(null);
1383
+ const textareaRef = (0, import_react40.useRef)(null);
1368
1384
  const ref = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, textareaRef);
1369
1385
  (0, import_react_use_escape_keydown.useEscapeKeydown)((e) => {
1370
1386
  const composer = useComposer.getState();
@@ -1383,7 +1399,7 @@ var ComposerPrimitiveInput = (0, import_react39.forwardRef)(
1383
1399
  }
1384
1400
  };
1385
1401
  const autoFocusEnabled = autoFocus && !disabled;
1386
- const focus = (0, import_react39.useCallback)(() => {
1402
+ const focus = (0, import_react40.useCallback)(() => {
1387
1403
  const textarea = textareaRef.current;
1388
1404
  if (!textarea || !autoFocusEnabled) return;
1389
1405
  textarea.focus({ preventScroll: true });
@@ -1392,13 +1408,13 @@ var ComposerPrimitiveInput = (0, import_react39.forwardRef)(
1392
1408
  textareaRef.current.value.length
1393
1409
  );
1394
1410
  }, [autoFocusEnabled]);
1395
- (0, import_react39.useEffect)(() => focus(), [focus]);
1411
+ (0, import_react40.useEffect)(() => focus(), [focus]);
1396
1412
  useOnComposerFocus(() => {
1397
1413
  if (type === "new") {
1398
1414
  focus();
1399
1415
  }
1400
1416
  });
1401
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
1417
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
1402
1418
  Component,
1403
1419
  {
1404
1420
  value,
@@ -1418,13 +1434,13 @@ var ComposerPrimitiveInput = (0, import_react39.forwardRef)(
1418
1434
  ComposerPrimitiveInput.displayName = "ComposerPrimitive.Input";
1419
1435
 
1420
1436
  // src/primitives/composer/ComposerSend.tsx
1421
- var import_react40 = require("react");
1437
+ var import_react41 = require("react");
1422
1438
  var import_react_primitive8 = require("@radix-ui/react-primitive");
1423
- var import_jsx_runtime21 = require("react/jsx-runtime");
1424
- var ComposerPrimitiveSend = (0, import_react40.forwardRef)(({ disabled, ...rest }, ref) => {
1439
+ var import_jsx_runtime22 = require("react/jsx-runtime");
1440
+ var ComposerPrimitiveSend = (0, import_react41.forwardRef)(({ disabled, ...rest }, ref) => {
1425
1441
  const { useComposer } = useComposerContext();
1426
1442
  const hasValue = useComposer((c) => c.isEditing && c.value.length > 0);
1427
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
1443
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
1428
1444
  import_react_primitive8.Primitive.button,
1429
1445
  {
1430
1446
  type: "submit",
@@ -1463,11 +1479,11 @@ __export(contentPart_exports, {
1463
1479
 
1464
1480
  // src/primitives/contentPart/ContentPartImage.tsx
1465
1481
  var import_react_primitive9 = require("@radix-ui/react-primitive");
1466
- var import_react41 = require("react");
1467
- var import_jsx_runtime22 = require("react/jsx-runtime");
1468
- var ContentPartPrimitiveImage = (0, import_react41.forwardRef)((props, forwardedRef) => {
1482
+ var import_react42 = require("react");
1483
+ var import_jsx_runtime23 = require("react/jsx-runtime");
1484
+ var ContentPartPrimitiveImage = (0, import_react42.forwardRef)((props, forwardedRef) => {
1469
1485
  const image = useContentPartImage();
1470
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_react_primitive9.Primitive.img, { src: image, ...props, ref: forwardedRef });
1486
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_react_primitive9.Primitive.img, { src: image, ...props, ref: forwardedRef });
1471
1487
  });
1472
1488
  ContentPartPrimitiveImage.displayName = "ContentPartPrimitive.Image";
1473
1489
 
@@ -1485,10 +1501,10 @@ __export(thread_exports, {
1485
1501
 
1486
1502
  // src/primitives/thread/ThreadRoot.tsx
1487
1503
  var import_react_primitive10 = require("@radix-ui/react-primitive");
1488
- var import_react42 = require("react");
1489
- var import_jsx_runtime23 = require("react/jsx-runtime");
1490
- var ThreadPrimitiveRoot = (0, import_react42.forwardRef)((props, ref) => {
1491
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_react_primitive10.Primitive.div, { ...props, ref });
1504
+ var import_react43 = require("react");
1505
+ var import_jsx_runtime24 = require("react/jsx-runtime");
1506
+ var ThreadPrimitiveRoot = (0, import_react43.forwardRef)((props, ref) => {
1507
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react_primitive10.Primitive.div, { ...props, ref });
1492
1508
  });
1493
1509
  ThreadPrimitiveRoot.displayName = "ThreadPrimitive.Root";
1494
1510
 
@@ -1514,21 +1530,21 @@ ThreadPrimitiveIf.displayName = "ThreadPrimitive.If";
1514
1530
  // src/primitives/thread/ThreadViewport.tsx
1515
1531
  var import_react_compose_refs3 = require("@radix-ui/react-compose-refs");
1516
1532
  var import_react_primitive11 = require("@radix-ui/react-primitive");
1517
- var import_react47 = require("react");
1533
+ var import_react48 = require("react");
1518
1534
 
1519
1535
  // src/primitive-hooks/thread/useThreadViewportAutoScroll.tsx
1520
1536
  var import_react_compose_refs2 = require("@radix-ui/react-compose-refs");
1521
- var import_react46 = require("react");
1537
+ var import_react47 = require("react");
1522
1538
 
1523
1539
  // src/utils/hooks/useOnResizeContent.tsx
1524
1540
  var import_react_use_callback_ref2 = require("@radix-ui/react-use-callback-ref");
1525
- var import_react44 = require("react");
1541
+ var import_react45 = require("react");
1526
1542
 
1527
1543
  // src/utils/hooks/useManagedRef.ts
1528
- var import_react43 = require("react");
1544
+ var import_react44 = require("react");
1529
1545
  var useManagedRef = (callback) => {
1530
- const cleanupRef = (0, import_react43.useRef)();
1531
- const ref = (0, import_react43.useCallback)(
1546
+ const cleanupRef = (0, import_react44.useRef)();
1547
+ const ref = (0, import_react44.useCallback)(
1532
1548
  (el) => {
1533
1549
  if (cleanupRef.current) {
1534
1550
  cleanupRef.current();
@@ -1545,7 +1561,7 @@ var useManagedRef = (callback) => {
1545
1561
  // src/utils/hooks/useOnResizeContent.tsx
1546
1562
  var useOnResizeContent = (callback) => {
1547
1563
  const callbackRef = (0, import_react_use_callback_ref2.useCallbackRef)(callback);
1548
- const refCallback = (0, import_react44.useCallback)(
1564
+ const refCallback = (0, import_react45.useCallback)(
1549
1565
  (el) => {
1550
1566
  const resizeObserver = new ResizeObserver(() => {
1551
1567
  callbackRef();
@@ -1582,11 +1598,11 @@ var useOnResizeContent = (callback) => {
1582
1598
 
1583
1599
  // src/utils/hooks/useOnScrollToBottom.tsx
1584
1600
  var import_react_use_callback_ref3 = require("@radix-ui/react-use-callback-ref");
1585
- var import_react45 = require("react");
1601
+ var import_react46 = require("react");
1586
1602
  var useOnScrollToBottom = (callback) => {
1587
1603
  const callbackRef = (0, import_react_use_callback_ref3.useCallbackRef)(callback);
1588
1604
  const { useViewport } = useThreadContext();
1589
- (0, import_react45.useEffect)(() => {
1605
+ (0, import_react46.useEffect)(() => {
1590
1606
  return useViewport.getState().onScrollToBottom(() => {
1591
1607
  callbackRef();
1592
1608
  });
@@ -1597,11 +1613,11 @@ var useOnScrollToBottom = (callback) => {
1597
1613
  var useThreadViewportAutoScroll = ({
1598
1614
  autoScroll = true
1599
1615
  }) => {
1600
- const divRef = (0, import_react46.useRef)(null);
1616
+ const divRef = (0, import_react47.useRef)(null);
1601
1617
  const { useViewport } = useThreadContext();
1602
- const firstRenderRef = (0, import_react46.useRef)(true);
1603
- const lastScrollTop = (0, import_react46.useRef)(0);
1604
- const isScrollingToBottomRef = (0, import_react46.useRef)(false);
1618
+ const firstRenderRef = (0, import_react47.useRef)(true);
1619
+ const lastScrollTop = (0, import_react47.useRef)(0);
1620
+ const isScrollingToBottomRef = (0, import_react47.useRef)(false);
1605
1621
  const scrollToBottom = () => {
1606
1622
  const div = divRef.current;
1607
1623
  if (!div || !autoScroll) return;
@@ -1647,21 +1663,21 @@ var useThreadViewportAutoScroll = ({
1647
1663
  };
1648
1664
 
1649
1665
  // src/primitives/thread/ThreadViewport.tsx
1650
- var import_jsx_runtime24 = require("react/jsx-runtime");
1651
- var ThreadPrimitiveViewport = (0, import_react47.forwardRef)(({ autoScroll, onScroll, children, ...rest }, forwardedRef) => {
1666
+ var import_jsx_runtime25 = require("react/jsx-runtime");
1667
+ var ThreadPrimitiveViewport = (0, import_react48.forwardRef)(({ autoScroll, onScroll, children, ...rest }, forwardedRef) => {
1652
1668
  const autoScrollRef = useThreadViewportAutoScroll({
1653
1669
  autoScroll
1654
1670
  });
1655
1671
  const ref = (0, import_react_compose_refs3.useComposedRefs)(forwardedRef, autoScrollRef);
1656
- return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react_primitive11.Primitive.div, { ...rest, ref, children });
1672
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_react_primitive11.Primitive.div, { ...rest, ref, children });
1657
1673
  });
1658
1674
  ThreadPrimitiveViewport.displayName = "ThreadPrimitive.Viewport";
1659
1675
 
1660
1676
  // src/primitives/thread/ThreadMessages.tsx
1661
- var import_react49 = require("react");
1677
+ var import_react50 = require("react");
1662
1678
 
1663
1679
  // src/context/providers/MessageProvider.tsx
1664
- var import_react48 = require("react");
1680
+ var import_react49 = require("react");
1665
1681
  var import_zustand12 = require("zustand");
1666
1682
 
1667
1683
  // src/context/stores/EditComposer.ts
@@ -1703,7 +1719,7 @@ var makeMessageUtilsStore = () => (0, import_zustand11.create)((set) => ({
1703
1719
  }));
1704
1720
 
1705
1721
  // src/context/providers/MessageProvider.tsx
1706
- var import_jsx_runtime25 = require("react/jsx-runtime");
1722
+ var import_jsx_runtime26 = require("react/jsx-runtime");
1707
1723
  var getIsLast = (messages, message) => {
1708
1724
  return messages[messages.length - 1]?.id === message.id;
1709
1725
  };
@@ -1725,7 +1741,7 @@ var syncMessage = (messages, getBranches, useMessage, messageIndex) => {
1725
1741
  };
1726
1742
  var useMessageContext2 = (messageIndex) => {
1727
1743
  const { useThreadMessages, useThreadActions } = useThreadContext();
1728
- const [context] = (0, import_react48.useState)(() => {
1744
+ const [context] = (0, import_react49.useState)(() => {
1729
1745
  const useMessage = (0, import_zustand12.create)(() => ({}));
1730
1746
  const useMessageUtils = makeMessageUtilsStore();
1731
1747
  const useEditComposer = makeEditComposerStore({
@@ -1762,7 +1778,7 @@ var useMessageContext2 = (messageIndex) => {
1762
1778
  );
1763
1779
  return { useMessage, useMessageUtils, useEditComposer };
1764
1780
  });
1765
- (0, import_react48.useEffect)(() => {
1781
+ (0, import_react49.useEffect)(() => {
1766
1782
  return useThreadMessages.subscribe((thread) => {
1767
1783
  syncMessage(
1768
1784
  thread,
@@ -1779,11 +1795,11 @@ var MessageProvider = ({
1779
1795
  children
1780
1796
  }) => {
1781
1797
  const context = useMessageContext2(messageIndex);
1782
- return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(MessageContext.Provider, { value: context, children });
1798
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(MessageContext.Provider, { value: context, children });
1783
1799
  };
1784
1800
 
1785
1801
  // src/primitives/thread/ThreadMessages.tsx
1786
- var import_jsx_runtime26 = require("react/jsx-runtime");
1802
+ var import_jsx_runtime27 = require("react/jsx-runtime");
1787
1803
  var getComponents = (components) => {
1788
1804
  return {
1789
1805
  EditComposer: components.EditComposer ?? components.UserMessage ?? components.Message,
@@ -1796,15 +1812,15 @@ var ThreadMessageImpl = ({
1796
1812
  components
1797
1813
  }) => {
1798
1814
  const { UserMessage, EditComposer, AssistantMessage } = getComponents(components);
1799
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(MessageProvider, { messageIndex, children: [
1800
- /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(MessagePrimitiveIf, { user: true, children: [
1801
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ComposerPrimitiveIf, { editing: false, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(UserMessage, {}) }),
1802
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ComposerPrimitiveIf, { editing: true, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(EditComposer, {}) })
1815
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(MessageProvider, { messageIndex, children: [
1816
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(MessagePrimitiveIf, { user: true, children: [
1817
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ComposerPrimitiveIf, { editing: false, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(UserMessage, {}) }),
1818
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ComposerPrimitiveIf, { editing: true, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(EditComposer, {}) })
1803
1819
  ] }),
1804
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(MessagePrimitiveIf, { assistant: true, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(AssistantMessage, {}) })
1820
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(MessagePrimitiveIf, { assistant: true, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(AssistantMessage, {}) })
1805
1821
  ] });
1806
1822
  };
1807
- var ThreadMessage = (0, import_react49.memo)(
1823
+ var ThreadMessage = (0, import_react50.memo)(
1808
1824
  ThreadMessageImpl,
1809
1825
  (prev, next) => prev.messageIndex === next.messageIndex && prev.components.UserMessage === next.components.UserMessage && prev.components.EditComposer === next.components.EditComposer && prev.components.AssistantMessage === next.components.AssistantMessage
1810
1826
  );
@@ -1816,7 +1832,7 @@ var ThreadPrimitiveMessages = ({
1816
1832
  if (messagesLength === 0) return null;
1817
1833
  return new Array(messagesLength).fill(null).map((_, idx) => {
1818
1834
  const messageIndex = idx;
1819
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
1835
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
1820
1836
  ThreadMessage,
1821
1837
  {
1822
1838
  messageIndex,
@@ -1841,7 +1857,7 @@ var ThreadPrimitiveSuggestion = createActionButton(
1841
1857
  );
1842
1858
 
1843
1859
  // src/runtime/local/useLocalRuntime.tsx
1844
- var import_react50 = require("react");
1860
+ var import_react51 = require("react");
1845
1861
 
1846
1862
  // src/runtime/utils/idUtils.tsx
1847
1863
  var import_non_secure = require("nanoid/non-secure");
@@ -2173,8 +2189,8 @@ var LocalThreadRuntime = class {
2173
2189
 
2174
2190
  // src/runtime/local/useLocalRuntime.tsx
2175
2191
  var useLocalRuntime = (adapter) => {
2176
- const [runtime] = (0, import_react50.useState)(() => new LocalRuntime(adapter));
2177
- (0, import_react50.useInsertionEffect)(() => {
2192
+ const [runtime] = (0, import_react51.useState)(() => new LocalRuntime(adapter));
2193
+ (0, import_react51.useInsertionEffect)(() => {
2178
2194
  runtime.adapter = adapter;
2179
2195
  });
2180
2196
  return runtime;