@assistant-ui/react 0.5.19 → 0.5.21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. package/dist/AssistantTypes-D93BmqD5.d.mts +160 -0
  2. package/dist/AssistantTypes-D93BmqD5.d.ts +160 -0
  3. package/dist/Thread-BbLf1cc4.d.mts +156 -0
  4. package/dist/Thread-jfAlPLli.d.ts +156 -0
  5. package/dist/chunk-2RKUKZSZ.mjs +761 -0
  6. package/dist/chunk-2RKUKZSZ.mjs.map +1 -0
  7. package/dist/chunk-BJPOCE4O.mjs +11 -0
  8. package/dist/chunk-BJPOCE4O.mjs.map +1 -0
  9. package/dist/chunk-QBS6JLLN.mjs +63 -0
  10. package/dist/chunk-QBS6JLLN.mjs.map +1 -0
  11. package/dist/chunk-V66MVXBH.mjs +608 -0
  12. package/dist/chunk-V66MVXBH.mjs.map +1 -0
  13. package/dist/edge.d.mts +5 -90
  14. package/dist/edge.d.ts +5 -90
  15. package/dist/edge.js +1 -0
  16. package/dist/edge.js.map +1 -1
  17. package/dist/edge.mjs +49 -799
  18. package/dist/edge.mjs.map +1 -1
  19. package/dist/index.d.mts +17 -293
  20. package/dist/index.d.ts +17 -293
  21. package/dist/index.js +341 -283
  22. package/dist/index.js.map +1 -1
  23. package/dist/index.mjs +313 -1601
  24. package/dist/index.mjs.map +1 -1
  25. package/dist/internal.d.mts +9 -0
  26. package/dist/internal.d.ts +9 -0
  27. package/dist/internal.js +620 -0
  28. package/dist/internal.js.map +1 -0
  29. package/dist/internal.mjs +24 -0
  30. package/dist/internal.mjs.map +1 -0
  31. package/dist/styles/index.css +3 -3
  32. package/dist/styles/index.css.map +1 -1
  33. package/dist/styles/tailwindcss/thread.css +1 -1
  34. package/dist/tailwindcss/index.js +1 -0
  35. package/dist/tailwindcss/index.js.map +1 -1
  36. package/dist/tailwindcss/index.mjs +3 -0
  37. package/dist/tailwindcss/index.mjs.map +1 -1
  38. package/internal/README.md +1 -0
  39. package/internal/package.json +5 -0
  40. package/package.json +12 -1
package/dist/index.mjs CHANGED
@@ -1,9 +1,40 @@
1
1
  "use client";
2
- var __defProp = Object.defineProperty;
3
- var __export = (target, all) => {
4
- for (var name in all)
5
- __defProp(target, name, { get: all[name], enumerable: true });
6
- };
2
+ import {
3
+ runResultStream,
4
+ toCoreMessage,
5
+ toCoreMessages,
6
+ toLanguageModelMessages,
7
+ toLanguageModelTools,
8
+ toolResultStream
9
+ } from "./chunk-2RKUKZSZ.mjs";
10
+ import {
11
+ AssistantContext,
12
+ BaseAssistantRuntime,
13
+ Button,
14
+ ContentPartContext,
15
+ MessageContext,
16
+ MessageRepository,
17
+ ProxyConfigProvider,
18
+ ThreadContext,
19
+ TooltipIconButton,
20
+ fromCoreMessage,
21
+ fromCoreMessages,
22
+ generateId,
23
+ internal_exports,
24
+ useAssistantContext,
25
+ useComposerContext,
26
+ useContentPartContext,
27
+ useMessageContext,
28
+ useSmooth,
29
+ useSmoothStatus,
30
+ useThreadContext,
31
+ withDefaults,
32
+ withSmoothContextProvider
33
+ } from "./chunk-V66MVXBH.mjs";
34
+ import "./chunk-QBS6JLLN.mjs";
35
+ import {
36
+ __export
37
+ } from "./chunk-BJPOCE4O.mjs";
7
38
 
8
39
  // src/context/providers/AssistantRuntimeProvider.tsx
9
40
  import { memo } from "react";
@@ -11,93 +42,8 @@ import { memo } from "react";
11
42
  // src/context/providers/AssistantProvider.tsx
12
43
  import { useEffect, useInsertionEffect as useInsertionEffect2, useRef as useRef2, useState as useState2 } from "react";
13
44
 
14
- // src/context/react/AssistantContext.ts
15
- import { createContext, useContext } from "react";
16
- var AssistantContext = createContext(
17
- null
18
- );
19
- function useAssistantContext(options) {
20
- const context = useContext(AssistantContext);
21
- if (!options?.optional && !context)
22
- throw new Error(
23
- "This component must be used within an AssistantRuntimeProvider."
24
- );
25
- return context;
26
- }
27
-
28
45
  // src/context/stores/AssistantModelConfig.ts
29
46
  import { create } from "zustand";
