@assistant-ui/react 0.5.21 → 0.5.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{AssistantTypes-D93BmqD5.d.mts → AssistantTypes-BNB-knVq.d.mts} +1 -1
- package/dist/{AssistantTypes-D93BmqD5.d.ts → AssistantTypes-BNB-knVq.d.ts} +1 -1
- package/dist/chunk-DCHYNTHI.js +11 -0
- package/dist/chunk-DCHYNTHI.js.map +1 -0
- package/dist/chunk-NSPHKRLF.js +819 -0
- package/dist/chunk-NSPHKRLF.js.map +1 -0
- package/dist/{chunk-2RKUKZSZ.mjs → chunk-ZWRFAYHH.mjs} +61 -3
- package/dist/chunk-ZWRFAYHH.mjs.map +1 -0
- package/dist/edge.d.mts +90 -5
- package/dist/edge.d.ts +90 -5
- package/dist/edge.js +0 -1
- package/dist/edge.js.map +1 -1
- package/dist/edge.mjs +799 -49
- package/dist/edge.mjs.map +1 -1
- package/dist/index.d.mts +153 -7
- package/dist/index.d.ts +153 -7
- package/dist/index.js +724 -1596
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +807 -252
- package/dist/index.mjs.map +1 -1
- package/dist/tailwindcss/index.js +24 -53
- package/dist/tailwindcss/index.js.map +1 -1
- package/package.json +1 -12
- package/dist/Thread-BbLf1cc4.d.mts +0 -156
- package/dist/Thread-jfAlPLli.d.ts +0 -156
- package/dist/chunk-2RKUKZSZ.mjs.map +0 -1
- package/dist/chunk-QBS6JLLN.mjs +0 -63
- package/dist/chunk-QBS6JLLN.mjs.map +0 -1
- package/dist/chunk-V66MVXBH.mjs +0 -608
- package/dist/chunk-V66MVXBH.mjs.map +0 -1
- package/dist/internal.d.mts +0 -9
- package/dist/internal.d.ts +0 -9
- package/dist/internal.js +0 -620
- package/dist/internal.js.map +0 -1
- package/dist/internal.mjs +0 -24
- package/dist/internal.mjs.map +0 -1
- package/internal/README.md +0 -1
- package/internal/package.json +0 -5
package/dist/index.mjs
CHANGED
@@ -1,37 +1,13 @@
|
|
1
1
|
"use client";
|
2
2
|
import {
|
3
|
+
mergeModelConfigs,
|
3
4
|
runResultStream,
|
4
5
|
toCoreMessage,
|
5
6
|
toCoreMessages,
|
6
7
|
toLanguageModelMessages,
|
7
8
|
toLanguageModelTools,
|
8
9
|
toolResultStream
|
9
|
-
} from "./chunk-
|
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";
|
10
|
+
} from "./chunk-ZWRFAYHH.mjs";
|
35
11
|
import {
|
36
12
|
__export
|
37
13
|
} from "./chunk-BJPOCE4O.mjs";
|
@@ -42,8 +18,38 @@ import { memo } from "react";
|
|
42
18
|
// src/context/providers/AssistantProvider.tsx
|
43
19
|
import { useEffect, useInsertionEffect as useInsertionEffect2, useRef as useRef2, useState as useState2 } from "react";
|
44
20
|
|
21
|
+
// src/context/react/AssistantContext.ts
|
22
|
+
import { createContext, useContext } from "react";
|
23
|
+
var AssistantContext = createContext(
|
24
|
+
null
|
25
|
+
);
|
26
|
+
function useAssistantContext(options) {
|
27
|
+
const context = useContext(AssistantContext);
|
28
|
+
if (!options?.optional && !context)
|
29
|
+
throw new Error(
|
30
|
+
"This component must be used within an AssistantRuntimeProvider."
|
31
|
+
);
|
32
|
+
return context;
|
33
|
+
}
|
34
|
+
|
45
35
|
// src/context/stores/AssistantModelConfig.ts
|
46
36
|
import { create } from "zustand";
|
37
|
+
|
38
|
+
// src/utils/ProxyConfigProvider.ts
|
39
|
+
var ProxyConfigProvider = class {
|
40
|
+
_providers = /* @__PURE__ */ new Set();
|
41
|
+
getModelConfig() {
|
42
|
+
return mergeModelConfigs(this._providers);
|
43
|
+
}
|
44
|
+
registerModelConfigProvider(provider) {
|
45
|
+
this._providers.add(provider);
|
46
|
+
return () => {
|
47
|
+
this._providers.delete(provider);
|
48
|
+
};
|
49
|
+
}
|
50
|
+
};
|
51
|
+
|
52
|
+
// src/context/stores/AssistantModelConfig.ts
|
47
53
|
var makeAssistantModelConfigStore = () => create(() => {
|
48
54
|
const proxy = new ProxyConfigProvider();
|
49
55
|
return Object.freeze({
|
@@ -91,6 +97,18 @@ var makeAssistantToolUIsStore = () => create2((set) => {
|
|
91
97
|
// src/context/providers/ThreadProvider.tsx
|
92
98
|
import { useCallback as useCallback2, useInsertionEffect, useState } from "react";
|
93
99
|
|
100
|
+
// src/context/react/ThreadContext.ts
|
101
|
+
import { createContext as createContext2, useContext as useContext2 } from "react";
|
102
|
+
var ThreadContext = createContext2(null);
|
103
|
+
function useThreadContext(options) {
|
104
|
+
const context = useContext2(ThreadContext);
|
105
|
+
if (!options?.optional && !context)
|
106
|
+
throw new Error(
|
107
|
+
"This component must be used within an AssistantRuntimeProvider."
|
108
|
+
);
|
109
|
+
return context;
|
110
|
+
}
|
111
|
+
|
94
112
|
// src/context/stores/Composer.ts
|
95
113
|
import { create as create3 } from "zustand";
|
96
114
|
|
@@ -318,6 +336,48 @@ var AssistantRuntimeProviderImpl = ({ children, runtime }) => {
|
|
318
336
|
};
|
319
337
|
var AssistantRuntimeProvider = memo(AssistantRuntimeProviderImpl);
|
320
338
|
|
339
|
+
// src/context/react/ComposerContext.ts
|
340
|
+
import { useMemo } from "react";
|
341
|
+
|
342
|
+
// src/context/react/MessageContext.ts
|
343
|
+
import { createContext as createContext3, useContext as useContext3 } from "react";
|
344
|
+
var MessageContext = createContext3(null);
|
345
|
+
function useMessageContext(options) {
|
346
|
+
const context = useContext3(MessageContext);
|
347
|
+
if (!options?.optional && !context)
|
348
|
+
throw new Error(
|
349
|
+
"This component can only be used inside a component passed to <ThreadPrimitive.Messages components={...} />."
|
350
|
+
);
|
351
|
+
return context;
|
352
|
+
}
|
353
|
+
|
354
|
+
// src/context/react/ComposerContext.ts
|
355
|
+
var useComposerContext = () => {
|
356
|
+
const { useComposer } = useThreadContext();
|
357
|
+
const { useEditComposer } = useMessageContext({ optional: true }) ?? {};
|
358
|
+
return useMemo(
|
359
|
+
() => ({
|
360
|
+
useComposer: useEditComposer ?? useComposer,
|
361
|
+
type: useEditComposer ? "edit" : "new"
|
362
|
+
}),
|
363
|
+
[useEditComposer, useComposer]
|
364
|
+
);
|
365
|
+
};
|
366
|
+
|
367
|
+
// src/context/react/ContentPartContext.ts
|
368
|
+
import { createContext as createContext4, useContext as useContext4 } from "react";
|
369
|
+
var ContentPartContext = createContext4(
|
370
|
+
null
|
371
|
+
);
|
372
|
+
function useContentPartContext(options) {
|
373
|
+
const context = useContext4(ContentPartContext);
|
374
|
+
if (!options?.optional && !context)
|
375
|
+
throw new Error(
|
376
|
+
"This component can only be used inside a component passed to <MessagePrimitive.Content components={...} >."
|
377
|
+
);
|
378
|
+
return context;
|
379
|
+
}
|
380
|
+
|
321
381
|
// src/hooks/useAppendMessage.tsx
|
322
382
|
import { useCallback as useCallback3 } from "react";
|
323
383
|
var toAppendMessage = (useThreadMessages, message) => {
|
@@ -435,7 +495,7 @@ var useAssistantInstructions = (instruction) => {
|
|
435
495
|
import { useCallback as useCallback5 } from "react";
|
436
496
|
|
437
497
|
// src/utils/combined/useCombinedStore.ts
|
438
|
-
import { useMemo } from "react";
|
498
|
+
import { useMemo as useMemo2 } from "react";
|
439
499
|
|
440
500
|
// src/utils/combined/createCombinedStore.ts
|
441
501
|
import { useSyncExternalStore } from "react";
|
@@ -456,7 +516,7 @@ var createCombinedStore = (stores) => {
|
|
456
516
|
|
457
517
|
// src/utils/combined/useCombinedStore.ts
|
458
518
|
var useCombinedStore = (stores, selector) => {
|
459
|
-
const useCombined =
|
519
|
+
const useCombined = useMemo2(() => createCombinedStore(stores), stores);
|
460
520
|
return useCombined(selector);
|
461
521
|
};
|
462
522
|
|
@@ -1011,7 +1071,7 @@ BranchPickerPrimitiveNumber.displayName = "BranchPickerPrimitive.Number";
|
|
1011
1071
|
|
1012
1072
|
// src/primitives/branchPicker/BranchPickerRoot.tsx
|
1013
1073
|
import { Primitive as Primitive5 } from "@radix-ui/react-primitive";
|
1014
|
-
import { forwardRef as
|
1074
|
+
import { forwardRef as forwardRef10 } from "react";
|
1015
1075
|
|
1016
1076
|
// src/primitives/message/index.ts
|
1017
1077
|
var message_exports = {};
|
@@ -1053,9 +1113,9 @@ var useIsHoveringRef = () => {
|
|
1053
1113
|
);
|
1054
1114
|
return useManagedRef(callbackRef);
|
1055
1115
|
};
|
1056
|
-
var MessagePrimitiveRoot = forwardRef6(({ onMouseEnter, onMouseLeave, ...rest },
|
1116
|
+
var MessagePrimitiveRoot = forwardRef6(({ onMouseEnter, onMouseLeave, ...rest }, forwardRef29) => {
|
1057
1117
|
const isHoveringRef = useIsHoveringRef();
|
1058
|
-
const ref = useComposedRefs(
|
1118
|
+
const ref = useComposedRefs(forwardRef29, isHoveringRef);
|
1059
1119
|
return /* @__PURE__ */ jsx12(Primitive3.div, { ...rest, ref });
|
1060
1120
|
});
|
1061
1121
|
MessagePrimitiveRoot.displayName = "MessagePrimitive.Root";
|
@@ -1144,27 +1204,170 @@ var ContentPartProvider = ({
|
|
1144
1204
|
|
1145
1205
|
// src/primitives/contentPart/ContentPartText.tsx
|
1146
1206
|
import {
|
1147
|
-
forwardRef as
|
1207
|
+
forwardRef as forwardRef8
|
1208
|
+
} from "react";
|
1209
|
+
|
1210
|
+
// src/utils/smooth/useSmooth.tsx
|
1211
|
+
import { useEffect as useEffect7, useMemo as useMemo3, useRef as useRef3, useState as useState6 } from "react";
|
1212
|
+
|
1213
|
+
// src/utils/smooth/SmoothContext.tsx
|
1214
|
+
import {
|
1215
|
+
createContext as createContext5,
|
1216
|
+
forwardRef as forwardRef7,
|
1217
|
+
useContext as useContext5,
|
1218
|
+
useState as useState5
|
1148
1219
|
} from "react";
|
1220
|
+
import { create as create11 } from "zustand";
|
1149
1221
|
import { jsx as jsx14 } from "react/jsx-runtime";
|
1150
|
-
var
|
1222
|
+
var SmoothContext = createContext5(null);
|
1223
|
+
var makeSmoothContext = (initialState) => {
|
1224
|
+
const useSmoothStatus2 = create11(() => initialState);
|
1225
|
+
return { useSmoothStatus: useSmoothStatus2 };
|
1226
|
+
};
|
1227
|
+
var SmoothContextProvider = ({ children }) => {
|
1228
|
+
const outer = useSmoothContext({ optional: true });
|
1229
|
+
const { useContentPart } = useContentPartContext();
|
1230
|
+
const [context] = useState5(
|
1231
|
+
() => makeSmoothContext(useContentPart.getState().status)
|
1232
|
+
);
|
1233
|
+
if (outer) return children;
|
1234
|
+
return /* @__PURE__ */ jsx14(SmoothContext.Provider, { value: context, children });
|
1235
|
+
};
|
1236
|
+
var withSmoothContextProvider = (Component) => {
|
1237
|
+
const Wrapped = forwardRef7((props, ref) => {
|
1238
|
+
return /* @__PURE__ */ jsx14(SmoothContextProvider, { children: /* @__PURE__ */ jsx14(Component, { ...props, ref }) });
|
1239
|
+
});
|
1240
|
+
Wrapped.displayName = Component.displayName;
|
1241
|
+
return Wrapped;
|
1242
|
+
};
|
1243
|
+
function useSmoothContext(options) {
|
1244
|
+
const context = useContext5(SmoothContext);
|
1245
|
+
if (!options?.optional && !context)
|
1246
|
+
throw new Error(
|
1247
|
+
"This component must be used within a SmoothContextProvider."
|
1248
|
+
);
|
1249
|
+
return context;
|
1250
|
+
}
|
1251
|
+
var useSmoothStatus = () => {
|
1252
|
+
const { useSmoothStatus: useSmoothStatus2 } = useSmoothContext();
|
1253
|
+
return useSmoothStatus2();
|
1254
|
+
};
|
1255
|
+
|
1256
|
+
// src/utils/smooth/useSmooth.tsx
|
1257
|
+
import { useCallbackRef as useCallbackRef2 } from "@radix-ui/react-use-callback-ref";
|
1258
|
+
var TextStreamAnimator = class {
|
1259
|
+
constructor(currentText, setText) {
|
1260
|
+
this.currentText = currentText;
|
1261
|
+
this.setText = setText;
|
1262
|
+
}
|
1263
|
+
animationFrameId = null;
|
1264
|
+
lastUpdateTime = Date.now();
|
1265
|
+
targetText = "";
|
1266
|
+
start() {
|
1267
|
+
if (this.animationFrameId !== null) return;
|
1268
|
+
this.lastUpdateTime = Date.now();
|
1269
|
+
this.animate();
|
1270
|
+
}
|
1271
|
+
stop() {
|
1272
|
+
if (this.animationFrameId !== null) {
|
1273
|
+
cancelAnimationFrame(this.animationFrameId);
|
1274
|
+
this.animationFrameId = null;
|
1275
|
+
}
|
1276
|
+
}
|
1277
|
+
animate = () => {
|
1278
|
+
const currentTime = Date.now();
|
1279
|
+
const deltaTime = currentTime - this.lastUpdateTime;
|
1280
|
+
let timeToConsume = deltaTime;
|
1281
|
+
const remainingChars = this.targetText.length - this.currentText.length;
|
1282
|
+
const baseTimePerChar = Math.min(5, 250 / remainingChars);
|
1283
|
+
let charsToAdd = 0;
|
1284
|
+
while (timeToConsume >= baseTimePerChar && charsToAdd < remainingChars) {
|
1285
|
+
charsToAdd++;
|
1286
|
+
timeToConsume -= baseTimePerChar;
|
1287
|
+
}
|
1288
|
+
if (charsToAdd !== remainingChars) {
|
1289
|
+
this.animationFrameId = requestAnimationFrame(this.animate);
|
1290
|
+
} else {
|
1291
|
+
this.animationFrameId = null;
|
1292
|
+
}
|
1293
|
+
if (charsToAdd === 0) return;
|
1294
|
+
this.currentText = this.targetText.slice(
|
1295
|
+
0,
|
1296
|
+
this.currentText.length + charsToAdd
|
1297
|
+
);
|
1298
|
+
this.lastUpdateTime = currentTime - timeToConsume;
|
1299
|
+
this.setText(this.currentText);
|
1300
|
+
};
|
1301
|
+
};
|
1302
|
+
var SMOOTH_STATUS = Object.freeze({
|
1303
|
+
type: "running"
|
1304
|
+
});
|
1305
|
+
var useSmooth = (state, smooth = false) => {
|
1306
|
+
const { useSmoothStatus: useSmoothStatus2 } = useSmoothContext({ optional: true }) ?? {};
|
1307
|
+
const {
|
1308
|
+
part: { text }
|
1309
|
+
} = state;
|
1310
|
+
const { useMessage } = useMessageContext();
|
1311
|
+
const id = useMessage((m) => m.message.id);
|
1312
|
+
const idRef = useRef3(id);
|
1313
|
+
const [displayedText, setDisplayedText] = useState6(text);
|
1314
|
+
const setText = useCallbackRef2((text2) => {
|
1315
|
+
setDisplayedText(text2);
|
1316
|
+
useSmoothStatus2?.setState(text2 !== state.part.text ? SMOOTH_STATUS : state.status);
|
1317
|
+
});
|
1318
|
+
const [animatorRef] = useState6(
|
1319
|
+
new TextStreamAnimator(text, setText)
|
1320
|
+
);
|
1321
|
+
useEffect7(() => {
|
1322
|
+
if (!smooth) {
|
1323
|
+
animatorRef.stop();
|
1324
|
+
return;
|
1325
|
+
}
|
1326
|
+
if (idRef.current !== id || !text.startsWith(animatorRef.targetText)) {
|
1327
|
+
idRef.current = id;
|
1328
|
+
setText(text);
|
1329
|
+
animatorRef.currentText = text;
|
1330
|
+
animatorRef.targetText = text;
|
1331
|
+
animatorRef.stop();
|
1332
|
+
return;
|
1333
|
+
}
|
1334
|
+
animatorRef.targetText = text;
|
1335
|
+
animatorRef.start();
|
1336
|
+
}, [setText, animatorRef, id, smooth, text]);
|
1337
|
+
useEffect7(() => {
|
1338
|
+
return () => {
|
1339
|
+
animatorRef.stop();
|
1340
|
+
};
|
1341
|
+
}, [animatorRef]);
|
1342
|
+
return useMemo3(
|
1343
|
+
() => smooth ? {
|
1344
|
+
part: { type: "text", text: displayedText },
|
1345
|
+
status: text === displayedText ? state.status : SMOOTH_STATUS
|
1346
|
+
} : state,
|
1347
|
+
[smooth, displayedText, state, text]
|
1348
|
+
);
|
1349
|
+
};
|
1350
|
+
|
1351
|
+
// src/primitives/contentPart/ContentPartText.tsx
|
1352
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
1353
|
+
var ContentPartPrimitiveText = forwardRef8(({ smooth = true, component: Component = "span", ...rest }, forwardedRef) => {
|
1151
1354
|
const {
|
1152
1355
|
part: { text },
|
1153
1356
|
status
|
1154
1357
|
} = useSmooth(useContentPartText(), smooth);
|
1155
|
-
return /* @__PURE__ */
|
1358
|
+
return /* @__PURE__ */ jsx15(Component, { "data-status": status.type, ...rest, ref: forwardedRef, children: text });
|
1156
1359
|
});
|
1157
1360
|
ContentPartPrimitiveText.displayName = "ContentPartPrimitive.Text";
|
1158
1361
|
|
1159
1362
|
// src/primitives/contentPart/ContentPartImage.tsx
|
1160
1363
|
import { Primitive as Primitive4 } from "@radix-ui/react-primitive";
|
1161
|
-
import { forwardRef as
|
1162
|
-
import { jsx as
|
1163
|
-
var ContentPartPrimitiveImage =
|
1364
|
+
import { forwardRef as forwardRef9 } from "react";
|
1365
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
1366
|
+
var ContentPartPrimitiveImage = forwardRef9((props, forwardedRef) => {
|
1164
1367
|
const {
|
1165
1368
|
part: { image }
|
1166
1369
|
} = useContentPartImage();
|
1167
|
-
return /* @__PURE__ */
|
1370
|
+
return /* @__PURE__ */ jsx16(Primitive4.img, { src: image, ...props, ref: forwardedRef });
|
1168
1371
|
});
|
1169
1372
|
ContentPartPrimitiveImage.displayName = "ContentPartPrimitive.Image";
|
1170
1373
|
|
@@ -1186,20 +1389,20 @@ var ContentPartPrimitiveInProgress = ({ children }) => {
|
|
1186
1389
|
ContentPartPrimitiveInProgress.displayName = "ContentPartPrimitive.InProgress";
|
1187
1390
|
|
1188
1391
|
// src/primitives/message/MessageContent.tsx
|
1189
|
-
import { jsx as
|
1392
|
+
import { jsx as jsx17, jsxs as jsxs2 } from "react/jsx-runtime";
|
1190
1393
|
var defaultComponents = {
|
1191
1394
|
Text: () => /* @__PURE__ */ jsxs2("p", { style: { whiteSpace: "pre-line" }, children: [
|
1192
|
-
/* @__PURE__ */
|
1193
|
-
/* @__PURE__ */
|
1395
|
+
/* @__PURE__ */ jsx17(ContentPartPrimitiveText, {}),
|
1396
|
+
/* @__PURE__ */ jsx17(ContentPartPrimitiveInProgress, { children: /* @__PURE__ */ jsx17("span", { style: { fontFamily: "revert" }, children: " \u25CF" }) })
|
1194
1397
|
] }),
|
1195
|
-
Image: () => /* @__PURE__ */
|
1196
|
-
UI: () => /* @__PURE__ */
|
1398
|
+
Image: () => /* @__PURE__ */ jsx17(ContentPartPrimitiveImage, {}),
|
1399
|
+
UI: () => /* @__PURE__ */ jsx17(ContentPartPrimitiveDisplay, {}),
|
1197
1400
|
tools: {
|
1198
1401
|
Fallback: (props) => {
|
1199
1402
|
const { useToolUIs } = useAssistantContext();
|
1200
1403
|
const Render = useToolUIs((s) => s.getToolUI(props.part.toolName));
|
1201
1404
|
if (!Render) return null;
|
1202
|
-
return /* @__PURE__ */
|
1405
|
+
return /* @__PURE__ */ jsx17(Render, { ...props });
|
1203
1406
|
}
|
1204
1407
|
}
|
1205
1408
|
};
|
@@ -1222,16 +1425,16 @@ var MessageContentPartComponent = ({
|
|
1222
1425
|
case "text":
|
1223
1426
|
if (status.type === "requires-action")
|
1224
1427
|
throw new Error("Encountered unexpected requires-action status");
|
1225
|
-
if (part === EMPTY_CONTENT) return /* @__PURE__ */
|
1226
|
-
return /* @__PURE__ */
|
1428
|
+
if (part === EMPTY_CONTENT) return /* @__PURE__ */ jsx17(Empty, { part, status });
|
1429
|
+
return /* @__PURE__ */ jsx17(Text2, { part, status });
|
1227
1430
|
case "image":
|
1228
1431
|
if (status.type === "requires-action")
|
1229
1432
|
throw new Error("Encountered unexpected requires-action status");
|
1230
|
-
return /* @__PURE__ */
|
1433
|
+
return /* @__PURE__ */ jsx17(Image2, { part, status });
|
1231
1434
|
case "ui":
|
1232
1435
|
if (status.type === "requires-action")
|
1233
1436
|
throw new Error("Encountered unexpected requires-action status");
|
1234
|
-
return /* @__PURE__ */
|
1437
|
+
return /* @__PURE__ */ jsx17(UI, { part, status });
|
1235
1438
|
case "tool-call": {
|
1236
1439
|
const Tool = by_name[part.toolName] || Fallback2;
|
1237
1440
|
const addResult = (result) => addToolResult({
|
@@ -1239,7 +1442,7 @@ var MessageContentPartComponent = ({
|
|
1239
1442
|
toolCallId: part.toolCallId,
|
1240
1443
|
result
|
1241
1444
|
});
|
1242
|
-
return /* @__PURE__ */
|
1445
|
+
return /* @__PURE__ */ jsx17(Tool, { part, status, addResult });
|
1243
1446
|
}
|
1244
1447
|
default:
|
1245
1448
|
const unhandledType = type;
|
@@ -1250,7 +1453,7 @@ var MessageContentPartImpl = ({
|
|
1250
1453
|
partIndex,
|
1251
1454
|
components
|
1252
1455
|
}) => {
|
1253
|
-
return /* @__PURE__ */
|
1456
|
+
return /* @__PURE__ */ jsx17(ContentPartProvider, { partIndex, children: /* @__PURE__ */ jsx17(MessageContentPartComponent, { components }) });
|
1254
1457
|
};
|
1255
1458
|
var MessageContentPart = memo2(
|
1256
1459
|
MessageContentPartImpl,
|
@@ -1263,7 +1466,7 @@ var MessagePrimitiveContent = ({
|
|
1263
1466
|
const contentLength = useMessage((s) => s.message.content.length) || 1;
|
1264
1467
|
return new Array(contentLength).fill(null).map((_, idx) => {
|
1265
1468
|
const partIndex = idx;
|
1266
|
-
return /* @__PURE__ */
|
1469
|
+
return /* @__PURE__ */ jsx17(
|
1267
1470
|
MessageContentPart,
|
1268
1471
|
{
|
1269
1472
|
partIndex,
|
@@ -1282,9 +1485,9 @@ var MessagePrimitiveInProgress = () => {
|
|
1282
1485
|
MessagePrimitiveInProgress.displayName = "MessagePrimitive.InProgress";
|
1283
1486
|
|
1284
1487
|
// src/primitives/branchPicker/BranchPickerRoot.tsx
|
1285
|
-
import { jsx as
|
1286
|
-
var BranchPickerPrimitiveRoot =
|
1287
|
-
return /* @__PURE__ */
|
1488
|
+
import { jsx as jsx18 } from "react/jsx-runtime";
|
1489
|
+
var BranchPickerPrimitiveRoot = forwardRef10(({ hideWhenSingleBranch, ...rest }, ref) => {
|
1490
|
+
return /* @__PURE__ */ jsx18(MessagePrimitiveIf, { hasBranches: hideWhenSingleBranch ? true : void 0, children: /* @__PURE__ */ jsx18(Primitive5.div, { ...rest, ref }) });
|
1288
1491
|
});
|
1289
1492
|
BranchPickerPrimitiveRoot.displayName = "BranchPickerPrimitive.Root";
|
1290
1493
|
|
@@ -1302,17 +1505,17 @@ __export(composer_exports, {
|
|
1302
1505
|
import { composeEventHandlers as composeEventHandlers4 } from "@radix-ui/primitive";
|
1303
1506
|
import { Primitive as Primitive6 } from "@radix-ui/react-primitive";
|
1304
1507
|
import {
|
1305
|
-
forwardRef as
|
1508
|
+
forwardRef as forwardRef11
|
1306
1509
|
} from "react";
|
1307
|
-
import { jsx as
|
1308
|
-
var ComposerPrimitiveRoot =
|
1510
|
+
import { jsx as jsx19 } from "react/jsx-runtime";
|
1511
|
+
var ComposerPrimitiveRoot = forwardRef11(({ onSubmit, ...rest }, forwardedRef) => {
|
1309
1512
|
const send = useComposerSend();
|
1310
1513
|
const handleSubmit = (e) => {
|
1311
1514
|
e.preventDefault();
|
1312
1515
|
if (!send) return;
|
1313
1516
|
send();
|
1314
1517
|
};
|
1315
|
-
return /* @__PURE__ */
|
1518
|
+
return /* @__PURE__ */ jsx19(
|
1316
1519
|
Primitive6.form,
|
1317
1520
|
{
|
1318
1521
|
...rest,
|
@@ -1328,15 +1531,15 @@ import { composeEventHandlers as composeEventHandlers5 } from "@radix-ui/primiti
|
|
1328
1531
|
import { useComposedRefs as useComposedRefs2 } from "@radix-ui/react-compose-refs";
|
1329
1532
|
import { Slot } from "@radix-ui/react-slot";
|
1330
1533
|
import {
|
1331
|
-
forwardRef as
|
1534
|
+
forwardRef as forwardRef12,
|
1332
1535
|
useCallback as useCallback15,
|
1333
|
-
useEffect as
|
1334
|
-
useRef as
|
1536
|
+
useEffect as useEffect8,
|
1537
|
+
useRef as useRef4
|
1335
1538
|
} from "react";
|
1336
1539
|
import TextareaAutosize from "react-textarea-autosize";
|
1337
1540
|
import { useEscapeKeydown } from "@radix-ui/react-use-escape-keydown";
|
1338
|
-
import { jsx as
|
1339
|
-
var ComposerPrimitiveInput =
|
1541
|
+
import { jsx as jsx20 } from "react/jsx-runtime";
|
1542
|
+
var ComposerPrimitiveInput = forwardRef12(
|
1340
1543
|
({
|
1341
1544
|
autoFocus = false,
|
1342
1545
|
asChild,
|
@@ -1353,7 +1556,7 @@ var ComposerPrimitiveInput = forwardRef11(
|
|
1353
1556
|
});
|
1354
1557
|
const Component = asChild ? Slot : TextareaAutosize;
|
1355
1558
|
const isDisabled = useThread((t) => t.isDisabled) ?? disabledProp ?? false;
|
1356
|
-
const textareaRef =
|
1559
|
+
const textareaRef = useRef4(null);
|
1357
1560
|
const ref = useComposedRefs2(forwardedRef, textareaRef);
|
1358
1561
|
useEscapeKeydown((e) => {
|
1359
1562
|
const composer = useComposer.getState();
|
@@ -1382,13 +1585,13 @@ var ComposerPrimitiveInput = forwardRef11(
|
|
1382
1585
|
textareaRef.current.value.length
|
1383
1586
|
);
|
1384
1587
|
}, [autoFocusEnabled]);
|
1385
|
-
|
1588
|
+
useEffect8(() => focus(), [focus]);
|
1386
1589
|
useOnComposerFocus(() => {
|
1387
1590
|
if (type === "new") {
|
1388
1591
|
focus();
|
1389
1592
|
}
|
1390
1593
|
});
|
1391
|
-
return /* @__PURE__ */
|
1594
|
+
return /* @__PURE__ */ jsx20(
|
1392
1595
|
Component,
|
1393
1596
|
{
|
1394
1597
|
name: "input",
|
@@ -1409,13 +1612,13 @@ var ComposerPrimitiveInput = forwardRef11(
|
|
1409
1612
|
ComposerPrimitiveInput.displayName = "ComposerPrimitive.Input";
|
1410
1613
|
|
1411
1614
|
// src/primitives/composer/ComposerSend.tsx
|
1412
|
-
import { forwardRef as
|
1615
|
+
import { forwardRef as forwardRef13 } from "react";
|
1413
1616
|
import { Primitive as Primitive7 } from "@radix-ui/react-primitive";
|
1414
|
-
import { jsx as
|
1415
|
-
var ComposerPrimitiveSend =
|
1617
|
+
import { jsx as jsx21 } from "react/jsx-runtime";
|
1618
|
+
var ComposerPrimitiveSend = forwardRef13(({ disabled, ...rest }, ref) => {
|
1416
1619
|
const { useComposer } = useComposerContext();
|
1417
1620
|
const hasValue = useComposer((c) => c.isEditing && c.value.length > 0);
|
1418
|
-
return /* @__PURE__ */
|
1621
|
+
return /* @__PURE__ */ jsx21(
|
1419
1622
|
Primitive7.button,
|
1420
1623
|
{
|
1421
1624
|
type: "submit",
|
@@ -1466,10 +1669,10 @@ __export(thread_exports, {
|
|
1466
1669
|
|
1467
1670
|
// src/primitives/thread/ThreadRoot.tsx
|
1468
1671
|
import { Primitive as Primitive8 } from "@radix-ui/react-primitive";
|
1469
|
-
import { forwardRef as
|
1470
|
-
import { jsx as
|
1471
|
-
var ThreadPrimitiveRoot =
|
1472
|
-
return /* @__PURE__ */
|
1672
|
+
import { forwardRef as forwardRef14 } from "react";
|
1673
|
+
import { jsx as jsx22 } from "react/jsx-runtime";
|
1674
|
+
var ThreadPrimitiveRoot = forwardRef14((props, ref) => {
|
1675
|
+
return /* @__PURE__ */ jsx22(Primitive8.div, { ...props, ref });
|
1473
1676
|
});
|
1474
1677
|
ThreadPrimitiveRoot.displayName = "ThreadPrimitive.Root";
|
1475
1678
|
|
@@ -1495,17 +1698,17 @@ ThreadPrimitiveIf.displayName = "ThreadPrimitive.If";
|
|
1495
1698
|
// src/primitives/thread/ThreadViewport.tsx
|
1496
1699
|
import { useComposedRefs as useComposedRefs4 } from "@radix-ui/react-compose-refs";
|
1497
1700
|
import { Primitive as Primitive9 } from "@radix-ui/react-primitive";
|
1498
|
-
import { forwardRef as
|
1701
|
+
import { forwardRef as forwardRef15 } from "react";
|
1499
1702
|
|
1500
1703
|
// src/primitive-hooks/thread/useThreadViewportAutoScroll.tsx
|
1501
1704
|
import { useComposedRefs as useComposedRefs3 } from "@radix-ui/react-compose-refs";
|
1502
|
-
import { useRef as
|
1705
|
+
import { useRef as useRef5 } from "react";
|
1503
1706
|
|
1504
1707
|
// src/utils/hooks/useOnResizeContent.tsx
|
1505
|
-
import { useCallbackRef as
|
1708
|
+
import { useCallbackRef as useCallbackRef3 } from "@radix-ui/react-use-callback-ref";
|
1506
1709
|
import { useCallback as useCallback16 } from "react";
|
1507
1710
|
var useOnResizeContent = (callback) => {
|
1508
|
-
const callbackRef =
|
1711
|
+
const callbackRef = useCallbackRef3(callback);
|
1509
1712
|
const refCallback = useCallback16(
|
1510
1713
|
(el) => {
|
1511
1714
|
const resizeObserver = new ResizeObserver(() => {
|
@@ -1542,12 +1745,12 @@ var useOnResizeContent = (callback) => {
|
|
1542
1745
|
};
|
1543
1746
|
|
1544
1747
|
// src/utils/hooks/useOnScrollToBottom.tsx
|
1545
|
-
import { useCallbackRef as
|
1546
|
-
import { useEffect as
|
1748
|
+
import { useCallbackRef as useCallbackRef4 } from "@radix-ui/react-use-callback-ref";
|
1749
|
+
import { useEffect as useEffect9 } from "react";
|
1547
1750
|
var useOnScrollToBottom = (callback) => {
|
1548
|
-
const callbackRef =
|
1751
|
+
const callbackRef = useCallbackRef4(callback);
|
1549
1752
|
const { useViewport } = useThreadContext();
|
1550
|
-
|
1753
|
+
useEffect9(() => {
|
1551
1754
|
return useViewport.getState().onScrollToBottom(() => {
|
1552
1755
|
callbackRef();
|
1553
1756
|
});
|
@@ -1558,10 +1761,10 @@ var useOnScrollToBottom = (callback) => {
|
|
1558
1761
|
var useThreadViewportAutoScroll = ({
|
1559
1762
|
autoScroll = true
|
1560
1763
|
}) => {
|
1561
|
-
const divRef =
|
1764
|
+
const divRef = useRef5(null);
|
1562
1765
|
const { useViewport } = useThreadContext();
|
1563
|
-
const lastScrollTop =
|
1564
|
-
const isScrollingToBottomRef =
|
1766
|
+
const lastScrollTop = useRef5(0);
|
1767
|
+
const isScrollingToBottomRef = useRef5(false);
|
1565
1768
|
const scrollToBottom = (behavior) => {
|
1566
1769
|
const div = divRef.current;
|
1567
1770
|
if (!div || !autoScroll) return;
|
@@ -1606,13 +1809,13 @@ var useThreadViewportAutoScroll = ({
|
|
1606
1809
|
};
|
1607
1810
|
|
1608
1811
|
// src/primitives/thread/ThreadViewport.tsx
|
1609
|
-
import { jsx as
|
1610
|
-
var ThreadPrimitiveViewport =
|
1812
|
+
import { jsx as jsx23 } from "react/jsx-runtime";
|
1813
|
+
var ThreadPrimitiveViewport = forwardRef15(({ autoScroll, onScroll, children, ...rest }, forwardedRef) => {
|
1611
1814
|
const autoScrollRef = useThreadViewportAutoScroll({
|
1612
1815
|
autoScroll
|
1613
1816
|
});
|
1614
1817
|
const ref = useComposedRefs4(forwardedRef, autoScrollRef);
|
1615
|
-
return /* @__PURE__ */
|
1818
|
+
return /* @__PURE__ */ jsx23(Primitive9.div, { ...rest, ref, children });
|
1616
1819
|
});
|
1617
1820
|
ThreadPrimitiveViewport.displayName = "ThreadPrimitive.Viewport";
|
1618
1821
|
|
@@ -1620,15 +1823,15 @@ ThreadPrimitiveViewport.displayName = "ThreadPrimitive.Viewport";
|
|
1620
1823
|
import { memo as memo3 } from "react";
|
1621
1824
|
|
1622
1825
|
// src/context/providers/MessageProvider.tsx
|
1623
|
-
import { useEffect as
|
1624
|
-
import { create as
|
1826
|
+
import { useEffect as useEffect10, useState as useState7 } from "react";
|
1827
|
+
import { create as create14 } from "zustand";
|
1625
1828
|
|
1626
1829
|
// src/context/stores/EditComposer.ts
|
1627
|
-
import { create as
|
1830
|
+
import { create as create12 } from "zustand";
|
1628
1831
|
var makeEditComposerStore = ({
|
1629
1832
|
onEdit,
|
1630
1833
|
onSend
|
1631
|
-
}) =>
|
1834
|
+
}) => create12()((set, get, store) => ({
|
1632
1835
|
...makeBaseComposer(set, get, store),
|
1633
1836
|
canCancel: false,
|
1634
1837
|
isEditing: false,
|
@@ -1647,8 +1850,8 @@ var makeEditComposerStore = ({
|
|
1647
1850
|
}));
|
1648
1851
|
|
1649
1852
|
// src/context/stores/MessageUtils.ts
|
1650
|
-
import { create as
|
1651
|
-
var makeMessageUtilsStore = () =>
|
1853
|
+
import { create as create13 } from "zustand";
|
1854
|
+
var makeMessageUtilsStore = () => create13((set) => ({
|
1652
1855
|
isCopied: false,
|
1653
1856
|
setIsCopied: (value) => {
|
1654
1857
|
set({ isCopied: value });
|
@@ -1660,7 +1863,7 @@ var makeMessageUtilsStore = () => create12((set) => ({
|
|
1660
1863
|
}));
|
1661
1864
|
|
1662
1865
|
// src/context/providers/MessageProvider.tsx
|
1663
|
-
import { jsx as
|
1866
|
+
import { jsx as jsx24 } from "react/jsx-runtime";
|
1664
1867
|
var getIsLast = (messages, message) => {
|
1665
1868
|
return messages[messages.length - 1]?.id === message.id;
|
1666
1869
|
};
|
@@ -1682,8 +1885,8 @@ var getMessageState = (messages, getBranches, useMessage, messageIndex) => {
|
|
1682
1885
|
};
|
1683
1886
|
var useMessageContext2 = (messageIndex) => {
|
1684
1887
|
const { useThreadMessages, useThreadActions } = useThreadContext();
|
1685
|
-
const [context] =
|
1686
|
-
const useMessage =
|
1888
|
+
const [context] = useState7(() => {
|
1889
|
+
const useMessage = create14(
|
1687
1890
|
() => getMessageState(
|
1688
1891
|
useThreadMessages.getState(),
|
1689
1892
|
useThreadActions.getState().getBranches,
|
@@ -1720,7 +1923,7 @@ var useMessageContext2 = (messageIndex) => {
|
|
1720
1923
|
});
|
1721
1924
|
return { useMessage, useMessageUtils, useEditComposer };
|
1722
1925
|
});
|
1723
|
-
|
1926
|
+
useEffect10(() => {
|
1724
1927
|
const syncMessage = (thread) => {
|
1725
1928
|
const newState = getMessageState(
|
1726
1929
|
thread,
|
@@ -1744,11 +1947,11 @@ var MessageProvider = ({
|
|
1744
1947
|
children
|
1745
1948
|
}) => {
|
1746
1949
|
const context = useMessageContext2(messageIndex);
|
1747
|
-
return /* @__PURE__ */
|
1950
|
+
return /* @__PURE__ */ jsx24(MessageContext.Provider, { value: context, children });
|
1748
1951
|
};
|
1749
1952
|
|
1750
1953
|
// src/primitives/thread/ThreadMessages.tsx
|
1751
|
-
import { jsx as
|
1954
|
+
import { jsx as jsx25, jsxs as jsxs3 } from "react/jsx-runtime";
|
1752
1955
|
var DEFAULT_SYSTEM_MESSAGE = () => null;
|
1753
1956
|
var getComponents = (components) => {
|
1754
1957
|
return {
|
@@ -1765,11 +1968,11 @@ var ThreadMessageImpl = ({
|
|
1765
1968
|
const { UserMessage: UserMessage2, EditComposer: EditComposer2, AssistantMessage: AssistantMessage2, SystemMessage: SystemMessage2 } = getComponents(components);
|
1766
1969
|
return /* @__PURE__ */ jsxs3(MessageProvider, { messageIndex, children: [
|
1767
1970
|
/* @__PURE__ */ jsxs3(MessagePrimitiveIf, { user: true, children: [
|
1768
|
-
/* @__PURE__ */
|
1769
|
-
/* @__PURE__ */
|
1971
|
+
/* @__PURE__ */ jsx25(ComposerPrimitiveIf, { editing: false, children: /* @__PURE__ */ jsx25(UserMessage2, {}) }),
|
1972
|
+
/* @__PURE__ */ jsx25(ComposerPrimitiveIf, { editing: true, children: /* @__PURE__ */ jsx25(EditComposer2, {}) })
|
1770
1973
|
] }),
|
1771
|
-
/* @__PURE__ */
|
1772
|
-
/* @__PURE__ */
|
1974
|
+
/* @__PURE__ */ jsx25(MessagePrimitiveIf, { assistant: true, children: /* @__PURE__ */ jsx25(AssistantMessage2, {}) }),
|
1975
|
+
/* @__PURE__ */ jsx25(MessagePrimitiveIf, { system: true, children: /* @__PURE__ */ jsx25(SystemMessage2, {}) })
|
1773
1976
|
] });
|
1774
1977
|
};
|
1775
1978
|
var ThreadMessage = memo3(
|
@@ -1784,7 +1987,7 @@ var ThreadPrimitiveMessagesImpl = ({
|
|
1784
1987
|
if (messagesLength === 0) return null;
|
1785
1988
|
return new Array(messagesLength).fill(null).map((_, idx) => {
|
1786
1989
|
const messageIndex = idx;
|
1787
|
-
return /* @__PURE__ */
|
1990
|
+
return /* @__PURE__ */ jsx25(
|
1788
1991
|
ThreadMessage,
|
1789
1992
|
{
|
1790
1993
|
messageIndex,
|
@@ -1814,7 +2017,359 @@ var ThreadPrimitiveSuggestion = createActionButton(
|
|
1814
2017
|
);
|
1815
2018
|
|
1816
2019
|
// src/runtimes/local/useLocalRuntime.tsx
|
1817
|
-
import { useInsertionEffect as useInsertionEffect3, useState as
|
2020
|
+
import { useInsertionEffect as useInsertionEffect3, useState as useState9 } from "react";
|
2021
|
+
|
2022
|
+
// src/runtimes/core/BaseAssistantRuntime.tsx
|
2023
|
+
var BaseAssistantRuntime = class {
|
2024
|
+
constructor(_thread) {
|
2025
|
+
this._thread = _thread;
|
2026
|
+
this._thread = _thread;
|
2027
|
+
}
|
2028
|
+
get thread() {
|
2029
|
+
return this._thread;
|
2030
|
+
}
|
2031
|
+
set thread(thread) {
|
2032
|
+
this._thread = thread;
|
2033
|
+
this.subscriptionHandler();
|
2034
|
+
}
|
2035
|
+
_subscriptions = /* @__PURE__ */ new Set();
|
2036
|
+
subscribe(callback) {
|
2037
|
+
this._subscriptions.add(callback);
|
2038
|
+
return () => this._subscriptions.delete(callback);
|
2039
|
+
}
|
2040
|
+
subscriptionHandler = () => {
|
2041
|
+
for (const callback of this._subscriptions) callback();
|
2042
|
+
};
|
2043
|
+
};
|
2044
|
+
|
2045
|
+
// src/internal.ts
|
2046
|
+
var internal_exports = {};
|
2047
|
+
__export(internal_exports, {
|
2048
|
+
BaseAssistantRuntime: () => BaseAssistantRuntime,
|
2049
|
+
MessageRepository: () => MessageRepository,
|
2050
|
+
ProxyConfigProvider: () => ProxyConfigProvider,
|
2051
|
+
TooltipIconButton: () => TooltipIconButton,
|
2052
|
+
generateId: () => generateId,
|
2053
|
+
useSmooth: () => useSmooth,
|
2054
|
+
useSmoothStatus: () => useSmoothStatus,
|
2055
|
+
withSmoothContextProvider: () => withSmoothContextProvider
|
2056
|
+
});
|
2057
|
+
|
2058
|
+
// src/utils/idUtils.tsx
|
2059
|
+
import { customAlphabet } from "nanoid/non-secure";
|
2060
|
+
var generateId = customAlphabet(
|
2061
|
+
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
2062
|
+
7
|
2063
|
+
);
|
2064
|
+
var optimisticPrefix = "__optimistic__";
|
2065
|
+
var generateOptimisticId = () => `${optimisticPrefix}${generateId()}`;
|
2066
|
+
|
2067
|
+
// src/runtimes/edge/converters/fromCoreMessage.ts
|
2068
|
+
var fromCoreMessages = (message) => {
|
2069
|
+
return message.map((message2) => fromCoreMessage(message2));
|
2070
|
+
};
|
2071
|
+
var fromCoreMessage = (message, {
|
2072
|
+
id = generateId(),
|
2073
|
+
status = { type: "complete", reason: "unknown" }
|
2074
|
+
} = {}) => {
|
2075
|
+
const commonProps = {
|
2076
|
+
id,
|
2077
|
+
createdAt: /* @__PURE__ */ new Date()
|
2078
|
+
};
|
2079
|
+
const role = message.role;
|
2080
|
+
switch (role) {
|
2081
|
+
case "assistant":
|
2082
|
+
return {
|
2083
|
+
...commonProps,
|
2084
|
+
role,
|
2085
|
+
content: message.content.map((part) => {
|
2086
|
+
if (part.type === "tool-call") {
|
2087
|
+
return {
|
2088
|
+
...part,
|
2089
|
+
argsText: JSON.stringify(part.args)
|
2090
|
+
};
|
2091
|
+
}
|
2092
|
+
return part;
|
2093
|
+
}),
|
2094
|
+
status
|
2095
|
+
};
|
2096
|
+
case "user":
|
2097
|
+
return {
|
2098
|
+
...commonProps,
|
2099
|
+
role,
|
2100
|
+
content: message.content
|
2101
|
+
};
|
2102
|
+
case "system":
|
2103
|
+
return {
|
2104
|
+
...commonProps,
|
2105
|
+
role,
|
2106
|
+
content: message.content
|
2107
|
+
};
|
2108
|
+
default: {
|
2109
|
+
const unsupportedRole = role;
|
2110
|
+
throw new Error(`Unknown message role: ${unsupportedRole}`);
|
2111
|
+
}
|
2112
|
+
}
|
2113
|
+
};
|
2114
|
+
|
2115
|
+
// src/runtimes/utils/MessageRepository.tsx
|
2116
|
+
var findHead = (message) => {
|
2117
|
+
if (message.next) return findHead(message.next);
|
2118
|
+
return message;
|
2119
|
+
};
|
2120
|
+
var MessageRepository = class {
|
2121
|
+
messages = /* @__PURE__ */ new Map();
|
2122
|
+
// message_id -> item
|
2123
|
+
head = null;
|
2124
|
+
root = {
|
2125
|
+
children: []
|
2126
|
+
};
|
2127
|
+
performOp(newParent, child, operation) {
|
2128
|
+
const parentOrRoot = child.prev ?? this.root;
|
2129
|
+
const newParentOrRoot = newParent ?? this.root;
|
2130
|
+
if (operation === "relink" && parentOrRoot === newParentOrRoot) return;
|
2131
|
+
if (operation !== "link") {
|
2132
|
+
parentOrRoot.children = parentOrRoot.children.filter(
|
2133
|
+
(m) => m !== child.current.id
|
2134
|
+
);
|
2135
|
+
if (child.prev?.next === child) {
|
2136
|
+
const fallbackId = child.prev.children.at(-1);
|
2137
|
+
const fallback = fallbackId ? this.messages.get(fallbackId) : null;
|
2138
|
+
if (fallback === void 0) {
|
2139
|
+
throw new Error(
|
2140
|
+
"MessageRepository(performOp/cut): Fallback sibling message not found. This is likely an internal bug in assistant-ui."
|
2141
|
+
);
|
2142
|
+
}
|
2143
|
+
child.prev.next = fallback;
|
2144
|
+
}
|
2145
|
+
}
|
2146
|
+
if (operation !== "cut") {
|
2147
|
+
newParentOrRoot.children = [
|
2148
|
+
...newParentOrRoot.children,
|
2149
|
+
child.current.id
|
2150
|
+
];
|
2151
|
+
if (newParent && (findHead(child) === this.head || newParent.next === null)) {
|
2152
|
+
newParent.next = child;
|
2153
|
+
}
|
2154
|
+
child.prev = newParent;
|
2155
|
+
}
|
2156
|
+
}
|
2157
|
+
getMessages() {
|
2158
|
+
const messages = new Array(this.head?.level ?? 0);
|
2159
|
+
for (let current = this.head; current; current = current.prev) {
|
2160
|
+
messages[current.level] = current.current;
|
2161
|
+
}
|
2162
|
+
return messages;
|
2163
|
+
}
|
2164
|
+
addOrUpdateMessage(parentId, message) {
|
2165
|
+
const existingItem = this.messages.get(message.id);
|
2166
|
+
const prev = parentId ? this.messages.get(parentId) : null;
|
2167
|
+
if (prev === void 0)
|
2168
|
+
throw new Error(
|
2169
|
+
"MessageRepository(addOrUpdateMessage): Parent message not found. This is likely an internal bug in assistant-ui."
|
2170
|
+
);
|
2171
|
+
if (existingItem) {
|
2172
|
+
existingItem.current = message;
|
2173
|
+
this.performOp(prev, existingItem, "relink");
|
2174
|
+
return;
|
2175
|
+
}
|
2176
|
+
const newItem = {
|
2177
|
+
prev,
|
2178
|
+
current: message,
|
2179
|
+
next: null,
|
2180
|
+
children: [],
|
2181
|
+
level: prev ? prev.level + 1 : 0
|
2182
|
+
};
|
2183
|
+
this.messages.set(message.id, newItem);
|
2184
|
+
this.performOp(prev, newItem, "link");
|
2185
|
+
if (this.head === prev) {
|
2186
|
+
this.head = newItem;
|
2187
|
+
}
|
2188
|
+
}
|
2189
|
+
getMessage(messageId) {
|
2190
|
+
const message = this.messages.get(messageId);
|
2191
|
+
if (!message)
|
2192
|
+
throw new Error(
|
2193
|
+
"MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui."
|
2194
|
+
);
|
2195
|
+
return {
|
2196
|
+
parentId: message.prev?.current.id ?? null,
|
2197
|
+
message: message.current
|
2198
|
+
};
|
2199
|
+
}
|
2200
|
+
appendOptimisticMessage(parentId, message) {
|
2201
|
+
let optimisticId;
|
2202
|
+
do {
|
2203
|
+
optimisticId = generateOptimisticId();
|
2204
|
+
} while (this.messages.has(optimisticId));
|
2205
|
+
this.addOrUpdateMessage(
|
2206
|
+
parentId,
|
2207
|
+
fromCoreMessage(message, {
|
2208
|
+
id: optimisticId,
|
2209
|
+
status: { type: "running" }
|
2210
|
+
})
|
2211
|
+
);
|
2212
|
+
return optimisticId;
|
2213
|
+
}
|
2214
|
+
deleteMessage(messageId, replacementId) {
|
2215
|
+
const message = this.messages.get(messageId);
|
2216
|
+
if (!message)
|
2217
|
+
throw new Error(
|
2218
|
+
"MessageRepository(deleteMessage): Optimistic message not found. This is likely an internal bug in assistant-ui."
|
2219
|
+
);
|
2220
|
+
const replacement = replacementId === void 0 ? message.prev : replacementId === null ? null : this.messages.get(replacementId);
|
2221
|
+
if (replacement === void 0)
|
2222
|
+
throw new Error(
|
2223
|
+
"MessageRepository(deleteMessage): Replacement not found. This is likely an internal bug in assistant-ui."
|
2224
|
+
);
|
2225
|
+
for (const child of message.children) {
|
2226
|
+
const childMessage = this.messages.get(child);
|
2227
|
+
if (!childMessage)
|
2228
|
+
throw new Error(
|
2229
|
+
"MessageRepository(deleteMessage): Child message not found. This is likely an internal bug in assistant-ui."
|
2230
|
+
);
|
2231
|
+
this.performOp(replacement, childMessage, "relink");
|
2232
|
+
}
|
2233
|
+
this.performOp(null, message, "cut");
|
2234
|
+
this.messages.delete(messageId);
|
2235
|
+
if (this.head === message) {
|
2236
|
+
this.head = replacement ? findHead(replacement) : null;
|
2237
|
+
}
|
2238
|
+
}
|
2239
|
+
getBranches(messageId) {
|
2240
|
+
const message = this.messages.get(messageId);
|
2241
|
+
if (!message)
|
2242
|
+
throw new Error(
|
2243
|
+
"MessageRepository(getBranches): Message not found. This is likely an internal bug in assistant-ui."
|
2244
|
+
);
|
2245
|
+
const { children } = message.prev ?? this.root;
|
2246
|
+
return children;
|
2247
|
+
}
|
2248
|
+
switchToBranch(messageId) {
|
2249
|
+
const message = this.messages.get(messageId);
|
2250
|
+
if (!message)
|
2251
|
+
throw new Error(
|
2252
|
+
"MessageRepository(switchToBranch): Branch not found. This is likely an internal bug in assistant-ui."
|
2253
|
+
);
|
2254
|
+
if (message.prev) {
|
2255
|
+
message.prev.next = message;
|
2256
|
+
}
|
2257
|
+
this.head = findHead(message);
|
2258
|
+
}
|
2259
|
+
resetHead(messageId) {
|
2260
|
+
if (messageId === null) {
|
2261
|
+
this.head = null;
|
2262
|
+
return;
|
2263
|
+
}
|
2264
|
+
const message = this.messages.get(messageId);
|
2265
|
+
if (!message)
|
2266
|
+
throw new Error(
|
2267
|
+
"MessageRepository(resetHead): Branch not found. This is likely an internal bug in assistant-ui."
|
2268
|
+
);
|
2269
|
+
this.head = message;
|
2270
|
+
for (let current = message; current; current = current.prev) {
|
2271
|
+
if (current.prev) {
|
2272
|
+
current.prev.next = current;
|
2273
|
+
}
|
2274
|
+
}
|
2275
|
+
}
|
2276
|
+
};
|
2277
|
+
|
2278
|
+
// src/ui/base/tooltip-icon-button.tsx
|
2279
|
+
import { forwardRef as forwardRef18 } from "react";
|
2280
|
+
|
2281
|
+
// src/ui/base/tooltip.tsx
|
2282
|
+
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
2283
|
+
|
2284
|
+
// src/ui/utils/withDefaults.tsx
|
2285
|
+
import {
|
2286
|
+
forwardRef as forwardRef16
|
2287
|
+
} from "react";
|
2288
|
+
import classNames from "classnames";
|
2289
|
+
import { jsx as jsx26 } from "react/jsx-runtime";
|
2290
|
+
var withDefaultProps = ({
|
2291
|
+
className,
|
2292
|
+
...defaultProps
|
2293
|
+
}) => ({ className: classNameProp, ...props }) => {
|
2294
|
+
return {
|
2295
|
+
className: classNames(className, classNameProp),
|
2296
|
+
...defaultProps,
|
2297
|
+
...props
|
2298
|
+
};
|
2299
|
+
};
|
2300
|
+
var withDefaults = (Component, defaultProps) => {
|
2301
|
+
const getProps = withDefaultProps(defaultProps);
|
2302
|
+
const WithDefaults = forwardRef16(
|
2303
|
+
(props, ref) => {
|
2304
|
+
const ComponentAsAny = Component;
|
2305
|
+
return /* @__PURE__ */ jsx26(ComponentAsAny, { ...getProps(props), ref });
|
2306
|
+
}
|
2307
|
+
);
|
2308
|
+
WithDefaults.displayName = "withDefaults(" + (typeof Component === "string" ? Component : Component.displayName) + ")";
|
2309
|
+
return WithDefaults;
|
2310
|
+
};
|
2311
|
+
|
2312
|
+
// src/ui/base/tooltip.tsx
|
2313
|
+
import { jsx as jsx27 } from "react/jsx-runtime";
|
2314
|
+
var Tooltip = (props) => {
|
2315
|
+
return /* @__PURE__ */ jsx27(TooltipPrimitive.Provider, { children: /* @__PURE__ */ jsx27(TooltipPrimitive.Root, { ...props }) });
|
2316
|
+
};
|
2317
|
+
Tooltip.displayName = "Tooltip";
|
2318
|
+
var TooltipTrigger = TooltipPrimitive.Trigger;
|
2319
|
+
var TooltipContent = withDefaults(TooltipPrimitive.Content, {
|
2320
|
+
sideOffset: 4,
|
2321
|
+
className: "aui-tooltip-content"
|
2322
|
+
});
|
2323
|
+
TooltipContent.displayName = "TooltipContent";
|
2324
|
+
|
2325
|
+
// src/ui/base/button.tsx
|
2326
|
+
import { cva } from "class-variance-authority";
|
2327
|
+
import { Primitive as Primitive10 } from "@radix-ui/react-primitive";
|
2328
|
+
import { forwardRef as forwardRef17 } from "react";
|
2329
|
+
import { jsx as jsx28 } from "react/jsx-runtime";
|
2330
|
+
var buttonVariants = cva("aui-button", {
|
2331
|
+
variants: {
|
2332
|
+
variant: {
|
2333
|
+
default: "aui-button-primary",
|
2334
|
+
outline: "aui-button-outline",
|
2335
|
+
ghost: "aui-button-ghost"
|
2336
|
+
},
|
2337
|
+
size: {
|
2338
|
+
default: "aui-button-medium",
|
2339
|
+
icon: "aui-button-icon"
|
2340
|
+
}
|
2341
|
+
},
|
2342
|
+
defaultVariants: {
|
2343
|
+
variant: "default",
|
2344
|
+
size: "default"
|
2345
|
+
}
|
2346
|
+
});
|
2347
|
+
var Button = forwardRef17(
|
2348
|
+
({ className, variant, size, ...props }, ref) => {
|
2349
|
+
return /* @__PURE__ */ jsx28(
|
2350
|
+
Primitive10.button,
|
2351
|
+
{
|
2352
|
+
className: buttonVariants({ variant, size, className }),
|
2353
|
+
...props,
|
2354
|
+
ref
|
2355
|
+
}
|
2356
|
+
);
|
2357
|
+
}
|
2358
|
+
);
|
2359
|
+
Button.displayName = "Button";
|
2360
|
+
|
2361
|
+
// src/ui/base/tooltip-icon-button.tsx
|
2362
|
+
import { jsx as jsx29, jsxs as jsxs4 } from "react/jsx-runtime";
|
2363
|
+
var TooltipIconButton = forwardRef18(({ children, tooltip, side = "bottom", ...rest }, ref) => {
|
2364
|
+
return /* @__PURE__ */ jsxs4(Tooltip, { children: [
|
2365
|
+
/* @__PURE__ */ jsx29(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxs4(Button, { variant: "ghost", size: "icon", ...rest, ref, children: [
|
2366
|
+
children,
|
2367
|
+
/* @__PURE__ */ jsx29("span", { className: "aui-sr-only", children: tooltip })
|
2368
|
+
] }) }),
|
2369
|
+
/* @__PURE__ */ jsx29(TooltipContent, { side, children: tooltip })
|
2370
|
+
] });
|
2371
|
+
});
|
2372
|
+
TooltipIconButton.displayName = "TooltipIconButton";
|
1818
2373
|
|
1819
2374
|
// src/runtimes/edge/converters/fromLanguageModelMessages.ts
|
1820
2375
|
var fromLanguageModelMessages = (lm, { mergeRoundtrips }) => {
|
@@ -1934,7 +2489,7 @@ var fromLanguageModelTools = (tools) => {
|
|
1934
2489
|
};
|
1935
2490
|
|
1936
2491
|
// src/runtimes/edge/useEdgeRuntime.ts
|
1937
|
-
import { useState as
|
2492
|
+
import { useState as useState8 } from "react";
|
1938
2493
|
|
1939
2494
|
// src/runtimes/edge/streams/assistantDecoderStream.ts
|
1940
2495
|
function assistantDecoderStream() {
|
@@ -2091,7 +2646,7 @@ var useEdgeRuntime = ({
|
|
2091
2646
|
initialMessages,
|
2092
2647
|
...options
|
2093
2648
|
}) => {
|
2094
|
-
const [adapter] =
|
2649
|
+
const [adapter] = useState8(() => new EdgeChatAdapter(options));
|
2095
2650
|
return useLocalRuntime(adapter, { initialMessages });
|
2096
2651
|
};
|
2097
2652
|
|
@@ -2305,7 +2860,7 @@ var LocalRuntime = class extends BaseAssistantRuntime {
|
|
2305
2860
|
|
2306
2861
|
// src/runtimes/local/useLocalRuntime.tsx
|
2307
2862
|
var useLocalRuntime = (adapter, options) => {
|
2308
|
-
const [runtime] =
|
2863
|
+
const [runtime] = useState9(() => new LocalRuntime(adapter, options));
|
2309
2864
|
useInsertionEffect3(() => {
|
2310
2865
|
runtime.adapter = adapter;
|
2311
2866
|
});
|
@@ -2313,7 +2868,7 @@ var useLocalRuntime = (adapter, options) => {
|
|
2313
2868
|
};
|
2314
2869
|
|
2315
2870
|
// src/runtimes/external-store/ExternalStoreThreadRuntime.tsx
|
2316
|
-
import { create as
|
2871
|
+
import { create as create15 } from "zustand";
|
2317
2872
|
|
2318
2873
|
// src/runtimes/external-store/getExternalStoreMessage.tsx
|
2319
2874
|
var symbolInnerMessage = Symbol("innerMessage");
|
@@ -2322,7 +2877,7 @@ var getExternalStoreMessage = (message) => {
|
|
2322
2877
|
};
|
2323
2878
|
|
2324
2879
|
// src/runtimes/external-store/useExternalStoreSync.tsx
|
2325
|
-
import { useEffect as
|
2880
|
+
import { useEffect as useEffect11, useInsertionEffect as useInsertionEffect4, useMemo as useMemo4, useRef as useRef6 } from "react";
|
2326
2881
|
|
2327
2882
|
// src/runtimes/external-store/ThreadMessageConverter.ts
|
2328
2883
|
var ThreadMessageConverter = class {
|
@@ -2416,11 +2971,11 @@ var fromThreadMessageLike = (like, fallbackId, fallbackStatus) => {
|
|
2416
2971
|
|
2417
2972
|
// src/runtimes/external-store/useExternalStoreSync.tsx
|
2418
2973
|
var useExternalStoreSync = (adapter, updateData) => {
|
2419
|
-
const adapterRef =
|
2974
|
+
const adapterRef = useRef6(adapter);
|
2420
2975
|
useInsertionEffect4(() => {
|
2421
2976
|
adapterRef.current = adapter;
|
2422
2977
|
});
|
2423
|
-
const [converter, convertCallback] =
|
2978
|
+
const [converter, convertCallback] = useMemo4(() => {
|
2424
2979
|
const converter2 = adapter.convertMessage ?? ((m) => m);
|
2425
2980
|
const convertCallback2 = (cache, m, idx) => {
|
2426
2981
|
const autoStatus = getAutoStatus(
|
@@ -2439,7 +2994,7 @@ var useExternalStoreSync = (adapter, updateData) => {
|
|
2439
2994
|
};
|
2440
2995
|
return [new ThreadMessageConverter(), convertCallback2];
|
2441
2996
|
}, [adapter.convertMessage]);
|
2442
|
-
|
2997
|
+
useEffect11(() => {
|
2443
2998
|
updateData(
|
2444
2999
|
adapter.isDisabled ?? false,
|
2445
3000
|
adapter.isRunning ?? false,
|
@@ -2467,7 +3022,7 @@ var ExternalStoreThreadRuntime = class {
|
|
2467
3022
|
store.isRunning ?? false,
|
2468
3023
|
store.messages
|
2469
3024
|
);
|
2470
|
-
this.useStore =
|
3025
|
+
this.useStore = create15(() => ({
|
2471
3026
|
store
|
2472
3027
|
}));
|
2473
3028
|
}
|
@@ -2608,13 +3163,13 @@ var ExternalStoreRuntime = class extends BaseAssistantRuntime {
|
|
2608
3163
|
};
|
2609
3164
|
|
2610
3165
|
// src/runtimes/external-store/useExternalStoreRuntime.tsx
|
2611
|
-
import { useEffect as
|
3166
|
+
import { useEffect as useEffect12, useInsertionEffect as useInsertionEffect5, useState as useState10 } from "react";
|
2612
3167
|
var useExternalStoreRuntime = (store) => {
|
2613
|
-
const [runtime] =
|
3168
|
+
const [runtime] = useState10(() => new ExternalStoreRuntime(store));
|
2614
3169
|
useInsertionEffect5(() => {
|
2615
3170
|
runtime.store = store;
|
2616
3171
|
});
|
2617
|
-
|
3172
|
+
useEffect12(() => {
|
2618
3173
|
runtime.onStoreUpdated();
|
2619
3174
|
});
|
2620
3175
|
return runtime;
|
@@ -2622,34 +3177,34 @@ var useExternalStoreRuntime = (store) => {
|
|
2622
3177
|
|
2623
3178
|
// src/ui/thread-config.tsx
|
2624
3179
|
import {
|
2625
|
-
createContext,
|
2626
|
-
useContext
|
3180
|
+
createContext as createContext6,
|
3181
|
+
useContext as useContext6
|
2627
3182
|
} from "react";
|
2628
|
-
import { Fragment as Fragment3, jsx as
|
2629
|
-
var ThreadConfigContext =
|
3183
|
+
import { Fragment as Fragment3, jsx as jsx30 } from "react/jsx-runtime";
|
3184
|
+
var ThreadConfigContext = createContext6({});
|
2630
3185
|
var useThreadConfig = () => {
|
2631
|
-
return
|
3186
|
+
return useContext6(ThreadConfigContext);
|
2632
3187
|
};
|
2633
3188
|
var ThreadConfigProvider = ({
|
2634
3189
|
children,
|
2635
3190
|
config
|
2636
3191
|
}) => {
|
2637
3192
|
const assistant = useAssistantContext({ optional: true });
|
2638
|
-
const configProvider = config && Object.keys(config ?? {}).length > 0 ? /* @__PURE__ */
|
3193
|
+
const configProvider = config && Object.keys(config ?? {}).length > 0 ? /* @__PURE__ */ jsx30(ThreadConfigContext.Provider, { value: config, children }) : /* @__PURE__ */ jsx30(Fragment3, { children });
|
2639
3194
|
if (!config?.runtime) return configProvider;
|
2640
3195
|
if (assistant) {
|
2641
3196
|
throw new Error(
|
2642
3197
|
"You provided a runtime to <Thread> while simulataneously using <AssistantRuntimeProvider>. This is not allowed."
|
2643
3198
|
);
|
2644
3199
|
}
|
2645
|
-
return /* @__PURE__ */
|
3200
|
+
return /* @__PURE__ */ jsx30(AssistantRuntimeProvider, { runtime: config.runtime, children: configProvider });
|
2646
3201
|
};
|
2647
3202
|
ThreadConfigProvider.displayName = "ThreadConfigProvider";
|
2648
3203
|
|
2649
3204
|
// src/ui/assistant-action-bar.tsx
|
2650
|
-
import { forwardRef as
|
3205
|
+
import { forwardRef as forwardRef19 } from "react";
|
2651
3206
|
import { CheckIcon, CopyIcon, RefreshCwIcon } from "lucide-react";
|
2652
|
-
import { Fragment as Fragment4, jsx as
|
3207
|
+
import { Fragment as Fragment4, jsx as jsx31, jsxs as jsxs5 } from "react/jsx-runtime";
|
2653
3208
|
var useAllowCopy = () => {
|
2654
3209
|
const { assistantMessage: { allowCopy = true } = {} } = useThreadConfig();
|
2655
3210
|
const { useThreadActions } = useThreadContext();
|
@@ -2666,15 +3221,15 @@ var AssistantActionBar = () => {
|
|
2666
3221
|
const allowCopy = useAllowCopy();
|
2667
3222
|
const allowReload = useAllowReload();
|
2668
3223
|
if (!allowCopy && !allowReload) return null;
|
2669
|
-
return /* @__PURE__ */
|
3224
|
+
return /* @__PURE__ */ jsxs5(
|
2670
3225
|
AssistantActionBarRoot,
|
2671
3226
|
{
|
2672
3227
|
hideWhenRunning: true,
|
2673
3228
|
autohide: "not-last",
|
2674
3229
|
autohideFloat: "single-branch",
|
2675
3230
|
children: [
|
2676
|
-
/* @__PURE__ */
|
2677
|
-
/* @__PURE__ */
|
3231
|
+
/* @__PURE__ */ jsx31(AssistantActionBarCopy, {}),
|
3232
|
+
/* @__PURE__ */ jsx31(AssistantActionBarReload, {})
|
2678
3233
|
]
|
2679
3234
|
}
|
2680
3235
|
);
|
@@ -2684,7 +3239,7 @@ var AssistantActionBarRoot = withDefaults(actionBar_exports.Root, {
|
|
2684
3239
|
className: "aui-assistant-action-bar-root"
|
2685
3240
|
});
|
2686
3241
|
AssistantActionBarRoot.displayName = "AssistantActionBarRoot";
|
2687
|
-
var AssistantActionBarCopy =
|
3242
|
+
var AssistantActionBarCopy = forwardRef19((props, ref) => {
|
2688
3243
|
const {
|
2689
3244
|
strings: {
|
2690
3245
|
assistantMessage: { reload: { tooltip = "Copy" } = {} } = {}
|
@@ -2692,13 +3247,13 @@ var AssistantActionBarCopy = forwardRef15((props, ref) => {
|
|
2692
3247
|
} = useThreadConfig();
|
2693
3248
|
const allowCopy = useAllowCopy();
|
2694
3249
|
if (!allowCopy) return null;
|
2695
|
-
return /* @__PURE__ */
|
2696
|
-
/* @__PURE__ */
|
2697
|
-
/* @__PURE__ */
|
3250
|
+
return /* @__PURE__ */ jsx31(actionBar_exports.Copy, { asChild: true, children: /* @__PURE__ */ jsx31(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsxs5(Fragment4, { children: [
|
3251
|
+
/* @__PURE__ */ jsx31(message_exports.If, { copied: true, children: /* @__PURE__ */ jsx31(CheckIcon, {}) }),
|
3252
|
+
/* @__PURE__ */ jsx31(message_exports.If, { copied: false, children: /* @__PURE__ */ jsx31(CopyIcon, {}) })
|
2698
3253
|
] }) }) });
|
2699
3254
|
});
|
2700
3255
|
AssistantActionBarCopy.displayName = "AssistantActionBarCopy";
|
2701
|
-
var AssistantActionBarReload =
|
3256
|
+
var AssistantActionBarReload = forwardRef19((props, ref) => {
|
2702
3257
|
const {
|
2703
3258
|
strings: {
|
2704
3259
|
assistantMessage: { reload: { tooltip = "Refresh" } = {} } = {}
|
@@ -2706,7 +3261,7 @@ var AssistantActionBarReload = forwardRef15((props, ref) => {
|
|
2706
3261
|
} = useThreadConfig();
|
2707
3262
|
const allowReload = useAllowReload();
|
2708
3263
|
if (!allowReload) return null;
|
2709
|
-
return /* @__PURE__ */
|
3264
|
+
return /* @__PURE__ */ jsx31(actionBar_exports.Reload, { asChild: true, children: /* @__PURE__ */ jsx31(TooltipIconButton, { tooltip, ...props, ref, children: /* @__PURE__ */ jsx31(RefreshCwIcon, {}) }) });
|
2710
3265
|
});
|
2711
3266
|
AssistantActionBarReload.displayName = "AssistantActionBarReload";
|
2712
3267
|
var exports = {
|
@@ -2720,12 +3275,12 @@ var assistant_action_bar_default = Object.assign(
|
|
2720
3275
|
);
|
2721
3276
|
|
2722
3277
|
// src/ui/assistant-message.tsx
|
2723
|
-
import { forwardRef as
|
3278
|
+
import { forwardRef as forwardRef21 } from "react";
|
2724
3279
|
|
2725
3280
|
// src/ui/branch-picker.tsx
|
2726
|
-
import { forwardRef as
|
3281
|
+
import { forwardRef as forwardRef20 } from "react";
|
2727
3282
|
import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react";
|
2728
|
-
import { jsx as
|
3283
|
+
import { jsx as jsx32, jsxs as jsxs6 } from "react/jsx-runtime";
|
2729
3284
|
var useAllowBranchPicker = () => {
|
2730
3285
|
const { branchPicker: { allowBranchPicker = true } = {} } = useThreadConfig();
|
2731
3286
|
const { useThreadActions } = useThreadContext();
|
@@ -2735,10 +3290,10 @@ var useAllowBranchPicker = () => {
|
|
2735
3290
|
var BranchPicker = () => {
|
2736
3291
|
const allowBranchPicker = useAllowBranchPicker();
|
2737
3292
|
if (!allowBranchPicker) return null;
|
2738
|
-
return /* @__PURE__ */
|
2739
|
-
/* @__PURE__ */
|
2740
|
-
/* @__PURE__ */
|
2741
|
-
/* @__PURE__ */
|
3293
|
+
return /* @__PURE__ */ jsxs6(BranchPickerRoot, { hideWhenSingleBranch: true, children: [
|
3294
|
+
/* @__PURE__ */ jsx32(BranchPickerPrevious2, {}),
|
3295
|
+
/* @__PURE__ */ jsx32(BranchPickerState, {}),
|
3296
|
+
/* @__PURE__ */ jsx32(BranchPickerNext, {})
|
2742
3297
|
] });
|
2743
3298
|
};
|
2744
3299
|
BranchPicker.displayName = "BranchPicker";
|
@@ -2746,31 +3301,31 @@ var BranchPickerRoot = withDefaults(branchPicker_exports.Root, {
|
|
2746
3301
|
className: "aui-branch-picker-root"
|
2747
3302
|
});
|
2748
3303
|
BranchPickerRoot.displayName = "BranchPickerRoot";
|
2749
|
-
var BranchPickerPrevious2 =
|
3304
|
+
var BranchPickerPrevious2 = forwardRef20((props, ref) => {
|
2750
3305
|
const {
|
2751
3306
|
strings: {
|
2752
3307
|
branchPicker: { previous: { tooltip = "Previous" } = {} } = {}
|
2753
3308
|
} = {}
|
2754
3309
|
} = useThreadConfig();
|
2755
|
-
return /* @__PURE__ */
|
3310
|
+
return /* @__PURE__ */ jsx32(branchPicker_exports.Previous, { asChild: true, children: /* @__PURE__ */ jsx32(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx32(ChevronLeftIcon, {}) }) });
|
2756
3311
|
});
|
2757
3312
|
BranchPickerPrevious2.displayName = "BranchPickerPrevious";
|
2758
3313
|
var BranchPickerStateWrapper = withDefaults("span", {
|
2759
3314
|
className: "aui-branch-picker-state"
|
2760
3315
|
});
|
2761
|
-
var BranchPickerState =
|
2762
|
-
return /* @__PURE__ */
|
2763
|
-
/* @__PURE__ */
|
3316
|
+
var BranchPickerState = forwardRef20((props, ref) => {
|
3317
|
+
return /* @__PURE__ */ jsxs6(BranchPickerStateWrapper, { ...props, ref, children: [
|
3318
|
+
/* @__PURE__ */ jsx32(branchPicker_exports.Number, {}),
|
2764
3319
|
" / ",
|
2765
|
-
/* @__PURE__ */
|
3320
|
+
/* @__PURE__ */ jsx32(branchPicker_exports.Count, {})
|
2766
3321
|
] });
|
2767
3322
|
});
|
2768
3323
|
BranchPickerState.displayName = "BranchPickerState";
|
2769
|
-
var BranchPickerNext =
|
3324
|
+
var BranchPickerNext = forwardRef20((props, ref) => {
|
2770
3325
|
const {
|
2771
3326
|
strings: { branchPicker: { next: { tooltip = "Next" } = {} } = {} } = {}
|
2772
3327
|
} = useThreadConfig();
|
2773
|
-
return /* @__PURE__ */
|
3328
|
+
return /* @__PURE__ */ jsx32(branchPicker_exports.Next, { asChild: true, children: /* @__PURE__ */ jsx32(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx32(ChevronRightIcon, {}) }) });
|
2774
3329
|
});
|
2775
3330
|
BranchPickerNext.displayName = "BranchPickerNext";
|
2776
3331
|
var exports2 = {
|
@@ -2782,12 +3337,12 @@ var branch_picker_default = Object.assign(BranchPicker, exports2);
|
|
2782
3337
|
|
2783
3338
|
// src/ui/base/avatar.tsx
|
2784
3339
|
import * as AvatarPrimitive from "@radix-ui/react-avatar";
|
2785
|
-
import { jsx as
|
3340
|
+
import { jsx as jsx33, jsxs as jsxs7 } from "react/jsx-runtime";
|
2786
3341
|
var Avatar = ({ src, alt, fallback }) => {
|
2787
3342
|
if (src == null && fallback == null) return null;
|
2788
|
-
return /* @__PURE__ */
|
2789
|
-
src != null && /* @__PURE__ */
|
2790
|
-
fallback != null && /* @__PURE__ */
|
3343
|
+
return /* @__PURE__ */ jsxs7(AvatarRoot, { children: [
|
3344
|
+
src != null && /* @__PURE__ */ jsx33(AvatarImage, { src, alt }),
|
3345
|
+
fallback != null && /* @__PURE__ */ jsx33(AvatarFallback, { children: fallback })
|
2791
3346
|
] });
|
2792
3347
|
};
|
2793
3348
|
Avatar.displayName = "Avatar";
|
@@ -2805,14 +3360,14 @@ var AvatarFallback = withDefaults(AvatarPrimitive.Fallback, {
|
|
2805
3360
|
AvatarFallback.displayName = "AvatarFallback";
|
2806
3361
|
|
2807
3362
|
// src/ui/content-part.tsx
|
2808
|
-
import
|
2809
|
-
import { jsx as
|
3363
|
+
import classNames2 from "classnames";
|
3364
|
+
import { jsx as jsx34 } from "react/jsx-runtime";
|
2810
3365
|
var Text = () => {
|
2811
3366
|
const status = useSmoothStatus();
|
2812
|
-
return /* @__PURE__ */
|
3367
|
+
return /* @__PURE__ */ jsx34(
|
2813
3368
|
contentPart_exports.Text,
|
2814
3369
|
{
|
2815
|
-
className:
|
3370
|
+
className: classNames2(
|
2816
3371
|
"aui-text",
|
2817
3372
|
status.type === "running" && "aui-text-running"
|
2818
3373
|
),
|
@@ -2824,19 +3379,19 @@ var exports3 = { Text: withSmoothContextProvider(Text) };
|
|
2824
3379
|
var content_part_default = exports3;
|
2825
3380
|
|
2826
3381
|
// src/ui/assistant-message.tsx
|
2827
|
-
import { jsx as
|
3382
|
+
import { jsx as jsx35, jsxs as jsxs8 } from "react/jsx-runtime";
|
2828
3383
|
var AssistantMessage = () => {
|
2829
|
-
return /* @__PURE__ */
|
2830
|
-
/* @__PURE__ */
|
2831
|
-
/* @__PURE__ */
|
2832
|
-
/* @__PURE__ */
|
2833
|
-
/* @__PURE__ */
|
3384
|
+
return /* @__PURE__ */ jsxs8(AssistantMessageRoot, { children: [
|
3385
|
+
/* @__PURE__ */ jsx35(AssistantMessageAvatar, {}),
|
3386
|
+
/* @__PURE__ */ jsx35(AssistantMessageContent, {}),
|
3387
|
+
/* @__PURE__ */ jsx35(branch_picker_default, {}),
|
3388
|
+
/* @__PURE__ */ jsx35(assistant_action_bar_default, {})
|
2834
3389
|
] });
|
2835
3390
|
};
|
2836
3391
|
AssistantMessage.displayName = "AssistantMessage";
|
2837
3392
|
var AssistantMessageAvatar = () => {
|
2838
3393
|
const { assistantAvatar: avatar = { fallback: "A" } } = useThreadConfig();
|
2839
|
-
return /* @__PURE__ */
|
3394
|
+
return /* @__PURE__ */ jsx35(Avatar, { ...avatar });
|
2840
3395
|
};
|
2841
3396
|
var AssistantMessageRoot = withDefaults(message_exports.Root, {
|
2842
3397
|
className: "aui-assistant-message-root"
|
@@ -2845,9 +3400,9 @@ AssistantMessageRoot.displayName = "AssistantMessageRoot";
|
|
2845
3400
|
var AssistantMessageContentWrapper = withDefaults("div", {
|
2846
3401
|
className: "aui-assistant-message-content"
|
2847
3402
|
});
|
2848
|
-
var AssistantMessageContent =
|
3403
|
+
var AssistantMessageContent = forwardRef21(({ components: componentsProp, ...rest }, ref) => {
|
2849
3404
|
const { assistantMessage: { components = {} } = {} } = useThreadConfig();
|
2850
|
-
return /* @__PURE__ */
|
3405
|
+
return /* @__PURE__ */ jsx35(AssistantMessageContentWrapper, { ...rest, ref, children: /* @__PURE__ */ jsx35(
|
2851
3406
|
message_exports.Content,
|
2852
3407
|
{
|
2853
3408
|
components: {
|
@@ -2869,38 +3424,38 @@ var assistant_message_default = Object.assign(
|
|
2869
3424
|
);
|
2870
3425
|
|
2871
3426
|
// src/ui/assistant-modal.tsx
|
2872
|
-
import { forwardRef as
|
3427
|
+
import { forwardRef as forwardRef28 } from "react";
|
2873
3428
|
import { BotIcon, ChevronDownIcon } from "lucide-react";
|
2874
3429
|
|
2875
3430
|
// src/ui/thread.tsx
|
2876
|
-
import { forwardRef as
|
3431
|
+
import { forwardRef as forwardRef27 } from "react";
|
2877
3432
|
import { ArrowDownIcon } from "lucide-react";
|
2878
3433
|
|
2879
3434
|
// src/ui/composer.tsx
|
2880
|
-
import { forwardRef as
|
3435
|
+
import { forwardRef as forwardRef22 } from "react";
|
2881
3436
|
import { SendHorizontalIcon } from "lucide-react";
|
2882
3437
|
|
2883
3438
|
// src/ui/base/CircleStopIcon.tsx
|
2884
|
-
import { jsx as
|
3439
|
+
import { jsx as jsx36 } from "react/jsx-runtime";
|
2885
3440
|
var CircleStopIcon = () => {
|
2886
|
-
return /* @__PURE__ */
|
3441
|
+
return /* @__PURE__ */ jsx36(
|
2887
3442
|
"svg",
|
2888
3443
|
{
|
2889
3444
|
xmlns: "http://www.w3.org/2000/svg",
|
2890
3445
|
viewBox: "0 0 16 16",
|
2891
3446
|
fill: "currentColor",
|
2892
|
-
children: /* @__PURE__ */
|
3447
|
+
children: /* @__PURE__ */ jsx36("rect", { width: "10", height: "10", x: "3", y: "3", rx: "2" })
|
2893
3448
|
}
|
2894
3449
|
);
|
2895
3450
|
};
|
2896
3451
|
CircleStopIcon.displayName = "CircleStopIcon";
|
2897
3452
|
|
2898
3453
|
// src/ui/composer.tsx
|
2899
|
-
import { Fragment as Fragment5, jsx as
|
3454
|
+
import { Fragment as Fragment5, jsx as jsx37, jsxs as jsxs9 } from "react/jsx-runtime";
|
2900
3455
|
var Composer = () => {
|
2901
|
-
return /* @__PURE__ */
|
2902
|
-
/* @__PURE__ */
|
2903
|
-
/* @__PURE__ */
|
3456
|
+
return /* @__PURE__ */ jsxs9(ComposerRoot, { children: [
|
3457
|
+
/* @__PURE__ */ jsx37(ComposerInput, { autoFocus: true }),
|
3458
|
+
/* @__PURE__ */ jsx37(ComposerAction, {})
|
2904
3459
|
] });
|
2905
3460
|
};
|
2906
3461
|
Composer.displayName = "Composer";
|
@@ -2913,14 +3468,14 @@ var ComposerInputStyled = withDefaults(composer_exports.Input, {
|
|
2913
3468
|
autoFocus: true,
|
2914
3469
|
className: "aui-composer-input"
|
2915
3470
|
});
|
2916
|
-
var ComposerInput =
|
3471
|
+
var ComposerInput = forwardRef22(
|
2917
3472
|
(props, ref) => {
|
2918
3473
|
const {
|
2919
3474
|
strings: {
|
2920
3475
|
composer: { input: { placeholder = "Write a message..." } = {} } = {}
|
2921
3476
|
} = {}
|
2922
3477
|
} = useThreadConfig();
|
2923
|
-
return /* @__PURE__ */
|
3478
|
+
return /* @__PURE__ */ jsx37(ComposerInputStyled, { placeholder, ...props, ref });
|
2924
3479
|
}
|
2925
3480
|
);
|
2926
3481
|
ComposerInput.displayName = "ComposerInput";
|
@@ -2931,10 +3486,10 @@ var useAllowCancel = () => {
|
|
2931
3486
|
};
|
2932
3487
|
var ComposerAction = () => {
|
2933
3488
|
const allowCancel = useAllowCancel();
|
2934
|
-
if (!allowCancel) return /* @__PURE__ */
|
2935
|
-
return /* @__PURE__ */
|
2936
|
-
/* @__PURE__ */
|
2937
|
-
/* @__PURE__ */
|
3489
|
+
if (!allowCancel) return /* @__PURE__ */ jsx37(ComposerSend, {});
|
3490
|
+
return /* @__PURE__ */ jsxs9(Fragment5, { children: [
|
3491
|
+
/* @__PURE__ */ jsx37(thread_exports.If, { running: false, children: /* @__PURE__ */ jsx37(ComposerSend, {}) }),
|
3492
|
+
/* @__PURE__ */ jsx37(thread_exports.If, { running: true, children: /* @__PURE__ */ jsx37(ComposerCancel, {}) })
|
2938
3493
|
] });
|
2939
3494
|
};
|
2940
3495
|
ComposerAction.displayName = "ComposerAction";
|
@@ -2942,22 +3497,22 @@ var ComposerSendButton = withDefaults(TooltipIconButton, {
|
|
2942
3497
|
variant: "default",
|
2943
3498
|
className: "aui-composer-send"
|
2944
3499
|
});
|
2945
|
-
var ComposerSend =
|
3500
|
+
var ComposerSend = forwardRef22((props, ref) => {
|
2946
3501
|
const {
|
2947
3502
|
strings: { composer: { send: { tooltip = "Send" } = {} } = {} } = {}
|
2948
3503
|
} = useThreadConfig();
|
2949
|
-
return /* @__PURE__ */
|
3504
|
+
return /* @__PURE__ */ jsx37(composer_exports.Send, { asChild: true, children: /* @__PURE__ */ jsx37(ComposerSendButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx37(SendHorizontalIcon, {}) }) });
|
2950
3505
|
});
|
2951
3506
|
ComposerSend.displayName = "ComposerSend";
|
2952
3507
|
var ComposerCancelButton = withDefaults(TooltipIconButton, {
|
2953
3508
|
variant: "default",
|
2954
3509
|
className: "aui-composer-cancel"
|
2955
3510
|
});
|
2956
|
-
var ComposerCancel =
|
3511
|
+
var ComposerCancel = forwardRef22((props, ref) => {
|
2957
3512
|
const {
|
2958
3513
|
strings: { composer: { cancel: { tooltip = "Cancel" } = {} } = {} } = {}
|
2959
3514
|
} = useThreadConfig();
|
2960
|
-
return /* @__PURE__ */
|
3515
|
+
return /* @__PURE__ */ jsx37(composer_exports.Cancel, { asChild: true, children: /* @__PURE__ */ jsx37(ComposerCancelButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx37(CircleStopIcon, {}) }) });
|
2961
3516
|
});
|
2962
3517
|
ComposerCancel.displayName = "ComposerCancel";
|
2963
3518
|
var exports5 = {
|
@@ -2970,15 +3525,15 @@ var exports5 = {
|
|
2970
3525
|
var composer_default = Object.assign(Composer, exports5);
|
2971
3526
|
|
2972
3527
|
// src/ui/thread-welcome.tsx
|
2973
|
-
import { forwardRef as
|
2974
|
-
import { jsx as
|
3528
|
+
import { forwardRef as forwardRef23 } from "react";
|
3529
|
+
import { jsx as jsx38, jsxs as jsxs10 } from "react/jsx-runtime";
|
2975
3530
|
var ThreadWelcome = () => {
|
2976
|
-
return /* @__PURE__ */
|
2977
|
-
/* @__PURE__ */
|
2978
|
-
/* @__PURE__ */
|
2979
|
-
/* @__PURE__ */
|
3531
|
+
return /* @__PURE__ */ jsxs10(ThreadWelcomeRoot, { children: [
|
3532
|
+
/* @__PURE__ */ jsxs10(ThreadWelcomeCenter, { children: [
|
3533
|
+
/* @__PURE__ */ jsx38(ThreadWelcomeAvatar, {}),
|
3534
|
+
/* @__PURE__ */ jsx38(ThreadWelcomeMessage, {})
|
2980
3535
|
] }),
|
2981
|
-
/* @__PURE__ */
|
3536
|
+
/* @__PURE__ */ jsx38(ThreadWelcomeSuggestions, {})
|
2982
3537
|
] });
|
2983
3538
|
};
|
2984
3539
|
ThreadWelcome.displayName = "ThreadWelcome";
|
@@ -2988,22 +3543,22 @@ var ThreadWelcomeRootStyled = withDefaults("div", {
|
|
2988
3543
|
var ThreadWelcomeCenter = withDefaults("div", {
|
2989
3544
|
className: "aui-thread-welcome-center"
|
2990
3545
|
});
|
2991
|
-
var ThreadWelcomeRoot =
|
3546
|
+
var ThreadWelcomeRoot = forwardRef23(
|
2992
3547
|
(props, ref) => {
|
2993
|
-
return /* @__PURE__ */
|
3548
|
+
return /* @__PURE__ */ jsx38(thread_exports.Empty, { children: /* @__PURE__ */ jsx38(ThreadWelcomeRootStyled, { ...props, ref }) });
|
2994
3549
|
}
|
2995
3550
|
);
|
2996
3551
|
ThreadWelcomeRoot.displayName = "ThreadWelcomeRoot";
|
2997
3552
|
var ThreadWelcomeAvatar = () => {
|
2998
3553
|
const { assistantAvatar: avatar = { fallback: "A" } } = useThreadConfig();
|
2999
|
-
return /* @__PURE__ */
|
3554
|
+
return /* @__PURE__ */ jsx38(Avatar, { ...avatar });
|
3000
3555
|
};
|
3001
3556
|
var ThreadWelcomeMessageStyled = withDefaults("p", {
|
3002
3557
|
className: "aui-thread-welcome-message"
|
3003
3558
|
});
|
3004
|
-
var ThreadWelcomeMessage =
|
3559
|
+
var ThreadWelcomeMessage = forwardRef23(({ message: messageProp, ...rest }, ref) => {
|
3005
3560
|
const { welcome: { message = "How can I help you today?" } = {} } = useThreadConfig();
|
3006
|
-
return /* @__PURE__ */
|
3561
|
+
return /* @__PURE__ */ jsx38(ThreadWelcomeMessageStyled, { ...rest, ref, children: messageProp ?? message });
|
3007
3562
|
});
|
3008
3563
|
ThreadWelcomeMessage.displayName = "ThreadWelcomeMessage";
|
3009
3564
|
var ThreadWelcomeSuggestionContainer = withDefaults("div", {
|
@@ -3015,21 +3570,21 @@ var ThreadWelcomeSuggestionStyled = withDefaults(thread_exports.Suggestion, {
|
|
3015
3570
|
var ThreadWelcomeSuggestion = ({
|
3016
3571
|
suggestion: { text, prompt }
|
3017
3572
|
}) => {
|
3018
|
-
return /* @__PURE__ */
|
3573
|
+
return /* @__PURE__ */ jsx38(
|
3019
3574
|
ThreadWelcomeSuggestionStyled,
|
3020
3575
|
{
|
3021
3576
|
prompt,
|
3022
3577
|
method: "replace",
|
3023
3578
|
autoSend: true,
|
3024
|
-
children: /* @__PURE__ */
|
3579
|
+
children: /* @__PURE__ */ jsx38("span", { className: "aui-thread-welcome-suggestion-text", children: text ?? prompt })
|
3025
3580
|
}
|
3026
3581
|
);
|
3027
3582
|
};
|
3028
3583
|
var ThreadWelcomeSuggestions = () => {
|
3029
3584
|
const { welcome: { suggestions } = {} } = useThreadConfig();
|
3030
|
-
return /* @__PURE__ */
|
3585
|
+
return /* @__PURE__ */ jsx38(ThreadWelcomeSuggestionContainer, { children: suggestions?.map((suggestion, idx) => {
|
3031
3586
|
const key = `${suggestion.prompt}-${idx}`;
|
3032
|
-
return /* @__PURE__ */
|
3587
|
+
return /* @__PURE__ */ jsx38(ThreadWelcomeSuggestion, { suggestion }, key);
|
3033
3588
|
}) });
|
3034
3589
|
};
|
3035
3590
|
ThreadWelcomeSuggestions.displayName = "ThreadWelcomeSuggestions";
|
@@ -3044,12 +3599,12 @@ var exports6 = {
|
|
3044
3599
|
var thread_welcome_default = Object.assign(ThreadWelcome, exports6);
|
3045
3600
|
|
3046
3601
|
// src/ui/user-message.tsx
|
3047
|
-
import { forwardRef as
|
3602
|
+
import { forwardRef as forwardRef25 } from "react";
|
3048
3603
|
|
3049
3604
|
// src/ui/user-action-bar.tsx
|
3050
|
-
import { forwardRef as
|
3605
|
+
import { forwardRef as forwardRef24 } from "react";
|
3051
3606
|
import { PencilIcon } from "lucide-react";
|
3052
|
-
import { jsx as
|
3607
|
+
import { jsx as jsx39 } from "react/jsx-runtime";
|
3053
3608
|
var useAllowEdit = () => {
|
3054
3609
|
const { userMessage: { allowEdit = true } = {} } = useThreadConfig();
|
3055
3610
|
const { useThreadActions } = useThreadContext();
|
@@ -3059,20 +3614,20 @@ var useAllowEdit = () => {
|
|
3059
3614
|
var UserActionBar = () => {
|
3060
3615
|
const allowEdit = useAllowEdit();
|
3061
3616
|
if (!allowEdit) return null;
|
3062
|
-
return /* @__PURE__ */
|
3617
|
+
return /* @__PURE__ */ jsx39(UserActionBarRoot, { hideWhenRunning: true, autohide: "not-last", children: /* @__PURE__ */ jsx39(UserActionBarEdit, {}) });
|
3063
3618
|
};
|
3064
3619
|
UserActionBar.displayName = "UserActionBar";
|
3065
3620
|
var UserActionBarRoot = withDefaults(actionBar_exports.Root, {
|
3066
3621
|
className: "aui-user-action-bar-root"
|
3067
3622
|
});
|
3068
3623
|
UserActionBarRoot.displayName = "UserActionBarRoot";
|
3069
|
-
var UserActionBarEdit =
|
3624
|
+
var UserActionBarEdit = forwardRef24((props, ref) => {
|
3070
3625
|
const {
|
3071
3626
|
strings: { userMessage: { edit: { tooltip = "Edit" } = {} } = {} } = {}
|
3072
3627
|
} = useThreadConfig();
|
3073
3628
|
const allowEdit = useAllowEdit();
|
3074
3629
|
if (!allowEdit) return null;
|
3075
|
-
return /* @__PURE__ */
|
3630
|
+
return /* @__PURE__ */ jsx39(actionBar_exports.Edit, { asChild: true, children: /* @__PURE__ */ jsx39(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx39(PencilIcon, {}) }) });
|
3076
3631
|
});
|
3077
3632
|
UserActionBarEdit.displayName = "UserActionBarEdit";
|
3078
3633
|
var exports7 = {
|
@@ -3082,12 +3637,12 @@ var exports7 = {
|
|
3082
3637
|
var user_action_bar_default = Object.assign(UserActionBar, exports7);
|
3083
3638
|
|
3084
3639
|
// src/ui/user-message.tsx
|
3085
|
-
import { jsx as
|
3640
|
+
import { jsx as jsx40, jsxs as jsxs11 } from "react/jsx-runtime";
|
3086
3641
|
var UserMessage = () => {
|
3087
|
-
return /* @__PURE__ */
|
3088
|
-
/* @__PURE__ */
|
3089
|
-
/* @__PURE__ */
|
3090
|
-
/* @__PURE__ */
|
3642
|
+
return /* @__PURE__ */ jsxs11(UserMessageRoot, { children: [
|
3643
|
+
/* @__PURE__ */ jsx40(user_action_bar_default, {}),
|
3644
|
+
/* @__PURE__ */ jsx40(UserMessageContent, {}),
|
3645
|
+
/* @__PURE__ */ jsx40(branch_picker_default, {})
|
3091
3646
|
] });
|
3092
3647
|
};
|
3093
3648
|
UserMessage.displayName = "UserMessage";
|
@@ -3098,9 +3653,9 @@ UserMessageRoot.displayName = "UserMessageRoot";
|
|
3098
3653
|
var UserMessageContentWrapper = withDefaults("div", {
|
3099
3654
|
className: "aui-user-message-content"
|
3100
3655
|
});
|
3101
|
-
var UserMessageContent =
|
3656
|
+
var UserMessageContent = forwardRef25(
|
3102
3657
|
({ components, ...props }, ref) => {
|
3103
|
-
return /* @__PURE__ */
|
3658
|
+
return /* @__PURE__ */ jsx40(UserMessageContentWrapper, { ...props, ref, children: /* @__PURE__ */ jsx40(
|
3104
3659
|
message_exports.Content,
|
3105
3660
|
{
|
3106
3661
|
components: {
|
@@ -3119,14 +3674,14 @@ var exports8 = {
|
|
3119
3674
|
var user_message_default = Object.assign(UserMessage, exports8);
|
3120
3675
|
|
3121
3676
|
// src/ui/edit-composer.tsx
|
3122
|
-
import { forwardRef as
|
3123
|
-
import { jsx as
|
3677
|
+
import { forwardRef as forwardRef26 } from "react";
|
3678
|
+
import { jsx as jsx41, jsxs as jsxs12 } from "react/jsx-runtime";
|
3124
3679
|
var EditComposer = () => {
|
3125
|
-
return /* @__PURE__ */
|
3126
|
-
/* @__PURE__ */
|
3127
|
-
/* @__PURE__ */
|
3128
|
-
/* @__PURE__ */
|
3129
|
-
/* @__PURE__ */
|
3680
|
+
return /* @__PURE__ */ jsxs12(EditComposerRoot, { children: [
|
3681
|
+
/* @__PURE__ */ jsx41(EditComposerInput, {}),
|
3682
|
+
/* @__PURE__ */ jsxs12(EditComposerFooter, { children: [
|
3683
|
+
/* @__PURE__ */ jsx41(EditComposerCancel, {}),
|
3684
|
+
/* @__PURE__ */ jsx41(EditComposerSend, {})
|
3130
3685
|
] })
|
3131
3686
|
] });
|
3132
3687
|
};
|
@@ -3143,23 +3698,23 @@ var EditComposerFooter = withDefaults("div", {
|
|
3143
3698
|
className: "aui-edit-composer-footer"
|
3144
3699
|
});
|
3145
3700
|
EditComposerFooter.displayName = "EditComposerFooter";
|
3146
|
-
var EditComposerCancel =
|
3701
|
+
var EditComposerCancel = forwardRef26(
|
3147
3702
|
(props, ref) => {
|
3148
3703
|
const {
|
3149
3704
|
strings: {
|
3150
3705
|
editComposer: { cancel: { label = "Cancel" } = {} } = {}
|
3151
3706
|
} = {}
|
3152
3707
|
} = useThreadConfig();
|
3153
|
-
return /* @__PURE__ */
|
3708
|
+
return /* @__PURE__ */ jsx41(composer_exports.Cancel, { asChild: true, children: /* @__PURE__ */ jsx41(Button, { variant: "ghost", ...props, ref, children: props.children ?? label }) });
|
3154
3709
|
}
|
3155
3710
|
);
|
3156
3711
|
EditComposerCancel.displayName = "EditComposerCancel";
|
3157
|
-
var EditComposerSend =
|
3712
|
+
var EditComposerSend = forwardRef26(
|
3158
3713
|
(props, ref) => {
|
3159
3714
|
const {
|
3160
3715
|
strings: { editComposer: { send: { label = "Send" } = {} } = {} } = {}
|
3161
3716
|
} = useThreadConfig();
|
3162
|
-
return /* @__PURE__ */
|
3717
|
+
return /* @__PURE__ */ jsx41(composer_exports.Send, { asChild: true, children: /* @__PURE__ */ jsx41(Button, { ...props, ref, children: props.children ?? label }) });
|
3163
3718
|
}
|
3164
3719
|
);
|
3165
3720
|
EditComposerSend.displayName = "EditComposerSend";
|
@@ -3173,23 +3728,23 @@ var exports9 = {
|
|
3173
3728
|
var edit_composer_default = Object.assign(EditComposer, exports9);
|
3174
3729
|
|
3175
3730
|
// src/ui/thread.tsx
|
3176
|
-
import { jsx as
|
3731
|
+
import { jsx as jsx42, jsxs as jsxs13 } from "react/jsx-runtime";
|
3177
3732
|
var Thread = (config) => {
|
3178
|
-
return /* @__PURE__ */
|
3179
|
-
/* @__PURE__ */
|
3180
|
-
/* @__PURE__ */
|
3181
|
-
/* @__PURE__ */
|
3182
|
-
/* @__PURE__ */
|
3183
|
-
/* @__PURE__ */
|
3733
|
+
return /* @__PURE__ */ jsx42(ThreadRoot, { config, children: /* @__PURE__ */ jsxs13(ThreadViewport, { children: [
|
3734
|
+
/* @__PURE__ */ jsx42(thread_welcome_default, {}),
|
3735
|
+
/* @__PURE__ */ jsx42(ThreadMessages, {}),
|
3736
|
+
/* @__PURE__ */ jsxs13(ThreadViewportFooter, { children: [
|
3737
|
+
/* @__PURE__ */ jsx42(ThreadScrollToBottom, {}),
|
3738
|
+
/* @__PURE__ */ jsx42(composer_default, {})
|
3184
3739
|
] })
|
3185
3740
|
] }) });
|
3186
3741
|
};
|
3187
3742
|
var ThreadRootStyled = withDefaults(thread_exports.Root, {
|
3188
3743
|
className: "aui-root aui-thread-root"
|
3189
3744
|
});
|
3190
|
-
var ThreadRoot =
|
3745
|
+
var ThreadRoot = forwardRef27(
|
3191
3746
|
({ config, ...props }, ref) => {
|
3192
|
-
return /* @__PURE__ */
|
3747
|
+
return /* @__PURE__ */ jsx42(ThreadConfigProvider, { config, children: /* @__PURE__ */ jsx42(ThreadRootStyled, { ...props, ref }) });
|
3193
3748
|
}
|
3194
3749
|
);
|
3195
3750
|
ThreadRoot.displayName = "ThreadRoot";
|
@@ -3203,7 +3758,7 @@ var ThreadViewportFooter = withDefaults("div", {
|
|
3203
3758
|
ThreadViewportFooter.displayName = "ThreadViewportFooter";
|
3204
3759
|
var SystemMessage = () => null;
|
3205
3760
|
var ThreadMessages = ({ components, ...rest }) => {
|
3206
|
-
return /* @__PURE__ */
|
3761
|
+
return /* @__PURE__ */ jsx42(
|
3207
3762
|
thread_exports.Messages,
|
3208
3763
|
{
|
3209
3764
|
components: {
|
@@ -3221,13 +3776,13 @@ var ThreadScrollToBottomIconButton = withDefaults(TooltipIconButton, {
|
|
3221
3776
|
variant: "outline",
|
3222
3777
|
className: "aui-thread-scroll-to-bottom"
|
3223
3778
|
});
|
3224
|
-
var ThreadScrollToBottom =
|
3779
|
+
var ThreadScrollToBottom = forwardRef27((props, ref) => {
|
3225
3780
|
const {
|
3226
3781
|
strings: {
|
3227
3782
|
thread: { scrollToBottom: { tooltip = "Scroll to bottom" } = {} } = {}
|
3228
3783
|
} = {}
|
3229
3784
|
} = useThreadConfig();
|
3230
|
-
return /* @__PURE__ */
|
3785
|
+
return /* @__PURE__ */ jsx42(thread_exports.ScrollToBottom, { asChild: true, children: /* @__PURE__ */ jsx42(ThreadScrollToBottomIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx42(ArrowDownIcon, {}) }) });
|
3231
3786
|
});
|
3232
3787
|
ThreadScrollToBottom.displayName = "ThreadScrollToBottom";
|
3233
3788
|
var exports10 = {
|
@@ -3240,20 +3795,20 @@ var exports10 = {
|
|
3240
3795
|
var thread_default = Object.assign(Thread, exports10);
|
3241
3796
|
|
3242
3797
|
// src/ui/assistant-modal.tsx
|
3243
|
-
import { Fragment as Fragment6, jsx as
|
3798
|
+
import { Fragment as Fragment6, jsx as jsx43, jsxs as jsxs14 } from "react/jsx-runtime";
|
3244
3799
|
var AssistantModal = (config) => {
|
3245
|
-
return /* @__PURE__ */
|
3246
|
-
/* @__PURE__ */
|
3247
|
-
/* @__PURE__ */
|
3800
|
+
return /* @__PURE__ */ jsxs14(AssistantModalRoot, { config, children: [
|
3801
|
+
/* @__PURE__ */ jsx43(AssistantModalTrigger, {}),
|
3802
|
+
/* @__PURE__ */ jsx43(AssistantModalContent, { children: /* @__PURE__ */ jsx43(thread_default, {}) })
|
3248
3803
|
] });
|
3249
3804
|
};
|
3250
3805
|
AssistantModal.displayName = "AssistantModal";
|
3251
3806
|
var AssistantModalRoot = ({ config, ...props }) => {
|
3252
|
-
return /* @__PURE__ */
|
3807
|
+
return /* @__PURE__ */ jsx43(ThreadConfigProvider, { config, children: /* @__PURE__ */ jsx43(assistantModal_exports.Root, { ...props }) });
|
3253
3808
|
};
|
3254
3809
|
AssistantModalRoot.displayName = "AssistantModalRoot";
|
3255
|
-
var AssistantModalTrigger =
|
3256
|
-
return /* @__PURE__ */
|
3810
|
+
var AssistantModalTrigger = forwardRef28((props, ref) => {
|
3811
|
+
return /* @__PURE__ */ jsx43(AssistantModalAnchor, { children: /* @__PURE__ */ jsx43(assistantModal_exports.Trigger, { asChild: true, children: /* @__PURE__ */ jsx43(AssistantModalButton, { ...props, ref }) }) });
|
3257
3812
|
});
|
3258
3813
|
AssistantModalTrigger.displayName = "AssistantModalTrigger";
|
3259
3814
|
var AssistantModalAnchor = withDefaults(assistantModal_exports.Anchor, {
|
@@ -3264,7 +3819,7 @@ var ModalButtonStyled = withDefaults(TooltipIconButton, {
|
|
3264
3819
|
variant: "default",
|
3265
3820
|
className: "aui-modal-button"
|
3266
3821
|
});
|
3267
|
-
var AssistantModalButton =
|
3822
|
+
var AssistantModalButton = forwardRef28(({ "data-state": state, ...rest }, ref) => {
|
3268
3823
|
const {
|
3269
3824
|
strings: {
|
3270
3825
|
assistantModal: {
|
@@ -3278,7 +3833,7 @@ var AssistantModalButton = forwardRef24(({ "data-state": state, ...rest }, ref)
|
|
3278
3833
|
} = {}
|
3279
3834
|
} = useThreadConfig();
|
3280
3835
|
const tooltip = state === "open" ? openTooltip : closedTooltip;
|
3281
|
-
return /* @__PURE__ */
|
3836
|
+
return /* @__PURE__ */ jsx43(
|
3282
3837
|
ModalButtonStyled,
|
3283
3838
|
{
|
3284
3839
|
side: "left",
|
@@ -3286,15 +3841,15 @@ var AssistantModalButton = forwardRef24(({ "data-state": state, ...rest }, ref)
|
|
3286
3841
|
"data-state": state,
|
3287
3842
|
...rest,
|
3288
3843
|
ref,
|
3289
|
-
children: rest.children ?? /* @__PURE__ */
|
3290
|
-
/* @__PURE__ */
|
3844
|
+
children: rest.children ?? /* @__PURE__ */ jsxs14(Fragment6, { children: [
|
3845
|
+
/* @__PURE__ */ jsx43(
|
3291
3846
|
BotIcon,
|
3292
3847
|
{
|
3293
3848
|
"data-state": state,
|
3294
3849
|
className: "aui-modal-button-closed-icon"
|
3295
3850
|
}
|
3296
3851
|
),
|
3297
|
-
/* @__PURE__ */
|
3852
|
+
/* @__PURE__ */ jsx43(
|
3298
3853
|
ChevronDownIcon,
|
3299
3854
|
{
|
3300
3855
|
"data-state": state,
|