@assistant-ui/react 0.5.20 → 0.5.21
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/{ModelConfigTypes-ComYH1b6.d.mts → AssistantTypes-D93BmqD5.d.mts} +64 -60
- package/dist/{ModelConfigTypes-ComYH1b6.d.ts → AssistantTypes-D93BmqD5.d.ts} +64 -60
- package/dist/Thread-BbLf1cc4.d.mts +156 -0
- package/dist/Thread-jfAlPLli.d.ts +156 -0
- package/dist/chunk-2RKUKZSZ.mjs +761 -0
- package/dist/chunk-2RKUKZSZ.mjs.map +1 -0
- package/dist/chunk-BJPOCE4O.mjs +11 -0
- package/dist/chunk-BJPOCE4O.mjs.map +1 -0
- package/dist/{chunk-BV6Y7C43.mjs → chunk-QBS6JLLN.mjs} +3 -1
- package/dist/{chunk-BV6Y7C43.mjs.map → chunk-QBS6JLLN.mjs.map} +1 -1
- package/dist/chunk-V66MVXBH.mjs +608 -0
- package/dist/chunk-V66MVXBH.mjs.map +1 -0
- package/dist/edge.d.mts +2 -2
- package/dist/edge.d.ts +2 -2
- package/dist/edge.js +1 -0
- package/dist/edge.js.map +1 -1
- package/dist/edge.mjs +10 -748
- package/dist/edge.mjs.map +1 -1
- package/dist/index.d.mts +11 -309
- package/dist/index.d.ts +11 -309
- package/dist/index.mjs +324 -1677
- package/dist/index.mjs.map +1 -1
- package/dist/internal.d.mts +7 -126
- package/dist/internal.d.ts +7 -126
- package/dist/internal.js +1 -0
- package/dist/internal.js.map +1 -1
- package/dist/internal.mjs +12 -519
- package/dist/internal.mjs.map +1 -1
- package/dist/tailwindcss/index.js +1 -0
- package/dist/tailwindcss/index.js.map +1 -1
- package/dist/tailwindcss/index.mjs +3 -0
- package/dist/tailwindcss/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
@@ -1,9 +1,40 @@
|
|
1
1
|
"use client";
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
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
|
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 =
|
459
|
+
const useCombined = useMemo(() => createCombinedStore(stores), stores);
|
568
460
|
return useCombined(selector);
|
569
461
|
};
|
570
462
|
|
@@ -1119,7 +1011,7 @@ BranchPickerPrimitiveNumber.displayName = "BranchPickerPrimitive.Number";
|
|
1119
1011
|
|
1120
1012
|
// src/primitives/branchPicker/BranchPickerRoot.tsx
|
1121
1013
|
import { Primitive as Primitive5 } from "@radix-ui/react-primitive";
|
1122
|
-
import { forwardRef as
|
1014
|
+
import { forwardRef as forwardRef9 } from "react";
|
1123
1015
|
|
1124
1016
|
// src/primitives/message/index.ts
|
1125
1017
|
var message_exports = {};
|
@@ -1161,9 +1053,9 @@ var useIsHoveringRef = () => {
|
|
1161
1053
|
);
|
1162
1054
|
return useManagedRef(callbackRef);
|
1163
1055
|
};
|
1164
|
-
var MessagePrimitiveRoot = forwardRef6(({ onMouseEnter, onMouseLeave, ...rest },
|
1056
|
+
var MessagePrimitiveRoot = forwardRef6(({ onMouseEnter, onMouseLeave, ...rest }, forwardRef25) => {
|
1165
1057
|
const isHoveringRef = useIsHoveringRef();
|
1166
|
-
const ref = useComposedRefs(
|
1058
|
+
const ref = useComposedRefs(forwardRef25, isHoveringRef);
|
1167
1059
|
return /* @__PURE__ */ jsx12(Primitive3.div, { ...rest, ref });
|
1168
1060
|
});
|
1169
1061
|
MessagePrimitiveRoot.displayName = "MessagePrimitive.Root";
|
@@ -1252,170 +1144,27 @@ var ContentPartProvider = ({
|
|
1252
1144
|
|
1253
1145
|
// src/primitives/contentPart/ContentPartText.tsx
|
1254
1146
|
import {
|
1255
|
-
forwardRef as
|
1147
|
+
forwardRef as forwardRef7
|
1256
1148
|
} from "react";
|
1257
|
-
|
1258
|
-
// src/utils/smooth/useSmooth.tsx
|
1259
|
-
import { useEffect as useEffect7, useMemo as useMemo3, useRef as useRef3, useState as useState6 } from "react";
|
1260
|
-
|
1261
|
-
// src/utils/smooth/SmoothContext.tsx
|
1262
|
-
import {
|
1263
|
-
createContext as createContext5,
|
1264
|
-
forwardRef as forwardRef7,
|
1265
|
-
useContext as useContext5,
|
1266
|
-
useState as useState5
|
1267
|
-
} from "react";
|
1268
|
-
import { create as create11 } from "zustand";
|
1269
1149
|
import { jsx as jsx14 } from "react/jsx-runtime";
|
1270
|
-
var
|
1271
|
-
var makeSmoothContext = (initialState) => {
|
1272
|
-
const useSmoothStatus2 = create11(() => initialState);
|
1273
|
-
return { useSmoothStatus: useSmoothStatus2 };
|
1274
|
-
};
|
1275
|
-
var SmoothContextProvider = ({ children }) => {
|
1276
|
-
const outer = useSmoothContext({ optional: true });
|
1277
|
-
const { useContentPart } = useContentPartContext();
|
1278
|
-
const [context] = useState5(
|
1279
|
-
() => makeSmoothContext(useContentPart.getState().status)
|
1280
|
-
);
|
1281
|
-
if (outer) return children;
|
1282
|
-
return /* @__PURE__ */ jsx14(SmoothContext.Provider, { value: context, children });
|
1283
|
-
};
|
1284
|
-
var withSmoothContextProvider = (Component) => {
|
1285
|
-
const Wrapped = forwardRef7((props, ref) => {
|
1286
|
-
return /* @__PURE__ */ jsx14(SmoothContextProvider, { children: /* @__PURE__ */ jsx14(Component, { ...props, ref }) });
|
1287
|
-
});
|
1288
|
-
Wrapped.displayName = Component.displayName;
|
1289
|
-
return Wrapped;
|
1290
|
-
};
|
1291
|
-
function useSmoothContext(options) {
|
1292
|
-
const context = useContext5(SmoothContext);
|
1293
|
-
if (!options?.optional && !context)
|
1294
|
-
throw new Error(
|
1295
|
-
"This component must be used within a SmoothContextProvider."
|
1296
|
-
);
|
1297
|
-
return context;
|
1298
|
-
}
|
1299
|
-
var useSmoothStatus = () => {
|
1300
|
-
const { useSmoothStatus: useSmoothStatus2 } = useSmoothContext();
|
1301
|
-
return useSmoothStatus2();
|
1302
|
-
};
|
1303
|
-
|
1304
|
-
// src/utils/smooth/useSmooth.tsx
|
1305
|
-
import { useCallbackRef as useCallbackRef2 } from "@radix-ui/react-use-callback-ref";
|
1306
|
-
var TextStreamAnimator = class {
|
1307
|
-
constructor(currentText, setText) {
|
1308
|
-
this.currentText = currentText;
|
1309
|
-
this.setText = setText;
|
1310
|
-
}
|
1311
|
-
animationFrameId = null;
|
1312
|
-
lastUpdateTime = Date.now();
|
1313
|
-
targetText = "";
|
1314
|
-
start() {
|
1315
|
-
if (this.animationFrameId !== null) return;
|
1316
|
-
this.lastUpdateTime = Date.now();
|
1317
|
-
this.animate();
|
1318
|
-
}
|
1319
|
-
stop() {
|
1320
|
-
if (this.animationFrameId !== null) {
|
1321
|
-
cancelAnimationFrame(this.animationFrameId);
|
1322
|
-
this.animationFrameId = null;
|
1323
|
-
}
|
1324
|
-
}
|
1325
|
-
animate = () => {
|
1326
|
-
const currentTime = Date.now();
|
1327
|
-
const deltaTime = currentTime - this.lastUpdateTime;
|
1328
|
-
let timeToConsume = deltaTime;
|
1329
|
-
const remainingChars = this.targetText.length - this.currentText.length;
|
1330
|
-
const baseTimePerChar = Math.min(5, 250 / remainingChars);
|
1331
|
-
let charsToAdd = 0;
|
1332
|
-
while (timeToConsume >= baseTimePerChar && charsToAdd < remainingChars) {
|
1333
|
-
charsToAdd++;
|
1334
|
-
timeToConsume -= baseTimePerChar;
|
1335
|
-
}
|
1336
|
-
if (charsToAdd !== remainingChars) {
|
1337
|
-
this.animationFrameId = requestAnimationFrame(this.animate);
|
1338
|
-
} else {
|
1339
|
-
this.animationFrameId = null;
|
1340
|
-
}
|
1341
|
-
if (charsToAdd === 0) return;
|
1342
|
-
this.currentText = this.targetText.slice(
|
1343
|
-
0,
|
1344
|
-
this.currentText.length + charsToAdd
|
1345
|
-
);
|
1346
|
-
this.lastUpdateTime = currentTime - timeToConsume;
|
1347
|
-
this.setText(this.currentText);
|
1348
|
-
};
|
1349
|
-
};
|
1350
|
-
var SMOOTH_STATUS = Object.freeze({
|
1351
|
-
type: "running"
|
1352
|
-
});
|
1353
|
-
var useSmooth = (state, smooth = false) => {
|
1354
|
-
const { useSmoothStatus: useSmoothStatus2 } = useSmoothContext({ optional: true }) ?? {};
|
1355
|
-
const {
|
1356
|
-
part: { text }
|
1357
|
-
} = state;
|
1358
|
-
const { useMessage } = useMessageContext();
|
1359
|
-
const id = useMessage((m) => m.message.id);
|
1360
|
-
const idRef = useRef3(id);
|
1361
|
-
const [displayedText, setDisplayedText] = useState6(text);
|
1362
|
-
const setText = useCallbackRef2((text2) => {
|
1363
|
-
setDisplayedText(text2);
|
1364
|
-
useSmoothStatus2?.setState(text2 !== state.part.text ? SMOOTH_STATUS : state.status);
|
1365
|
-
});
|
1366
|
-
const [animatorRef] = useState6(
|
1367
|
-
new TextStreamAnimator(text, setText)
|
1368
|
-
);
|
1369
|
-
useEffect7(() => {
|
1370
|
-
if (!smooth) {
|
1371
|
-
animatorRef.stop();
|
1372
|
-
return;
|
1373
|
-
}
|
1374
|
-
if (idRef.current !== id || !text.startsWith(animatorRef.targetText)) {
|
1375
|
-
idRef.current = id;
|
1376
|
-
setText(text);
|
1377
|
-
animatorRef.currentText = text;
|
1378
|
-
animatorRef.targetText = text;
|
1379
|
-
animatorRef.stop();
|
1380
|
-
return;
|
1381
|
-
}
|
1382
|
-
animatorRef.targetText = text;
|
1383
|
-
animatorRef.start();
|
1384
|
-
}, [setText, animatorRef, id, smooth, text]);
|
1385
|
-
useEffect7(() => {
|
1386
|
-
return () => {
|
1387
|
-
animatorRef.stop();
|
1388
|
-
};
|
1389
|
-
}, [animatorRef]);
|
1390
|
-
return useMemo3(
|
1391
|
-
() => smooth ? {
|
1392
|
-
part: { type: "text", text: displayedText },
|
1393
|
-
status: text === displayedText ? state.status : SMOOTH_STATUS
|
1394
|
-
} : state,
|
1395
|
-
[smooth, displayedText, state, text]
|
1396
|
-
);
|
1397
|
-
};
|
1398
|
-
|
1399
|
-
// src/primitives/contentPart/ContentPartText.tsx
|
1400
|
-
import { jsx as jsx15 } from "react/jsx-runtime";
|
1401
|
-
var ContentPartPrimitiveText = forwardRef8(({ smooth = true, component: Component = "span", ...rest }, forwardedRef) => {
|
1150
|
+
var ContentPartPrimitiveText = forwardRef7(({ smooth = true, component: Component = "span", ...rest }, forwardedRef) => {
|
1402
1151
|
const {
|
1403
1152
|
part: { text },
|
1404
1153
|
status
|
1405
1154
|
} = useSmooth(useContentPartText(), smooth);
|
1406
|
-
return /* @__PURE__ */
|
1155
|
+
return /* @__PURE__ */ jsx14(Component, { "data-status": status.type, ...rest, ref: forwardedRef, children: text });
|
1407
1156
|
});
|
1408
1157
|
ContentPartPrimitiveText.displayName = "ContentPartPrimitive.Text";
|
1409
1158
|
|
1410
1159
|
// src/primitives/contentPart/ContentPartImage.tsx
|
1411
1160
|
import { Primitive as Primitive4 } from "@radix-ui/react-primitive";
|
1412
|
-
import { forwardRef as
|
1413
|
-
import { jsx as
|
1414
|
-
var ContentPartPrimitiveImage =
|
1161
|
+
import { forwardRef as forwardRef8 } from "react";
|
1162
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
1163
|
+
var ContentPartPrimitiveImage = forwardRef8((props, forwardedRef) => {
|
1415
1164
|
const {
|
1416
1165
|
part: { image }
|
1417
1166
|
} = useContentPartImage();
|
1418
|
-
return /* @__PURE__ */
|
1167
|
+
return /* @__PURE__ */ jsx15(Primitive4.img, { src: image, ...props, ref: forwardedRef });
|
1419
1168
|
});
|
1420
1169
|
ContentPartPrimitiveImage.displayName = "ContentPartPrimitive.Image";
|
1421
1170
|
|
@@ -1437,20 +1186,20 @@ var ContentPartPrimitiveInProgress = ({ children }) => {
|
|
1437
1186
|
ContentPartPrimitiveInProgress.displayName = "ContentPartPrimitive.InProgress";
|
1438
1187
|
|
1439
1188
|
// src/primitives/message/MessageContent.tsx
|
1440
|
-
import { jsx as
|
1189
|
+
import { jsx as jsx16, jsxs as jsxs2 } from "react/jsx-runtime";
|
1441
1190
|
var defaultComponents = {
|
1442
1191
|
Text: () => /* @__PURE__ */ jsxs2("p", { style: { whiteSpace: "pre-line" }, children: [
|
1443
|
-
/* @__PURE__ */
|
1444
|
-
/* @__PURE__ */
|
1192
|
+
/* @__PURE__ */ jsx16(ContentPartPrimitiveText, {}),
|
1193
|
+
/* @__PURE__ */ jsx16(ContentPartPrimitiveInProgress, { children: /* @__PURE__ */ jsx16("span", { style: { fontFamily: "revert" }, children: " \u25CF" }) })
|
1445
1194
|
] }),
|
1446
|
-
Image: () => /* @__PURE__ */
|
1447
|
-
UI: () => /* @__PURE__ */
|
1195
|
+
Image: () => /* @__PURE__ */ jsx16(ContentPartPrimitiveImage, {}),
|
1196
|
+
UI: () => /* @__PURE__ */ jsx16(ContentPartPrimitiveDisplay, {}),
|
1448
1197
|
tools: {
|
1449
1198
|
Fallback: (props) => {
|
1450
1199
|
const { useToolUIs } = useAssistantContext();
|
1451
1200
|
const Render = useToolUIs((s) => s.getToolUI(props.part.toolName));
|
1452
1201
|
if (!Render) return null;
|
1453
|
-
return /* @__PURE__ */
|
1202
|
+
return /* @__PURE__ */ jsx16(Render, { ...props });
|
1454
1203
|
}
|
1455
1204
|
}
|
1456
1205
|
};
|
@@ -1473,16 +1222,16 @@ var MessageContentPartComponent = ({
|
|
1473
1222
|
case "text":
|
1474
1223
|
if (status.type === "requires-action")
|
1475
1224
|
throw new Error("Encountered unexpected requires-action status");
|
1476
|
-
if (part === EMPTY_CONTENT) return /* @__PURE__ */
|
1477
|
-
return /* @__PURE__ */
|
1225
|
+
if (part === EMPTY_CONTENT) return /* @__PURE__ */ jsx16(Empty, { part, status });
|
1226
|
+
return /* @__PURE__ */ jsx16(Text2, { part, status });
|
1478
1227
|
case "image":
|
1479
1228
|
if (status.type === "requires-action")
|
1480
1229
|
throw new Error("Encountered unexpected requires-action status");
|
1481
|
-
return /* @__PURE__ */
|
1230
|
+
return /* @__PURE__ */ jsx16(Image2, { part, status });
|
1482
1231
|
case "ui":
|
1483
1232
|
if (status.type === "requires-action")
|
1484
1233
|
throw new Error("Encountered unexpected requires-action status");
|
1485
|
-
return /* @__PURE__ */
|
1234
|
+
return /* @__PURE__ */ jsx16(UI, { part, status });
|
1486
1235
|
case "tool-call": {
|
1487
1236
|
const Tool = by_name[part.toolName] || Fallback2;
|
1488
1237
|
const addResult = (result) => addToolResult({
|
@@ -1490,7 +1239,7 @@ var MessageContentPartComponent = ({
|
|
1490
1239
|
toolCallId: part.toolCallId,
|
1491
1240
|
result
|
1492
1241
|
});
|
1493
|
-
return /* @__PURE__ */
|
1242
|
+
return /* @__PURE__ */ jsx16(Tool, { part, status, addResult });
|
1494
1243
|
}
|
1495
1244
|
default:
|
1496
1245
|
const unhandledType = type;
|
@@ -1501,7 +1250,7 @@ var MessageContentPartImpl = ({
|
|
1501
1250
|
partIndex,
|
1502
1251
|
components
|
1503
1252
|
}) => {
|
1504
|
-
return /* @__PURE__ */
|
1253
|
+
return /* @__PURE__ */ jsx16(ContentPartProvider, { partIndex, children: /* @__PURE__ */ jsx16(MessageContentPartComponent, { components }) });
|
1505
1254
|
};
|
1506
1255
|
var MessageContentPart = memo2(
|
1507
1256
|
MessageContentPartImpl,
|
@@ -1514,7 +1263,7 @@ var MessagePrimitiveContent = ({
|
|
1514
1263
|
const contentLength = useMessage((s) => s.message.content.length) || 1;
|
1515
1264
|
return new Array(contentLength).fill(null).map((_, idx) => {
|
1516
1265
|
const partIndex = idx;
|
1517
|
-
return /* @__PURE__ */
|
1266
|
+
return /* @__PURE__ */ jsx16(
|
1518
1267
|
MessageContentPart,
|
1519
1268
|
{
|
1520
1269
|
partIndex,
|
@@ -1533,9 +1282,9 @@ var MessagePrimitiveInProgress = () => {
|
|
1533
1282
|
MessagePrimitiveInProgress.displayName = "MessagePrimitive.InProgress";
|
1534
1283
|
|
1535
1284
|
// src/primitives/branchPicker/BranchPickerRoot.tsx
|
1536
|
-
import { jsx as
|
1537
|
-
var BranchPickerPrimitiveRoot =
|
1538
|
-
return /* @__PURE__ */
|
1285
|
+
import { jsx as jsx17 } from "react/jsx-runtime";
|
1286
|
+
var BranchPickerPrimitiveRoot = forwardRef9(({ hideWhenSingleBranch, ...rest }, ref) => {
|
1287
|
+
return /* @__PURE__ */ jsx17(MessagePrimitiveIf, { hasBranches: hideWhenSingleBranch ? true : void 0, children: /* @__PURE__ */ jsx17(Primitive5.div, { ...rest, ref }) });
|
1539
1288
|
});
|
1540
1289
|
BranchPickerPrimitiveRoot.displayName = "BranchPickerPrimitive.Root";
|
1541
1290
|
|
@@ -1553,17 +1302,17 @@ __export(composer_exports, {
|
|
1553
1302
|
import { composeEventHandlers as composeEventHandlers4 } from "@radix-ui/primitive";
|
1554
1303
|
import { Primitive as Primitive6 } from "@radix-ui/react-primitive";
|
1555
1304
|
import {
|
1556
|
-
forwardRef as
|
1305
|
+
forwardRef as forwardRef10
|
1557
1306
|
} from "react";
|
1558
|
-
import { jsx as
|
1559
|
-
var ComposerPrimitiveRoot =
|
1307
|
+
import { jsx as jsx18 } from "react/jsx-runtime";
|
1308
|
+
var ComposerPrimitiveRoot = forwardRef10(({ onSubmit, ...rest }, forwardedRef) => {
|
1560
1309
|
const send = useComposerSend();
|
1561
1310
|
const handleSubmit = (e) => {
|
1562
1311
|
e.preventDefault();
|
1563
1312
|
if (!send) return;
|
1564
1313
|
send();
|
1565
1314
|
};
|
1566
|
-
return /* @__PURE__ */
|
1315
|
+
return /* @__PURE__ */ jsx18(
|
1567
1316
|
Primitive6.form,
|
1568
1317
|
{
|
1569
1318
|
...rest,
|
@@ -1579,15 +1328,15 @@ import { composeEventHandlers as composeEventHandlers5 } from "@radix-ui/primiti
|
|
1579
1328
|
import { useComposedRefs as useComposedRefs2 } from "@radix-ui/react-compose-refs";
|
1580
1329
|
import { Slot } from "@radix-ui/react-slot";
|
1581
1330
|
import {
|
1582
|
-
forwardRef as
|
1331
|
+
forwardRef as forwardRef11,
|
1583
1332
|
useCallback as useCallback15,
|
1584
|
-
useEffect as
|
1585
|
-
useRef as
|
1333
|
+
useEffect as useEffect7,
|
1334
|
+
useRef as useRef3
|
1586
1335
|
} from "react";
|
1587
1336
|
import TextareaAutosize from "react-textarea-autosize";
|
1588
1337
|
import { useEscapeKeydown } from "@radix-ui/react-use-escape-keydown";
|
1589
|
-
import { jsx as
|
1590
|
-
var ComposerPrimitiveInput =
|
1338
|
+
import { jsx as jsx19 } from "react/jsx-runtime";
|
1339
|
+
var ComposerPrimitiveInput = forwardRef11(
|
1591
1340
|
({
|
1592
1341
|
autoFocus = false,
|
1593
1342
|
asChild,
|
@@ -1604,7 +1353,7 @@ var ComposerPrimitiveInput = forwardRef12(
|
|
1604
1353
|
});
|
1605
1354
|
const Component = asChild ? Slot : TextareaAutosize;
|
1606
1355
|
const isDisabled = useThread((t) => t.isDisabled) ?? disabledProp ?? false;
|
1607
|
-
const textareaRef =
|
1356
|
+
const textareaRef = useRef3(null);
|
1608
1357
|
const ref = useComposedRefs2(forwardedRef, textareaRef);
|
1609
1358
|
useEscapeKeydown((e) => {
|
1610
1359
|
const composer = useComposer.getState();
|
@@ -1633,13 +1382,13 @@ var ComposerPrimitiveInput = forwardRef12(
|
|
1633
1382
|
textareaRef.current.value.length
|
1634
1383
|
);
|
1635
1384
|
}, [autoFocusEnabled]);
|
1636
|
-
|
1385
|
+
useEffect7(() => focus(), [focus]);
|
1637
1386
|
useOnComposerFocus(() => {
|
1638
1387
|
if (type === "new") {
|
1639
1388
|
focus();
|
1640
1389
|
}
|
1641
1390
|
});
|
1642
|
-
return /* @__PURE__ */
|
1391
|
+
return /* @__PURE__ */ jsx19(
|
1643
1392
|
Component,
|
1644
1393
|
{
|
1645
1394
|
name: "input",
|
@@ -1660,13 +1409,13 @@ var ComposerPrimitiveInput = forwardRef12(
|
|
1660
1409
|
ComposerPrimitiveInput.displayName = "ComposerPrimitive.Input";
|
1661
1410
|
|
1662
1411
|
// src/primitives/composer/ComposerSend.tsx
|
1663
|
-
import { forwardRef as
|
1412
|
+
import { forwardRef as forwardRef12 } from "react";
|
1664
1413
|
import { Primitive as Primitive7 } from "@radix-ui/react-primitive";
|
1665
|
-
import { jsx as
|
1666
|
-
var ComposerPrimitiveSend =
|
1414
|
+
import { jsx as jsx20 } from "react/jsx-runtime";
|
1415
|
+
var ComposerPrimitiveSend = forwardRef12(({ disabled, ...rest }, ref) => {
|
1667
1416
|
const { useComposer } = useComposerContext();
|
1668
1417
|
const hasValue = useComposer((c) => c.isEditing && c.value.length > 0);
|
1669
|
-
return /* @__PURE__ */
|
1418
|
+
return /* @__PURE__ */ jsx20(
|
1670
1419
|
Primitive7.button,
|
1671
1420
|
{
|
1672
1421
|
type: "submit",
|
@@ -1717,10 +1466,10 @@ __export(thread_exports, {
|
|
1717
1466
|
|
1718
1467
|
// src/primitives/thread/ThreadRoot.tsx
|
1719
1468
|
import { Primitive as Primitive8 } from "@radix-ui/react-primitive";
|
1720
|
-
import { forwardRef as
|
1721
|
-
import { jsx as
|
1722
|
-
var ThreadPrimitiveRoot =
|
1723
|
-
return /* @__PURE__ */
|
1469
|
+
import { forwardRef as forwardRef13 } from "react";
|
1470
|
+
import { jsx as jsx21 } from "react/jsx-runtime";
|
1471
|
+
var ThreadPrimitiveRoot = forwardRef13((props, ref) => {
|
1472
|
+
return /* @__PURE__ */ jsx21(Primitive8.div, { ...props, ref });
|
1724
1473
|
});
|
1725
1474
|
ThreadPrimitiveRoot.displayName = "ThreadPrimitive.Root";
|
1726
1475
|
|
@@ -1746,17 +1495,17 @@ ThreadPrimitiveIf.displayName = "ThreadPrimitive.If";
|
|
1746
1495
|
// src/primitives/thread/ThreadViewport.tsx
|
1747
1496
|
import { useComposedRefs as useComposedRefs4 } from "@radix-ui/react-compose-refs";
|
1748
1497
|
import { Primitive as Primitive9 } from "@radix-ui/react-primitive";
|
1749
|
-
import { forwardRef as
|
1498
|
+
import { forwardRef as forwardRef14 } from "react";
|
1750
1499
|
|
1751
1500
|
// src/primitive-hooks/thread/useThreadViewportAutoScroll.tsx
|
1752
1501
|
import { useComposedRefs as useComposedRefs3 } from "@radix-ui/react-compose-refs";
|
1753
|
-
import { useRef as
|
1502
|
+
import { useRef as useRef4 } from "react";
|
1754
1503
|
|
1755
1504
|
// src/utils/hooks/useOnResizeContent.tsx
|
1756
|
-
import { useCallbackRef as
|
1505
|
+
import { useCallbackRef as useCallbackRef2 } from "@radix-ui/react-use-callback-ref";
|
1757
1506
|
import { useCallback as useCallback16 } from "react";
|
1758
1507
|
var useOnResizeContent = (callback) => {
|
1759
|
-
const callbackRef =
|
1508
|
+
const callbackRef = useCallbackRef2(callback);
|
1760
1509
|
const refCallback = useCallback16(
|
1761
1510
|
(el) => {
|
1762
1511
|
const resizeObserver = new ResizeObserver(() => {
|
@@ -1793,12 +1542,12 @@ var useOnResizeContent = (callback) => {
|
|
1793
1542
|
};
|
1794
1543
|
|
1795
1544
|
// src/utils/hooks/useOnScrollToBottom.tsx
|
1796
|
-
import { useCallbackRef as
|
1797
|
-
import { useEffect as
|
1545
|
+
import { useCallbackRef as useCallbackRef3 } from "@radix-ui/react-use-callback-ref";
|
1546
|
+
import { useEffect as useEffect8 } from "react";
|
1798
1547
|
var useOnScrollToBottom = (callback) => {
|
1799
|
-
const callbackRef =
|
1548
|
+
const callbackRef = useCallbackRef3(callback);
|
1800
1549
|
const { useViewport } = useThreadContext();
|
1801
|
-
|
1550
|
+
useEffect8(() => {
|
1802
1551
|
return useViewport.getState().onScrollToBottom(() => {
|
1803
1552
|
callbackRef();
|
1804
1553
|
});
|
@@ -1809,10 +1558,10 @@ var useOnScrollToBottom = (callback) => {
|
|
1809
1558
|
var useThreadViewportAutoScroll = ({
|
1810
1559
|
autoScroll = true
|
1811
1560
|
}) => {
|
1812
|
-
const divRef =
|
1561
|
+
const divRef = useRef4(null);
|
1813
1562
|
const { useViewport } = useThreadContext();
|
1814
|
-
const lastScrollTop =
|
1815
|
-
const isScrollingToBottomRef =
|
1563
|
+
const lastScrollTop = useRef4(0);
|
1564
|
+
const isScrollingToBottomRef = useRef4(false);
|
1816
1565
|
const scrollToBottom = (behavior) => {
|
1817
1566
|
const div = divRef.current;
|
1818
1567
|
if (!div || !autoScroll) return;
|
@@ -1857,13 +1606,13 @@ var useThreadViewportAutoScroll = ({
|
|
1857
1606
|
};
|
1858
1607
|
|
1859
1608
|
// src/primitives/thread/ThreadViewport.tsx
|
1860
|
-
import { jsx as
|
1861
|
-
var ThreadPrimitiveViewport =
|
1609
|
+
import { jsx as jsx22 } from "react/jsx-runtime";
|
1610
|
+
var ThreadPrimitiveViewport = forwardRef14(({ autoScroll, onScroll, children, ...rest }, forwardedRef) => {
|
1862
1611
|
const autoScrollRef = useThreadViewportAutoScroll({
|
1863
1612
|
autoScroll
|
1864
1613
|
});
|
1865
1614
|
const ref = useComposedRefs4(forwardedRef, autoScrollRef);
|
1866
|
-
return /* @__PURE__ */
|
1615
|
+
return /* @__PURE__ */ jsx22(Primitive9.div, { ...rest, ref, children });
|
1867
1616
|
});
|
1868
1617
|
ThreadPrimitiveViewport.displayName = "ThreadPrimitive.Viewport";
|
1869
1618
|
|
@@ -1871,15 +1620,15 @@ ThreadPrimitiveViewport.displayName = "ThreadPrimitive.Viewport";
|
|
1871
1620
|
import { memo as memo3 } from "react";
|
1872
1621
|
|
1873
1622
|
// src/context/providers/MessageProvider.tsx
|
1874
|
-
import { useEffect as
|
1875
|
-
import { create as
|
1623
|
+
import { useEffect as useEffect9, useState as useState5 } from "react";
|
1624
|
+
import { create as create13 } from "zustand";
|
1876
1625
|
|
1877
1626
|
// src/context/stores/EditComposer.ts
|
1878
|
-
import { create as
|
1627
|
+
import { create as create11 } from "zustand";
|
1879
1628
|
var makeEditComposerStore = ({
|
1880
1629
|
onEdit,
|
1881
1630
|
onSend
|
1882
|
-
}) =>
|
1631
|
+
}) => create11()((set, get, store) => ({
|
1883
1632
|
...makeBaseComposer(set, get, store),
|
1884
1633
|
canCancel: false,
|
1885
1634
|
isEditing: false,
|
@@ -1898,8 +1647,8 @@ var makeEditComposerStore = ({
|
|
1898
1647
|
}));
|
1899
1648
|
|
1900
1649
|
// src/context/stores/MessageUtils.ts
|
1901
|
-
import { create as
|
1902
|
-
var makeMessageUtilsStore = () =>
|
1650
|
+
import { create as create12 } from "zustand";
|
1651
|
+
var makeMessageUtilsStore = () => create12((set) => ({
|
1903
1652
|
isCopied: false,
|
1904
1653
|
setIsCopied: (value) => {
|
1905
1654
|
set({ isCopied: value });
|
@@ -1911,7 +1660,7 @@ var makeMessageUtilsStore = () => create13((set) => ({
|
|
1911
1660
|
}));
|
1912
1661
|
|
1913
1662
|
// src/context/providers/MessageProvider.tsx
|
1914
|
-
import { jsx as
|
1663
|
+
import { jsx as jsx23 } from "react/jsx-runtime";
|
1915
1664
|
var getIsLast = (messages, message) => {
|
1916
1665
|
return messages[messages.length - 1]?.id === message.id;
|
1917
1666
|
};
|
@@ -1933,8 +1682,8 @@ var getMessageState = (messages, getBranches, useMessage, messageIndex) => {
|
|
1933
1682
|
};
|
1934
1683
|
var useMessageContext2 = (messageIndex) => {
|
1935
1684
|
const { useThreadMessages, useThreadActions } = useThreadContext();
|
1936
|
-
const [context] =
|
1937
|
-
const useMessage =
|
1685
|
+
const [context] = useState5(() => {
|
1686
|
+
const useMessage = create13(
|
1938
1687
|
() => getMessageState(
|
1939
1688
|
useThreadMessages.getState(),
|
1940
1689
|
useThreadActions.getState().getBranches,
|
@@ -1971,7 +1720,7 @@ var useMessageContext2 = (messageIndex) => {
|
|
1971
1720
|
});
|
1972
1721
|
return { useMessage, useMessageUtils, useEditComposer };
|
1973
1722
|
});
|
1974
|
-
|
1723
|
+
useEffect9(() => {
|
1975
1724
|
const syncMessage = (thread) => {
|
1976
1725
|
const newState = getMessageState(
|
1977
1726
|
thread,
|
@@ -1995,11 +1744,11 @@ var MessageProvider = ({
|
|
1995
1744
|
children
|
1996
1745
|
}) => {
|
1997
1746
|
const context = useMessageContext2(messageIndex);
|
1998
|
-
return /* @__PURE__ */
|
1747
|
+
return /* @__PURE__ */ jsx23(MessageContext.Provider, { value: context, children });
|
1999
1748
|
};
|
2000
1749
|
|
2001
1750
|
// src/primitives/thread/ThreadMessages.tsx
|
2002
|
-
import { jsx as
|
1751
|
+
import { jsx as jsx24, jsxs as jsxs3 } from "react/jsx-runtime";
|
2003
1752
|
var DEFAULT_SYSTEM_MESSAGE = () => null;
|
2004
1753
|
var getComponents = (components) => {
|
2005
1754
|
return {
|
@@ -2016,11 +1765,11 @@ var ThreadMessageImpl = ({
|
|
2016
1765
|
const { UserMessage: UserMessage2, EditComposer: EditComposer2, AssistantMessage: AssistantMessage2, SystemMessage: SystemMessage2 } = getComponents(components);
|
2017
1766
|
return /* @__PURE__ */ jsxs3(MessageProvider, { messageIndex, children: [
|
2018
1767
|
/* @__PURE__ */ jsxs3(MessagePrimitiveIf, { user: true, children: [
|
2019
|
-
/* @__PURE__ */
|
2020
|
-
/* @__PURE__ */
|
1768
|
+
/* @__PURE__ */ jsx24(ComposerPrimitiveIf, { editing: false, children: /* @__PURE__ */ jsx24(UserMessage2, {}) }),
|
1769
|
+
/* @__PURE__ */ jsx24(ComposerPrimitiveIf, { editing: true, children: /* @__PURE__ */ jsx24(EditComposer2, {}) })
|
2021
1770
|
] }),
|
2022
|
-
/* @__PURE__ */
|
2023
|
-
/* @__PURE__ */
|
1771
|
+
/* @__PURE__ */ jsx24(MessagePrimitiveIf, { assistant: true, children: /* @__PURE__ */ jsx24(AssistantMessage2, {}) }),
|
1772
|
+
/* @__PURE__ */ jsx24(MessagePrimitiveIf, { system: true, children: /* @__PURE__ */ jsx24(SystemMessage2, {}) })
|
2024
1773
|
] });
|
2025
1774
|
};
|
2026
1775
|
var ThreadMessage = memo3(
|
@@ -2035,7 +1784,7 @@ var ThreadPrimitiveMessagesImpl = ({
|
|
2035
1784
|
if (messagesLength === 0) return null;
|
2036
1785
|
return new Array(messagesLength).fill(null).map((_, idx) => {
|
2037
1786
|
const messageIndex = idx;
|
2038
|
-
return /* @__PURE__ */
|
1787
|
+
return /* @__PURE__ */ jsx24(
|
2039
1788
|
ThreadMessage,
|
2040
1789
|
{
|
2041
1790
|
messageIndex,
|
@@ -2065,543 +1814,75 @@ var ThreadPrimitiveSuggestion = createActionButton(
|
|
2065
1814
|
);
|
2066
1815
|
|
2067
1816
|
// src/runtimes/local/useLocalRuntime.tsx
|
2068
|
-
import { useInsertionEffect as useInsertionEffect3, useState as
|
2069
|
-
|
2070
|
-
// src/runtimes/core/BaseAssistantRuntime.tsx
|
2071
|
-
var BaseAssistantRuntime = class {
|
2072
|
-
constructor(_thread) {
|
2073
|
-
this._thread = _thread;
|
2074
|
-
this._thread = _thread;
|
2075
|
-
}
|
2076
|
-
get thread() {
|
2077
|
-
return this._thread;
|
2078
|
-
}
|
2079
|
-
set thread(thread) {
|
2080
|
-
this._thread = thread;
|
2081
|
-
this.subscriptionHandler();
|
2082
|
-
}
|
2083
|
-
_subscriptions = /* @__PURE__ */ new Set();
|
2084
|
-
subscribe(callback) {
|
2085
|
-
this._subscriptions.add(callback);
|
2086
|
-
return () => this._subscriptions.delete(callback);
|
2087
|
-
}
|
2088
|
-
subscriptionHandler = () => {
|
2089
|
-
for (const callback of this._subscriptions) callback();
|
2090
|
-
};
|
2091
|
-
};
|
2092
|
-
|
2093
|
-
// src/internal.ts
|
2094
|
-
var internal_exports = {};
|
2095
|
-
__export(internal_exports, {
|
2096
|
-
BaseAssistantRuntime: () => BaseAssistantRuntime,
|
2097
|
-
MessageRepository: () => MessageRepository,
|
2098
|
-
ProxyConfigProvider: () => ProxyConfigProvider,
|
2099
|
-
TooltipIconButton: () => TooltipIconButton,
|
2100
|
-
generateId: () => generateId,
|
2101
|
-
useSmooth: () => useSmooth,
|
2102
|
-
useSmoothStatus: () => useSmoothStatus,
|
2103
|
-
withSmoothContextProvider: () => withSmoothContextProvider
|
2104
|
-
});
|
2105
|
-
|
2106
|
-
// src/utils/idUtils.tsx
|
2107
|
-
import { customAlphabet } from "nanoid/non-secure";
|
2108
|
-
var generateId = customAlphabet(
|
2109
|
-
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
2110
|
-
7
|
2111
|
-
);
|
2112
|
-
var optimisticPrefix = "__optimistic__";
|
2113
|
-
var generateOptimisticId = () => `${optimisticPrefix}${generateId()}`;
|
1817
|
+
import { useInsertionEffect as useInsertionEffect3, useState as useState7 } from "react";
|
2114
1818
|
|
2115
|
-
// src/runtimes/edge/converters/
|
2116
|
-
var
|
2117
|
-
|
2118
|
-
|
2119
|
-
|
2120
|
-
|
2121
|
-
|
2122
|
-
|
2123
|
-
|
2124
|
-
|
2125
|
-
|
2126
|
-
|
2127
|
-
|
2128
|
-
|
2129
|
-
|
2130
|
-
|
2131
|
-
|
2132
|
-
|
2133
|
-
|
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) => {
|
2134
1869
|
if (part.type === "tool-call") {
|
2135
1870
|
return {
|
2136
|
-
|
2137
|
-
|
1871
|
+
type: "tool-call",
|
1872
|
+
toolCallId: part.toolCallId,
|
1873
|
+
toolName: part.toolName,
|
1874
|
+
argsText: JSON.stringify(part.args),
|
1875
|
+
args: part.args
|
2138
1876
|
};
|
2139
1877
|
}
|
2140
1878
|
return part;
|
2141
|
-
})
|
2142
|
-
|
2143
|
-
|
2144
|
-
|
2145
|
-
|
2146
|
-
|
2147
|
-
|
2148
|
-
content: message.content
|
2149
|
-
};
|
2150
|
-
case "system":
|
2151
|
-
return {
|
2152
|
-
...commonProps,
|
2153
|
-
role,
|
2154
|
-
content: message.content
|
2155
|
-
};
|
2156
|
-
default: {
|
2157
|
-
const unsupportedRole = role;
|
2158
|
-
throw new Error(`Unknown message role: ${unsupportedRole}`);
|
2159
|
-
}
|
2160
|
-
}
|
2161
|
-
};
|
2162
|
-
|
2163
|
-
// src/runtimes/utils/MessageRepository.tsx
|
2164
|
-
var findHead = (message) => {
|
2165
|
-
if (message.next) return findHead(message.next);
|
2166
|
-
return message;
|
2167
|
-
};
|
2168
|
-
var MessageRepository = class {
|
2169
|
-
messages = /* @__PURE__ */ new Map();
|
2170
|
-
// message_id -> item
|
2171
|
-
head = null;
|
2172
|
-
root = {
|
2173
|
-
children: []
|
2174
|
-
};
|
2175
|
-
performOp(newParent, child, operation) {
|
2176
|
-
const parentOrRoot = child.prev ?? this.root;
|
2177
|
-
const newParentOrRoot = newParent ?? this.root;
|
2178
|
-
if (operation === "relink" && parentOrRoot === newParentOrRoot) return;
|
2179
|
-
if (operation !== "link") {
|
2180
|
-
parentOrRoot.children = parentOrRoot.children.filter(
|
2181
|
-
(m) => m !== child.current.id
|
2182
|
-
);
|
2183
|
-
if (child.prev?.next === child) {
|
2184
|
-
const fallbackId = child.prev.children.at(-1);
|
2185
|
-
const fallback = fallbackId ? this.messages.get(fallbackId) : null;
|
2186
|
-
if (fallback === void 0) {
|
2187
|
-
throw new Error(
|
2188
|
-
"MessageRepository(performOp/cut): Fallback sibling message not found. This is likely an internal bug in assistant-ui."
|
2189
|
-
);
|
2190
|
-
}
|
2191
|
-
child.prev.next = fallback;
|
2192
|
-
}
|
2193
|
-
}
|
2194
|
-
if (operation !== "cut") {
|
2195
|
-
newParentOrRoot.children = [
|
2196
|
-
...newParentOrRoot.children,
|
2197
|
-
child.current.id
|
2198
|
-
];
|
2199
|
-
if (newParent && (findHead(child) === this.head || newParent.next === null)) {
|
2200
|
-
newParent.next = child;
|
2201
|
-
}
|
2202
|
-
child.prev = newParent;
|
2203
|
-
}
|
2204
|
-
}
|
2205
|
-
getMessages() {
|
2206
|
-
const messages = new Array(this.head?.level ?? 0);
|
2207
|
-
for (let current = this.head; current; current = current.prev) {
|
2208
|
-
messages[current.level] = current.current;
|
2209
|
-
}
|
2210
|
-
return messages;
|
2211
|
-
}
|
2212
|
-
addOrUpdateMessage(parentId, message) {
|
2213
|
-
const existingItem = this.messages.get(message.id);
|
2214
|
-
const prev = parentId ? this.messages.get(parentId) : null;
|
2215
|
-
if (prev === void 0)
|
2216
|
-
throw new Error(
|
2217
|
-
"MessageRepository(addOrUpdateMessage): Parent message not found. This is likely an internal bug in assistant-ui."
|
2218
|
-
);
|
2219
|
-
if (existingItem) {
|
2220
|
-
existingItem.current = message;
|
2221
|
-
this.performOp(prev, existingItem, "relink");
|
2222
|
-
return;
|
2223
|
-
}
|
2224
|
-
const newItem = {
|
2225
|
-
prev,
|
2226
|
-
current: message,
|
2227
|
-
next: null,
|
2228
|
-
children: [],
|
2229
|
-
level: prev ? prev.level + 1 : 0
|
2230
|
-
};
|
2231
|
-
this.messages.set(message.id, newItem);
|
2232
|
-
this.performOp(prev, newItem, "link");
|
2233
|
-
if (this.head === prev) {
|
2234
|
-
this.head = newItem;
|
2235
|
-
}
|
2236
|
-
}
|
2237
|
-
getMessage(messageId) {
|
2238
|
-
const message = this.messages.get(messageId);
|
2239
|
-
if (!message)
|
2240
|
-
throw new Error(
|
2241
|
-
"MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui."
|
2242
|
-
);
|
2243
|
-
return {
|
2244
|
-
parentId: message.prev?.current.id ?? null,
|
2245
|
-
message: message.current
|
2246
|
-
};
|
2247
|
-
}
|
2248
|
-
appendOptimisticMessage(parentId, message) {
|
2249
|
-
let optimisticId;
|
2250
|
-
do {
|
2251
|
-
optimisticId = generateOptimisticId();
|
2252
|
-
} while (this.messages.has(optimisticId));
|
2253
|
-
this.addOrUpdateMessage(
|
2254
|
-
parentId,
|
2255
|
-
fromCoreMessage(message, {
|
2256
|
-
id: optimisticId,
|
2257
|
-
status: { type: "running" }
|
2258
|
-
})
|
2259
|
-
);
|
2260
|
-
return optimisticId;
|
2261
|
-
}
|
2262
|
-
deleteMessage(messageId, replacementId) {
|
2263
|
-
const message = this.messages.get(messageId);
|
2264
|
-
if (!message)
|
2265
|
-
throw new Error(
|
2266
|
-
"MessageRepository(deleteMessage): Optimistic message not found. This is likely an internal bug in assistant-ui."
|
2267
|
-
);
|
2268
|
-
const replacement = replacementId === void 0 ? message.prev : replacementId === null ? null : this.messages.get(replacementId);
|
2269
|
-
if (replacement === void 0)
|
2270
|
-
throw new Error(
|
2271
|
-
"MessageRepository(deleteMessage): Replacement not found. This is likely an internal bug in assistant-ui."
|
2272
|
-
);
|
2273
|
-
for (const child of message.children) {
|
2274
|
-
const childMessage = this.messages.get(child);
|
2275
|
-
if (!childMessage)
|
2276
|
-
throw new Error(
|
2277
|
-
"MessageRepository(deleteMessage): Child message not found. This is likely an internal bug in assistant-ui."
|
2278
|
-
);
|
2279
|
-
this.performOp(replacement, childMessage, "relink");
|
2280
|
-
}
|
2281
|
-
this.performOp(null, message, "cut");
|
2282
|
-
this.messages.delete(messageId);
|
2283
|
-
if (this.head === message) {
|
2284
|
-
this.head = replacement ? findHead(replacement) : null;
|
2285
|
-
}
|
2286
|
-
}
|
2287
|
-
getBranches(messageId) {
|
2288
|
-
const message = this.messages.get(messageId);
|
2289
|
-
if (!message)
|
2290
|
-
throw new Error(
|
2291
|
-
"MessageRepository(getBranches): Message not found. This is likely an internal bug in assistant-ui."
|
2292
|
-
);
|
2293
|
-
const { children } = message.prev ?? this.root;
|
2294
|
-
return children;
|
2295
|
-
}
|
2296
|
-
switchToBranch(messageId) {
|
2297
|
-
const message = this.messages.get(messageId);
|
2298
|
-
if (!message)
|
2299
|
-
throw new Error(
|
2300
|
-
"MessageRepository(switchToBranch): Branch not found. This is likely an internal bug in assistant-ui."
|
2301
|
-
);
|
2302
|
-
if (message.prev) {
|
2303
|
-
message.prev.next = message;
|
2304
|
-
}
|
2305
|
-
this.head = findHead(message);
|
2306
|
-
}
|
2307
|
-
resetHead(messageId) {
|
2308
|
-
if (messageId === null) {
|
2309
|
-
this.head = null;
|
2310
|
-
return;
|
2311
|
-
}
|
2312
|
-
const message = this.messages.get(messageId);
|
2313
|
-
if (!message)
|
2314
|
-
throw new Error(
|
2315
|
-
"MessageRepository(resetHead): Branch not found. This is likely an internal bug in assistant-ui."
|
2316
|
-
);
|
2317
|
-
this.head = message;
|
2318
|
-
for (let current = message; current; current = current.prev) {
|
2319
|
-
if (current.prev) {
|
2320
|
-
current.prev.next = current;
|
2321
|
-
}
|
2322
|
-
}
|
2323
|
-
}
|
2324
|
-
};
|
2325
|
-
|
2326
|
-
// src/ui/base/tooltip-icon-button.tsx
|
2327
|
-
import { forwardRef as forwardRef18 } from "react";
|
2328
|
-
|
2329
|
-
// src/ui/base/tooltip.tsx
|
2330
|
-
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
2331
|
-
|
2332
|
-
// src/ui/utils/withDefaults.tsx
|
2333
|
-
import {
|
2334
|
-
forwardRef as forwardRef16
|
2335
|
-
} from "react";
|
2336
|
-
import classNames from "classnames";
|
2337
|
-
import { jsx as jsx26 } from "react/jsx-runtime";
|
2338
|
-
var withDefaultProps = ({
|
2339
|
-
className,
|
2340
|
-
...defaultProps
|
2341
|
-
}) => ({ className: classNameProp, ...props }) => {
|
2342
|
-
return {
|
2343
|
-
className: classNames(className, classNameProp),
|
2344
|
-
...defaultProps,
|
2345
|
-
...props
|
2346
|
-
};
|
2347
|
-
};
|
2348
|
-
var withDefaults = (Component, defaultProps) => {
|
2349
|
-
const getProps = withDefaultProps(defaultProps);
|
2350
|
-
const WithDefaults = forwardRef16(
|
2351
|
-
(props, ref) => {
|
2352
|
-
const ComponentAsAny = Component;
|
2353
|
-
return /* @__PURE__ */ jsx26(ComponentAsAny, { ...getProps(props), ref });
|
2354
|
-
}
|
2355
|
-
);
|
2356
|
-
WithDefaults.displayName = "withDefaults(" + (typeof Component === "string" ? Component : Component.displayName) + ")";
|
2357
|
-
return WithDefaults;
|
2358
|
-
};
|
2359
|
-
|
2360
|
-
// src/ui/base/tooltip.tsx
|
2361
|
-
import { jsx as jsx27 } from "react/jsx-runtime";
|
2362
|
-
var Tooltip = (props) => {
|
2363
|
-
return /* @__PURE__ */ jsx27(TooltipPrimitive.Provider, { children: /* @__PURE__ */ jsx27(TooltipPrimitive.Root, { ...props }) });
|
2364
|
-
};
|
2365
|
-
Tooltip.displayName = "Tooltip";
|
2366
|
-
var TooltipTrigger = TooltipPrimitive.Trigger;
|
2367
|
-
var TooltipContent = withDefaults(TooltipPrimitive.Content, {
|
2368
|
-
sideOffset: 4,
|
2369
|
-
className: "aui-tooltip-content"
|
2370
|
-
});
|
2371
|
-
TooltipContent.displayName = "TooltipContent";
|
2372
|
-
|
2373
|
-
// src/ui/base/button.tsx
|
2374
|
-
import { cva } from "class-variance-authority";
|
2375
|
-
import { Primitive as Primitive10 } from "@radix-ui/react-primitive";
|
2376
|
-
import { forwardRef as forwardRef17 } from "react";
|
2377
|
-
import { jsx as jsx28 } from "react/jsx-runtime";
|
2378
|
-
var buttonVariants = cva("aui-button", {
|
2379
|
-
variants: {
|
2380
|
-
variant: {
|
2381
|
-
default: "aui-button-primary",
|
2382
|
-
outline: "aui-button-outline",
|
2383
|
-
ghost: "aui-button-ghost"
|
2384
|
-
},
|
2385
|
-
size: {
|
2386
|
-
default: "aui-button-medium",
|
2387
|
-
icon: "aui-button-icon"
|
2388
|
-
}
|
2389
|
-
},
|
2390
|
-
defaultVariants: {
|
2391
|
-
variant: "default",
|
2392
|
-
size: "default"
|
2393
|
-
}
|
2394
|
-
});
|
2395
|
-
var Button = forwardRef17(
|
2396
|
-
({ className, variant, size, ...props }, ref) => {
|
2397
|
-
return /* @__PURE__ */ jsx28(
|
2398
|
-
Primitive10.button,
|
2399
|
-
{
|
2400
|
-
className: buttonVariants({ variant, size, className }),
|
2401
|
-
...props,
|
2402
|
-
ref
|
2403
|
-
}
|
2404
|
-
);
|
2405
|
-
}
|
2406
|
-
);
|
2407
|
-
Button.displayName = "Button";
|
2408
|
-
|
2409
|
-
// src/ui/base/tooltip-icon-button.tsx
|
2410
|
-
import { jsx as jsx29, jsxs as jsxs4 } from "react/jsx-runtime";
|
2411
|
-
var TooltipIconButton = forwardRef18(({ children, tooltip, side = "bottom", ...rest }, ref) => {
|
2412
|
-
return /* @__PURE__ */ jsxs4(Tooltip, { children: [
|
2413
|
-
/* @__PURE__ */ jsx29(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxs4(Button, { variant: "ghost", size: "icon", ...rest, ref, children: [
|
2414
|
-
children,
|
2415
|
-
/* @__PURE__ */ jsx29("span", { className: "aui-sr-only", children: tooltip })
|
2416
|
-
] }) }),
|
2417
|
-
/* @__PURE__ */ jsx29(TooltipContent, { side, children: tooltip })
|
2418
|
-
] });
|
2419
|
-
});
|
2420
|
-
TooltipIconButton.displayName = "TooltipIconButton";
|
2421
|
-
|
2422
|
-
// src/runtimes/edge/converters/toLanguageModelMessages.ts
|
2423
|
-
var assistantMessageSplitter = () => {
|
2424
|
-
const stash = [];
|
2425
|
-
let assistantMessage = {
|
2426
|
-
role: "assistant",
|
2427
|
-
content: []
|
2428
|
-
};
|
2429
|
-
let toolMessage = {
|
2430
|
-
role: "tool",
|
2431
|
-
content: []
|
2432
|
-
};
|
2433
|
-
return {
|
2434
|
-
addTextContentPart: (part) => {
|
2435
|
-
if (toolMessage.content.length > 0) {
|
2436
|
-
stash.push(assistantMessage);
|
2437
|
-
stash.push(toolMessage);
|
2438
|
-
assistantMessage = {
|
2439
|
-
role: "assistant",
|
2440
|
-
content: []
|
2441
|
-
};
|
2442
|
-
toolMessage = {
|
2443
|
-
role: "tool",
|
2444
|
-
content: []
|
2445
|
-
};
|
2446
|
-
}
|
2447
|
-
assistantMessage.content.push(part);
|
2448
|
-
},
|
2449
|
-
addToolCallPart: (part) => {
|
2450
|
-
assistantMessage.content.push({
|
2451
|
-
type: "tool-call",
|
2452
|
-
toolCallId: part.toolCallId,
|
2453
|
-
toolName: part.toolName,
|
2454
|
-
args: part.args
|
2455
|
-
});
|
2456
|
-
if (part.result) {
|
2457
|
-
toolMessage.content.push({
|
2458
|
-
type: "tool-result",
|
2459
|
-
toolCallId: part.toolCallId,
|
2460
|
-
toolName: part.toolName,
|
2461
|
-
result: part.result
|
2462
|
-
// isError
|
2463
|
-
});
|
2464
|
-
}
|
2465
|
-
},
|
2466
|
-
getMessages: () => {
|
2467
|
-
if (toolMessage.content.length > 0) {
|
2468
|
-
return [...stash, assistantMessage, toolMessage];
|
2469
|
-
}
|
2470
|
-
return [...stash, assistantMessage];
|
2471
|
-
}
|
2472
|
-
};
|
2473
|
-
};
|
2474
|
-
function toLanguageModelMessages(message) {
|
2475
|
-
return message.flatMap((message2) => {
|
2476
|
-
const role = message2.role;
|
2477
|
-
switch (role) {
|
2478
|
-
case "system": {
|
2479
|
-
return [{ role: "system", content: message2.content[0].text }];
|
2480
|
-
}
|
2481
|
-
case "user": {
|
2482
|
-
const msg = {
|
2483
|
-
role: "user",
|
2484
|
-
content: message2.content.map(
|
2485
|
-
(part) => {
|
2486
|
-
const type = part.type;
|
2487
|
-
switch (type) {
|
2488
|
-
case "text": {
|
2489
|
-
return part;
|
2490
|
-
}
|
2491
|
-
case "image": {
|
2492
|
-
return {
|
2493
|
-
type: "image",
|
2494
|
-
image: new URL(part.image)
|
2495
|
-
};
|
2496
|
-
}
|
2497
|
-
default: {
|
2498
|
-
const unhandledType = type;
|
2499
|
-
throw new Error(
|
2500
|
-
`Unspported content part type: ${unhandledType}`
|
2501
|
-
);
|
2502
|
-
}
|
2503
|
-
}
|
2504
|
-
}
|
2505
|
-
)
|
2506
|
-
};
|
2507
|
-
return [msg];
|
2508
|
-
}
|
2509
|
-
case "assistant": {
|
2510
|
-
const splitter = assistantMessageSplitter();
|
2511
|
-
for (const part of message2.content) {
|
2512
|
-
const type = part.type;
|
2513
|
-
switch (type) {
|
2514
|
-
case "text": {
|
2515
|
-
splitter.addTextContentPart(part);
|
2516
|
-
break;
|
2517
|
-
}
|
2518
|
-
case "tool-call": {
|
2519
|
-
splitter.addToolCallPart(part);
|
2520
|
-
break;
|
2521
|
-
}
|
2522
|
-
default: {
|
2523
|
-
const unhandledType = type;
|
2524
|
-
throw new Error(`Unhandled content part type: ${unhandledType}`);
|
2525
|
-
}
|
2526
|
-
}
|
2527
|
-
}
|
2528
|
-
return splitter.getMessages();
|
2529
|
-
}
|
2530
|
-
default: {
|
2531
|
-
const unhandledRole = role;
|
2532
|
-
throw new Error(`Unknown message role: ${unhandledRole}`);
|
2533
|
-
}
|
2534
|
-
}
|
2535
|
-
});
|
2536
|
-
}
|
2537
|
-
|
2538
|
-
// src/runtimes/edge/converters/fromLanguageModelMessages.ts
|
2539
|
-
var fromLanguageModelMessages = (lm, { mergeRoundtrips }) => {
|
2540
|
-
const messages = [];
|
2541
|
-
for (const lmMessage of lm) {
|
2542
|
-
const role = lmMessage.role;
|
2543
|
-
switch (role) {
|
2544
|
-
case "system": {
|
2545
|
-
messages.push({
|
2546
|
-
role: "system",
|
2547
|
-
content: [
|
2548
|
-
{
|
2549
|
-
type: "text",
|
2550
|
-
text: lmMessage.content
|
2551
|
-
}
|
2552
|
-
]
|
2553
|
-
});
|
2554
|
-
break;
|
2555
|
-
}
|
2556
|
-
case "user": {
|
2557
|
-
messages.push({
|
2558
|
-
role: "user",
|
2559
|
-
content: lmMessage.content.map((part) => {
|
2560
|
-
const type = part.type;
|
2561
|
-
switch (type) {
|
2562
|
-
case "text": {
|
2563
|
-
return {
|
2564
|
-
type: "text",
|
2565
|
-
text: part.text
|
2566
|
-
};
|
2567
|
-
}
|
2568
|
-
case "image": {
|
2569
|
-
if (part.image instanceof URL) {
|
2570
|
-
return {
|
2571
|
-
type: "image",
|
2572
|
-
image: part.image.href
|
2573
|
-
};
|
2574
|
-
}
|
2575
|
-
throw new Error("Only images with URL data are supported");
|
2576
|
-
}
|
2577
|
-
default: {
|
2578
|
-
const unhandledType = type;
|
2579
|
-
throw new Error(`Unknown content part type: ${unhandledType}`);
|
2580
|
-
}
|
2581
|
-
}
|
2582
|
-
})
|
2583
|
-
});
|
2584
|
-
break;
|
2585
|
-
}
|
2586
|
-
case "assistant": {
|
2587
|
-
const newContent = lmMessage.content.map((part) => {
|
2588
|
-
if (part.type === "tool-call") {
|
2589
|
-
return {
|
2590
|
-
type: "tool-call",
|
2591
|
-
toolCallId: part.toolCallId,
|
2592
|
-
toolName: part.toolName,
|
2593
|
-
argsText: JSON.stringify(part.args),
|
2594
|
-
args: part.args
|
2595
|
-
};
|
2596
|
-
}
|
2597
|
-
return part;
|
2598
|
-
});
|
2599
|
-
if (mergeRoundtrips) {
|
2600
|
-
const previousMessage = messages[messages.length - 1];
|
2601
|
-
if (previousMessage?.role === "assistant") {
|
2602
|
-
previousMessage.content.push(...newContent);
|
2603
|
-
break;
|
2604
|
-
}
|
1879
|
+
});
|
1880
|
+
if (mergeRoundtrips) {
|
1881
|
+
const previousMessage = messages[messages.length - 1];
|
1882
|
+
if (previousMessage?.role === "assistant") {
|
1883
|
+
previousMessage.content.push(...newContent);
|
1884
|
+
break;
|
1885
|
+
}
|
2605
1886
|
}
|
2606
1887
|
messages.push({
|
2607
1888
|
role: "assistant",
|
@@ -2639,45 +1920,6 @@ var fromLanguageModelMessages = (lm, { mergeRoundtrips }) => {
|
|
2639
1920
|
return messages;
|
2640
1921
|
};
|
2641
1922
|
|
2642
|
-
// src/runtimes/edge/converters/toCoreMessages.ts
|
2643
|
-
var toCoreMessages = (message) => {
|
2644
|
-
return message.map(toCoreMessage);
|
2645
|
-
};
|
2646
|
-
var toCoreMessage = (message) => {
|
2647
|
-
const role = message.role;
|
2648
|
-
switch (role) {
|
2649
|
-
case "assistant":
|
2650
|
-
return {
|
2651
|
-
role,
|
2652
|
-
content: message.content.map((part) => {
|
2653
|
-
if (part.type === "ui") throw new Error("UI parts are not supported");
|
2654
|
-
if (part.type === "tool-call") {
|
2655
|
-
const { argsText, ...rest } = part;
|
2656
|
-
return rest;
|
2657
|
-
}
|
2658
|
-
return part;
|
2659
|
-
})
|
2660
|
-
};
|
2661
|
-
case "user":
|
2662
|
-
return {
|
2663
|
-
role,
|
2664
|
-
content: message.content.map((part) => {
|
2665
|
-
if (part.type === "ui") throw new Error("UI parts are not supported");
|
2666
|
-
return part;
|
2667
|
-
})
|
2668
|
-
};
|
2669
|
-
case "system":
|
2670
|
-
return {
|
2671
|
-
role,
|
2672
|
-
content: message.content
|
2673
|
-
};
|
2674
|
-
default: {
|
2675
|
-
const unsupportedRole = role;
|
2676
|
-
throw new Error(`Unknown message role: ${unsupportedRole}`);
|
2677
|
-
}
|
2678
|
-
}
|
2679
|
-
};
|
2680
|
-
|
2681
1923
|
// src/runtimes/edge/converters/fromLanguageModelTools.ts
|
2682
1924
|
var fromLanguageModelTools = (tools) => {
|
2683
1925
|
return Object.fromEntries(
|
@@ -2691,20 +1933,8 @@ var fromLanguageModelTools = (tools) => {
|
|
2691
1933
|
);
|
2692
1934
|
};
|
2693
1935
|
|
2694
|
-
// src/runtimes/edge/converters/toLanguageModelTools.ts
|
2695
|
-
import { z as z2 } from "zod";
|
2696
|
-
import zodToJsonSchema from "zod-to-json-schema";
|
2697
|
-
var toLanguageModelTools = (tools) => {
|
2698
|
-
return Object.entries(tools).map(([name, tool]) => ({
|
2699
|
-
type: "function",
|
2700
|
-
name,
|
2701
|
-
...tool.description ? { description: tool.description } : void 0,
|
2702
|
-
parameters: tool.parameters instanceof z2.ZodType ? zodToJsonSchema(tool.parameters) : tool.parameters
|
2703
|
-
}));
|
2704
|
-
};
|
2705
|
-
|
2706
1936
|
// src/runtimes/edge/useEdgeRuntime.ts
|
2707
|
-
import { useState as
|
1937
|
+
import { useState as useState6 } from "react";
|
2708
1938
|
|
2709
1939
|
// src/runtimes/edge/streams/assistantDecoderStream.ts
|
2710
1940
|
function assistantDecoderStream() {
|
@@ -2810,589 +2040,6 @@ function chunkByLineStream() {
|
|
2810
2040
|
});
|
2811
2041
|
}
|
2812
2042
|
|
2813
|
-
// src/runtimes/edge/partial-json/parse-partial-json.ts
|
2814
|
-
import sjson from "secure-json-parse";
|
2815
|
-
|
2816
|
-
// src/runtimes/edge/partial-json/fix-json.ts
|
2817
|
-
function fixJson(input) {
|
2818
|
-
const stack = ["ROOT"];
|
2819
|
-
let lastValidIndex = -1;
|
2820
|
-
let literalStart = null;
|
2821
|
-
function processValueStart(char, i, swapState) {
|
2822
|
-
{
|
2823
|
-
switch (char) {
|
2824
|
-
case '"': {
|
2825
|
-
lastValidIndex = i;
|
2826
|
-
stack.pop();
|
2827
|
-
stack.push(swapState);
|
2828
|
-
stack.push("INSIDE_STRING");
|
2829
|
-
break;
|
2830
|
-
}
|
2831
|
-
case "f":
|
2832
|
-
case "t":
|
2833
|
-
case "n": {
|
2834
|
-
lastValidIndex = i;
|
2835
|
-
literalStart = i;
|
2836
|
-
stack.pop();
|
2837
|
-
stack.push(swapState);
|
2838
|
-
stack.push("INSIDE_LITERAL");
|
2839
|
-
break;
|
2840
|
-
}
|
2841
|
-
case "-": {
|
2842
|
-
stack.pop();
|
2843
|
-
stack.push(swapState);
|
2844
|
-
stack.push("INSIDE_NUMBER");
|
2845
|
-
break;
|
2846
|
-
}
|
2847
|
-
case "0":
|
2848
|
-
case "1":
|
2849
|
-
case "2":
|
2850
|
-
case "3":
|
2851
|
-
case "4":
|
2852
|
-
case "5":
|
2853
|
-
case "6":
|
2854
|
-
case "7":
|
2855
|
-
case "8":
|
2856
|
-
case "9": {
|
2857
|
-
lastValidIndex = i;
|
2858
|
-
stack.pop();
|
2859
|
-
stack.push(swapState);
|
2860
|
-
stack.push("INSIDE_NUMBER");
|
2861
|
-
break;
|
2862
|
-
}
|
2863
|
-
case "{": {
|
2864
|
-
lastValidIndex = i;
|
2865
|
-
stack.pop();
|
2866
|
-
stack.push(swapState);
|
2867
|
-
stack.push("INSIDE_OBJECT_START");
|
2868
|
-
break;
|
2869
|
-
}
|
2870
|
-
case "[": {
|
2871
|
-
lastValidIndex = i;
|
2872
|
-
stack.pop();
|
2873
|
-
stack.push(swapState);
|
2874
|
-
stack.push("INSIDE_ARRAY_START");
|
2875
|
-
break;
|
2876
|
-
}
|
2877
|
-
}
|
2878
|
-
}
|
2879
|
-
}
|
2880
|
-
function processAfterObjectValue(char, i) {
|
2881
|
-
switch (char) {
|
2882
|
-
case ",": {
|
2883
|
-
stack.pop();
|
2884
|
-
stack.push("INSIDE_OBJECT_AFTER_COMMA");
|
2885
|
-
break;
|
2886
|
-
}
|
2887
|
-
case "}": {
|
2888
|
-
lastValidIndex = i;
|
2889
|
-
stack.pop();
|
2890
|
-
break;
|
2891
|
-
}
|
2892
|
-
}
|
2893
|
-
}
|
2894
|
-
function processAfterArrayValue(char, i) {
|
2895
|
-
switch (char) {
|
2896
|
-
case ",": {
|
2897
|
-
stack.pop();
|
2898
|
-
stack.push("INSIDE_ARRAY_AFTER_COMMA");
|
2899
|
-
break;
|
2900
|
-
}
|
2901
|
-
case "]": {
|
2902
|
-
lastValidIndex = i;
|
2903
|
-
stack.pop();
|
2904
|
-
break;
|
2905
|
-
}
|
2906
|
-
}
|
2907
|
-
}
|
2908
|
-
for (let i = 0; i < input.length; i++) {
|
2909
|
-
const char = input[i];
|
2910
|
-
const currentState = stack[stack.length - 1];
|
2911
|
-
switch (currentState) {
|
2912
|
-
case "ROOT":
|
2913
|
-
processValueStart(char, i, "FINISH");
|
2914
|
-
break;
|
2915
|
-
case "INSIDE_OBJECT_START": {
|
2916
|
-
switch (char) {
|
2917
|
-
case '"': {
|
2918
|
-
stack.pop();
|
2919
|
-
stack.push("INSIDE_OBJECT_KEY");
|
2920
|
-
break;
|
2921
|
-
}
|
2922
|
-
case "}": {
|
2923
|
-
lastValidIndex = i;
|
2924
|
-
stack.pop();
|
2925
|
-
break;
|
2926
|
-
}
|
2927
|
-
}
|
2928
|
-
break;
|
2929
|
-
}
|
2930
|
-
case "INSIDE_OBJECT_AFTER_COMMA": {
|
2931
|
-
switch (char) {
|
2932
|
-
case '"': {
|
2933
|
-
stack.pop();
|
2934
|
-
stack.push("INSIDE_OBJECT_KEY");
|
2935
|
-
break;
|
2936
|
-
}
|
2937
|
-
}
|
2938
|
-
break;
|
2939
|
-
}
|
2940
|
-
case "INSIDE_OBJECT_KEY": {
|
2941
|
-
switch (char) {
|
2942
|
-
case '"': {
|
2943
|
-
stack.pop();
|
2944
|
-
stack.push("INSIDE_OBJECT_AFTER_KEY");
|
2945
|
-
break;
|
2946
|
-
}
|
2947
|
-
}
|
2948
|
-
break;
|
2949
|
-
}
|
2950
|
-
case "INSIDE_OBJECT_AFTER_KEY": {
|
2951
|
-
switch (char) {
|
2952
|
-
case ":": {
|
2953
|
-
stack.pop();
|
2954
|
-
stack.push("INSIDE_OBJECT_BEFORE_VALUE");
|
2955
|
-
break;
|
2956
|
-
}
|
2957
|
-
}
|
2958
|
-
break;
|
2959
|
-
}
|
2960
|
-
case "INSIDE_OBJECT_BEFORE_VALUE": {
|
2961
|
-
processValueStart(char, i, "INSIDE_OBJECT_AFTER_VALUE");
|
2962
|
-
break;
|
2963
|
-
}
|
2964
|
-
case "INSIDE_OBJECT_AFTER_VALUE": {
|
2965
|
-
processAfterObjectValue(char, i);
|
2966
|
-
break;
|
2967
|
-
}
|
2968
|
-
case "INSIDE_STRING": {
|
2969
|
-
switch (char) {
|
2970
|
-
case '"': {
|
2971
|
-
stack.pop();
|
2972
|
-
lastValidIndex = i;
|
2973
|
-
break;
|
2974
|
-
}
|
2975
|
-
case "\\": {
|
2976
|
-
stack.push("INSIDE_STRING_ESCAPE");
|
2977
|
-
break;
|
2978
|
-
}
|
2979
|
-
default: {
|
2980
|
-
lastValidIndex = i;
|
2981
|
-
}
|
2982
|
-
}
|
2983
|
-
break;
|
2984
|
-
}
|
2985
|
-
case "INSIDE_ARRAY_START": {
|
2986
|
-
switch (char) {
|
2987
|
-
case "]": {
|
2988
|
-
lastValidIndex = i;
|
2989
|
-
stack.pop();
|
2990
|
-
break;
|
2991
|
-
}
|
2992
|
-
default: {
|
2993
|
-
lastValidIndex = i;
|
2994
|
-
processValueStart(char, i, "INSIDE_ARRAY_AFTER_VALUE");
|
2995
|
-
break;
|
2996
|
-
}
|
2997
|
-
}
|
2998
|
-
break;
|
2999
|
-
}
|
3000
|
-
case "INSIDE_ARRAY_AFTER_VALUE": {
|
3001
|
-
switch (char) {
|
3002
|
-
case ",": {
|
3003
|
-
stack.pop();
|
3004
|
-
stack.push("INSIDE_ARRAY_AFTER_COMMA");
|
3005
|
-
break;
|
3006
|
-
}
|
3007
|
-
case "]": {
|
3008
|
-
lastValidIndex = i;
|
3009
|
-
stack.pop();
|
3010
|
-
break;
|
3011
|
-
}
|
3012
|
-
default: {
|
3013
|
-
lastValidIndex = i;
|
3014
|
-
break;
|
3015
|
-
}
|
3016
|
-
}
|
3017
|
-
break;
|
3018
|
-
}
|
3019
|
-
case "INSIDE_ARRAY_AFTER_COMMA": {
|
3020
|
-
processValueStart(char, i, "INSIDE_ARRAY_AFTER_VALUE");
|
3021
|
-
break;
|
3022
|
-
}
|
3023
|
-
case "INSIDE_STRING_ESCAPE": {
|
3024
|
-
stack.pop();
|
3025
|
-
lastValidIndex = i;
|
3026
|
-
break;
|
3027
|
-
}
|
3028
|
-
case "INSIDE_NUMBER": {
|
3029
|
-
switch (char) {
|
3030
|
-
case "0":
|
3031
|
-
case "1":
|
3032
|
-
case "2":
|
3033
|
-
case "3":
|
3034
|
-
case "4":
|
3035
|
-
case "5":
|
3036
|
-
case "6":
|
3037
|
-
case "7":
|
3038
|
-
case "8":
|
3039
|
-
case "9": {
|
3040
|
-
lastValidIndex = i;
|
3041
|
-
break;
|
3042
|
-
}
|
3043
|
-
case "e":
|
3044
|
-
case "E":
|
3045
|
-
case "-":
|
3046
|
-
case ".": {
|
3047
|
-
break;
|
3048
|
-
}
|
3049
|
-
case ",": {
|
3050
|
-
stack.pop();
|
3051
|
-
if (stack[stack.length - 1] === "INSIDE_ARRAY_AFTER_VALUE") {
|
3052
|
-
processAfterArrayValue(char, i);
|
3053
|
-
}
|
3054
|
-
if (stack[stack.length - 1] === "INSIDE_OBJECT_AFTER_VALUE") {
|
3055
|
-
processAfterObjectValue(char, i);
|
3056
|
-
}
|
3057
|
-
break;
|
3058
|
-
}
|
3059
|
-
case "}": {
|
3060
|
-
stack.pop();
|
3061
|
-
if (stack[stack.length - 1] === "INSIDE_OBJECT_AFTER_VALUE") {
|
3062
|
-
processAfterObjectValue(char, i);
|
3063
|
-
}
|
3064
|
-
break;
|
3065
|
-
}
|
3066
|
-
case "]": {
|
3067
|
-
stack.pop();
|
3068
|
-
if (stack[stack.length - 1] === "INSIDE_ARRAY_AFTER_VALUE") {
|
3069
|
-
processAfterArrayValue(char, i);
|
3070
|
-
}
|
3071
|
-
break;
|
3072
|
-
}
|
3073
|
-
default: {
|
3074
|
-
stack.pop();
|
3075
|
-
break;
|
3076
|
-
}
|
3077
|
-
}
|
3078
|
-
break;
|
3079
|
-
}
|
3080
|
-
case "INSIDE_LITERAL": {
|
3081
|
-
const partialLiteral = input.substring(literalStart, i + 1);
|
3082
|
-
if (!"false".startsWith(partialLiteral) && !"true".startsWith(partialLiteral) && !"null".startsWith(partialLiteral)) {
|
3083
|
-
stack.pop();
|
3084
|
-
if (stack[stack.length - 1] === "INSIDE_OBJECT_AFTER_VALUE") {
|
3085
|
-
processAfterObjectValue(char, i);
|
3086
|
-
} else if (stack[stack.length - 1] === "INSIDE_ARRAY_AFTER_VALUE") {
|
3087
|
-
processAfterArrayValue(char, i);
|
3088
|
-
}
|
3089
|
-
} else {
|
3090
|
-
lastValidIndex = i;
|
3091
|
-
}
|
3092
|
-
break;
|
3093
|
-
}
|
3094
|
-
}
|
3095
|
-
}
|
3096
|
-
let result = input.slice(0, lastValidIndex + 1);
|
3097
|
-
for (let i = stack.length - 1; i >= 0; i--) {
|
3098
|
-
const state = stack[i];
|
3099
|
-
switch (state) {
|
3100
|
-
case "INSIDE_STRING": {
|
3101
|
-
result += '"';
|
3102
|
-
break;
|
3103
|
-
}
|
3104
|
-
case "INSIDE_OBJECT_KEY":
|
3105
|
-
case "INSIDE_OBJECT_AFTER_KEY":
|
3106
|
-
case "INSIDE_OBJECT_AFTER_COMMA":
|
3107
|
-
case "INSIDE_OBJECT_START":
|
3108
|
-
case "INSIDE_OBJECT_BEFORE_VALUE":
|
3109
|
-
case "INSIDE_OBJECT_AFTER_VALUE": {
|
3110
|
-
result += "}";
|
3111
|
-
break;
|
3112
|
-
}
|
3113
|
-
case "INSIDE_ARRAY_START":
|
3114
|
-
case "INSIDE_ARRAY_AFTER_COMMA":
|
3115
|
-
case "INSIDE_ARRAY_AFTER_VALUE": {
|
3116
|
-
result += "]";
|
3117
|
-
break;
|
3118
|
-
}
|
3119
|
-
case "INSIDE_LITERAL": {
|
3120
|
-
const partialLiteral = input.substring(literalStart, input.length);
|
3121
|
-
if ("true".startsWith(partialLiteral)) {
|
3122
|
-
result += "true".slice(partialLiteral.length);
|
3123
|
-
} else if ("false".startsWith(partialLiteral)) {
|
3124
|
-
result += "false".slice(partialLiteral.length);
|
3125
|
-
} else if ("null".startsWith(partialLiteral)) {
|
3126
|
-
result += "null".slice(partialLiteral.length);
|
3127
|
-
}
|
3128
|
-
}
|
3129
|
-
}
|
3130
|
-
}
|
3131
|
-
return result;
|
3132
|
-
}
|
3133
|
-
|
3134
|
-
// src/runtimes/edge/partial-json/parse-partial-json.ts
|
3135
|
-
var parsePartialJson = (json) => {
|
3136
|
-
try {
|
3137
|
-
return sjson.parse(json);
|
3138
|
-
} catch {
|
3139
|
-
try {
|
3140
|
-
return sjson.parse(fixJson(json));
|
3141
|
-
} catch {
|
3142
|
-
return void 0;
|
3143
|
-
}
|
3144
|
-
}
|
3145
|
-
};
|
3146
|
-
|
3147
|
-
// src/runtimes/edge/streams/runResultStream.ts
|
3148
|
-
function runResultStream() {
|
3149
|
-
let message = {
|
3150
|
-
content: [],
|
3151
|
-
status: { type: "running" }
|
3152
|
-
};
|
3153
|
-
const currentToolCall = { toolCallId: "", argsText: "" };
|
3154
|
-
return new TransformStream({
|
3155
|
-
transform(chunk, controller) {
|
3156
|
-
const chunkType = chunk.type;
|
3157
|
-
switch (chunkType) {
|
3158
|
-
case "text-delta": {
|
3159
|
-
message = appendOrUpdateText(message, chunk.textDelta);
|
3160
|
-
controller.enqueue(message);
|
3161
|
-
break;
|
3162
|
-
}
|
3163
|
-
case "tool-call-delta": {
|
3164
|
-
const { toolCallId, toolName, argsTextDelta } = chunk;
|
3165
|
-
if (currentToolCall.toolCallId !== toolCallId) {
|
3166
|
-
currentToolCall.toolCallId = toolCallId;
|
3167
|
-
currentToolCall.argsText = argsTextDelta;
|
3168
|
-
} else {
|
3169
|
-
currentToolCall.argsText += argsTextDelta;
|
3170
|
-
}
|
3171
|
-
message = appendOrUpdateToolCall(
|
3172
|
-
message,
|
3173
|
-
toolCallId,
|
3174
|
-
toolName,
|
3175
|
-
currentToolCall.argsText
|
3176
|
-
);
|
3177
|
-
controller.enqueue(message);
|
3178
|
-
break;
|
3179
|
-
}
|
3180
|
-
case "tool-call": {
|
3181
|
-
break;
|
3182
|
-
}
|
3183
|
-
case "tool-result": {
|
3184
|
-
message = appendOrUpdateToolResult(
|
3185
|
-
message,
|
3186
|
-
chunk.toolCallId,
|
3187
|
-
chunk.toolName,
|
3188
|
-
chunk.result
|
3189
|
-
);
|
3190
|
-
controller.enqueue(message);
|
3191
|
-
break;
|
3192
|
-
}
|
3193
|
-
case "finish": {
|
3194
|
-
message = appendOrUpdateFinish(message, chunk);
|
3195
|
-
controller.enqueue(message);
|
3196
|
-
break;
|
3197
|
-
}
|
3198
|
-
case "error": {
|
3199
|
-
if (chunk.error instanceof Error && chunk.error.name === "AbortError") {
|
3200
|
-
message = appendOrUpdateCancel(message);
|
3201
|
-
controller.enqueue(message);
|
3202
|
-
break;
|
3203
|
-
} else {
|
3204
|
-
throw chunk.error;
|
3205
|
-
}
|
3206
|
-
}
|
3207
|
-
default: {
|
3208
|
-
const unhandledType = chunkType;
|
3209
|
-
throw new Error(`Unhandled chunk type: ${unhandledType}`);
|
3210
|
-
}
|
3211
|
-
}
|
3212
|
-
}
|
3213
|
-
});
|
3214
|
-
}
|
3215
|
-
var appendOrUpdateText = (message, textDelta) => {
|
3216
|
-
let contentParts = message.content;
|
3217
|
-
let contentPart = message.content.at(-1);
|
3218
|
-
if (contentPart?.type !== "text") {
|
3219
|
-
contentPart = { type: "text", text: textDelta };
|
3220
|
-
} else {
|
3221
|
-
contentParts = contentParts.slice(0, -1);
|
3222
|
-
contentPart = { type: "text", text: contentPart.text + textDelta };
|
3223
|
-
}
|
3224
|
-
return {
|
3225
|
-
...message,
|
3226
|
-
content: contentParts.concat([contentPart])
|
3227
|
-
};
|
3228
|
-
};
|
3229
|
-
var appendOrUpdateToolCall = (message, toolCallId, toolName, argsText) => {
|
3230
|
-
let contentParts = message.content;
|
3231
|
-
let contentPart = message.content.at(-1);
|
3232
|
-
if (contentPart?.type !== "tool-call" || contentPart.toolCallId !== toolCallId) {
|
3233
|
-
contentPart = {
|
3234
|
-
type: "tool-call",
|
3235
|
-
toolCallId,
|
3236
|
-
toolName,
|
3237
|
-
argsText,
|
3238
|
-
args: parsePartialJson(argsText)
|
3239
|
-
};
|
3240
|
-
} else {
|
3241
|
-
contentParts = contentParts.slice(0, -1);
|
3242
|
-
contentPart = {
|
3243
|
-
...contentPart,
|
3244
|
-
argsText,
|
3245
|
-
args: parsePartialJson(argsText)
|
3246
|
-
};
|
3247
|
-
}
|
3248
|
-
return {
|
3249
|
-
...message,
|
3250
|
-
content: contentParts.concat([contentPart])
|
3251
|
-
};
|
3252
|
-
};
|
3253
|
-
var appendOrUpdateToolResult = (message, toolCallId, toolName, result) => {
|
3254
|
-
let found = false;
|
3255
|
-
const newContentParts = message.content.map((part) => {
|
3256
|
-
if (part.type !== "tool-call" || part.toolCallId !== toolCallId)
|
3257
|
-
return part;
|
3258
|
-
found = true;
|
3259
|
-
if (part.toolName !== toolName)
|
3260
|
-
throw new Error(
|
3261
|
-
`Tool call ${toolCallId} found with tool name ${part.toolName}, but expected ${toolName}`
|
3262
|
-
);
|
3263
|
-
return {
|
3264
|
-
...part,
|
3265
|
-
result
|
3266
|
-
};
|
3267
|
-
});
|
3268
|
-
if (!found)
|
3269
|
-
throw new Error(
|
3270
|
-
`Received tool result for unknown tool call "${toolName}" / "${toolCallId}". This is likely an internal bug in assistant-ui.`
|
3271
|
-
);
|
3272
|
-
return {
|
3273
|
-
...message,
|
3274
|
-
content: newContentParts
|
3275
|
-
};
|
3276
|
-
};
|
3277
|
-
var appendOrUpdateFinish = (message, chunk) => {
|
3278
|
-
const { type, ...rest } = chunk;
|
3279
|
-
return {
|
3280
|
-
...message,
|
3281
|
-
status: getStatus(chunk),
|
3282
|
-
roundtrips: [
|
3283
|
-
...message.roundtrips ?? [],
|
3284
|
-
{
|
3285
|
-
logprobs: rest.logprobs,
|
3286
|
-
usage: rest.usage
|
3287
|
-
}
|
3288
|
-
]
|
3289
|
-
};
|
3290
|
-
};
|
3291
|
-
var getStatus = (chunk) => {
|
3292
|
-
if (chunk.finishReason === "tool-calls") {
|
3293
|
-
return {
|
3294
|
-
type: "requires-action",
|
3295
|
-
reason: "tool-calls"
|
3296
|
-
};
|
3297
|
-
} else if (chunk.finishReason === "stop" || chunk.finishReason === "unknown") {
|
3298
|
-
return {
|
3299
|
-
type: "complete",
|
3300
|
-
reason: chunk.finishReason
|
3301
|
-
};
|
3302
|
-
} else {
|
3303
|
-
return {
|
3304
|
-
type: "incomplete",
|
3305
|
-
reason: chunk.finishReason
|
3306
|
-
};
|
3307
|
-
}
|
3308
|
-
};
|
3309
|
-
var appendOrUpdateCancel = (message) => {
|
3310
|
-
return {
|
3311
|
-
...message,
|
3312
|
-
status: {
|
3313
|
-
type: "incomplete",
|
3314
|
-
reason: "cancelled"
|
3315
|
-
}
|
3316
|
-
};
|
3317
|
-
};
|
3318
|
-
|
3319
|
-
// src/runtimes/edge/streams/toolResultStream.ts
|
3320
|
-
import { z as z3 } from "zod";
|
3321
|
-
import sjson2 from "secure-json-parse";
|
3322
|
-
function toolResultStream(tools) {
|
3323
|
-
const toolCallExecutions = /* @__PURE__ */ new Map();
|
3324
|
-
return new TransformStream({
|
3325
|
-
transform(chunk, controller) {
|
3326
|
-
controller.enqueue(chunk);
|
3327
|
-
const chunkType = chunk.type;
|
3328
|
-
switch (chunkType) {
|
3329
|
-
case "tool-call": {
|
3330
|
-
const { toolCallId, toolCallType, toolName, args: argsText } = chunk;
|
3331
|
-
const tool = tools?.[toolName];
|
3332
|
-
if (!tool || !tool.execute) return;
|
3333
|
-
const args = sjson2.parse(argsText);
|
3334
|
-
if (tool.parameters instanceof z3.ZodType) {
|
3335
|
-
const result = tool.parameters.safeParse(args);
|
3336
|
-
if (!result.success) {
|
3337
|
-
controller.enqueue({
|
3338
|
-
type: "tool-result",
|
3339
|
-
toolCallType,
|
3340
|
-
toolCallId,
|
3341
|
-
toolName,
|
3342
|
-
result: "Function parameter validation failed. " + JSON.stringify(result.error.issues),
|
3343
|
-
isError: true
|
3344
|
-
});
|
3345
|
-
return;
|
3346
|
-
} else {
|
3347
|
-
toolCallExecutions.set(
|
3348
|
-
toolCallId,
|
3349
|
-
(async () => {
|
3350
|
-
try {
|
3351
|
-
const result2 = await tool.execute(args);
|
3352
|
-
controller.enqueue({
|
3353
|
-
type: "tool-result",
|
3354
|
-
toolCallType,
|
3355
|
-
toolCallId,
|
3356
|
-
toolName,
|
3357
|
-
result: result2
|
3358
|
-
});
|
3359
|
-
} catch (error) {
|
3360
|
-
console.error("Error: ", error);
|
3361
|
-
controller.enqueue({
|
3362
|
-
type: "tool-result",
|
3363
|
-
toolCallType,
|
3364
|
-
toolCallId,
|
3365
|
-
toolName,
|
3366
|
-
result: "Error: " + error,
|
3367
|
-
isError: true
|
3368
|
-
});
|
3369
|
-
} finally {
|
3370
|
-
toolCallExecutions.delete(toolCallId);
|
3371
|
-
}
|
3372
|
-
})()
|
3373
|
-
);
|
3374
|
-
}
|
3375
|
-
}
|
3376
|
-
break;
|
3377
|
-
}
|
3378
|
-
case "text-delta":
|
3379
|
-
case "tool-call-delta":
|
3380
|
-
case "tool-result":
|
3381
|
-
case "finish":
|
3382
|
-
case "error":
|
3383
|
-
break;
|
3384
|
-
default: {
|
3385
|
-
const unhandledType = chunkType;
|
3386
|
-
throw new Error(`Unhandled chunk type: ${unhandledType}`);
|
3387
|
-
}
|
3388
|
-
}
|
3389
|
-
},
|
3390
|
-
async flush() {
|
3391
|
-
await Promise.all(toolCallExecutions.values());
|
3392
|
-
}
|
3393
|
-
});
|
3394
|
-
}
|
3395
|
-
|
3396
2043
|
// src/runtimes/edge/EdgeChatAdapter.ts
|
3397
2044
|
function asAsyncIterable(source) {
|
3398
2045
|
return {
|
@@ -3444,7 +2091,7 @@ var useEdgeRuntime = ({
|
|
3444
2091
|
initialMessages,
|
3445
2092
|
...options
|
3446
2093
|
}) => {
|
3447
|
-
const [adapter] =
|
2094
|
+
const [adapter] = useState6(() => new EdgeChatAdapter(options));
|
3448
2095
|
return useLocalRuntime(adapter, { initialMessages });
|
3449
2096
|
};
|
3450
2097
|
|
@@ -3658,7 +2305,7 @@ var LocalRuntime = class extends BaseAssistantRuntime {
|
|
3658
2305
|
|
3659
2306
|
// src/runtimes/local/useLocalRuntime.tsx
|
3660
2307
|
var useLocalRuntime = (adapter, options) => {
|
3661
|
-
const [runtime] =
|
2308
|
+
const [runtime] = useState7(() => new LocalRuntime(adapter, options));
|
3662
2309
|
useInsertionEffect3(() => {
|
3663
2310
|
runtime.adapter = adapter;
|
3664
2311
|
});
|
@@ -3666,7 +2313,7 @@ var useLocalRuntime = (adapter, options) => {
|
|
3666
2313
|
};
|
3667
2314
|
|
3668
2315
|
// src/runtimes/external-store/ExternalStoreThreadRuntime.tsx
|
3669
|
-
import { create as
|
2316
|
+
import { create as create14 } from "zustand";
|
3670
2317
|
|
3671
2318
|
// src/runtimes/external-store/getExternalStoreMessage.tsx
|
3672
2319
|
var symbolInnerMessage = Symbol("innerMessage");
|
@@ -3675,7 +2322,7 @@ var getExternalStoreMessage = (message) => {
|
|
3675
2322
|
};
|
3676
2323
|
|
3677
2324
|
// src/runtimes/external-store/useExternalStoreSync.tsx
|
3678
|
-
import { useEffect as
|
2325
|
+
import { useEffect as useEffect10, useInsertionEffect as useInsertionEffect4, useMemo as useMemo2, useRef as useRef5 } from "react";
|
3679
2326
|
|
3680
2327
|
// src/runtimes/external-store/ThreadMessageConverter.ts
|
3681
2328
|
var ThreadMessageConverter = class {
|
@@ -3769,11 +2416,11 @@ var fromThreadMessageLike = (like, fallbackId, fallbackStatus) => {
|
|
3769
2416
|
|
3770
2417
|
// src/runtimes/external-store/useExternalStoreSync.tsx
|
3771
2418
|
var useExternalStoreSync = (adapter, updateData) => {
|
3772
|
-
const adapterRef =
|
2419
|
+
const adapterRef = useRef5(adapter);
|
3773
2420
|
useInsertionEffect4(() => {
|
3774
2421
|
adapterRef.current = adapter;
|
3775
2422
|
});
|
3776
|
-
const [converter, convertCallback] =
|
2423
|
+
const [converter, convertCallback] = useMemo2(() => {
|
3777
2424
|
const converter2 = adapter.convertMessage ?? ((m) => m);
|
3778
2425
|
const convertCallback2 = (cache, m, idx) => {
|
3779
2426
|
const autoStatus = getAutoStatus(
|
@@ -3792,7 +2439,7 @@ var useExternalStoreSync = (adapter, updateData) => {
|
|
3792
2439
|
};
|
3793
2440
|
return [new ThreadMessageConverter(), convertCallback2];
|
3794
2441
|
}, [adapter.convertMessage]);
|
3795
|
-
|
2442
|
+
useEffect10(() => {
|
3796
2443
|
updateData(
|
3797
2444
|
adapter.isDisabled ?? false,
|
3798
2445
|
adapter.isRunning ?? false,
|
@@ -3820,7 +2467,7 @@ var ExternalStoreThreadRuntime = class {
|
|
3820
2467
|
store.isRunning ?? false,
|
3821
2468
|
store.messages
|
3822
2469
|
);
|
3823
|
-
this.useStore =
|
2470
|
+
this.useStore = create14(() => ({
|
3824
2471
|
store
|
3825
2472
|
}));
|
3826
2473
|
}
|
@@ -3961,13 +2608,13 @@ var ExternalStoreRuntime = class extends BaseAssistantRuntime {
|
|
3961
2608
|
};
|
3962
2609
|
|
3963
2610
|
// src/runtimes/external-store/useExternalStoreRuntime.tsx
|
3964
|
-
import { useEffect as
|
2611
|
+
import { useEffect as useEffect11, useInsertionEffect as useInsertionEffect5, useState as useState8 } from "react";
|
3965
2612
|
var useExternalStoreRuntime = (store) => {
|
3966
|
-
const [runtime] =
|
2613
|
+
const [runtime] = useState8(() => new ExternalStoreRuntime(store));
|
3967
2614
|
useInsertionEffect5(() => {
|
3968
2615
|
runtime.store = store;
|
3969
2616
|
});
|
3970
|
-
|
2617
|
+
useEffect11(() => {
|
3971
2618
|
runtime.onStoreUpdated();
|
3972
2619
|
});
|
3973
2620
|
return runtime;
|
@@ -3975,34 +2622,34 @@ var useExternalStoreRuntime = (store) => {
|
|
3975
2622
|
|
3976
2623
|
// src/ui/thread-config.tsx
|
3977
2624
|
import {
|
3978
|
-
createContext
|
3979
|
-
useContext
|
2625
|
+
createContext,
|
2626
|
+
useContext
|
3980
2627
|
} from "react";
|
3981
|
-
import { Fragment as Fragment3, jsx as
|
3982
|
-
var ThreadConfigContext =
|
2628
|
+
import { Fragment as Fragment3, jsx as jsx25 } from "react/jsx-runtime";
|
2629
|
+
var ThreadConfigContext = createContext({});
|
3983
2630
|
var useThreadConfig = () => {
|
3984
|
-
return
|
2631
|
+
return useContext(ThreadConfigContext);
|
3985
2632
|
};
|
3986
2633
|
var ThreadConfigProvider = ({
|
3987
2634
|
children,
|
3988
2635
|
config
|
3989
2636
|
}) => {
|
3990
2637
|
const assistant = useAssistantContext({ optional: true });
|
3991
|
-
const configProvider = config && Object.keys(config ?? {}).length > 0 ? /* @__PURE__ */
|
2638
|
+
const configProvider = config && Object.keys(config ?? {}).length > 0 ? /* @__PURE__ */ jsx25(ThreadConfigContext.Provider, { value: config, children }) : /* @__PURE__ */ jsx25(Fragment3, { children });
|
3992
2639
|
if (!config?.runtime) return configProvider;
|
3993
2640
|
if (assistant) {
|
3994
2641
|
throw new Error(
|
3995
2642
|
"You provided a runtime to <Thread> while simulataneously using <AssistantRuntimeProvider>. This is not allowed."
|
3996
2643
|
);
|
3997
2644
|
}
|
3998
|
-
return /* @__PURE__ */
|
2645
|
+
return /* @__PURE__ */ jsx25(AssistantRuntimeProvider, { runtime: config.runtime, children: configProvider });
|
3999
2646
|
};
|
4000
2647
|
ThreadConfigProvider.displayName = "ThreadConfigProvider";
|
4001
2648
|
|
4002
2649
|
// src/ui/assistant-action-bar.tsx
|
4003
|
-
import { forwardRef as
|
2650
|
+
import { forwardRef as forwardRef15 } from "react";
|
4004
2651
|
import { CheckIcon, CopyIcon, RefreshCwIcon } from "lucide-react";
|
4005
|
-
import { Fragment as Fragment4, jsx as
|
2652
|
+
import { Fragment as Fragment4, jsx as jsx26, jsxs as jsxs4 } from "react/jsx-runtime";
|
4006
2653
|
var useAllowCopy = () => {
|
4007
2654
|
const { assistantMessage: { allowCopy = true } = {} } = useThreadConfig();
|
4008
2655
|
const { useThreadActions } = useThreadContext();
|
@@ -4019,15 +2666,15 @@ var AssistantActionBar = () => {
|
|
4019
2666
|
const allowCopy = useAllowCopy();
|
4020
2667
|
const allowReload = useAllowReload();
|
4021
2668
|
if (!allowCopy && !allowReload) return null;
|
4022
|
-
return /* @__PURE__ */
|
2669
|
+
return /* @__PURE__ */ jsxs4(
|
4023
2670
|
AssistantActionBarRoot,
|
4024
2671
|
{
|
4025
2672
|
hideWhenRunning: true,
|
4026
2673
|
autohide: "not-last",
|
4027
2674
|
autohideFloat: "single-branch",
|
4028
2675
|
children: [
|
4029
|
-
/* @__PURE__ */
|
4030
|
-
/* @__PURE__ */
|
2676
|
+
/* @__PURE__ */ jsx26(AssistantActionBarCopy, {}),
|
2677
|
+
/* @__PURE__ */ jsx26(AssistantActionBarReload, {})
|
4031
2678
|
]
|
4032
2679
|
}
|
4033
2680
|
);
|
@@ -4037,7 +2684,7 @@ var AssistantActionBarRoot = withDefaults(actionBar_exports.Root, {
|
|
4037
2684
|
className: "aui-assistant-action-bar-root"
|
4038
2685
|
});
|
4039
2686
|
AssistantActionBarRoot.displayName = "AssistantActionBarRoot";
|
4040
|
-
var AssistantActionBarCopy =
|
2687
|
+
var AssistantActionBarCopy = forwardRef15((props, ref) => {
|
4041
2688
|
const {
|
4042
2689
|
strings: {
|
4043
2690
|
assistantMessage: { reload: { tooltip = "Copy" } = {} } = {}
|
@@ -4045,13 +2692,13 @@ var AssistantActionBarCopy = forwardRef19((props, ref) => {
|
|
4045
2692
|
} = useThreadConfig();
|
4046
2693
|
const allowCopy = useAllowCopy();
|
4047
2694
|
if (!allowCopy) return null;
|
4048
|
-
return /* @__PURE__ */
|
4049
|
-
/* @__PURE__ */
|
4050
|
-
/* @__PURE__ */
|
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, {}) })
|
4051
2698
|
] }) }) });
|
4052
2699
|
});
|
4053
2700
|
AssistantActionBarCopy.displayName = "AssistantActionBarCopy";
|
4054
|
-
var AssistantActionBarReload =
|
2701
|
+
var AssistantActionBarReload = forwardRef15((props, ref) => {
|
4055
2702
|
const {
|
4056
2703
|
strings: {
|
4057
2704
|
assistantMessage: { reload: { tooltip = "Refresh" } = {} } = {}
|
@@ -4059,7 +2706,7 @@ var AssistantActionBarReload = forwardRef19((props, ref) => {
|
|
4059
2706
|
} = useThreadConfig();
|
4060
2707
|
const allowReload = useAllowReload();
|
4061
2708
|
if (!allowReload) return null;
|
4062
|
-
return /* @__PURE__ */
|
2709
|
+
return /* @__PURE__ */ jsx26(actionBar_exports.Reload, { asChild: true, children: /* @__PURE__ */ jsx26(TooltipIconButton, { tooltip, ...props, ref, children: /* @__PURE__ */ jsx26(RefreshCwIcon, {}) }) });
|
4063
2710
|
});
|
4064
2711
|
AssistantActionBarReload.displayName = "AssistantActionBarReload";
|
4065
2712
|
var exports = {
|
@@ -4073,12 +2720,12 @@ var assistant_action_bar_default = Object.assign(
|
|
4073
2720
|
);
|
4074
2721
|
|
4075
2722
|
// src/ui/assistant-message.tsx
|
4076
|
-
import { forwardRef as
|
2723
|
+
import { forwardRef as forwardRef17 } from "react";
|
4077
2724
|
|
4078
2725
|
// src/ui/branch-picker.tsx
|
4079
|
-
import { forwardRef as
|
2726
|
+
import { forwardRef as forwardRef16 } from "react";
|
4080
2727
|
import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react";
|
4081
|
-
import { jsx as
|
2728
|
+
import { jsx as jsx27, jsxs as jsxs5 } from "react/jsx-runtime";
|
4082
2729
|
var useAllowBranchPicker = () => {
|
4083
2730
|
const { branchPicker: { allowBranchPicker = true } = {} } = useThreadConfig();
|
4084
2731
|
const { useThreadActions } = useThreadContext();
|
@@ -4088,10 +2735,10 @@ var useAllowBranchPicker = () => {
|
|
4088
2735
|
var BranchPicker = () => {
|
4089
2736
|
const allowBranchPicker = useAllowBranchPicker();
|
4090
2737
|
if (!allowBranchPicker) return null;
|
4091
|
-
return /* @__PURE__ */
|
4092
|
-
/* @__PURE__ */
|
4093
|
-
/* @__PURE__ */
|
4094
|
-
/* @__PURE__ */
|
2738
|
+
return /* @__PURE__ */ jsxs5(BranchPickerRoot, { hideWhenSingleBranch: true, children: [
|
2739
|
+
/* @__PURE__ */ jsx27(BranchPickerPrevious2, {}),
|
2740
|
+
/* @__PURE__ */ jsx27(BranchPickerState, {}),
|
2741
|
+
/* @__PURE__ */ jsx27(BranchPickerNext, {})
|
4095
2742
|
] });
|
4096
2743
|
};
|
4097
2744
|
BranchPicker.displayName = "BranchPicker";
|
@@ -4099,31 +2746,31 @@ var BranchPickerRoot = withDefaults(branchPicker_exports.Root, {
|
|
4099
2746
|
className: "aui-branch-picker-root"
|
4100
2747
|
});
|
4101
2748
|
BranchPickerRoot.displayName = "BranchPickerRoot";
|
4102
|
-
var BranchPickerPrevious2 =
|
2749
|
+
var BranchPickerPrevious2 = forwardRef16((props, ref) => {
|
4103
2750
|
const {
|
4104
2751
|
strings: {
|
4105
2752
|
branchPicker: { previous: { tooltip = "Previous" } = {} } = {}
|
4106
2753
|
} = {}
|
4107
2754
|
} = useThreadConfig();
|
4108
|
-
return /* @__PURE__ */
|
2755
|
+
return /* @__PURE__ */ jsx27(branchPicker_exports.Previous, { asChild: true, children: /* @__PURE__ */ jsx27(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx27(ChevronLeftIcon, {}) }) });
|
4109
2756
|
});
|
4110
2757
|
BranchPickerPrevious2.displayName = "BranchPickerPrevious";
|
4111
2758
|
var BranchPickerStateWrapper = withDefaults("span", {
|
4112
2759
|
className: "aui-branch-picker-state"
|
4113
2760
|
});
|
4114
|
-
var BranchPickerState =
|
4115
|
-
return /* @__PURE__ */
|
4116
|
-
/* @__PURE__ */
|
2761
|
+
var BranchPickerState = forwardRef16((props, ref) => {
|
2762
|
+
return /* @__PURE__ */ jsxs5(BranchPickerStateWrapper, { ...props, ref, children: [
|
2763
|
+
/* @__PURE__ */ jsx27(branchPicker_exports.Number, {}),
|
4117
2764
|
" / ",
|
4118
|
-
/* @__PURE__ */
|
2765
|
+
/* @__PURE__ */ jsx27(branchPicker_exports.Count, {})
|
4119
2766
|
] });
|
4120
2767
|
});
|
4121
2768
|
BranchPickerState.displayName = "BranchPickerState";
|
4122
|
-
var BranchPickerNext =
|
2769
|
+
var BranchPickerNext = forwardRef16((props, ref) => {
|
4123
2770
|
const {
|
4124
2771
|
strings: { branchPicker: { next: { tooltip = "Next" } = {} } = {} } = {}
|
4125
2772
|
} = useThreadConfig();
|
4126
|
-
return /* @__PURE__ */
|
2773
|
+
return /* @__PURE__ */ jsx27(branchPicker_exports.Next, { asChild: true, children: /* @__PURE__ */ jsx27(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx27(ChevronRightIcon, {}) }) });
|
4127
2774
|
});
|
4128
2775
|
BranchPickerNext.displayName = "BranchPickerNext";
|
4129
2776
|
var exports2 = {
|
@@ -4135,12 +2782,12 @@ var branch_picker_default = Object.assign(BranchPicker, exports2);
|
|
4135
2782
|
|
4136
2783
|
// src/ui/base/avatar.tsx
|
4137
2784
|
import * as AvatarPrimitive from "@radix-ui/react-avatar";
|
4138
|
-
import { jsx as
|
2785
|
+
import { jsx as jsx28, jsxs as jsxs6 } from "react/jsx-runtime";
|
4139
2786
|
var Avatar = ({ src, alt, fallback }) => {
|
4140
2787
|
if (src == null && fallback == null) return null;
|
4141
|
-
return /* @__PURE__ */
|
4142
|
-
src != null && /* @__PURE__ */
|
4143
|
-
fallback != null && /* @__PURE__ */
|
2788
|
+
return /* @__PURE__ */ jsxs6(AvatarRoot, { children: [
|
2789
|
+
src != null && /* @__PURE__ */ jsx28(AvatarImage, { src, alt }),
|
2790
|
+
fallback != null && /* @__PURE__ */ jsx28(AvatarFallback, { children: fallback })
|
4144
2791
|
] });
|
4145
2792
|
};
|
4146
2793
|
Avatar.displayName = "Avatar";
|
@@ -4158,14 +2805,14 @@ var AvatarFallback = withDefaults(AvatarPrimitive.Fallback, {
|
|
4158
2805
|
AvatarFallback.displayName = "AvatarFallback";
|
4159
2806
|
|
4160
2807
|
// src/ui/content-part.tsx
|
4161
|
-
import
|
4162
|
-
import { jsx as
|
2808
|
+
import classNames from "classnames";
|
2809
|
+
import { jsx as jsx29 } from "react/jsx-runtime";
|
4163
2810
|
var Text = () => {
|
4164
2811
|
const status = useSmoothStatus();
|
4165
|
-
return /* @__PURE__ */
|
2812
|
+
return /* @__PURE__ */ jsx29(
|
4166
2813
|
contentPart_exports.Text,
|
4167
2814
|
{
|
4168
|
-
className:
|
2815
|
+
className: classNames(
|
4169
2816
|
"aui-text",
|
4170
2817
|
status.type === "running" && "aui-text-running"
|
4171
2818
|
),
|
@@ -4177,19 +2824,19 @@ var exports3 = { Text: withSmoothContextProvider(Text) };
|
|
4177
2824
|
var content_part_default = exports3;
|
4178
2825
|
|
4179
2826
|
// src/ui/assistant-message.tsx
|
4180
|
-
import { jsx as
|
2827
|
+
import { jsx as jsx30, jsxs as jsxs7 } from "react/jsx-runtime";
|
4181
2828
|
var AssistantMessage = () => {
|
4182
|
-
return /* @__PURE__ */
|
4183
|
-
/* @__PURE__ */
|
4184
|
-
/* @__PURE__ */
|
4185
|
-
/* @__PURE__ */
|
4186
|
-
/* @__PURE__ */
|
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, {})
|
4187
2834
|
] });
|
4188
2835
|
};
|
4189
2836
|
AssistantMessage.displayName = "AssistantMessage";
|
4190
2837
|
var AssistantMessageAvatar = () => {
|
4191
2838
|
const { assistantAvatar: avatar = { fallback: "A" } } = useThreadConfig();
|
4192
|
-
return /* @__PURE__ */
|
2839
|
+
return /* @__PURE__ */ jsx30(Avatar, { ...avatar });
|
4193
2840
|
};
|
4194
2841
|
var AssistantMessageRoot = withDefaults(message_exports.Root, {
|
4195
2842
|
className: "aui-assistant-message-root"
|
@@ -4198,9 +2845,9 @@ AssistantMessageRoot.displayName = "AssistantMessageRoot";
|
|
4198
2845
|
var AssistantMessageContentWrapper = withDefaults("div", {
|
4199
2846
|
className: "aui-assistant-message-content"
|
4200
2847
|
});
|
4201
|
-
var AssistantMessageContent =
|
2848
|
+
var AssistantMessageContent = forwardRef17(({ components: componentsProp, ...rest }, ref) => {
|
4202
2849
|
const { assistantMessage: { components = {} } = {} } = useThreadConfig();
|
4203
|
-
return /* @__PURE__ */
|
2850
|
+
return /* @__PURE__ */ jsx30(AssistantMessageContentWrapper, { ...rest, ref, children: /* @__PURE__ */ jsx30(
|
4204
2851
|
message_exports.Content,
|
4205
2852
|
{
|
4206
2853
|
components: {
|
@@ -4222,38 +2869,38 @@ var assistant_message_default = Object.assign(
|
|
4222
2869
|
);
|
4223
2870
|
|
4224
2871
|
// src/ui/assistant-modal.tsx
|
4225
|
-
import { forwardRef as
|
2872
|
+
import { forwardRef as forwardRef24 } from "react";
|
4226
2873
|
import { BotIcon, ChevronDownIcon } from "lucide-react";
|
4227
2874
|
|
4228
2875
|
// src/ui/thread.tsx
|
4229
|
-
import { forwardRef as
|
2876
|
+
import { forwardRef as forwardRef23 } from "react";
|
4230
2877
|
import { ArrowDownIcon } from "lucide-react";
|
4231
2878
|
|
4232
2879
|
// src/ui/composer.tsx
|
4233
|
-
import { forwardRef as
|
2880
|
+
import { forwardRef as forwardRef18 } from "react";
|
4234
2881
|
import { SendHorizontalIcon } from "lucide-react";
|
4235
2882
|
|
4236
2883
|
// src/ui/base/CircleStopIcon.tsx
|
4237
|
-
import { jsx as
|
2884
|
+
import { jsx as jsx31 } from "react/jsx-runtime";
|
4238
2885
|
var CircleStopIcon = () => {
|
4239
|
-
return /* @__PURE__ */
|
2886
|
+
return /* @__PURE__ */ jsx31(
|
4240
2887
|
"svg",
|
4241
2888
|
{
|
4242
2889
|
xmlns: "http://www.w3.org/2000/svg",
|
4243
2890
|
viewBox: "0 0 16 16",
|
4244
2891
|
fill: "currentColor",
|
4245
|
-
children: /* @__PURE__ */
|
2892
|
+
children: /* @__PURE__ */ jsx31("rect", { width: "10", height: "10", x: "3", y: "3", rx: "2" })
|
4246
2893
|
}
|
4247
2894
|
);
|
4248
2895
|
};
|
4249
2896
|
CircleStopIcon.displayName = "CircleStopIcon";
|
4250
2897
|
|
4251
2898
|
// src/ui/composer.tsx
|
4252
|
-
import { Fragment as Fragment5, jsx as
|
2899
|
+
import { Fragment as Fragment5, jsx as jsx32, jsxs as jsxs8 } from "react/jsx-runtime";
|
4253
2900
|
var Composer = () => {
|
4254
|
-
return /* @__PURE__ */
|
4255
|
-
/* @__PURE__ */
|
4256
|
-
/* @__PURE__ */
|
2901
|
+
return /* @__PURE__ */ jsxs8(ComposerRoot, { children: [
|
2902
|
+
/* @__PURE__ */ jsx32(ComposerInput, { autoFocus: true }),
|
2903
|
+
/* @__PURE__ */ jsx32(ComposerAction, {})
|
4257
2904
|
] });
|
4258
2905
|
};
|
4259
2906
|
Composer.displayName = "Composer";
|
@@ -4266,14 +2913,14 @@ var ComposerInputStyled = withDefaults(composer_exports.Input, {
|
|
4266
2913
|
autoFocus: true,
|
4267
2914
|
className: "aui-composer-input"
|
4268
2915
|
});
|
4269
|
-
var ComposerInput =
|
2916
|
+
var ComposerInput = forwardRef18(
|
4270
2917
|
(props, ref) => {
|
4271
2918
|
const {
|
4272
2919
|
strings: {
|
4273
2920
|
composer: { input: { placeholder = "Write a message..." } = {} } = {}
|
4274
2921
|
} = {}
|
4275
2922
|
} = useThreadConfig();
|
4276
|
-
return /* @__PURE__ */
|
2923
|
+
return /* @__PURE__ */ jsx32(ComposerInputStyled, { placeholder, ...props, ref });
|
4277
2924
|
}
|
4278
2925
|
);
|
4279
2926
|
ComposerInput.displayName = "ComposerInput";
|
@@ -4284,10 +2931,10 @@ var useAllowCancel = () => {
|
|
4284
2931
|
};
|
4285
2932
|
var ComposerAction = () => {
|
4286
2933
|
const allowCancel = useAllowCancel();
|
4287
|
-
if (!allowCancel) return /* @__PURE__ */
|
4288
|
-
return /* @__PURE__ */
|
4289
|
-
/* @__PURE__ */
|
4290
|
-
/* @__PURE__ */
|
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, {}) })
|
4291
2938
|
] });
|
4292
2939
|
};
|
4293
2940
|
ComposerAction.displayName = "ComposerAction";
|
@@ -4295,22 +2942,22 @@ var ComposerSendButton = withDefaults(TooltipIconButton, {
|
|
4295
2942
|
variant: "default",
|
4296
2943
|
className: "aui-composer-send"
|
4297
2944
|
});
|
4298
|
-
var ComposerSend =
|
2945
|
+
var ComposerSend = forwardRef18((props, ref) => {
|
4299
2946
|
const {
|
4300
2947
|
strings: { composer: { send: { tooltip = "Send" } = {} } = {} } = {}
|
4301
2948
|
} = useThreadConfig();
|
4302
|
-
return /* @__PURE__ */
|
2949
|
+
return /* @__PURE__ */ jsx32(composer_exports.Send, { asChild: true, children: /* @__PURE__ */ jsx32(ComposerSendButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx32(SendHorizontalIcon, {}) }) });
|
4303
2950
|
});
|
4304
2951
|
ComposerSend.displayName = "ComposerSend";
|
4305
2952
|
var ComposerCancelButton = withDefaults(TooltipIconButton, {
|
4306
2953
|
variant: "default",
|
4307
2954
|
className: "aui-composer-cancel"
|
4308
2955
|
});
|
4309
|
-
var ComposerCancel =
|
2956
|
+
var ComposerCancel = forwardRef18((props, ref) => {
|
4310
2957
|
const {
|
4311
2958
|
strings: { composer: { cancel: { tooltip = "Cancel" } = {} } = {} } = {}
|
4312
2959
|
} = useThreadConfig();
|
4313
|
-
return /* @__PURE__ */
|
2960
|
+
return /* @__PURE__ */ jsx32(composer_exports.Cancel, { asChild: true, children: /* @__PURE__ */ jsx32(ComposerCancelButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx32(CircleStopIcon, {}) }) });
|
4314
2961
|
});
|
4315
2962
|
ComposerCancel.displayName = "ComposerCancel";
|
4316
2963
|
var exports5 = {
|
@@ -4323,15 +2970,15 @@ var exports5 = {
|
|
4323
2970
|
var composer_default = Object.assign(Composer, exports5);
|
4324
2971
|
|
4325
2972
|
// src/ui/thread-welcome.tsx
|
4326
|
-
import { forwardRef as
|
4327
|
-
import { jsx as
|
2973
|
+
import { forwardRef as forwardRef19 } from "react";
|
2974
|
+
import { jsx as jsx33, jsxs as jsxs9 } from "react/jsx-runtime";
|
4328
2975
|
var ThreadWelcome = () => {
|
4329
|
-
return /* @__PURE__ */
|
4330
|
-
/* @__PURE__ */
|
4331
|
-
/* @__PURE__ */
|
4332
|
-
/* @__PURE__ */
|
2976
|
+
return /* @__PURE__ */ jsxs9(ThreadWelcomeRoot, { children: [
|
2977
|
+
/* @__PURE__ */ jsxs9(ThreadWelcomeCenter, { children: [
|
2978
|
+
/* @__PURE__ */ jsx33(ThreadWelcomeAvatar, {}),
|
2979
|
+
/* @__PURE__ */ jsx33(ThreadWelcomeMessage, {})
|
4333
2980
|
] }),
|
4334
|
-
/* @__PURE__ */
|
2981
|
+
/* @__PURE__ */ jsx33(ThreadWelcomeSuggestions, {})
|
4335
2982
|
] });
|
4336
2983
|
};
|
4337
2984
|
ThreadWelcome.displayName = "ThreadWelcome";
|
@@ -4341,22 +2988,22 @@ var ThreadWelcomeRootStyled = withDefaults("div", {
|
|
4341
2988
|
var ThreadWelcomeCenter = withDefaults("div", {
|
4342
2989
|
className: "aui-thread-welcome-center"
|
4343
2990
|
});
|
4344
|
-
var ThreadWelcomeRoot =
|
2991
|
+
var ThreadWelcomeRoot = forwardRef19(
|
4345
2992
|
(props, ref) => {
|
4346
|
-
return /* @__PURE__ */
|
2993
|
+
return /* @__PURE__ */ jsx33(thread_exports.Empty, { children: /* @__PURE__ */ jsx33(ThreadWelcomeRootStyled, { ...props, ref }) });
|
4347
2994
|
}
|
4348
2995
|
);
|
4349
2996
|
ThreadWelcomeRoot.displayName = "ThreadWelcomeRoot";
|
4350
2997
|
var ThreadWelcomeAvatar = () => {
|
4351
2998
|
const { assistantAvatar: avatar = { fallback: "A" } } = useThreadConfig();
|
4352
|
-
return /* @__PURE__ */
|
2999
|
+
return /* @__PURE__ */ jsx33(Avatar, { ...avatar });
|
4353
3000
|
};
|
4354
3001
|
var ThreadWelcomeMessageStyled = withDefaults("p", {
|
4355
3002
|
className: "aui-thread-welcome-message"
|
4356
3003
|
});
|
4357
|
-
var ThreadWelcomeMessage =
|
3004
|
+
var ThreadWelcomeMessage = forwardRef19(({ message: messageProp, ...rest }, ref) => {
|
4358
3005
|
const { welcome: { message = "How can I help you today?" } = {} } = useThreadConfig();
|
4359
|
-
return /* @__PURE__ */
|
3006
|
+
return /* @__PURE__ */ jsx33(ThreadWelcomeMessageStyled, { ...rest, ref, children: messageProp ?? message });
|
4360
3007
|
});
|
4361
3008
|
ThreadWelcomeMessage.displayName = "ThreadWelcomeMessage";
|
4362
3009
|
var ThreadWelcomeSuggestionContainer = withDefaults("div", {
|
@@ -4368,21 +3015,21 @@ var ThreadWelcomeSuggestionStyled = withDefaults(thread_exports.Suggestion, {
|
|
4368
3015
|
var ThreadWelcomeSuggestion = ({
|
4369
3016
|
suggestion: { text, prompt }
|
4370
3017
|
}) => {
|
4371
|
-
return /* @__PURE__ */
|
3018
|
+
return /* @__PURE__ */ jsx33(
|
4372
3019
|
ThreadWelcomeSuggestionStyled,
|
4373
3020
|
{
|
4374
3021
|
prompt,
|
4375
3022
|
method: "replace",
|
4376
3023
|
autoSend: true,
|
4377
|
-
children: /* @__PURE__ */
|
3024
|
+
children: /* @__PURE__ */ jsx33("span", { className: "aui-thread-welcome-suggestion-text", children: text ?? prompt })
|
4378
3025
|
}
|
4379
3026
|
);
|
4380
3027
|
};
|
4381
3028
|
var ThreadWelcomeSuggestions = () => {
|
4382
3029
|
const { welcome: { suggestions } = {} } = useThreadConfig();
|
4383
|
-
return /* @__PURE__ */
|
3030
|
+
return /* @__PURE__ */ jsx33(ThreadWelcomeSuggestionContainer, { children: suggestions?.map((suggestion, idx) => {
|
4384
3031
|
const key = `${suggestion.prompt}-${idx}`;
|
4385
|
-
return /* @__PURE__ */
|
3032
|
+
return /* @__PURE__ */ jsx33(ThreadWelcomeSuggestion, { suggestion }, key);
|
4386
3033
|
}) });
|
4387
3034
|
};
|
4388
3035
|
ThreadWelcomeSuggestions.displayName = "ThreadWelcomeSuggestions";
|
@@ -4397,12 +3044,12 @@ var exports6 = {
|
|
4397
3044
|
var thread_welcome_default = Object.assign(ThreadWelcome, exports6);
|
4398
3045
|
|
4399
3046
|
// src/ui/user-message.tsx
|
4400
|
-
import { forwardRef as
|
3047
|
+
import { forwardRef as forwardRef21 } from "react";
|
4401
3048
|
|
4402
3049
|
// src/ui/user-action-bar.tsx
|
4403
|
-
import { forwardRef as
|
3050
|
+
import { forwardRef as forwardRef20 } from "react";
|
4404
3051
|
import { PencilIcon } from "lucide-react";
|
4405
|
-
import { jsx as
|
3052
|
+
import { jsx as jsx34 } from "react/jsx-runtime";
|
4406
3053
|
var useAllowEdit = () => {
|
4407
3054
|
const { userMessage: { allowEdit = true } = {} } = useThreadConfig();
|
4408
3055
|
const { useThreadActions } = useThreadContext();
|
@@ -4412,20 +3059,20 @@ var useAllowEdit = () => {
|
|
4412
3059
|
var UserActionBar = () => {
|
4413
3060
|
const allowEdit = useAllowEdit();
|
4414
3061
|
if (!allowEdit) return null;
|
4415
|
-
return /* @__PURE__ */
|
3062
|
+
return /* @__PURE__ */ jsx34(UserActionBarRoot, { hideWhenRunning: true, autohide: "not-last", children: /* @__PURE__ */ jsx34(UserActionBarEdit, {}) });
|
4416
3063
|
};
|
4417
3064
|
UserActionBar.displayName = "UserActionBar";
|
4418
3065
|
var UserActionBarRoot = withDefaults(actionBar_exports.Root, {
|
4419
3066
|
className: "aui-user-action-bar-root"
|
4420
3067
|
});
|
4421
3068
|
UserActionBarRoot.displayName = "UserActionBarRoot";
|
4422
|
-
var UserActionBarEdit =
|
3069
|
+
var UserActionBarEdit = forwardRef20((props, ref) => {
|
4423
3070
|
const {
|
4424
3071
|
strings: { userMessage: { edit: { tooltip = "Edit" } = {} } = {} } = {}
|
4425
3072
|
} = useThreadConfig();
|
4426
3073
|
const allowEdit = useAllowEdit();
|
4427
3074
|
if (!allowEdit) return null;
|
4428
|
-
return /* @__PURE__ */
|
3075
|
+
return /* @__PURE__ */ jsx34(actionBar_exports.Edit, { asChild: true, children: /* @__PURE__ */ jsx34(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx34(PencilIcon, {}) }) });
|
4429
3076
|
});
|
4430
3077
|
UserActionBarEdit.displayName = "UserActionBarEdit";
|
4431
3078
|
var exports7 = {
|
@@ -4435,12 +3082,12 @@ var exports7 = {
|
|
4435
3082
|
var user_action_bar_default = Object.assign(UserActionBar, exports7);
|
4436
3083
|
|
4437
3084
|
// src/ui/user-message.tsx
|
4438
|
-
import { jsx as
|
3085
|
+
import { jsx as jsx35, jsxs as jsxs10 } from "react/jsx-runtime";
|
4439
3086
|
var UserMessage = () => {
|
4440
|
-
return /* @__PURE__ */
|
4441
|
-
/* @__PURE__ */
|
4442
|
-
/* @__PURE__ */
|
4443
|
-
/* @__PURE__ */
|
3087
|
+
return /* @__PURE__ */ jsxs10(UserMessageRoot, { children: [
|
3088
|
+
/* @__PURE__ */ jsx35(user_action_bar_default, {}),
|
3089
|
+
/* @__PURE__ */ jsx35(UserMessageContent, {}),
|
3090
|
+
/* @__PURE__ */ jsx35(branch_picker_default, {})
|
4444
3091
|
] });
|
4445
3092
|
};
|
4446
3093
|
UserMessage.displayName = "UserMessage";
|
@@ -4451,9 +3098,9 @@ UserMessageRoot.displayName = "UserMessageRoot";
|
|
4451
3098
|
var UserMessageContentWrapper = withDefaults("div", {
|
4452
3099
|
className: "aui-user-message-content"
|
4453
3100
|
});
|
4454
|
-
var UserMessageContent =
|
3101
|
+
var UserMessageContent = forwardRef21(
|
4455
3102
|
({ components, ...props }, ref) => {
|
4456
|
-
return /* @__PURE__ */
|
3103
|
+
return /* @__PURE__ */ jsx35(UserMessageContentWrapper, { ...props, ref, children: /* @__PURE__ */ jsx35(
|
4457
3104
|
message_exports.Content,
|
4458
3105
|
{
|
4459
3106
|
components: {
|
@@ -4472,14 +3119,14 @@ var exports8 = {
|
|
4472
3119
|
var user_message_default = Object.assign(UserMessage, exports8);
|
4473
3120
|
|
4474
3121
|
// src/ui/edit-composer.tsx
|
4475
|
-
import { forwardRef as
|
4476
|
-
import { jsx as
|
3122
|
+
import { forwardRef as forwardRef22 } from "react";
|
3123
|
+
import { jsx as jsx36, jsxs as jsxs11 } from "react/jsx-runtime";
|
4477
3124
|
var EditComposer = () => {
|
4478
|
-
return /* @__PURE__ */
|
4479
|
-
/* @__PURE__ */
|
4480
|
-
/* @__PURE__ */
|
4481
|
-
/* @__PURE__ */
|
4482
|
-
/* @__PURE__ */
|
3125
|
+
return /* @__PURE__ */ jsxs11(EditComposerRoot, { children: [
|
3126
|
+
/* @__PURE__ */ jsx36(EditComposerInput, {}),
|
3127
|
+
/* @__PURE__ */ jsxs11(EditComposerFooter, { children: [
|
3128
|
+
/* @__PURE__ */ jsx36(EditComposerCancel, {}),
|
3129
|
+
/* @__PURE__ */ jsx36(EditComposerSend, {})
|
4483
3130
|
] })
|
4484
3131
|
] });
|
4485
3132
|
};
|
@@ -4496,23 +3143,23 @@ var EditComposerFooter = withDefaults("div", {
|
|
4496
3143
|
className: "aui-edit-composer-footer"
|
4497
3144
|
});
|
4498
3145
|
EditComposerFooter.displayName = "EditComposerFooter";
|
4499
|
-
var EditComposerCancel =
|
3146
|
+
var EditComposerCancel = forwardRef22(
|
4500
3147
|
(props, ref) => {
|
4501
3148
|
const {
|
4502
3149
|
strings: {
|
4503
3150
|
editComposer: { cancel: { label = "Cancel" } = {} } = {}
|
4504
3151
|
} = {}
|
4505
3152
|
} = useThreadConfig();
|
4506
|
-
return /* @__PURE__ */
|
3153
|
+
return /* @__PURE__ */ jsx36(composer_exports.Cancel, { asChild: true, children: /* @__PURE__ */ jsx36(Button, { variant: "ghost", ...props, ref, children: props.children ?? label }) });
|
4507
3154
|
}
|
4508
3155
|
);
|
4509
3156
|
EditComposerCancel.displayName = "EditComposerCancel";
|
4510
|
-
var EditComposerSend =
|
3157
|
+
var EditComposerSend = forwardRef22(
|
4511
3158
|
(props, ref) => {
|
4512
3159
|
const {
|
4513
3160
|
strings: { editComposer: { send: { label = "Send" } = {} } = {} } = {}
|
4514
3161
|
} = useThreadConfig();
|
4515
|
-
return /* @__PURE__ */
|
3162
|
+
return /* @__PURE__ */ jsx36(composer_exports.Send, { asChild: true, children: /* @__PURE__ */ jsx36(Button, { ...props, ref, children: props.children ?? label }) });
|
4516
3163
|
}
|
4517
3164
|
);
|
4518
3165
|
EditComposerSend.displayName = "EditComposerSend";
|
@@ -4526,23 +3173,23 @@ var exports9 = {
|
|
4526
3173
|
var edit_composer_default = Object.assign(EditComposer, exports9);
|
4527
3174
|
|
4528
3175
|
// src/ui/thread.tsx
|
4529
|
-
import { jsx as
|
3176
|
+
import { jsx as jsx37, jsxs as jsxs12 } from "react/jsx-runtime";
|
4530
3177
|
var Thread = (config) => {
|
4531
|
-
return /* @__PURE__ */
|
4532
|
-
/* @__PURE__ */
|
4533
|
-
/* @__PURE__ */
|
4534
|
-
/* @__PURE__ */
|
4535
|
-
/* @__PURE__ */
|
4536
|
-
/* @__PURE__ */
|
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, {})
|
4537
3184
|
] })
|
4538
3185
|
] }) });
|
4539
3186
|
};
|
4540
3187
|
var ThreadRootStyled = withDefaults(thread_exports.Root, {
|
4541
3188
|
className: "aui-root aui-thread-root"
|
4542
3189
|
});
|
4543
|
-
var ThreadRoot =
|
3190
|
+
var ThreadRoot = forwardRef23(
|
4544
3191
|
({ config, ...props }, ref) => {
|
4545
|
-
return /* @__PURE__ */
|
3192
|
+
return /* @__PURE__ */ jsx37(ThreadConfigProvider, { config, children: /* @__PURE__ */ jsx37(ThreadRootStyled, { ...props, ref }) });
|
4546
3193
|
}
|
4547
3194
|
);
|
4548
3195
|
ThreadRoot.displayName = "ThreadRoot";
|
@@ -4556,7 +3203,7 @@ var ThreadViewportFooter = withDefaults("div", {
|
|
4556
3203
|
ThreadViewportFooter.displayName = "ThreadViewportFooter";
|
4557
3204
|
var SystemMessage = () => null;
|
4558
3205
|
var ThreadMessages = ({ components, ...rest }) => {
|
4559
|
-
return /* @__PURE__ */
|
3206
|
+
return /* @__PURE__ */ jsx37(
|
4560
3207
|
thread_exports.Messages,
|
4561
3208
|
{
|
4562
3209
|
components: {
|
@@ -4574,13 +3221,13 @@ var ThreadScrollToBottomIconButton = withDefaults(TooltipIconButton, {
|
|
4574
3221
|
variant: "outline",
|
4575
3222
|
className: "aui-thread-scroll-to-bottom"
|
4576
3223
|
});
|
4577
|
-
var ThreadScrollToBottom =
|
3224
|
+
var ThreadScrollToBottom = forwardRef23((props, ref) => {
|
4578
3225
|
const {
|
4579
3226
|
strings: {
|
4580
3227
|
thread: { scrollToBottom: { tooltip = "Scroll to bottom" } = {} } = {}
|
4581
3228
|
} = {}
|
4582
3229
|
} = useThreadConfig();
|
4583
|
-
return /* @__PURE__ */
|
3230
|
+
return /* @__PURE__ */ jsx37(thread_exports.ScrollToBottom, { asChild: true, children: /* @__PURE__ */ jsx37(ThreadScrollToBottomIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx37(ArrowDownIcon, {}) }) });
|
4584
3231
|
});
|
4585
3232
|
ThreadScrollToBottom.displayName = "ThreadScrollToBottom";
|
4586
3233
|
var exports10 = {
|
@@ -4593,20 +3240,20 @@ var exports10 = {
|
|
4593
3240
|
var thread_default = Object.assign(Thread, exports10);
|
4594
3241
|
|
4595
3242
|
// src/ui/assistant-modal.tsx
|
4596
|
-
import { Fragment as Fragment6, jsx as
|
3243
|
+
import { Fragment as Fragment6, jsx as jsx38, jsxs as jsxs13 } from "react/jsx-runtime";
|
4597
3244
|
var AssistantModal = (config) => {
|
4598
|
-
return /* @__PURE__ */
|
4599
|
-
/* @__PURE__ */
|
4600
|
-
/* @__PURE__ */
|
3245
|
+
return /* @__PURE__ */ jsxs13(AssistantModalRoot, { config, children: [
|
3246
|
+
/* @__PURE__ */ jsx38(AssistantModalTrigger, {}),
|
3247
|
+
/* @__PURE__ */ jsx38(AssistantModalContent, { children: /* @__PURE__ */ jsx38(thread_default, {}) })
|
4601
3248
|
] });
|
4602
3249
|
};
|
4603
3250
|
AssistantModal.displayName = "AssistantModal";
|
4604
3251
|
var AssistantModalRoot = ({ config, ...props }) => {
|
4605
|
-
return /* @__PURE__ */
|
3252
|
+
return /* @__PURE__ */ jsx38(ThreadConfigProvider, { config, children: /* @__PURE__ */ jsx38(assistantModal_exports.Root, { ...props }) });
|
4606
3253
|
};
|
4607
3254
|
AssistantModalRoot.displayName = "AssistantModalRoot";
|
4608
|
-
var AssistantModalTrigger =
|
4609
|
-
return /* @__PURE__ */
|
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 }) }) });
|
4610
3257
|
});
|
4611
3258
|
AssistantModalTrigger.displayName = "AssistantModalTrigger";
|
4612
3259
|
var AssistantModalAnchor = withDefaults(assistantModal_exports.Anchor, {
|
@@ -4617,7 +3264,7 @@ var ModalButtonStyled = withDefaults(TooltipIconButton, {
|
|
4617
3264
|
variant: "default",
|
4618
3265
|
className: "aui-modal-button"
|
4619
3266
|
});
|
4620
|
-
var AssistantModalButton =
|
3267
|
+
var AssistantModalButton = forwardRef24(({ "data-state": state, ...rest }, ref) => {
|
4621
3268
|
const {
|
4622
3269
|
strings: {
|
4623
3270
|
assistantModal: {
|
@@ -4631,7 +3278,7 @@ var AssistantModalButton = forwardRef28(({ "data-state": state, ...rest }, ref)
|
|
4631
3278
|
} = {}
|
4632
3279
|
} = useThreadConfig();
|
4633
3280
|
const tooltip = state === "open" ? openTooltip : closedTooltip;
|
4634
|
-
return /* @__PURE__ */
|
3281
|
+
return /* @__PURE__ */ jsx38(
|
4635
3282
|
ModalButtonStyled,
|
4636
3283
|
{
|
4637
3284
|
side: "left",
|
@@ -4639,15 +3286,15 @@ var AssistantModalButton = forwardRef28(({ "data-state": state, ...rest }, ref)
|
|
4639
3286
|
"data-state": state,
|
4640
3287
|
...rest,
|
4641
3288
|
ref,
|
4642
|
-
children: rest.children ?? /* @__PURE__ */
|
4643
|
-
/* @__PURE__ */
|
3289
|
+
children: rest.children ?? /* @__PURE__ */ jsxs13(Fragment6, { children: [
|
3290
|
+
/* @__PURE__ */ jsx38(
|
4644
3291
|
BotIcon,
|
4645
3292
|
{
|
4646
3293
|
"data-state": state,
|
4647
3294
|
className: "aui-modal-button-closed-icon"
|
4648
3295
|
}
|
4649
3296
|
),
|
4650
|
-
/* @__PURE__ */
|
3297
|
+
/* @__PURE__ */ jsx38(
|
4651
3298
|
ChevronDownIcon,
|
4652
3299
|
{
|
4653
3300
|
"data-state": state,
|