30
-
31
- // src/types/ModelConfigTypes.ts
32
- import { z } from "zod";
33
- var LanguageModelV1CallSettingsSchema = z.object({
34
- maxTokens: z.number().int().positive().optional(),
35
- temperature: z.number().optional(),
36
- topP: z.number().optional(),
37
- presencePenalty: z.number().optional(),
38
- frequencyPenalty: z.number().optional(),
39
- seed: z.number().int().optional(),
40
- headers: z.record(z.string().optional()).optional()
41
- });
42
- var LanguageModelConfigSchema = z.object({
43
- apiKey: z.string().optional(),
44
- baseUrl: z.string().optional(),
45
- modelName: z.string().optional()
46
- });
47
- var mergeModelConfigs = (configSet) => {
48
- const configs = Array.from(configSet).map((c) => c.getModelConfig()).sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
49
- return configs.reduce((acc, config) => {
50
- if (config.system) {
51
- if (acc.system) {
52
- acc.system += `
53
-
54
- ${config.system}`;
55
- } else {
56
- acc.system = config.system;
57
- }
58
- }
59
- if (config.tools) {
60
- for (const [name, tool] of Object.entries(config.tools)) {
61
- if (acc.tools?.[name]) {
62
- throw new Error(
63
- `You tried to define a tool with the name ${name}, but it already exists.`
64
- );
65
- }
66
- if (!acc.tools) acc.tools = {};
67
- acc.tools[name] = tool;
68
- }
69
- }
70
- if (config.config) {
71
- acc.config = {
72
- ...acc.config,
73
- ...config.config
74
- };
75
- }
76
- if (config.callSettings) {
77
- acc.callSettings = {
78
- ...acc.callSettings,
79
- ...config.callSettings
80
- };
81
- }
82
- return acc;
83
- }, {});
84
- };
85
-
86
- // src/utils/ProxyConfigProvider.ts
87
- var ProxyConfigProvider = class {
88
- _providers = /* @__PURE__ */ new Set();
89
- getModelConfig() {
90
- return mergeModelConfigs(this._providers);
91
- }
92
- registerModelConfigProvider(provider) {
93
- this._providers.add(provider);
94
- return () => {
95
- this._providers.delete(provider);
96
- };
97
- }
98
- };
99
-
100
- // src/context/stores/AssistantModelConfig.ts
101
47
  var makeAssistantModelConfigStore = () => create(() => {
102
48
  const proxy = new ProxyConfigProvider();
103
49
  return Object.freeze({
@@ -145,18 +91,6 @@ var makeAssistantToolUIsStore = () => create2((set) => {
145
91
  // src/context/providers/ThreadProvider.tsx
146
92
  import { useCallback as useCallback2, useInsertionEffect, useState } from "react";
147
93
 
148
- // src/context/react/ThreadContext.ts
149
- import { createContext as createContext2, useContext as useContext2 } from "react";
150
- var ThreadContext = createContext2(null);
151
- function useThreadContext(options) {
152
- const context = useContext2(ThreadContext);
153
- if (!options?.optional && !context)
154
- throw new Error(
155
- "This component must be used within an AssistantRuntimeProvider."
156
- );
157
- return context;
158
- }
159
-
160
94
  // src/context/stores/Composer.ts
161
95
  import { create as create3 } from "zustand";
162
96
 
@@ -384,48 +318,6 @@ var AssistantRuntimeProviderImpl = ({ children, runtime }) => {
384
318
  };
385
319
  var AssistantRuntimeProvider = memo(AssistantRuntimeProviderImpl);
386
320
 
387
- // src/context/react/ComposerContext.ts
388
- import { useMemo } from "react";
389
-
390
- // src/context/react/MessageContext.ts
391
- import { createContext as createContext3, useContext as useContext3 } from "react";
392
- var MessageContext = createContext3(null);
393
- function useMessageContext(options) {
394
- const context = useContext3(MessageContext);
395
- if (!options?.optional && !context)
396
- throw new Error(
397
- "This component can only be used inside a component passed to <ThreadPrimitive.Messages components={...} />."
398
- );
399
- return context;
400
- }
401
-
402
- // src/context/react/ComposerContext.ts
403
- var useComposerContext = () => {
404
- const { useComposer } = useThreadContext();
405
- const { useEditComposer } = useMessageContext({ optional: true }) ?? {};
406
- return useMemo(
407
- () => ({
408
- useComposer: useEditComposer ?? useComposer,
409
- type: useEditComposer ? "edit" : "new"
410
- }),
411
- [useEditComposer, useComposer]
412
- );
413
- };
414
-
415
- // src/context/react/ContentPartContext.ts
416
- import { createContext as createContext4, useContext as useContext4 } from "react";
417
- var ContentPartContext = createContext4(
418
- null
419
- );
420
- function useContentPartContext(options) {
421
- const context = useContext4(ContentPartContext);
422
- if (!options?.optional && !context)
423
- throw new Error(
424
- "This component can only be used inside a component passed to <MessagePrimitive.Content components={...} >."
425
- );
426
- return context;
427
- }
428
-
429
321
  // src/hooks/useAppendMessage.tsx
430
322
  import { useCallback as useCallback3 } from "react";
431
323
  var toAppendMessage = (useThreadMessages, message) => {
@@ -543,7 +435,7 @@ var useAssistantInstructions = (instruction) => {
543
435
  import { useCallback as useCallback5 } from "react";
544
436
 
545
437
  // src/utils/combined/useCombinedStore.ts
546
- import { useMemo as useMemo2 } from "react";
438
+ import { useMemo } from "react";
547
439
 
548
440
  // src/utils/combined/createCombinedStore.ts
549
441
  import { useSyncExternalStore } from "react";
@@ -564,7 +456,7 @@ var createCombinedStore = (stores) => {
564
456
 
565
457
  // src/utils/combined/useCombinedStore.ts
566
458
  var useCombinedStore = (stores, selector) => {
567
- const useCombined = useMemo2(() => createCombinedStore(stores), stores);
459
+ const useCombined = useMemo(() => createCombinedStore(stores), stores);
568
460
  return useCombined(selector);
569
461
  };
570
462
 
@@ -1118,7 +1010,7 @@ var BranchPickerPrimitiveNumber = () => {
1118
1010
  BranchPickerPrimitiveNumber.displayName = "BranchPickerPrimitive.Number";
1119
1011
 
1120
1012
  // src/primitives/branchPicker/BranchPickerRoot.tsx
1121
- import { Primitive as Primitive6 } from "@radix-ui/react-primitive";
1013
+ import { Primitive as Primitive5 } from "@radix-ui/react-primitive";
1122
1014
  import { forwardRef as forwardRef9 } from "react";
1123
1015
 
1124
1016
  // src/primitives/message/index.ts
@@ -1161,9 +1053,9 @@ var useIsHoveringRef = () => {
1161
1053
  );
1162
1054
  return useManagedRef(callbackRef);
1163
1055
  };
1164
- var MessagePrimitiveRoot = forwardRef6(({ onMouseEnter, onMouseLeave, ...rest }, forwardRef28) => {
1056
+ var MessagePrimitiveRoot = forwardRef6(({ onMouseEnter, onMouseLeave, ...rest }, forwardRef25) => {
1165
1057
  const isHoveringRef = useIsHoveringRef();
1166
- const ref = useComposedRefs(forwardRef28, isHoveringRef);
1058
+ const ref = useComposedRefs(forwardRef25, isHoveringRef);
1167
1059
  return /* @__PURE__ */ jsx12(Primitive3.div, { ...rest, ref });
1168
1060
  });
1169
1061
  MessagePrimitiveRoot.displayName = "MessagePrimitive.Root";
@@ -1225,7 +1117,6 @@ var useContentPartContext2 = (partIndex) => {
1225
1117
  const useContentPart = create10(
1226
1118
  () => getContentPartState(useMessage.getState(), void 0, partIndex)
1227
1119
  );
1228
- getContentPartState(useMessage.getState(), useContentPart, partIndex);
1229
1120
  return { useContentPart };
1230
1121
  });
1231
1122
  useEffect6(() => {
@@ -1252,108 +1143,28 @@ var ContentPartProvider = ({
1252
1143
  };
1253
1144
 
1254
1145
  // src/primitives/contentPart/ContentPartText.tsx
1255
- import { Primitive as Primitive4 } from "@radix-ui/react-primitive";
1256
- import { forwardRef as forwardRef7 } from "react";
1257
-
1258
- // src/utils/hooks/useSmooth.tsx
1259
- import { useEffect as useEffect7, useRef as useRef3, useState as useState5 } from "react";
1260
- var TextStreamAnimator = class {
1261
- constructor(currentText, setText) {
1262
- this.currentText = currentText;
1263
- this.setText = setText;
1264
- }
1265
- animationFrameId = null;
1266
- lastUpdateTime = Date.now();
1267
- targetText = "";
1268
- start() {
1269
- if (this.animationFrameId !== null) return;
1270
- this.lastUpdateTime = Date.now();
1271
- this.animate();
1272
- }
1273
- stop() {
1274
- if (this.animationFrameId !== null) {
1275
- cancelAnimationFrame(this.animationFrameId);
1276
- this.animationFrameId = null;
1277
- }
1278
- }
1279
- animate = () => {
1280
- const currentTime = Date.now();
1281
- const deltaTime = currentTime - this.lastUpdateTime;
1282
- let timeToConsume = deltaTime;
1283
- const remainingChars = this.targetText.length - this.currentText.length;
1284
- const baseTimePerChar = Math.min(5, 250 / remainingChars);
1285
- let charsToAdd = 0;
1286
- while (timeToConsume >= baseTimePerChar && charsToAdd < remainingChars) {
1287
- charsToAdd++;
1288
- timeToConsume -= baseTimePerChar;
1289
- }
1290
- if (charsToAdd !== remainingChars) {
1291
- this.animationFrameId = requestAnimationFrame(this.animate);
1292
- } else {
1293
- this.animationFrameId = null;
1294
- }
1295
- if (charsToAdd === 0) return;
1296
- this.currentText = this.targetText.slice(
1297
- 0,
1298
- this.currentText.length + charsToAdd
1299
- );
1300
- this.lastUpdateTime = currentTime - timeToConsume;
1301
- this.setText(this.currentText);
1302
- };
1303
- };
1304
- var useSmooth = (text, smooth = false) => {
1305
- const { useMessage } = useMessageContext();
1306
- const id = useMessage((m) => m.message.id);
1307
- const idRef = useRef3(id);
1308
- const [displayedText, setDisplayedText] = useState5(text);
1309
- const [animatorRef] = useState5(
1310
- new TextStreamAnimator(text, setDisplayedText)
1311
- );
1312
- useEffect7(() => {
1313
- if (!smooth) {
1314
- animatorRef.stop();
1315
- return;
1316
- }
1317
- if (idRef.current !== id || !text.startsWith(animatorRef.targetText)) {
1318
- idRef.current = id;
1319
- setDisplayedText(text);
1320
- animatorRef.currentText = text;
1321
- animatorRef.targetText = text;
1322
- animatorRef.stop();
1323
- return;
1324
- }
1325
- animatorRef.targetText = text;
1326
- animatorRef.start();
1327
- }, [animatorRef, id, smooth, text]);
1328
- useEffect7(() => {
1329
- return () => {
1330
- animatorRef.stop();
1331
- };
1332
- }, [animatorRef]);
1333
- return smooth ? displayedText : text;
1334
- };
1335
-
1336
- // src/primitives/contentPart/ContentPartText.tsx
1146
+ import {
1147
+ forwardRef as forwardRef7
1148
+ } from "react";
1337
1149
  import { jsx as jsx14 } from "react/jsx-runtime";
1338
- var ContentPartPrimitiveText = forwardRef7(({ smooth = true, ...rest }, forwardedRef) => {
1150
+ var ContentPartPrimitiveText = forwardRef7(({ smooth = true, component: Component = "span", ...rest }, forwardedRef) => {
1339
1151
  const {
1340
- status,
1341
- part: { text }
1342
- } = useContentPartText();
1343
- const smoothText = useSmooth(text, smooth);
1344
- return /* @__PURE__ */ jsx14(Primitive4.span, { "data-status": status.type, ...rest, ref: forwardedRef, children: smoothText });
1152
+ part: { text },
1153
+ status
1154
+ } = useSmooth(useContentPartText(), smooth);
1155
+ return /* @__PURE__ */ jsx14(Component, { "data-status": status.type, ...rest, ref: forwardedRef, children: text });
1345
1156
  });
1346
1157
  ContentPartPrimitiveText.displayName = "ContentPartPrimitive.Text";
1347
1158
 
1348
1159
  // src/primitives/contentPart/ContentPartImage.tsx
1349
- import { Primitive as Primitive5 } from "@radix-ui/react-primitive";
1160
+ import { Primitive as Primitive4 } from "@radix-ui/react-primitive";
1350
1161
  import { forwardRef as forwardRef8 } from "react";
1351
1162
  import { jsx as jsx15 } from "react/jsx-runtime";
1352
1163
  var ContentPartPrimitiveImage = forwardRef8((props, forwardedRef) => {
1353
1164
  const {
1354
1165
  part: { image }
1355
1166
  } = useContentPartImage();
1356
- return /* @__PURE__ */ jsx15(Primitive5.img, { src: image, ...props, ref: forwardedRef });
1167
+ return /* @__PURE__ */ jsx15(Primitive4.img, { src: image, ...props, ref: forwardedRef });
1357
1168
  });
1358
1169
  ContentPartPrimitiveImage.displayName = "ContentPartPrimitive.Image";
1359
1170
 
@@ -1473,7 +1284,7 @@ MessagePrimitiveInProgress.displayName = "MessagePrimitive.InProgress";
1473
1284
  // src/primitives/branchPicker/BranchPickerRoot.tsx
1474
1285
  import { jsx as jsx17 } from "react/jsx-runtime";
1475
1286
  var BranchPickerPrimitiveRoot = forwardRef9(({ hideWhenSingleBranch, ...rest }, ref) => {
1476
- return /* @__PURE__ */ jsx17(MessagePrimitiveIf, { hasBranches: hideWhenSingleBranch ? true : void 0, children: /* @__PURE__ */ jsx17(Primitive6.div, { ...rest, ref }) });
1287
+ return /* @__PURE__ */ jsx17(MessagePrimitiveIf, { hasBranches: hideWhenSingleBranch ? true : void 0, children: /* @__PURE__ */ jsx17(Primitive5.div, { ...rest, ref }) });
1477
1288
  });
1478
1289
  BranchPickerPrimitiveRoot.displayName = "BranchPickerPrimitive.Root";
1479
1290
 
@@ -1489,7 +1300,7 @@ __export(composer_exports, {
1489
1300
 
1490
1301
  // src/primitives/composer/ComposerRoot.tsx
1491
1302
  import { composeEventHandlers as composeEventHandlers4 } from "@radix-ui/primitive";
1492
- import { Primitive as Primitive7 } from "@radix-ui/react-primitive";
1303
+ import { Primitive as Primitive6 } from "@radix-ui/react-primitive";
1493
1304
  import {
1494
1305
  forwardRef as forwardRef10
1495
1306
  } from "react";
@@ -1502,7 +1313,7 @@ var ComposerPrimitiveRoot = forwardRef10(({ onSubmit, ...rest }, forwardedRef) =
1502
1313
  send();
1503
1314
  };
1504
1315
  return /* @__PURE__ */ jsx18(
1505
- Primitive7.form,
1316
+ Primitive6.form,
1506
1317
  {
1507
1318
  ...rest,
1508
1319
  ref: forwardedRef,
@@ -1519,8 +1330,8 @@ import { Slot } from "@radix-ui/react-slot";
1519
1330
  import {
1520
1331
  forwardRef as forwardRef11,
1521
1332
  useCallback as useCallback15,
1522
- useEffect as useEffect8,
1523
- useRef as useRef4
1333
+ useEffect as useEffect7,
1334
+ useRef as useRef3
1524
1335
  } from "react";
1525
1336
  import TextareaAutosize from "react-textarea-autosize";
1526
1337
  import { useEscapeKeydown } from "@radix-ui/react-use-escape-keydown";
@@ -1542,7 +1353,7 @@ var ComposerPrimitiveInput = forwardRef11(
1542
1353
  });
1543
1354
  const Component = asChild ? Slot : TextareaAutosize;
1544
1355
  const isDisabled = useThread((t) => t.isDisabled) ?? disabledProp ?? false;
1545
- const textareaRef = useRef4(null);
1356
+ const textareaRef = useRef3(null);
1546
1357
  const ref = useComposedRefs2(forwardedRef, textareaRef);
1547
1358
  useEscapeKeydown((e) => {
1548
1359
  const composer = useComposer.getState();
@@ -1571,7 +1382,7 @@ var ComposerPrimitiveInput = forwardRef11(
1571
1382
  textareaRef.current.value.length
1572
1383
  );
1573
1384
  }, [autoFocusEnabled]);
1574
- useEffect8(() => focus(), [focus]);
1385
+ useEffect7(() => focus(), [focus]);
1575
1386
  useOnComposerFocus(() => {
1576
1387
  if (type === "new") {
1577
1388
  focus();
@@ -1599,13 +1410,13 @@ ComposerPrimitiveInput.displayName = "ComposerPrimitive.Input";
1599
1410
 
1600
1411
  // src/primitives/composer/ComposerSend.tsx
1601
1412
  import { forwardRef as forwardRef12 } from "react";
1602
- import { Primitive as Primitive8 } from "@radix-ui/react-primitive";
1413
+ import { Primitive as Primitive7 } from "@radix-ui/react-primitive";
1603
1414
  import { jsx as jsx20 } from "react/jsx-runtime";
1604
1415
  var ComposerPrimitiveSend = forwardRef12(({ disabled, ...rest }, ref) => {
1605
1416
  const { useComposer } = useComposerContext();
1606
1417
  const hasValue = useComposer((c) => c.isEditing && c.value.length > 0);
1607
1418
  return /* @__PURE__ */ jsx20(
1608
- Primitive8.button,
1419
+ Primitive7.button,
1609
1420
  {
1610
1421
  type: "submit",
1611
1422
  ...rest,
@@ -1654,11 +1465,11 @@ __export(thread_exports, {
1654
1465
  });
1655
1466
 
1656
1467
  // src/primitives/thread/ThreadRoot.tsx
1657
- import { Primitive as Primitive9 } from "@radix-ui/react-primitive";
1468
+ import { Primitive as Primitive8 } from "@radix-ui/react-primitive";
1658
1469
  import { forwardRef as forwardRef13 } from "react";
1659
1470
  import { jsx as jsx21 } from "react/jsx-runtime";
1660
1471
  var ThreadPrimitiveRoot = forwardRef13((props, ref) => {
1661
- return /* @__PURE__ */ jsx21(Primitive9.div, { ...props, ref });
1472
+ return /* @__PURE__ */ jsx21(Primitive8.div, { ...props, ref });
1662
1473
  });
1663
1474
  ThreadPrimitiveRoot.displayName = "ThreadPrimitive.Root";
1664
1475
 
@@ -1683,12 +1494,12 @@ ThreadPrimitiveIf.displayName = "ThreadPrimitive.If";
1683
1494
 
1684
1495
  // src/primitives/thread/ThreadViewport.tsx
1685
1496
  import { useComposedRefs as useComposedRefs4 } from "@radix-ui/react-compose-refs";
1686
- import { Primitive as Primitive10 } from "@radix-ui/react-primitive";
1497
+ import { Primitive as Primitive9 } from "@radix-ui/react-primitive";
1687
1498
  import { forwardRef as forwardRef14 } from "react";
1688
1499
 
1689
1500
  // src/primitive-hooks/thread/useThreadViewportAutoScroll.tsx
1690
1501
  import { useComposedRefs as useComposedRefs3 } from "@radix-ui/react-compose-refs";
1691
- import { useRef as useRef5 } from "react";
1502
+ import { useRef as useRef4 } from "react";
1692
1503
 
1693
1504
  // src/utils/hooks/useOnResizeContent.tsx
1694
1505
  import { useCallbackRef as useCallbackRef2 } from "@radix-ui/react-use-callback-ref";
@@ -1732,11 +1543,11 @@ var useOnResizeContent = (callback) => {
1732
1543
 
1733
1544
  // src/utils/hooks/useOnScrollToBottom.tsx
1734
1545
  import { useCallbackRef as useCallbackRef3 } from "@radix-ui/react-use-callback-ref";
1735
- import { useEffect as useEffect9 } from "react";
1546
+ import { useEffect as useEffect8 } from "react";
1736
1547
  var useOnScrollToBottom = (callback) => {
1737
1548
  const callbackRef = useCallbackRef3(callback);
1738
1549
  const { useViewport } = useThreadContext();
1739
- useEffect9(() => {
1550
+ useEffect8(() => {
1740
1551
  return useViewport.getState().onScrollToBottom(() => {
1741
1552
  callbackRef();
1742
1553
  });
@@ -1747,10 +1558,10 @@ var useOnScrollToBottom = (callback) => {
1747
1558
  var useThreadViewportAutoScroll = ({
1748
1559
  autoScroll = true
1749
1560
  }) => {
1750
- const divRef = useRef5(null);
1561
+ const divRef = useRef4(null);
1751
1562
  const { useViewport } = useThreadContext();
1752
- const lastScrollTop = useRef5(0);
1753
- const isScrollingToBottomRef = useRef5(false);
1563
+ const lastScrollTop = useRef4(0);
1564
+ const isScrollingToBottomRef = useRef4(false);
1754
1565
  const scrollToBottom = (behavior) => {
1755
1566
  const div = divRef.current;
1756
1567
  if (!div || !autoScroll) return;
@@ -1801,7 +1612,7 @@ var ThreadPrimitiveViewport = forwardRef14(({ autoScroll, onScroll, children, ..
1801
1612
  autoScroll
1802
1613
  });
1803
1614
  const ref = useComposedRefs4(forwardedRef, autoScrollRef);
1804
- return /* @__PURE__ */ jsx22(Primitive10.div, { ...rest, ref, children });
1615
+ return /* @__PURE__ */ jsx22(Primitive9.div, { ...rest, ref, children });
1805
1616
  });
1806
1617
  ThreadPrimitiveViewport.displayName = "ThreadPrimitive.Viewport";
1807
1618
 
@@ -1809,7 +1620,7 @@ ThreadPrimitiveViewport.displayName = "ThreadPrimitive.Viewport";
1809
1620
  import { memo as memo3 } from "react";
1810
1621
 
1811
1622
  // src/context/providers/MessageProvider.tsx
1812
- import { useEffect as useEffect10, useState as useState6 } from "react";
1623
+ import { useEffect as useEffect9, useState as useState5 } from "react";
1813
1624
  import { create as create13 } from "zustand";
1814
1625
 
1815
1626
  // src/context/stores/EditComposer.ts
@@ -1871,7 +1682,7 @@ var getMessageState = (messages, getBranches, useMessage, messageIndex) => {
1871
1682
  };
1872
1683
  var useMessageContext2 = (messageIndex) => {
1873
1684
  const { useThreadMessages, useThreadActions } = useThreadContext();
1874
- const [context] = useState6(() => {
1685
+ const [context] = useState5(() => {
1875
1686
  const useMessage = create13(
1876
1687
  () => getMessageState(
1877
1688
  useThreadMessages.getState(),
@@ -1909,7 +1720,7 @@ var useMessageContext2 = (messageIndex) => {
1909
1720
  });
1910
1721
  return { useMessage, useMessageUtils, useEditComposer };
1911
1722
  });
1912
- useEffect10(() => {
1723
+ useEffect9(() => {
1913
1724
  const syncMessage = (thread) => {
1914
1725
  const newState = getMessageState(
1915
1726
  thread,
@@ -2003,617 +1814,112 @@ var ThreadPrimitiveSuggestion = createActionButton(
2003
1814
  );
2004
1815
 
2005
1816
  // src/runtimes/local/useLocalRuntime.tsx
2006
- import { useInsertionEffect as useInsertionEffect3, useState as useState8 } from "react";
2007
-
2008
- // src/runtimes/core/BaseAssistantRuntime.tsx
2009
- var BaseAssistantRuntime = class {
2010
- constructor(_thread) {
2011
- this._thread = _thread;
2012
- this._thread = _thread;
2013
- }
2014
- get thread() {
2015
- return this._thread;
2016
- }
2017
- set thread(thread) {
2018
- this._thread = thread;
2019
- this.subscriptionHandler();
2020
- }
2021
- _subscriptions = /* @__PURE__ */ new Set();
2022
- subscribe(callback) {
2023
- this._subscriptions.add(callback);
2024
- return () => this._subscriptions.delete(callback);
2025
- }
2026
- subscriptionHandler = () => {
2027
- for (const callback of this._subscriptions) callback();
2028
- };
2029
- };
2030
-
2031
- // src/internal.ts
2032
- var internal_exports = {};
2033
- __export(internal_exports, {
2034
- BaseAssistantRuntime: () => BaseAssistantRuntime,
2035
- MessageRepository: () => MessageRepository,
2036
- ProxyConfigProvider: () => ProxyConfigProvider,
2037
- TooltipIconButton: () => TooltipIconButton,
2038
- generateId: () => generateId,
2039
- useSmooth: () => useSmooth
2040
- });
2041
-
2042
- // src/utils/idUtils.tsx
2043
- import { customAlphabet } from "nanoid/non-secure";
2044
- var generateId = customAlphabet(
2045
- "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
2046
- 7
2047
- );
2048
- var optimisticPrefix = "__optimistic__";
2049
- var generateOptimisticId = () => `${optimisticPrefix}${generateId()}`;
1817
+ import { useInsertionEffect as useInsertionEffect3, useState as useState7 } from "react";
2050
1818
 
2051
- // src/runtimes/edge/converters/fromCoreMessage.ts
2052
- var fromCoreMessages = (message) => {
2053
- return message.map((message2) => fromCoreMessage(message2));
2054
- };
2055
- var fromCoreMessage = (message, {
2056
- id = generateId(),
2057
- status = { type: "complete", reason: "unknown" }
2058
- } = {}) => {
2059
- const commonProps = {
2060
- id,
2061
- createdAt: /* @__PURE__ */ new Date()
2062
- };
2063
- const role = message.role;
2064
- switch (role) {
2065
- case "assistant":
2066
- return {
2067
- ...commonProps,
2068
- role,
2069
- content: message.content.map((part) => {
1819
+ // src/runtimes/edge/converters/fromLanguageModelMessages.ts
1820
+ var fromLanguageModelMessages = (lm, { mergeRoundtrips }) => {
1821
+ const messages = [];
1822
+ for (const lmMessage of lm) {
1823
+ const role = lmMessage.role;
1824
+ switch (role) {
1825
+ case "system": {
1826
+ messages.push({
1827
+ role: "system",
1828
+ content: [
1829
+ {
1830
+ type: "text",
1831
+ text: lmMessage.content
1832
+ }
1833
+ ]
1834
+ });
1835
+ break;
1836
+ }
1837
+ case "user": {
1838
+ messages.push({
1839
+ role: "user",
1840
+ content: lmMessage.content.map((part) => {
1841
+ const type = part.type;
1842
+ switch (type) {
1843
+ case "text": {
1844
+ return {
1845
+ type: "text",
1846
+ text: part.text
1847
+ };
1848
+ }
1849
+ case "image": {
1850
+ if (part.image instanceof URL) {
1851
+ return {
1852
+ type: "image",
1853
+ image: part.image.href
1854
+ };
1855
+ }
1856
+ throw new Error("Only images with URL data are supported");
1857
+ }
1858
+ default: {
1859
+ const unhandledType = type;
1860
+ throw new Error(`Unknown content part type: ${unhandledType}`);
1861
+ }
1862
+ }
1863
+ })
1864
+ });
1865
+ break;
1866
+ }
1867
+ case "assistant": {
1868
+ const newContent = lmMessage.content.map((part) => {
2070
1869
  if (part.type === "tool-call") {
2071
1870
  return {
2072
- ...part,
2073
- argsText: JSON.stringify(part.args)
1871
+ type: "tool-call",
1872
+ toolCallId: part.toolCallId,
1873
+ toolName: part.toolName,
1874
+ argsText: JSON.stringify(part.args),
1875
+ args: part.args
2074
1876
  };
2075
1877
  }
2076
1878
  return part;
2077
- }),
2078
- status
2079
- };
2080
- case "user":
2081
- return {
2082
- ...commonProps,
2083
- role,
2084
- content: message.content
2085
- };
2086
- case "system":
2087
- return {
2088
- ...commonProps,
2089
- role,
2090
- content: message.content
2091
- };
2092
- default: {
2093
- const unsupportedRole = role;
2094
- throw new Error(`Unknown message role: ${unsupportedRole}`);
2095
- }
2096
- }
2097
- };
2098
-
2099
- // src/runtimes/utils/MessageRepository.tsx
2100
- var findHead = (message) => {
2101
- if (message.next) return findHead(message.next);
2102
- return message;
2103
- };
2104
- var MessageRepository = class {
2105
- messages = /* @__PURE__ */ new Map();
2106
- // message_id -> item
2107
- head = null;
2108
- root = {
2109
- children: []
2110
- };
2111
- performOp(newParent, child, operation) {
2112
- const parentOrRoot = child.prev ?? this.root;
2113
- const newParentOrRoot = newParent ?? this.root;
2114
- if (operation === "relink" && parentOrRoot === newParentOrRoot) return;
2115
- if (operation !== "link") {
2116
- parentOrRoot.children = parentOrRoot.children.filter(
2117
- (m) => m !== child.current.id
2118
- );
2119
- if (child.prev?.next === child) {
2120
- const fallbackId = child.prev.children.at(-1);
2121
- const fallback = fallbackId ? this.messages.get(fallbackId) : null;
2122
- if (fallback === void 0) {
1879
+ });
1880
+ if (mergeRoundtrips) {
1881
+ const previousMessage = messages[messages.length - 1];
1882
+ if (previousMessage?.role === "assistant") {
1883
+ previousMessage.content.push(...newContent);
1884
+ break;
1885
+ }
1886
+ }
1887
+ messages.push({
1888
+ role: "assistant",
1889
+ content: newContent
1890
+ });
1891
+ break;
1892
+ }
1893
+ case "tool": {
1894
+ const previousMessage = messages[messages.length - 1];
1895
+ if (previousMessage?.role !== "assistant")
2123
1896
  throw new Error(
2124
- "MessageRepository(performOp/cut): Fallback sibling message not found. This is likely an internal bug in assistant-ui."
1897
+ "A tool message must be preceded by an assistant message."
1898
+ );
1899
+ for (const tool of lmMessage.content) {
1900
+ const toolCall = previousMessage.content.find(
1901
+ (c) => c.type === "tool-call" && c.toolCallId === tool.toolCallId
2125
1902
  );
1903
+ if (!toolCall)
1904
+ throw new Error("Received tool result for an unknown tool call.");
1905
+ if (toolCall.toolName !== tool.toolName)
1906
+ throw new Error("Tool call name mismatch.");
1907
+ toolCall.result = tool.result;
1908
+ if (tool.isError) {
1909
+ toolCall.isError = true;
1910
+ }
2126
1911
  }
2127
- child.prev.next = fallback;
1912
+ break;
2128
1913
  }
2129
- }
2130
- if (operation !== "cut") {
2131
- newParentOrRoot.children = [
2132
- ...newParentOrRoot.children,
2133
- child.current.id
2134
- ];
2135
- if (newParent && (findHead(child) === this.head || newParent.next === null)) {
2136
- newParent.next = child;
2137
- }
2138
- child.prev = newParent;
2139
- }
2140
- }
2141
- getMessages() {
2142
- const messages = new Array(this.head?.level ?? 0);
2143
- for (let current = this.head; current; current = current.prev) {
2144
- messages[current.level] = current.current;
2145
- }
2146
- return messages;
2147
- }
2148
- addOrUpdateMessage(parentId, message) {
2149
- const existingItem = this.messages.get(message.id);
2150
- const prev = parentId ? this.messages.get(parentId) : null;
2151
- if (prev === void 0)
2152
- throw new Error(
2153
- "MessageRepository(addOrUpdateMessage): Parent message not found. This is likely an internal bug in assistant-ui."
2154
- );
2155
- if (existingItem) {
2156
- existingItem.current = message;
2157
- this.performOp(prev, existingItem, "relink");
2158
- return;
2159
- }
2160
- const newItem = {
2161
- prev,
2162
- current: message,
2163
- next: null,
2164
- children: [],
2165
- level: prev ? prev.level + 1 : 0
2166
- };
2167
- this.messages.set(message.id, newItem);
2168
- this.performOp(prev, newItem, "link");
2169
- if (this.head === prev) {
2170
- this.head = newItem;
2171
- }
2172
- }
2173
- getMessage(messageId) {
2174
- const message = this.messages.get(messageId);
2175
- if (!message)
2176
- throw new Error(
2177
- "MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui."
2178
- );
2179
- return {
2180
- parentId: message.prev?.current.id ?? null,
2181
- message: message.current
2182
- };
2183
- }
2184
- appendOptimisticMessage(parentId, message) {
2185
- let optimisticId;
2186
- do {
2187
- optimisticId = generateOptimisticId();
2188
- } while (this.messages.has(optimisticId));
2189
- this.addOrUpdateMessage(
2190
- parentId,
2191
- fromCoreMessage(message, {
2192
- id: optimisticId,
2193
- status: { type: "running" }
2194
- })
2195
- );
2196
- return optimisticId;
2197
- }
2198
- deleteMessage(messageId, replacementId) {
2199
- const message = this.messages.get(messageId);
2200
- if (!message)
2201
- throw new Error(
2202
- "MessageRepository(deleteMessage): Optimistic message not found. This is likely an internal bug in assistant-ui."
2203
- );
2204
- const replacement = replacementId === void 0 ? message.prev : replacementId === null ? null : this.messages.get(replacementId);
2205
- if (replacement === void 0)
2206
- throw new Error(
2207
- "MessageRepository(deleteMessage): Replacement not found. This is likely an internal bug in assistant-ui."
2208
- );
2209
- for (const child of message.children) {
2210
- const childMessage = this.messages.get(child);
2211
- if (!childMessage)
2212
- throw new Error(
2213
- "MessageRepository(deleteMessage): Child message not found. This is likely an internal bug in assistant-ui."
2214
- );
2215
- this.performOp(replacement, childMessage, "relink");
2216
- }
2217
- this.performOp(null, message, "cut");
2218
- this.messages.delete(messageId);
2219
- if (this.head === message) {
2220
- this.head = replacement ? findHead(replacement) : null;
2221
- }
2222
- }
2223
- getBranches(messageId) {
2224
- const message = this.messages.get(messageId);
2225
- if (!message)
2226
- throw new Error(
2227
- "MessageRepository(getBranches): Message not found. This is likely an internal bug in assistant-ui."
2228
- );
2229
- const { children } = message.prev ?? this.root;
2230
- return children;
2231
- }
2232
- switchToBranch(messageId) {
2233
- const message = this.messages.get(messageId);
2234
- if (!message)
2235
- throw new Error(
2236
- "MessageRepository(switchToBranch): Branch not found. This is likely an internal bug in assistant-ui."
2237
- );
2238
- if (message.prev) {
2239
- message.prev.next = message;
2240
- }
2241
- this.head = findHead(message);
2242
- }
2243
- resetHead(messageId) {
2244
- if (messageId === null) {
2245
- this.head = null;
2246
- return;
2247
- }
2248
- const message = this.messages.get(messageId);
2249
- if (!message)
2250
- throw new Error(
2251
- "MessageRepository(resetHead): Branch not found. This is likely an internal bug in assistant-ui."
2252
- );
2253
- this.head = message;
2254
- for (let current = message; current; current = current.prev) {
2255
- if (current.prev) {
2256
- current.prev.next = current;
2257
- }
2258
- }
2259
- }
2260
- };
2261
-
2262
- // src/ui/base/tooltip-icon-button.tsx
2263
- import { forwardRef as forwardRef17 } from "react";
2264
-
2265
- // src/ui/base/tooltip.tsx
2266
- import * as TooltipPrimitive from "@radix-ui/react-tooltip";
2267
-
2268
- // src/ui/utils/withDefaults.tsx
2269
- import {
2270
- forwardRef as forwardRef15
2271
- } from "react";
2272
- import classNames from "classnames";
2273
- import { jsx as jsx25 } from "react/jsx-runtime";
2274
- var withDefaultProps = ({
2275
- className,
2276
- ...defaultProps
2277
- }) => ({ className: classNameProp, ...props }) => {
2278
- return {
2279
- className: classNames(className, classNameProp),
2280
- ...defaultProps,
2281
- ...props
2282
- };
2283
- };
2284
- var withDefaults = (Component, defaultProps) => {
2285
- const getProps = withDefaultProps(defaultProps);
2286
- const WithDefaults = forwardRef15(
2287
- (props, ref) => {
2288
- const ComponentAsAny = Component;
2289
- return /* @__PURE__ */ jsx25(ComponentAsAny, { ...getProps(props), ref });
2290
- }
2291
- );
2292
- WithDefaults.displayName = "withDefaults(" + (typeof Component === "string" ? Component : Component.displayName) + ")";
2293
- return WithDefaults;
2294
- };
2295
-
2296
- // src/ui/base/tooltip.tsx
2297
- import { jsx as jsx26 } from "react/jsx-runtime";
2298
- var Tooltip = (props) => {
2299
- return /* @__PURE__ */ jsx26(TooltipPrimitive.Provider, { children: /* @__PURE__ */ jsx26(TooltipPrimitive.Root, { ...props }) });
2300
- };
2301
- Tooltip.displayName = "Tooltip";
2302
- var TooltipTrigger = TooltipPrimitive.Trigger;
2303
- var TooltipContent = withDefaults(TooltipPrimitive.Content, {
2304
- sideOffset: 4,
2305
- className: "aui-tooltip-content"
2306
- });
2307
- TooltipContent.displayName = "TooltipContent";
2308
-
2309
- // src/ui/base/button.tsx
2310
- import { cva } from "class-variance-authority";
2311
- import { Primitive as Primitive11 } from "@radix-ui/react-primitive";
2312
- import { forwardRef as forwardRef16 } from "react";
2313
- import { jsx as jsx27 } from "react/jsx-runtime";
2314
- var buttonVariants = cva("aui-button", {
2315
- variants: {
2316
- variant: {
2317
- default: "aui-button-primary",
2318
- outline: "aui-button-outline",
2319
- ghost: "aui-button-ghost"
2320
- },
2321
- size: {
2322
- default: "aui-button-medium",
2323
- icon: "aui-button-icon"
2324
- }
2325
- },
2326
- defaultVariants: {
2327
- variant: "default",
2328
- size: "default"
2329
- }
2330
- });
2331
- var Button = forwardRef16(
2332
- ({ className, variant, size, ...props }, ref) => {
2333
- return /* @__PURE__ */ jsx27(
2334
- Primitive11.button,
2335
- {
2336
- className: buttonVariants({ variant, size, className }),
2337
- ...props,
2338
- ref
2339
- }
2340
- );
2341
- }
2342
- );
2343
- Button.displayName = "Button";
2344
-
2345
- // src/ui/base/tooltip-icon-button.tsx
2346
- import { jsx as jsx28, jsxs as jsxs4 } from "react/jsx-runtime";
2347
- var TooltipIconButton = forwardRef17(({ children, tooltip, side = "bottom", ...rest }, ref) => {
2348
- return /* @__PURE__ */ jsxs4(Tooltip, { children: [
2349
- /* @__PURE__ */ jsx28(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxs4(Button, { variant: "ghost", size: "icon", ...rest, ref, children: [
2350
- children,
2351
- /* @__PURE__ */ jsx28("span", { className: "aui-sr-only", children: tooltip })
2352
- ] }) }),
2353
- /* @__PURE__ */ jsx28(TooltipContent, { side, children: tooltip })
2354
- ] });
2355
- });
2356
- TooltipIconButton.displayName = "TooltipIconButton";
2357
-
2358
- // src/runtimes/edge/converters/toLanguageModelMessages.ts
2359
- var assistantMessageSplitter = () => {
2360
- const stash = [];
2361
- let assistantMessage = {
2362
- role: "assistant",
2363
- content: []
2364
- };
2365
- let toolMessage = {
2366
- role: "tool",
2367
- content: []
2368
- };
2369
- return {
2370
- addTextContentPart: (part) => {
2371
- if (toolMessage.content.length > 0) {
2372
- stash.push(assistantMessage);
2373
- stash.push(toolMessage);
2374
- assistantMessage = {
2375
- role: "assistant",
2376
- content: []
2377
- };
2378
- toolMessage = {
2379
- role: "tool",
2380
- content: []
2381
- };
2382
- }
2383
- assistantMessage.content.push(part);
2384
- },
2385
- addToolCallPart: (part) => {
2386
- assistantMessage.content.push({
2387
- type: "tool-call",
2388
- toolCallId: part.toolCallId,
2389
- toolName: part.toolName,
2390
- args: part.args
2391
- });
2392
- if (part.result) {
2393
- toolMessage.content.push({
2394
- type: "tool-result",
2395
- toolCallId: part.toolCallId,
2396
- toolName: part.toolName,
2397
- result: part.result
2398
- // isError
2399
- });
2400
- }
2401
- },
2402
- getMessages: () => {
2403
- if (toolMessage.content.length > 0) {
2404
- return [...stash, assistantMessage, toolMessage];
2405
- }
2406
- return [...stash, assistantMessage];
2407
- }
2408
- };
2409
- };
2410
- function toLanguageModelMessages(message) {
2411
- return message.flatMap((message2) => {
2412
- const role = message2.role;
2413
- switch (role) {
2414
- case "system": {
2415
- return [{ role: "system", content: message2.content[0].text }];
2416
- }
2417
- case "user": {
2418
- const msg = {
2419
- role: "user",
2420
- content: message2.content.map(
2421
- (part) => {
2422
- const type = part.type;
2423
- switch (type) {
2424
- case "text": {
2425
- return part;
2426
- }
2427
- case "image": {
2428
- return {
2429
- type: "image",
2430
- image: new URL(part.image)
2431
- };
2432
- }
2433
- default: {
2434
- const unhandledType = type;
2435
- throw new Error(
2436
- `Unspported content part type: ${unhandledType}`
2437
- );
2438
- }
2439
- }
2440
- }
2441
- )
2442
- };
2443
- return [msg];
2444
- }
2445
- case "assistant": {
2446
- const splitter = assistantMessageSplitter();
2447
- for (const part of message2.content) {
2448
- const type = part.type;
2449
- switch (type) {
2450
- case "text": {
2451
- splitter.addTextContentPart(part);
2452
- break;
2453
- }
2454
- case "tool-call": {
2455
- splitter.addToolCallPart(part);
2456
- break;
2457
- }
2458
- default: {
2459
- const unhandledType = type;
2460
- throw new Error(`Unhandled content part type: ${unhandledType}`);
2461
- }
2462
- }
2463
- }
2464
- return splitter.getMessages();
2465
- }
2466
- default: {
2467
- const unhandledRole = role;
2468
- throw new Error(`Unknown message role: ${unhandledRole}`);
2469
- }
2470
- }
2471
- });
2472
- }
2473
-
2474
- // src/runtimes/edge/converters/fromLanguageModelMessages.ts
2475
- var fromLanguageModelMessages = (lm, { mergeRoundtrips }) => {
2476
- const messages = [];
2477
- for (const lmMessage of lm) {
2478
- const role = lmMessage.role;
2479
- switch (role) {
2480
- case "system": {
2481
- messages.push({
2482
- role: "system",
2483
- content: [
2484
- {
2485
- type: "text",
2486
- text: lmMessage.content
2487
- }
2488
- ]
2489
- });
2490
- break;
2491
- }
2492
- case "user": {
2493
- messages.push({
2494
- role: "user",
2495
- content: lmMessage.content.map((part) => {
2496
- const type = part.type;
2497
- switch (type) {
2498
- case "text": {
2499
- return {
2500
- type: "text",
2501
- text: part.text
2502
- };
2503
- }
2504
- case "image": {
2505
- if (part.image instanceof URL) {
2506
- return {
2507
- type: "image",
2508
- image: part.image.href
2509
- };
2510
- }
2511
- throw new Error("Only images with URL data are supported");
2512
- }
2513
- default: {
2514
- const unhandledType = type;
2515
- throw new Error(`Unknown content part type: ${unhandledType}`);
2516
- }
2517
- }
2518
- })
2519
- });
2520
- break;
2521
- }
2522
- case "assistant": {
2523
- const newContent = lmMessage.content.map((part) => {
2524
- if (part.type === "tool-call") {
2525
- return {
2526
- type: "tool-call",
2527
- toolCallId: part.toolCallId,
2528
- toolName: part.toolName,
2529
- argsText: JSON.stringify(part.args),
2530
- args: part.args
2531
- };
2532
- }
2533
- return part;
2534
- });
2535
- if (mergeRoundtrips) {
2536
- const previousMessage = messages[messages.length - 1];
2537
- if (previousMessage?.role === "assistant") {
2538
- previousMessage.content.push(...newContent);
2539
- break;
2540
- }
2541
- }
2542
- messages.push({
2543
- role: "assistant",
2544
- content: newContent
2545
- });
2546
- break;
2547
- }
2548
- case "tool": {
2549
- const previousMessage = messages[messages.length - 1];
2550
- if (previousMessage?.role !== "assistant")
2551
- throw new Error(
2552
- "A tool message must be preceded by an assistant message."
2553
- );
2554
- for (const tool of lmMessage.content) {
2555
- const toolCall = previousMessage.content.find(
2556
- (c) => c.type === "tool-call" && c.toolCallId === tool.toolCallId
2557
- );
2558
- if (!toolCall)
2559
- throw new Error("Received tool result for an unknown tool call.");
2560
- if (toolCall.toolName !== tool.toolName)
2561
- throw new Error("Tool call name mismatch.");
2562
- toolCall.result = tool.result;
2563
- if (tool.isError) {
2564
- toolCall.isError = true;
2565
- }
2566
- }
2567
- break;
2568
- }
2569
- default: {
2570
- const unhandledRole = role;
2571
- throw new Error(`Unknown message role: ${unhandledRole}`);
1914
+ default: {
1915
+ const unhandledRole = role;
1916
+ throw new Error(`Unknown message role: ${unhandledRole}`);
2572
1917
  }
2573
1918
  }
2574
1919
  }
2575
1920
  return messages;
2576
1921
  };
2577
1922
 
2578
- // src/runtimes/edge/converters/toCoreMessages.ts
2579
- var toCoreMessages = (message) => {
2580
- return message.map(toCoreMessage);
2581
- };
2582
- var toCoreMessage = (message) => {
2583
- const role = message.role;
2584
- switch (role) {
2585
- case "assistant":
2586
- return {
2587
- role,
2588
- content: message.content.map((part) => {
2589
- if (part.type === "ui") throw new Error("UI parts are not supported");
2590
- if (part.type === "tool-call") {
2591
- const { argsText, ...rest } = part;
2592
- return rest;
2593
- }
2594
- return part;
2595
- })
2596
- };
2597
- case "user":
2598
- return {
2599
- role,
2600
- content: message.content.map((part) => {
2601
- if (part.type === "ui") throw new Error("UI parts are not supported");
2602
- return part;
2603
- })
2604
- };
2605
- case "system":
2606
- return {
2607
- role,
2608
- content: message.content
2609
- };
2610
- default: {
2611
- const unsupportedRole = role;
2612
- throw new Error(`Unknown message role: ${unsupportedRole}`);
2613
- }
2614
- }
2615
- };
2616
-
2617
1923
  // src/runtimes/edge/converters/fromLanguageModelTools.ts
2618
1924
  var fromLanguageModelTools = (tools) => {
2619
1925
  return Object.fromEntries(
@@ -2627,20 +1933,8 @@ var fromLanguageModelTools = (tools) => {
2627
1933
  );
2628
1934
  };
2629
1935
 
2630
- // src/runtimes/edge/converters/toLanguageModelTools.ts
2631
- import { z as z2 } from "zod";
2632
- import zodToJsonSchema from "zod-to-json-schema";
2633
- var toLanguageModelTools = (tools) => {
2634
- return Object.entries(tools).map(([name, tool]) => ({
2635
- type: "function",
2636
- name,
2637
- ...tool.description ? { description: tool.description } : void 0,
2638
- parameters: tool.parameters instanceof z2.ZodType ? zodToJsonSchema(tool.parameters) : tool.parameters
2639
- }));
2640
- };
2641
-
2642
1936
  // src/runtimes/edge/useEdgeRuntime.ts
2643
- import { useState as useState7 } from "react";
1937
+ import { useState as useState6 } from "react";
2644
1938
 
2645
1939
  // src/runtimes/edge/streams/assistantDecoderStream.ts
2646
1940
  function assistantDecoderStream() {
@@ -2746,589 +2040,6 @@ function chunkByLineStream() {
2746
2040
  });
2747
2041
  }
2748
2042
 
2749
- // src/runtimes/edge/partial-json/parse-partial-json.ts
2750
- import sjson from "secure-json-parse";
2751
-
2752
- // src/runtimes/edge/partial-json/fix-json.ts
2753
- function fixJson(input) {
2754
- const stack = ["ROOT"];
2755
- let lastValidIndex = -1;
2756
- let literalStart = null;
2757
- function processValueStart(char, i, swapState) {
2758
- {
2759
- switch (char) {
2760
- case '"': {
2761
- lastValidIndex = i;
2762
- stack.pop();
2763
- stack.push(swapState);
2764
- stack.push("INSIDE_STRING");
2765
- break;
2766
- }
2767
- case "f":
2768
- case "t":
2769
- case "n": {
2770
- lastValidIndex = i;
2771
- literalStart = i;
2772
- stack.pop();
2773
- stack.push(swapState);
2774
- stack.push("INSIDE_LITERAL");
2775
- break;
2776
- }
2777
- case "-": {
2778
- stack.pop();
2779
- stack.push(swapState);
2780
- stack.push("INSIDE_NUMBER");
2781
- break;
2782
- }
2783
- case "0":
2784
- case "1":
2785
- case "2":
2786
- case "3":
2787
- case "4":
2788
- case "5":
2789
- case "6":
2790
- case "7":
2791
- case "8":
2792
- case "9": {
2793
- lastValidIndex = i;
2794
- stack.pop();
2795
- stack.push(swapState);
2796
- stack.push("INSIDE_NUMBER");
2797
- break;
2798
- }
2799
- case "{": {
2800
- lastValidIndex = i;
2801
- stack.pop();
2802
- stack.push(swapState);
2803
- stack.push("INSIDE_OBJECT_START");
2804
- break;
2805
- }
2806
- case "[": {
2807
- lastValidIndex = i;
2808
- stack.pop();
2809
- stack.push(swapState);
2810
- stack.push("INSIDE_ARRAY_START");
2811
- break;
2812
- }
2813
- }
2814
- }
2815
- }
2816
- function processAfterObjectValue(char, i) {
2817
- switch (char) {
2818
- case ",": {
2819
- stack.pop();
2820
- stack.push("INSIDE_OBJECT_AFTER_COMMA");
2821
- break;
2822
- }
2823
- case "}": {
2824
- lastValidIndex = i;
2825
- stack.pop();
2826
- break;
2827
- }
2828
- }
2829
- }
2830
- function processAfterArrayValue(char, i) {
2831
- switch (char) {
2832
- case ",": {
2833
- stack.pop();
2834
- stack.push("INSIDE_ARRAY_AFTER_COMMA");
2835
- break;
2836
- }
2837
- case "]": {
2838
- lastValidIndex = i;
2839
- stack.pop();
2840
- break;
2841
- }
2842
- }
2843
- }
2844
- for (let i = 0; i < input.length; i++) {
2845
- const char = input[i];
2846
- const currentState = stack[stack.length - 1];
2847
- switch (currentState) {
2848
- case "ROOT":
2849
- processValueStart(char, i, "FINISH");
2850
- break;
2851
- case "INSIDE_OBJECT_START": {
2852
- switch (char) {
2853
- case '"': {
2854
- stack.pop();
2855
- stack.push("INSIDE_OBJECT_KEY");
2856
- break;
2857
- }
2858
- case "}": {
2859
- lastValidIndex = i;
2860
- stack.pop();
2861
- break;
2862
- }
2863
- }
2864
- break;
2865
- }
2866
- case "INSIDE_OBJECT_AFTER_COMMA": {
2867
- switch (char) {
2868
- case '"': {
2869
- stack.pop();
2870
- stack.push("INSIDE_OBJECT_KEY");
2871
- break;
2872
- }
2873
- }
2874
- break;
2875
- }
2876
- case "INSIDE_OBJECT_KEY": {
2877
- switch (char) {
2878
- case '"': {
2879
- stack.pop();
2880
- stack.push("INSIDE_OBJECT_AFTER_KEY");
2881
- break;
2882
- }
2883
- }
2884
- break;
2885
- }
2886
- case "INSIDE_OBJECT_AFTER_KEY": {
2887
- switch (char) {
2888
- case ":": {
2889
- stack.pop();
2890
- stack.push("INSIDE_OBJECT_BEFORE_VALUE");
2891
- break;
2892
- }
2893
- }
2894
- break;
2895
- }
2896
- case "INSIDE_OBJECT_BEFORE_VALUE": {
2897
- processValueStart(char, i, "INSIDE_OBJECT_AFTER_VALUE");
2898
- break;
2899
- }
2900
- case "INSIDE_OBJECT_AFTER_VALUE": {
2901
- processAfterObjectValue(char, i);
2902
- break;
2903
- }
2904
- case "INSIDE_STRING": {
2905
- switch (char) {
2906
- case '"': {
2907
- stack.pop();
2908
- lastValidIndex = i;
2909
- break;
2910
- }
2911
- case "\\": {
2912
- stack.push("INSIDE_STRING_ESCAPE");
2913
- break;
2914
- }
2915
- default: {
2916
- lastValidIndex = i;
2917
- }
2918
- }
2919
- break;
2920
- }
2921
- case "INSIDE_ARRAY_START": {
2922
- switch (char) {
2923
- case "]": {
2924
- lastValidIndex = i;
2925
- stack.pop();
2926
- break;
2927
- }
2928
- default: {
2929
- lastValidIndex = i;
2930
- processValueStart(char, i, "INSIDE_ARRAY_AFTER_VALUE");
2931
- break;
2932
- }
2933
- }
2934
- break;
2935
- }
2936
- case "INSIDE_ARRAY_AFTER_VALUE": {
2937
- switch (char) {
2938
- case ",": {
2939
- stack.pop();
2940
- stack.push("INSIDE_ARRAY_AFTER_COMMA");
2941
- break;
2942
- }
2943
- case "]": {
2944
- lastValidIndex = i;
2945
- stack.pop();
2946
- break;
2947
- }
2948
- default: {
2949
- lastValidIndex = i;
2950
- break;
2951
- }
2952
- }
2953
- break;
2954
- }
2955
- case "INSIDE_ARRAY_AFTER_COMMA": {
2956
- processValueStart(char, i, "INSIDE_ARRAY_AFTER_VALUE");
2957
- break;
2958
- }
2959
- case "INSIDE_STRING_ESCAPE": {
2960
- stack.pop();
2961
- lastValidIndex = i;
2962
- break;
2963
- }
2964
- case "INSIDE_NUMBER": {
2965
- switch (char) {
2966
- case "0":
2967
- case "1":
2968
- case "2":
2969
- case "3":
2970
- case "4":
2971
- case "5":
2972
- case "6":
2973
- case "7":
2974
- case "8":
2975
- case "9": {
2976
- lastValidIndex = i;
2977
- break;
2978
- }
2979
- case "e":
2980
- case "E":
2981
- case "-":
2982
- case ".": {
2983
- break;
2984
- }
2985
- case ",": {
2986
- stack.pop();
2987
- if (stack[stack.length - 1] === "INSIDE_ARRAY_AFTER_VALUE") {
2988
- processAfterArrayValue(char, i);
2989
- }
2990
- if (stack[stack.length - 1] === "INSIDE_OBJECT_AFTER_VALUE") {
2991
- processAfterObjectValue(char, i);
2992
- }
2993
- break;
2994
- }
2995
- case "}": {
2996
- stack.pop();
2997
- if (stack[stack.length - 1] === "INSIDE_OBJECT_AFTER_VALUE") {
2998
- processAfterObjectValue(char, i);
2999
- }
3000
- break;
3001
- }
3002
- case "]": {
3003
- stack.pop();
3004
- if (stack[stack.length - 1] === "INSIDE_ARRAY_AFTER_VALUE") {
3005
- processAfterArrayValue(char, i);
3006
- }
3007
- break;
3008
- }
3009
- default: {
3010
- stack.pop();
3011
- break;
3012
- }
3013
- }
3014
- break;
3015
- }
3016
- case "INSIDE_LITERAL": {
3017
- const partialLiteral = input.substring(literalStart, i + 1);
3018
- if (!"false".startsWith(partialLiteral) && !"true".startsWith(partialLiteral) && !"null".startsWith(partialLiteral)) {
3019
- stack.pop();
3020
- if (stack[stack.length - 1] === "INSIDE_OBJECT_AFTER_VALUE") {
3021
- processAfterObjectValue(char, i);
3022
- } else if (stack[stack.length - 1] === "INSIDE_ARRAY_AFTER_VALUE") {
3023
- processAfterArrayValue(char, i);
3024
- }
3025
- } else {
3026
- lastValidIndex = i;
3027
- }
3028
- break;
3029
- }
3030
- }
3031
- }
3032
- let result = input.slice(0, lastValidIndex + 1);
3033
- for (let i = stack.length - 1; i >= 0; i--) {
3034
- const state = stack[i];
3035
- switch (state) {
3036
- case "INSIDE_STRING": {
3037
- result += '"';
3038
- break;
3039
- }
3040
- case "INSIDE_OBJECT_KEY":
3041
- case "INSIDE_OBJECT_AFTER_KEY":
3042
- case "INSIDE_OBJECT_AFTER_COMMA":
3043
- case "INSIDE_OBJECT_START":
3044
- case "INSIDE_OBJECT_BEFORE_VALUE":
3045
- case "INSIDE_OBJECT_AFTER_VALUE": {
3046
- result += "}";
3047
- break;
3048
- }
3049
- case "INSIDE_ARRAY_START":
3050
- case "INSIDE_ARRAY_AFTER_COMMA":
3051
- case "INSIDE_ARRAY_AFTER_VALUE": {
3052
- result += "]";
3053
- break;
3054
- }
3055
- case "INSIDE_LITERAL": {
3056
- const partialLiteral = input.substring(literalStart, input.length);
3057
- if ("true".startsWith(partialLiteral)) {
3058
- result += "true".slice(partialLiteral.length);
3059
- } else if ("false".startsWith(partialLiteral)) {
3060
- result += "false".slice(partialLiteral.length);
3061
- } else if ("null".startsWith(partialLiteral)) {
3062
- result += "null".slice(partialLiteral.length);
3063
- }
3064
- }
3065
- }
3066
- }
3067
- return result;
3068
- }
3069
-
3070
- // src/runtimes/edge/partial-json/parse-partial-json.ts
3071
- var parsePartialJson = (json) => {
3072
- try {
3073
- return sjson.parse(json);
3074
- } catch {
3075
- try {
3076
- return sjson.parse(fixJson(json));
3077
- } catch {
3078
- return void 0;
3079
- }
3080
- }
3081
- };
3082
-
3083
- // src/runtimes/edge/streams/runResultStream.ts
3084
- function runResultStream() {
3085
- let message = {
3086
- content: [],
3087
- status: { type: "running" }
3088
- };
3089
- const currentToolCall = { toolCallId: "", argsText: "" };
3090
- return new TransformStream({
3091
- transform(chunk, controller) {
3092
- const chunkType = chunk.type;
3093
- switch (chunkType) {
3094
- case "text-delta": {
3095
- message = appendOrUpdateText(message, chunk.textDelta);
3096
- controller.enqueue(message);
3097
- break;
3098
- }
3099
- case "tool-call-delta": {
3100
- const { toolCallId, toolName, argsTextDelta } = chunk;
3101
- if (currentToolCall.toolCallId !== toolCallId) {
3102
- currentToolCall.toolCallId = toolCallId;
3103
- currentToolCall.argsText = argsTextDelta;
3104
- } else {
3105
- currentToolCall.argsText += argsTextDelta;
3106
- }
3107
- message = appendOrUpdateToolCall(
3108
- message,
3109
- toolCallId,
3110
- toolName,
3111
- currentToolCall.argsText
3112
- );
3113
- controller.enqueue(message);
3114
- break;
3115
- }
3116
- case "tool-call": {
3117
- break;
3118
- }
3119
- case "tool-result": {
3120
- message = appendOrUpdateToolResult(
3121
- message,
3122
- chunk.toolCallId,
3123
- chunk.toolName,
3124
- chunk.result
3125
- );
3126
- controller.enqueue(message);
3127
- break;
3128
- }
3129
- case "finish": {
3130
- message = appendOrUpdateFinish(message, chunk);
3131
- controller.enqueue(message);
3132
- break;
3133
- }
3134
- case "error": {
3135
- if (chunk.error instanceof Error && chunk.error.name === "AbortError") {
3136
- message = appendOrUpdateCancel(message);
3137
- controller.enqueue(message);
3138
- break;
3139
- } else {
3140
- throw chunk.error;
3141
- }
3142
- }
3143
- default: {
3144
- const unhandledType = chunkType;
3145
- throw new Error(`Unhandled chunk type: ${unhandledType}`);
3146
- }
3147
- }
3148
- }
3149
- });
3150
- }
3151
- var appendOrUpdateText = (message, textDelta) => {
3152
- let contentParts = message.content;
3153
- let contentPart = message.content.at(-1);
3154
- if (contentPart?.type !== "text") {
3155
- contentPart = { type: "text", text: textDelta };
3156
- } else {
3157
- contentParts = contentParts.slice(0, -1);
3158
- contentPart = { type: "text", text: contentPart.text + textDelta };
3159
- }
3160
- return {
3161
- ...message,
3162
- content: contentParts.concat([contentPart])
3163
- };
3164
- };
3165
- var appendOrUpdateToolCall = (message, toolCallId, toolName, argsText) => {
3166
- let contentParts = message.content;
3167
- let contentPart = message.content.at(-1);
3168
- if (contentPart?.type !== "tool-call" || contentPart.toolCallId !== toolCallId) {
3169
- contentPart = {
3170
- type: "tool-call",
3171
- toolCallId,
3172
- toolName,
3173
- argsText,
3174
- args: parsePartialJson(argsText)
3175
- };
3176
- } else {
3177
- contentParts = contentParts.slice(0, -1);
3178
- contentPart = {
3179
- ...contentPart,
3180
- argsText,
3181
- args: parsePartialJson(argsText)
3182
- };
3183
- }
3184
- return {
3185
- ...message,
3186
- content: contentParts.concat([contentPart])
3187
- };
3188
- };
3189
- var appendOrUpdateToolResult = (message, toolCallId, toolName, result) => {
3190
- let found = false;
3191
- const newContentParts = message.content.map((part) => {
3192
- if (part.type !== "tool-call" || part.toolCallId !== toolCallId)
3193
- return part;
3194
- found = true;
3195
- if (part.toolName !== toolName)
3196
- throw new Error(
3197
- `Tool call ${toolCallId} found with tool name ${part.toolName}, but expected ${toolName}`
3198
- );
3199
- return {
3200
- ...part,
3201
- result
3202
- };
3203
- });
3204
- if (!found)
3205
- throw new Error(
3206
- `Received tool result for unknown tool call "${toolName}" / "${toolCallId}". This is likely an internal bug in assistant-ui.`
3207
- );
3208
- return {
3209
- ...message,
3210
- content: newContentParts
3211
- };
3212
- };
3213
- var appendOrUpdateFinish = (message, chunk) => {
3214
- const { type, ...rest } = chunk;
3215
- return {
3216
- ...message,
3217
- status: getStatus(chunk),
3218
- roundtrips: [
3219
- ...message.roundtrips ?? [],
3220
- {
3221
- logprobs: rest.logprobs,
3222
- usage: rest.usage
3223
- }
3224
- ]
3225
- };
3226
- };
3227
- var getStatus = (chunk) => {
3228
- if (chunk.finishReason === "tool-calls") {
3229
- return {
3230
- type: "requires-action",
3231
- reason: "tool-calls"
3232
- };
3233
- } else if (chunk.finishReason === "stop" || chunk.finishReason === "unknown") {
3234
- return {
3235
- type: "complete",
3236
- reason: chunk.finishReason
3237
- };
3238
- } else {
3239
- return {
3240
- type: "incomplete",
3241
- reason: chunk.finishReason
3242
- };
3243
- }
3244
- };
3245
- var appendOrUpdateCancel = (message) => {
3246
- return {
3247
- ...message,
3248
- status: {
3249
- type: "incomplete",
3250
- reason: "cancelled"
3251
- }
3252
- };
3253
- };
3254
-
3255
- // src/runtimes/edge/streams/toolResultStream.ts
3256
- import { z as z3 } from "zod";
3257
- import sjson2 from "secure-json-parse";
3258
- function toolResultStream(tools) {
3259
- const toolCallExecutions = /* @__PURE__ */ new Map();
3260
- return new TransformStream({
3261
- transform(chunk, controller) {
3262
- controller.enqueue(chunk);
3263
- const chunkType = chunk.type;
3264
- switch (chunkType) {
3265
- case "tool-call": {
3266
- const { toolCallId, toolCallType, toolName, args: argsText } = chunk;
3267
- const tool = tools?.[toolName];
3268
- if (!tool || !tool.execute) return;
3269
- const args = sjson2.parse(argsText);
3270
- if (tool.parameters instanceof z3.ZodType) {
3271
- const result = tool.parameters.safeParse(args);
3272
- if (!result.success) {
3273
- controller.enqueue({
3274
- type: "tool-result",
3275
- toolCallType,
3276
- toolCallId,
3277
- toolName,
3278
- result: "Function parameter validation failed. " + JSON.stringify(result.error.issues),
3279
- isError: true
3280
- });
3281
- return;
3282
- } else {
3283
- toolCallExecutions.set(
3284
- toolCallId,
3285
- (async () => {
3286
- try {
3287
- const result2 = await tool.execute(args);
3288
- controller.enqueue({
3289
- type: "tool-result",
3290
- toolCallType,
3291
- toolCallId,
3292
- toolName,
3293
- result: result2
3294
- });
3295
- } catch (error) {
3296
- console.error("Error: ", error);
3297
- controller.enqueue({
3298
- type: "tool-result",
3299
- toolCallType,
3300
- toolCallId,
3301
- toolName,
3302
- result: "Error: " + error,
3303
- isError: true
3304
- });
3305
- } finally {
3306
- toolCallExecutions.delete(toolCallId);
3307
- }
3308
- })()
3309
- );
3310
- }
3311
- }
3312
- break;
3313
- }
3314
- case "text-delta":
3315
- case "tool-call-delta":
3316
- case "tool-result":
3317
- case "finish":
3318
- case "error":
3319
- break;
3320
- default: {
3321
- const unhandledType = chunkType;
3322
- throw new Error(`Unhandled chunk type: ${unhandledType}`);
3323
- }
3324
- }
3325
- },
3326
- async flush() {
3327
- await Promise.all(toolCallExecutions.values());
3328
- }
3329
- });
3330
- }
3331
-
3332
2043
  // src/runtimes/edge/EdgeChatAdapter.ts
3333
2044
  function asAsyncIterable(source) {
3334
2045
  return {
@@ -3380,7 +2091,7 @@ var useEdgeRuntime = ({
3380
2091
  initialMessages,
3381
2092
  ...options
3382
2093
  }) => {
3383
- const [adapter] = useState7(() => new EdgeChatAdapter(options));
2094
+ const [adapter] = useState6(() => new EdgeChatAdapter(options));
3384
2095
  return useLocalRuntime(adapter, { initialMessages });
3385
2096
  };
3386
2097
 
@@ -3594,7 +2305,7 @@ var LocalRuntime = class extends BaseAssistantRuntime {
3594
2305
 
3595
2306
  // src/runtimes/local/useLocalRuntime.tsx
3596
2307
  var useLocalRuntime = (adapter, options) => {
3597
- const [runtime] = useState8(() => new LocalRuntime(adapter, options));
2308
+ const [runtime] = useState7(() => new LocalRuntime(adapter, options));
3598
2309
  useInsertionEffect3(() => {
3599
2310
  runtime.adapter = adapter;
3600
2311
  });
@@ -3611,7 +2322,7 @@ var getExternalStoreMessage = (message) => {
3611
2322
  };
3612
2323
 
3613
2324
  // src/runtimes/external-store/useExternalStoreSync.tsx
3614
- import { useEffect as useEffect11, useInsertionEffect as useInsertionEffect4, useMemo as useMemo3, useRef as useRef6 } from "react";
2325
+ import { useEffect as useEffect10, useInsertionEffect as useInsertionEffect4, useMemo as useMemo2, useRef as useRef5 } from "react";
3615
2326
 
3616
2327
  // src/runtimes/external-store/ThreadMessageConverter.ts
3617
2328
  var ThreadMessageConverter = class {
@@ -3705,11 +2416,11 @@ var fromThreadMessageLike = (like, fallbackId, fallbackStatus) => {
3705
2416
 
3706
2417
  // src/runtimes/external-store/useExternalStoreSync.tsx
3707
2418
  var useExternalStoreSync = (adapter, updateData) => {
3708
- const adapterRef = useRef6(adapter);
2419
+ const adapterRef = useRef5(adapter);
3709
2420
  useInsertionEffect4(() => {
3710
2421
  adapterRef.current = adapter;
3711
2422
  });
3712
- const [converter, convertCallback] = useMemo3(() => {
2423
+ const [converter, convertCallback] = useMemo2(() => {
3713
2424
  const converter2 = adapter.convertMessage ?? ((m) => m);
3714
2425
  const convertCallback2 = (cache, m, idx) => {
3715
2426
  const autoStatus = getAutoStatus(
@@ -3728,7 +2439,7 @@ var useExternalStoreSync = (adapter, updateData) => {
3728
2439
  };
3729
2440
  return [new ThreadMessageConverter(), convertCallback2];
3730
2441
  }, [adapter.convertMessage]);
3731
- useEffect11(() => {
2442
+ useEffect10(() => {
3732
2443
  updateData(
3733
2444
  adapter.isDisabled ?? false,
3734
2445
  adapter.isRunning ?? false,
@@ -3897,13 +2608,13 @@ var ExternalStoreRuntime = class extends BaseAssistantRuntime {
3897
2608
  };
3898
2609
 
3899
2610
  // src/runtimes/external-store/useExternalStoreRuntime.tsx
3900
- import { useEffect as useEffect12, useInsertionEffect as useInsertionEffect5, useState as useState9 } from "react";
2611
+ import { useEffect as useEffect11, useInsertionEffect as useInsertionEffect5, useState as useState8 } from "react";
3901
2612
  var useExternalStoreRuntime = (store) => {
3902
- const [runtime] = useState9(() => new ExternalStoreRuntime(store));
2613
+ const [runtime] = useState8(() => new ExternalStoreRuntime(store));
3903
2614
  useInsertionEffect5(() => {
3904
2615
  runtime.store = store;
3905
2616
  });
3906
- useEffect12(() => {
2617
+ useEffect11(() => {
3907
2618
  runtime.onStoreUpdated();
3908
2619
  });
3909
2620
  return runtime;
@@ -3911,34 +2622,34 @@ var useExternalStoreRuntime = (store) => {
3911
2622
 
3912
2623
  // src/ui/thread-config.tsx
3913
2624
  import {
3914
- createContext as createContext5,
3915
- useContext as useContext5
2625
+ createContext,
2626
+ useContext
3916
2627
  } from "react";
3917
- import { Fragment as Fragment3, jsx as jsx29 } from "react/jsx-runtime";
3918
- var ThreadConfigContext = createContext5({});
2628
+ import { Fragment as Fragment3, jsx as jsx25 } from "react/jsx-runtime";
2629
+ var ThreadConfigContext = createContext({});
3919
2630
  var useThreadConfig = () => {
3920
- return useContext5(ThreadConfigContext);
2631
+ return useContext(ThreadConfigContext);
3921
2632
  };
3922
2633
  var ThreadConfigProvider = ({
3923
2634
  children,
3924
2635
  config
3925
2636
  }) => {
3926
2637
  const assistant = useAssistantContext({ optional: true });
3927
- const configProvider = config && Object.keys(config ?? {}).length > 0 ? /* @__PURE__ */ jsx29(ThreadConfigContext.Provider, { value: config, children }) : /* @__PURE__ */ jsx29(Fragment3, { children });
2638
+ const configProvider = config && Object.keys(config ?? {}).length > 0 ? /* @__PURE__ */ jsx25(ThreadConfigContext.Provider, { value: config, children }) : /* @__PURE__ */ jsx25(Fragment3, { children });
3928
2639
  if (!config?.runtime) return configProvider;
3929
2640
  if (assistant) {
3930
2641
  throw new Error(
3931
2642
  "You provided a runtime to <Thread> while simulataneously using <AssistantRuntimeProvider>. This is not allowed."
3932
2643
  );
3933
2644
  }
3934
- return /* @__PURE__ */ jsx29(AssistantRuntimeProvider, { runtime: config.runtime, children: configProvider });
2645
+ return /* @__PURE__ */ jsx25(AssistantRuntimeProvider, { runtime: config.runtime, children: configProvider });
3935
2646
  };
3936
2647
  ThreadConfigProvider.displayName = "ThreadConfigProvider";
3937
2648
 
3938
2649
  // src/ui/assistant-action-bar.tsx
3939
- import { forwardRef as forwardRef18 } from "react";
2650
+ import { forwardRef as forwardRef15 } from "react";
3940
2651
  import { CheckIcon, CopyIcon, RefreshCwIcon } from "lucide-react";
3941
- import { Fragment as Fragment4, jsx as jsx30, jsxs as jsxs5 } from "react/jsx-runtime";
2652
+ import { Fragment as Fragment4, jsx as jsx26, jsxs as jsxs4 } from "react/jsx-runtime";
3942
2653
  var useAllowCopy = () => {
3943
2654
  const { assistantMessage: { allowCopy = true } = {} } = useThreadConfig();
3944
2655
  const { useThreadActions } = useThreadContext();
@@ -3955,15 +2666,15 @@ var AssistantActionBar = () => {
3955
2666
  const allowCopy = useAllowCopy();
3956
2667
  const allowReload = useAllowReload();
3957
2668
  if (!allowCopy && !allowReload) return null;
3958
- return /* @__PURE__ */ jsxs5(
2669
+ return /* @__PURE__ */ jsxs4(
3959
2670
  AssistantActionBarRoot,
3960
2671
  {
3961
2672
  hideWhenRunning: true,
3962
2673
  autohide: "not-last",
3963
2674
  autohideFloat: "single-branch",
3964
2675
  children: [
3965
- /* @__PURE__ */ jsx30(AssistantActionBarCopy, {}),
3966
- /* @__PURE__ */ jsx30(AssistantActionBarReload, {})
2676
+ /* @__PURE__ */ jsx26(AssistantActionBarCopy, {}),
2677
+ /* @__PURE__ */ jsx26(AssistantActionBarReload, {})
3967
2678
  ]
3968
2679
  }
3969
2680
  );
@@ -3973,7 +2684,7 @@ var AssistantActionBarRoot = withDefaults(actionBar_exports.Root, {
3973
2684
  className: "aui-assistant-action-bar-root"
3974
2685
  });
3975
2686
  AssistantActionBarRoot.displayName = "AssistantActionBarRoot";
3976
- var AssistantActionBarCopy = forwardRef18((props, ref) => {
2687
+ var AssistantActionBarCopy = forwardRef15((props, ref) => {
3977
2688
  const {
3978
2689
  strings: {
3979
2690
  assistantMessage: { reload: { tooltip = "Copy" } = {} } = {}
@@ -3981,13 +2692,13 @@ var AssistantActionBarCopy = forwardRef18((props, ref) => {
3981
2692
  } = useThreadConfig();
3982
2693
  const allowCopy = useAllowCopy();
3983
2694
  if (!allowCopy) return null;
3984
- return /* @__PURE__ */ jsx30(actionBar_exports.Copy, { asChild: true, children: /* @__PURE__ */ jsx30(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsxs5(Fragment4, { children: [
3985
- /* @__PURE__ */ jsx30(message_exports.If, { copied: true, children: /* @__PURE__ */ jsx30(CheckIcon, {}) }),
3986
- /* @__PURE__ */ jsx30(message_exports.If, { copied: false, children: /* @__PURE__ */ jsx30(CopyIcon, {}) })
2695
+ return /* @__PURE__ */ jsx26(actionBar_exports.Copy, { asChild: true, children: /* @__PURE__ */ jsx26(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsxs4(Fragment4, { children: [
2696
+ /* @__PURE__ */ jsx26(message_exports.If, { copied: true, children: /* @__PURE__ */ jsx26(CheckIcon, {}) }),
2697
+ /* @__PURE__ */ jsx26(message_exports.If, { copied: false, children: /* @__PURE__ */ jsx26(CopyIcon, {}) })
3987
2698
  ] }) }) });
3988
2699
  });
3989
2700
  AssistantActionBarCopy.displayName = "AssistantActionBarCopy";
3990
- var AssistantActionBarReload = forwardRef18((props, ref) => {
2701
+ var AssistantActionBarReload = forwardRef15((props, ref) => {
3991
2702
  const {
3992
2703
  strings: {
3993
2704
  assistantMessage: { reload: { tooltip = "Refresh" } = {} } = {}
@@ -3995,7 +2706,7 @@ var AssistantActionBarReload = forwardRef18((props, ref) => {
3995
2706
  } = useThreadConfig();
3996
2707
  const allowReload = useAllowReload();
3997
2708
  if (!allowReload) return null;
3998
- return /* @__PURE__ */ jsx30(actionBar_exports.Reload, { asChild: true, children: /* @__PURE__ */ jsx30(TooltipIconButton, { tooltip, ...props, ref, children: /* @__PURE__ */ jsx30(RefreshCwIcon, {}) }) });
2709
+ return /* @__PURE__ */ jsx26(actionBar_exports.Reload, { asChild: true, children: /* @__PURE__ */ jsx26(TooltipIconButton, { tooltip, ...props, ref, children: /* @__PURE__ */ jsx26(RefreshCwIcon, {}) }) });
3999
2710
  });
4000
2711
  AssistantActionBarReload.displayName = "AssistantActionBarReload";
4001
2712
  var exports = {
@@ -4009,12 +2720,12 @@ var assistant_action_bar_default = Object.assign(
4009
2720
  );
4010
2721
 
4011
2722
  // src/ui/assistant-message.tsx
4012
- import { forwardRef as forwardRef20 } from "react";
2723
+ import { forwardRef as forwardRef17 } from "react";
4013
2724
 
4014
2725
  // src/ui/branch-picker.tsx
4015
- import { forwardRef as forwardRef19 } from "react";
2726
+ import { forwardRef as forwardRef16 } from "react";
4016
2727
  import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react";
4017
- import { jsx as jsx31, jsxs as jsxs6 } from "react/jsx-runtime";
2728
+ import { jsx as jsx27, jsxs as jsxs5 } from "react/jsx-runtime";
4018
2729
  var useAllowBranchPicker = () => {
4019
2730
  const { branchPicker: { allowBranchPicker = true } = {} } = useThreadConfig();
4020
2731
  const { useThreadActions } = useThreadContext();
@@ -4024,10 +2735,10 @@ var useAllowBranchPicker = () => {
4024
2735
  var BranchPicker = () => {
4025
2736
  const allowBranchPicker = useAllowBranchPicker();
4026
2737
  if (!allowBranchPicker) return null;
4027
- return /* @__PURE__ */ jsxs6(BranchPickerRoot, { hideWhenSingleBranch: true, children: [
4028
- /* @__PURE__ */ jsx31(BranchPickerPrevious2, {}),
4029
- /* @__PURE__ */ jsx31(BranchPickerState, {}),
4030
- /* @__PURE__ */ jsx31(BranchPickerNext, {})
2738
+ return /* @__PURE__ */ jsxs5(BranchPickerRoot, { hideWhenSingleBranch: true, children: [
2739
+ /* @__PURE__ */ jsx27(BranchPickerPrevious2, {}),
2740
+ /* @__PURE__ */ jsx27(BranchPickerState, {}),
2741
+ /* @__PURE__ */ jsx27(BranchPickerNext, {})
4031
2742
  ] });
4032
2743
  };
4033
2744
  BranchPicker.displayName = "BranchPicker";
@@ -4035,31 +2746,31 @@ var BranchPickerRoot = withDefaults(branchPicker_exports.Root, {
4035
2746
  className: "aui-branch-picker-root"
4036
2747
  });
4037
2748
  BranchPickerRoot.displayName = "BranchPickerRoot";
4038
- var BranchPickerPrevious2 = forwardRef19((props, ref) => {
2749
+ var BranchPickerPrevious2 = forwardRef16((props, ref) => {
4039
2750
  const {
4040
2751
  strings: {
4041
2752
  branchPicker: { previous: { tooltip = "Previous" } = {} } = {}
4042
2753
  } = {}
4043
2754
  } = useThreadConfig();
4044
- return /* @__PURE__ */ jsx31(branchPicker_exports.Previous, { asChild: true, children: /* @__PURE__ */ jsx31(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx31(ChevronLeftIcon, {}) }) });
2755
+ return /* @__PURE__ */ jsx27(branchPicker_exports.Previous, { asChild: true, children: /* @__PURE__ */ jsx27(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx27(ChevronLeftIcon, {}) }) });
4045
2756
  });
4046
2757
  BranchPickerPrevious2.displayName = "BranchPickerPrevious";
4047
2758
  var BranchPickerStateWrapper = withDefaults("span", {
4048
2759
  className: "aui-branch-picker-state"
4049
2760
  });
4050
- var BranchPickerState = forwardRef19((props, ref) => {
4051
- return /* @__PURE__ */ jsxs6(BranchPickerStateWrapper, { ...props, ref, children: [
4052
- /* @__PURE__ */ jsx31(branchPicker_exports.Number, {}),
2761
+ var BranchPickerState = forwardRef16((props, ref) => {
2762
+ return /* @__PURE__ */ jsxs5(BranchPickerStateWrapper, { ...props, ref, children: [
2763
+ /* @__PURE__ */ jsx27(branchPicker_exports.Number, {}),
4053
2764
  " / ",
4054
- /* @__PURE__ */ jsx31(branchPicker_exports.Count, {})
2765
+ /* @__PURE__ */ jsx27(branchPicker_exports.Count, {})
4055
2766
  ] });
4056
2767
  });
4057
2768
  BranchPickerState.displayName = "BranchPickerState";
4058
- var BranchPickerNext = forwardRef19((props, ref) => {
2769
+ var BranchPickerNext = forwardRef16((props, ref) => {
4059
2770
  const {
4060
2771
  strings: { branchPicker: { next: { tooltip = "Next" } = {} } = {} } = {}
4061
2772
  } = useThreadConfig();
4062
- return /* @__PURE__ */ jsx31(branchPicker_exports.Next, { asChild: true, children: /* @__PURE__ */ jsx31(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx31(ChevronRightIcon, {}) }) });
2773
+ return /* @__PURE__ */ jsx27(branchPicker_exports.Next, { asChild: true, children: /* @__PURE__ */ jsx27(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx27(ChevronRightIcon, {}) }) });
4063
2774
  });
4064
2775
  BranchPickerNext.displayName = "BranchPickerNext";
4065
2776
  var exports2 = {
@@ -4071,12 +2782,12 @@ var branch_picker_default = Object.assign(BranchPicker, exports2);
4071
2782
 
4072
2783
  // src/ui/base/avatar.tsx
4073
2784
  import * as AvatarPrimitive from "@radix-ui/react-avatar";
4074
- import { jsx as jsx32, jsxs as jsxs7 } from "react/jsx-runtime";
2785
+ import { jsx as jsx28, jsxs as jsxs6 } from "react/jsx-runtime";
4075
2786
  var Avatar = ({ src, alt, fallback }) => {
4076
2787
  if (src == null && fallback == null) return null;
4077
- return /* @__PURE__ */ jsxs7(AvatarRoot, { children: [
4078
- src != null && /* @__PURE__ */ jsx32(AvatarImage, { src, alt }),
4079
- fallback != null && /* @__PURE__ */ jsx32(AvatarFallback, { children: fallback })
2788
+ return /* @__PURE__ */ jsxs6(AvatarRoot, { children: [
2789
+ src != null && /* @__PURE__ */ jsx28(AvatarImage, { src, alt }),
2790
+ fallback != null && /* @__PURE__ */ jsx28(AvatarFallback, { children: fallback })
4080
2791
  ] });
4081
2792
  };
4082
2793
  Avatar.displayName = "Avatar";
@@ -4094,37 +2805,38 @@ var AvatarFallback = withDefaults(AvatarPrimitive.Fallback, {
4094
2805
  AvatarFallback.displayName = "AvatarFallback";
4095
2806
 
4096
2807
  // src/ui/content-part.tsx
4097
- import classNames2 from "classnames";
4098
- import { jsx as jsx33 } from "react/jsx-runtime";
4099
- var Text = ({ status }) => {
4100
- return /* @__PURE__ */ jsx33(
4101
- "p",
2808
+ import classNames from "classnames";
2809
+ import { jsx as jsx29 } from "react/jsx-runtime";
2810
+ var Text = () => {
2811
+ const status = useSmoothStatus();
2812
+ return /* @__PURE__ */ jsx29(
2813
+ contentPart_exports.Text,
4102
2814
  {
4103
- className: classNames2(
2815
+ className: classNames(
4104
2816
  "aui-text",
4105
- status.type === "running" && "aui-text-in-progress"
2817
+ status.type === "running" && "aui-text-running"
4106
2818
  ),
4107
- children: /* @__PURE__ */ jsx33(contentPart_exports.Text, {})
2819
+ component: "p"
4108
2820
  }
4109
2821
  );
4110
2822
  };
4111
- var exports3 = { Text };
2823
+ var exports3 = { Text: withSmoothContextProvider(Text) };
4112
2824
  var content_part_default = exports3;
4113
2825
 
4114
2826
  // src/ui/assistant-message.tsx
4115
- import { jsx as jsx34, jsxs as jsxs8 } from "react/jsx-runtime";
2827
+ import { jsx as jsx30, jsxs as jsxs7 } from "react/jsx-runtime";
4116
2828
  var AssistantMessage = () => {
4117
- return /* @__PURE__ */ jsxs8(AssistantMessageRoot, { children: [
4118
- /* @__PURE__ */ jsx34(AssistantMessageAvatar, {}),
4119
- /* @__PURE__ */ jsx34(AssistantMessageContent, {}),
4120
- /* @__PURE__ */ jsx34(branch_picker_default, {}),
4121
- /* @__PURE__ */ jsx34(assistant_action_bar_default, {})
2829
+ return /* @__PURE__ */ jsxs7(AssistantMessageRoot, { children: [
2830
+ /* @__PURE__ */ jsx30(AssistantMessageAvatar, {}),
2831
+ /* @__PURE__ */ jsx30(AssistantMessageContent, {}),
2832
+ /* @__PURE__ */ jsx30(branch_picker_default, {}),
2833
+ /* @__PURE__ */ jsx30(assistant_action_bar_default, {})
4122
2834
  ] });
4123
2835
  };
4124
2836
  AssistantMessage.displayName = "AssistantMessage";
4125
2837
  var AssistantMessageAvatar = () => {
4126
2838
  const { assistantAvatar: avatar = { fallback: "A" } } = useThreadConfig();
4127
- return /* @__PURE__ */ jsx34(Avatar, { ...avatar });
2839
+ return /* @__PURE__ */ jsx30(Avatar, { ...avatar });
4128
2840
  };
4129
2841
  var AssistantMessageRoot = withDefaults(message_exports.Root, {
4130
2842
  className: "aui-assistant-message-root"
@@ -4133,9 +2845,9 @@ AssistantMessageRoot.displayName = "AssistantMessageRoot";
4133
2845
  var AssistantMessageContentWrapper = withDefaults("div", {
4134
2846
  className: "aui-assistant-message-content"
4135
2847
  });
4136
- var AssistantMessageContent = forwardRef20(({ components: componentsProp, ...rest }, ref) => {
2848
+ var AssistantMessageContent = forwardRef17(({ components: componentsProp, ...rest }, ref) => {
4137
2849
  const { assistantMessage: { components = {} } = {} } = useThreadConfig();
4138
- return /* @__PURE__ */ jsx34(AssistantMessageContentWrapper, { ...rest, ref, children: /* @__PURE__ */ jsx34(
2850
+ return /* @__PURE__ */ jsx30(AssistantMessageContentWrapper, { ...rest, ref, children: /* @__PURE__ */ jsx30(
4139
2851
  message_exports.Content,
4140
2852
  {
4141
2853
  components: {
@@ -4157,38 +2869,38 @@ var assistant_message_default = Object.assign(
4157
2869
  );
4158
2870
 
4159
2871
  // src/ui/assistant-modal.tsx
4160
- import { forwardRef as forwardRef27 } from "react";
2872
+ import { forwardRef as forwardRef24 } from "react";
4161
2873
  import { BotIcon, ChevronDownIcon } from "lucide-react";
4162
2874
 
4163
2875
  // src/ui/thread.tsx
4164
- import { forwardRef as forwardRef26 } from "react";
2876
+ import { forwardRef as forwardRef23 } from "react";
4165
2877
  import { ArrowDownIcon } from "lucide-react";
4166
2878
 
4167
2879
  // src/ui/composer.tsx
4168
- import { forwardRef as forwardRef21 } from "react";
2880
+ import { forwardRef as forwardRef18 } from "react";
4169
2881
  import { SendHorizontalIcon } from "lucide-react";
4170
2882
 
4171
2883
  // src/ui/base/CircleStopIcon.tsx
4172
- import { jsx as jsx35 } from "react/jsx-runtime";
2884
+ import { jsx as jsx31 } from "react/jsx-runtime";
4173
2885
  var CircleStopIcon = () => {
4174
- return /* @__PURE__ */ jsx35(
2886
+ return /* @__PURE__ */ jsx31(
4175
2887
  "svg",
4176
2888
  {
4177
2889
  xmlns: "http://www.w3.org/2000/svg",
4178
2890
  viewBox: "0 0 16 16",
4179
2891
  fill: "currentColor",
4180
- children: /* @__PURE__ */ jsx35("rect", { width: "10", height: "10", x: "3", y: "3", rx: "2" })
2892
+ children: /* @__PURE__ */ jsx31("rect", { width: "10", height: "10", x: "3", y: "3", rx: "2" })
4181
2893
  }
4182
2894
  );
4183
2895
  };
4184
2896
  CircleStopIcon.displayName = "CircleStopIcon";
4185
2897
 
4186
2898
  // src/ui/composer.tsx
4187
- import { Fragment as Fragment5, jsx as jsx36, jsxs as jsxs9 } from "react/jsx-runtime";
2899
+ import { Fragment as Fragment5, jsx as jsx32, jsxs as jsxs8 } from "react/jsx-runtime";
4188
2900
  var Composer = () => {
4189
- return /* @__PURE__ */ jsxs9(ComposerRoot, { children: [
4190
- /* @__PURE__ */ jsx36(ComposerInput, { autoFocus: true }),
4191
- /* @__PURE__ */ jsx36(ComposerAction, {})
2901
+ return /* @__PURE__ */ jsxs8(ComposerRoot, { children: [
2902
+ /* @__PURE__ */ jsx32(ComposerInput, { autoFocus: true }),
2903
+ /* @__PURE__ */ jsx32(ComposerAction, {})
4192
2904
  ] });
4193
2905
  };
4194
2906
  Composer.displayName = "Composer";
@@ -4201,14 +2913,14 @@ var ComposerInputStyled = withDefaults(composer_exports.Input, {
4201
2913
  autoFocus: true,
4202
2914
  className: "aui-composer-input"
4203
2915
  });
4204
- var ComposerInput = forwardRef21(
2916
+ var ComposerInput = forwardRef18(
4205
2917
  (props, ref) => {
4206
2918
  const {
4207
2919
  strings: {
4208
2920
  composer: { input: { placeholder = "Write a message..." } = {} } = {}
4209
2921
  } = {}
4210
2922
  } = useThreadConfig();
4211
- return /* @__PURE__ */ jsx36(ComposerInputStyled, { placeholder, ...props, ref });
2923
+ return /* @__PURE__ */ jsx32(ComposerInputStyled, { placeholder, ...props, ref });
4212
2924
  }
4213
2925
  );
4214
2926
  ComposerInput.displayName = "ComposerInput";
@@ -4219,10 +2931,10 @@ var useAllowCancel = () => {
4219
2931
  };
4220
2932
  var ComposerAction = () => {
4221
2933
  const allowCancel = useAllowCancel();
4222
- if (!allowCancel) return /* @__PURE__ */ jsx36(ComposerSend, {});
4223
- return /* @__PURE__ */ jsxs9(Fragment5, { children: [
4224
- /* @__PURE__ */ jsx36(thread_exports.If, { running: false, children: /* @__PURE__ */ jsx36(ComposerSend, {}) }),
4225
- /* @__PURE__ */ jsx36(thread_exports.If, { running: true, children: /* @__PURE__ */ jsx36(ComposerCancel, {}) })
2934
+ if (!allowCancel) return /* @__PURE__ */ jsx32(ComposerSend, {});
2935
+ return /* @__PURE__ */ jsxs8(Fragment5, { children: [
2936
+ /* @__PURE__ */ jsx32(thread_exports.If, { running: false, children: /* @__PURE__ */ jsx32(ComposerSend, {}) }),
2937
+ /* @__PURE__ */ jsx32(thread_exports.If, { running: true, children: /* @__PURE__ */ jsx32(ComposerCancel, {}) })
4226
2938
  ] });
4227
2939
  };
4228
2940
  ComposerAction.displayName = "ComposerAction";
@@ -4230,22 +2942,22 @@ var ComposerSendButton = withDefaults(TooltipIconButton, {
4230
2942
  variant: "default",
4231
2943
  className: "aui-composer-send"
4232
2944
  });
4233
- var ComposerSend = forwardRef21((props, ref) => {
2945
+ var ComposerSend = forwardRef18((props, ref) => {
4234
2946
  const {
4235
2947
  strings: { composer: { send: { tooltip = "Send" } = {} } = {} } = {}
4236
2948
  } = useThreadConfig();
4237
- return /* @__PURE__ */ jsx36(composer_exports.Send, { asChild: true, children: /* @__PURE__ */ jsx36(ComposerSendButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx36(SendHorizontalIcon, {}) }) });
2949
+ return /* @__PURE__ */ jsx32(composer_exports.Send, { asChild: true, children: /* @__PURE__ */ jsx32(ComposerSendButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx32(SendHorizontalIcon, {}) }) });
4238
2950
  });
4239
2951
  ComposerSend.displayName = "ComposerSend";
4240
2952
  var ComposerCancelButton = withDefaults(TooltipIconButton, {
4241
2953
  variant: "default",
4242
2954
  className: "aui-composer-cancel"
4243
2955
  });
4244
- var ComposerCancel = forwardRef21((props, ref) => {
2956
+ var ComposerCancel = forwardRef18((props, ref) => {
4245
2957
  const {
4246
2958
  strings: { composer: { cancel: { tooltip = "Cancel" } = {} } = {} } = {}
4247
2959
  } = useThreadConfig();
4248
- return /* @__PURE__ */ jsx36(composer_exports.Cancel, { asChild: true, children: /* @__PURE__ */ jsx36(ComposerCancelButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx36(CircleStopIcon, {}) }) });
2960
+ return /* @__PURE__ */ jsx32(composer_exports.Cancel, { asChild: true, children: /* @__PURE__ */ jsx32(ComposerCancelButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx32(CircleStopIcon, {}) }) });
4249
2961
  });
4250
2962
  ComposerCancel.displayName = "ComposerCancel";
4251
2963
  var exports5 = {
@@ -4258,15 +2970,15 @@ var exports5 = {
4258
2970
  var composer_default = Object.assign(Composer, exports5);
4259
2971
 
4260
2972
  // src/ui/thread-welcome.tsx
4261
- import { forwardRef as forwardRef22 } from "react";
4262
- import { jsx as jsx37, jsxs as jsxs10 } from "react/jsx-runtime";
2973
+ import { forwardRef as forwardRef19 } from "react";
2974
+ import { jsx as jsx33, jsxs as jsxs9 } from "react/jsx-runtime";
4263
2975
  var ThreadWelcome = () => {
4264
- return /* @__PURE__ */ jsxs10(ThreadWelcomeRoot, { children: [
4265
- /* @__PURE__ */ jsxs10(ThreadWelcomeCenter, { children: [
4266
- /* @__PURE__ */ jsx37(ThreadWelcomeAvatar, {}),
4267
- /* @__PURE__ */ jsx37(ThreadWelcomeMessage, {})
2976
+ return /* @__PURE__ */ jsxs9(ThreadWelcomeRoot, { children: [
2977
+ /* @__PURE__ */ jsxs9(ThreadWelcomeCenter, { children: [
2978
+ /* @__PURE__ */ jsx33(ThreadWelcomeAvatar, {}),
2979
+ /* @__PURE__ */ jsx33(ThreadWelcomeMessage, {})
4268
2980
  ] }),
4269
- /* @__PURE__ */ jsx37(ThreadWelcomeSuggestions, {})
2981
+ /* @__PURE__ */ jsx33(ThreadWelcomeSuggestions, {})
4270
2982
  ] });
4271
2983
  };
4272
2984
  ThreadWelcome.displayName = "ThreadWelcome";
@@ -4276,22 +2988,22 @@ var ThreadWelcomeRootStyled = withDefaults("div", {
4276
2988
  var ThreadWelcomeCenter = withDefaults("div", {
4277
2989
  className: "aui-thread-welcome-center"
4278
2990
  });
4279
- var ThreadWelcomeRoot = forwardRef22(
2991
+ var ThreadWelcomeRoot = forwardRef19(
4280
2992
  (props, ref) => {
4281
- return /* @__PURE__ */ jsx37(thread_exports.Empty, { children: /* @__PURE__ */ jsx37(ThreadWelcomeRootStyled, { ...props, ref }) });
2993
+ return /* @__PURE__ */ jsx33(thread_exports.Empty, { children: /* @__PURE__ */ jsx33(ThreadWelcomeRootStyled, { ...props, ref }) });
4282
2994
  }
4283
2995
  );
4284
2996
  ThreadWelcomeRoot.displayName = "ThreadWelcomeRoot";
4285
2997
  var ThreadWelcomeAvatar = () => {
4286
2998
  const { assistantAvatar: avatar = { fallback: "A" } } = useThreadConfig();
4287
- return /* @__PURE__ */ jsx37(Avatar, { ...avatar });
2999
+ return /* @__PURE__ */ jsx33(Avatar, { ...avatar });
4288
3000
  };
4289
3001
  var ThreadWelcomeMessageStyled = withDefaults("p", {
4290
3002
  className: "aui-thread-welcome-message"
4291
3003
  });
4292
- var ThreadWelcomeMessage = forwardRef22(({ message: messageProp, ...rest }, ref) => {
3004
+ var ThreadWelcomeMessage = forwardRef19(({ message: messageProp, ...rest }, ref) => {
4293
3005
  const { welcome: { message = "How can I help you today?" } = {} } = useThreadConfig();
4294
- return /* @__PURE__ */ jsx37(ThreadWelcomeMessageStyled, { ...rest, ref, children: messageProp ?? message });
3006
+ return /* @__PURE__ */ jsx33(ThreadWelcomeMessageStyled, { ...rest, ref, children: messageProp ?? message });
4295
3007
  });
4296
3008
  ThreadWelcomeMessage.displayName = "ThreadWelcomeMessage";
4297
3009
  var ThreadWelcomeSuggestionContainer = withDefaults("div", {
@@ -4303,21 +3015,21 @@ var ThreadWelcomeSuggestionStyled = withDefaults(thread_exports.Suggestion, {
4303
3015
  var ThreadWelcomeSuggestion = ({
4304
3016
  suggestion: { text, prompt }
4305
3017
  }) => {
4306
- return /* @__PURE__ */ jsx37(
3018
+ return /* @__PURE__ */ jsx33(
4307
3019
  ThreadWelcomeSuggestionStyled,
4308
3020
  {
4309
3021
  prompt,
4310
3022
  method: "replace",
4311
3023
  autoSend: true,
4312
- children: /* @__PURE__ */ jsx37("span", { className: "aui-thread-welcome-suggestion-text", children: text ?? prompt })
3024
+ children: /* @__PURE__ */ jsx33("span", { className: "aui-thread-welcome-suggestion-text", children: text ?? prompt })
4313
3025
  }
4314
3026
  );
4315
3027
  };
4316
3028
  var ThreadWelcomeSuggestions = () => {
4317
3029
  const { welcome: { suggestions } = {} } = useThreadConfig();
4318
- return /* @__PURE__ */ jsx37(ThreadWelcomeSuggestionContainer, { children: suggestions?.map((suggestion, idx) => {
3030
+ return /* @__PURE__ */ jsx33(ThreadWelcomeSuggestionContainer, { children: suggestions?.map((suggestion, idx) => {
4319
3031
  const key = `${suggestion.prompt}-${idx}`;
4320
- return /* @__PURE__ */ jsx37(ThreadWelcomeSuggestion, { suggestion }, key);
3032
+ return /* @__PURE__ */ jsx33(ThreadWelcomeSuggestion, { suggestion }, key);
4321
3033
  }) });
4322
3034
  };
4323
3035
  ThreadWelcomeSuggestions.displayName = "ThreadWelcomeSuggestions";
@@ -4332,12 +3044,12 @@ var exports6 = {
4332
3044
  var thread_welcome_default = Object.assign(ThreadWelcome, exports6);
4333
3045
 
4334
3046
  // src/ui/user-message.tsx
4335
- import { forwardRef as forwardRef24 } from "react";
3047
+ import { forwardRef as forwardRef21 } from "react";
4336
3048
 
4337
3049
  // src/ui/user-action-bar.tsx
4338
- import { forwardRef as forwardRef23 } from "react";
3050
+ import { forwardRef as forwardRef20 } from "react";
4339
3051
  import { PencilIcon } from "lucide-react";
4340
- import { jsx as jsx38 } from "react/jsx-runtime";
3052
+ import { jsx as jsx34 } from "react/jsx-runtime";
4341
3053
  var useAllowEdit = () => {
4342
3054
  const { userMessage: { allowEdit = true } = {} } = useThreadConfig();
4343
3055
  const { useThreadActions } = useThreadContext();
@@ -4347,20 +3059,20 @@ var useAllowEdit = () => {
4347
3059
  var UserActionBar = () => {
4348
3060
  const allowEdit = useAllowEdit();
4349
3061
  if (!allowEdit) return null;
4350
- return /* @__PURE__ */ jsx38(UserActionBarRoot, { hideWhenRunning: true, autohide: "not-last", children: /* @__PURE__ */ jsx38(UserActionBarEdit, {}) });
3062
+ return /* @__PURE__ */ jsx34(UserActionBarRoot, { hideWhenRunning: true, autohide: "not-last", children: /* @__PURE__ */ jsx34(UserActionBarEdit, {}) });
4351
3063
  };
4352
3064
  UserActionBar.displayName = "UserActionBar";
4353
3065
  var UserActionBarRoot = withDefaults(actionBar_exports.Root, {
4354
3066
  className: "aui-user-action-bar-root"
4355
3067
  });
4356
3068
  UserActionBarRoot.displayName = "UserActionBarRoot";
4357
- var UserActionBarEdit = forwardRef23((props, ref) => {
3069
+ var UserActionBarEdit = forwardRef20((props, ref) => {
4358
3070
  const {
4359
3071
  strings: { userMessage: { edit: { tooltip = "Edit" } = {} } = {} } = {}
4360
3072
  } = useThreadConfig();
4361
3073
  const allowEdit = useAllowEdit();
4362
3074
  if (!allowEdit) return null;
4363
- return /* @__PURE__ */ jsx38(actionBar_exports.Edit, { asChild: true, children: /* @__PURE__ */ jsx38(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx38(PencilIcon, {}) }) });
3075
+ return /* @__PURE__ */ jsx34(actionBar_exports.Edit, { asChild: true, children: /* @__PURE__ */ jsx34(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx34(PencilIcon, {}) }) });
4364
3076
  });
4365
3077
  UserActionBarEdit.displayName = "UserActionBarEdit";
4366
3078
  var exports7 = {
@@ -4370,12 +3082,12 @@ var exports7 = {
4370
3082
  var user_action_bar_default = Object.assign(UserActionBar, exports7);
4371
3083
 
4372
3084
  // src/ui/user-message.tsx
4373
- import { jsx as jsx39, jsxs as jsxs11 } from "react/jsx-runtime";
3085
+ import { jsx as jsx35, jsxs as jsxs10 } from "react/jsx-runtime";
4374
3086
  var UserMessage = () => {
4375
- return /* @__PURE__ */ jsxs11(UserMessageRoot, { children: [
4376
- /* @__PURE__ */ jsx39(user_action_bar_default, {}),
4377
- /* @__PURE__ */ jsx39(UserMessageContent, {}),
4378
- /* @__PURE__ */ jsx39(branch_picker_default, {})
3087
+ return /* @__PURE__ */ jsxs10(UserMessageRoot, { children: [
3088
+ /* @__PURE__ */ jsx35(user_action_bar_default, {}),
3089
+ /* @__PURE__ */ jsx35(UserMessageContent, {}),
3090
+ /* @__PURE__ */ jsx35(branch_picker_default, {})
4379
3091
  ] });
4380
3092
  };
4381
3093
  UserMessage.displayName = "UserMessage";
@@ -4386,9 +3098,9 @@ UserMessageRoot.displayName = "UserMessageRoot";
4386
3098
  var UserMessageContentWrapper = withDefaults("div", {
4387
3099
  className: "aui-user-message-content"
4388
3100
  });
4389
- var UserMessageContent = forwardRef24(
3101
+ var UserMessageContent = forwardRef21(
4390
3102
  ({ components, ...props }, ref) => {
4391
- return /* @__PURE__ */ jsx39(UserMessageContentWrapper, { ...props, ref, children: /* @__PURE__ */ jsx39(
3103
+ return /* @__PURE__ */ jsx35(UserMessageContentWrapper, { ...props, ref, children: /* @__PURE__ */ jsx35(
4392
3104
  message_exports.Content,
4393
3105
  {
4394
3106
  components: {
@@ -4407,14 +3119,14 @@ var exports8 = {
4407
3119
  var user_message_default = Object.assign(UserMessage, exports8);
4408
3120
 
4409
3121
  // src/ui/edit-composer.tsx
4410
- import { forwardRef as forwardRef25 } from "react";
4411
- import { jsx as jsx40, jsxs as jsxs12 } from "react/jsx-runtime";
3122
+ import { forwardRef as forwardRef22 } from "react";
3123
+ import { jsx as jsx36, jsxs as jsxs11 } from "react/jsx-runtime";
4412
3124
  var EditComposer = () => {
4413
- return /* @__PURE__ */ jsxs12(EditComposerRoot, { children: [
4414
- /* @__PURE__ */ jsx40(EditComposerInput, {}),
4415
- /* @__PURE__ */ jsxs12(EditComposerFooter, { children: [
4416
- /* @__PURE__ */ jsx40(EditComposerCancel, {}),
4417
- /* @__PURE__ */ jsx40(EditComposerSend, {})
3125
+ return /* @__PURE__ */ jsxs11(EditComposerRoot, { children: [
3126
+ /* @__PURE__ */ jsx36(EditComposerInput, {}),
3127
+ /* @__PURE__ */ jsxs11(EditComposerFooter, { children: [
3128
+ /* @__PURE__ */ jsx36(EditComposerCancel, {}),
3129
+ /* @__PURE__ */ jsx36(EditComposerSend, {})
4418
3130
  ] })
4419
3131
  ] });
4420
3132
  };
@@ -4431,23 +3143,23 @@ var EditComposerFooter = withDefaults("div", {
4431
3143
  className: "aui-edit-composer-footer"
4432
3144
  });
4433
3145
  EditComposerFooter.displayName = "EditComposerFooter";
4434
- var EditComposerCancel = forwardRef25(
3146
+ var EditComposerCancel = forwardRef22(
4435
3147
  (props, ref) => {
4436
3148
  const {
4437
3149
  strings: {
4438
3150
  editComposer: { cancel: { label = "Cancel" } = {} } = {}
4439
3151
  } = {}
4440
3152
  } = useThreadConfig();
4441
- return /* @__PURE__ */ jsx40(composer_exports.Cancel, { asChild: true, children: /* @__PURE__ */ jsx40(Button, { variant: "ghost", ...props, ref, children: props.children ?? label }) });
3153
+ return /* @__PURE__ */ jsx36(composer_exports.Cancel, { asChild: true, children: /* @__PURE__ */ jsx36(Button, { variant: "ghost", ...props, ref, children: props.children ?? label }) });
4442
3154
  }
4443
3155
  );
4444
3156
  EditComposerCancel.displayName = "EditComposerCancel";
4445
- var EditComposerSend = forwardRef25(
3157
+ var EditComposerSend = forwardRef22(
4446
3158
  (props, ref) => {
4447
3159
  const {
4448
3160
  strings: { editComposer: { send: { label = "Send" } = {} } = {} } = {}
4449
3161
  } = useThreadConfig();
4450
- return /* @__PURE__ */ jsx40(composer_exports.Send, { asChild: true, children: /* @__PURE__ */ jsx40(Button, { ...props, ref, children: props.children ?? label }) });
3162
+ return /* @__PURE__ */ jsx36(composer_exports.Send, { asChild: true, children: /* @__PURE__ */ jsx36(Button, { ...props, ref, children: props.children ?? label }) });
4451
3163
  }
4452
3164
  );
4453
3165
  EditComposerSend.displayName = "EditComposerSend";
@@ -4461,23 +3173,23 @@ var exports9 = {
4461
3173
  var edit_composer_default = Object.assign(EditComposer, exports9);
4462
3174
 
4463
3175
  // src/ui/thread.tsx
4464
- import { jsx as jsx41, jsxs as jsxs13 } from "react/jsx-runtime";
3176
+ import { jsx as jsx37, jsxs as jsxs12 } from "react/jsx-runtime";
4465
3177
  var Thread = (config) => {
4466
- return /* @__PURE__ */ jsx41(ThreadRoot, { config, children: /* @__PURE__ */ jsxs13(ThreadViewport, { children: [
4467
- /* @__PURE__ */ jsx41(thread_welcome_default, {}),
4468
- /* @__PURE__ */ jsx41(ThreadMessages, {}),
4469
- /* @__PURE__ */ jsxs13(ThreadViewportFooter, { children: [
4470
- /* @__PURE__ */ jsx41(ThreadScrollToBottom, {}),
4471
- /* @__PURE__ */ jsx41(composer_default, {})
3178
+ return /* @__PURE__ */ jsx37(ThreadRoot, { config, children: /* @__PURE__ */ jsxs12(ThreadViewport, { children: [
3179
+ /* @__PURE__ */ jsx37(thread_welcome_default, {}),
3180
+ /* @__PURE__ */ jsx37(ThreadMessages, {}),
3181
+ /* @__PURE__ */ jsxs12(ThreadViewportFooter, { children: [
3182
+ /* @__PURE__ */ jsx37(ThreadScrollToBottom, {}),
3183
+ /* @__PURE__ */ jsx37(composer_default, {})
4472
3184
  ] })
4473
3185
  ] }) });
4474
3186
  };
4475
3187
  var ThreadRootStyled = withDefaults(thread_exports.Root, {
4476
3188
  className: "aui-root aui-thread-root"
4477
3189
  });
4478
- var ThreadRoot = forwardRef26(
3190
+ var ThreadRoot = forwardRef23(
4479
3191
  ({ config, ...props }, ref) => {
4480
- return /* @__PURE__ */ jsx41(ThreadConfigProvider, { config, children: /* @__PURE__ */ jsx41(ThreadRootStyled, { ...props, ref }) });
3192
+ return /* @__PURE__ */ jsx37(ThreadConfigProvider, { config, children: /* @__PURE__ */ jsx37(ThreadRootStyled, { ...props, ref }) });
4481
3193
  }
4482
3194
  );
4483
3195
  ThreadRoot.displayName = "ThreadRoot";
@@ -4491,7 +3203,7 @@ var ThreadViewportFooter = withDefaults("div", {
4491
3203
  ThreadViewportFooter.displayName = "ThreadViewportFooter";
4492
3204
  var SystemMessage = () => null;
4493
3205
  var ThreadMessages = ({ components, ...rest }) => {
4494
- return /* @__PURE__ */ jsx41(
3206
+ return /* @__PURE__ */ jsx37(
4495
3207
  thread_exports.Messages,
4496
3208
  {
4497
3209
  components: {
@@ -4509,13 +3221,13 @@ var ThreadScrollToBottomIconButton = withDefaults(TooltipIconButton, {
4509
3221
  variant: "outline",
4510
3222
  className: "aui-thread-scroll-to-bottom"
4511
3223
  });
4512
- var ThreadScrollToBottom = forwardRef26((props, ref) => {
3224
+ var ThreadScrollToBottom = forwardRef23((props, ref) => {
4513
3225
  const {
4514
3226
  strings: {
4515
3227
  thread: { scrollToBottom: { tooltip = "Scroll to bottom" } = {} } = {}
4516
3228
  } = {}
4517
3229
  } = useThreadConfig();
4518
- return /* @__PURE__ */ jsx41(thread_exports.ScrollToBottom, { asChild: true, children: /* @__PURE__ */ jsx41(ThreadScrollToBottomIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx41(ArrowDownIcon, {}) }) });
3230
+ return /* @__PURE__ */ jsx37(thread_exports.ScrollToBottom, { asChild: true, children: /* @__PURE__ */ jsx37(ThreadScrollToBottomIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx37(ArrowDownIcon, {}) }) });
4519
3231
  });
4520
3232
  ThreadScrollToBottom.displayName = "ThreadScrollToBottom";
4521
3233
  var exports10 = {
@@ -4528,20 +3240,20 @@ var exports10 = {
4528
3240
  var thread_default = Object.assign(Thread, exports10);
4529
3241
 
4530
3242
  // src/ui/assistant-modal.tsx
4531
- import { Fragment as Fragment6, jsx as jsx42, jsxs as jsxs14 } from "react/jsx-runtime";
3243
+ import { Fragment as Fragment6, jsx as jsx38, jsxs as jsxs13 } from "react/jsx-runtime";
4532
3244
  var AssistantModal = (config) => {
4533
- return /* @__PURE__ */ jsxs14(AssistantModalRoot, { config, children: [
4534
- /* @__PURE__ */ jsx42(AssistantModalTrigger, {}),
4535
- /* @__PURE__ */ jsx42(AssistantModalContent, { children: /* @__PURE__ */ jsx42(thread_default, {}) })
3245
+ return /* @__PURE__ */ jsxs13(AssistantModalRoot, { config, children: [
3246
+ /* @__PURE__ */ jsx38(AssistantModalTrigger, {}),
3247
+ /* @__PURE__ */ jsx38(AssistantModalContent, { children: /* @__PURE__ */ jsx38(thread_default, {}) })
4536
3248
  ] });
4537
3249
  };
4538
3250
  AssistantModal.displayName = "AssistantModal";
4539
3251
  var AssistantModalRoot = ({ config, ...props }) => {
4540
- return /* @__PURE__ */ jsx42(ThreadConfigProvider, { config, children: /* @__PURE__ */ jsx42(assistantModal_exports.Root, { ...props }) });
3252
+ return /* @__PURE__ */ jsx38(ThreadConfigProvider, { config, children: /* @__PURE__ */ jsx38(assistantModal_exports.Root, { ...props }) });
4541
3253
  };
4542
3254
  AssistantModalRoot.displayName = "AssistantModalRoot";
4543
- var AssistantModalTrigger = forwardRef27((props, ref) => {
4544
- return /* @__PURE__ */ jsx42(AssistantModalAnchor, { children: /* @__PURE__ */ jsx42(assistantModal_exports.Trigger, { asChild: true, children: /* @__PURE__ */ jsx42(AssistantModalButton, { ...props, ref }) }) });
3255
+ var AssistantModalTrigger = forwardRef24((props, ref) => {
3256
+ return /* @__PURE__ */ jsx38(AssistantModalAnchor, { children: /* @__PURE__ */ jsx38(assistantModal_exports.Trigger, { asChild: true, children: /* @__PURE__ */ jsx38(AssistantModalButton, { ...props, ref }) }) });
4545
3257
  });
4546
3258
  AssistantModalTrigger.displayName = "AssistantModalTrigger";
4547
3259
  var AssistantModalAnchor = withDefaults(assistantModal_exports.Anchor, {
@@ -4552,7 +3264,7 @@ var ModalButtonStyled = withDefaults(TooltipIconButton, {
4552
3264
  variant: "default",
4553
3265
  className: "aui-modal-button"
4554
3266
  });
4555
- var AssistantModalButton = forwardRef27(({ "data-state": state, ...rest }, ref) => {
3267
+ var AssistantModalButton = forwardRef24(({ "data-state": state, ...rest }, ref) => {
4556
3268
  const {
4557
3269
  strings: {
4558
3270
  assistantModal: {
@@ -4566,7 +3278,7 @@ var AssistantModalButton = forwardRef27(({ "data-state": state, ...rest }, ref)
4566
3278
  } = {}
4567
3279
  } = useThreadConfig();
4568
3280
  const tooltip = state === "open" ? openTooltip : closedTooltip;
4569
- return /* @__PURE__ */ jsx42(
3281
+ return /* @__PURE__ */ jsx38(
4570
3282
  ModalButtonStyled,
4571
3283
  {
4572
3284
  side: "left",
@@ -4574,15 +3286,15 @@ var AssistantModalButton = forwardRef27(({ "data-state": state, ...rest }, ref)
4574
3286
  "data-state": state,
4575
3287
  ...rest,
4576
3288
  ref,
4577
- children: rest.children ?? /* @__PURE__ */ jsxs14(Fragment6, { children: [
4578
- /* @__PURE__ */ jsx42(
3289
+ children: rest.children ?? /* @__PURE__ */ jsxs13(Fragment6, { children: [
3290
+ /* @__PURE__ */ jsx38(
4579
3291
  BotIcon,
4580
3292
  {
4581
3293
  "data-state": state,
4582
3294
  className: "aui-modal-button-closed-icon"
4583
3295
  }
4584
3296
  ),
4585
- /* @__PURE__ */ jsx42(
3297
+ /* @__PURE__ */ jsx38(
4586
3298
  ChevronDownIcon,
4587
3299
  {
4588
3300
  "data-state": state,