@assistant-ui/react 0.5.65 → 0.5.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +346 -297
- package/dist/index.d.ts +346 -297
- package/dist/index.js +341 -441
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +470 -570
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
@@ -16,10 +16,7 @@ import {
|
|
16
16
|
} from "./chunk-BJPOCE4O.mjs";
|
17
17
|
|
18
18
|
// src/context/providers/AssistantRuntimeProvider.tsx
|
19
|
-
import { memo } from "react";
|
20
|
-
|
21
|
-
// src/context/providers/AssistantProvider.tsx
|
22
|
-
import { useEffect as useEffect2, useInsertionEffect, useRef, useState as useState2 } from "react";
|
19
|
+
import { memo, useEffect as useEffect2, useMemo as useMemo2, useState as useState2 } from "react";
|
23
20
|
|
24
21
|
// src/context/react/AssistantContext.ts
|
25
22
|
import { createContext } from "react";
|
@@ -122,8 +119,8 @@ var makeAssistantToolUIsStore = () => create((set) => {
|
|
122
119
|
});
|
123
120
|
});
|
124
121
|
|
125
|
-
// src/context/providers/
|
126
|
-
import { useEffect, useState } from "react";
|
122
|
+
// src/context/providers/ThreadRuntimeProvider.tsx
|
123
|
+
import { useEffect, useMemo, useState } from "react";
|
127
124
|
|
128
125
|
// src/context/react/ThreadContext.ts
|
129
126
|
import { createContext as createContext2 } from "react";
|
@@ -160,10 +157,9 @@ var {
|
|
160
157
|
|
161
158
|
// src/context/stores/ThreadComposer.ts
|
162
159
|
import { create as create2 } from "zustand";
|
163
|
-
var makeThreadComposerStore = (
|
160
|
+
var makeThreadComposerStore = (runtime) => {
|
164
161
|
const focusListeners = /* @__PURE__ */ new Set();
|
165
162
|
return create2()((_, get) => {
|
166
|
-
const runtime = useThreadRuntime2.getState();
|
167
163
|
return {
|
168
164
|
type: "thread",
|
169
165
|
get value() {
|
@@ -172,30 +168,27 @@ var makeThreadComposerStore = (useThreadRuntime2) => {
|
|
172
168
|
setValue(value) {
|
173
169
|
get().setText(value);
|
174
170
|
},
|
175
|
-
|
176
|
-
|
171
|
+
...runtime.getState(),
|
172
|
+
canCancel: false,
|
173
|
+
// "TODO",
|
174
|
+
isEditing: true,
|
177
175
|
addAttachment: (file) => {
|
178
|
-
|
176
|
+
runtime.addAttachment(file);
|
179
177
|
},
|
180
178
|
removeAttachment: (attachmentId) => {
|
181
|
-
|
179
|
+
runtime.removeAttachment(attachmentId);
|
182
180
|
},
|
183
181
|
reset: () => {
|
184
|
-
|
182
|
+
runtime.reset();
|
185
183
|
},
|
186
|
-
text: runtime.composer.text,
|
187
184
|
setText: (text) => {
|
188
|
-
|
185
|
+
runtime.setText(text);
|
189
186
|
},
|
190
|
-
canCancel: runtime.capabilities.cancel,
|
191
|
-
isEditing: true,
|
192
|
-
isEmpty: runtime.composer.isEmpty,
|
193
187
|
send: () => {
|
194
|
-
|
195
|
-
runtime2.composer.send();
|
188
|
+
runtime.send();
|
196
189
|
},
|
197
190
|
cancel: () => {
|
198
|
-
|
191
|
+
runtime.cancel();
|
199
192
|
},
|
200
193
|
focus: () => {
|
201
194
|
for (const listener of focusListeners) {
|
@@ -212,27 +205,11 @@ var makeThreadComposerStore = (useThreadRuntime2) => {
|
|
212
205
|
});
|
213
206
|
};
|
214
207
|
|
215
|
-
// src/context/stores/Thread.ts
|
216
|
-
import { create as create3 } from "zustand";
|
217
|
-
var getThreadStateFromRuntime = (runtime) => {
|
218
|
-
const lastMessage = runtime.messages.at(-1);
|
219
|
-
return Object.freeze({
|
220
|
-
threadId: runtime.threadId,
|
221
|
-
capabilities: runtime.capabilities,
|
222
|
-
isDisabled: runtime.isDisabled,
|
223
|
-
isRunning: lastMessage?.role !== "assistant" ? false : lastMessage.status.type === "running"
|
224
|
-
});
|
225
|
-
};
|
226
|
-
var makeThreadStore = (runtimeRef) => {
|
227
|
-
const runtime = runtimeRef.getState();
|
228
|
-
return create3(() => getThreadStateFromRuntime(runtime));
|
229
|
-
};
|
230
|
-
|
231
208
|
// src/context/stores/ThreadViewport.tsx
|
232
|
-
import { create as
|
209
|
+
import { create as create3 } from "zustand";
|
233
210
|
var makeThreadViewportStore = () => {
|
234
211
|
const scrollToBottomListeners = /* @__PURE__ */ new Set();
|
235
|
-
return
|
212
|
+
return create3(() => ({
|
236
213
|
isAtBottom: true,
|
237
214
|
scrollToBottom: () => {
|
238
215
|
for (const listener of scrollToBottomListeners) {
|
@@ -248,85 +225,65 @@ var makeThreadViewportStore = () => {
|
|
248
225
|
}));
|
249
226
|
};
|
250
227
|
|
251
|
-
// src/context/stores/ThreadMessages.ts
|
252
|
-
import { create as create5 } from "zustand";
|
253
|
-
var makeThreadMessagesStore = (runtimeRef) => {
|
254
|
-
return create5(() => runtimeRef.getState().messages);
|
255
|
-
};
|
256
|
-
|
257
228
|
// src/context/ReadonlyStore.ts
|
258
229
|
var writableStore = (store) => {
|
259
230
|
return store;
|
260
231
|
};
|
261
232
|
|
262
|
-
// src/context/providers/
|
263
|
-
import { create as
|
233
|
+
// src/context/providers/ThreadRuntimeProvider.tsx
|
234
|
+
import { create as create4 } from "zustand";
|
264
235
|
import { jsx, jsxs } from "react/jsx-runtime";
|
265
|
-
var
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
236
|
+
var useThreadRuntimeStore2 = (runtime) => {
|
237
|
+
const [store] = useState(() => create4(() => runtime));
|
238
|
+
useEffect(() => {
|
239
|
+
writableStore(store).setState(runtime, true);
|
240
|
+
}, [runtime, store]);
|
241
|
+
return store;
|
242
|
+
};
|
243
|
+
var useThreadStore2 = (runtime) => {
|
244
|
+
const [store] = useState(() => create4(() => runtime.getState()));
|
245
|
+
useEffect(() => {
|
246
|
+
const updateState = () => writableStore(store).setState(runtime.getState(), true);
|
247
|
+
updateState();
|
248
|
+
return runtime.subscribe(updateState);
|
249
|
+
}, [runtime, store]);
|
250
|
+
return store;
|
251
|
+
};
|
252
|
+
var useThreadMessagesStore2 = (runtime) => {
|
253
|
+
const [store] = useState(() => create4(() => runtime.messages));
|
254
|
+
useEffect(() => {
|
255
|
+
const updateState = () => writableStore(store).setState(runtime.messages, true);
|
256
|
+
updateState();
|
257
|
+
return runtime.subscribe(updateState);
|
258
|
+
}, [runtime, store]);
|
259
|
+
return store;
|
260
|
+
};
|
261
|
+
var useThreadComposerStore2 = (runtime) => {
|
262
|
+
const [store] = useState(() => makeThreadComposerStore(runtime));
|
263
|
+
useEffect(() => {
|
264
|
+
const updateState = () => writableStore(store).setState(runtime.getState());
|
265
|
+
updateState();
|
266
|
+
return runtime.subscribe(updateState);
|
267
|
+
}, [runtime, store]);
|
268
|
+
return store;
|
269
|
+
};
|
270
|
+
var ThreadRuntimeProvider = ({ children, runtime }) => {
|
271
|
+
const useThreadRuntime2 = useThreadRuntimeStore2(runtime);
|
272
|
+
const useThread2 = useThreadStore2(runtime);
|
273
|
+
const useThreadMessages2 = useThreadMessagesStore2(runtime);
|
274
|
+
const useThreadComposer2 = useThreadComposerStore2(runtime.composer);
|
275
|
+
const context = useMemo(() => {
|
273
276
|
const useViewport = makeThreadViewportStore();
|
274
|
-
const useComposer2 = makeThreadComposerStore(useThreadRuntime2);
|
275
277
|
return {
|
276
278
|
useThread: useThread2,
|
277
279
|
useThreadRuntime: useThreadRuntime2,
|
278
280
|
useThreadMessages: useThreadMessages2,
|
279
281
|
useThreadActions: useThreadRuntime2,
|
280
|
-
useComposer:
|
282
|
+
useComposer: useThreadComposer2,
|
281
283
|
useViewport
|
282
284
|
};
|
283
|
-
});
|
284
|
-
|
285
|
-
const onThreadUpdate = () => {
|
286
|
-
const oldState = context.useThread.getState();
|
287
|
-
const state = getThreadStateFromRuntime(thread);
|
288
|
-
if (oldState.threadId !== state.threadId || oldState.isDisabled !== state.isDisabled || oldState.isRunning !== state.isRunning || oldState.capabilities !== state.capabilities) {
|
289
|
-
writableStore(context.useThread).setState(state, true);
|
290
|
-
}
|
291
|
-
if (thread.messages !== context.useThreadMessages.getState()) {
|
292
|
-
writableStore(context.useThreadMessages).setState(
|
293
|
-
thread.messages,
|
294
|
-
true
|
295
|
-
);
|
296
|
-
}
|
297
|
-
const composerState = context.useComposer.getState();
|
298
|
-
if (state.capabilities.cancel !== composerState.canCancel) {
|
299
|
-
writableStore(context.useComposer).setState({
|
300
|
-
canCancel: state.capabilities.cancel
|
301
|
-
});
|
302
|
-
}
|
303
|
-
};
|
304
|
-
onThreadUpdate();
|
305
|
-
return thread.subscribe(onThreadUpdate);
|
306
|
-
}, [thread, context]);
|
307
|
-
useEffect(() => {
|
308
|
-
const onComposerUpdate = () => {
|
309
|
-
const composer = thread.composer;
|
310
|
-
const composerState = context.useComposer.getState();
|
311
|
-
if (composer.isEmpty !== composerState.isEmpty || composer.text !== composerState.text || composer.attachmentAccept !== composerState.attachmentAccept || composer.attachments !== composerState.attachments) {
|
312
|
-
writableStore(context.useComposer).setState({
|
313
|
-
isEmpty: composer.isEmpty,
|
314
|
-
text: composer.text,
|
315
|
-
attachmentAccept: composer.attachmentAccept,
|
316
|
-
attachments: composer.attachments
|
317
|
-
});
|
318
|
-
}
|
319
|
-
};
|
320
|
-
onComposerUpdate();
|
321
|
-
return thread.composer.subscribe(onComposerUpdate);
|
322
|
-
}, [thread, context]);
|
323
|
-
useEffect(
|
324
|
-
() => thread.subscribe(() => {
|
325
|
-
writableStore(context.useThreadRuntime).setState(thread, true);
|
326
|
-
}),
|
327
|
-
[thread, context]
|
328
|
-
);
|
329
|
-
const Synchronizer = context.useThreadRuntime(
|
285
|
+
}, [useThread2, useThreadRuntime2, useThreadMessages2, useThreadComposer2]);
|
286
|
+
const Synchronizer = context.useThread(
|
330
287
|
(t) => t.unstable_synchronizer
|
331
288
|
);
|
332
289
|
return /* @__PURE__ */ jsxs(ThreadContext.Provider, { value: context, children: [
|
@@ -335,40 +292,36 @@ var ThreadProvider = ({
|
|
335
292
|
] });
|
336
293
|
};
|
337
294
|
|
338
|
-
// src/context/providers/
|
339
|
-
import { create as
|
295
|
+
// src/context/providers/AssistantRuntimeProvider.tsx
|
296
|
+
import { create as create5 } from "zustand";
|
340
297
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
341
|
-
var
|
342
|
-
const
|
343
|
-
|
344
|
-
|
345
|
-
});
|
346
|
-
|
347
|
-
|
348
|
-
|
298
|
+
var useAssistantRuntimeStore2 = (runtime) => {
|
299
|
+
const [store] = useState2(() => create5(() => runtime));
|
300
|
+
useEffect2(() => {
|
301
|
+
writableStore(store).setState(runtime, true);
|
302
|
+
}, [runtime, store]);
|
303
|
+
return store;
|
304
|
+
};
|
305
|
+
var useAssistantToolUIsStore = () => {
|
306
|
+
return useMemo2(() => makeAssistantToolUIsStore(), []);
|
307
|
+
};
|
308
|
+
var AssistantRuntimeProviderImpl = ({ children, runtime }) => {
|
309
|
+
const useAssistantRuntime2 = useAssistantRuntimeStore2(runtime);
|
310
|
+
const useToolUIs2 = useAssistantToolUIsStore();
|
311
|
+
const context = useMemo2(() => {
|
349
312
|
return {
|
350
313
|
useToolUIs: useToolUIs2,
|
351
314
|
useAssistantRuntime: useAssistantRuntime2,
|
352
315
|
useAssistantActions: useAssistantRuntime2
|
353
316
|
};
|
354
|
-
});
|
355
|
-
|
356
|
-
() => writableStore(context.useAssistantRuntime).setState(runtime, true),
|
357
|
-
[runtime, context]
|
358
|
-
);
|
359
|
-
return /* @__PURE__ */ jsx2(AssistantContext.Provider, { value: context, children: /* @__PURE__ */ jsx2(ThreadProvider, { provider: runtime.thread, children }) });
|
360
|
-
};
|
361
|
-
|
362
|
-
// src/context/providers/AssistantRuntimeProvider.tsx
|
363
|
-
import { jsx as jsx3 } from "react/jsx-runtime";
|
364
|
-
var AssistantRuntimeProviderImpl = ({ children, runtime }) => {
|
365
|
-
return /* @__PURE__ */ jsx3(AssistantProvider, { runtime, children });
|
317
|
+
}, [useAssistantRuntime2, useToolUIs2]);
|
318
|
+
return /* @__PURE__ */ jsx2(AssistantContext.Provider, { value: context, children: /* @__PURE__ */ jsx2(ThreadRuntimeProvider, { runtime: runtime.thread, children }) });
|
366
319
|
};
|
367
320
|
var AssistantRuntimeProvider = memo(AssistantRuntimeProviderImpl);
|
368
321
|
|
369
322
|
// src/context/providers/TextContentPartProvider.tsx
|
370
323
|
import { useEffect as useEffect3, useState as useState3 } from "react";
|
371
|
-
import { create as
|
324
|
+
import { create as create6 } from "zustand";
|
372
325
|
|
373
326
|
// src/context/react/ContentPartContext.ts
|
374
327
|
import { createContext as createContext3 } from "react";
|
@@ -385,7 +338,7 @@ var { useContentPart, useContentPartStore } = createContextStoreHook(
|
|
385
338
|
);
|
386
339
|
|
387
340
|
// src/context/providers/TextContentPartProvider.tsx
|
388
|
-
import { jsx as
|
341
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
389
342
|
var COMPLETE_STATUS = {
|
390
343
|
type: "complete"
|
391
344
|
};
|
@@ -394,7 +347,7 @@ var RUNNING_STATUS = {
|
|
394
347
|
};
|
395
348
|
var TextContentPartProvider = ({ children, text, isRunning }) => {
|
396
349
|
const [context] = useState3(() => {
|
397
|
-
const useContentPart2 =
|
350
|
+
const useContentPart2 = create6(() => ({
|
398
351
|
status: isRunning ? RUNNING_STATUS : COMPLETE_STATUS,
|
399
352
|
part: { type: "text", text }
|
400
353
|
}));
|
@@ -417,7 +370,7 @@ var TextContentPartProvider = ({ children, text, isRunning }) => {
|
|
417
370
|
true
|
418
371
|
);
|
419
372
|
}, [context, isRunning, text]);
|
420
|
-
return /* @__PURE__ */
|
373
|
+
return /* @__PURE__ */ jsx3(ContentPartContext.Provider, { value: context, children });
|
421
374
|
};
|
422
375
|
|
423
376
|
// src/context/react/MessageContext.ts
|
@@ -427,6 +380,11 @@ var useMessageContext = createContextHook(
|
|
427
380
|
MessageContext,
|
428
381
|
"a component passed to <ThreadPrimitive.Messages components={...} />"
|
429
382
|
);
|
383
|
+
function useMessageRuntime(options) {
|
384
|
+
const context = useMessageContext(options);
|
385
|
+
if (!context) return null;
|
386
|
+
return context.useMessageRuntime();
|
387
|
+
}
|
430
388
|
var { useMessage, useMessageStore } = createContextStoreHook(
|
431
389
|
useMessageContext,
|
432
390
|
"useMessage"
|
@@ -441,11 +399,11 @@ var { useEditComposer, useEditComposerStore } = createContextStoreHook(
|
|
441
399
|
);
|
442
400
|
|
443
401
|
// src/context/react/ComposerContext.ts
|
444
|
-
import { useMemo } from "react";
|
402
|
+
import { useMemo as useMemo3 } from "react";
|
445
403
|
var useComposerContext = () => {
|
446
404
|
const { useComposer: useComposer2 } = useThreadContext();
|
447
405
|
const { useEditComposer: useEditComposer2 } = useMessageContext({ optional: true }) ?? {};
|
448
|
-
return
|
406
|
+
return useMemo3(
|
449
407
|
() => ({
|
450
408
|
useComposer: useEditComposer2 ?? useComposer2,
|
451
409
|
type: useEditComposer2 ? "edit" : "new"
|
@@ -460,40 +418,17 @@ var { useComposer, useComposerStore } = createContextStoreHook(
|
|
460
418
|
|
461
419
|
// src/hooks/useAppendMessage.tsx
|
462
420
|
import { useCallback } from "react";
|
463
|
-
var toAppendMessage = (useThreadMessages2, message) => {
|
464
|
-
if (typeof message === "string") {
|
465
|
-
return {
|
466
|
-
parentId: useThreadMessages2.getState().at(-1)?.id ?? null,
|
467
|
-
role: "user",
|
468
|
-
content: [{ type: "text", text: message }],
|
469
|
-
attachments: []
|
470
|
-
};
|
471
|
-
}
|
472
|
-
return {
|
473
|
-
parentId: message.parentId ?? useThreadMessages2.getState().at(-1)?.id ?? null,
|
474
|
-
role: message.role ?? "user",
|
475
|
-
content: message.content,
|
476
|
-
attachments: message.attachments ?? []
|
477
|
-
};
|
478
|
-
};
|
479
421
|
var useAppendMessage = () => {
|
480
|
-
const threadMessagesStore = useThreadMessagesStore();
|
481
422
|
const threadRuntime = useThreadRuntime();
|
482
423
|
const threadViewportStore = useThreadViewportStore();
|
483
424
|
const threadComposerStore = useThreadComposerStore();
|
484
425
|
const append = useCallback(
|
485
426
|
(message) => {
|
486
|
-
|
487
|
-
threadRuntime.append(appendMessage);
|
427
|
+
threadRuntime.append(message);
|
488
428
|
threadViewportStore.getState().scrollToBottom();
|
489
429
|
threadComposerStore.getState().focus();
|
490
430
|
},
|
491
|
-
[
|
492
|
-
threadMessagesStore,
|
493
|
-
threadRuntime,
|
494
|
-
threadViewportStore,
|
495
|
-
threadComposerStore
|
496
|
-
]
|
431
|
+
[threadRuntime, threadViewportStore, threadComposerStore]
|
497
432
|
);
|
498
433
|
return append;
|
499
434
|
};
|
@@ -582,7 +517,7 @@ var useAssistantInstructions = (instruction) => {
|
|
582
517
|
import { useCallback as useCallback3 } from "react";
|
583
518
|
|
584
519
|
// src/utils/combined/useCombinedStore.ts
|
585
|
-
import { useMemo as
|
520
|
+
import { useMemo as useMemo4 } from "react";
|
586
521
|
|
587
522
|
// src/utils/combined/createCombinedStore.ts
|
588
523
|
import { useSyncExternalStore } from "react";
|
@@ -603,7 +538,7 @@ var createCombinedStore = (stores) => {
|
|
603
538
|
|
604
539
|
// src/utils/combined/useCombinedStore.ts
|
605
540
|
var useCombinedStore = (stores, selector) => {
|
606
|
-
const useCombined =
|
541
|
+
const useCombined = useMemo4(() => createCombinedStore(stores), stores);
|
607
542
|
return useCombined(selector);
|
608
543
|
};
|
609
544
|
|
@@ -624,12 +559,12 @@ var useActionBarCopy = ({
|
|
624
559
|
const editComposerStore = useEditComposerStore();
|
625
560
|
const hasCopyableContent = useCombinedStore(
|
626
561
|
[messageStore, editComposerStore],
|
627
|
-
(
|
562
|
+
(message, c) => {
|
628
563
|
return !c.isEditing && (message.role !== "assistant" || message.status.type !== "running") && message.content.some((c2) => c2.type === "text" && c2.text.length > 0);
|
629
564
|
}
|
630
565
|
);
|
631
566
|
const callback = useCallback3(() => {
|
632
|
-
const
|
567
|
+
const message = messageStore.getState();
|
633
568
|
const { setIsCopied } = messageUtilsStore.getState();
|
634
569
|
const { isEditing, text: composerValue } = editComposerStore.getState();
|
635
570
|
const valueToCopy = isEditing ? composerValue : getThreadMessageText(message);
|
@@ -665,7 +600,7 @@ var useActionBarReload = () => {
|
|
665
600
|
const threadViewportStore = useThreadViewportStore();
|
666
601
|
const disabled = useCombinedStore(
|
667
602
|
[threadStore, messageStore],
|
668
|
-
(t, m) => t.isRunning || t.isDisabled || m.
|
603
|
+
(t, m) => t.isRunning || t.isDisabled || m.role !== "assistant"
|
669
604
|
);
|
670
605
|
const callback = useCallback5(() => {
|
671
606
|
const { parentId } = messageStore.getState();
|
@@ -719,7 +654,7 @@ var useActionBarFeedbackPositive = () => {
|
|
719
654
|
const messageUtilsStore = useMessageUtilsStore();
|
720
655
|
const callback = useCallback8(() => {
|
721
656
|
threadRuntime.submitFeedback({
|
722
|
-
messageId: messageStore.getState().
|
657
|
+
messageId: messageStore.getState().id,
|
723
658
|
type: "positive"
|
724
659
|
});
|
725
660
|
messageUtilsStore.getState().setSubmittedFeedback("positive");
|
@@ -735,7 +670,7 @@ var useActionBarFeedbackNegative = () => {
|
|
735
670
|
const messageUtilsStore = useMessageUtilsStore();
|
736
671
|
const callback = useCallback9(() => {
|
737
672
|
threadRuntime.submitFeedback({
|
738
|
-
messageId: messageStore.getState().
|
673
|
+
messageId: messageStore.getState().id,
|
739
674
|
type: "negative"
|
740
675
|
});
|
741
676
|
messageUtilsStore.getState().setSubmittedFeedback("negative");
|
@@ -745,48 +680,46 @@ var useActionBarFeedbackNegative = () => {
|
|
745
680
|
|
746
681
|
// src/primitive-hooks/branchPicker/useBranchPickerCount.tsx
|
747
682
|
var useBranchPickerCount = () => {
|
748
|
-
const branchCount = useMessage((s) => s.
|
683
|
+
const branchCount = useMessage((s) => s.branchCount);
|
749
684
|
return branchCount;
|
750
685
|
};
|
751
686
|
|
752
687
|
// src/primitive-hooks/branchPicker/useBranchPickerNext.tsx
|
753
688
|
import { useCallback as useCallback10 } from "react";
|
754
689
|
var useBranchPickerNext = () => {
|
690
|
+
const messageRuntime = useMessageRuntime();
|
755
691
|
const messageStore = useMessageStore();
|
756
692
|
const editComposerStore = useEditComposerStore();
|
757
|
-
const threadRuntime = useThreadRuntime();
|
758
693
|
const disabled = useCombinedStore(
|
759
694
|
[messageStore, editComposerStore],
|
760
|
-
(m, c) => c.isEditing || m.
|
695
|
+
(m, c) => c.isEditing || m.branchNumber >= m.branchCount
|
761
696
|
);
|
762
697
|
const callback = useCallback10(() => {
|
763
|
-
|
764
|
-
|
765
|
-
}, [threadRuntime, messageStore]);
|
698
|
+
messageRuntime.switchToBranch({ position: "next" });
|
699
|
+
}, [messageRuntime]);
|
766
700
|
if (disabled) return null;
|
767
701
|
return callback;
|
768
702
|
};
|
769
703
|
|
770
704
|
// src/primitive-hooks/branchPicker/useBranchPickerNumber.tsx
|
771
705
|
var useBranchPickerNumber = () => {
|
772
|
-
const
|
773
|
-
return
|
706
|
+
const branchNumber = useMessage((s) => s.branchNumber);
|
707
|
+
return branchNumber;
|
774
708
|
};
|
775
709
|
|
776
710
|
// src/primitive-hooks/branchPicker/useBranchPickerPrevious.tsx
|
777
711
|
import { useCallback as useCallback11 } from "react";
|
778
712
|
var useBranchPickerPrevious = () => {
|
713
|
+
const messageRuntime = useMessageRuntime();
|
779
714
|
const messageStore = useMessageStore();
|
780
715
|
const editComposerStore = useEditComposerStore();
|
781
|
-
const threadRuntime = useThreadRuntime();
|
782
716
|
const disabled = useCombinedStore(
|
783
717
|
[messageStore, editComposerStore],
|
784
|
-
(m, c) => c.isEditing || m.
|
718
|
+
(m, c) => c.isEditing || m.branchNumber <= 1
|
785
719
|
);
|
786
720
|
const callback = useCallback11(() => {
|
787
|
-
|
788
|
-
|
789
|
-
}, [threadRuntime, messageStore]);
|
721
|
+
messageRuntime.switchToBranch({ position: "previous" });
|
722
|
+
}, [messageRuntime]);
|
790
723
|
if (disabled) return null;
|
791
724
|
return callback;
|
792
725
|
};
|
@@ -902,19 +835,19 @@ var useMessageIf = (props) => {
|
|
902
835
|
const messageUtilsStore = useMessageUtilsStore();
|
903
836
|
return useCombinedStore(
|
904
837
|
[messageStore, messageUtilsStore],
|
905
|
-
({
|
906
|
-
if (props.hasBranches === true &&
|
907
|
-
if (props.user &&
|
908
|
-
if (props.assistant &&
|
909
|
-
if (props.system &&
|
838
|
+
({ role, attachments, branchCount, isLast }, { isCopied, isHovering, isSpeaking, submittedFeedback }) => {
|
839
|
+
if (props.hasBranches === true && branchCount < 2) return false;
|
840
|
+
if (props.user && role !== "user") return false;
|
841
|
+
if (props.assistant && role !== "assistant") return false;
|
842
|
+
if (props.system && role !== "system") return false;
|
910
843
|
if (props.lastOrHover === true && !isHovering && !isLast) return false;
|
911
844
|
if (props.copied === true && !isCopied) return false;
|
912
845
|
if (props.copied === false && isCopied) return false;
|
913
846
|
if (props.speaking === true && !isSpeaking) return false;
|
914
847
|
if (props.speaking === false && isSpeaking) return false;
|
915
|
-
if (props.hasAttachments === true && (
|
848
|
+
if (props.hasAttachments === true && (role !== "user" || !attachments.length))
|
916
849
|
return false;
|
917
|
-
if (props.hasAttachments === false &&
|
850
|
+
if (props.hasAttachments === false && role === "user" && !!attachments.length)
|
918
851
|
return false;
|
919
852
|
if (props.submittedFeedback !== void 0 && submittedFeedback !== props.submittedFeedback)
|
920
853
|
return false;
|
@@ -1025,7 +958,7 @@ var useActionBarFloatStatus = ({
|
|
1025
958
|
};
|
1026
959
|
|
1027
960
|
// src/primitives/actionBar/ActionBarRoot.tsx
|
1028
|
-
import { jsx as
|
961
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
1029
962
|
var ActionBarPrimitiveRoot = forwardRef(({ hideWhenRunning, autohide, autohideFloat, ...rest }, ref) => {
|
1030
963
|
const hideAndfloatStatus = useActionBarFloatStatus({
|
1031
964
|
hideWhenRunning,
|
@@ -1033,7 +966,7 @@ var ActionBarPrimitiveRoot = forwardRef(({ hideWhenRunning, autohide, autohideFl
|
|
1033
966
|
autohideFloat
|
1034
967
|
});
|
1035
968
|
if (hideAndfloatStatus === "hidden" /* Hidden */) return null;
|
1036
|
-
return /* @__PURE__ */
|
969
|
+
return /* @__PURE__ */ jsx4(
|
1037
970
|
Primitive.div,
|
1038
971
|
{
|
1039
972
|
...hideAndfloatStatus === "floating" /* Floating */ ? { "data-floating": "true" } : null,
|
@@ -1048,11 +981,11 @@ ActionBarPrimitiveRoot.displayName = "ActionBarPrimitive.Root";
|
|
1048
981
|
import { forwardRef as forwardRef2 } from "react";
|
1049
982
|
import { composeEventHandlers } from "@radix-ui/primitive";
|
1050
983
|
import { Primitive as Primitive2 } from "@radix-ui/react-primitive";
|
1051
|
-
import { jsx as
|
984
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
1052
985
|
var ActionBarPrimitiveCopy = forwardRef2(({ copiedDuration, onClick, disabled, ...props }, forwardedRef) => {
|
1053
986
|
const isCopied = useMessageUtils((u) => u.isCopied);
|
1054
987
|
const callback = useActionBarCopy({ copiedDuration });
|
1055
|
-
return /* @__PURE__ */
|
988
|
+
return /* @__PURE__ */ jsx5(
|
1056
989
|
Primitive2.button,
|
1057
990
|
{
|
1058
991
|
type: "button",
|
@@ -1072,7 +1005,7 @@ ActionBarPrimitiveCopy.displayName = "ActionBarPrimitive.Copy";
|
|
1072
1005
|
import { forwardRef as forwardRef3 } from "react";
|
1073
1006
|
import { Primitive as Primitive3 } from "@radix-ui/react-primitive";
|
1074
1007
|
import { composeEventHandlers as composeEventHandlers2 } from "@radix-ui/primitive";
|
1075
|
-
import { jsx as
|
1008
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
1076
1009
|
var createActionButton = (displayName, useActionButton, forwardProps = []) => {
|
1077
1010
|
const ActionButton = forwardRef3((props, forwardedRef) => {
|
1078
1011
|
const forwardedProps = {};
|
@@ -1085,7 +1018,7 @@ var createActionButton = (displayName, useActionButton, forwardProps = []) => {
|
|
1085
1018
|
}
|
1086
1019
|
});
|
1087
1020
|
const callback = useActionButton(forwardedProps);
|
1088
|
-
return /* @__PURE__ */
|
1021
|
+
return /* @__PURE__ */ jsx6(
|
1089
1022
|
Primitive3.button,
|
1090
1023
|
{
|
1091
1024
|
type: "button",
|
@@ -1125,7 +1058,7 @@ import { forwardRef as forwardRef4 } from "react";
|
|
1125
1058
|
import { useEscapeKeydown } from "@radix-ui/react-use-escape-keydown";
|
1126
1059
|
import { Primitive as Primitive4 } from "@radix-ui/react-primitive";
|
1127
1060
|
import { composeEventHandlers as composeEventHandlers3 } from "@radix-ui/primitive";
|
1128
|
-
import { jsx as
|
1061
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
1129
1062
|
var ActionBarPrimitiveStopSpeaking = forwardRef4((props, ref) => {
|
1130
1063
|
const callback = useActionBarStopSpeaking();
|
1131
1064
|
useEscapeKeydown((e) => {
|
@@ -1134,7 +1067,7 @@ var ActionBarPrimitiveStopSpeaking = forwardRef4((props, ref) => {
|
|
1134
1067
|
callback();
|
1135
1068
|
}
|
1136
1069
|
});
|
1137
|
-
return /* @__PURE__ */
|
1070
|
+
return /* @__PURE__ */ jsx7(
|
1138
1071
|
Primitive4.button,
|
1139
1072
|
{
|
1140
1073
|
type: "button",
|
@@ -1153,13 +1086,13 @@ ActionBarPrimitiveStopSpeaking.displayName = "ActionBarPrimitive.StopSpeaking";
|
|
1153
1086
|
import { forwardRef as forwardRef5 } from "react";
|
1154
1087
|
import { composeEventHandlers as composeEventHandlers4 } from "@radix-ui/primitive";
|
1155
1088
|
import { Primitive as Primitive5 } from "@radix-ui/react-primitive";
|
1156
|
-
import { jsx as
|
1089
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
1157
1090
|
var ActionBarPrimitiveFeedbackPositive = forwardRef5(({ onClick, disabled, ...props }, forwardedRef) => {
|
1158
1091
|
const isSubmitted = useMessageUtils(
|
1159
1092
|
(u) => u.submittedFeedback === "positive"
|
1160
1093
|
);
|
1161
1094
|
const callback = useActionBarFeedbackPositive();
|
1162
|
-
return /* @__PURE__ */
|
1095
|
+
return /* @__PURE__ */ jsx8(
|
1163
1096
|
Primitive5.button,
|
1164
1097
|
{
|
1165
1098
|
type: "button",
|
@@ -1179,13 +1112,13 @@ ActionBarPrimitiveFeedbackPositive.displayName = "ActionBarPrimitive.FeedbackPos
|
|
1179
1112
|
import { forwardRef as forwardRef6 } from "react";
|
1180
1113
|
import { composeEventHandlers as composeEventHandlers5 } from "@radix-ui/primitive";
|
1181
1114
|
import { Primitive as Primitive6 } from "@radix-ui/react-primitive";
|
1182
|
-
import { jsx as
|
1115
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
1183
1116
|
var ActionBarPrimitiveFeedbackNegative = forwardRef6(({ onClick, disabled, ...props }, forwardedRef) => {
|
1184
1117
|
const isSubmitted = useMessageUtils(
|
1185
1118
|
(u) => u.submittedFeedback === "negative"
|
1186
1119
|
);
|
1187
1120
|
const callback = useActionBarFeedbackNegative();
|
1188
|
-
return /* @__PURE__ */
|
1121
|
+
return /* @__PURE__ */ jsx9(
|
1189
1122
|
Primitive6.button,
|
1190
1123
|
{
|
1191
1124
|
type: "button",
|
@@ -1233,7 +1166,7 @@ import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
1233
1166
|
var usePopoverScope = PopoverPrimitive.createPopoverScope();
|
1234
1167
|
|
1235
1168
|
// src/primitives/assistantModal/AssistantModalRoot.tsx
|
1236
|
-
import { jsx as
|
1169
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
1237
1170
|
var useAssistantModalOpenState = (defaultOpen = false) => {
|
1238
1171
|
const state = useState4(defaultOpen);
|
1239
1172
|
const [, setOpen] = state;
|
@@ -1251,7 +1184,7 @@ var AssistantModalPrimitiveRoot = ({
|
|
1251
1184
|
}) => {
|
1252
1185
|
const scope = usePopoverScope(__scopeAssistantModal);
|
1253
1186
|
const [modalOpen, setOpen] = useAssistantModalOpenState(defaultOpen);
|
1254
|
-
return /* @__PURE__ */
|
1187
|
+
return /* @__PURE__ */ jsx10(
|
1255
1188
|
PopoverPrimitive2.Root,
|
1256
1189
|
{
|
1257
1190
|
...scope,
|
@@ -1266,14 +1199,14 @@ AssistantModalPrimitiveRoot.displayName = "AssistantModalPrimitive.Root";
|
|
1266
1199
|
// src/primitives/assistantModal/AssistantModalTrigger.tsx
|
1267
1200
|
import { forwardRef as forwardRef7 } from "react";
|
1268
1201
|
import * as PopoverPrimitive3 from "@radix-ui/react-popover";
|
1269
|
-
import { jsx as
|
1202
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
1270
1203
|
var AssistantModalPrimitiveTrigger = forwardRef7(
|
1271
1204
|
({
|
1272
1205
|
__scopeAssistantModal,
|
1273
1206
|
...rest
|
1274
1207
|
}, ref) => {
|
1275
1208
|
const scope = usePopoverScope(__scopeAssistantModal);
|
1276
|
-
return /* @__PURE__ */
|
1209
|
+
return /* @__PURE__ */ jsx11(PopoverPrimitive3.Trigger, { ...scope, ...rest, ref });
|
1277
1210
|
}
|
1278
1211
|
);
|
1279
1212
|
AssistantModalPrimitiveTrigger.displayName = "AssistantModalPrimitive.Trigger";
|
@@ -1282,7 +1215,7 @@ AssistantModalPrimitiveTrigger.displayName = "AssistantModalPrimitive.Trigger";
|
|
1282
1215
|
import { forwardRef as forwardRef8 } from "react";
|
1283
1216
|
import * as PopoverPrimitive4 from "@radix-ui/react-popover";
|
1284
1217
|
import { composeEventHandlers as composeEventHandlers7 } from "@radix-ui/primitive";
|
1285
|
-
import { jsx as
|
1218
|
+
import { jsx as jsx12 } from "react/jsx-runtime";
|
1286
1219
|
var AssistantModalPrimitiveContent = forwardRef8(
|
1287
1220
|
({
|
1288
1221
|
__scopeAssistantModal,
|
@@ -1293,7 +1226,7 @@ var AssistantModalPrimitiveContent = forwardRef8(
|
|
1293
1226
|
...props
|
1294
1227
|
}, forwardedRef) => {
|
1295
1228
|
const scope = usePopoverScope(__scopeAssistantModal);
|
1296
|
-
return /* @__PURE__ */
|
1229
|
+
return /* @__PURE__ */ jsx12(PopoverPrimitive4.Portal, { ...scope, children: /* @__PURE__ */ jsx12(
|
1297
1230
|
PopoverPrimitive4.Content,
|
1298
1231
|
{
|
1299
1232
|
...scope,
|
@@ -1314,14 +1247,14 @@ AssistantModalPrimitiveContent.displayName = "AssistantModalPrimitive.Content";
|
|
1314
1247
|
// src/primitives/assistantModal/AssistantModalAnchor.tsx
|
1315
1248
|
import { forwardRef as forwardRef9 } from "react";
|
1316
1249
|
import * as PopoverPrimitive5 from "@radix-ui/react-popover";
|
1317
|
-
import { jsx as
|
1250
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
1318
1251
|
var AssistantModalPrimitiveAnchor = forwardRef9(
|
1319
1252
|
({
|
1320
1253
|
__scopeAssistantModal,
|
1321
1254
|
...rest
|
1322
1255
|
}, ref) => {
|
1323
1256
|
const scope = usePopoverScope(__scopeAssistantModal);
|
1324
|
-
return /* @__PURE__ */
|
1257
|
+
return /* @__PURE__ */ jsx13(PopoverPrimitive5.Anchor, { ...scope, ...rest, ref });
|
1325
1258
|
}
|
1326
1259
|
);
|
1327
1260
|
AssistantModalPrimitiveAnchor.displayName = "AssistantModalPrimitive.Anchor";
|
@@ -1349,18 +1282,18 @@ var BranchPickerPrevious = createActionButton(
|
|
1349
1282
|
);
|
1350
1283
|
|
1351
1284
|
// src/primitives/branchPicker/BranchPickerCount.tsx
|
1352
|
-
import { Fragment, jsx as
|
1285
|
+
import { Fragment, jsx as jsx14 } from "react/jsx-runtime";
|
1353
1286
|
var BranchPickerPrimitiveCount = () => {
|
1354
1287
|
const branchCount = useBranchPickerCount();
|
1355
|
-
return /* @__PURE__ */
|
1288
|
+
return /* @__PURE__ */ jsx14(Fragment, { children: branchCount });
|
1356
1289
|
};
|
1357
1290
|
BranchPickerPrimitiveCount.displayName = "BranchPickerPrimitive.Count";
|
1358
1291
|
|
1359
1292
|
// src/primitives/branchPicker/BranchPickerNumber.tsx
|
1360
|
-
import { Fragment as Fragment2, jsx as
|
1293
|
+
import { Fragment as Fragment2, jsx as jsx15 } from "react/jsx-runtime";
|
1361
1294
|
var BranchPickerPrimitiveNumber = () => {
|
1362
1295
|
const branchNumber = useBranchPickerNumber();
|
1363
|
-
return /* @__PURE__ */
|
1296
|
+
return /* @__PURE__ */ jsx15(Fragment2, { children: branchNumber });
|
1364
1297
|
};
|
1365
1298
|
BranchPickerPrimitiveNumber.displayName = "BranchPickerPrimitive.Number";
|
1366
1299
|
|
@@ -1386,9 +1319,9 @@ import {
|
|
1386
1319
|
} from "react";
|
1387
1320
|
|
1388
1321
|
// src/utils/hooks/useManagedRef.ts
|
1389
|
-
import { useCallback as useCallback17, useRef
|
1322
|
+
import { useCallback as useCallback17, useRef } from "react";
|
1390
1323
|
var useManagedRef = (callback) => {
|
1391
|
-
const cleanupRef =
|
1324
|
+
const cleanupRef = useRef();
|
1392
1325
|
const ref = useCallback17(
|
1393
1326
|
(el) => {
|
1394
1327
|
if (cleanupRef.current) {
|
@@ -1405,7 +1338,7 @@ var useManagedRef = (callback) => {
|
|
1405
1338
|
|
1406
1339
|
// src/primitives/message/MessageRoot.tsx
|
1407
1340
|
import { useComposedRefs } from "@radix-ui/react-compose-refs";
|
1408
|
-
import { jsx as
|
1341
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
1409
1342
|
var useIsHoveringRef = () => {
|
1410
1343
|
const messageUtilsStore = useMessageUtilsStore();
|
1411
1344
|
const callbackRef = useCallback18(
|
@@ -1432,7 +1365,7 @@ var useIsHoveringRef = () => {
|
|
1432
1365
|
var MessagePrimitiveRoot = forwardRef10((props, forwardRef33) => {
|
1433
1366
|
const isHoveringRef = useIsHoveringRef();
|
1434
1367
|
const ref = useComposedRefs(forwardRef33, isHoveringRef);
|
1435
|
-
return /* @__PURE__ */
|
1368
|
+
return /* @__PURE__ */ jsx16(Primitive7.div, { ...props, ref });
|
1436
1369
|
});
|
1437
1370
|
MessagePrimitiveRoot.displayName = "MessagePrimitive.Root";
|
1438
1371
|
|
@@ -1451,8 +1384,8 @@ import { memo as memo2 } from "react";
|
|
1451
1384
|
|
1452
1385
|
// src/context/providers/ContentPartProvider.tsx
|
1453
1386
|
import { useEffect as useEffect8, useState as useState5 } from "react";
|
1454
|
-
import { create as
|
1455
|
-
import { jsx as
|
1387
|
+
import { create as create7 } from "zustand";
|
1388
|
+
import { jsx as jsx17 } from "react/jsx-runtime";
|
1456
1389
|
var COMPLETE_STATUS2 = {
|
1457
1390
|
type: "complete"
|
1458
1391
|
};
|
@@ -1492,7 +1425,7 @@ var getContentPartState = ({ message }, useContentPart2, partIndex) => {
|
|
1492
1425
|
var useContentPartContext2 = (partIndex) => {
|
1493
1426
|
const messageStore = useMessageStore();
|
1494
1427
|
const [context] = useState5(() => {
|
1495
|
-
const useContentPart2 =
|
1428
|
+
const useContentPart2 = create7(
|
1496
1429
|
() => getContentPartState(messageStore.getState(), void 0, partIndex)
|
1497
1430
|
);
|
1498
1431
|
return { useContentPart: useContentPart2 };
|
@@ -1517,7 +1450,7 @@ var ContentPartProvider = ({
|
|
1517
1450
|
children
|
1518
1451
|
}) => {
|
1519
1452
|
const context = useContentPartContext2(partIndex);
|
1520
|
-
return /* @__PURE__ */
|
1453
|
+
return /* @__PURE__ */ jsx17(ContentPartContext.Provider, { value: context, children });
|
1521
1454
|
};
|
1522
1455
|
|
1523
1456
|
// src/primitives/contentPart/ContentPartText.tsx
|
@@ -1526,7 +1459,7 @@ import {
|
|
1526
1459
|
} from "react";
|
1527
1460
|
|
1528
1461
|
// src/utils/smooth/useSmooth.tsx
|
1529
|
-
import { useEffect as useEffect9, useMemo as
|
1462
|
+
import { useEffect as useEffect9, useMemo as useMemo5, useRef as useRef2, useState as useState7 } from "react";
|
1530
1463
|
import { useCallbackRef as useCallbackRef2 } from "@radix-ui/react-use-callback-ref";
|
1531
1464
|
|
1532
1465
|
// src/utils/smooth/SmoothContext.tsx
|
@@ -1536,11 +1469,11 @@ import {
|
|
1536
1469
|
useContext as useContext2,
|
1537
1470
|
useState as useState6
|
1538
1471
|
} from "react";
|
1539
|
-
import { create as
|
1540
|
-
import { jsx as
|
1472
|
+
import { create as create8 } from "zustand";
|
1473
|
+
import { jsx as jsx18 } from "react/jsx-runtime";
|
1541
1474
|
var SmoothContext = createContext5(null);
|
1542
1475
|
var makeSmoothContext = (initialState) => {
|
1543
|
-
const useSmoothStatus2 =
|
1476
|
+
const useSmoothStatus2 = create8(() => initialState);
|
1544
1477
|
return { useSmoothStatus: useSmoothStatus2 };
|
1545
1478
|
};
|
1546
1479
|
var SmoothContextProvider = ({ children }) => {
|
@@ -1550,11 +1483,11 @@ var SmoothContextProvider = ({ children }) => {
|
|
1550
1483
|
() => makeSmoothContext(contentPartStore.getState().status)
|
1551
1484
|
);
|
1552
1485
|
if (outer) return children;
|
1553
|
-
return /* @__PURE__ */
|
1486
|
+
return /* @__PURE__ */ jsx18(SmoothContext.Provider, { value: context, children });
|
1554
1487
|
};
|
1555
1488
|
var withSmoothContextProvider = (Component) => {
|
1556
1489
|
const Wrapped = forwardRef11((props, ref) => {
|
1557
|
-
return /* @__PURE__ */
|
1490
|
+
return /* @__PURE__ */ jsx18(SmoothContextProvider, { children: /* @__PURE__ */ jsx18(Component, { ...props, ref }) });
|
1558
1491
|
});
|
1559
1492
|
Wrapped.displayName = Component.displayName;
|
1560
1493
|
return Wrapped;
|
@@ -1626,9 +1559,9 @@ var useSmooth = (state, smooth = false) => {
|
|
1626
1559
|
} = state;
|
1627
1560
|
const id = useMessage({
|
1628
1561
|
optional: true,
|
1629
|
-
selector: (m) => m.
|
1562
|
+
selector: (m) => m.id
|
1630
1563
|
});
|
1631
|
-
const idRef =
|
1564
|
+
const idRef = useRef2(id);
|
1632
1565
|
const [displayedText, setDisplayedText] = useState7(text);
|
1633
1566
|
const smoothStatusStore = useSmoothStatusStore({ optional: true });
|
1634
1567
|
const setText = useCallbackRef2((text2) => {
|
@@ -1670,7 +1603,7 @@ var useSmooth = (state, smooth = false) => {
|
|
1670
1603
|
animatorRef.stop();
|
1671
1604
|
};
|
1672
1605
|
}, [animatorRef]);
|
1673
|
-
return
|
1606
|
+
return useMemo5(
|
1674
1607
|
() => smooth ? {
|
1675
1608
|
part: { type: "text", text: displayedText },
|
1676
1609
|
status: text === displayedText ? state.status : SMOOTH_STATUS
|
@@ -1680,25 +1613,25 @@ var useSmooth = (state, smooth = false) => {
|
|
1680
1613
|
};
|
1681
1614
|
|
1682
1615
|
// src/primitives/contentPart/ContentPartText.tsx
|
1683
|
-
import { jsx as
|
1616
|
+
import { jsx as jsx19 } from "react/jsx-runtime";
|
1684
1617
|
var ContentPartPrimitiveText = forwardRef12(({ smooth = true, component: Component = "span", ...rest }, forwardedRef) => {
|
1685
1618
|
const {
|
1686
1619
|
part: { text },
|
1687
1620
|
status
|
1688
1621
|
} = useSmooth(useContentPartText(), smooth);
|
1689
|
-
return /* @__PURE__ */
|
1622
|
+
return /* @__PURE__ */ jsx19(Component, { "data-status": status.type, ...rest, ref: forwardedRef, children: text });
|
1690
1623
|
});
|
1691
1624
|
ContentPartPrimitiveText.displayName = "ContentPartPrimitive.Text";
|
1692
1625
|
|
1693
1626
|
// src/primitives/contentPart/ContentPartImage.tsx
|
1694
1627
|
import { Primitive as Primitive8 } from "@radix-ui/react-primitive";
|
1695
1628
|
import { forwardRef as forwardRef13 } from "react";
|
1696
|
-
import { jsx as
|
1629
|
+
import { jsx as jsx20 } from "react/jsx-runtime";
|
1697
1630
|
var ContentPartPrimitiveImage = forwardRef13((props, forwardedRef) => {
|
1698
1631
|
const {
|
1699
1632
|
part: { image }
|
1700
1633
|
} = useContentPartImage();
|
1701
|
-
return /* @__PURE__ */
|
1634
|
+
return /* @__PURE__ */ jsx20(Primitive8.img, { src: image, ...props, ref: forwardedRef });
|
1702
1635
|
});
|
1703
1636
|
ContentPartPrimitiveImage.displayName = "ContentPartPrimitive.Image";
|
1704
1637
|
|
@@ -1719,22 +1652,22 @@ var ContentPartPrimitiveInProgress = ({ children }) => {
|
|
1719
1652
|
ContentPartPrimitiveInProgress.displayName = "ContentPartPrimitive.InProgress";
|
1720
1653
|
|
1721
1654
|
// src/primitives/message/MessageContent.tsx
|
1722
|
-
import { jsx as
|
1655
|
+
import { jsx as jsx21, jsxs as jsxs2 } from "react/jsx-runtime";
|
1723
1656
|
var ToolUIDisplay = ({
|
1724
1657
|
UI,
|
1725
1658
|
...props
|
1726
1659
|
}) => {
|
1727
1660
|
const Render = useToolUIs((s) => s.getToolUI(props.part.toolName)) ?? UI;
|
1728
1661
|
if (!Render) return null;
|
1729
|
-
return /* @__PURE__ */
|
1662
|
+
return /* @__PURE__ */ jsx21(Render, { ...props });
|
1730
1663
|
};
|
1731
1664
|
var defaultComponents = {
|
1732
1665
|
Text: () => /* @__PURE__ */ jsxs2("p", { style: { whiteSpace: "pre-line" }, children: [
|
1733
|
-
/* @__PURE__ */
|
1734
|
-
/* @__PURE__ */
|
1666
|
+
/* @__PURE__ */ jsx21(ContentPartPrimitiveText, {}),
|
1667
|
+
/* @__PURE__ */ jsx21(ContentPartPrimitiveInProgress, { children: /* @__PURE__ */ jsx21("span", { style: { fontFamily: "revert" }, children: " \u25CF" }) })
|
1735
1668
|
] }),
|
1736
|
-
Image: () => /* @__PURE__ */
|
1737
|
-
UI: () => /* @__PURE__ */
|
1669
|
+
Image: () => /* @__PURE__ */ jsx21(ContentPartPrimitiveImage, {}),
|
1670
|
+
UI: () => /* @__PURE__ */ jsx21(ContentPartPrimitiveDisplay, {})
|
1738
1671
|
};
|
1739
1672
|
var MessageContentPartComponent = ({
|
1740
1673
|
components: {
|
@@ -1754,26 +1687,26 @@ var MessageContentPartComponent = ({
|
|
1754
1687
|
if (status.type === "requires-action")
|
1755
1688
|
throw new Error("Encountered unexpected requires-action status");
|
1756
1689
|
if (part === EMPTY_CONTENT && !!Empty) {
|
1757
|
-
return /* @__PURE__ */
|
1690
|
+
return /* @__PURE__ */ jsx21(Empty, { status });
|
1758
1691
|
}
|
1759
|
-
return /* @__PURE__ */
|
1692
|
+
return /* @__PURE__ */ jsx21(Text2, { part, status });
|
1760
1693
|
case "image":
|
1761
1694
|
if (status.type === "requires-action")
|
1762
1695
|
throw new Error("Encountered unexpected requires-action status");
|
1763
|
-
return /* @__PURE__ */
|
1696
|
+
return /* @__PURE__ */ jsx21(Image2, { part, status });
|
1764
1697
|
case "ui":
|
1765
1698
|
if (status.type === "requires-action")
|
1766
1699
|
throw new Error("Encountered unexpected requires-action status");
|
1767
|
-
return /* @__PURE__ */
|
1700
|
+
return /* @__PURE__ */ jsx21(UI, { part, status });
|
1768
1701
|
case "tool-call": {
|
1769
1702
|
const Tool = by_name[part.toolName] || Fallback2;
|
1770
1703
|
const addResult = (result) => threadRuntime.addToolResult({
|
1771
|
-
messageId: messageStore.getState().
|
1704
|
+
messageId: messageStore.getState().id,
|
1772
1705
|
toolName: part.toolName,
|
1773
1706
|
toolCallId: part.toolCallId,
|
1774
1707
|
result
|
1775
1708
|
});
|
1776
|
-
return /* @__PURE__ */
|
1709
|
+
return /* @__PURE__ */ jsx21(
|
1777
1710
|
ToolUIDisplay,
|
1778
1711
|
{
|
1779
1712
|
UI: Tool,
|
@@ -1792,7 +1725,7 @@ var MessageContentPartImpl = ({
|
|
1792
1725
|
partIndex,
|
1793
1726
|
components
|
1794
1727
|
}) => {
|
1795
|
-
return /* @__PURE__ */
|
1728
|
+
return /* @__PURE__ */ jsx21(ContentPartProvider, { partIndex, children: /* @__PURE__ */ jsx21(MessageContentPartComponent, { components }) });
|
1796
1729
|
};
|
1797
1730
|
var MessageContentPart = memo2(
|
1798
1731
|
MessageContentPartImpl,
|
@@ -1801,8 +1734,8 @@ var MessageContentPart = memo2(
|
|
1801
1734
|
var MessagePrimitiveContent = ({
|
1802
1735
|
components
|
1803
1736
|
}) => {
|
1804
|
-
const contentLength = useMessage((s) => s.
|
1805
|
-
return Array.from({ length: contentLength }, (_, index) => /* @__PURE__ */
|
1737
|
+
const contentLength = useMessage((s) => s.content.length) || 1;
|
1738
|
+
return Array.from({ length: contentLength }, (_, index) => /* @__PURE__ */ jsx21(MessageContentPart, { partIndex: index, components }, index));
|
1806
1739
|
};
|
1807
1740
|
MessagePrimitiveContent.displayName = "MessagePrimitive.Content";
|
1808
1741
|
|
@@ -1861,9 +1794,9 @@ var {
|
|
1861
1794
|
|
1862
1795
|
// src/context/providers/MessageAttachmentProvider.tsx
|
1863
1796
|
import { useEffect as useEffect10, useState as useState8 } from "react";
|
1864
|
-
import { create as
|
1865
|
-
import { jsx as
|
1866
|
-
var getAttachment = (
|
1797
|
+
import { create as create9 } from "zustand";
|
1798
|
+
import { jsx as jsx22 } from "react/jsx-runtime";
|
1799
|
+
var getAttachment = (message, useAttachment2, partIndex) => {
|
1867
1800
|
if (message.role !== "user") return null;
|
1868
1801
|
const attachments = message.attachments;
|
1869
1802
|
const attachment = attachments[partIndex];
|
@@ -1876,7 +1809,7 @@ var useMessageAttachmentContext2 = (partIndex) => {
|
|
1876
1809
|
const messageStore = useMessageStore();
|
1877
1810
|
const [context] = useState8(
|
1878
1811
|
() => {
|
1879
|
-
const useAttachment2 =
|
1812
|
+
const useAttachment2 = create9(
|
1880
1813
|
() => getAttachment(messageStore.getState(), void 0, partIndex)
|
1881
1814
|
);
|
1882
1815
|
return { type: "message", useAttachment: useAttachment2 };
|
@@ -1902,11 +1835,11 @@ var MessageAttachmentProvider = ({
|
|
1902
1835
|
children
|
1903
1836
|
}) => {
|
1904
1837
|
const context = useMessageAttachmentContext2(partIndex);
|
1905
|
-
return /* @__PURE__ */
|
1838
|
+
return /* @__PURE__ */ jsx22(AttachmentContext.Provider, { value: context, children });
|
1906
1839
|
};
|
1907
1840
|
|
1908
1841
|
// src/primitives/message/MessageAttachments.tsx
|
1909
|
-
import { jsx as
|
1842
|
+
import { jsx as jsx23 } from "react/jsx-runtime";
|
1910
1843
|
var getComponent = (components, attachment) => {
|
1911
1844
|
const type = attachment.type;
|
1912
1845
|
switch (type) {
|
@@ -1926,10 +1859,10 @@ var AttachmentComponent = ({ components }) => {
|
|
1926
1859
|
(a) => getComponent(components, a.attachment)
|
1927
1860
|
);
|
1928
1861
|
if (!Component) return null;
|
1929
|
-
return /* @__PURE__ */
|
1862
|
+
return /* @__PURE__ */ jsx23(Component, {});
|
1930
1863
|
};
|
1931
1864
|
var MessageAttachmentImpl = ({ components, attachmentIndex }) => {
|
1932
|
-
return /* @__PURE__ */
|
1865
|
+
return /* @__PURE__ */ jsx23(MessageAttachmentProvider, { attachmentIndex, children: /* @__PURE__ */ jsx23(AttachmentComponent, { components }) });
|
1933
1866
|
};
|
1934
1867
|
var MessageAttachment = memo3(
|
1935
1868
|
MessageAttachmentImpl,
|
@@ -1940,7 +1873,7 @@ var MessagePrimitiveAttachments = ({ components }) => {
|
|
1940
1873
|
if (message.role !== "user") return 0;
|
1941
1874
|
return message.attachments.length;
|
1942
1875
|
});
|
1943
|
-
return Array.from({ length: attachmentsCount }, (_, index) => /* @__PURE__ */
|
1876
|
+
return Array.from({ length: attachmentsCount }, (_, index) => /* @__PURE__ */ jsx23(
|
1944
1877
|
MessageAttachment,
|
1945
1878
|
{
|
1946
1879
|
attachmentIndex: index,
|
@@ -1952,9 +1885,9 @@ var MessagePrimitiveAttachments = ({ components }) => {
|
|
1952
1885
|
MessagePrimitiveAttachments.displayName = "MessagePrimitive.Attachments";
|
1953
1886
|
|
1954
1887
|
// src/primitives/branchPicker/BranchPickerRoot.tsx
|
1955
|
-
import { jsx as
|
1888
|
+
import { jsx as jsx24 } from "react/jsx-runtime";
|
1956
1889
|
var BranchPickerPrimitiveRoot = forwardRef14(({ hideWhenSingleBranch, ...rest }, ref) => {
|
1957
|
-
return /* @__PURE__ */
|
1890
|
+
return /* @__PURE__ */ jsx24(MessagePrimitiveIf, { hasBranches: hideWhenSingleBranch ? true : void 0, children: /* @__PURE__ */ jsx24(Primitive9.div, { ...rest, ref }) });
|
1958
1891
|
});
|
1959
1892
|
BranchPickerPrimitiveRoot.displayName = "BranchPickerPrimitive.Root";
|
1960
1893
|
|
@@ -1976,7 +1909,7 @@ import { Primitive as Primitive10 } from "@radix-ui/react-primitive";
|
|
1976
1909
|
import {
|
1977
1910
|
forwardRef as forwardRef15
|
1978
1911
|
} from "react";
|
1979
|
-
import { jsx as
|
1912
|
+
import { jsx as jsx25 } from "react/jsx-runtime";
|
1980
1913
|
var ComposerPrimitiveRoot = forwardRef15(({ onSubmit, ...rest }, forwardedRef) => {
|
1981
1914
|
const send = useComposerSend();
|
1982
1915
|
const handleSubmit = (e) => {
|
@@ -1984,7 +1917,7 @@ var ComposerPrimitiveRoot = forwardRef15(({ onSubmit, ...rest }, forwardedRef) =
|
|
1984
1917
|
if (!send) return;
|
1985
1918
|
send();
|
1986
1919
|
};
|
1987
|
-
return /* @__PURE__ */
|
1920
|
+
return /* @__PURE__ */ jsx25(
|
1988
1921
|
Primitive10.form,
|
1989
1922
|
{
|
1990
1923
|
...rest,
|
@@ -2003,11 +1936,11 @@ import {
|
|
2003
1936
|
forwardRef as forwardRef16,
|
2004
1937
|
useCallback as useCallback19,
|
2005
1938
|
useEffect as useEffect11,
|
2006
|
-
useRef as
|
1939
|
+
useRef as useRef3
|
2007
1940
|
} from "react";
|
2008
1941
|
import TextareaAutosize from "react-textarea-autosize";
|
2009
1942
|
import { useEscapeKeydown as useEscapeKeydown2 } from "@radix-ui/react-use-escape-keydown";
|
2010
|
-
import { jsx as
|
1943
|
+
import { jsx as jsx26 } from "react/jsx-runtime";
|
2011
1944
|
var ComposerPrimitiveInput = forwardRef16(
|
2012
1945
|
({
|
2013
1946
|
autoFocus = false,
|
@@ -2027,7 +1960,7 @@ var ComposerPrimitiveInput = forwardRef16(
|
|
2027
1960
|
});
|
2028
1961
|
const Component = asChild ? Slot : TextareaAutosize;
|
2029
1962
|
const isDisabled = useThread((t) => t.isDisabled) ?? disabledProp ?? false;
|
2030
|
-
const textareaRef =
|
1963
|
+
const textareaRef = useRef3(null);
|
2031
1964
|
const ref = useComposedRefs2(forwardedRef, textareaRef);
|
2032
1965
|
useEscapeKeydown2((e) => {
|
2033
1966
|
if (!cancelOnEscape) return;
|
@@ -2064,7 +1997,7 @@ var ComposerPrimitiveInput = forwardRef16(
|
|
2064
1997
|
focus();
|
2065
1998
|
}
|
2066
1999
|
});
|
2067
|
-
return /* @__PURE__ */
|
2000
|
+
return /* @__PURE__ */ jsx26(
|
2068
2001
|
Component,
|
2069
2002
|
{
|
2070
2003
|
name: "input",
|
@@ -2107,8 +2040,8 @@ import { memo as memo4 } from "react";
|
|
2107
2040
|
|
2108
2041
|
// src/context/providers/ComposerAttachmentProvider.tsx
|
2109
2042
|
import { useEffect as useEffect12, useState as useState9 } from "react";
|
2110
|
-
import { create as
|
2111
|
-
import { jsx as
|
2043
|
+
import { create as create10 } from "zustand";
|
2044
|
+
import { jsx as jsx27 } from "react/jsx-runtime";
|
2112
2045
|
var getAttachment2 = ({ attachments }, useAttachment2, partIndex) => {
|
2113
2046
|
const attachment = attachments[partIndex];
|
2114
2047
|
if (!attachment) return null;
|
@@ -2120,7 +2053,7 @@ var useComposerAttachmentContext2 = (partIndex) => {
|
|
2120
2053
|
const threadComposerStore = useThreadComposerStore();
|
2121
2054
|
const [context] = useState9(
|
2122
2055
|
() => {
|
2123
|
-
const useAttachment2 =
|
2056
|
+
const useAttachment2 = create10(
|
2124
2057
|
() => getAttachment2(threadComposerStore.getState(), void 0, partIndex)
|
2125
2058
|
);
|
2126
2059
|
return { type: "composer", useAttachment: useAttachment2 };
|
@@ -2143,11 +2076,11 @@ var useComposerAttachmentContext2 = (partIndex) => {
|
|
2143
2076
|
};
|
2144
2077
|
var ComposerAttachmentProvider = ({ attachmentIndex: partIndex, children }) => {
|
2145
2078
|
const context = useComposerAttachmentContext2(partIndex);
|
2146
|
-
return /* @__PURE__ */
|
2079
|
+
return /* @__PURE__ */ jsx27(AttachmentContext.Provider, { value: context, children });
|
2147
2080
|
};
|
2148
2081
|
|
2149
2082
|
// src/primitives/composer/ComposerAttachments.tsx
|
2150
|
-
import { jsx as
|
2083
|
+
import { jsx as jsx28 } from "react/jsx-runtime";
|
2151
2084
|
var getComponent2 = (components, attachment) => {
|
2152
2085
|
const type = attachment.type;
|
2153
2086
|
switch (type) {
|
@@ -2167,10 +2100,10 @@ var AttachmentComponent2 = ({ components }) => {
|
|
2167
2100
|
(a) => getComponent2(components, a.attachment)
|
2168
2101
|
);
|
2169
2102
|
if (!Component) return null;
|
2170
|
-
return /* @__PURE__ */
|
2103
|
+
return /* @__PURE__ */ jsx28(Component, {});
|
2171
2104
|
};
|
2172
2105
|
var ComposerAttachmentImpl = ({ components, attachmentIndex }) => {
|
2173
|
-
return /* @__PURE__ */
|
2106
|
+
return /* @__PURE__ */ jsx28(ComposerAttachmentProvider, { attachmentIndex, children: /* @__PURE__ */ jsx28(AttachmentComponent2, { components }) });
|
2174
2107
|
};
|
2175
2108
|
var ComposerAttachment = memo4(
|
2176
2109
|
ComposerAttachmentImpl,
|
@@ -2178,7 +2111,7 @@ var ComposerAttachment = memo4(
|
|
2178
2111
|
);
|
2179
2112
|
var ComposerPrimitiveAttachments = ({ components }) => {
|
2180
2113
|
const attachmentsCount = useThreadComposer((s) => s.attachments.length);
|
2181
|
-
return Array.from({ length: attachmentsCount }, (_, index) => /* @__PURE__ */
|
2114
|
+
return Array.from({ length: attachmentsCount }, (_, index) => /* @__PURE__ */ jsx28(
|
2182
2115
|
ComposerAttachment,
|
2183
2116
|
{
|
2184
2117
|
attachmentIndex: index,
|
@@ -2223,9 +2156,9 @@ __export(thread_exports, {
|
|
2223
2156
|
// src/primitives/thread/ThreadRoot.tsx
|
2224
2157
|
import { Primitive as Primitive11 } from "@radix-ui/react-primitive";
|
2225
2158
|
import { forwardRef as forwardRef17 } from "react";
|
2226
|
-
import { jsx as
|
2159
|
+
import { jsx as jsx29 } from "react/jsx-runtime";
|
2227
2160
|
var ThreadPrimitiveRoot = forwardRef17((props, ref) => {
|
2228
|
-
return /* @__PURE__ */
|
2161
|
+
return /* @__PURE__ */ jsx29(Primitive11.div, { ...props, ref });
|
2229
2162
|
});
|
2230
2163
|
ThreadPrimitiveRoot.displayName = "ThreadPrimitive.Root";
|
2231
2164
|
|
@@ -2255,7 +2188,7 @@ import { forwardRef as forwardRef18 } from "react";
|
|
2255
2188
|
|
2256
2189
|
// src/primitive-hooks/thread/useThreadViewportAutoScroll.tsx
|
2257
2190
|
import { useComposedRefs as useComposedRefs3 } from "@radix-ui/react-compose-refs";
|
2258
|
-
import { useRef as
|
2191
|
+
import { useRef as useRef4 } from "react";
|
2259
2192
|
|
2260
2193
|
// src/utils/hooks/useOnResizeContent.tsx
|
2261
2194
|
import { useCallbackRef as useCallbackRef3 } from "@radix-ui/react-use-callback-ref";
|
@@ -2314,10 +2247,10 @@ var useOnScrollToBottom = (callback) => {
|
|
2314
2247
|
var useThreadViewportAutoScroll = ({
|
2315
2248
|
autoScroll = true
|
2316
2249
|
}) => {
|
2317
|
-
const divRef =
|
2250
|
+
const divRef = useRef4(null);
|
2318
2251
|
const threadViewportStore = useThreadViewportStore();
|
2319
|
-
const lastScrollTop =
|
2320
|
-
const isScrollingToBottomRef =
|
2252
|
+
const lastScrollTop = useRef4(0);
|
2253
|
+
const isScrollingToBottomRef = useRef4(false);
|
2321
2254
|
const scrollToBottom = (behavior) => {
|
2322
2255
|
const div = divRef.current;
|
2323
2256
|
if (!div || !autoScroll) return;
|
@@ -2362,29 +2295,29 @@ var useThreadViewportAutoScroll = ({
|
|
2362
2295
|
};
|
2363
2296
|
|
2364
2297
|
// src/primitives/thread/ThreadViewport.tsx
|
2365
|
-
import { jsx as
|
2298
|
+
import { jsx as jsx30 } from "react/jsx-runtime";
|
2366
2299
|
var ThreadPrimitiveViewport = forwardRef18(({ autoScroll, children, ...rest }, forwardedRef) => {
|
2367
2300
|
const autoScrollRef = useThreadViewportAutoScroll({
|
2368
2301
|
autoScroll
|
2369
2302
|
});
|
2370
2303
|
const ref = useComposedRefs4(forwardedRef, autoScrollRef);
|
2371
|
-
return /* @__PURE__ */
|
2304
|
+
return /* @__PURE__ */ jsx30(Primitive12.div, { ...rest, ref, children });
|
2372
2305
|
});
|
2373
2306
|
ThreadPrimitiveViewport.displayName = "ThreadPrimitive.Viewport";
|
2374
2307
|
|
2375
2308
|
// src/primitives/thread/ThreadMessages.tsx
|
2376
|
-
import { memo as memo5 } from "react";
|
2309
|
+
import { memo as memo5, useMemo as useMemo6 } from "react";
|
2377
2310
|
|
2378
|
-
// src/context/providers/
|
2311
|
+
// src/context/providers/MessageRuntimeProvider.tsx
|
2379
2312
|
import { useEffect as useEffect14, useState as useState10 } from "react";
|
2380
|
-
import { create as
|
2313
|
+
import { create as create13 } from "zustand";
|
2381
2314
|
|
2382
2315
|
// src/context/stores/EditComposer.ts
|
2383
|
-
import { create as
|
2316
|
+
import { create as create11 } from "zustand";
|
2384
2317
|
var makeEditComposerStore = ({
|
2385
2318
|
onEdit,
|
2386
2319
|
onSend
|
2387
|
-
}) =>
|
2320
|
+
}) => create11()((set, get) => ({
|
2388
2321
|
type: "edit",
|
2389
2322
|
get value() {
|
2390
2323
|
return get().text;
|
@@ -2419,8 +2352,8 @@ var makeEditComposerStore = ({
|
|
2419
2352
|
}));
|
2420
2353
|
|
2421
2354
|
// src/context/stores/MessageUtils.ts
|
2422
|
-
import { create as
|
2423
|
-
var makeMessageUtilsStore = () =>
|
2355
|
+
import { create as create12 } from "zustand";
|
2356
|
+
var makeMessageUtilsStore = () => create12((set) => {
|
2424
2357
|
let utterance = null;
|
2425
2358
|
return {
|
2426
2359
|
isCopied: false,
|
@@ -2449,89 +2382,70 @@ var makeMessageUtilsStore = () => create14((set) => {
|
|
2449
2382
|
};
|
2450
2383
|
});
|
2451
2384
|
|
2452
|
-
// src/context/providers/
|
2453
|
-
import { jsx as
|
2454
|
-
var
|
2455
|
-
|
2456
|
-
|
2457
|
-
|
2458
|
-
|
2459
|
-
|
2460
|
-
if (!message) return null;
|
2461
|
-
const isLast = getIsLast(messages, message);
|
2462
|
-
const branches = getBranches(message.id);
|
2463
|
-
const currentState = useMessage2?.getState();
|
2464
|
-
if (currentState && currentState.message === message && currentState.parentId === parentId && currentState.branches === branches && currentState.isLast === isLast)
|
2465
|
-
return null;
|
2466
|
-
return Object.freeze({
|
2467
|
-
message,
|
2468
|
-
parentId,
|
2469
|
-
branches,
|
2470
|
-
isLast
|
2471
|
-
});
|
2385
|
+
// src/context/providers/MessageRuntimeProvider.tsx
|
2386
|
+
import { jsx as jsx31 } from "react/jsx-runtime";
|
2387
|
+
var useMessageRuntimeStore = (runtime) => {
|
2388
|
+
const [store] = useState10(() => create13(() => runtime));
|
2389
|
+
useEffect14(() => {
|
2390
|
+
writableStore(store).setState(runtime, true);
|
2391
|
+
}, [runtime, store]);
|
2392
|
+
return store;
|
2472
2393
|
};
|
2473
|
-
var
|
2474
|
-
const
|
2475
|
-
|
2476
|
-
|
2477
|
-
|
2478
|
-
|
2479
|
-
|
2480
|
-
|
2481
|
-
|
2482
|
-
|
2483
|
-
|
2484
|
-
|
2485
|
-
|
2486
|
-
|
2394
|
+
var useMessageStore2 = (runtime) => {
|
2395
|
+
const [store] = useState10(() => create13(() => runtime.getState()));
|
2396
|
+
useEffect14(() => {
|
2397
|
+
const updateState = () => writableStore(store).setState(runtime.getState(), true);
|
2398
|
+
updateState();
|
2399
|
+
return runtime.subscribe(updateState);
|
2400
|
+
}, [runtime, store]);
|
2401
|
+
return store;
|
2402
|
+
};
|
2403
|
+
var useMessageUtilsStore2 = () => {
|
2404
|
+
const [store] = useState10(() => makeMessageUtilsStore());
|
2405
|
+
return store;
|
2406
|
+
};
|
2407
|
+
var useEditComposerStore2 = (useMessageRuntime2) => {
|
2408
|
+
const [store] = useState10(
|
2409
|
+
() => makeEditComposerStore({
|
2487
2410
|
onEdit: () => {
|
2488
|
-
const
|
2489
|
-
|
2411
|
+
const text = getThreadMessageText(
|
2412
|
+
useMessageRuntime2.getState().getState()
|
2413
|
+
);
|
2490
2414
|
return text;
|
2491
2415
|
},
|
2492
2416
|
onSend: (text) => {
|
2493
|
-
const
|
2417
|
+
const message = useMessageRuntime2.getState().getState();
|
2494
2418
|
const previousText = getThreadMessageText(message);
|
2495
2419
|
if (previousText === text) return;
|
2496
2420
|
const nonTextParts = message.content.filter(
|
2497
2421
|
(part) => part.type !== "text" && part.type !== "ui"
|
2498
2422
|
);
|
2499
|
-
|
2500
|
-
parentId,
|
2423
|
+
useMessageRuntime2.getState().edit({
|
2501
2424
|
role: message.role,
|
2502
2425
|
content: [{ type: "text", text }, ...nonTextParts],
|
2503
|
-
attachments: message.attachments
|
2426
|
+
attachments: message.attachments ?? []
|
2504
2427
|
});
|
2505
2428
|
}
|
2506
|
-
})
|
2507
|
-
|
2508
|
-
|
2509
|
-
useEffect14(() => {
|
2510
|
-
const syncMessage = (thread) => {
|
2511
|
-
const newState = getMessageState(
|
2512
|
-
thread,
|
2513
|
-
threadRuntime.getBranches.bind(threadRuntime),
|
2514
|
-
context.useMessage,
|
2515
|
-
messageIndex
|
2516
|
-
);
|
2517
|
-
if (!newState) return;
|
2518
|
-
writableStore(context.useMessage).setState(newState, true);
|
2519
|
-
};
|
2520
|
-
syncMessage(threadMessagesStore.getState());
|
2521
|
-
return threadMessagesStore.subscribe(syncMessage);
|
2522
|
-
}, [threadMessagesStore, threadRuntime, context, messageIndex]);
|
2523
|
-
return context;
|
2429
|
+
})
|
2430
|
+
);
|
2431
|
+
return store;
|
2524
2432
|
};
|
2525
|
-
var
|
2526
|
-
|
2433
|
+
var MessageRuntimeProvider = ({
|
2434
|
+
runtime,
|
2527
2435
|
children
|
2528
2436
|
}) => {
|
2529
|
-
const
|
2530
|
-
|
2437
|
+
const useMessageRuntime2 = useMessageRuntimeStore(runtime);
|
2438
|
+
const useMessage2 = useMessageStore2(runtime);
|
2439
|
+
const useMessageUtils2 = useMessageUtilsStore2();
|
2440
|
+
const useEditComposer2 = useEditComposerStore2(useMessageRuntime2);
|
2441
|
+
const [context] = useState10(() => {
|
2442
|
+
return { useMessageRuntime: useMessageRuntime2, useMessage: useMessage2, useMessageUtils: useMessageUtils2, useEditComposer: useEditComposer2 };
|
2443
|
+
});
|
2444
|
+
return /* @__PURE__ */ jsx31(MessageContext.Provider, { value: context, children });
|
2531
2445
|
};
|
2532
2446
|
|
2533
2447
|
// src/primitives/thread/ThreadMessages.tsx
|
2534
|
-
import { jsx as
|
2448
|
+
import { jsx as jsx32 } from "react/jsx-runtime";
|
2535
2449
|
var isComponentsSame = (prev, next) => {
|
2536
2450
|
return prev.Message === next.Message && prev.EditComposer === next.EditComposer && prev.UserEditComposer === next.UserEditComposer && prev.AssistantEditComposer === next.AssistantEditComposer && prev.SystemEditComposer === next.SystemEditComposer && prev.UserMessage === next.UserMessage && prev.AssistantMessage === next.AssistantMessage && prev.SystemMessage === next.SystemMessage;
|
2537
2451
|
};
|
@@ -2564,16 +2478,21 @@ var getComponent3 = (components, role, isEditing) => {
|
|
2564
2478
|
var ThreadMessageComponent = ({
|
2565
2479
|
components
|
2566
2480
|
}) => {
|
2567
|
-
const role = useMessage((m) => m.
|
2481
|
+
const role = useMessage((m) => m.role);
|
2568
2482
|
const isEditing = useEditComposer((c) => c.isEditing);
|
2569
2483
|
const Component = getComponent3(components, role, isEditing);
|
2570
|
-
return /* @__PURE__ */
|
2484
|
+
return /* @__PURE__ */ jsx32(Component, {});
|
2571
2485
|
};
|
2572
2486
|
var ThreadMessageImpl = ({
|
2573
2487
|
messageIndex,
|
2574
2488
|
components
|
2575
2489
|
}) => {
|
2576
|
-
|
2490
|
+
const threadRuntime = useThreadRuntime();
|
2491
|
+
const runtime = useMemo6(
|
2492
|
+
() => threadRuntime.unstable_getMesssageByIndex(messageIndex),
|
2493
|
+
[threadRuntime, messageIndex]
|
2494
|
+
);
|
2495
|
+
return /* @__PURE__ */ jsx32(MessageRuntimeProvider, { runtime, children: /* @__PURE__ */ jsx32(ThreadMessageComponent, { components }) });
|
2577
2496
|
};
|
2578
2497
|
var ThreadMessage = memo5(
|
2579
2498
|
ThreadMessageImpl,
|
@@ -2584,7 +2503,7 @@ var ThreadPrimitiveMessagesImpl = ({
|
|
2584
2503
|
}) => {
|
2585
2504
|
const messagesLength = useThreadMessages((t) => t.length);
|
2586
2505
|
if (messagesLength === 0) return null;
|
2587
|
-
return Array.from({ length: messagesLength }, (_, index) => /* @__PURE__ */
|
2506
|
+
return Array.from({ length: messagesLength }, (_, index) => /* @__PURE__ */ jsx32(ThreadMessage, { messageIndex: index, components }, index));
|
2588
2507
|
};
|
2589
2508
|
ThreadPrimitiveMessagesImpl.displayName = "ThreadPrimitive.Messages";
|
2590
2509
|
var ThreadPrimitiveMessages = memo5(
|
@@ -2626,7 +2545,7 @@ var subscribeToMainThread = (runtime, callback) => {
|
|
2626
2545
|
};
|
2627
2546
|
|
2628
2547
|
// src/runtimes/local/useLocalRuntime.tsx
|
2629
|
-
import { useInsertionEffect
|
2548
|
+
import { useInsertionEffect, useMemo as useMemo7, useState as useState12 } from "react";
|
2630
2549
|
|
2631
2550
|
// src/runtimes/core/BaseAssistantRuntimeCore.tsx
|
2632
2551
|
var BaseAssistantRuntimeCore = class {
|
@@ -2656,7 +2575,7 @@ var internal_exports = {};
|
|
2656
2575
|
__export(internal_exports, {
|
2657
2576
|
AssistantRuntime: () => AssistantRuntime,
|
2658
2577
|
BaseAssistantRuntimeCore: () => BaseAssistantRuntimeCore,
|
2659
|
-
|
2578
|
+
BaseThreadComposerRuntimeCore: () => BaseThreadComposerRuntimeCore,
|
2660
2579
|
MessageRepository: () => MessageRepository,
|
2661
2580
|
ProxyConfigProvider: () => ProxyConfigProvider,
|
2662
2581
|
ThreadRuntime: () => ThreadRuntime,
|
@@ -2671,12 +2590,25 @@ __export(internal_exports, {
|
|
2671
2590
|
var BaseThreadComposerRuntimeCore = class {
|
2672
2591
|
constructor(runtime) {
|
2673
2592
|
this.runtime = runtime;
|
2593
|
+
this.connect();
|
2674
2594
|
}
|
2675
2595
|
_attachmentAdapter;
|
2676
2596
|
attachmentAccept = "*";
|
2677
2597
|
get isEmpty() {
|
2678
2598
|
return !this.text.trim() && !this.attachments.length;
|
2679
2599
|
}
|
2600
|
+
_canCancel = false;
|
2601
|
+
get canCancel() {
|
2602
|
+
return this._canCancel;
|
2603
|
+
}
|
2604
|
+
connect() {
|
2605
|
+
return this.runtime.subscribe(() => {
|
2606
|
+
if (this.canCancel !== this.runtime.capabilities.cancel) {
|
2607
|
+
this._canCancel = this.runtime.capabilities.cancel;
|
2608
|
+
this.notifySubscribers();
|
2609
|
+
}
|
2610
|
+
});
|
2611
|
+
}
|
2680
2612
|
setAttachmentAdapter(adapter) {
|
2681
2613
|
this._attachmentAdapter = adapter;
|
2682
2614
|
const accept = adapter?.accept ?? "*";
|
@@ -2734,6 +2666,9 @@ var BaseThreadComposerRuntimeCore = class {
|
|
2734
2666
|
});
|
2735
2667
|
this.reset();
|
2736
2668
|
}
|
2669
|
+
async cancel() {
|
2670
|
+
this.runtime.cancelRun();
|
2671
|
+
}
|
2737
2672
|
_subscriptions = /* @__PURE__ */ new Set();
|
2738
2673
|
notifySubscribers() {
|
2739
2674
|
for (const callback of this._subscriptions) callback();
|
@@ -3018,7 +2953,7 @@ import {
|
|
3018
2953
|
forwardRef as forwardRef19
|
3019
2954
|
} from "react";
|
3020
2955
|
import classNames from "classnames";
|
3021
|
-
import { jsx as
|
2956
|
+
import { jsx as jsx33 } from "react/jsx-runtime";
|
3022
2957
|
var withDefaultProps = ({
|
3023
2958
|
className,
|
3024
2959
|
...defaultProps
|
@@ -3034,7 +2969,7 @@ var withDefaults = (Component, defaultProps) => {
|
|
3034
2969
|
const WithDefaults = forwardRef19(
|
3035
2970
|
(props, ref) => {
|
3036
2971
|
const ComponentAsAny = Component;
|
3037
|
-
return /* @__PURE__ */
|
2972
|
+
return /* @__PURE__ */ jsx33(ComponentAsAny, { ...getProps(props), ref });
|
3038
2973
|
}
|
3039
2974
|
);
|
3040
2975
|
WithDefaults.displayName = "withDefaults(" + (typeof Component === "string" ? Component : Component.displayName) + ")";
|
@@ -3042,9 +2977,9 @@ var withDefaults = (Component, defaultProps) => {
|
|
3042
2977
|
};
|
3043
2978
|
|
3044
2979
|
// src/ui/base/tooltip.tsx
|
3045
|
-
import { jsx as
|
2980
|
+
import { jsx as jsx34 } from "react/jsx-runtime";
|
3046
2981
|
var Tooltip = (props) => {
|
3047
|
-
return /* @__PURE__ */
|
2982
|
+
return /* @__PURE__ */ jsx34(TooltipPrimitive.Provider, { children: /* @__PURE__ */ jsx34(TooltipPrimitive.Root, { ...props }) });
|
3048
2983
|
};
|
3049
2984
|
Tooltip.displayName = "Tooltip";
|
3050
2985
|
var TooltipTrigger = TooltipPrimitive.Trigger;
|
@@ -3058,7 +2993,7 @@ TooltipContent.displayName = "TooltipContent";
|
|
3058
2993
|
import { cva } from "class-variance-authority";
|
3059
2994
|
import { Primitive as Primitive13 } from "@radix-ui/react-primitive";
|
3060
2995
|
import { forwardRef as forwardRef20 } from "react";
|
3061
|
-
import { jsx as
|
2996
|
+
import { jsx as jsx35 } from "react/jsx-runtime";
|
3062
2997
|
var buttonVariants = cva("aui-button", {
|
3063
2998
|
variants: {
|
3064
2999
|
variant: {
|
@@ -3078,7 +3013,7 @@ var buttonVariants = cva("aui-button", {
|
|
3078
3013
|
});
|
3079
3014
|
var Button = forwardRef20(
|
3080
3015
|
({ className, variant, size, ...props }, ref) => {
|
3081
|
-
return /* @__PURE__ */
|
3016
|
+
return /* @__PURE__ */ jsx35(
|
3082
3017
|
Primitive13.button,
|
3083
3018
|
{
|
3084
3019
|
className: buttonVariants({ variant, size, className }),
|
@@ -3091,14 +3026,14 @@ var Button = forwardRef20(
|
|
3091
3026
|
Button.displayName = "Button";
|
3092
3027
|
|
3093
3028
|
// src/ui/base/tooltip-icon-button.tsx
|
3094
|
-
import { jsx as
|
3029
|
+
import { jsx as jsx36, jsxs as jsxs3 } from "react/jsx-runtime";
|
3095
3030
|
var TooltipIconButton = forwardRef21(({ children, tooltip, side = "bottom", ...rest }, ref) => {
|
3096
3031
|
return /* @__PURE__ */ jsxs3(Tooltip, { children: [
|
3097
|
-
/* @__PURE__ */
|
3032
|
+
/* @__PURE__ */ jsx36(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxs3(Button, { variant: "ghost", size: "icon", ...rest, ref, children: [
|
3098
3033
|
children,
|
3099
|
-
/* @__PURE__ */
|
3034
|
+
/* @__PURE__ */ jsx36("span", { className: "aui-sr-only", children: tooltip })
|
3100
3035
|
] }) }),
|
3101
|
-
/* @__PURE__ */
|
3036
|
+
/* @__PURE__ */ jsx36(TooltipContent, { side, children: tooltip })
|
3102
3037
|
] });
|
3103
3038
|
});
|
3104
3039
|
TooltipIconButton.displayName = "TooltipIconButton";
|
@@ -3213,7 +3148,7 @@ var ContentPartRuntime = class {
|
|
3213
3148
|
const toolName = state.part.toolName;
|
3214
3149
|
const toolCallId = state.part.toolCallId;
|
3215
3150
|
this.threadApi.getState().addToolResult({
|
3216
|
-
messageId: message.
|
3151
|
+
messageId: message.id,
|
3217
3152
|
toolName,
|
3218
3153
|
toolCallId,
|
3219
3154
|
result
|
@@ -3267,60 +3202,13 @@ var ShallowMemoizeSubject = class extends BaseSubject {
|
|
3267
3202
|
};
|
3268
3203
|
|
3269
3204
|
// src/api/MessageRuntime.ts
|
3270
|
-
var MessageState = class {
|
3271
|
-
constructor(snapshot) {
|
3272
|
-
this.snapshot = snapshot;
|
3273
|
-
}
|
3274
|
-
/**
|
3275
|
-
* @deprecated Replace `.message.content` with `.content` etc. This will be removed in 0.6.0.
|
3276
|
-
*/
|
3277
|
-
get message() {
|
3278
|
-
return this.snapshot.message;
|
3279
|
-
}
|
3280
|
-
get id() {
|
3281
|
-
return this.snapshot.message.id;
|
3282
|
-
}
|
3283
|
-
get createdAt() {
|
3284
|
-
return this.snapshot.message.createdAt;
|
3285
|
-
}
|
3286
|
-
get role() {
|
3287
|
-
return this.snapshot.message.role;
|
3288
|
-
}
|
3289
|
-
get content() {
|
3290
|
-
return this.snapshot.message.content;
|
3291
|
-
}
|
3292
|
-
get attachments() {
|
3293
|
-
return this.snapshot.message.attachments;
|
3294
|
-
}
|
3295
|
-
get metadata() {
|
3296
|
-
return this.snapshot.message.metadata;
|
3297
|
-
}
|
3298
|
-
get status() {
|
3299
|
-
return this.snapshot.message.status;
|
3300
|
-
}
|
3301
|
-
get parentId() {
|
3302
|
-
return this.snapshot.parentId;
|
3303
|
-
}
|
3304
|
-
get isLast() {
|
3305
|
-
return this.snapshot.isLast;
|
3306
|
-
}
|
3307
|
-
get branches() {
|
3308
|
-
return this.snapshot.branches;
|
3309
|
-
}
|
3310
|
-
get branchNumber() {
|
3311
|
-
return this.snapshot.branchNumber;
|
3312
|
-
}
|
3313
|
-
get branchCount() {
|
3314
|
-
return this.snapshot.branchCount;
|
3315
|
-
}
|
3316
|
-
};
|
3317
3205
|
var MessageRuntime = class {
|
3318
3206
|
constructor(_core, _threadBinding) {
|
3319
3207
|
this._core = _core;
|
3320
3208
|
this._threadBinding = _threadBinding;
|
3321
3209
|
}
|
3322
3210
|
getState() {
|
3323
|
-
return
|
3211
|
+
return this._core.getState();
|
3324
3212
|
}
|
3325
3213
|
// TODO improve type
|
3326
3214
|
edit(message) {
|
@@ -3339,13 +3227,13 @@ var MessageRuntime = class {
|
|
3339
3227
|
speak() {
|
3340
3228
|
const state = this._core.getState();
|
3341
3229
|
if (!state) throw new Error("Message is not available");
|
3342
|
-
this._threadBinding.getState().speak(state.
|
3230
|
+
this._threadBinding.getState().speak(state.id);
|
3343
3231
|
}
|
3344
3232
|
submitFeedback({ type }) {
|
3345
3233
|
const state = this._core.getState();
|
3346
3234
|
if (!state) throw new Error("Message is not available");
|
3347
3235
|
this._threadBinding.getState().submitFeedback({
|
3348
|
-
messageId: state.
|
3236
|
+
messageId: state.id,
|
3349
3237
|
type
|
3350
3238
|
});
|
3351
3239
|
}
|
@@ -3361,7 +3249,7 @@ var MessageRuntime = class {
|
|
3361
3249
|
throw new Error("Must specify either branchId or position");
|
3362
3250
|
}
|
3363
3251
|
const thread = this._threadBinding.getState();
|
3364
|
-
const branches = thread.getBranches(state.
|
3252
|
+
const branches = thread.getBranches(state.id);
|
3365
3253
|
let targetBranch = branchId;
|
3366
3254
|
if (position === "previous") {
|
3367
3255
|
targetBranch = branches[state.branchNumber - 2];
|
@@ -3398,27 +3286,18 @@ var MessageRuntime = class {
|
|
3398
3286
|
};
|
3399
3287
|
|
3400
3288
|
// src/api/ThreadComposerRuntime.ts
|
3401
|
-
var
|
3402
|
-
|
3403
|
-
|
3404
|
-
|
3405
|
-
|
3406
|
-
|
3407
|
-
|
3408
|
-
|
3409
|
-
return this._composerBinding.getState().text;
|
3410
|
-
}
|
3411
|
-
get attachmentAccept() {
|
3412
|
-
return this._composerBinding.getState().attachmentAccept;
|
3413
|
-
}
|
3414
|
-
get attachments() {
|
3415
|
-
return this._composerBinding.getState().attachments;
|
3416
|
-
}
|
3289
|
+
var getThreadComposerState = (runtime) => {
|
3290
|
+
return Object.freeze({
|
3291
|
+
canCancel: runtime.canCancel,
|
3292
|
+
isEmpty: runtime.isEmpty,
|
3293
|
+
text: runtime.text,
|
3294
|
+
attachments: runtime.attachments,
|
3295
|
+
attachmentAccept: runtime.attachmentAccept
|
3296
|
+
});
|
3417
3297
|
};
|
3418
3298
|
var ThreadComposerRuntime = class {
|
3419
3299
|
constructor(_core) {
|
3420
3300
|
this._core = _core;
|
3421
|
-
this._state = new ComposerState(_core);
|
3422
3301
|
}
|
3423
3302
|
/**
|
3424
3303
|
* @deprecated Use `getState().isEmpty` instead. This will be removed in 0.6.0.
|
@@ -3426,6 +3305,12 @@ var ThreadComposerRuntime = class {
|
|
3426
3305
|
get isEmpty() {
|
3427
3306
|
return this._core.getState().isEmpty;
|
3428
3307
|
}
|
3308
|
+
/**
|
3309
|
+
* @deprecated Use `getState().canCancel` instead. This will be removed in 0.6.0.
|
3310
|
+
*/
|
3311
|
+
get canCancel() {
|
3312
|
+
return this._core.getState().canCancel;
|
3313
|
+
}
|
3429
3314
|
/**
|
3430
3315
|
* @deprecated Use `getState().text` instead. This will be removed in 0.6.0.
|
3431
3316
|
*/
|
@@ -3445,9 +3330,8 @@ var ThreadComposerRuntime = class {
|
|
3445
3330
|
get attachments() {
|
3446
3331
|
return this._core.getState().attachments;
|
3447
3332
|
}
|
3448
|
-
_state;
|
3449
3333
|
getState() {
|
3450
|
-
return this.
|
3334
|
+
return getThreadComposerState(this._core.getState());
|
3451
3335
|
}
|
3452
3336
|
setText(text) {
|
3453
3337
|
this._core.getState().setText(text);
|
@@ -3470,30 +3354,43 @@ var ThreadComposerRuntime = class {
|
|
3470
3354
|
send() {
|
3471
3355
|
this._core.getState().send();
|
3472
3356
|
}
|
3357
|
+
cancel() {
|
3358
|
+
this._core.getState().cancel();
|
3359
|
+
}
|
3473
3360
|
subscribe(callback) {
|
3474
3361
|
return this._core.subscribe(callback);
|
3475
3362
|
}
|
3476
3363
|
};
|
3477
3364
|
|
3478
3365
|
// src/api/ThreadRuntime.ts
|
3479
|
-
var
|
3480
|
-
|
3481
|
-
|
3482
|
-
|
3483
|
-
|
3484
|
-
|
3485
|
-
|
3486
|
-
|
3487
|
-
return this._core.isDisabled;
|
3488
|
-
}
|
3489
|
-
get isRunning() {
|
3490
|
-
const messages = this._core.messages;
|
3491
|
-
const lastMessage = messages[messages.length - 1];
|
3492
|
-
return lastMessage?.role !== "assistant" ? false : lastMessage.status.type === "running";
|
3366
|
+
var toAppendMessage = (messages, message) => {
|
3367
|
+
if (typeof message === "string") {
|
3368
|
+
return {
|
3369
|
+
parentId: messages.at(-1)?.id ?? null,
|
3370
|
+
role: "user",
|
3371
|
+
content: [{ type: "text", text: message }],
|
3372
|
+
attachments: []
|
3373
|
+
};
|
3493
3374
|
}
|
3494
|
-
|
3495
|
-
return
|
3375
|
+
if (message.role && message.parentId && message.attachments) {
|
3376
|
+
return message;
|
3496
3377
|
}
|
3378
|
+
return {
|
3379
|
+
parentId: message.parentId ?? messages.at(-1)?.id ?? null,
|
3380
|
+
role: message.role ?? "user",
|
3381
|
+
content: message.content,
|
3382
|
+
attachments: message.attachments ?? []
|
3383
|
+
};
|
3384
|
+
};
|
3385
|
+
var getThreadState = (runtime) => {
|
3386
|
+
const lastMessage = runtime.messages.at(-1);
|
3387
|
+
return Object.freeze({
|
3388
|
+
threadId: runtime.threadId,
|
3389
|
+
capabilities: runtime.capabilities,
|
3390
|
+
isDisabled: runtime.isDisabled,
|
3391
|
+
isRunning: lastMessage?.role !== "assistant" ? false : lastMessage.status.type === "running",
|
3392
|
+
unstable_synchronizer: runtime.unstable_synchronizer
|
3393
|
+
});
|
3497
3394
|
};
|
3498
3395
|
var ThreadRuntime = class {
|
3499
3396
|
constructor(_threadBinding) {
|
@@ -3538,10 +3435,12 @@ var ThreadRuntime = class {
|
|
3538
3435
|
})
|
3539
3436
|
);
|
3540
3437
|
getState() {
|
3541
|
-
return
|
3438
|
+
return getThreadState(this._threadBinding.getState());
|
3542
3439
|
}
|
3543
3440
|
append(message) {
|
3544
|
-
this._threadBinding.getState().append(
|
3441
|
+
this._threadBinding.getState().append(
|
3442
|
+
toAppendMessage(this._threadBinding.getState().messages, message)
|
3443
|
+
);
|
3545
3444
|
}
|
3546
3445
|
subscribe(callback) {
|
3547
3446
|
return this._threadBinding.subscribe(callback);
|
@@ -3601,6 +3500,7 @@ var ThreadRuntime = class {
|
|
3601
3500
|
if (!message) return void 0;
|
3602
3501
|
const branches = this._threadBinding.getState().getBranches(message.id);
|
3603
3502
|
return {
|
3503
|
+
...message,
|
3604
3504
|
message,
|
3605
3505
|
isLast: idx === messages.length - 1,
|
3606
3506
|
parentId: messages[idx - 1]?.id ?? null,
|
@@ -4239,15 +4139,15 @@ var LocalRuntime = class extends AssistantRuntime {
|
|
4239
4139
|
};
|
4240
4140
|
var useLocalRuntime = (adapter, options = {}) => {
|
4241
4141
|
const [runtime] = useState12(() => new LocalRuntimeCore(adapter, options));
|
4242
|
-
|
4142
|
+
useInsertionEffect(() => {
|
4243
4143
|
runtime.thread.adapter = adapter;
|
4244
4144
|
runtime.thread.options = options;
|
4245
4145
|
});
|
4246
|
-
return
|
4146
|
+
return useMemo7(() => new LocalRuntime(runtime), [runtime]);
|
4247
4147
|
};
|
4248
4148
|
|
4249
4149
|
// src/runtimes/external-store/useExternalStoreRuntime.tsx
|
4250
|
-
import { useEffect as useEffect15, useMemo as
|
4150
|
+
import { useEffect as useEffect15, useMemo as useMemo8, useState as useState13 } from "react";
|
4251
4151
|
|
4252
4152
|
// src/runtimes/external-store/getExternalStoreMessage.tsx
|
4253
4153
|
var symbolInnerMessage = Symbol("innerMessage");
|
@@ -4587,11 +4487,11 @@ var useExternalStoreRuntime = (store) => {
|
|
4587
4487
|
useEffect15(() => {
|
4588
4488
|
runtime.thread.store = store;
|
4589
4489
|
});
|
4590
|
-
return
|
4490
|
+
return useMemo8(() => new AssistantRuntime(runtime, ThreadRuntime), [runtime]);
|
4591
4491
|
};
|
4592
4492
|
|
4593
4493
|
// src/runtimes/external-store/external-message-converter.tsx
|
4594
|
-
import { useMemo as
|
4494
|
+
import { useMemo as useMemo9 } from "react";
|
4595
4495
|
var joinExternalMessages = (messages) => {
|
4596
4496
|
const assistantMessage = {
|
4597
4497
|
role: "assistant",
|
@@ -4620,19 +4520,18 @@ var joinExternalMessages = (messages) => {
|
|
4620
4520
|
);
|
4621
4521
|
}
|
4622
4522
|
} else {
|
4623
|
-
const content = output.content;
|
4624
4523
|
const role = output.role;
|
4625
4524
|
switch (role) {
|
4626
4525
|
case "system":
|
4627
4526
|
case "user":
|
4628
|
-
return
|
4527
|
+
return output;
|
4629
4528
|
case "assistant":
|
4630
4529
|
if (assistantMessage.content.length === 0) {
|
4631
4530
|
assistantMessage.id = output.id;
|
4632
4531
|
assistantMessage.createdAt ??= output.createdAt;
|
4633
4532
|
assistantMessage.status ??= output.status;
|
4634
4533
|
}
|
4635
|
-
assistantMessage.content.push(...content);
|
4534
|
+
assistantMessage.content.push(...output.content);
|
4636
4535
|
break;
|
4637
4536
|
default: {
|
4638
4537
|
const unsupportedRole = role;
|
@@ -4678,7 +4577,7 @@ var useExternalMessageConverter = ({
|
|
4678
4577
|
messages,
|
4679
4578
|
isRunning
|
4680
4579
|
}) => {
|
4681
|
-
const state =
|
4580
|
+
const state = useMemo9(
|
4682
4581
|
() => ({
|
4683
4582
|
callback,
|
4684
4583
|
callbackCache: /* @__PURE__ */ new WeakMap(),
|
@@ -4687,7 +4586,7 @@ var useExternalMessageConverter = ({
|
|
4687
4586
|
}),
|
4688
4587
|
[callback]
|
4689
4588
|
);
|
4690
|
-
return
|
4589
|
+
return useMemo9(() => {
|
4691
4590
|
const callbackResults = [];
|
4692
4591
|
for (const message of messages) {
|
4693
4592
|
let result = state.callbackCache.get(message);
|
@@ -4955,7 +4854,7 @@ import {
|
|
4955
4854
|
createContext as createContext7,
|
4956
4855
|
useContext as useContext4
|
4957
4856
|
} from "react";
|
4958
|
-
import { Fragment as Fragment3, jsx as
|
4857
|
+
import { Fragment as Fragment3, jsx as jsx37 } from "react/jsx-runtime";
|
4959
4858
|
var ThreadConfigContext = createContext7({});
|
4960
4859
|
var useThreadConfig = () => {
|
4961
4860
|
return useContext4(ThreadConfigContext);
|
@@ -4965,14 +4864,14 @@ var ThreadConfigProvider = ({
|
|
4965
4864
|
config
|
4966
4865
|
}) => {
|
4967
4866
|
const hasAssistant = !!useAssistantRuntime({ optional: true });
|
4968
|
-
const configProvider = config && Object.keys(config ?? {}).length > 0 ? /* @__PURE__ */
|
4867
|
+
const configProvider = config && Object.keys(config ?? {}).length > 0 ? /* @__PURE__ */ jsx37(ThreadConfigContext.Provider, { value: config, children }) : /* @__PURE__ */ jsx37(Fragment3, { children });
|
4969
4868
|
if (!config?.runtime) return configProvider;
|
4970
4869
|
if (hasAssistant) {
|
4971
4870
|
throw new Error(
|
4972
4871
|
"You provided a runtime to <Thread> while simulataneously using <AssistantRuntimeProvider>. This is not allowed."
|
4973
4872
|
);
|
4974
4873
|
}
|
4975
|
-
return /* @__PURE__ */
|
4874
|
+
return /* @__PURE__ */ jsx37(AssistantRuntimeProvider, { runtime: config.runtime, children: configProvider });
|
4976
4875
|
};
|
4977
4876
|
ThreadConfigProvider.displayName = "ThreadConfigProvider";
|
4978
4877
|
|
@@ -4987,7 +4886,7 @@ import {
|
|
4987
4886
|
ThumbsDownIcon,
|
4988
4887
|
ThumbsUpIcon
|
4989
4888
|
} from "lucide-react";
|
4990
|
-
import { Fragment as Fragment4, jsx as
|
4889
|
+
import { Fragment as Fragment4, jsx as jsx38, jsxs as jsxs4 } from "react/jsx-runtime";
|
4991
4890
|
var useAllowCopy = (ensureCapability = false) => {
|
4992
4891
|
const { assistantMessage: { allowCopy = true } = {} } = useThreadConfig();
|
4993
4892
|
const copySupported = useThread((t) => t.capabilities.unstable_copy);
|
@@ -5028,11 +4927,11 @@ var AssistantActionBar = () => {
|
|
5028
4927
|
autohide: "not-last",
|
5029
4928
|
autohideFloat: "single-branch",
|
5030
4929
|
children: [
|
5031
|
-
allowSpeak && /* @__PURE__ */
|
5032
|
-
allowCopy && /* @__PURE__ */
|
5033
|
-
allowReload && /* @__PURE__ */
|
5034
|
-
allowFeedbackPositive && /* @__PURE__ */
|
5035
|
-
allowFeedbackNegative && /* @__PURE__ */
|
4930
|
+
allowSpeak && /* @__PURE__ */ jsx38(AssistantActionBarSpeechControl, {}),
|
4931
|
+
allowCopy && /* @__PURE__ */ jsx38(AssistantActionBarCopy, {}),
|
4932
|
+
allowReload && /* @__PURE__ */ jsx38(AssistantActionBarReload, {}),
|
4933
|
+
allowFeedbackPositive && /* @__PURE__ */ jsx38(AssistantActionBarFeedbackPositive, {}),
|
4934
|
+
allowFeedbackNegative && /* @__PURE__ */ jsx38(AssistantActionBarFeedbackNegative, {})
|
5036
4935
|
]
|
5037
4936
|
}
|
5038
4937
|
);
|
@@ -5048,16 +4947,16 @@ var AssistantActionBarCopy = forwardRef22((props, ref) => {
|
|
5048
4947
|
assistantMessage: { copy: { tooltip = "Copy" } = {} } = {}
|
5049
4948
|
} = {}
|
5050
4949
|
} = useThreadConfig();
|
5051
|
-
return /* @__PURE__ */
|
5052
|
-
/* @__PURE__ */
|
5053
|
-
/* @__PURE__ */
|
4950
|
+
return /* @__PURE__ */ jsx38(actionBar_exports.Copy, { asChild: true, children: /* @__PURE__ */ jsx38(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsxs4(Fragment4, { children: [
|
4951
|
+
/* @__PURE__ */ jsx38(message_exports.If, { copied: true, children: /* @__PURE__ */ jsx38(CheckIcon, {}) }),
|
4952
|
+
/* @__PURE__ */ jsx38(message_exports.If, { copied: false, children: /* @__PURE__ */ jsx38(CopyIcon, {}) })
|
5054
4953
|
] }) }) });
|
5055
4954
|
});
|
5056
4955
|
AssistantActionBarCopy.displayName = "AssistantActionBarCopy";
|
5057
4956
|
var AssistantActionBarSpeechControl = () => {
|
5058
4957
|
return /* @__PURE__ */ jsxs4(Fragment4, { children: [
|
5059
|
-
/* @__PURE__ */
|
5060
|
-
/* @__PURE__ */
|
4958
|
+
/* @__PURE__ */ jsx38(message_exports.If, { speaking: false, children: /* @__PURE__ */ jsx38(AssistantActionBarSpeak, {}) }),
|
4959
|
+
/* @__PURE__ */ jsx38(message_exports.If, { speaking: true, children: /* @__PURE__ */ jsx38(AssistantActionBarStopSpeaking, {}) })
|
5061
4960
|
] });
|
5062
4961
|
};
|
5063
4962
|
var AssistantActionBarSpeak = forwardRef22((props, ref) => {
|
@@ -5067,7 +4966,7 @@ var AssistantActionBarSpeak = forwardRef22((props, ref) => {
|
|
5067
4966
|
} = {}
|
5068
4967
|
} = useThreadConfig();
|
5069
4968
|
const allowSpeak = useAllowSpeak();
|
5070
|
-
return /* @__PURE__ */
|
4969
|
+
return /* @__PURE__ */ jsx38(actionBar_exports.Speak, { disabled: !allowSpeak, asChild: true, children: /* @__PURE__ */ jsx38(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx38(AudioLinesIcon, {}) }) });
|
5071
4970
|
});
|
5072
4971
|
AssistantActionBarSpeak.displayName = "AssistantActionBarSpeak";
|
5073
4972
|
var AssistantActionBarStopSpeaking = forwardRef22((props, ref) => {
|
@@ -5079,7 +4978,7 @@ var AssistantActionBarStopSpeaking = forwardRef22((props, ref) => {
|
|
5079
4978
|
} = {}
|
5080
4979
|
} = useThreadConfig();
|
5081
4980
|
const allowSpeak = useAllowSpeak();
|
5082
|
-
return /* @__PURE__ */
|
4981
|
+
return /* @__PURE__ */ jsx38(actionBar_exports.StopSpeaking, { disabled: !allowSpeak, asChild: true, children: /* @__PURE__ */ jsx38(TooltipIconButton, { tooltip: stopTooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx38(StopCircleIcon, {}) }) });
|
5083
4982
|
});
|
5084
4983
|
AssistantActionBarStopSpeaking.displayName = "AssistantActionBarStopSpeaking";
|
5085
4984
|
var AssistantActionBarReload = forwardRef22((props, ref) => {
|
@@ -5089,7 +4988,7 @@ var AssistantActionBarReload = forwardRef22((props, ref) => {
|
|
5089
4988
|
} = {}
|
5090
4989
|
} = useThreadConfig();
|
5091
4990
|
const allowReload = useAllowReload();
|
5092
|
-
return /* @__PURE__ */
|
4991
|
+
return /* @__PURE__ */ jsx38(actionBar_exports.Reload, { disabled: !allowReload, asChild: true, children: /* @__PURE__ */ jsx38(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx38(RefreshCwIcon, {}) }) });
|
5093
4992
|
});
|
5094
4993
|
AssistantActionBarReload.displayName = "AssistantActionBarReload";
|
5095
4994
|
var AssistantActionBarFeedbackPositive = forwardRef22((props, ref) => {
|
@@ -5101,13 +5000,13 @@ var AssistantActionBarFeedbackPositive = forwardRef22((props, ref) => {
|
|
5101
5000
|
} = {}
|
5102
5001
|
} = useThreadConfig();
|
5103
5002
|
const allowFeedbackPositive = useAllowFeedbackPositive();
|
5104
|
-
return /* @__PURE__ */
|
5003
|
+
return /* @__PURE__ */ jsx38(
|
5105
5004
|
actionBar_exports.FeedbackPositive,
|
5106
5005
|
{
|
5107
5006
|
disabled: !allowFeedbackPositive,
|
5108
5007
|
className: "aui-assistant-action-bar-feedback-positive",
|
5109
5008
|
asChild: true,
|
5110
|
-
children: /* @__PURE__ */
|
5009
|
+
children: /* @__PURE__ */ jsx38(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx38(ThumbsUpIcon, {}) })
|
5111
5010
|
}
|
5112
5011
|
);
|
5113
5012
|
});
|
@@ -5121,13 +5020,13 @@ var AssistantActionBarFeedbackNegative = forwardRef22((props, ref) => {
|
|
5121
5020
|
} = {}
|
5122
5021
|
} = useThreadConfig();
|
5123
5022
|
const allowFeedbackNegative = useAllowFeedbackNegative();
|
5124
|
-
return /* @__PURE__ */
|
5023
|
+
return /* @__PURE__ */ jsx38(
|
5125
5024
|
actionBar_exports.FeedbackNegative,
|
5126
5025
|
{
|
5127
5026
|
disabled: !allowFeedbackNegative,
|
5128
5027
|
className: "aui-assistant-action-bar-feedback-negative",
|
5129
5028
|
asChild: true,
|
5130
|
-
children: /* @__PURE__ */
|
5029
|
+
children: /* @__PURE__ */ jsx38(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx38(ThumbsDownIcon, {}) })
|
5131
5030
|
}
|
5132
5031
|
);
|
5133
5032
|
});
|
@@ -5148,12 +5047,12 @@ var assistant_action_bar_default = Object.assign(
|
|
5148
5047
|
);
|
5149
5048
|
|
5150
5049
|
// src/ui/assistant-message.tsx
|
5151
|
-
import { forwardRef as forwardRef24, useMemo as
|
5050
|
+
import { forwardRef as forwardRef24, useMemo as useMemo10 } from "react";
|
5152
5051
|
|
5153
5052
|
// src/ui/branch-picker.tsx
|
5154
5053
|
import { forwardRef as forwardRef23 } from "react";
|
5155
5054
|
import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react";
|
5156
|
-
import { jsx as
|
5055
|
+
import { jsx as jsx39, jsxs as jsxs5 } from "react/jsx-runtime";
|
5157
5056
|
var useAllowBranchPicker = (ensureCapability = false) => {
|
5158
5057
|
const { branchPicker: { allowBranchPicker = true } = {} } = useThreadConfig();
|
5159
5058
|
const branchPickerSupported = useThread((t) => t.capabilities.edit);
|
@@ -5163,9 +5062,9 @@ var BranchPicker = () => {
|
|
5163
5062
|
const allowBranchPicker = useAllowBranchPicker();
|
5164
5063
|
if (!allowBranchPicker) return null;
|
5165
5064
|
return /* @__PURE__ */ jsxs5(BranchPickerRoot, { hideWhenSingleBranch: true, children: [
|
5166
|
-
/* @__PURE__ */
|
5167
|
-
/* @__PURE__ */
|
5168
|
-
/* @__PURE__ */
|
5065
|
+
/* @__PURE__ */ jsx39(BranchPickerPrevious2, {}),
|
5066
|
+
/* @__PURE__ */ jsx39(BranchPickerState, {}),
|
5067
|
+
/* @__PURE__ */ jsx39(BranchPickerNext, {})
|
5169
5068
|
] });
|
5170
5069
|
};
|
5171
5070
|
BranchPicker.displayName = "BranchPicker";
|
@@ -5180,7 +5079,7 @@ var BranchPickerPrevious2 = forwardRef23((props, ref) => {
|
|
5180
5079
|
} = {}
|
5181
5080
|
} = useThreadConfig();
|
5182
5081
|
const allowBranchPicker = useAllowBranchPicker();
|
5183
|
-
return /* @__PURE__ */
|
5082
|
+
return /* @__PURE__ */ jsx39(branchPicker_exports.Previous, { disabled: !allowBranchPicker, asChild: true, children: /* @__PURE__ */ jsx39(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx39(ChevronLeftIcon, {}) }) });
|
5184
5083
|
});
|
5185
5084
|
BranchPickerPrevious2.displayName = "BranchPickerPrevious";
|
5186
5085
|
var BranchPickerStateWrapper = withDefaults("span", {
|
@@ -5188,9 +5087,9 @@ var BranchPickerStateWrapper = withDefaults("span", {
|
|
5188
5087
|
});
|
5189
5088
|
var BranchPickerState = forwardRef23((props, ref) => {
|
5190
5089
|
return /* @__PURE__ */ jsxs5(BranchPickerStateWrapper, { ...props, ref, children: [
|
5191
|
-
/* @__PURE__ */
|
5090
|
+
/* @__PURE__ */ jsx39(branchPicker_exports.Number, {}),
|
5192
5091
|
" / ",
|
5193
|
-
/* @__PURE__ */
|
5092
|
+
/* @__PURE__ */ jsx39(branchPicker_exports.Count, {})
|
5194
5093
|
] });
|
5195
5094
|
});
|
5196
5095
|
BranchPickerState.displayName = "BranchPickerState";
|
@@ -5199,7 +5098,7 @@ var BranchPickerNext = forwardRef23((props, ref) => {
|
|
5199
5098
|
strings: { branchPicker: { next: { tooltip = "Next" } = {} } = {} } = {}
|
5200
5099
|
} = useThreadConfig();
|
5201
5100
|
const allowBranchPicker = useAllowBranchPicker();
|
5202
|
-
return /* @__PURE__ */
|
5101
|
+
return /* @__PURE__ */ jsx39(branchPicker_exports.Next, { disabled: !allowBranchPicker, asChild: true, children: /* @__PURE__ */ jsx39(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx39(ChevronRightIcon, {}) }) });
|
5203
5102
|
});
|
5204
5103
|
BranchPickerNext.displayName = "BranchPickerNext";
|
5205
5104
|
var exports2 = {
|
@@ -5211,12 +5110,12 @@ var branch_picker_default = Object.assign(BranchPicker, exports2);
|
|
5211
5110
|
|
5212
5111
|
// src/ui/base/avatar.tsx
|
5213
5112
|
import * as AvatarPrimitive from "@radix-ui/react-avatar";
|
5214
|
-
import { jsx as
|
5113
|
+
import { jsx as jsx40, jsxs as jsxs6 } from "react/jsx-runtime";
|
5215
5114
|
var Avatar = ({ src, alt, fallback }) => {
|
5216
5115
|
if (src == null && fallback == null) return null;
|
5217
5116
|
return /* @__PURE__ */ jsxs6(AvatarRoot, { children: [
|
5218
|
-
src != null && /* @__PURE__ */
|
5219
|
-
fallback != null && /* @__PURE__ */
|
5117
|
+
src != null && /* @__PURE__ */ jsx40(AvatarImage, { src, alt }),
|
5118
|
+
fallback != null && /* @__PURE__ */ jsx40(AvatarFallback, { children: fallback })
|
5220
5119
|
] });
|
5221
5120
|
};
|
5222
5121
|
Avatar.displayName = "Avatar";
|
@@ -5235,10 +5134,10 @@ AvatarFallback.displayName = "AvatarFallback";
|
|
5235
5134
|
|
5236
5135
|
// src/ui/content-part.tsx
|
5237
5136
|
import classNames2 from "classnames";
|
5238
|
-
import { jsx as
|
5137
|
+
import { jsx as jsx41 } from "react/jsx-runtime";
|
5239
5138
|
var Text = () => {
|
5240
5139
|
const status = useSmoothStatus();
|
5241
|
-
return /* @__PURE__ */
|
5140
|
+
return /* @__PURE__ */ jsx41(
|
5242
5141
|
contentPart_exports.Text,
|
5243
5142
|
{
|
5244
5143
|
className: classNames2(
|
@@ -5253,19 +5152,19 @@ var exports3 = { Text: withSmoothContextProvider(Text) };
|
|
5253
5152
|
var content_part_default = exports3;
|
5254
5153
|
|
5255
5154
|
// src/ui/assistant-message.tsx
|
5256
|
-
import { jsx as
|
5155
|
+
import { jsx as jsx42, jsxs as jsxs7 } from "react/jsx-runtime";
|
5257
5156
|
var AssistantMessage = () => {
|
5258
5157
|
return /* @__PURE__ */ jsxs7(AssistantMessageRoot, { children: [
|
5259
|
-
/* @__PURE__ */
|
5260
|
-
/* @__PURE__ */
|
5261
|
-
/* @__PURE__ */
|
5262
|
-
/* @__PURE__ */
|
5158
|
+
/* @__PURE__ */ jsx42(AssistantMessageAvatar, {}),
|
5159
|
+
/* @__PURE__ */ jsx42(AssistantMessageContent, {}),
|
5160
|
+
/* @__PURE__ */ jsx42(branch_picker_default, {}),
|
5161
|
+
/* @__PURE__ */ jsx42(assistant_action_bar_default, {})
|
5263
5162
|
] });
|
5264
5163
|
};
|
5265
5164
|
AssistantMessage.displayName = "AssistantMessage";
|
5266
5165
|
var AssistantMessageAvatar = () => {
|
5267
5166
|
const { assistantAvatar: avatar = { fallback: "A" } } = useThreadConfig();
|
5268
|
-
return /* @__PURE__ */
|
5167
|
+
return /* @__PURE__ */ jsx42(Avatar, { ...avatar });
|
5269
5168
|
};
|
5270
5169
|
var AssistantMessageRoot = withDefaults(message_exports.Root, {
|
5271
5170
|
className: "aui-assistant-message-root"
|
@@ -5276,7 +5175,7 @@ var AssistantMessageContentWrapper = withDefaults("div", {
|
|
5276
5175
|
});
|
5277
5176
|
var AssistantMessageContent = forwardRef24(({ components: componentsProp, ...rest }, ref) => {
|
5278
5177
|
const { tools, assistantMessage: { components = {} } = {} } = useThreadConfig();
|
5279
|
-
const toolsComponents =
|
5178
|
+
const toolsComponents = useMemo10(
|
5280
5179
|
() => ({
|
5281
5180
|
by_name: !tools ? void 0 : Object.fromEntries(
|
5282
5181
|
tools.map((t) => [
|
@@ -5289,7 +5188,7 @@ var AssistantMessageContent = forwardRef24(({ components: componentsProp, ...res
|
|
5289
5188
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
5290
5189
|
[...tools ?? [], components.ToolFallback]
|
5291
5190
|
);
|
5292
|
-
return /* @__PURE__ */
|
5191
|
+
return /* @__PURE__ */ jsx42(AssistantMessageContentWrapper, { ...rest, ref, children: /* @__PURE__ */ jsx42(
|
5293
5192
|
message_exports.Content,
|
5294
5193
|
{
|
5295
5194
|
components: {
|
@@ -5324,9 +5223,9 @@ import { forwardRef as forwardRef26 } from "react";
|
|
5324
5223
|
import { PaperclipIcon, SendHorizontalIcon } from "lucide-react";
|
5325
5224
|
|
5326
5225
|
// src/ui/base/CircleStopIcon.tsx
|
5327
|
-
import { jsx as
|
5226
|
+
import { jsx as jsx43 } from "react/jsx-runtime";
|
5328
5227
|
var CircleStopIcon = () => {
|
5329
|
-
return /* @__PURE__ */
|
5228
|
+
return /* @__PURE__ */ jsx43(
|
5330
5229
|
"svg",
|
5331
5230
|
{
|
5332
5231
|
xmlns: "http://www.w3.org/2000/svg",
|
@@ -5334,7 +5233,7 @@ var CircleStopIcon = () => {
|
|
5334
5233
|
fill: "currentColor",
|
5335
5234
|
width: "16",
|
5336
5235
|
height: "16",
|
5337
|
-
children: /* @__PURE__ */
|
5236
|
+
children: /* @__PURE__ */ jsx43("rect", { width: "10", height: "10", x: "3", y: "3", rx: "2" })
|
5338
5237
|
}
|
5339
5238
|
);
|
5340
5239
|
};
|
@@ -5343,7 +5242,7 @@ CircleStopIcon.displayName = "CircleStopIcon";
|
|
5343
5242
|
// src/ui/composer-attachment.tsx
|
5344
5243
|
import { forwardRef as forwardRef25 } from "react";
|
5345
5244
|
import { CircleXIcon } from "lucide-react";
|
5346
|
-
import { jsx as
|
5245
|
+
import { jsx as jsx44, jsxs as jsxs8 } from "react/jsx-runtime";
|
5347
5246
|
var ComposerAttachmentRoot = withDefaults("div", {
|
5348
5247
|
className: "aui-composer-attachment-root"
|
5349
5248
|
});
|
@@ -5353,7 +5252,7 @@ var ComposerAttachment2 = () => {
|
|
5353
5252
|
return /* @__PURE__ */ jsxs8(ComposerAttachmentRoot, { children: [
|
5354
5253
|
".",
|
5355
5254
|
attachment.name.split(".").pop(),
|
5356
|
-
/* @__PURE__ */
|
5255
|
+
/* @__PURE__ */ jsx44(ComposerAttachmentRemove, {})
|
5357
5256
|
] });
|
5358
5257
|
};
|
5359
5258
|
ComposerAttachment2.displayName = "ComposerAttachment";
|
@@ -5368,7 +5267,7 @@ var ComposerAttachmentRemove = forwardRef25((props, ref) => {
|
|
5368
5267
|
const handleRemoveAttachment = () => {
|
5369
5268
|
composerStore.getState().removeAttachment(attachmentStore.getState().attachment.id);
|
5370
5269
|
};
|
5371
|
-
return /* @__PURE__ */
|
5270
|
+
return /* @__PURE__ */ jsx44(
|
5372
5271
|
TooltipIconButton,
|
5373
5272
|
{
|
5374
5273
|
tooltip,
|
@@ -5377,7 +5276,7 @@ var ComposerAttachmentRemove = forwardRef25((props, ref) => {
|
|
5377
5276
|
...props,
|
5378
5277
|
onClick: handleRemoveAttachment,
|
5379
5278
|
ref,
|
5380
|
-
children: props.children ?? /* @__PURE__ */
|
5279
|
+
children: props.children ?? /* @__PURE__ */ jsx44(CircleXIcon, {})
|
5381
5280
|
}
|
5382
5281
|
);
|
5383
5282
|
});
|
@@ -5392,7 +5291,7 @@ var composer_attachment_default = Object.assign(
|
|
5392
5291
|
);
|
5393
5292
|
|
5394
5293
|
// src/ui/composer.tsx
|
5395
|
-
import { Fragment as Fragment5, jsx as
|
5294
|
+
import { Fragment as Fragment5, jsx as jsx45, jsxs as jsxs9 } from "react/jsx-runtime";
|
5396
5295
|
var useAllowAttachments = (ensureCapability = false) => {
|
5397
5296
|
const { composer: { allowAttachments = true } = {} } = useThreadConfig();
|
5398
5297
|
const attachmentsSupported = useThread((t) => t.capabilities.attachments);
|
@@ -5401,10 +5300,10 @@ var useAllowAttachments = (ensureCapability = false) => {
|
|
5401
5300
|
var Composer = () => {
|
5402
5301
|
const allowAttachments = useAllowAttachments(true);
|
5403
5302
|
return /* @__PURE__ */ jsxs9(ComposerRoot, { children: [
|
5404
|
-
allowAttachments && /* @__PURE__ */
|
5405
|
-
allowAttachments && /* @__PURE__ */
|
5406
|
-
/* @__PURE__ */
|
5407
|
-
/* @__PURE__ */
|
5303
|
+
allowAttachments && /* @__PURE__ */ jsx45(ComposerAttachments, {}),
|
5304
|
+
allowAttachments && /* @__PURE__ */ jsx45(ComposerAddAttachment, {}),
|
5305
|
+
/* @__PURE__ */ jsx45(ComposerInput, { autoFocus: true }),
|
5306
|
+
/* @__PURE__ */ jsx45(ComposerAction, {})
|
5408
5307
|
] });
|
5409
5308
|
};
|
5410
5309
|
Composer.displayName = "Composer";
|
@@ -5424,7 +5323,7 @@ var ComposerInput = forwardRef26(
|
|
5424
5323
|
composer: { input: { placeholder = "Write a message..." } = {} } = {}
|
5425
5324
|
} = {}
|
5426
5325
|
} = useThreadConfig();
|
5427
|
-
return /* @__PURE__ */
|
5326
|
+
return /* @__PURE__ */ jsx45(ComposerInputStyled, { placeholder, ...props, ref });
|
5428
5327
|
}
|
5429
5328
|
);
|
5430
5329
|
ComposerInput.displayName = "ComposerInput";
|
@@ -5432,7 +5331,7 @@ var ComposerAttachmentsContainer = withDefaults("div", {
|
|
5432
5331
|
className: "aui-composer-attachments"
|
5433
5332
|
});
|
5434
5333
|
var ComposerAttachments = ({ components }) => {
|
5435
|
-
return /* @__PURE__ */
|
5334
|
+
return /* @__PURE__ */ jsx45(ComposerAttachmentsContainer, { children: /* @__PURE__ */ jsx45(
|
5436
5335
|
composer_exports.Attachments,
|
5437
5336
|
{
|
5438
5337
|
components: {
|
@@ -5453,14 +5352,14 @@ var ComposerAddAttachment = forwardRef26((props, ref) => {
|
|
5453
5352
|
} = {}
|
5454
5353
|
} = useThreadConfig();
|
5455
5354
|
const allowAttachments = useAllowAttachments();
|
5456
|
-
return /* @__PURE__ */
|
5355
|
+
return /* @__PURE__ */ jsx45(composer_exports.AddAttachment, { disabled: !allowAttachments, asChild: true, children: /* @__PURE__ */ jsx45(
|
5457
5356
|
ComposerAttachButton,
|
5458
5357
|
{
|
5459
5358
|
tooltip,
|
5460
5359
|
variant: "ghost",
|
5461
5360
|
...props,
|
5462
5361
|
ref,
|
5463
|
-
children: props.children ?? /* @__PURE__ */
|
5362
|
+
children: props.children ?? /* @__PURE__ */ jsx45(PaperclipIcon, {})
|
5464
5363
|
}
|
5465
5364
|
) });
|
5466
5365
|
});
|
@@ -5471,10 +5370,10 @@ var useAllowCancel = () => {
|
|
5471
5370
|
};
|
5472
5371
|
var ComposerAction = () => {
|
5473
5372
|
const allowCancel = useAllowCancel();
|
5474
|
-
if (!allowCancel) return /* @__PURE__ */
|
5373
|
+
if (!allowCancel) return /* @__PURE__ */ jsx45(ComposerSend, {});
|
5475
5374
|
return /* @__PURE__ */ jsxs9(Fragment5, { children: [
|
5476
|
-
/* @__PURE__ */
|
5477
|
-
/* @__PURE__ */
|
5375
|
+
/* @__PURE__ */ jsx45(thread_exports.If, { running: false, children: /* @__PURE__ */ jsx45(ComposerSend, {}) }),
|
5376
|
+
/* @__PURE__ */ jsx45(thread_exports.If, { running: true, children: /* @__PURE__ */ jsx45(ComposerCancel, {}) })
|
5478
5377
|
] });
|
5479
5378
|
};
|
5480
5379
|
ComposerAction.displayName = "ComposerAction";
|
@@ -5486,7 +5385,7 @@ var ComposerSend = forwardRef26((props, ref) => {
|
|
5486
5385
|
const {
|
5487
5386
|
strings: { composer: { send: { tooltip = "Send" } = {} } = {} } = {}
|
5488
5387
|
} = useThreadConfig();
|
5489
|
-
return /* @__PURE__ */
|
5388
|
+
return /* @__PURE__ */ jsx45(composer_exports.Send, { asChild: true, children: /* @__PURE__ */ jsx45(ComposerSendButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx45(SendHorizontalIcon, {}) }) });
|
5490
5389
|
});
|
5491
5390
|
ComposerSend.displayName = "ComposerSend";
|
5492
5391
|
var ComposerCancelButton = withDefaults(TooltipIconButton, {
|
@@ -5497,7 +5396,7 @@ var ComposerCancel = forwardRef26((props, ref) => {
|
|
5497
5396
|
const {
|
5498
5397
|
strings: { composer: { cancel: { tooltip = "Cancel" } = {} } = {} } = {}
|
5499
5398
|
} = useThreadConfig();
|
5500
|
-
return /* @__PURE__ */
|
5399
|
+
return /* @__PURE__ */ jsx45(composer_exports.Cancel, { asChild: true, children: /* @__PURE__ */ jsx45(ComposerCancelButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx45(CircleStopIcon, {}) }) });
|
5501
5400
|
});
|
5502
5401
|
ComposerCancel.displayName = "ComposerCancel";
|
5503
5402
|
var exports6 = {
|
@@ -5513,14 +5412,14 @@ var composer_default = Object.assign(Composer, exports6);
|
|
5513
5412
|
|
5514
5413
|
// src/ui/thread-welcome.tsx
|
5515
5414
|
import { forwardRef as forwardRef27 } from "react";
|
5516
|
-
import { jsx as
|
5415
|
+
import { jsx as jsx46, jsxs as jsxs10 } from "react/jsx-runtime";
|
5517
5416
|
var ThreadWelcome = () => {
|
5518
5417
|
return /* @__PURE__ */ jsxs10(ThreadWelcomeRoot, { children: [
|
5519
5418
|
/* @__PURE__ */ jsxs10(ThreadWelcomeCenter, { children: [
|
5520
|
-
/* @__PURE__ */
|
5521
|
-
/* @__PURE__ */
|
5419
|
+
/* @__PURE__ */ jsx46(ThreadWelcomeAvatar, {}),
|
5420
|
+
/* @__PURE__ */ jsx46(ThreadWelcomeMessage, {})
|
5522
5421
|
] }),
|
5523
|
-
/* @__PURE__ */
|
5422
|
+
/* @__PURE__ */ jsx46(ThreadWelcomeSuggestions, {})
|
5524
5423
|
] });
|
5525
5424
|
};
|
5526
5425
|
ThreadWelcome.displayName = "ThreadWelcome";
|
@@ -5532,20 +5431,20 @@ var ThreadWelcomeCenter = withDefaults("div", {
|
|
5532
5431
|
});
|
5533
5432
|
var ThreadWelcomeRoot = forwardRef27(
|
5534
5433
|
(props, ref) => {
|
5535
|
-
return /* @__PURE__ */
|
5434
|
+
return /* @__PURE__ */ jsx46(thread_exports.Empty, { children: /* @__PURE__ */ jsx46(ThreadWelcomeRootStyled, { ...props, ref }) });
|
5536
5435
|
}
|
5537
5436
|
);
|
5538
5437
|
ThreadWelcomeRoot.displayName = "ThreadWelcomeRoot";
|
5539
5438
|
var ThreadWelcomeAvatar = () => {
|
5540
5439
|
const { assistantAvatar: avatar = { fallback: "A" } } = useThreadConfig();
|
5541
|
-
return /* @__PURE__ */
|
5440
|
+
return /* @__PURE__ */ jsx46(Avatar, { ...avatar });
|
5542
5441
|
};
|
5543
5442
|
var ThreadWelcomeMessageStyled = withDefaults("p", {
|
5544
5443
|
className: "aui-thread-welcome-message"
|
5545
5444
|
});
|
5546
5445
|
var ThreadWelcomeMessage = forwardRef27(({ message: messageProp, ...rest }, ref) => {
|
5547
5446
|
const { welcome: { message = "How can I help you today?" } = {} } = useThreadConfig();
|
5548
|
-
return /* @__PURE__ */
|
5447
|
+
return /* @__PURE__ */ jsx46(ThreadWelcomeMessageStyled, { ...rest, ref, children: messageProp ?? message });
|
5549
5448
|
});
|
5550
5449
|
ThreadWelcomeMessage.displayName = "ThreadWelcomeMessage";
|
5551
5450
|
var ThreadWelcomeSuggestionContainer = withDefaults("div", {
|
@@ -5557,21 +5456,21 @@ var ThreadWelcomeSuggestionStyled = withDefaults(thread_exports.Suggestion, {
|
|
5557
5456
|
var ThreadWelcomeSuggestion = ({
|
5558
5457
|
suggestion: { text, prompt }
|
5559
5458
|
}) => {
|
5560
|
-
return /* @__PURE__ */
|
5459
|
+
return /* @__PURE__ */ jsx46(
|
5561
5460
|
ThreadWelcomeSuggestionStyled,
|
5562
5461
|
{
|
5563
5462
|
prompt,
|
5564
5463
|
method: "replace",
|
5565
5464
|
autoSend: true,
|
5566
|
-
children: /* @__PURE__ */
|
5465
|
+
children: /* @__PURE__ */ jsx46("span", { className: "aui-thread-welcome-suggestion-text", children: text ?? prompt })
|
5567
5466
|
}
|
5568
5467
|
);
|
5569
5468
|
};
|
5570
5469
|
var ThreadWelcomeSuggestions = () => {
|
5571
5470
|
const { welcome: { suggestions } = {} } = useThreadConfig();
|
5572
|
-
return /* @__PURE__ */
|
5471
|
+
return /* @__PURE__ */ jsx46(ThreadWelcomeSuggestionContainer, { children: suggestions?.map((suggestion, idx) => {
|
5573
5472
|
const key = `${suggestion.prompt}-${idx}`;
|
5574
|
-
return /* @__PURE__ */
|
5473
|
+
return /* @__PURE__ */ jsx46(ThreadWelcomeSuggestion, { suggestion }, key);
|
5575
5474
|
}) });
|
5576
5475
|
};
|
5577
5476
|
ThreadWelcomeSuggestions.displayName = "ThreadWelcomeSuggestions";
|
@@ -5591,7 +5490,7 @@ import { forwardRef as forwardRef29 } from "react";
|
|
5591
5490
|
// src/ui/user-action-bar.tsx
|
5592
5491
|
import { forwardRef as forwardRef28 } from "react";
|
5593
5492
|
import { PencilIcon } from "lucide-react";
|
5594
|
-
import { jsx as
|
5493
|
+
import { jsx as jsx47 } from "react/jsx-runtime";
|
5595
5494
|
var useAllowEdit = (ensureCapability = false) => {
|
5596
5495
|
const { userMessage: { allowEdit = true } = {} } = useThreadConfig();
|
5597
5496
|
const editSupported = useThread((t) => t.capabilities.edit);
|
@@ -5600,7 +5499,7 @@ var useAllowEdit = (ensureCapability = false) => {
|
|
5600
5499
|
var UserActionBar = () => {
|
5601
5500
|
const allowEdit = useAllowEdit(true);
|
5602
5501
|
if (!allowEdit) return null;
|
5603
|
-
return /* @__PURE__ */
|
5502
|
+
return /* @__PURE__ */ jsx47(UserActionBarRoot, { hideWhenRunning: true, autohide: "not-last", children: /* @__PURE__ */ jsx47(UserActionBarEdit, {}) });
|
5604
5503
|
};
|
5605
5504
|
UserActionBar.displayName = "UserActionBar";
|
5606
5505
|
var UserActionBarRoot = withDefaults(actionBar_exports.Root, {
|
@@ -5612,7 +5511,7 @@ var UserActionBarEdit = forwardRef28((props, ref) => {
|
|
5612
5511
|
strings: { userMessage: { edit: { tooltip = "Edit" } = {} } = {} } = {}
|
5613
5512
|
} = useThreadConfig();
|
5614
5513
|
const allowEdit = useAllowEdit();
|
5615
|
-
return /* @__PURE__ */
|
5514
|
+
return /* @__PURE__ */ jsx47(actionBar_exports.Edit, { disabled: !allowEdit, asChild: true, children: /* @__PURE__ */ jsx47(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx47(PencilIcon, {}) }) });
|
5616
5515
|
});
|
5617
5516
|
UserActionBarEdit.displayName = "UserActionBarEdit";
|
5618
5517
|
var exports8 = {
|
@@ -5644,13 +5543,13 @@ var user_message_attachment_default = Object.assign(
|
|
5644
5543
|
);
|
5645
5544
|
|
5646
5545
|
// src/ui/user-message.tsx
|
5647
|
-
import { jsx as
|
5546
|
+
import { jsx as jsx48, jsxs as jsxs12 } from "react/jsx-runtime";
|
5648
5547
|
var UserMessage = () => {
|
5649
5548
|
return /* @__PURE__ */ jsxs12(UserMessageRoot, { children: [
|
5650
|
-
/* @__PURE__ */
|
5651
|
-
/* @__PURE__ */
|
5652
|
-
/* @__PURE__ */
|
5653
|
-
/* @__PURE__ */
|
5549
|
+
/* @__PURE__ */ jsx48(UserMessageAttachments, {}),
|
5550
|
+
/* @__PURE__ */ jsx48(user_action_bar_default, {}),
|
5551
|
+
/* @__PURE__ */ jsx48(UserMessageContent, {}),
|
5552
|
+
/* @__PURE__ */ jsx48(branch_picker_default, {})
|
5654
5553
|
] });
|
5655
5554
|
};
|
5656
5555
|
UserMessage.displayName = "UserMessage";
|
@@ -5663,7 +5562,7 @@ var UserMessageContentWrapper = withDefaults("div", {
|
|
5663
5562
|
});
|
5664
5563
|
var UserMessageContent = forwardRef29(
|
5665
5564
|
({ components, ...props }, ref) => {
|
5666
|
-
return /* @__PURE__ */
|
5565
|
+
return /* @__PURE__ */ jsx48(UserMessageContentWrapper, { ...props, ref, children: /* @__PURE__ */ jsx48(
|
5667
5566
|
message_exports.Content,
|
5668
5567
|
{
|
5669
5568
|
components: {
|
@@ -5681,7 +5580,7 @@ var UserMessageAttachmentsContainer = withDefaults("div", {
|
|
5681
5580
|
var UserMessageAttachments = ({
|
5682
5581
|
components
|
5683
5582
|
}) => {
|
5684
|
-
return /* @__PURE__ */
|
5583
|
+
return /* @__PURE__ */ jsx48(message_exports.If, { hasAttachments: true, children: /* @__PURE__ */ jsx48(UserMessageAttachmentsContainer, { children: /* @__PURE__ */ jsx48(
|
5685
5584
|
message_exports.Attachments,
|
5686
5585
|
{
|
5687
5586
|
components: {
|
@@ -5700,13 +5599,13 @@ var user_message_default = Object.assign(UserMessage, exports10);
|
|
5700
5599
|
|
5701
5600
|
// src/ui/edit-composer.tsx
|
5702
5601
|
import { forwardRef as forwardRef30 } from "react";
|
5703
|
-
import { jsx as
|
5602
|
+
import { jsx as jsx49, jsxs as jsxs13 } from "react/jsx-runtime";
|
5704
5603
|
var EditComposer = () => {
|
5705
5604
|
return /* @__PURE__ */ jsxs13(EditComposerRoot, { children: [
|
5706
|
-
/* @__PURE__ */
|
5605
|
+
/* @__PURE__ */ jsx49(EditComposerInput, {}),
|
5707
5606
|
/* @__PURE__ */ jsxs13(EditComposerFooter, { children: [
|
5708
|
-
/* @__PURE__ */
|
5709
|
-
/* @__PURE__ */
|
5607
|
+
/* @__PURE__ */ jsx49(EditComposerCancel, {}),
|
5608
|
+
/* @__PURE__ */ jsx49(EditComposerSend, {})
|
5710
5609
|
] })
|
5711
5610
|
] });
|
5712
5611
|
};
|
@@ -5730,7 +5629,7 @@ var EditComposerCancel = forwardRef30(
|
|
5730
5629
|
editComposer: { cancel: { label = "Cancel" } = {} } = {}
|
5731
5630
|
} = {}
|
5732
5631
|
} = useThreadConfig();
|
5733
|
-
return /* @__PURE__ */
|
5632
|
+
return /* @__PURE__ */ jsx49(composer_exports.Cancel, { asChild: true, children: /* @__PURE__ */ jsx49(Button, { variant: "ghost", ...props, ref, children: props.children ?? label }) });
|
5734
5633
|
}
|
5735
5634
|
);
|
5736
5635
|
EditComposerCancel.displayName = "EditComposerCancel";
|
@@ -5739,7 +5638,7 @@ var EditComposerSend = forwardRef30(
|
|
5739
5638
|
const {
|
5740
5639
|
strings: { editComposer: { send: { label = "Send" } = {} } = {} } = {}
|
5741
5640
|
} = useThreadConfig();
|
5742
|
-
return /* @__PURE__ */
|
5641
|
+
return /* @__PURE__ */ jsx49(composer_exports.Send, { asChild: true, children: /* @__PURE__ */ jsx49(Button, { ...props, ref, children: props.children ?? label }) });
|
5743
5642
|
}
|
5744
5643
|
);
|
5745
5644
|
EditComposerSend.displayName = "EditComposerSend";
|
@@ -5753,14 +5652,14 @@ var exports11 = {
|
|
5753
5652
|
var edit_composer_default = Object.assign(EditComposer, exports11);
|
5754
5653
|
|
5755
5654
|
// src/ui/thread.tsx
|
5756
|
-
import { jsx as
|
5655
|
+
import { jsx as jsx50, jsxs as jsxs14 } from "react/jsx-runtime";
|
5757
5656
|
var Thread = (config) => {
|
5758
|
-
return /* @__PURE__ */
|
5759
|
-
/* @__PURE__ */
|
5760
|
-
/* @__PURE__ */
|
5657
|
+
return /* @__PURE__ */ jsx50(ThreadRoot, { config, children: /* @__PURE__ */ jsxs14(ThreadViewport, { children: [
|
5658
|
+
/* @__PURE__ */ jsx50(thread_welcome_default, {}),
|
5659
|
+
/* @__PURE__ */ jsx50(ThreadMessages, {}),
|
5761
5660
|
/* @__PURE__ */ jsxs14(ThreadViewportFooter, { children: [
|
5762
|
-
/* @__PURE__ */
|
5763
|
-
/* @__PURE__ */
|
5661
|
+
/* @__PURE__ */ jsx50(ThreadScrollToBottom, {}),
|
5662
|
+
/* @__PURE__ */ jsx50(composer_default, {})
|
5764
5663
|
] })
|
5765
5664
|
] }) });
|
5766
5665
|
};
|
@@ -5769,7 +5668,7 @@ var ThreadRootStyled = withDefaults(thread_exports.Root, {
|
|
5769
5668
|
});
|
5770
5669
|
var ThreadRoot = forwardRef31(
|
5771
5670
|
({ config, ...props }, ref) => {
|
5772
|
-
return /* @__PURE__ */
|
5671
|
+
return /* @__PURE__ */ jsx50(ThreadConfigProvider, { config, children: /* @__PURE__ */ jsx50(ThreadRootStyled, { ...props, ref }) });
|
5773
5672
|
}
|
5774
5673
|
);
|
5775
5674
|
ThreadRoot.displayName = "ThreadRoot";
|
@@ -5783,7 +5682,7 @@ var ThreadViewportFooter = withDefaults("div", {
|
|
5783
5682
|
ThreadViewportFooter.displayName = "ThreadViewportFooter";
|
5784
5683
|
var SystemMessage = () => null;
|
5785
5684
|
var ThreadMessages = ({ components, ...rest }) => {
|
5786
|
-
return /* @__PURE__ */
|
5685
|
+
return /* @__PURE__ */ jsx50(
|
5787
5686
|
thread_exports.Messages,
|
5788
5687
|
{
|
5789
5688
|
components: {
|
@@ -5807,7 +5706,7 @@ var ThreadScrollToBottom = forwardRef31((props, ref) => {
|
|
5807
5706
|
thread: { scrollToBottom: { tooltip = "Scroll to bottom" } = {} } = {}
|
5808
5707
|
} = {}
|
5809
5708
|
} = useThreadConfig();
|
5810
|
-
return /* @__PURE__ */
|
5709
|
+
return /* @__PURE__ */ jsx50(thread_exports.ScrollToBottom, { asChild: true, children: /* @__PURE__ */ jsx50(ThreadScrollToBottomIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx50(ArrowDownIcon, {}) }) });
|
5811
5710
|
});
|
5812
5711
|
ThreadScrollToBottom.displayName = "ThreadScrollToBottom";
|
5813
5712
|
var exports12 = {
|
@@ -5820,20 +5719,20 @@ var exports12 = {
|
|
5820
5719
|
var thread_default = Object.assign(Thread, exports12);
|
5821
5720
|
|
5822
5721
|
// src/ui/assistant-modal.tsx
|
5823
|
-
import { Fragment as Fragment6, jsx as
|
5722
|
+
import { Fragment as Fragment6, jsx as jsx51, jsxs as jsxs15 } from "react/jsx-runtime";
|
5824
5723
|
var AssistantModal = (config) => {
|
5825
5724
|
return /* @__PURE__ */ jsxs15(AssistantModalRoot, { config, children: [
|
5826
|
-
/* @__PURE__ */
|
5827
|
-
/* @__PURE__ */
|
5725
|
+
/* @__PURE__ */ jsx51(AssistantModalTrigger, {}),
|
5726
|
+
/* @__PURE__ */ jsx51(AssistantModalContent, { children: /* @__PURE__ */ jsx51(thread_default, {}) })
|
5828
5727
|
] });
|
5829
5728
|
};
|
5830
5729
|
AssistantModal.displayName = "AssistantModal";
|
5831
5730
|
var AssistantModalRoot = ({ config, ...props }) => {
|
5832
|
-
return /* @__PURE__ */
|
5731
|
+
return /* @__PURE__ */ jsx51(ThreadConfigProvider, { config, children: /* @__PURE__ */ jsx51(assistantModal_exports.Root, { ...props }) });
|
5833
5732
|
};
|
5834
5733
|
AssistantModalRoot.displayName = "AssistantModalRoot";
|
5835
5734
|
var AssistantModalTrigger = forwardRef32((props, ref) => {
|
5836
|
-
return /* @__PURE__ */
|
5735
|
+
return /* @__PURE__ */ jsx51(AssistantModalAnchor, { children: /* @__PURE__ */ jsx51(assistantModal_exports.Trigger, { asChild: true, children: /* @__PURE__ */ jsx51(AssistantModalButton, { ...props, ref }) }) });
|
5837
5736
|
});
|
5838
5737
|
AssistantModalTrigger.displayName = "AssistantModalTrigger";
|
5839
5738
|
var AssistantModalAnchor = withDefaults(assistantModal_exports.Anchor, {
|
@@ -5858,7 +5757,7 @@ var AssistantModalButton = forwardRef32(({ "data-state": state, ...rest }, ref)
|
|
5858
5757
|
} = {}
|
5859
5758
|
} = useThreadConfig();
|
5860
5759
|
const tooltip = state === "open" ? openTooltip : closedTooltip;
|
5861
|
-
return /* @__PURE__ */
|
5760
|
+
return /* @__PURE__ */ jsx51(
|
5862
5761
|
ModalButtonStyled,
|
5863
5762
|
{
|
5864
5763
|
side: "left",
|
@@ -5867,14 +5766,14 @@ var AssistantModalButton = forwardRef32(({ "data-state": state, ...rest }, ref)
|
|
5867
5766
|
...rest,
|
5868
5767
|
ref,
|
5869
5768
|
children: rest.children ?? /* @__PURE__ */ jsxs15(Fragment6, { children: [
|
5870
|
-
/* @__PURE__ */
|
5769
|
+
/* @__PURE__ */ jsx51(
|
5871
5770
|
BotIcon,
|
5872
5771
|
{
|
5873
5772
|
"data-state": state,
|
5874
5773
|
className: "aui-modal-button-closed-icon"
|
5875
5774
|
}
|
5876
5775
|
),
|
5877
|
-
/* @__PURE__ */
|
5776
|
+
/* @__PURE__ */ jsx51(
|
5878
5777
|
ChevronDownIcon,
|
5879
5778
|
{
|
5880
5779
|
"data-state": state,
|
@@ -5985,6 +5884,7 @@ export {
|
|
5985
5884
|
useMessage,
|
5986
5885
|
useMessageContext,
|
5987
5886
|
useMessageIf,
|
5887
|
+
useMessageRuntime,
|
5988
5888
|
useMessageStore,
|
5989
5889
|
useMessageUtils,
|
5990
5890
|
useMessageUtilsStore,
|