@superinterface/react 2.0.1 → 2.0.2
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.cjs +1852 -1776
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +125 -97
- package/dist/index.d.ts +125 -97
- package/dist/index.js +1794 -1710
- package/dist/index.js.map +1 -1
- package/dist/mutationFns.cjs +22 -22
- package/dist/mutationFns.cjs.map +1 -1
- package/dist/mutationFns.d.cts +4 -4
- package/dist/mutationFns.d.ts +4 -4
- package/dist/mutationFns.js +19 -19
- package/dist/mutationFns.js.map +1 -1
- package/dist/queryFns.cjs +50 -50
- package/dist/queryFns.cjs.map +1 -1
- package/dist/queryFns.d.cts +3 -3
- package/dist/queryFns.d.ts +3 -3
- package/dist/queryFns.js +46 -46
- package/dist/queryFns.js.map +1 -1
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.cts +6 -6
- package/dist/types/index.d.ts +6 -6
- package/dist/utils.cjs +13 -13
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +4 -4
- package/dist/utils.d.ts +4 -4
- package/dist/utils.js +11 -11
- package/dist/utils.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -317,169 +317,9 @@ var SuperinterfaceProvider = function(param) {
|
|
|
317
317
|
children: children
|
|
318
318
|
});
|
|
319
319
|
};
|
|
320
|
-
// src/components/threads/Thread/index.tsx
|
|
321
|
-
import { Flex as
|
|
322
|
-
// src/
|
|
323
|
-
import { Flex as Flex12 } from "@radix-ui/themes";
|
|
324
|
-
// src/hooks/misc/useInfiniteScroll/index.tsx
|
|
325
|
-
import { useRef as useRef2 } from "react";
|
|
326
|
-
import { useInView } from "react-intersection-observer";
|
|
327
|
-
// src/hooks/misc/useThrottledEffect/index.tsx
|
|
328
|
-
import _3 from "lodash";
|
|
329
|
-
import { useRef, useEffect, useCallback } from "react";
|
|
330
|
-
var useThrottledEffect = function(cb, delay, additionalDeps) {
|
|
331
|
-
var _cbRef;
|
|
332
|
-
var cbRef = useRef(cb);
|
|
333
|
-
var throttledCb = useCallback(_3.throttle(function() {
|
|
334
|
-
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
335
|
-
args[_key] = arguments[_key];
|
|
336
|
-
}
|
|
337
|
-
return (_cbRef = cbRef).current.apply(_cbRef, _to_consumable_array(args));
|
|
338
|
-
}, delay, {
|
|
339
|
-
leading: true,
|
|
340
|
-
trailing: true
|
|
341
|
-
}), [
|
|
342
|
-
delay
|
|
343
|
-
]);
|
|
344
|
-
useEffect(function() {
|
|
345
|
-
cbRef.current = cb;
|
|
346
|
-
});
|
|
347
|
-
useEffect(throttledCb, [
|
|
348
|
-
throttledCb
|
|
349
|
-
].concat(_to_consumable_array(additionalDeps)));
|
|
350
|
-
};
|
|
351
|
-
// src/hooks/misc/useInfiniteScroll/index.tsx
|
|
352
|
-
var useInfiniteScroll = function(param) {
|
|
353
|
-
var isFetchingNextPage = param.isFetchingNextPage, hasNextPage = param.hasNextPage, fetchNextPage = param.fetchNextPage;
|
|
354
|
-
var containerRef = useRef2(null);
|
|
355
|
-
var _useInView = useInView({
|
|
356
|
-
root: containerRef.current,
|
|
357
|
-
rootMargin: "0px",
|
|
358
|
-
threshold: 0.1
|
|
359
|
-
}), loaderRef = _useInView.ref, inView = _useInView.inView;
|
|
360
|
-
useThrottledEffect(function() {
|
|
361
|
-
if (isFetchingNextPage) return;
|
|
362
|
-
if (!inView) return;
|
|
363
|
-
if (!hasNextPage) return;
|
|
364
|
-
console.log("Fetching next page");
|
|
365
|
-
fetchNextPage();
|
|
366
|
-
}, 500, [
|
|
367
|
-
inView,
|
|
368
|
-
isFetchingNextPage,
|
|
369
|
-
hasNextPage,
|
|
370
|
-
fetchNextPage
|
|
371
|
-
]);
|
|
372
|
-
return {
|
|
373
|
-
containerRef: containerRef,
|
|
374
|
-
loaderRef: loaderRef,
|
|
375
|
-
inView: inView
|
|
376
|
-
};
|
|
377
|
-
};
|
|
378
|
-
// src/components/skeletons/ThreadMessagesSkeleton/index.tsx
|
|
379
|
-
import { forwardRef as forwardRef2 } from "react";
|
|
380
|
-
import { Flex as Flex4, Avatar, Box } from "@radix-ui/themes";
|
|
381
|
-
// src/components/skeletons/Skeleton/index.tsx
|
|
382
|
-
import { Flex } from "@radix-ui/themes";
|
|
383
|
-
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
384
|
-
var Skeleton = function(_param) {
|
|
385
|
-
var height = _param.height, style = _param.style, rest = _object_without_properties(_param, [
|
|
386
|
-
"height",
|
|
387
|
-
"style"
|
|
388
|
-
]);
|
|
389
|
-
return(// @ts-ignore-next-line
|
|
390
|
-
/* @__PURE__ */ jsx2(Flex, _object_spread({
|
|
391
|
-
style: _object_spread({
|
|
392
|
-
animation: "pulse 2s cubic-bezier(.4,0,.6,1) infinite",
|
|
393
|
-
borderRadius: "var(--radius-3)",
|
|
394
|
-
backgroundColor: "var(--gray-5)",
|
|
395
|
-
height: "var(--space-".concat(height, ")")
|
|
396
|
-
}, style)
|
|
397
|
-
}, rest)));
|
|
398
|
-
};
|
|
399
|
-
// src/components/threadMessageGroups/ThreadMessagesGroupBase/index.tsx
|
|
400
|
-
import { forwardRef } from "react";
|
|
401
|
-
import { Flex as Flex2, Container } from "@radix-ui/themes";
|
|
402
|
-
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
403
|
-
var ThreadMessagesGroupBase = forwardRef(function ThreadMessagesGroupBase2(param, ref) {
|
|
404
|
-
var children = param.children;
|
|
405
|
-
return /* @__PURE__ */ jsx3(Container, {
|
|
406
|
-
ref: ref,
|
|
407
|
-
size: "2",
|
|
408
|
-
grow: "0",
|
|
409
|
-
children: /* @__PURE__ */ jsx3(Flex2, {
|
|
410
|
-
shrink: "0",
|
|
411
|
-
gap: "3",
|
|
412
|
-
children: children
|
|
413
|
-
})
|
|
414
|
-
});
|
|
415
|
-
});
|
|
416
|
-
// src/components/threadMessageGroups/ThreadMessagesGroupBase/Name.tsx
|
|
417
|
-
import { Flex as Flex3, Text } from "@radix-ui/themes";
|
|
418
|
-
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
419
|
-
var Name = function(param) {
|
|
420
|
-
var children = param.children;
|
|
421
|
-
return /* @__PURE__ */ jsx4(Flex3, {
|
|
422
|
-
align: "center",
|
|
423
|
-
style: {
|
|
424
|
-
height: "var(--space-5)"
|
|
425
|
-
},
|
|
426
|
-
children: /* @__PURE__ */ jsx4(Text, {
|
|
427
|
-
size: "2",
|
|
428
|
-
weight: "bold",
|
|
429
|
-
children: children
|
|
430
|
-
})
|
|
431
|
-
});
|
|
432
|
-
};
|
|
433
|
-
// src/components/skeletons/ThreadMessagesSkeleton/index.tsx
|
|
434
|
-
import { jsx as jsx5, jsxs } from "react/jsx-runtime";
|
|
435
|
-
var ThreadMessagesSkeleton = forwardRef2(function ThreadMessagesSkeleton2(_props, ref) {
|
|
436
|
-
return /* @__PURE__ */ jsxs(ThreadMessagesGroupBase, {
|
|
437
|
-
ref: ref,
|
|
438
|
-
children: [
|
|
439
|
-
/* @__PURE__ */ jsx5(Avatar, {
|
|
440
|
-
fallback: /* @__PURE__ */ jsx5(Flex4, {}),
|
|
441
|
-
size: "1",
|
|
442
|
-
style: {
|
|
443
|
-
animation: "pulse 2s cubic-bezier(.4,0,.6,1) infinite"
|
|
444
|
-
}
|
|
445
|
-
}),
|
|
446
|
-
/* @__PURE__ */ jsxs(Box, {
|
|
447
|
-
pb: "3",
|
|
448
|
-
children: [
|
|
449
|
-
/* @__PURE__ */ jsx5(Name, {
|
|
450
|
-
children: /* @__PURE__ */ jsx5(Skeleton, {
|
|
451
|
-
height: "1",
|
|
452
|
-
style: {
|
|
453
|
-
width: "128px"
|
|
454
|
-
}
|
|
455
|
-
})
|
|
456
|
-
}),
|
|
457
|
-
/* @__PURE__ */ jsx5(Skeleton, {
|
|
458
|
-
height: "2",
|
|
459
|
-
style: {
|
|
460
|
-
width: "256px"
|
|
461
|
-
}
|
|
462
|
-
}),
|
|
463
|
-
/* @__PURE__ */ jsx5(Skeleton, {
|
|
464
|
-
height: "2",
|
|
465
|
-
style: {
|
|
466
|
-
width: "256px",
|
|
467
|
-
marginTop: "var(--space-2)"
|
|
468
|
-
}
|
|
469
|
-
}),
|
|
470
|
-
/* @__PURE__ */ jsx5(Skeleton, {
|
|
471
|
-
height: "2",
|
|
472
|
-
style: {
|
|
473
|
-
width: "256px",
|
|
474
|
-
marginTop: "var(--space-2)"
|
|
475
|
-
}
|
|
476
|
-
})
|
|
477
|
-
]
|
|
478
|
-
})
|
|
479
|
-
]
|
|
480
|
-
});
|
|
481
|
-
});
|
|
482
|
-
// src/hooks/threadMessages/useThreadMessages/index.tsx
|
|
320
|
+
// src/components/threads/Thread/Messages/index.tsx
|
|
321
|
+
import { Flex as Flex13 } from "@radix-ui/themes";
|
|
322
|
+
// src/hooks/messages/useMessages/index.tsx
|
|
483
323
|
import { useMemo } from "react";
|
|
484
324
|
import { useInfiniteQuery, useQueryClient as useQueryClient2 } from "@tanstack/react-query";
|
|
485
325
|
// src/lib/threads/queryOptions/index.ts
|
|
@@ -502,9 +342,13 @@ var queryOptions = function(param) {
|
|
|
502
342
|
} : {}, variables));
|
|
503
343
|
return [
|
|
504
344
|
2,
|
|
505
|
-
fetch("".concat(superinterfaceContext.baseUrl).concat(path, "?").concat(params), {
|
|
345
|
+
fetch("".concat(superinterfaceContext.baseUrl).concat(path, "?").concat(params), _object_spread({
|
|
506
346
|
credentials: "include"
|
|
507
|
-
}
|
|
347
|
+
}, superinterfaceContext.publicApiKey ? {
|
|
348
|
+
headers: {
|
|
349
|
+
Authorization: "Bearer ".concat(superinterfaceContext.publicApiKey)
|
|
350
|
+
}
|
|
351
|
+
} : {})).then(function() {
|
|
508
352
|
var _ref = _async_to_generator(function(response) {
|
|
509
353
|
var errorResponse, error;
|
|
510
354
|
return _ts_generator(this, function(_state) {
|
|
@@ -561,23 +405,23 @@ var queryOptions = function(param) {
|
|
|
561
405
|
queryKey: queryKey
|
|
562
406
|
}), threadContext.defaultOptions.queries));
|
|
563
407
|
};
|
|
564
|
-
// src/hooks/
|
|
565
|
-
var
|
|
408
|
+
// src/hooks/messages/useMessages/index.tsx
|
|
409
|
+
var messages = function(param) {
|
|
566
410
|
var props = param.props;
|
|
567
411
|
if (!props.data) return [];
|
|
568
412
|
return props.data.pages.reduce(function(acc, page) {
|
|
569
413
|
return acc.concat(page.data);
|
|
570
414
|
}, []);
|
|
571
415
|
};
|
|
572
|
-
var
|
|
416
|
+
var useMessages = function() {
|
|
573
417
|
var queryClient = useQueryClient2();
|
|
574
418
|
var threadContext = useSuperinterfaceContext();
|
|
575
419
|
var superinterfaceContext = useSuperinterfaceContext();
|
|
576
420
|
var props = useInfiniteQuery(queryOptions({
|
|
577
421
|
queryKeyBase: [
|
|
578
|
-
"
|
|
422
|
+
"messages"
|
|
579
423
|
],
|
|
580
|
-
path: "/
|
|
424
|
+
path: "/messages",
|
|
581
425
|
queryClient: queryClient,
|
|
582
426
|
threadContext: threadContext,
|
|
583
427
|
superinterfaceContext: superinterfaceContext
|
|
@@ -585,7 +429,7 @@ var useThreadMessages = function() {
|
|
|
585
429
|
return useMemo(function() {
|
|
586
430
|
return _object_spread_props(_object_spread({}, props), {
|
|
587
431
|
// @ts-ignore-next-line
|
|
588
|
-
|
|
432
|
+
messages: messages({
|
|
589
433
|
props: props
|
|
590
434
|
})
|
|
591
435
|
});
|
|
@@ -593,1354 +437,1562 @@ var useThreadMessages = function() {
|
|
|
593
437
|
props
|
|
594
438
|
]);
|
|
595
439
|
};
|
|
596
|
-
// src/hooks/
|
|
597
|
-
import { useQueryClient as useQueryClient5 } from "@tanstack/react-query";
|
|
598
|
-
import { useEffect as useEffect2 } from "react";
|
|
599
|
-
// src/hooks/threadMessages/useLatestThreadMessage/index.ts
|
|
440
|
+
// src/hooks/messageGroups/useMessageGroups/index.ts
|
|
600
441
|
import { useMemo as useMemo2 } from "react";
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
442
|
+
// src/hooks/messageGroups/useMessageGroups/lib/messageGroups/index.ts
|
|
443
|
+
import _3 from "lodash";
|
|
444
|
+
import { last } from "radash";
|
|
445
|
+
// src/lib/messages/order.ts
|
|
446
|
+
import { sort } from "radash";
|
|
447
|
+
var order = function(param) {
|
|
448
|
+
var messages2 = param.messages;
|
|
449
|
+
return sort(messages2, function(m) {
|
|
450
|
+
return m.created_at;
|
|
451
|
+
}, true);
|
|
452
|
+
};
|
|
453
|
+
// src/hooks/messageGroups/useMessageGroups/lib/messageGroups/newGroup/newGroupItem.ts
|
|
454
|
+
var newGroupItem = function(param) {
|
|
455
|
+
var message = param.message;
|
|
456
|
+
return {
|
|
457
|
+
id: message.id,
|
|
458
|
+
role: message.role,
|
|
459
|
+
createdAt: message.created_at,
|
|
460
|
+
messages: [
|
|
461
|
+
message
|
|
462
|
+
]
|
|
463
|
+
};
|
|
464
|
+
};
|
|
465
|
+
// src/hooks/messageGroups/useMessageGroups/lib/messageGroups/newGroup/index.ts
|
|
466
|
+
var newGroup = function(param) {
|
|
467
|
+
var groups = param.groups, message = param.message;
|
|
468
|
+
return _to_consumable_array(groups).concat([
|
|
469
|
+
newGroupItem({
|
|
470
|
+
message: message
|
|
471
|
+
})
|
|
609
472
|
]);
|
|
610
473
|
};
|
|
611
|
-
// src/hooks/
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
var
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
474
|
+
// src/hooks/messageGroups/useMessageGroups/lib/messageGroups/index.ts
|
|
475
|
+
var messageGroups = function(param) {
|
|
476
|
+
var messages2 = param.messages;
|
|
477
|
+
return _3.reduce(order({
|
|
478
|
+
messages: messages2
|
|
479
|
+
}), function(groups, message) {
|
|
480
|
+
var group = last(groups);
|
|
481
|
+
if (!group) return newGroup({
|
|
482
|
+
groups: groups,
|
|
483
|
+
message: message
|
|
484
|
+
});
|
|
485
|
+
if (group.role !== message.role) {
|
|
486
|
+
return newGroup({
|
|
487
|
+
groups: groups,
|
|
488
|
+
message: message
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
return _to_consumable_array(_3.dropRight(groups)).concat([
|
|
492
|
+
_object_spread_props(_object_spread({}, group), {
|
|
493
|
+
messages: _to_consumable_array(group.messages).concat([
|
|
494
|
+
message
|
|
495
|
+
])
|
|
496
|
+
})
|
|
497
|
+
]);
|
|
622
498
|
}, []);
|
|
623
499
|
};
|
|
624
|
-
// src/hooks/
|
|
625
|
-
var
|
|
626
|
-
var
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
"runs"
|
|
632
|
-
],
|
|
633
|
-
path: "/runs",
|
|
634
|
-
queryClient: queryClient,
|
|
635
|
-
threadContext: threadContext,
|
|
636
|
-
superinterfaceContext: superinterfaceContext
|
|
637
|
-
}));
|
|
638
|
-
return useMemo3(function() {
|
|
639
|
-
return _object_spread_props(_object_spread({}, props), {
|
|
640
|
-
// @ts-ignore-next-line
|
|
641
|
-
runs: getRuns({
|
|
642
|
-
data: props.data
|
|
500
|
+
// src/hooks/messageGroups/useMessageGroups/index.ts
|
|
501
|
+
var useMessageGroups = function(param) {
|
|
502
|
+
var messages2 = param.messages;
|
|
503
|
+
return useMemo2(function() {
|
|
504
|
+
return {
|
|
505
|
+
messageGroups: messageGroups({
|
|
506
|
+
messages: messages2
|
|
643
507
|
})
|
|
644
|
-
}
|
|
508
|
+
};
|
|
645
509
|
}, [
|
|
646
|
-
|
|
510
|
+
messages2
|
|
647
511
|
]);
|
|
648
512
|
};
|
|
649
|
-
// src/
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
513
|
+
// src/components/skeletons/MessagesSkeleton/index.tsx
|
|
514
|
+
import { forwardRef as forwardRef2 } from "react";
|
|
515
|
+
import { Flex as Flex4, Avatar, Box } from "@radix-ui/themes";
|
|
516
|
+
// src/components/skeletons/Skeleton/index.tsx
|
|
517
|
+
import { Flex } from "@radix-ui/themes";
|
|
518
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
519
|
+
var Skeleton = function(_param) {
|
|
520
|
+
var height = _param.height, style = _param.style, rest = _object_without_properties(_param, [
|
|
521
|
+
"height",
|
|
522
|
+
"style"
|
|
658
523
|
]);
|
|
524
|
+
return /* @__PURE__ */ jsx2(Flex, _object_spread({
|
|
525
|
+
height: "var(--space-".concat(height, ")"),
|
|
526
|
+
style: _object_spread({
|
|
527
|
+
animation: "pulse 2s cubic-bezier(.4,0,.6,1) infinite",
|
|
528
|
+
borderRadius: "var(--radius-3)",
|
|
529
|
+
backgroundColor: "var(--gray-5)"
|
|
530
|
+
}, style)
|
|
531
|
+
}, rest));
|
|
659
532
|
};
|
|
660
|
-
// src/
|
|
661
|
-
import {
|
|
662
|
-
import {
|
|
663
|
-
|
|
664
|
-
var
|
|
665
|
-
var
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
4
|
|
692
|
-
]);
|
|
693
|
-
return [
|
|
694
|
-
4,
|
|
695
|
-
response.json()
|
|
696
|
-
];
|
|
697
|
-
case 2:
|
|
698
|
-
errorResponse = _state.sent();
|
|
699
|
-
throw new Error(errorResponse.error);
|
|
700
|
-
case 3:
|
|
701
|
-
error = _state.sent();
|
|
702
|
-
throw new Error("Failed to fetch");
|
|
703
|
-
case 4:
|
|
704
|
-
return [
|
|
705
|
-
2,
|
|
706
|
-
response.json()
|
|
707
|
-
];
|
|
708
|
-
}
|
|
709
|
-
});
|
|
710
|
-
});
|
|
711
|
-
return function(response) {
|
|
712
|
-
return _ref.apply(this, arguments);
|
|
713
|
-
};
|
|
714
|
-
}());
|
|
715
|
-
}
|
|
716
|
-
}, queryClient.getMutationDefaults(mutationKey)), {
|
|
717
|
-
mutationKey: mutationKey
|
|
718
|
-
}), threadContext.defaultOptions.mutations);
|
|
533
|
+
// src/components/messageGroups/MessageGroupBase/index.tsx
|
|
534
|
+
import { forwardRef } from "react";
|
|
535
|
+
import { Flex as Flex2, Container } from "@radix-ui/themes";
|
|
536
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
537
|
+
var MessageGroupBase = forwardRef(function MessageGroupBase2(param, ref) {
|
|
538
|
+
var children = param.children;
|
|
539
|
+
return /* @__PURE__ */ jsx3(Container, {
|
|
540
|
+
ref: ref,
|
|
541
|
+
size: "2",
|
|
542
|
+
flexGrow: "0",
|
|
543
|
+
children: /* @__PURE__ */ jsx3(Flex2, {
|
|
544
|
+
flexShrink: "0",
|
|
545
|
+
gap: "3",
|
|
546
|
+
children: children
|
|
547
|
+
})
|
|
548
|
+
});
|
|
549
|
+
});
|
|
550
|
+
// src/components/messageGroups/MessageGroupBase/Name.tsx
|
|
551
|
+
import { Flex as Flex3, Text } from "@radix-ui/themes";
|
|
552
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
553
|
+
var Name = function(param) {
|
|
554
|
+
var children = param.children;
|
|
555
|
+
return /* @__PURE__ */ jsx4(Flex3, {
|
|
556
|
+
align: "center",
|
|
557
|
+
height: "var(--space-5)",
|
|
558
|
+
children: /* @__PURE__ */ jsx4(Text, {
|
|
559
|
+
size: "2",
|
|
560
|
+
weight: "bold",
|
|
561
|
+
children: children
|
|
562
|
+
})
|
|
563
|
+
});
|
|
719
564
|
};
|
|
720
|
-
// src/
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
return
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
565
|
+
// src/components/skeletons/MessagesSkeleton/index.tsx
|
|
566
|
+
import { jsx as jsx5, jsxs } from "react/jsx-runtime";
|
|
567
|
+
var MessagesSkeleton = forwardRef2(function MessagesSkeleton2(_props, ref) {
|
|
568
|
+
return /* @__PURE__ */ jsxs(MessageGroupBase, {
|
|
569
|
+
ref: ref,
|
|
570
|
+
children: [
|
|
571
|
+
/* @__PURE__ */ jsx5(Avatar, {
|
|
572
|
+
fallback: /* @__PURE__ */ jsx5(Flex4, {}),
|
|
573
|
+
size: "1",
|
|
574
|
+
style: {
|
|
575
|
+
animation: "pulse 2s cubic-bezier(.4,0,.6,1) infinite"
|
|
576
|
+
}
|
|
577
|
+
}),
|
|
578
|
+
/* @__PURE__ */ jsxs(Box, {
|
|
579
|
+
pb: "3",
|
|
580
|
+
children: [
|
|
581
|
+
/* @__PURE__ */ jsx5(Name, {
|
|
582
|
+
children: /* @__PURE__ */ jsx5(Skeleton, {
|
|
583
|
+
height: "1",
|
|
584
|
+
style: {
|
|
585
|
+
width: "128px"
|
|
586
|
+
}
|
|
587
|
+
})
|
|
588
|
+
}),
|
|
589
|
+
/* @__PURE__ */ jsx5(Skeleton, {
|
|
590
|
+
height: "2",
|
|
591
|
+
style: {
|
|
592
|
+
width: "256px"
|
|
593
|
+
}
|
|
594
|
+
}),
|
|
595
|
+
/* @__PURE__ */ jsx5(Skeleton, {
|
|
596
|
+
height: "2",
|
|
597
|
+
style: {
|
|
598
|
+
width: "256px",
|
|
599
|
+
marginTop: "var(--space-2)"
|
|
600
|
+
}
|
|
601
|
+
}),
|
|
602
|
+
/* @__PURE__ */ jsx5(Skeleton, {
|
|
603
|
+
height: "2",
|
|
604
|
+
style: {
|
|
605
|
+
width: "256px",
|
|
606
|
+
marginTop: "var(--space-2)"
|
|
745
607
|
}
|
|
746
|
-
var _prevData_pages = _to_array(prevData.pages), latestPage = _prevData_pages[0], pagesRest = _prevData_pages.slice(1);
|
|
747
|
-
return _object_spread_props(_object_spread({}, prevData), {
|
|
748
|
-
pages: [
|
|
749
|
-
_object_spread_props(_object_spread({}, latestPage), {
|
|
750
|
-
data: [
|
|
751
|
-
data3.run
|
|
752
|
-
].concat(_to_consumable_array(latestPage.data))
|
|
753
|
-
})
|
|
754
|
-
].concat(_to_consumable_array(pagesRest))
|
|
755
|
-
});
|
|
756
608
|
})
|
|
757
|
-
]
|
|
758
|
-
});
|
|
759
|
-
});
|
|
760
|
-
return function(data3, variables) {
|
|
761
|
-
return _ref.apply(this, arguments);
|
|
762
|
-
};
|
|
763
|
-
}();
|
|
764
|
-
};
|
|
765
|
-
// src/hooks/runs/useCreateRun/lib/onSettled.ts
|
|
766
|
-
var onSettled = function(param) {
|
|
767
|
-
var queryClient = param.queryClient;
|
|
768
|
-
return function() {
|
|
769
|
-
var _ref = _async_to_generator(function(_data, _error, variables) {
|
|
770
|
-
return _ts_generator(this, function(_state) {
|
|
771
|
-
switch(_state.label){
|
|
772
|
-
case 0:
|
|
773
|
-
return [
|
|
774
|
-
4,
|
|
775
|
-
queryClient.invalidateQueries({
|
|
776
|
-
queryKey: [
|
|
777
|
-
"threadMessages",
|
|
778
|
-
variables
|
|
779
|
-
]
|
|
780
|
-
})
|
|
781
|
-
];
|
|
782
|
-
case 1:
|
|
783
|
-
_state.sent();
|
|
784
|
-
return [
|
|
785
|
-
4,
|
|
786
|
-
queryClient.invalidateQueries({
|
|
787
|
-
queryKey: [
|
|
788
|
-
"runs",
|
|
789
|
-
variables
|
|
790
|
-
]
|
|
791
|
-
})
|
|
792
|
-
];
|
|
793
|
-
case 2:
|
|
794
|
-
_state.sent();
|
|
795
|
-
return [
|
|
796
|
-
2
|
|
797
|
-
];
|
|
798
|
-
}
|
|
799
|
-
});
|
|
800
|
-
});
|
|
801
|
-
return function(_data, _error, variables) {
|
|
802
|
-
return _ref.apply(this, arguments);
|
|
803
|
-
};
|
|
804
|
-
}();
|
|
805
|
-
};
|
|
806
|
-
// src/lib/optimistic/optimisticId.ts
|
|
807
|
-
import { uid } from "radash";
|
|
808
|
-
var optimisticId = function() {
|
|
809
|
-
return "-".concat(uid(24));
|
|
810
|
-
};
|
|
811
|
-
// src/hooks/runs/useCreateRun/lib/onMutate/data.ts
|
|
812
|
-
var data = function(prevData) {
|
|
813
|
-
var run = {
|
|
814
|
-
id: optimisticId(),
|
|
815
|
-
object: "thread.run",
|
|
816
|
-
created_at: +/* @__PURE__ */ new Date(),
|
|
817
|
-
assistant_id: null,
|
|
818
|
-
thread_id: null,
|
|
819
|
-
status: "in_progress",
|
|
820
|
-
expires_at: +/* @__PURE__ */ new Date() + 1e3 * 60 * 60 * 24,
|
|
821
|
-
cancelled_at: null,
|
|
822
|
-
failed_at: null,
|
|
823
|
-
completed_at: null,
|
|
824
|
-
required_action: null,
|
|
825
|
-
last_error: null,
|
|
826
|
-
model: null,
|
|
827
|
-
instructions: null,
|
|
828
|
-
tools: [],
|
|
829
|
-
file_ids: [],
|
|
830
|
-
metadata: {},
|
|
831
|
-
usage: null
|
|
832
|
-
};
|
|
833
|
-
if (!prevData) {
|
|
834
|
-
return {
|
|
835
|
-
pageParams: [],
|
|
836
|
-
pages: [
|
|
837
|
-
{
|
|
838
|
-
data: [
|
|
839
|
-
run
|
|
840
|
-
],
|
|
841
|
-
hasNextPage: false,
|
|
842
|
-
lastId: run.id
|
|
843
|
-
}
|
|
844
|
-
]
|
|
845
|
-
};
|
|
846
|
-
}
|
|
847
|
-
var _prevData_pages = _to_array(prevData.pages), latestPage = _prevData_pages[0], pagesRest = _prevData_pages.slice(1);
|
|
848
|
-
return _object_spread_props(_object_spread({}, prevData), {
|
|
849
|
-
pages: [
|
|
850
|
-
_object_spread_props(_object_spread({}, latestPage), {
|
|
851
|
-
data: [
|
|
852
|
-
run
|
|
853
|
-
].concat(_to_consumable_array(latestPage.data))
|
|
609
|
+
]
|
|
854
610
|
})
|
|
855
|
-
]
|
|
611
|
+
]
|
|
612
|
+
});
|
|
613
|
+
});
|
|
614
|
+
// src/components/threads/Thread/Messages/Content/MessageGroup/index.tsx
|
|
615
|
+
import { useContext as useContext5 } from "react";
|
|
616
|
+
import { Box as Box8, Avatar as Avatar3 } from "@radix-ui/themes";
|
|
617
|
+
import { PersonIcon } from "@radix-ui/react-icons";
|
|
618
|
+
// src/components/messageGroups/MessageGroupBase/AssistantAvatar.tsx
|
|
619
|
+
import { useContext as useContext2 } from "react";
|
|
620
|
+
import { Flex as Flex5 } from "@radix-ui/themes";
|
|
621
|
+
// src/contexts/assistants/AssistantAvatarContext/index.tsx
|
|
622
|
+
import { createContext as createContext2 } from "react";
|
|
623
|
+
import { Avatar as Avatar2 } from "@radix-ui/themes";
|
|
624
|
+
import { LightningBoltIcon } from "@radix-ui/react-icons";
|
|
625
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
626
|
+
var AssistantAvatarContext = createContext2(/* @__PURE__ */ jsx6(Avatar2, {
|
|
627
|
+
fallback: /* @__PURE__ */ jsx6(LightningBoltIcon, {}),
|
|
628
|
+
size: "1"
|
|
629
|
+
}));
|
|
630
|
+
// src/components/messageGroups/MessageGroupBase/AssistantAvatar.tsx
|
|
631
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
632
|
+
var AssistantAvatar = function() {
|
|
633
|
+
var AssistantAvatarContextValue = useContext2(AssistantAvatarContext);
|
|
634
|
+
return /* @__PURE__ */ jsx7(Flex5, {
|
|
635
|
+
flexShrink: "0",
|
|
636
|
+
height: "24px",
|
|
637
|
+
width: "24px",
|
|
638
|
+
style: {
|
|
639
|
+
borderRadius: "var(--radius-3)",
|
|
640
|
+
overflow: "hidden"
|
|
641
|
+
},
|
|
642
|
+
children: AssistantAvatarContextValue
|
|
856
643
|
});
|
|
857
644
|
};
|
|
858
|
-
// src/
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
var useCreateRun = function() {
|
|
898
|
-
var queryClient = useQueryClient4();
|
|
899
|
-
var superinterfaceContext = useSuperinterfaceContext();
|
|
900
|
-
var threadContext = useSuperinterfaceContext();
|
|
901
|
-
var props = useMutation(_object_spread({
|
|
902
|
-
onSuccess: onSuccess({
|
|
903
|
-
queryClient: queryClient
|
|
904
|
-
}),
|
|
905
|
-
onSettled: onSettled({
|
|
906
|
-
queryClient: queryClient
|
|
907
|
-
}),
|
|
908
|
-
onMutate: onMutate({
|
|
909
|
-
queryClient: queryClient
|
|
645
|
+
// src/contexts/assistants/AssistantNameContext/index.tsx
|
|
646
|
+
import { createContext as createContext3 } from "react";
|
|
647
|
+
var AssistantNameContext = createContext3("Assistant");
|
|
648
|
+
// src/components/threads/Thread/Messages/Content/MessageGroup/Content/index.tsx
|
|
649
|
+
import { Flex as Flex11 } from "@radix-ui/themes";
|
|
650
|
+
// src/components/threads/Thread/Message/index.tsx
|
|
651
|
+
import { useMemo as useMemo4 } from "react";
|
|
652
|
+
import { Box as Box7 } from "@radix-ui/themes";
|
|
653
|
+
// src/components/runSteps/RunSteps/index.tsx
|
|
654
|
+
import { Flex as Flex10 } from "@radix-ui/themes";
|
|
655
|
+
// src/components/runSteps/RunStep/ToolCalls/index.tsx
|
|
656
|
+
import { Flex as Flex9 } from "@radix-ui/themes";
|
|
657
|
+
// src/components/runSteps/RunStep/ToolCalls/ToolCall/index.tsx
|
|
658
|
+
import { Flex as Flex8 } from "@radix-ui/themes";
|
|
659
|
+
// src/components/runSteps/RunStep/ToolCalls/ToolCall/Fn/index.tsx
|
|
660
|
+
import { useContext as useContext3 } from "react";
|
|
661
|
+
// src/contexts/functions/FunctionComponentsContext/index.tsx
|
|
662
|
+
import { createContext as createContext4 } from "react";
|
|
663
|
+
var FunctionComponentsContext = createContext4({});
|
|
664
|
+
// src/components/functions/FunctionBase/index.tsx
|
|
665
|
+
import { PopoverRoot, PopoverContent } from "@radix-ui/themes";
|
|
666
|
+
// src/components/toolCalls/ToolCallBase/index.tsx
|
|
667
|
+
import { Flex as Flex6, Button, PopoverTrigger } from "@radix-ui/themes";
|
|
668
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
669
|
+
var ToolCallBase = function(param) {
|
|
670
|
+
var children = param.children;
|
|
671
|
+
return /* @__PURE__ */ jsx8(Flex6, {
|
|
672
|
+
py: "1",
|
|
673
|
+
ml: "-2",
|
|
674
|
+
children: /* @__PURE__ */ jsx8(PopoverTrigger, {
|
|
675
|
+
children: /* @__PURE__ */ jsx8(Button, {
|
|
676
|
+
size: "1",
|
|
677
|
+
color: "gold",
|
|
678
|
+
variant: "outline",
|
|
679
|
+
style: {
|
|
680
|
+
boxShadow: "none"
|
|
681
|
+
},
|
|
682
|
+
children: children
|
|
683
|
+
})
|
|
910
684
|
})
|
|
911
|
-
}, mutationOptions({
|
|
912
|
-
mutationKeyBase: [
|
|
913
|
-
"createRun"
|
|
914
|
-
],
|
|
915
|
-
path: "/runs",
|
|
916
|
-
queryClient: queryClient,
|
|
917
|
-
threadContext: threadContext,
|
|
918
|
-
superinterfaceContext: superinterfaceContext
|
|
919
|
-
})));
|
|
920
|
-
return _object_spread_props(_object_spread({}, props), {
|
|
921
|
-
createRun: partob(props.mutate, threadContext.variables)
|
|
922
685
|
});
|
|
923
686
|
};
|
|
924
|
-
// src/
|
|
925
|
-
import
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
687
|
+
// src/components/toolCalls/ToolCallBase/ToolCallTitle.tsx
|
|
688
|
+
import { Text as Text2 } from "@radix-ui/themes";
|
|
689
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
690
|
+
var ToolCallTitle = function(param) {
|
|
691
|
+
var children = param.children;
|
|
692
|
+
return /* @__PURE__ */ jsx9(Text2, {
|
|
693
|
+
weight: "regular",
|
|
694
|
+
children: children
|
|
695
|
+
});
|
|
929
696
|
};
|
|
930
|
-
// src/
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
var
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
697
|
+
// src/components/functions/FunctionBase/Icon.tsx
|
|
698
|
+
import { CircleIcon, CircleBackslashIcon, CheckCircledIcon } from "@radix-ui/react-icons";
|
|
699
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
700
|
+
var Icon = function(param) {
|
|
701
|
+
var runStep = param.runStep;
|
|
702
|
+
if (runStep.completed_at) {
|
|
703
|
+
return /* @__PURE__ */ jsx10(CheckCircledIcon, {});
|
|
704
|
+
} else if (runStep.cancelled_at || runStep.failed_at || runStep.status === "expired") {
|
|
705
|
+
return /* @__PURE__ */ jsx10(CircleBackslashIcon, {});
|
|
706
|
+
} else {
|
|
707
|
+
return /* @__PURE__ */ jsx10(CircleIcon, {});
|
|
708
|
+
}
|
|
709
|
+
};
|
|
710
|
+
// src/components/functions/FunctionBase/Content.tsx
|
|
711
|
+
import { useMemo as useMemo3 } from "react";
|
|
712
|
+
import { Code, Box as Box2 } from "@radix-ui/themes";
|
|
713
|
+
import { jsx as jsx11, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
714
|
+
var Content = function(param) {
|
|
715
|
+
var fn = param.fn;
|
|
716
|
+
var args = useMemo3(function() {
|
|
717
|
+
var result = null;
|
|
718
|
+
try {
|
|
719
|
+
result = JSON.parse(fn.arguments);
|
|
720
|
+
} catch (error) {
|
|
721
|
+
console.error(error);
|
|
948
722
|
}
|
|
949
|
-
|
|
950
|
-
mutationKey: [
|
|
951
|
-
"createRun",
|
|
952
|
-
threadContext.variables
|
|
953
|
-
]
|
|
954
|
-
});
|
|
955
|
-
if (isMutating) return;
|
|
956
|
-
createRunProps.createRun();
|
|
723
|
+
return result;
|
|
957
724
|
}, [
|
|
958
|
-
|
|
959
|
-
queryClient,
|
|
960
|
-
createRunProps,
|
|
961
|
-
latestRunProps,
|
|
962
|
-
latestThreadMessageProps
|
|
725
|
+
fn
|
|
963
726
|
]);
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
if (!
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
"failed"
|
|
996
|
-
];
|
|
997
|
-
var isRunActive = function(param) {
|
|
998
|
-
var latestRunProps = param.latestRunProps, latestThreadMessageProps = param.latestThreadMessageProps, isMutating = param.isMutating;
|
|
999
|
-
var _latestThreadMessageProps_latestThreadMessage_metadata, _latestThreadMessageProps_latestThreadMessage;
|
|
1000
|
-
if ((_latestThreadMessageProps_latestThreadMessage = latestThreadMessageProps.latestThreadMessage) === null || _latestThreadMessageProps_latestThreadMessage === void 0 ? void 0 : (_latestThreadMessageProps_latestThreadMessage_metadata = _latestThreadMessageProps_latestThreadMessage.metadata) === null || _latestThreadMessageProps_latestThreadMessage_metadata === void 0 ? void 0 : _latestThreadMessageProps_latestThreadMessage_metadata.isBlocking) return false;
|
|
1001
|
-
if (isMutating) return true;
|
|
1002
|
-
if (!latestRunProps.latestRun) return false;
|
|
1003
|
-
if (progressStatuses.includes(latestRunProps.latestRun.status)) return true;
|
|
1004
|
-
if (stoppedStatuses.includes(latestRunProps.latestRun.status)) return false;
|
|
1005
|
-
return isRunEditingThreadMessage({
|
|
1006
|
-
threadMessage: latestThreadMessageProps.latestThreadMessage
|
|
1007
|
-
});
|
|
1008
|
-
};
|
|
1009
|
-
var useIsRunActive = function() {
|
|
1010
|
-
var latestRunProps = useLatestRun();
|
|
1011
|
-
var latestThreadMessageProps = useLatestThreadMessage();
|
|
1012
|
-
var threadContext = useSuperinterfaceContext();
|
|
1013
|
-
var isMutatingCreateRun = useIsMutating({
|
|
1014
|
-
mutationKey: [
|
|
1015
|
-
"createRun",
|
|
1016
|
-
threadContext.variables
|
|
1017
|
-
]
|
|
1018
|
-
});
|
|
1019
|
-
var isMutatingCreateThreadMessage = useIsMutating({
|
|
1020
|
-
mutationKey: [
|
|
1021
|
-
"createThreadMessage",
|
|
1022
|
-
threadContext.variables
|
|
727
|
+
var output = useMemo3(function() {
|
|
728
|
+
if (!fn.output) {
|
|
729
|
+
return null;
|
|
730
|
+
}
|
|
731
|
+
var result = null;
|
|
732
|
+
try {
|
|
733
|
+
result = JSON.parse(fn.output);
|
|
734
|
+
} catch (error) {
|
|
735
|
+
console.error(error);
|
|
736
|
+
}
|
|
737
|
+
return result;
|
|
738
|
+
}, [
|
|
739
|
+
fn
|
|
740
|
+
]);
|
|
741
|
+
if (!args) {
|
|
742
|
+
return null;
|
|
743
|
+
}
|
|
744
|
+
return /* @__PURE__ */ jsxs2(Code, {
|
|
745
|
+
variant: "ghost",
|
|
746
|
+
color: "gold",
|
|
747
|
+
style: {
|
|
748
|
+
whiteSpace: "pre",
|
|
749
|
+
wordBreak: "break-word"
|
|
750
|
+
},
|
|
751
|
+
children: [
|
|
752
|
+
/* @__PURE__ */ jsx11(Box2, {
|
|
753
|
+
children: args && JSON.stringify(args, null, 2)
|
|
754
|
+
}),
|
|
755
|
+
/* @__PURE__ */ jsx11(Box2, {
|
|
756
|
+
children: output && JSON.stringify(output, null, 2)
|
|
757
|
+
})
|
|
1023
758
|
]
|
|
1024
759
|
});
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
760
|
+
};
|
|
761
|
+
// src/components/functions/FunctionBase/index.tsx
|
|
762
|
+
import { jsx as jsx12, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
763
|
+
var FunctionBase = function(param) {
|
|
764
|
+
var fn = param.fn, runStep = param.runStep, title2 = param.title;
|
|
765
|
+
return /* @__PURE__ */ jsxs3(PopoverRoot, {
|
|
766
|
+
children: [
|
|
767
|
+
/* @__PURE__ */ jsxs3(ToolCallBase, {
|
|
768
|
+
children: [
|
|
769
|
+
/* @__PURE__ */ jsx12(Icon, {
|
|
770
|
+
runStep: runStep
|
|
771
|
+
}),
|
|
772
|
+
/* @__PURE__ */ jsx12(ToolCallTitle, {
|
|
773
|
+
children: title2
|
|
774
|
+
})
|
|
775
|
+
]
|
|
776
|
+
}),
|
|
777
|
+
/* @__PURE__ */ jsx12(PopoverContent, {
|
|
778
|
+
style: {
|
|
779
|
+
maxHeight: "500px"
|
|
780
|
+
},
|
|
781
|
+
children: /* @__PURE__ */ jsx12(Content, {
|
|
782
|
+
fn: fn
|
|
783
|
+
})
|
|
784
|
+
})
|
|
1029
785
|
]
|
|
1030
786
|
});
|
|
1031
|
-
return useMemo5(function() {
|
|
1032
|
-
return _object_spread_props(_object_spread({}, latestRunProps), {
|
|
1033
|
-
isRunActive: isRunActive({
|
|
1034
|
-
latestRunProps: latestRunProps,
|
|
1035
|
-
latestThreadMessageProps: latestThreadMessageProps,
|
|
1036
|
-
isMutating: isMutatingCreateRun > 0 || isMutatingCreateThreadMessage > 0 || isMutatingCreateHandleAction > 0
|
|
1037
|
-
})
|
|
1038
|
-
});
|
|
1039
|
-
}, [
|
|
1040
|
-
latestRunProps,
|
|
1041
|
-
latestThreadMessageProps,
|
|
1042
|
-
isMutatingCreateRun,
|
|
1043
|
-
isMutatingCreateThreadMessage,
|
|
1044
|
-
isMutatingCreateHandleAction
|
|
1045
|
-
]);
|
|
1046
787
|
};
|
|
1047
|
-
// src/
|
|
1048
|
-
var
|
|
1049
|
-
var
|
|
1050
|
-
|
|
1051
|
-
return
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
queryKey: (_threadContext_defaultOptions_queries_queryKey1 = threadContext.defaultOptions.queries.queryKey) !== null && _threadContext_defaultOptions_queries_queryKey1 !== void 0 ? _threadContext_defaultOptions_queries_queryKey1 : [
|
|
1070
|
-
"runs",
|
|
1071
|
-
threadContext.variables
|
|
1072
|
-
]
|
|
1073
|
-
})
|
|
1074
|
-
];
|
|
1075
|
-
case 2:
|
|
1076
|
-
_state.sent();
|
|
1077
|
-
return [
|
|
1078
|
-
2
|
|
1079
|
-
];
|
|
1080
|
-
}
|
|
1081
|
-
});
|
|
788
|
+
// src/components/runSteps/RunStep/ToolCalls/ToolCall/Fn/DefaultFunction/lib/title.ts
|
|
789
|
+
var title = function(param) {
|
|
790
|
+
var fn = param.fn, runStep = param.runStep;
|
|
791
|
+
if (runStep.completed_at) {
|
|
792
|
+
return "Finished ".concat(fn.name);
|
|
793
|
+
} else if (runStep.cancelled_at) {
|
|
794
|
+
return "Cancelled ".concat(fn.name);
|
|
795
|
+
} else {
|
|
796
|
+
return "Calling ".concat(fn.name);
|
|
797
|
+
}
|
|
798
|
+
};
|
|
799
|
+
// src/components/runSteps/RunStep/ToolCalls/ToolCall/Fn/DefaultFunction/index.tsx
|
|
800
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
801
|
+
var DefaultFunction = function(param) {
|
|
802
|
+
var fn = param.fn, runStep = param.runStep;
|
|
803
|
+
return /* @__PURE__ */ jsx13(FunctionBase, {
|
|
804
|
+
fn: fn,
|
|
805
|
+
runStep: runStep,
|
|
806
|
+
title: title({
|
|
807
|
+
runStep: runStep,
|
|
808
|
+
fn: fn
|
|
809
|
+
})
|
|
1082
810
|
});
|
|
1083
|
-
return function refetch(_) {
|
|
1084
|
-
return _ref.apply(this, arguments);
|
|
1085
|
-
};
|
|
1086
|
-
}();
|
|
1087
|
-
// src/hooks/runs/usePolling/index.tsx
|
|
1088
|
-
var usePolling = function() {
|
|
1089
|
-
var threadContext = useSuperinterfaceContext();
|
|
1090
|
-
var queryClient = useQueryClient6();
|
|
1091
|
-
var isRunActiveProps = useIsRunActive();
|
|
1092
|
-
useInterval(function() {
|
|
1093
|
-
refetch({
|
|
1094
|
-
queryClient: queryClient,
|
|
1095
|
-
threadContext: threadContext
|
|
1096
|
-
});
|
|
1097
|
-
console.log("poll refetched");
|
|
1098
|
-
}, isRunActiveProps.isRunActive ? 3e3 : null);
|
|
1099
|
-
return null;
|
|
1100
811
|
};
|
|
1101
|
-
// src/
|
|
1102
|
-
import {
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
//
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
return _ts_generator(this, function(_state) {
|
|
1113
|
-
switch(_state.label){
|
|
1114
|
-
case 0:
|
|
1115
|
-
return [
|
|
1116
|
-
4,
|
|
1117
|
-
queryClient.invalidateQueries({
|
|
1118
|
-
queryKey: [
|
|
1119
|
-
"threadMessages",
|
|
1120
|
-
variables
|
|
1121
|
-
]
|
|
1122
|
-
})
|
|
1123
|
-
];
|
|
1124
|
-
case 1:
|
|
1125
|
-
_state.sent();
|
|
1126
|
-
return [
|
|
1127
|
-
4,
|
|
1128
|
-
queryClient.invalidateQueries({
|
|
1129
|
-
queryKey: [
|
|
1130
|
-
"runs",
|
|
1131
|
-
variables
|
|
1132
|
-
]
|
|
1133
|
-
})
|
|
1134
|
-
];
|
|
1135
|
-
case 2:
|
|
1136
|
-
_state.sent();
|
|
1137
|
-
return [
|
|
1138
|
-
2
|
|
1139
|
-
];
|
|
1140
|
-
}
|
|
1141
|
-
});
|
|
1142
|
-
});
|
|
1143
|
-
return function(_data, _error, variables) {
|
|
1144
|
-
return _ref.apply(this, arguments);
|
|
1145
|
-
};
|
|
1146
|
-
}();
|
|
812
|
+
// src/components/runSteps/RunStep/ToolCalls/ToolCall/Fn/index.tsx
|
|
813
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
814
|
+
var Fn = function(param) {
|
|
815
|
+
var fn = param.fn, runStep = param.runStep;
|
|
816
|
+
var functionComponentsContext = useContext3(FunctionComponentsContext);
|
|
817
|
+
var Component = functionComponentsContext[fn.name] || DefaultFunction;
|
|
818
|
+
return(// @ts-ignore-next-line
|
|
819
|
+
/* @__PURE__ */ jsx14(Component, {
|
|
820
|
+
fn: fn,
|
|
821
|
+
runStep: runStep
|
|
822
|
+
}));
|
|
1147
823
|
};
|
|
1148
|
-
// src/
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
var
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
queryClient: queryClient
|
|
1156
|
-
})
|
|
1157
|
-
}, mutationOptions({
|
|
1158
|
-
mutationKeyBase: [
|
|
1159
|
-
"handleAction"
|
|
1160
|
-
],
|
|
1161
|
-
path: "/actions",
|
|
1162
|
-
queryClient: queryClient,
|
|
1163
|
-
threadContext: threadContext,
|
|
1164
|
-
superinterfaceContext: superinterfaceContext
|
|
1165
|
-
})));
|
|
1166
|
-
return _object_spread_props(_object_spread({}, props), {
|
|
1167
|
-
handleAction: partob2(props.mutate, threadContext.variables)
|
|
824
|
+
// src/components/runSteps/RunStep/ToolCalls/ToolCall/CodeInterpreter/index.tsx
|
|
825
|
+
import { Flex as Flex7 } from "@radix-ui/themes";
|
|
826
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
827
|
+
var CodeInterpreter = function(param) {
|
|
828
|
+
var codeInterpreter = param.codeInterpreter;
|
|
829
|
+
return /* @__PURE__ */ jsx15(Flex7, {
|
|
830
|
+
children: codeInterpreter.input
|
|
1168
831
|
});
|
|
1169
832
|
};
|
|
1170
|
-
// src/
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
var
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
if (latestRunProps.isFetching) return;
|
|
1179
|
-
if (!latestRunProps.latestRun) return;
|
|
1180
|
-
if (latestRunProps.latestRun.status !== "requires_action") return;
|
|
1181
|
-
var isMutating = queryClient.isMutating({
|
|
1182
|
-
mutationKey: [
|
|
1183
|
-
"handleAction",
|
|
1184
|
-
threadContext.variables
|
|
1185
|
-
]
|
|
1186
|
-
});
|
|
1187
|
-
if (isMutating) return;
|
|
1188
|
-
console.log("requires action", {
|
|
1189
|
-
latestRunProps: latestRunProps
|
|
833
|
+
// src/components/runSteps/RunStep/ToolCalls/ToolCall/index.tsx
|
|
834
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
835
|
+
var ToolCall = function(param) {
|
|
836
|
+
var toolCall = param.toolCall, runStep = param.runStep;
|
|
837
|
+
if (toolCall.type === "function") {
|
|
838
|
+
return /* @__PURE__ */ jsx16(Fn, {
|
|
839
|
+
fn: toolCall.function,
|
|
840
|
+
runStep: runStep
|
|
1190
841
|
});
|
|
1191
|
-
|
|
1192
|
-
|
|
842
|
+
}
|
|
843
|
+
if (toolCall.type === "code_interpreter") {
|
|
844
|
+
return /* @__PURE__ */ jsx16(CodeInterpreter, {
|
|
845
|
+
codeInterpreter: toolCall.code_interpreter,
|
|
846
|
+
runStep: runStep
|
|
1193
847
|
});
|
|
1194
|
-
}
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
848
|
+
}
|
|
849
|
+
return /* @__PURE__ */ jsx16(Flex8, {
|
|
850
|
+
children: toolCall.type
|
|
851
|
+
});
|
|
852
|
+
};
|
|
853
|
+
// src/components/runSteps/RunStep/ToolCalls/Starting/index.tsx
|
|
854
|
+
import { PopoverRoot as PopoverRoot2, PopoverContent as PopoverContent2, Text as Text3 } from "@radix-ui/themes";
|
|
855
|
+
import { CircleIcon as CircleIcon2 } from "@radix-ui/react-icons";
|
|
856
|
+
import { jsx as jsx17, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
857
|
+
var Starting = function() {
|
|
858
|
+
return /* @__PURE__ */ jsxs4(PopoverRoot2, {
|
|
859
|
+
children: [
|
|
860
|
+
/* @__PURE__ */ jsxs4(ToolCallBase, {
|
|
861
|
+
children: [
|
|
862
|
+
/* @__PURE__ */ jsx17(CircleIcon2, {}),
|
|
863
|
+
/* @__PURE__ */ jsx17(ToolCallTitle, {
|
|
864
|
+
children: "Starting actions"
|
|
865
|
+
})
|
|
866
|
+
]
|
|
867
|
+
}),
|
|
868
|
+
/* @__PURE__ */ jsx17(PopoverContent2, {
|
|
869
|
+
style: {
|
|
870
|
+
maxHeight: "500px"
|
|
871
|
+
},
|
|
872
|
+
children: /* @__PURE__ */ jsx17(Text3, {
|
|
873
|
+
children: "Getting ready to connect to domain API"
|
|
874
|
+
})
|
|
875
|
+
})
|
|
876
|
+
]
|
|
877
|
+
});
|
|
878
|
+
};
|
|
879
|
+
// src/components/runSteps/RunStep/ToolCalls/index.tsx
|
|
880
|
+
import { jsx as jsx18, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
881
|
+
var ToolCalls = function(param) {
|
|
882
|
+
var stepDetails = param.stepDetails, runStep = param.runStep;
|
|
883
|
+
return /* @__PURE__ */ jsxs5(Flex9, {
|
|
884
|
+
direction: "column",
|
|
885
|
+
children: [
|
|
886
|
+
!stepDetails.tool_calls.length && /* @__PURE__ */ jsx18(Starting, {}),
|
|
887
|
+
stepDetails.tool_calls.map(function(toolCall) {
|
|
888
|
+
return /* @__PURE__ */ jsx18(ToolCall, {
|
|
889
|
+
toolCall: toolCall,
|
|
890
|
+
runStep: runStep
|
|
891
|
+
}, toolCall.id);
|
|
892
|
+
})
|
|
893
|
+
]
|
|
894
|
+
});
|
|
1199
895
|
};
|
|
1200
|
-
// src/
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
896
|
+
// src/components/runSteps/RunStep/index.tsx
|
|
897
|
+
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
898
|
+
var RunStep = function(param) {
|
|
899
|
+
var runStep = param.runStep;
|
|
900
|
+
if (runStep.step_details.type === "tool_calls") {
|
|
901
|
+
return /* @__PURE__ */ jsx19(ToolCalls, {
|
|
902
|
+
stepDetails: runStep.step_details,
|
|
903
|
+
runStep: runStep
|
|
904
|
+
});
|
|
905
|
+
}
|
|
1205
906
|
return null;
|
|
1206
907
|
};
|
|
1207
|
-
// src/
|
|
1208
|
-
import {
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
}
|
|
1219
|
-
};
|
|
1220
|
-
// src/hooks/threadMessageGroups/useThreadMessageGroups/lib/threadMessageGroups/newGroup/newGroupItem.ts
|
|
1221
|
-
var newGroupItem = function(param) {
|
|
1222
|
-
var threadMessage = param.threadMessage;
|
|
1223
|
-
return {
|
|
1224
|
-
id: threadMessage.id,
|
|
1225
|
-
role: threadMessage.role,
|
|
1226
|
-
createdAt: threadMessage.created_at,
|
|
1227
|
-
threadMessages: [
|
|
1228
|
-
threadMessage
|
|
1229
|
-
]
|
|
1230
|
-
};
|
|
908
|
+
// src/components/runSteps/RunSteps/index.tsx
|
|
909
|
+
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
910
|
+
var RunSteps = function(param) {
|
|
911
|
+
var runSteps = param.runSteps;
|
|
912
|
+
return /* @__PURE__ */ jsx20(Flex10, {
|
|
913
|
+
direction: "column-reverse",
|
|
914
|
+
children: runSteps.map(function(runStep) {
|
|
915
|
+
return /* @__PURE__ */ jsx20(RunStep, {
|
|
916
|
+
runStep: runStep
|
|
917
|
+
}, runStep.id);
|
|
918
|
+
})
|
|
919
|
+
});
|
|
1231
920
|
};
|
|
1232
|
-
// src/
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
921
|
+
// src/components/threads/Thread/Message/TextContent/index.tsx
|
|
922
|
+
import { useContext as useContext4 } from "react";
|
|
923
|
+
import { useRemarkSync } from "react-remark";
|
|
924
|
+
// src/contexts/markdown/MarkdownContext/index.ts
|
|
925
|
+
import { createContext as createContext5 } from "react";
|
|
926
|
+
// src/contexts/markdown/MarkdownContext/lib/components/Paragraph.tsx
|
|
927
|
+
import { Box as Box3, Text as Text4 } from "@radix-ui/themes";
|
|
928
|
+
import { jsx as jsx21 } from "react/jsx-runtime";
|
|
929
|
+
var Paragraph = function(param) {
|
|
930
|
+
var children = param.children;
|
|
931
|
+
return /* @__PURE__ */ jsx21(Box3, {
|
|
932
|
+
pb: "3",
|
|
933
|
+
children: /* @__PURE__ */ jsx21(Text4, {
|
|
934
|
+
size: "3",
|
|
935
|
+
style: {
|
|
936
|
+
whiteSpace: "pre-line",
|
|
937
|
+
wordBreak: "break-word"
|
|
938
|
+
},
|
|
939
|
+
children: children
|
|
1238
940
|
})
|
|
1239
|
-
|
|
941
|
+
});
|
|
1240
942
|
};
|
|
1241
|
-
// src/
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
threadMessage: threadMessage
|
|
1251
|
-
});
|
|
1252
|
-
if (group.role !== threadMessage.role) {
|
|
1253
|
-
return newGroup({
|
|
1254
|
-
groups: groups,
|
|
1255
|
-
threadMessage: threadMessage
|
|
1256
|
-
});
|
|
1257
|
-
}
|
|
1258
|
-
return _to_consumable_array(_6.dropRight(groups)).concat([
|
|
1259
|
-
_object_spread_props(_object_spread({}, group), {
|
|
1260
|
-
threadMessages: _to_consumable_array(group.threadMessages).concat([
|
|
1261
|
-
threadMessage
|
|
1262
|
-
])
|
|
1263
|
-
})
|
|
1264
|
-
]);
|
|
1265
|
-
}, []);
|
|
943
|
+
// src/contexts/markdown/MarkdownContext/lib/components/Link.tsx
|
|
944
|
+
import { Link as RadixLink } from "@radix-ui/themes";
|
|
945
|
+
import { jsx as jsx22 } from "react/jsx-runtime";
|
|
946
|
+
var Link = function(param) {
|
|
947
|
+
var children = param.children, href = param.href;
|
|
948
|
+
return /* @__PURE__ */ jsx22(RadixLink, {
|
|
949
|
+
href: href,
|
|
950
|
+
children: children
|
|
951
|
+
});
|
|
1266
952
|
};
|
|
1267
|
-
// src/
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
953
|
+
// src/contexts/markdown/MarkdownContext/lib/components/UnorderedList.tsx
|
|
954
|
+
import { Box as Box4 } from "@radix-ui/themes";
|
|
955
|
+
import { jsx as jsx23 } from "react/jsx-runtime";
|
|
956
|
+
var UnorderedList = function(param) {
|
|
957
|
+
var children = param.children;
|
|
958
|
+
return /* @__PURE__ */ jsx23(Box4, {
|
|
959
|
+
pb: "3",
|
|
960
|
+
asChild: true,
|
|
961
|
+
children: /* @__PURE__ */ jsx23("ul", {
|
|
962
|
+
style: {
|
|
963
|
+
listStylePosition: "inside"
|
|
964
|
+
},
|
|
965
|
+
children: children
|
|
966
|
+
})
|
|
967
|
+
});
|
|
1279
968
|
};
|
|
1280
|
-
// src/
|
|
1281
|
-
import {
|
|
1282
|
-
import {
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
size: "1"
|
|
1295
|
-
}));
|
|
1296
|
-
// src/components/threadMessageGroups/ThreadMessagesGroupBase/AssistantAvatar.tsx
|
|
1297
|
-
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
1298
|
-
var AssistantAvatar = function() {
|
|
1299
|
-
var AssistantAvatarContextValue = useContext2(AssistantAvatarContext);
|
|
1300
|
-
return /* @__PURE__ */ jsx7(Flex5, {
|
|
1301
|
-
shrink: "0",
|
|
1302
|
-
style: {
|
|
1303
|
-
borderRadius: "var(--radius-3)",
|
|
1304
|
-
overflow: "hidden",
|
|
1305
|
-
height: "24px",
|
|
1306
|
-
width: "24px"
|
|
1307
|
-
},
|
|
1308
|
-
children: AssistantAvatarContextValue
|
|
969
|
+
// src/contexts/markdown/MarkdownContext/lib/components/OrderedList.tsx
|
|
970
|
+
import { Box as Box5 } from "@radix-ui/themes";
|
|
971
|
+
import { jsx as jsx24 } from "react/jsx-runtime";
|
|
972
|
+
var OrderedList = function(param) {
|
|
973
|
+
var children = param.children;
|
|
974
|
+
return /* @__PURE__ */ jsx24(Box5, {
|
|
975
|
+
pb: "3",
|
|
976
|
+
asChild: true,
|
|
977
|
+
children: /* @__PURE__ */ jsx24("ol", {
|
|
978
|
+
style: {
|
|
979
|
+
listStylePosition: "inside"
|
|
980
|
+
},
|
|
981
|
+
children: children
|
|
982
|
+
})
|
|
1309
983
|
});
|
|
1310
984
|
};
|
|
1311
|
-
// src/contexts/
|
|
1312
|
-
import {
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
import { Flex as Flex11 } from "@radix-ui/themes";
|
|
1316
|
-
// src/components/ThreadMessages/ThreadMessage/index.tsx
|
|
1317
|
-
import { useMemo as useMemo8 } from "react";
|
|
1318
|
-
import { Box as Box7 } from "@radix-ui/themes";
|
|
1319
|
-
// src/components/runSteps/RunSteps/index.tsx
|
|
1320
|
-
import { Flex as Flex10 } from "@radix-ui/themes";
|
|
1321
|
-
// src/components/runSteps/RunStep/ToolCalls/index.tsx
|
|
1322
|
-
import { Flex as Flex9 } from "@radix-ui/themes";
|
|
1323
|
-
// src/components/runSteps/RunStep/ToolCalls/ToolCall/index.tsx
|
|
1324
|
-
import { Flex as Flex8 } from "@radix-ui/themes";
|
|
1325
|
-
// src/components/runSteps/RunStep/ToolCalls/ToolCall/Fn/index.tsx
|
|
1326
|
-
import { useContext as useContext3 } from "react";
|
|
1327
|
-
// src/contexts/functions/FunctionComponentsContext/index.tsx
|
|
1328
|
-
import { createContext as createContext4 } from "react";
|
|
1329
|
-
var FunctionComponentsContext = createContext4({});
|
|
1330
|
-
// src/components/functions/FunctionBase/index.tsx
|
|
1331
|
-
import { PopoverRoot, PopoverContent } from "@radix-ui/themes";
|
|
1332
|
-
// src/components/toolCalls/ToolCallBase/index.tsx
|
|
1333
|
-
import { Flex as Flex6, Button, PopoverTrigger } from "@radix-ui/themes";
|
|
1334
|
-
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
1335
|
-
var ToolCallBase = function(param) {
|
|
985
|
+
// src/contexts/markdown/MarkdownContext/lib/components/ListItem.tsx
|
|
986
|
+
import { Box as Box6 } from "@radix-ui/themes";
|
|
987
|
+
import { jsx as jsx25 } from "react/jsx-runtime";
|
|
988
|
+
var ListItem = function(param) {
|
|
1336
989
|
var children = param.children;
|
|
1337
|
-
return /* @__PURE__ */
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
children: /* @__PURE__ */ jsx8(Button, {
|
|
1342
|
-
size: "1",
|
|
1343
|
-
color: "gold",
|
|
1344
|
-
variant: "outline",
|
|
1345
|
-
style: {
|
|
1346
|
-
boxShadow: "none"
|
|
1347
|
-
},
|
|
1348
|
-
children: children
|
|
1349
|
-
})
|
|
990
|
+
return /* @__PURE__ */ jsx25(Box6, {
|
|
991
|
+
pb: "1",
|
|
992
|
+
children: /* @__PURE__ */ jsx25("li", {
|
|
993
|
+
children: children
|
|
1350
994
|
})
|
|
1351
995
|
});
|
|
1352
996
|
};
|
|
1353
|
-
// src/
|
|
1354
|
-
import {
|
|
1355
|
-
import { jsx as
|
|
1356
|
-
var
|
|
997
|
+
// src/contexts/markdown/MarkdownContext/lib/components/Strong.tsx
|
|
998
|
+
import { Strong as RadixStrong } from "@radix-ui/themes";
|
|
999
|
+
import { jsx as jsx26 } from "react/jsx-runtime";
|
|
1000
|
+
var Strong = function(param) {
|
|
1357
1001
|
var children = param.children;
|
|
1358
|
-
return /* @__PURE__ */
|
|
1359
|
-
weight: "regular",
|
|
1002
|
+
return /* @__PURE__ */ jsx26(RadixStrong, {
|
|
1360
1003
|
children: children
|
|
1361
1004
|
});
|
|
1362
1005
|
};
|
|
1363
|
-
// src/
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1006
|
+
// src/contexts/markdown/MarkdownContext/lib/components/index.tsx
|
|
1007
|
+
var components = {
|
|
1008
|
+
p: Paragraph,
|
|
1009
|
+
a: Link,
|
|
1010
|
+
strong: Strong,
|
|
1011
|
+
ul: UnorderedList,
|
|
1012
|
+
ol: OrderedList,
|
|
1013
|
+
li: ListItem
|
|
1014
|
+
};
|
|
1015
|
+
// src/contexts/markdown/MarkdownContext/index.ts
|
|
1016
|
+
var MarkdownContext = createContext5({
|
|
1017
|
+
remarkPlugins: [],
|
|
1018
|
+
rehypeReactOptions: {
|
|
1019
|
+
components: components
|
|
1374
1020
|
}
|
|
1021
|
+
});
|
|
1022
|
+
// src/components/threads/Thread/Message/TextContent/index.tsx
|
|
1023
|
+
var TextContent = function(param) {
|
|
1024
|
+
var content = param.content;
|
|
1025
|
+
var markdownContext = useContext4(MarkdownContext);
|
|
1026
|
+
return useRemarkSync(content.text.value, markdownContext);
|
|
1375
1027
|
};
|
|
1376
|
-
// src/components/
|
|
1377
|
-
import {
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
var
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
}
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
if (!fn.output) {
|
|
1395
|
-
return null;
|
|
1028
|
+
// src/components/threads/Thread/Message/index.tsx
|
|
1029
|
+
import { jsx as jsx27, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1030
|
+
var Message = function(param) {
|
|
1031
|
+
var message = param.message;
|
|
1032
|
+
var _useMemo4 = _sliced_to_array(useMemo4(function() {
|
|
1033
|
+
if (!message.runSteps.length) return [
|
|
1034
|
+
[],
|
|
1035
|
+
[]
|
|
1036
|
+
];
|
|
1037
|
+
var messageCreationRunStepIndex = message.runSteps.findIndex(function(runStep) {
|
|
1038
|
+
if (runStep.step_details.type !== "message_creation") return;
|
|
1039
|
+
return runStep.step_details.message_creation.message_id === message.id;
|
|
1040
|
+
});
|
|
1041
|
+
var nextRunStepIndex = message.runSteps.slice(0, messageCreationRunStepIndex).findLastIndex(function(runStep) {
|
|
1042
|
+
return runStep.step_details.type === "message_creation";
|
|
1043
|
+
});
|
|
1044
|
+
if (nextRunStepIndex === -1) {
|
|
1045
|
+
nextRunStepIndex = 0;
|
|
1396
1046
|
}
|
|
1397
|
-
var
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
}
|
|
1401
|
-
|
|
1047
|
+
var laterRunSteps2 = message.runSteps.slice(nextRunStepIndex, messageCreationRunStepIndex);
|
|
1048
|
+
var prevRunStepIndex = message.runSteps.slice(messageCreationRunStepIndex + 1).findIndex(function(runStep) {
|
|
1049
|
+
return runStep.step_details.type === "message_creation";
|
|
1050
|
+
});
|
|
1051
|
+
var olderRunSteps2;
|
|
1052
|
+
if (prevRunStepIndex === -1) {
|
|
1053
|
+
olderRunSteps2 = message.runSteps.slice(messageCreationRunStepIndex + 1);
|
|
1054
|
+
} else {
|
|
1055
|
+
olderRunSteps2 = message.runSteps.slice(messageCreationRunStepIndex + 1, messageCreationRunStepIndex + prevRunStepIndex);
|
|
1402
1056
|
}
|
|
1403
|
-
return
|
|
1057
|
+
return [
|
|
1058
|
+
olderRunSteps2,
|
|
1059
|
+
laterRunSteps2
|
|
1060
|
+
];
|
|
1404
1061
|
}, [
|
|
1405
|
-
|
|
1406
|
-
]);
|
|
1407
|
-
|
|
1408
|
-
return null;
|
|
1409
|
-
}
|
|
1410
|
-
return /* @__PURE__ */ jsxs2(Code, {
|
|
1411
|
-
variant: "ghost",
|
|
1412
|
-
color: "gold",
|
|
1413
|
-
style: {
|
|
1414
|
-
whiteSpace: "pre",
|
|
1415
|
-
wordBreak: "break-word"
|
|
1416
|
-
},
|
|
1062
|
+
message
|
|
1063
|
+
]), 2), olderRunSteps = _useMemo4[0], laterRunSteps = _useMemo4[1];
|
|
1064
|
+
return /* @__PURE__ */ jsxs6(Box7, {
|
|
1417
1065
|
children: [
|
|
1418
|
-
/* @__PURE__ */
|
|
1419
|
-
|
|
1066
|
+
/* @__PURE__ */ jsx27(RunSteps, {
|
|
1067
|
+
runSteps: olderRunSteps
|
|
1420
1068
|
}),
|
|
1421
|
-
|
|
1422
|
-
|
|
1069
|
+
message.content.map(function(content, index) {
|
|
1070
|
+
return /* @__PURE__ */ jsx27(Box7, {
|
|
1071
|
+
children: content.type === "text" && /* @__PURE__ */ jsx27(TextContent, {
|
|
1072
|
+
content: content
|
|
1073
|
+
})
|
|
1074
|
+
}, index);
|
|
1075
|
+
}),
|
|
1076
|
+
/* @__PURE__ */ jsx27(RunSteps, {
|
|
1077
|
+
runSteps: laterRunSteps
|
|
1423
1078
|
})
|
|
1424
1079
|
]
|
|
1425
1080
|
});
|
|
1426
1081
|
};
|
|
1427
|
-
// src/components/
|
|
1428
|
-
import { jsx as
|
|
1429
|
-
var
|
|
1430
|
-
var
|
|
1431
|
-
return /* @__PURE__ */
|
|
1082
|
+
// src/components/threads/Thread/Messages/Content/MessageGroup/Content/index.tsx
|
|
1083
|
+
import { jsx as jsx28 } from "react/jsx-runtime";
|
|
1084
|
+
var Content2 = function(param) {
|
|
1085
|
+
var messageGroup = param.messageGroup;
|
|
1086
|
+
return /* @__PURE__ */ jsx28(Flex11, {
|
|
1087
|
+
direction: "column-reverse",
|
|
1088
|
+
children: messageGroup.messages.map(function(message) {
|
|
1089
|
+
return /* @__PURE__ */ jsx28(Message, {
|
|
1090
|
+
message: message
|
|
1091
|
+
}, message.id);
|
|
1092
|
+
})
|
|
1093
|
+
});
|
|
1094
|
+
};
|
|
1095
|
+
// src/components/threads/Thread/Messages/Content/MessageGroup/index.tsx
|
|
1096
|
+
import { jsx as jsx29, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1097
|
+
var MessageGroup = function(param) {
|
|
1098
|
+
var messageGroup = param.messageGroup;
|
|
1099
|
+
var assistantNameContext = useContext5(AssistantNameContext);
|
|
1100
|
+
return /* @__PURE__ */ jsxs7(MessageGroupBase, {
|
|
1432
1101
|
children: [
|
|
1433
|
-
/* @__PURE__ */
|
|
1102
|
+
messageGroup.role === "user" ? /* @__PURE__ */ jsx29(Avatar3, {
|
|
1103
|
+
fallback: /* @__PURE__ */ jsx29(PersonIcon, {}),
|
|
1104
|
+
size: "1"
|
|
1105
|
+
}) : /* @__PURE__ */ jsx29(AssistantAvatar, {}),
|
|
1106
|
+
/* @__PURE__ */ jsxs7(Box8, {
|
|
1107
|
+
flexGrow: "1",
|
|
1434
1108
|
children: [
|
|
1435
|
-
/* @__PURE__ */
|
|
1436
|
-
|
|
1109
|
+
/* @__PURE__ */ jsx29(Name, {
|
|
1110
|
+
children: messageGroup.role === "user" ? "You" : assistantNameContext
|
|
1437
1111
|
}),
|
|
1438
|
-
/* @__PURE__ */
|
|
1439
|
-
|
|
1112
|
+
/* @__PURE__ */ jsx29(Content2, {
|
|
1113
|
+
messageGroup: messageGroup
|
|
1440
1114
|
})
|
|
1441
1115
|
]
|
|
1442
|
-
}),
|
|
1443
|
-
/* @__PURE__ */ jsx12(PopoverContent, {
|
|
1444
|
-
style: {
|
|
1445
|
-
maxHeight: "500px"
|
|
1446
|
-
},
|
|
1447
|
-
children: /* @__PURE__ */ jsx12(Content, {
|
|
1448
|
-
fn: fn
|
|
1449
|
-
})
|
|
1450
1116
|
})
|
|
1451
1117
|
]
|
|
1452
1118
|
});
|
|
1453
1119
|
};
|
|
1454
|
-
// src/components/
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
return
|
|
1120
|
+
// src/components/threads/Thread/Messages/Content/index.tsx
|
|
1121
|
+
import { Fragment, jsx as jsx30 } from "react/jsx-runtime";
|
|
1122
|
+
var Content3 = function() {
|
|
1123
|
+
var _useMessages = useMessages(), messages2 = _useMessages.messages, isLoading = _useMessages.isLoading, isLoadingError = _useMessages.isLoadingError;
|
|
1124
|
+
var _useMessageGroups = useMessageGroups({
|
|
1125
|
+
messages: messages2
|
|
1126
|
+
}), messageGroups2 = _useMessageGroups.messageGroups;
|
|
1127
|
+
if (isLoading || isLoadingError) {
|
|
1128
|
+
return /* @__PURE__ */ jsx30(MessagesSkeleton, {});
|
|
1463
1129
|
}
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
return /* @__PURE__ */ jsx13(FunctionBase, {
|
|
1470
|
-
fn: fn,
|
|
1471
|
-
runStep: runStep,
|
|
1472
|
-
title: title({
|
|
1473
|
-
runStep: runStep,
|
|
1474
|
-
fn: fn
|
|
1130
|
+
return /* @__PURE__ */ jsx30(Fragment, {
|
|
1131
|
+
children: messageGroups2.map(function(messageGroup) {
|
|
1132
|
+
return /* @__PURE__ */ jsx30(MessageGroup, {
|
|
1133
|
+
messageGroup: messageGroup
|
|
1134
|
+
}, messageGroup.id);
|
|
1475
1135
|
})
|
|
1476
1136
|
});
|
|
1477
1137
|
};
|
|
1478
|
-
// src/components/
|
|
1479
|
-
import {
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
return(
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1138
|
+
// src/components/threads/Thread/Messages/Progress/index.tsx
|
|
1139
|
+
import { Box as Box11 } from "@radix-ui/themes";
|
|
1140
|
+
// src/components/skeletons/StartingContentSkeleton/index.tsx
|
|
1141
|
+
import { Box as Box9 } from "@radix-ui/themes";
|
|
1142
|
+
import { jsx as jsx31 } from "react/jsx-runtime";
|
|
1143
|
+
var StartingContentSkeleton = function() {
|
|
1144
|
+
return /* @__PURE__ */ jsx31(Box9, {
|
|
1145
|
+
flexShrink: "0",
|
|
1146
|
+
mt: "1",
|
|
1147
|
+
height: "var(--space-4)",
|
|
1148
|
+
width: "var(--space-4)",
|
|
1149
|
+
style: {
|
|
1150
|
+
animation: "pulse 2s cubic-bezier(.4,0,.6,1) infinite",
|
|
1151
|
+
borderRadius: "var(--radius-3)",
|
|
1152
|
+
backgroundColor: "var(--gray-12)"
|
|
1153
|
+
}
|
|
1154
|
+
});
|
|
1489
1155
|
};
|
|
1490
|
-
// src/components/
|
|
1491
|
-
import {
|
|
1492
|
-
import {
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1156
|
+
// src/components/skeletons/StartingSkeleton/index.tsx
|
|
1157
|
+
import { useContext as useContext6 } from "react";
|
|
1158
|
+
import { Box as Box10 } from "@radix-ui/themes";
|
|
1159
|
+
import { jsx as jsx32, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1160
|
+
var StartingSkeleton = function(param) {
|
|
1161
|
+
var children = param.children;
|
|
1162
|
+
var assistantNameContext = useContext6(AssistantNameContext);
|
|
1163
|
+
return /* @__PURE__ */ jsxs8(MessageGroupBase, {
|
|
1164
|
+
children: [
|
|
1165
|
+
/* @__PURE__ */ jsx32(AssistantAvatar, {}),
|
|
1166
|
+
/* @__PURE__ */ jsxs8(Box10, {
|
|
1167
|
+
children: [
|
|
1168
|
+
/* @__PURE__ */ jsx32(Name, {
|
|
1169
|
+
children: assistantNameContext
|
|
1170
|
+
}),
|
|
1171
|
+
children,
|
|
1172
|
+
/* @__PURE__ */ jsx32(StartingContentSkeleton, {})
|
|
1173
|
+
]
|
|
1174
|
+
})
|
|
1175
|
+
]
|
|
1497
1176
|
});
|
|
1498
1177
|
};
|
|
1499
|
-
// src/
|
|
1500
|
-
import {
|
|
1501
|
-
var
|
|
1502
|
-
var
|
|
1503
|
-
|
|
1504
|
-
return
|
|
1505
|
-
|
|
1506
|
-
runStep: runStep
|
|
1178
|
+
// src/hooks/messages/useLatestMessage/index.ts
|
|
1179
|
+
import { useMemo as useMemo5 } from "react";
|
|
1180
|
+
var useLatestMessage = function() {
|
|
1181
|
+
var props = useMessages();
|
|
1182
|
+
return useMemo5(function() {
|
|
1183
|
+
return _object_spread_props(_object_spread({}, props), {
|
|
1184
|
+
latestMessage: props.messages[0] || null
|
|
1507
1185
|
});
|
|
1508
|
-
}
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1186
|
+
}, [
|
|
1187
|
+
props
|
|
1188
|
+
]);
|
|
1189
|
+
};
|
|
1190
|
+
// src/hooks/runs/useIsRunActive/index.tsx
|
|
1191
|
+
import { useMemo as useMemo8 } from "react";
|
|
1192
|
+
import { useIsMutating } from "@tanstack/react-query";
|
|
1193
|
+
// src/hooks/runs/useLatestRun/index.ts
|
|
1194
|
+
import { useMemo as useMemo7 } from "react";
|
|
1195
|
+
// src/hooks/runs/useRuns/index.tsx
|
|
1196
|
+
import { useMemo as useMemo6 } from "react";
|
|
1197
|
+
import { useInfiniteQuery as useInfiniteQuery2, useQueryClient as useQueryClient3 } from "@tanstack/react-query";
|
|
1198
|
+
// src/hooks/runs/useRuns/lib/getRuns.ts
|
|
1199
|
+
var getRuns = function(param) {
|
|
1200
|
+
var data3 = param.data;
|
|
1201
|
+
if (!data3) return [];
|
|
1202
|
+
return data3.pages.reduce(function(acc, page) {
|
|
1203
|
+
return acc.concat(page.data);
|
|
1204
|
+
}, []);
|
|
1205
|
+
};
|
|
1206
|
+
// src/hooks/runs/useRuns/index.tsx
|
|
1207
|
+
var useRuns = function() {
|
|
1208
|
+
var queryClient = useQueryClient3();
|
|
1209
|
+
var superinterfaceContext = useSuperinterfaceContext();
|
|
1210
|
+
var threadContext = useSuperinterfaceContext();
|
|
1211
|
+
var props = useInfiniteQuery2(queryOptions({
|
|
1212
|
+
queryKeyBase: [
|
|
1213
|
+
"runs"
|
|
1214
|
+
],
|
|
1215
|
+
path: "/runs",
|
|
1216
|
+
queryClient: queryClient,
|
|
1217
|
+
threadContext: threadContext,
|
|
1218
|
+
superinterfaceContext: superinterfaceContext
|
|
1219
|
+
}));
|
|
1220
|
+
return useMemo6(function() {
|
|
1221
|
+
return _object_spread_props(_object_spread({}, props), {
|
|
1222
|
+
// @ts-ignore-next-line
|
|
1223
|
+
runs: getRuns({
|
|
1224
|
+
data: props.data
|
|
1225
|
+
})
|
|
1513
1226
|
});
|
|
1514
|
-
}
|
|
1515
|
-
|
|
1516
|
-
|
|
1227
|
+
}, [
|
|
1228
|
+
props
|
|
1229
|
+
]);
|
|
1230
|
+
};
|
|
1231
|
+
// src/hooks/runs/useLatestRun/index.ts
|
|
1232
|
+
var useLatestRun = function() {
|
|
1233
|
+
var props = useRuns();
|
|
1234
|
+
return useMemo7(function() {
|
|
1235
|
+
return _object_spread_props(_object_spread({}, props), {
|
|
1236
|
+
latestRun: props.runs[0]
|
|
1237
|
+
});
|
|
1238
|
+
}, [
|
|
1239
|
+
props
|
|
1240
|
+
]);
|
|
1241
|
+
};
|
|
1242
|
+
// src/lib/runs/isRunEditingMessage/index.ts
|
|
1243
|
+
import _4 from "lodash";
|
|
1244
|
+
var isRunEditingMessage = function(param) {
|
|
1245
|
+
var message = param.message;
|
|
1246
|
+
if (!message) return false;
|
|
1247
|
+
if (message.role === "user") return false;
|
|
1248
|
+
if (!message.run_id) return false;
|
|
1249
|
+
var hasContent = _4.some(message.content, function(content) {
|
|
1250
|
+
var _content_text;
|
|
1251
|
+
return content.type !== "text" || content.type === "text" && ((_content_text = content.text) === null || _content_text === void 0 ? void 0 : _content_text.value) !== "";
|
|
1252
|
+
});
|
|
1253
|
+
return !hasContent;
|
|
1254
|
+
};
|
|
1255
|
+
// src/hooks/runs/useIsRunActive/index.tsx
|
|
1256
|
+
var progressStatuses = [
|
|
1257
|
+
"queued",
|
|
1258
|
+
"in_progress",
|
|
1259
|
+
"cancelling",
|
|
1260
|
+
"requires_action"
|
|
1261
|
+
];
|
|
1262
|
+
var stoppedStatuses = [
|
|
1263
|
+
"expired",
|
|
1264
|
+
"cancelled",
|
|
1265
|
+
"failed"
|
|
1266
|
+
];
|
|
1267
|
+
var isRunActive = function(param) {
|
|
1268
|
+
var latestRunProps = param.latestRunProps, latestMessageProps = param.latestMessageProps, isMutating = param.isMutating;
|
|
1269
|
+
var _latestMessageProps_latestMessage_metadata, _latestMessageProps_latestMessage;
|
|
1270
|
+
if ((_latestMessageProps_latestMessage = latestMessageProps.latestMessage) === null || _latestMessageProps_latestMessage === void 0 ? void 0 : (_latestMessageProps_latestMessage_metadata = _latestMessageProps_latestMessage.metadata) === null || _latestMessageProps_latestMessage_metadata === void 0 ? void 0 : _latestMessageProps_latestMessage_metadata.isBlocking) return false;
|
|
1271
|
+
if (isMutating) return true;
|
|
1272
|
+
if (!latestRunProps.latestRun) return false;
|
|
1273
|
+
if (progressStatuses.includes(latestRunProps.latestRun.status)) return true;
|
|
1274
|
+
if (stoppedStatuses.includes(latestRunProps.latestRun.status)) return false;
|
|
1275
|
+
return isRunEditingMessage({
|
|
1276
|
+
message: latestMessageProps.latestMessage
|
|
1277
|
+
});
|
|
1278
|
+
};
|
|
1279
|
+
var useIsRunActive = function() {
|
|
1280
|
+
var latestRunProps = useLatestRun();
|
|
1281
|
+
var latestMessageProps = useLatestMessage();
|
|
1282
|
+
var threadContext = useSuperinterfaceContext();
|
|
1283
|
+
var isMutatingCreateRun = useIsMutating({
|
|
1284
|
+
mutationKey: [
|
|
1285
|
+
"createRun",
|
|
1286
|
+
threadContext.variables
|
|
1287
|
+
]
|
|
1288
|
+
});
|
|
1289
|
+
var isMutatingCreateMessage = useIsMutating({
|
|
1290
|
+
mutationKey: [
|
|
1291
|
+
"createMessage",
|
|
1292
|
+
threadContext.variables
|
|
1293
|
+
]
|
|
1294
|
+
});
|
|
1295
|
+
var isMutatingCreateHandleAction = useIsMutating({
|
|
1296
|
+
mutationKey: [
|
|
1297
|
+
"handleAction",
|
|
1298
|
+
threadContext.variables
|
|
1299
|
+
]
|
|
1517
1300
|
});
|
|
1301
|
+
return useMemo8(function() {
|
|
1302
|
+
return _object_spread_props(_object_spread({}, latestRunProps), {
|
|
1303
|
+
isRunActive: isRunActive({
|
|
1304
|
+
latestRunProps: latestRunProps,
|
|
1305
|
+
latestMessageProps: latestMessageProps,
|
|
1306
|
+
isMutating: isMutatingCreateRun > 0 || isMutatingCreateMessage > 0 || isMutatingCreateHandleAction > 0
|
|
1307
|
+
})
|
|
1308
|
+
});
|
|
1309
|
+
}, [
|
|
1310
|
+
latestRunProps,
|
|
1311
|
+
latestMessageProps,
|
|
1312
|
+
isMutatingCreateRun,
|
|
1313
|
+
isMutatingCreateMessage,
|
|
1314
|
+
isMutatingCreateHandleAction
|
|
1315
|
+
]);
|
|
1518
1316
|
};
|
|
1519
|
-
// src/components/
|
|
1520
|
-
import {
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
var
|
|
1524
|
-
|
|
1317
|
+
// src/components/threads/Thread/Messages/Progress/index.tsx
|
|
1318
|
+
import { jsx as jsx33, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1319
|
+
var Progress = function() {
|
|
1320
|
+
var _useIsRunActive = useIsRunActive(), isRunActive2 = _useIsRunActive.isRunActive;
|
|
1321
|
+
var latestMessage = useLatestMessage().latestMessage;
|
|
1322
|
+
if (!latestMessage) return null;
|
|
1323
|
+
if (!isRunActive2) return null;
|
|
1324
|
+
if (latestMessage.role === "user") {
|
|
1325
|
+
return /* @__PURE__ */ jsx33(StartingSkeleton, {});
|
|
1326
|
+
}
|
|
1327
|
+
return /* @__PURE__ */ jsxs9(MessageGroupBase, {
|
|
1525
1328
|
children: [
|
|
1526
|
-
/* @__PURE__ */
|
|
1527
|
-
|
|
1528
|
-
/* @__PURE__ */ jsx17(CircleIcon2, {}),
|
|
1529
|
-
/* @__PURE__ */ jsx17(ToolCallTitle, {
|
|
1530
|
-
children: "Starting actions"
|
|
1531
|
-
})
|
|
1532
|
-
]
|
|
1329
|
+
/* @__PURE__ */ jsx33(Box11, {
|
|
1330
|
+
pl: "5"
|
|
1533
1331
|
}),
|
|
1534
|
-
/* @__PURE__ */
|
|
1535
|
-
style: {
|
|
1536
|
-
maxHeight: "500px"
|
|
1537
|
-
},
|
|
1538
|
-
children: /* @__PURE__ */ jsx17(Text3, {
|
|
1539
|
-
children: "Getting ready to connect to domain API"
|
|
1540
|
-
})
|
|
1541
|
-
})
|
|
1332
|
+
/* @__PURE__ */ jsx33(StartingContentSkeleton, {})
|
|
1542
1333
|
]
|
|
1543
1334
|
});
|
|
1544
1335
|
};
|
|
1545
|
-
// src/components/
|
|
1546
|
-
import {
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1336
|
+
// src/components/threads/Thread/Messages/Root/index.tsx
|
|
1337
|
+
import { Flex as Flex12 } from "@radix-ui/themes";
|
|
1338
|
+
// src/hooks/misc/useInfiniteScroll/index.tsx
|
|
1339
|
+
import { useRef as useRef2 } from "react";
|
|
1340
|
+
import { useInView } from "react-intersection-observer";
|
|
1341
|
+
// src/hooks/misc/useThrottledEffect/index.tsx
|
|
1342
|
+
import _5 from "lodash";
|
|
1343
|
+
import { useRef, useEffect, useCallback } from "react";
|
|
1344
|
+
var useThrottledEffect = function(cb, delay, additionalDeps) {
|
|
1345
|
+
var _cbRef;
|
|
1346
|
+
var cbRef = useRef(cb);
|
|
1347
|
+
var throttledCb = useCallback(_5.throttle(function() {
|
|
1348
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
1349
|
+
args[_key] = arguments[_key];
|
|
1350
|
+
}
|
|
1351
|
+
return (_cbRef = cbRef).current.apply(_cbRef, _to_consumable_array(args));
|
|
1352
|
+
}, delay, {
|
|
1353
|
+
leading: true,
|
|
1354
|
+
trailing: true
|
|
1355
|
+
}), [
|
|
1356
|
+
delay
|
|
1357
|
+
]);
|
|
1358
|
+
useEffect(function() {
|
|
1359
|
+
cbRef.current = cb;
|
|
1560
1360
|
});
|
|
1361
|
+
useEffect(throttledCb, [
|
|
1362
|
+
throttledCb
|
|
1363
|
+
].concat(_to_consumable_array(additionalDeps)));
|
|
1561
1364
|
};
|
|
1562
|
-
// src/
|
|
1563
|
-
|
|
1564
|
-
var
|
|
1565
|
-
var
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1365
|
+
// src/hooks/misc/useInfiniteScroll/index.tsx
|
|
1366
|
+
var useInfiniteScroll = function(param) {
|
|
1367
|
+
var isFetchingNextPage = param.isFetchingNextPage, hasNextPage = param.hasNextPage, fetchNextPage = param.fetchNextPage;
|
|
1368
|
+
var containerRef = useRef2(null);
|
|
1369
|
+
var _useInView = useInView({
|
|
1370
|
+
root: containerRef.current,
|
|
1371
|
+
rootMargin: "0px",
|
|
1372
|
+
threshold: 0.1
|
|
1373
|
+
}), loaderRef = _useInView.ref, inView = _useInView.inView;
|
|
1374
|
+
useThrottledEffect(function() {
|
|
1375
|
+
if (isFetchingNextPage) return;
|
|
1376
|
+
if (!inView) return;
|
|
1377
|
+
if (!hasNextPage) return;
|
|
1378
|
+
console.log("Fetching next page");
|
|
1379
|
+
fetchNextPage();
|
|
1380
|
+
}, 500, [
|
|
1381
|
+
inView,
|
|
1382
|
+
isFetchingNextPage,
|
|
1383
|
+
hasNextPage,
|
|
1384
|
+
fetchNextPage
|
|
1385
|
+
]);
|
|
1386
|
+
return {
|
|
1387
|
+
containerRef: containerRef,
|
|
1388
|
+
loaderRef: loaderRef,
|
|
1389
|
+
inView: inView
|
|
1390
|
+
};
|
|
1391
|
+
};
|
|
1392
|
+
// src/hooks/runs/useManageRuns/index.tsx
|
|
1393
|
+
import { useQueryClient as useQueryClient5 } from "@tanstack/react-query";
|
|
1394
|
+
import { useEffect as useEffect2 } from "react";
|
|
1395
|
+
// src/hooks/runs/useCreateRun/index.ts
|
|
1396
|
+
import { partob } from "radash";
|
|
1397
|
+
import { useMutation, useQueryClient as useQueryClient4 } from "@tanstack/react-query";
|
|
1398
|
+
// src/lib/threads/mutationOptions/index.ts
|
|
1399
|
+
var mutationOptions = function(param) {
|
|
1400
|
+
var mutationKeyBase = param.mutationKeyBase, path = param.path, queryClient = param.queryClient, threadContext = param.threadContext, superinterfaceContext = param.superinterfaceContext;
|
|
1401
|
+
var mutationKey = _to_consumable_array(mutationKeyBase).concat([
|
|
1402
|
+
threadContext.variables
|
|
1403
|
+
]);
|
|
1404
|
+
return _object_spread(_object_spread_props(_object_spread({
|
|
1405
|
+
mutationFn: function(variables) {
|
|
1406
|
+
return fetch("".concat(superinterfaceContext.baseUrl).concat(path), _object_spread({
|
|
1407
|
+
method: "POST",
|
|
1408
|
+
body: JSON.stringify(variables),
|
|
1409
|
+
credentials: "include"
|
|
1410
|
+
}, superinterfaceContext.publicApiKey ? {
|
|
1411
|
+
headers: {
|
|
1412
|
+
Authorization: "Bearer ".concat(superinterfaceContext.publicApiKey)
|
|
1413
|
+
}
|
|
1414
|
+
} : {})).then(function() {
|
|
1415
|
+
var _ref = _async_to_generator(function(response) {
|
|
1416
|
+
var errorResponse, error;
|
|
1417
|
+
return _ts_generator(this, function(_state) {
|
|
1418
|
+
switch(_state.label){
|
|
1419
|
+
case 0:
|
|
1420
|
+
if (!(response.status !== 200)) return [
|
|
1421
|
+
3,
|
|
1422
|
+
4
|
|
1423
|
+
];
|
|
1424
|
+
_state.label = 1;
|
|
1425
|
+
case 1:
|
|
1426
|
+
_state.trys.push([
|
|
1427
|
+
1,
|
|
1428
|
+
3,
|
|
1429
|
+
,
|
|
1430
|
+
4
|
|
1431
|
+
]);
|
|
1432
|
+
return [
|
|
1433
|
+
4,
|
|
1434
|
+
response.json()
|
|
1435
|
+
];
|
|
1436
|
+
case 2:
|
|
1437
|
+
errorResponse = _state.sent();
|
|
1438
|
+
throw new Error(errorResponse.error);
|
|
1439
|
+
case 3:
|
|
1440
|
+
error = _state.sent();
|
|
1441
|
+
throw new Error("Failed to fetch");
|
|
1442
|
+
case 4:
|
|
1443
|
+
return [
|
|
1444
|
+
2,
|
|
1445
|
+
response.json()
|
|
1446
|
+
];
|
|
1447
|
+
}
|
|
1448
|
+
});
|
|
1449
|
+
});
|
|
1450
|
+
return function(response) {
|
|
1451
|
+
return _ref.apply(this, arguments);
|
|
1452
|
+
};
|
|
1453
|
+
}());
|
|
1454
|
+
}
|
|
1455
|
+
}, queryClient.getMutationDefaults(mutationKey)), {
|
|
1456
|
+
mutationKey: mutationKey
|
|
1457
|
+
}), threadContext.defaultOptions.mutations);
|
|
1458
|
+
};
|
|
1459
|
+
// src/hooks/runs/useCreateRun/lib/onSuccess.ts
|
|
1460
|
+
var onSuccess = function(param) {
|
|
1461
|
+
var queryClient = param.queryClient;
|
|
1462
|
+
return function() {
|
|
1463
|
+
var _ref = _async_to_generator(function(data3, variables) {
|
|
1464
|
+
return _ts_generator(this, function(_state) {
|
|
1465
|
+
return [
|
|
1466
|
+
2,
|
|
1467
|
+
queryClient.setQueryData([
|
|
1468
|
+
"runs",
|
|
1469
|
+
variables
|
|
1470
|
+
], function(prevData) {
|
|
1471
|
+
if (!prevData) {
|
|
1472
|
+
return {
|
|
1473
|
+
pageParams: [],
|
|
1474
|
+
pages: [
|
|
1475
|
+
{
|
|
1476
|
+
data: [
|
|
1477
|
+
data3.run
|
|
1478
|
+
],
|
|
1479
|
+
hasNextPage: false,
|
|
1480
|
+
lastId: data3.run.id
|
|
1481
|
+
}
|
|
1482
|
+
]
|
|
1483
|
+
};
|
|
1484
|
+
}
|
|
1485
|
+
var _prevData_pages = _to_array(prevData.pages), latestPage = _prevData_pages[0], pagesRest = _prevData_pages.slice(1);
|
|
1486
|
+
return _object_spread_props(_object_spread({}, prevData), {
|
|
1487
|
+
pages: [
|
|
1488
|
+
_object_spread_props(_object_spread({}, latestPage), {
|
|
1489
|
+
data: [
|
|
1490
|
+
data3.run
|
|
1491
|
+
].concat(_to_consumable_array(latestPage.data))
|
|
1492
|
+
})
|
|
1493
|
+
].concat(_to_consumable_array(pagesRest))
|
|
1494
|
+
});
|
|
1495
|
+
})
|
|
1496
|
+
];
|
|
1497
|
+
});
|
|
1498
|
+
});
|
|
1499
|
+
return function(data3, variables) {
|
|
1500
|
+
return _ref.apply(this, arguments);
|
|
1501
|
+
};
|
|
1502
|
+
}();
|
|
1503
|
+
};
|
|
1504
|
+
// src/hooks/runs/useCreateRun/lib/onSettled.ts
|
|
1505
|
+
var onSettled = function(param) {
|
|
1506
|
+
var queryClient = param.queryClient;
|
|
1507
|
+
return function() {
|
|
1508
|
+
var _ref = _async_to_generator(function(_data, _error, variables) {
|
|
1509
|
+
return _ts_generator(this, function(_state) {
|
|
1510
|
+
switch(_state.label){
|
|
1511
|
+
case 0:
|
|
1512
|
+
return [
|
|
1513
|
+
4,
|
|
1514
|
+
queryClient.invalidateQueries({
|
|
1515
|
+
queryKey: [
|
|
1516
|
+
"messages",
|
|
1517
|
+
variables
|
|
1518
|
+
]
|
|
1519
|
+
})
|
|
1520
|
+
];
|
|
1521
|
+
case 1:
|
|
1522
|
+
_state.sent();
|
|
1523
|
+
return [
|
|
1524
|
+
4,
|
|
1525
|
+
queryClient.invalidateQueries({
|
|
1526
|
+
queryKey: [
|
|
1527
|
+
"runs",
|
|
1528
|
+
variables
|
|
1529
|
+
]
|
|
1530
|
+
})
|
|
1531
|
+
];
|
|
1532
|
+
case 2:
|
|
1533
|
+
_state.sent();
|
|
1534
|
+
return [
|
|
1535
|
+
2
|
|
1536
|
+
];
|
|
1537
|
+
}
|
|
1538
|
+
});
|
|
1570
1539
|
});
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
};
|
|
1574
|
-
|
|
1575
|
-
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
1576
|
-
var RunSteps = function(param) {
|
|
1577
|
-
var runSteps = param.runSteps;
|
|
1578
|
-
return /* @__PURE__ */ jsx20(Flex10, {
|
|
1579
|
-
direction: "column-reverse",
|
|
1580
|
-
children: runSteps.map(function(runStep) {
|
|
1581
|
-
return /* @__PURE__ */ jsx20(RunStep, {
|
|
1582
|
-
runStep: runStep
|
|
1583
|
-
}, runStep.id);
|
|
1584
|
-
})
|
|
1585
|
-
});
|
|
1586
|
-
};
|
|
1587
|
-
// src/components/ThreadMessages/ThreadMessage/TextContent/index.tsx
|
|
1588
|
-
import { useContext as useContext4 } from "react";
|
|
1589
|
-
import { useRemarkSync } from "react-remark";
|
|
1590
|
-
// src/contexts/markdown/MarkdownContext/index.ts
|
|
1591
|
-
import { createContext as createContext5 } from "react";
|
|
1592
|
-
// src/contexts/markdown/MarkdownContext/lib/components/Paragraph.tsx
|
|
1593
|
-
import { Box as Box3, Text as Text4 } from "@radix-ui/themes";
|
|
1594
|
-
import { jsx as jsx21 } from "react/jsx-runtime";
|
|
1595
|
-
var Paragraph = function(param) {
|
|
1596
|
-
var children = param.children;
|
|
1597
|
-
return /* @__PURE__ */ jsx21(Box3, {
|
|
1598
|
-
pb: "3",
|
|
1599
|
-
children: /* @__PURE__ */ jsx21(Text4, {
|
|
1600
|
-
size: "3",
|
|
1601
|
-
style: {
|
|
1602
|
-
whiteSpace: "pre-line",
|
|
1603
|
-
wordBreak: "break-word"
|
|
1604
|
-
},
|
|
1605
|
-
children: children
|
|
1606
|
-
})
|
|
1607
|
-
});
|
|
1540
|
+
return function(_data, _error, variables) {
|
|
1541
|
+
return _ref.apply(this, arguments);
|
|
1542
|
+
};
|
|
1543
|
+
}();
|
|
1608
1544
|
};
|
|
1609
|
-
// src/
|
|
1610
|
-
import {
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
var children = param.children, href = param.href;
|
|
1614
|
-
return /* @__PURE__ */ jsx22(RadixLink, {
|
|
1615
|
-
href: href,
|
|
1616
|
-
children: children
|
|
1617
|
-
});
|
|
1545
|
+
// src/lib/optimistic/optimisticId.ts
|
|
1546
|
+
import { uid } from "radash";
|
|
1547
|
+
var optimisticId = function() {
|
|
1548
|
+
return "-".concat(uid(24));
|
|
1618
1549
|
};
|
|
1619
|
-
// src/
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1550
|
+
// src/hooks/runs/useCreateRun/lib/onMutate/data.ts
|
|
1551
|
+
var data = function(prevData) {
|
|
1552
|
+
var run = {
|
|
1553
|
+
id: optimisticId(),
|
|
1554
|
+
object: "thread.run",
|
|
1555
|
+
created_at: +/* @__PURE__ */ new Date(),
|
|
1556
|
+
assistant_id: null,
|
|
1557
|
+
thread_id: null,
|
|
1558
|
+
status: "in_progress",
|
|
1559
|
+
expires_at: +/* @__PURE__ */ new Date() + 1e3 * 60 * 60 * 24,
|
|
1560
|
+
cancelled_at: null,
|
|
1561
|
+
failed_at: null,
|
|
1562
|
+
completed_at: null,
|
|
1563
|
+
required_action: null,
|
|
1564
|
+
last_error: null,
|
|
1565
|
+
model: null,
|
|
1566
|
+
instructions: null,
|
|
1567
|
+
tools: [],
|
|
1568
|
+
file_ids: [],
|
|
1569
|
+
metadata: {},
|
|
1570
|
+
usage: null
|
|
1571
|
+
};
|
|
1572
|
+
if (!prevData) {
|
|
1573
|
+
return {
|
|
1574
|
+
pageParams: [],
|
|
1575
|
+
pages: [
|
|
1576
|
+
{
|
|
1577
|
+
data: [
|
|
1578
|
+
run
|
|
1579
|
+
],
|
|
1580
|
+
hasNextPage: false,
|
|
1581
|
+
lastId: run.id
|
|
1582
|
+
}
|
|
1583
|
+
]
|
|
1584
|
+
};
|
|
1585
|
+
}
|
|
1586
|
+
var _prevData_pages = _to_array(prevData.pages), latestPage = _prevData_pages[0], pagesRest = _prevData_pages.slice(1);
|
|
1587
|
+
return _object_spread_props(_object_spread({}, prevData), {
|
|
1588
|
+
pages: [
|
|
1589
|
+
_object_spread_props(_object_spread({}, latestPage), {
|
|
1590
|
+
data: [
|
|
1591
|
+
run
|
|
1592
|
+
].concat(_to_consumable_array(latestPage.data))
|
|
1593
|
+
})
|
|
1594
|
+
].concat(_to_consumable_array(pagesRest))
|
|
1633
1595
|
});
|
|
1634
1596
|
};
|
|
1635
|
-
// src/
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1597
|
+
// src/hooks/runs/useCreateRun/lib/onMutate/index.ts
|
|
1598
|
+
var onMutate = function(param) {
|
|
1599
|
+
var queryClient = param.queryClient;
|
|
1600
|
+
return function() {
|
|
1601
|
+
var _ref = _async_to_generator(function(variables) {
|
|
1602
|
+
var queryKey, prevRuns;
|
|
1603
|
+
return _ts_generator(this, function(_state) {
|
|
1604
|
+
switch(_state.label){
|
|
1605
|
+
case 0:
|
|
1606
|
+
queryKey = [
|
|
1607
|
+
"runs",
|
|
1608
|
+
variables
|
|
1609
|
+
];
|
|
1610
|
+
return [
|
|
1611
|
+
4,
|
|
1612
|
+
queryClient.cancelQueries({
|
|
1613
|
+
queryKey: queryKey
|
|
1614
|
+
})
|
|
1615
|
+
];
|
|
1616
|
+
case 1:
|
|
1617
|
+
_state.sent();
|
|
1618
|
+
prevRuns = queryClient.getQueryData(queryKey);
|
|
1619
|
+
queryClient.setQueryData(queryKey, data);
|
|
1620
|
+
return [
|
|
1621
|
+
2,
|
|
1622
|
+
{
|
|
1623
|
+
prevRuns: prevRuns,
|
|
1624
|
+
variables: variables
|
|
1625
|
+
}
|
|
1626
|
+
];
|
|
1627
|
+
}
|
|
1628
|
+
});
|
|
1629
|
+
});
|
|
1630
|
+
return function(variables) {
|
|
1631
|
+
return _ref.apply(this, arguments);
|
|
1632
|
+
};
|
|
1633
|
+
}();
|
|
1650
1634
|
};
|
|
1651
|
-
// src/
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
var
|
|
1655
|
-
var
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1635
|
+
// src/hooks/runs/useCreateRun/index.ts
|
|
1636
|
+
var useCreateRun = function() {
|
|
1637
|
+
var queryClient = useQueryClient4();
|
|
1638
|
+
var superinterfaceContext = useSuperinterfaceContext();
|
|
1639
|
+
var threadContext = useSuperinterfaceContext();
|
|
1640
|
+
var props = useMutation(_object_spread({
|
|
1641
|
+
onSuccess: onSuccess({
|
|
1642
|
+
queryClient: queryClient
|
|
1643
|
+
}),
|
|
1644
|
+
onSettled: onSettled({
|
|
1645
|
+
queryClient: queryClient
|
|
1646
|
+
}),
|
|
1647
|
+
onMutate: onMutate({
|
|
1648
|
+
queryClient: queryClient
|
|
1660
1649
|
})
|
|
1650
|
+
}, mutationOptions({
|
|
1651
|
+
mutationKeyBase: [
|
|
1652
|
+
"createRun"
|
|
1653
|
+
],
|
|
1654
|
+
path: "/runs",
|
|
1655
|
+
queryClient: queryClient,
|
|
1656
|
+
threadContext: threadContext,
|
|
1657
|
+
superinterfaceContext: superinterfaceContext
|
|
1658
|
+
})));
|
|
1659
|
+
return _object_spread_props(_object_spread({}, props), {
|
|
1660
|
+
createRun: partob(props.mutate, threadContext.variables)
|
|
1661
1661
|
});
|
|
1662
1662
|
};
|
|
1663
|
-
// src/
|
|
1664
|
-
import
|
|
1665
|
-
|
|
1666
|
-
var
|
|
1667
|
-
|
|
1668
|
-
return /* @__PURE__ */ jsx26(RadixStrong, {
|
|
1669
|
-
children: children
|
|
1670
|
-
});
|
|
1671
|
-
};
|
|
1672
|
-
// src/contexts/markdown/MarkdownContext/lib/components/index.tsx
|
|
1673
|
-
var components = {
|
|
1674
|
-
p: Paragraph,
|
|
1675
|
-
a: Link,
|
|
1676
|
-
strong: Strong,
|
|
1677
|
-
ul: UnorderedList,
|
|
1678
|
-
ol: OrderedList,
|
|
1679
|
-
li: ListItem
|
|
1680
|
-
};
|
|
1681
|
-
// src/contexts/markdown/MarkdownContext/index.ts
|
|
1682
|
-
var MarkdownContext = createContext5({
|
|
1683
|
-
remarkPlugins: [],
|
|
1684
|
-
rehypeReactOptions: {
|
|
1685
|
-
components: components
|
|
1686
|
-
}
|
|
1687
|
-
});
|
|
1688
|
-
// src/components/ThreadMessages/ThreadMessage/TextContent/index.tsx
|
|
1689
|
-
var TextContent = function(param) {
|
|
1690
|
-
var content = param.content;
|
|
1691
|
-
var markdownContext = useContext4(MarkdownContext);
|
|
1692
|
-
return useRemarkSync(content.text.value, markdownContext);
|
|
1663
|
+
// src/lib/optimistic/isOptimistic.ts
|
|
1664
|
+
import _6 from "lodash";
|
|
1665
|
+
var isOptimistic = function(param) {
|
|
1666
|
+
var id = param.id;
|
|
1667
|
+
return _6.startsWith(id, "-");
|
|
1693
1668
|
};
|
|
1694
|
-
// src/
|
|
1695
|
-
|
|
1696
|
-
var
|
|
1697
|
-
var
|
|
1698
|
-
var
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
});
|
|
1710
|
-
if (
|
|
1711
|
-
|
|
1669
|
+
// src/hooks/runs/useManageRuns/index.tsx
|
|
1670
|
+
var useManageRuns = function() {
|
|
1671
|
+
var queryClient = useQueryClient5();
|
|
1672
|
+
var latestRunProps = useLatestRun();
|
|
1673
|
+
var latestMessageProps = useLatestMessage();
|
|
1674
|
+
var createRunProps = useCreateRun();
|
|
1675
|
+
var threadContext = useSuperinterfaceContext();
|
|
1676
|
+
useEffect2(function() {
|
|
1677
|
+
if (createRunProps.isPending) return;
|
|
1678
|
+
if (latestRunProps.isFetching) return;
|
|
1679
|
+
if (latestMessageProps.isFetching) return;
|
|
1680
|
+
if (!latestMessageProps.latestMessage) return;
|
|
1681
|
+
if (latestMessageProps.latestMessage.role !== "user") return;
|
|
1682
|
+
if (isOptimistic({
|
|
1683
|
+
id: latestMessageProps.latestMessage.id
|
|
1684
|
+
})) return;
|
|
1685
|
+
if (latestRunProps.latestRun && latestRunProps.latestRun.created_at > latestMessageProps.latestMessage.created_at) {
|
|
1686
|
+
return;
|
|
1712
1687
|
}
|
|
1713
|
-
var
|
|
1714
|
-
|
|
1715
|
-
|
|
1688
|
+
var isMutating = queryClient.isMutating({
|
|
1689
|
+
mutationKey: [
|
|
1690
|
+
"createRun",
|
|
1691
|
+
threadContext.variables
|
|
1692
|
+
]
|
|
1716
1693
|
});
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
olderRunSteps2 = threadMessage.runSteps.slice(messageCreationRunStepIndex + 1);
|
|
1720
|
-
} else {
|
|
1721
|
-
olderRunSteps2 = threadMessage.runSteps.slice(messageCreationRunStepIndex + 1, messageCreationRunStepIndex + prevRunStepIndex);
|
|
1722
|
-
}
|
|
1723
|
-
return [
|
|
1724
|
-
olderRunSteps2,
|
|
1725
|
-
laterRunSteps2
|
|
1726
|
-
];
|
|
1694
|
+
if (isMutating) return;
|
|
1695
|
+
createRunProps.createRun();
|
|
1727
1696
|
}, [
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
threadMessage.content.map(function(content, index) {
|
|
1736
|
-
return /* @__PURE__ */ jsx27(Box7, {
|
|
1737
|
-
children: content.type === "text" && /* @__PURE__ */ jsx27(TextContent, {
|
|
1738
|
-
content: content
|
|
1739
|
-
})
|
|
1740
|
-
}, index);
|
|
1741
|
-
}),
|
|
1742
|
-
/* @__PURE__ */ jsx27(RunSteps, {
|
|
1743
|
-
runSteps: laterRunSteps
|
|
1744
|
-
})
|
|
1745
|
-
]
|
|
1746
|
-
});
|
|
1697
|
+
threadContext,
|
|
1698
|
+
queryClient,
|
|
1699
|
+
createRunProps,
|
|
1700
|
+
latestRunProps,
|
|
1701
|
+
latestMessageProps
|
|
1702
|
+
]);
|
|
1703
|
+
return null;
|
|
1747
1704
|
};
|
|
1748
|
-
// src/
|
|
1749
|
-
import {
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1705
|
+
// src/hooks/runs/usePolling/index.tsx
|
|
1706
|
+
import { useQueryClient as useQueryClient6 } from "@tanstack/react-query";
|
|
1707
|
+
import { useInterval } from "react-use";
|
|
1708
|
+
// src/hooks/runs/usePolling/lib/refetch.ts
|
|
1709
|
+
var refetch = function() {
|
|
1710
|
+
var _ref = _async_to_generator(function(param) {
|
|
1711
|
+
var queryClient, threadContext, _threadContext_defaultOptions_queries_queryKey, _threadContext_defaultOptions_queries_queryKey1;
|
|
1712
|
+
return _ts_generator(this, function(_state) {
|
|
1713
|
+
switch(_state.label){
|
|
1714
|
+
case 0:
|
|
1715
|
+
queryClient = param.queryClient, threadContext = param.threadContext;
|
|
1716
|
+
return [
|
|
1717
|
+
4,
|
|
1718
|
+
queryClient.invalidateQueries({
|
|
1719
|
+
queryKey: (_threadContext_defaultOptions_queries_queryKey = threadContext.defaultOptions.queries.queryKey) !== null && _threadContext_defaultOptions_queries_queryKey !== void 0 ? _threadContext_defaultOptions_queries_queryKey : [
|
|
1720
|
+
"messages",
|
|
1721
|
+
threadContext.variables
|
|
1722
|
+
]
|
|
1723
|
+
})
|
|
1724
|
+
];
|
|
1725
|
+
case 1:
|
|
1726
|
+
_state.sent();
|
|
1727
|
+
return [
|
|
1728
|
+
4,
|
|
1729
|
+
queryClient.invalidateQueries({
|
|
1730
|
+
queryKey: (_threadContext_defaultOptions_queries_queryKey1 = threadContext.defaultOptions.queries.queryKey) !== null && _threadContext_defaultOptions_queries_queryKey1 !== void 0 ? _threadContext_defaultOptions_queries_queryKey1 : [
|
|
1731
|
+
"runs",
|
|
1732
|
+
threadContext.variables
|
|
1733
|
+
]
|
|
1734
|
+
})
|
|
1735
|
+
];
|
|
1736
|
+
case 2:
|
|
1737
|
+
_state.sent();
|
|
1738
|
+
return [
|
|
1739
|
+
2
|
|
1740
|
+
];
|
|
1741
|
+
}
|
|
1742
|
+
});
|
|
1759
1743
|
});
|
|
1744
|
+
return function refetch(_) {
|
|
1745
|
+
return _ref.apply(this, arguments);
|
|
1746
|
+
};
|
|
1747
|
+
}();
|
|
1748
|
+
// src/hooks/runs/usePolling/index.tsx
|
|
1749
|
+
var usePolling = function() {
|
|
1750
|
+
var threadContext = useSuperinterfaceContext();
|
|
1751
|
+
var queryClient = useQueryClient6();
|
|
1752
|
+
var isRunActiveProps = useIsRunActive();
|
|
1753
|
+
useInterval(function() {
|
|
1754
|
+
refetch({
|
|
1755
|
+
queryClient: queryClient,
|
|
1756
|
+
threadContext: threadContext
|
|
1757
|
+
});
|
|
1758
|
+
console.log("poll refetched");
|
|
1759
|
+
}, isRunActiveProps.isRunActive ? 3e3 : null);
|
|
1760
|
+
return null;
|
|
1760
1761
|
};
|
|
1761
|
-
// src/
|
|
1762
|
-
import {
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1762
|
+
// src/hooks/actions/useManageActions/index.tsx
|
|
1763
|
+
import { useQueryClient as useQueryClient8 } from "@tanstack/react-query";
|
|
1764
|
+
import { useEffect as useEffect3 } from "react";
|
|
1765
|
+
// src/hooks/actions/useHandleAction/index.tsx
|
|
1766
|
+
import { partob as partob2 } from "radash";
|
|
1767
|
+
import { useMutation as useMutation2, useQueryClient as useQueryClient7 } from "@tanstack/react-query";
|
|
1768
|
+
// src/hooks/actions/useHandleAction/lib/onSettled.ts
|
|
1769
|
+
var onSettled2 = function(param) {
|
|
1770
|
+
var queryClient = param.queryClient;
|
|
1771
|
+
return function() {
|
|
1772
|
+
var _ref = _async_to_generator(function(_data, _error, variables) {
|
|
1773
|
+
return _ts_generator(this, function(_state) {
|
|
1774
|
+
switch(_state.label){
|
|
1775
|
+
case 0:
|
|
1776
|
+
return [
|
|
1777
|
+
4,
|
|
1778
|
+
queryClient.invalidateQueries({
|
|
1779
|
+
queryKey: [
|
|
1780
|
+
"messages",
|
|
1781
|
+
variables
|
|
1782
|
+
]
|
|
1783
|
+
})
|
|
1784
|
+
];
|
|
1785
|
+
case 1:
|
|
1786
|
+
_state.sent();
|
|
1787
|
+
return [
|
|
1788
|
+
4,
|
|
1789
|
+
queryClient.invalidateQueries({
|
|
1790
|
+
queryKey: [
|
|
1791
|
+
"runs",
|
|
1792
|
+
variables
|
|
1793
|
+
]
|
|
1794
|
+
})
|
|
1795
|
+
];
|
|
1796
|
+
case 2:
|
|
1797
|
+
_state.sent();
|
|
1798
|
+
return [
|
|
1799
|
+
2
|
|
1800
|
+
];
|
|
1801
|
+
}
|
|
1802
|
+
});
|
|
1803
|
+
});
|
|
1804
|
+
return function(_data, _error, variables) {
|
|
1805
|
+
return _ref.apply(this, arguments);
|
|
1806
|
+
};
|
|
1807
|
+
}();
|
|
1785
1808
|
};
|
|
1786
|
-
// src/
|
|
1787
|
-
|
|
1788
|
-
var
|
|
1789
|
-
var
|
|
1790
|
-
var
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
return /* @__PURE__ */ jsx30(ThreadMessagesSkeleton, {});
|
|
1795
|
-
}
|
|
1796
|
-
return /* @__PURE__ */ jsx30(Fragment, {
|
|
1797
|
-
children: threadMessageGroups2.map(function(threadMessageGroup) {
|
|
1798
|
-
return /* @__PURE__ */ jsx30(ThreadMessageGroup, {
|
|
1799
|
-
threadMessageGroup: threadMessageGroup
|
|
1800
|
-
}, threadMessageGroup.id);
|
|
1809
|
+
// src/hooks/actions/useHandleAction/index.tsx
|
|
1810
|
+
var useHandleAction = function() {
|
|
1811
|
+
var queryClient = useQueryClient7();
|
|
1812
|
+
var superinterfaceContext = useSuperinterfaceContext();
|
|
1813
|
+
var threadContext = useSuperinterfaceContext();
|
|
1814
|
+
var props = useMutation2(_object_spread({
|
|
1815
|
+
onSettled: onSettled2({
|
|
1816
|
+
queryClient: queryClient
|
|
1801
1817
|
})
|
|
1818
|
+
}, mutationOptions({
|
|
1819
|
+
mutationKeyBase: [
|
|
1820
|
+
"handleAction"
|
|
1821
|
+
],
|
|
1822
|
+
path: "/actions",
|
|
1823
|
+
queryClient: queryClient,
|
|
1824
|
+
threadContext: threadContext,
|
|
1825
|
+
superinterfaceContext: superinterfaceContext
|
|
1826
|
+
})));
|
|
1827
|
+
return _object_spread_props(_object_spread({}, props), {
|
|
1828
|
+
handleAction: partob2(props.mutate, threadContext.variables)
|
|
1802
1829
|
});
|
|
1803
1830
|
};
|
|
1804
|
-
// src/
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
var
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
})
|
|
1841
|
-
]
|
|
1842
|
-
});
|
|
1843
|
-
};
|
|
1844
|
-
// src/components/threadMessages/ThreadMessages/Progress/index.tsx
|
|
1845
|
-
import { jsx as jsx33, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1846
|
-
var Progress = function(param) {
|
|
1847
|
-
var latestThreadMessage = param.latestThreadMessage, isRunActive2 = param.isRunActive;
|
|
1848
|
-
if (!latestThreadMessage) return null;
|
|
1849
|
-
if (!isRunActive2) return null;
|
|
1850
|
-
if (latestThreadMessage.role === "user") {
|
|
1851
|
-
return /* @__PURE__ */ jsx33(StartingSkeleton, {});
|
|
1852
|
-
}
|
|
1853
|
-
return /* @__PURE__ */ jsxs9(ThreadMessagesGroupBase, {
|
|
1854
|
-
children: [
|
|
1855
|
-
/* @__PURE__ */ jsx33(Box11, {
|
|
1856
|
-
pl: "5"
|
|
1857
|
-
}),
|
|
1858
|
-
/* @__PURE__ */ jsx33(StartingContentSkeleton, {})
|
|
1859
|
-
]
|
|
1860
|
-
});
|
|
1831
|
+
// src/hooks/actions/useManageActions/index.tsx
|
|
1832
|
+
var useManageActions = function() {
|
|
1833
|
+
var queryClient = useQueryClient8();
|
|
1834
|
+
var threadContext = useSuperinterfaceContext();
|
|
1835
|
+
var latestRunProps = useLatestRun();
|
|
1836
|
+
var handleActionProps = useHandleAction();
|
|
1837
|
+
useEffect3(function() {
|
|
1838
|
+
if (handleActionProps.isPending) return;
|
|
1839
|
+
if (latestRunProps.isFetching) return;
|
|
1840
|
+
if (!latestRunProps.latestRun) return;
|
|
1841
|
+
if (latestRunProps.latestRun.status !== "requires_action") return;
|
|
1842
|
+
var isMutating = queryClient.isMutating({
|
|
1843
|
+
mutationKey: [
|
|
1844
|
+
"handleAction",
|
|
1845
|
+
threadContext.variables
|
|
1846
|
+
]
|
|
1847
|
+
});
|
|
1848
|
+
if (isMutating) return;
|
|
1849
|
+
console.log("requires action", {
|
|
1850
|
+
latestRunProps: latestRunProps
|
|
1851
|
+
});
|
|
1852
|
+
handleActionProps.handleAction({
|
|
1853
|
+
latestRun: latestRunProps.latestRun
|
|
1854
|
+
});
|
|
1855
|
+
}, [
|
|
1856
|
+
handleActionProps,
|
|
1857
|
+
latestRunProps
|
|
1858
|
+
]);
|
|
1859
|
+
return null;
|
|
1860
|
+
};
|
|
1861
|
+
// src/hooks/threads/useLifecycle/index.tsx
|
|
1862
|
+
var useLifecycle = function() {
|
|
1863
|
+
useManageRuns();
|
|
1864
|
+
useManageActions();
|
|
1865
|
+
usePolling();
|
|
1866
|
+
return null;
|
|
1861
1867
|
};
|
|
1862
|
-
// src/components/
|
|
1868
|
+
// src/components/threads/Thread/Messages/Root/index.tsx
|
|
1863
1869
|
import { jsx as jsx34, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1864
|
-
var
|
|
1870
|
+
var Root = function(param) {
|
|
1865
1871
|
var children = param.children, _param_style = param.style, style = _param_style === void 0 ? {} : _param_style;
|
|
1866
|
-
var
|
|
1867
|
-
|
|
1872
|
+
var _useMessages = useMessages(), isFetchingNextPage = _useMessages.isFetchingNextPage, hasNextPage = _useMessages.hasNextPage, fetchNextPage = _useMessages.fetchNextPage;
|
|
1873
|
+
useLifecycle();
|
|
1868
1874
|
var _useInfiniteScroll = useInfiniteScroll({
|
|
1869
1875
|
isFetchingNextPage: isFetchingNextPage,
|
|
1870
1876
|
hasNextPage: hasNextPage,
|
|
1871
1877
|
fetchNextPage: fetchNextPage
|
|
1872
1878
|
}), containerRef = _useInfiniteScroll.containerRef, loaderRef = _useInfiniteScroll.loaderRef;
|
|
1873
|
-
var _useIsRunActive = useIsRunActive(), isRunActive2 = _useIsRunActive.isRunActive;
|
|
1874
|
-
var latestThreadMessage = useLatestThreadMessage().latestThreadMessage;
|
|
1875
1879
|
return /* @__PURE__ */ jsxs10(Flex12, {
|
|
1876
1880
|
ref: containerRef,
|
|
1877
1881
|
direction: "column-reverse",
|
|
1878
|
-
|
|
1882
|
+
flexGrow: "1",
|
|
1879
1883
|
style: _object_spread_props(_object_spread({}, style), {
|
|
1880
1884
|
overflow: "auto"
|
|
1881
1885
|
}),
|
|
1882
1886
|
children: [
|
|
1883
|
-
/* @__PURE__ */ jsx34(Flex12, {
|
|
1884
|
-
shrink: "0",
|
|
1885
|
-
style: {
|
|
1886
|
-
height: "var(--space-3)"
|
|
1887
|
-
}
|
|
1888
|
-
}),
|
|
1889
|
-
/* @__PURE__ */ jsx34(Progress, {
|
|
1890
|
-
latestThreadMessage: latestThreadMessage,
|
|
1891
|
-
isRunActive: isRunActive2
|
|
1892
|
-
}),
|
|
1893
1887
|
children,
|
|
1894
|
-
/* @__PURE__ */ jsx34(
|
|
1895
|
-
threadMessages: threadMessages2,
|
|
1896
|
-
isLoading: isLoading,
|
|
1897
|
-
isLoadingError: isLoadingError
|
|
1898
|
-
}),
|
|
1899
|
-
hasNextPage && /* @__PURE__ */ jsx34(ThreadMessagesSkeleton, {
|
|
1888
|
+
hasNextPage && /* @__PURE__ */ jsx34(Flex12, {
|
|
1900
1889
|
ref: loaderRef
|
|
1901
1890
|
}),
|
|
1902
1891
|
/* @__PURE__ */ jsx34(Flex12, {
|
|
1903
|
-
|
|
1904
|
-
|
|
1892
|
+
flexShrink: "0",
|
|
1893
|
+
flexGrow: "1"
|
|
1905
1894
|
})
|
|
1906
1895
|
]
|
|
1907
1896
|
});
|
|
1908
1897
|
};
|
|
1909
|
-
// src/components/
|
|
1910
|
-
import { Container as Container2, Flex as Flex13, Text as Text5 } from "@radix-ui/themes";
|
|
1911
|
-
import { useRef as useRef3, useEffect as useEffect4, useMemo as useMemo9, useContext as useContext7 } from "react";
|
|
1912
|
-
import { useForm } from "react-hook-form";
|
|
1913
|
-
import { usePrevious } from "react-use";
|
|
1914
|
-
// src/components/textareas/TextareaBase/index.tsx
|
|
1915
|
-
import { forwardRef as forwardRef3 } from "react";
|
|
1916
|
-
import TextareaAutosize from "react-textarea-autosize";
|
|
1898
|
+
// src/components/threads/Thread/Messages/NextPageSkeleton.tsx
|
|
1917
1899
|
import { jsx as jsx35 } from "react/jsx-runtime";
|
|
1918
|
-
var
|
|
1919
|
-
var
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1900
|
+
var NextPageSkeleton = function() {
|
|
1901
|
+
var hasNextPage = useMessages().hasNextPage;
|
|
1902
|
+
if (!hasNextPage) {
|
|
1903
|
+
return null;
|
|
1904
|
+
}
|
|
1905
|
+
return /* @__PURE__ */ jsx35(MessagesSkeleton, {});
|
|
1906
|
+
};
|
|
1907
|
+
// src/components/threads/Thread/Messages/index.tsx
|
|
1908
|
+
import { jsx as jsx36, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1909
|
+
var Messages = function(param) {
|
|
1910
|
+
var children = param.children, _param_style = param.style, style = _param_style === void 0 ? {} : _param_style;
|
|
1911
|
+
return /* @__PURE__ */ jsxs11(Root, {
|
|
1912
|
+
style: style,
|
|
1913
|
+
children: [
|
|
1914
|
+
/* @__PURE__ */ jsx36(Flex13, {
|
|
1915
|
+
flexShrink: "0",
|
|
1916
|
+
height: "var(--space-3)"
|
|
1917
|
+
}),
|
|
1918
|
+
/* @__PURE__ */ jsx36(Progress, {}),
|
|
1919
|
+
children,
|
|
1920
|
+
/* @__PURE__ */ jsx36(Content3, {}),
|
|
1921
|
+
/* @__PURE__ */ jsx36(NextPageSkeleton, {}),
|
|
1922
|
+
/* @__PURE__ */ jsx36(Flex13, {
|
|
1923
|
+
flexShrink: "0",
|
|
1924
|
+
flexGrow: "1"
|
|
1925
|
+
})
|
|
1926
|
+
]
|
|
1927
|
+
});
|
|
1928
|
+
};
|
|
1929
|
+
Messages.Root = Root;
|
|
1930
|
+
Messages.Message = Message;
|
|
1931
|
+
Messages.NextPageSkeleton = NextPageSkeleton;
|
|
1932
|
+
// src/components/threads/Thread/MessageForm/index.tsx
|
|
1933
|
+
import { Flex as Flex15, Text as Text5 } from "@radix-ui/themes";
|
|
1934
|
+
// src/components/threads/Thread/MessageForm/Submit/index.tsx
|
|
1935
|
+
import { ArrowUpIcon } from "@radix-ui/react-icons";
|
|
1936
|
+
import { Button as Button2 } from "@radix-ui/themes";
|
|
1937
|
+
// src/components/spinners/Spinner/index.tsx
|
|
1938
|
+
import { jsx as jsx37 } from "react/jsx-runtime";
|
|
1939
|
+
var Spinner = function(props) {
|
|
1940
|
+
return /* @__PURE__ */ jsx37("svg", _object_spread_props(_object_spread({
|
|
1941
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1942
|
+
width: "24",
|
|
1943
|
+
height: "24",
|
|
1944
|
+
viewBox: "0 0 24 24",
|
|
1945
|
+
fill: "none",
|
|
1946
|
+
stroke: "currentColor",
|
|
1947
|
+
strokeWidth: "2",
|
|
1948
|
+
strokeLinecap: "round",
|
|
1949
|
+
strokeLinejoin: "round",
|
|
1923
1950
|
style: {
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
transform: "scale(".concat(1 / UPSCALE_RATIO, ")"),
|
|
1928
|
-
margin: "0 ".concat((-100 * UPSCALE_RATIO + 100) / 2, "%"),
|
|
1929
|
-
width: "".concat(100 * UPSCALE_RATIO, "%"),
|
|
1930
|
-
maxWidth: "".concat(100 * UPSCALE_RATIO, "%"),
|
|
1931
|
-
flexGrow: 1,
|
|
1932
|
-
display: "flex"
|
|
1951
|
+
height: "var(--space-4)",
|
|
1952
|
+
width: "var(--space-4)",
|
|
1953
|
+
animation: "spin 1s linear infinite"
|
|
1933
1954
|
}
|
|
1934
|
-
}, props)
|
|
1955
|
+
}, props), {
|
|
1956
|
+
children: /* @__PURE__ */ jsx37("path", {
|
|
1957
|
+
d: "M21 12a9 9 0 1 1-6.219-8.56"
|
|
1958
|
+
})
|
|
1959
|
+
}));
|
|
1960
|
+
};
|
|
1961
|
+
// src/hooks/messages/useMessageFormContext/index.ts
|
|
1962
|
+
import { useContext as useContext7 } from "react";
|
|
1963
|
+
// src/contexts/messages/MessageFormContext/index.ts
|
|
1964
|
+
import { createContext as createContext6 } from "react";
|
|
1965
|
+
var MessageFormContext = createContext6({
|
|
1966
|
+
isDisabled: false,
|
|
1967
|
+
isLoading: false,
|
|
1968
|
+
submit: function() {}
|
|
1935
1969
|
});
|
|
1936
|
-
// src/hooks/
|
|
1970
|
+
// src/hooks/messages/useMessageFormContext/index.ts
|
|
1971
|
+
var useMessageFormContext = function() {
|
|
1972
|
+
return useContext7(MessageFormContext);
|
|
1973
|
+
};
|
|
1974
|
+
// src/components/threads/Thread/MessageForm/Submit/index.tsx
|
|
1975
|
+
import { jsx as jsx38 } from "react/jsx-runtime";
|
|
1976
|
+
var Submit = function() {
|
|
1977
|
+
var _useMessageFormContext = useMessageFormContext(), isDisabled = _useMessageFormContext.isDisabled, isLoading = _useMessageFormContext.isLoading;
|
|
1978
|
+
return /* @__PURE__ */ jsx38(Button2, {
|
|
1979
|
+
type: "submit",
|
|
1980
|
+
radius: "large",
|
|
1981
|
+
disabled: isDisabled,
|
|
1982
|
+
children: isLoading ? /* @__PURE__ */ jsx38(Spinner, {}) : /* @__PURE__ */ jsx38(ArrowUpIcon, {})
|
|
1983
|
+
});
|
|
1984
|
+
};
|
|
1985
|
+
// src/components/threads/Thread/MessageForm/Root/index.tsx
|
|
1986
|
+
import { useMemo as useMemo9 } from "react";
|
|
1987
|
+
import { useForm, FormProvider } from "react-hook-form";
|
|
1988
|
+
// src/hooks/messages/useCreateMessage/index.ts
|
|
1937
1989
|
import { partob as partob3 } from "radash";
|
|
1938
1990
|
import { useMutation as useMutation3, useQueryClient as useQueryClient9 } from "@tanstack/react-query";
|
|
1939
|
-
// src/hooks/
|
|
1991
|
+
// src/hooks/messages/useCreateMessage/lib/mutationOptions/onMutate/index.ts
|
|
1940
1992
|
import { omit } from "radash";
|
|
1941
|
-
// src/hooks/
|
|
1993
|
+
// src/hooks/messages/useCreateMessage/lib/mutationOptions/onMutate/data.ts
|
|
1942
1994
|
var data2 = function(param) {
|
|
1943
|
-
var
|
|
1995
|
+
var newMessage = param.newMessage;
|
|
1944
1996
|
return function(prevData) {
|
|
1945
1997
|
var message = {
|
|
1946
1998
|
id: optimisticId(),
|
|
@@ -1952,7 +2004,7 @@ var data2 = function(param) {
|
|
|
1952
2004
|
type: "text",
|
|
1953
2005
|
text: {
|
|
1954
2006
|
annotations: [],
|
|
1955
|
-
value:
|
|
2007
|
+
value: newMessage.content
|
|
1956
2008
|
}
|
|
1957
2009
|
}
|
|
1958
2010
|
],
|
|
@@ -1989,18 +2041,18 @@ var data2 = function(param) {
|
|
|
1989
2041
|
});
|
|
1990
2042
|
};
|
|
1991
2043
|
};
|
|
1992
|
-
// src/hooks/
|
|
2044
|
+
// src/hooks/messages/useCreateMessage/lib/mutationOptions/onMutate/index.ts
|
|
1993
2045
|
var onMutate2 = function(param) {
|
|
1994
2046
|
var queryClient = param.queryClient;
|
|
1995
2047
|
return function() {
|
|
1996
|
-
var _ref = _async_to_generator(function(
|
|
1997
|
-
var queryKey,
|
|
2048
|
+
var _ref = _async_to_generator(function(newMessage) {
|
|
2049
|
+
var queryKey, prevMessages;
|
|
1998
2050
|
return _ts_generator(this, function(_state) {
|
|
1999
2051
|
switch(_state.label){
|
|
2000
2052
|
case 0:
|
|
2001
2053
|
queryKey = [
|
|
2002
|
-
"
|
|
2003
|
-
omit(
|
|
2054
|
+
"messages",
|
|
2055
|
+
omit(newMessage, [
|
|
2004
2056
|
"content"
|
|
2005
2057
|
])
|
|
2006
2058
|
];
|
|
@@ -2012,26 +2064,26 @@ var onMutate2 = function(param) {
|
|
|
2012
2064
|
];
|
|
2013
2065
|
case 1:
|
|
2014
2066
|
_state.sent();
|
|
2015
|
-
|
|
2067
|
+
prevMessages = queryClient.getQueryData(queryKey);
|
|
2016
2068
|
queryClient.setQueryData(queryKey, data2({
|
|
2017
|
-
|
|
2069
|
+
newMessage: newMessage
|
|
2018
2070
|
}));
|
|
2019
2071
|
return [
|
|
2020
2072
|
2,
|
|
2021
2073
|
{
|
|
2022
|
-
|
|
2023
|
-
|
|
2074
|
+
prevMessages: prevMessages,
|
|
2075
|
+
newMessage: newMessage
|
|
2024
2076
|
}
|
|
2025
2077
|
];
|
|
2026
2078
|
}
|
|
2027
2079
|
});
|
|
2028
2080
|
});
|
|
2029
|
-
return function(
|
|
2081
|
+
return function(newMessage) {
|
|
2030
2082
|
return _ref.apply(this, arguments);
|
|
2031
2083
|
};
|
|
2032
2084
|
}();
|
|
2033
2085
|
};
|
|
2034
|
-
// src/hooks/
|
|
2086
|
+
// src/hooks/messages/useCreateMessage/lib/mutationOptions/onSettled.ts
|
|
2035
2087
|
import { omit as omit2 } from "radash";
|
|
2036
2088
|
var onSettled3 = function(param) {
|
|
2037
2089
|
var queryClient = param.queryClient;
|
|
@@ -2044,7 +2096,7 @@ var onSettled3 = function(param) {
|
|
|
2044
2096
|
4,
|
|
2045
2097
|
queryClient.invalidateQueries({
|
|
2046
2098
|
queryKey: [
|
|
2047
|
-
"
|
|
2099
|
+
"messages",
|
|
2048
2100
|
omit2(variables, [
|
|
2049
2101
|
"content"
|
|
2050
2102
|
])
|
|
@@ -2077,8 +2129,8 @@ var onSettled3 = function(param) {
|
|
|
2077
2129
|
};
|
|
2078
2130
|
}();
|
|
2079
2131
|
};
|
|
2080
|
-
// src/hooks/
|
|
2081
|
-
var
|
|
2132
|
+
// src/hooks/messages/useCreateMessage/index.ts
|
|
2133
|
+
var useCreateMessage = function() {
|
|
2082
2134
|
var queryClient = useQueryClient9();
|
|
2083
2135
|
var superinterfaceContext = useSuperinterfaceContext();
|
|
2084
2136
|
var threadContext = useSuperinterfaceContext();
|
|
@@ -2091,69 +2143,32 @@ var useCreateThreadMessage = function() {
|
|
|
2091
2143
|
})
|
|
2092
2144
|
}, mutationOptions({
|
|
2093
2145
|
mutationKeyBase: [
|
|
2094
|
-
"
|
|
2146
|
+
"createMessage"
|
|
2095
2147
|
],
|
|
2096
|
-
path: "/
|
|
2148
|
+
path: "/messages",
|
|
2097
2149
|
queryClient: queryClient,
|
|
2098
2150
|
threadContext: threadContext,
|
|
2099
2151
|
superinterfaceContext: superinterfaceContext
|
|
2100
2152
|
})));
|
|
2101
2153
|
return _object_spread_props(_object_spread({}, props), {
|
|
2102
|
-
|
|
2103
|
-
});
|
|
2104
|
-
};
|
|
2105
|
-
// src/components/threadMessages/ThreadMessageForm/Submit/index.tsx
|
|
2106
|
-
import { ArrowUpIcon } from "@radix-ui/react-icons";
|
|
2107
|
-
import { Button as Button2 } from "@radix-ui/themes";
|
|
2108
|
-
// src/components/spinners/Spinner/index.tsx
|
|
2109
|
-
import { jsx as jsx36 } from "react/jsx-runtime";
|
|
2110
|
-
var Spinner = function(props) {
|
|
2111
|
-
return /* @__PURE__ */ jsx36("svg", _object_spread_props(_object_spread({
|
|
2112
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
2113
|
-
width: "24",
|
|
2114
|
-
height: "24",
|
|
2115
|
-
viewBox: "0 0 24 24",
|
|
2116
|
-
fill: "none",
|
|
2117
|
-
stroke: "currentColor",
|
|
2118
|
-
strokeWidth: "2",
|
|
2119
|
-
strokeLinecap: "round",
|
|
2120
|
-
strokeLinejoin: "round",
|
|
2121
|
-
style: {
|
|
2122
|
-
height: "var(--space-4)",
|
|
2123
|
-
width: "var(--space-4)",
|
|
2124
|
-
animation: "spin 1s linear infinite"
|
|
2125
|
-
}
|
|
2126
|
-
}, props), {
|
|
2127
|
-
children: /* @__PURE__ */ jsx36("path", {
|
|
2128
|
-
d: "M21 12a9 9 0 1 1-6.219-8.56"
|
|
2129
|
-
})
|
|
2130
|
-
}));
|
|
2131
|
-
};
|
|
2132
|
-
// src/components/threadMessages/ThreadMessageForm/Submit/index.tsx
|
|
2133
|
-
import { jsx as jsx37 } from "react/jsx-runtime";
|
|
2134
|
-
var Submit = function(param) {
|
|
2135
|
-
var isLoading = param.isLoading, isDisabled = param.isDisabled;
|
|
2136
|
-
return /* @__PURE__ */ jsx37(Button2, {
|
|
2137
|
-
type: "submit",
|
|
2138
|
-
radius: "large",
|
|
2139
|
-
disabled: isDisabled,
|
|
2140
|
-
children: isLoading ? /* @__PURE__ */ jsx37(Spinner, {}) : /* @__PURE__ */ jsx37(ArrowUpIcon, {})
|
|
2154
|
+
createMessage: partob3(props.mutateAsync, threadContext.variables)
|
|
2141
2155
|
});
|
|
2142
2156
|
};
|
|
2143
|
-
// src/components/
|
|
2157
|
+
// src/components/threads/Thread/MessageForm/Root/lib/formOptions.ts
|
|
2144
2158
|
import { z } from "zod";
|
|
2145
2159
|
import { zodResolver } from "@hookform/resolvers/zod";
|
|
2146
2160
|
var schema = z.object({
|
|
2147
2161
|
content: z.string().min(1)
|
|
2148
2162
|
});
|
|
2149
|
-
var
|
|
2163
|
+
var formOptions = {
|
|
2150
2164
|
resolver: zodResolver(schema)
|
|
2151
2165
|
};
|
|
2152
|
-
// src/components/
|
|
2153
|
-
import { jsx as
|
|
2154
|
-
var
|
|
2155
|
-
var
|
|
2156
|
-
var
|
|
2166
|
+
// src/components/threads/Thread/MessageForm/Root/index.tsx
|
|
2167
|
+
import { jsx as jsx39 } from "react/jsx-runtime";
|
|
2168
|
+
var Root2 = function(param) {
|
|
2169
|
+
var children = param.children;
|
|
2170
|
+
var formProps = useForm(formOptions);
|
|
2171
|
+
var handleSubmit = formProps.handleSubmit, isSubmitting = formProps.formState.isSubmitting, reset = formProps.reset;
|
|
2157
2172
|
var _useIsRunActive = useIsRunActive(), isRunActive2 = _useIsRunActive.isRunActive;
|
|
2158
2173
|
var isLoading = useMemo9(function() {
|
|
2159
2174
|
return isRunActive2 || isSubmitting;
|
|
@@ -2161,7 +2176,7 @@ var ThreadMessageForm = function() {
|
|
|
2161
2176
|
isRunActive2,
|
|
2162
2177
|
isSubmitting
|
|
2163
2178
|
]);
|
|
2164
|
-
var
|
|
2179
|
+
var createMessage = useCreateMessage().createMessage;
|
|
2165
2180
|
var onSubmit = function() {
|
|
2166
2181
|
var _ref = _async_to_generator(function(data3) {
|
|
2167
2182
|
return _ts_generator(this, function(_state) {
|
|
@@ -2170,7 +2185,7 @@ var ThreadMessageForm = function() {
|
|
|
2170
2185
|
reset();
|
|
2171
2186
|
return [
|
|
2172
2187
|
4,
|
|
2173
|
-
|
|
2188
|
+
createMessage({
|
|
2174
2189
|
content: data3.content
|
|
2175
2190
|
})
|
|
2176
2191
|
];
|
|
@@ -2186,16 +2201,92 @@ var ThreadMessageForm = function() {
|
|
|
2186
2201
|
return _ref.apply(this, arguments);
|
|
2187
2202
|
};
|
|
2188
2203
|
}();
|
|
2189
|
-
var
|
|
2204
|
+
var latestMessage = useLatestMessage().latestMessage;
|
|
2190
2205
|
var isDisabled = useMemo9(function() {
|
|
2191
2206
|
var // @ts-ignore-next-line
|
|
2192
|
-
|
|
2193
|
-
return
|
|
2207
|
+
_latestMessage_metadata;
|
|
2208
|
+
return latestMessage === null || latestMessage === void 0 ? void 0 : (_latestMessage_metadata = latestMessage.metadata) === null || _latestMessage_metadata === void 0 ? void 0 : _latestMessage_metadata.isBlocking;
|
|
2194
2209
|
}, [
|
|
2195
|
-
|
|
2210
|
+
latestMessage,
|
|
2196
2211
|
isLoading
|
|
2197
2212
|
]);
|
|
2198
|
-
|
|
2213
|
+
return /* @__PURE__ */ jsx39(MessageFormContext.Provider, {
|
|
2214
|
+
value: {
|
|
2215
|
+
isDisabled: isDisabled,
|
|
2216
|
+
isLoading: isLoading,
|
|
2217
|
+
submit: handleSubmit(onSubmit)
|
|
2218
|
+
},
|
|
2219
|
+
children: /* @__PURE__ */ jsx39(FormProvider, _object_spread_props(_object_spread({}, formProps), {
|
|
2220
|
+
children: /* @__PURE__ */ jsx39("form", {
|
|
2221
|
+
onSubmit: handleSubmit(onSubmit),
|
|
2222
|
+
children: children
|
|
2223
|
+
})
|
|
2224
|
+
}))
|
|
2225
|
+
});
|
|
2226
|
+
};
|
|
2227
|
+
// src/components/threads/Thread/MessageForm/Field/index.tsx
|
|
2228
|
+
import { usePrevious } from "react-use";
|
|
2229
|
+
import { useContext as useContext8, useMemo as useMemo10, useRef as useRef3, useEffect as useEffect4 } from "react";
|
|
2230
|
+
// src/components/textareas/TextareaBase/index.tsx
|
|
2231
|
+
import { forwardRef as forwardRef3 } from "react";
|
|
2232
|
+
import TextareaAutosize from "react-textarea-autosize";
|
|
2233
|
+
import { jsx as jsx40 } from "react/jsx-runtime";
|
|
2234
|
+
var UPSCALE_RATIO = 16 / 14;
|
|
2235
|
+
var TextareaBase = forwardRef3(function TextareaBase2(props, ref) {
|
|
2236
|
+
return /* @__PURE__ */ jsx40(TextareaAutosize, _object_spread({
|
|
2237
|
+
ref: ref,
|
|
2238
|
+
className: "textarea-base",
|
|
2239
|
+
style: {
|
|
2240
|
+
resize: "none",
|
|
2241
|
+
fontSize: "".concat(14 * UPSCALE_RATIO, "px"),
|
|
2242
|
+
lineHeight: "".concat(24 * UPSCALE_RATIO, "px"),
|
|
2243
|
+
transform: "scale(".concat(1 / UPSCALE_RATIO, ")"),
|
|
2244
|
+
margin: "0 ".concat((-100 * UPSCALE_RATIO + 100) / 2, "%"),
|
|
2245
|
+
width: "".concat(100 * UPSCALE_RATIO, "%"),
|
|
2246
|
+
maxWidth: "".concat(100 * UPSCALE_RATIO, "%"),
|
|
2247
|
+
flexGrow: 1,
|
|
2248
|
+
display: "flex"
|
|
2249
|
+
}
|
|
2250
|
+
}, props));
|
|
2251
|
+
});
|
|
2252
|
+
// src/components/threads/Thread/MessageForm/Field/index.tsx
|
|
2253
|
+
import { useFormContext } from "react-hook-form";
|
|
2254
|
+
import { Container as Container2, Flex as Flex14 } from "@radix-ui/themes";
|
|
2255
|
+
import { jsx as jsx41 } from "react/jsx-runtime";
|
|
2256
|
+
var Root3 = function(param) {
|
|
2257
|
+
var children = param.children;
|
|
2258
|
+
var _useFormContext = useFormContext(), errors = _useFormContext.formState.errors;
|
|
2259
|
+
return /* @__PURE__ */ jsx41(Container2, {
|
|
2260
|
+
size: "2",
|
|
2261
|
+
flexGrow: "0",
|
|
2262
|
+
children: /* @__PURE__ */ jsx41(Flex14, {
|
|
2263
|
+
direction: "column",
|
|
2264
|
+
flexShrink: "0",
|
|
2265
|
+
children: /* @__PURE__ */ jsx41(Flex14, {
|
|
2266
|
+
direction: "column",
|
|
2267
|
+
flexShrink: "0",
|
|
2268
|
+
children: /* @__PURE__ */ jsx41(Flex14, {
|
|
2269
|
+
style: _object_spread({
|
|
2270
|
+
borderRadius: "var(--radius-2)",
|
|
2271
|
+
borderWidth: "1px",
|
|
2272
|
+
borderStyle: "solid",
|
|
2273
|
+
borderColor: errors.content ? "var(--red-9)" : "var(--gray-5)"
|
|
2274
|
+
}, errors.content ? {
|
|
2275
|
+
backgroundColor: "var(--red-2)"
|
|
2276
|
+
} : {}),
|
|
2277
|
+
p: "2",
|
|
2278
|
+
pl: "4",
|
|
2279
|
+
children: children
|
|
2280
|
+
})
|
|
2281
|
+
})
|
|
2282
|
+
})
|
|
2283
|
+
});
|
|
2284
|
+
};
|
|
2285
|
+
var Control = function() {
|
|
2286
|
+
var assistantNameContext = useContext8(AssistantNameContext);
|
|
2287
|
+
var register = useFormContext().register;
|
|
2288
|
+
var _useMessageFormContext = useMessageFormContext(), isDisabled = _useMessageFormContext.isDisabled, isLoading = _useMessageFormContext.isLoading, submit = _useMessageFormContext.submit;
|
|
2289
|
+
var isSubmitDisabled = useMemo10(function() {
|
|
2199
2290
|
return isDisabled || isLoading;
|
|
2200
2291
|
}, [
|
|
2201
2292
|
isDisabled,
|
|
@@ -2214,123 +2305,108 @@ var ThreadMessageForm = function() {
|
|
|
2214
2305
|
isDisabledPrevious,
|
|
2215
2306
|
textareaProps
|
|
2216
2307
|
]);
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
borderWidth: "1px",
|
|
2236
|
-
borderStyle: "solid",
|
|
2237
|
-
borderColor: errors.content ? "var(--red-9)" : "var(--gray-5)"
|
|
2238
|
-
}, errors.content ? {
|
|
2239
|
-
backgroundColor: "var(--red-2)"
|
|
2240
|
-
} : {}),
|
|
2241
|
-
p: "2",
|
|
2242
|
-
pl: "4",
|
|
2243
|
-
children: [
|
|
2244
|
-
/* @__PURE__ */ jsx38(Text5, {
|
|
2245
|
-
size: "2",
|
|
2246
|
-
style: {
|
|
2247
|
-
flexGrow: 1
|
|
2248
|
-
},
|
|
2249
|
-
children: /* @__PURE__ */ jsx38(Flex13, {
|
|
2250
|
-
grow: "1",
|
|
2251
|
-
direction: "column",
|
|
2252
|
-
children: /* @__PURE__ */ jsx38(TextareaBase, _object_spread_props(_object_spread({
|
|
2253
|
-
minRows: 1,
|
|
2254
|
-
placeholder: "Message ".concat(assistantNameContext, "..."),
|
|
2255
|
-
disabled: isDisabled,
|
|
2256
|
-
onKeyDown: function(e) {
|
|
2257
|
-
if (e.key === "Enter" && !e.shiftKey) {
|
|
2258
|
-
e.preventDefault();
|
|
2259
|
-
if (isSubmitDisabled) return;
|
|
2260
|
-
handleSubmit(onSubmit)();
|
|
2261
|
-
}
|
|
2262
|
-
},
|
|
2263
|
-
autoFocus: true
|
|
2264
|
-
}, textareaProps), {
|
|
2265
|
-
ref: function(e) {
|
|
2266
|
-
textareaProps.ref(e);
|
|
2267
|
-
textareaRef.current = e;
|
|
2268
|
-
}
|
|
2269
|
-
}))
|
|
2270
|
-
})
|
|
2271
|
-
}),
|
|
2272
|
-
/* @__PURE__ */ jsx38(Flex13, {
|
|
2273
|
-
shrink: "0",
|
|
2274
|
-
align: "end",
|
|
2275
|
-
children: /* @__PURE__ */ jsx38(Submit, {
|
|
2276
|
-
isLoading: isLoading,
|
|
2277
|
-
isDisabled: isSubmitDisabled
|
|
2278
|
-
})
|
|
2279
|
-
})
|
|
2280
|
-
]
|
|
2281
|
-
})
|
|
2282
|
-
})
|
|
2283
|
-
})
|
|
2284
|
-
})
|
|
2285
|
-
]
|
|
2286
|
-
});
|
|
2308
|
+
return /* @__PURE__ */ jsx41(TextareaBase, _object_spread_props(_object_spread({
|
|
2309
|
+
minRows: 1,
|
|
2310
|
+
placeholder: "Message ".concat(assistantNameContext, "..."),
|
|
2311
|
+
disabled: isDisabled,
|
|
2312
|
+
onKeyDown: function(e) {
|
|
2313
|
+
if (e.key === "Enter" && !e.shiftKey) {
|
|
2314
|
+
e.preventDefault();
|
|
2315
|
+
if (isSubmitDisabled) return;
|
|
2316
|
+
submit();
|
|
2317
|
+
}
|
|
2318
|
+
},
|
|
2319
|
+
autoFocus: true
|
|
2320
|
+
}, textareaProps), {
|
|
2321
|
+
ref: function(e) {
|
|
2322
|
+
textareaProps.ref(e);
|
|
2323
|
+
textareaRef.current = e;
|
|
2324
|
+
}
|
|
2325
|
+
}));
|
|
2287
2326
|
};
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2327
|
+
var Field = {
|
|
2328
|
+
Root: Root3,
|
|
2329
|
+
Control: Control
|
|
2330
|
+
};
|
|
2331
|
+
// src/components/threads/Thread/MessageForm/index.tsx
|
|
2332
|
+
import { jsx as jsx42, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
2333
|
+
var MessageForm = function() {
|
|
2334
|
+
return /* @__PURE__ */ jsx42(Root2, {
|
|
2335
|
+
children: /* @__PURE__ */ jsxs12(Field.Root, {
|
|
2295
2336
|
children: [
|
|
2296
|
-
/* @__PURE__ */
|
|
2337
|
+
/* @__PURE__ */ jsx42(Text5, {
|
|
2338
|
+
size: "2",
|
|
2297
2339
|
style: {
|
|
2298
|
-
|
|
2299
|
-
}
|
|
2340
|
+
flexGrow: 1
|
|
2341
|
+
},
|
|
2342
|
+
children: /* @__PURE__ */ jsx42(Flex15, {
|
|
2343
|
+
flexGrow: "1",
|
|
2344
|
+
direction: "column",
|
|
2345
|
+
children: /* @__PURE__ */ jsx42(Field.Control, {})
|
|
2346
|
+
})
|
|
2300
2347
|
}),
|
|
2301
|
-
/* @__PURE__ */
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
paddingBottom: "var(--space-5)"
|
|
2306
|
-
}
|
|
2348
|
+
/* @__PURE__ */ jsx42(Flex15, {
|
|
2349
|
+
flexShrink: "0",
|
|
2350
|
+
align: "end",
|
|
2351
|
+
children: /* @__PURE__ */ jsx42(Submit, {})
|
|
2307
2352
|
})
|
|
2308
2353
|
]
|
|
2309
2354
|
})
|
|
2355
|
+
});
|
|
2356
|
+
};
|
|
2357
|
+
MessageForm.Root = Root2;
|
|
2358
|
+
MessageForm.Field = Field;
|
|
2359
|
+
MessageForm.Submit = Submit;
|
|
2360
|
+
// src/components/threads/Thread/Root/index.tsx
|
|
2361
|
+
import { Flex as Flex16 } from "@radix-ui/themes";
|
|
2362
|
+
import { jsx as jsx43 } from "react/jsx-runtime";
|
|
2363
|
+
var Root4 = function(_param) {
|
|
2364
|
+
var children = _param.children, rest = _object_without_properties(_param, [
|
|
2365
|
+
"children"
|
|
2366
|
+
]);
|
|
2367
|
+
return /* @__PURE__ */ jsx43(SuperinterfaceProvider, _object_spread_props(_object_spread({}, rest), {
|
|
2368
|
+
children: /* @__PURE__ */ jsx43(Flex16, {
|
|
2369
|
+
direction: "column",
|
|
2370
|
+
flexGrow: "1",
|
|
2371
|
+
children: children
|
|
2372
|
+
})
|
|
2373
|
+
}));
|
|
2374
|
+
};
|
|
2375
|
+
// src/components/threads/Thread/index.tsx
|
|
2376
|
+
import { jsx as jsx44, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
2377
|
+
var Thread = function(props) {
|
|
2378
|
+
return /* @__PURE__ */ jsxs13(Root4, _object_spread_props(_object_spread({}, props), {
|
|
2379
|
+
children: [
|
|
2380
|
+
/* @__PURE__ */ jsx44(Messages, {}),
|
|
2381
|
+
/* @__PURE__ */ jsx44(MessageForm, {})
|
|
2382
|
+
]
|
|
2310
2383
|
}));
|
|
2311
2384
|
};
|
|
2385
|
+
Thread.Root = Root4;
|
|
2386
|
+
Thread.Messages = Messages;
|
|
2387
|
+
Thread.MessageForm = MessageForm;
|
|
2312
2388
|
// src/components/threads/ThreadDialog/Root/index.tsx
|
|
2313
|
-
import { Flex as
|
|
2389
|
+
import { Flex as Flex17 } from "@radix-ui/themes";
|
|
2314
2390
|
// src/components/threads/ThreadDialog/Provider/index.tsx
|
|
2315
2391
|
import { useState } from "react";
|
|
2316
2392
|
// src/contexts/threads/ThreadDialogContext/index.ts
|
|
2317
|
-
import { createContext as
|
|
2318
|
-
var ThreadDialogContext =
|
|
2393
|
+
import { createContext as createContext7 } from "react";
|
|
2394
|
+
var ThreadDialogContext = createContext7({
|
|
2319
2395
|
isOpen: false,
|
|
2320
2396
|
setIsOpen: function() {}
|
|
2321
2397
|
});
|
|
2322
2398
|
// src/hooks/threads/useThreadDialogContext/index.ts
|
|
2323
|
-
import { useContext as
|
|
2399
|
+
import { useContext as useContext9 } from "react";
|
|
2324
2400
|
var useThreadDialogContext = function() {
|
|
2325
|
-
return
|
|
2401
|
+
return useContext9(ThreadDialogContext);
|
|
2326
2402
|
};
|
|
2327
2403
|
// src/components/threads/ThreadDialog/Provider/index.tsx
|
|
2328
|
-
import { jsx as
|
|
2404
|
+
import { jsx as jsx45 } from "react/jsx-runtime";
|
|
2329
2405
|
var Provider = function(param) {
|
|
2330
2406
|
var children = param.children;
|
|
2331
2407
|
var threadDialogContext = useThreadDialogContext();
|
|
2332
2408
|
var _useState = _sliced_to_array(useState(threadDialogContext.isOpen), 2), isOpen = _useState[0], setIsOpen = _useState[1];
|
|
2333
|
-
return /* @__PURE__ */
|
|
2409
|
+
return /* @__PURE__ */ jsx45(ThreadDialogContext.Provider, {
|
|
2334
2410
|
value: {
|
|
2335
2411
|
isOpen: isOpen,
|
|
2336
2412
|
setIsOpen: setIsOpen
|
|
@@ -2339,11 +2415,11 @@ var Provider = function(param) {
|
|
|
2339
2415
|
});
|
|
2340
2416
|
};
|
|
2341
2417
|
// src/components/threads/ThreadDialog/Root/index.tsx
|
|
2342
|
-
import { jsx as
|
|
2343
|
-
var
|
|
2418
|
+
import { jsx as jsx46 } from "react/jsx-runtime";
|
|
2419
|
+
var Root5 = function(param) {
|
|
2344
2420
|
var children = param.children, _param_style = param.style, style = _param_style === void 0 ? {} : _param_style;
|
|
2345
|
-
return /* @__PURE__ */
|
|
2346
|
-
children: /* @__PURE__ */
|
|
2421
|
+
return /* @__PURE__ */ jsx46(Provider, {
|
|
2422
|
+
children: /* @__PURE__ */ jsx46(Flex17, {
|
|
2347
2423
|
direction: "column",
|
|
2348
2424
|
justify: "end",
|
|
2349
2425
|
align: "end",
|
|
@@ -2359,94 +2435,107 @@ var Root = function(param) {
|
|
|
2359
2435
|
});
|
|
2360
2436
|
};
|
|
2361
2437
|
// src/components/threads/ThreadDialog/Trigger/index.tsx
|
|
2362
|
-
import { Flex as
|
|
2363
|
-
import { jsx as
|
|
2438
|
+
import { Flex as Flex18 } from "@radix-ui/themes";
|
|
2439
|
+
import { jsx as jsx47 } from "react/jsx-runtime";
|
|
2364
2440
|
var Trigger = function(param) {
|
|
2365
2441
|
var children = param.children;
|
|
2366
2442
|
var setIsOpen = useThreadDialogContext().setIsOpen;
|
|
2367
|
-
return /* @__PURE__ */
|
|
2443
|
+
return /* @__PURE__ */ jsx47(Flex18, {
|
|
2368
2444
|
onClick: function() {
|
|
2369
2445
|
return setIsOpen(function(prev) {
|
|
2370
2446
|
return !prev;
|
|
2371
2447
|
});
|
|
2372
2448
|
},
|
|
2373
2449
|
direction: "column",
|
|
2374
|
-
|
|
2450
|
+
flexShrink: "0",
|
|
2375
2451
|
children: children
|
|
2376
2452
|
});
|
|
2377
2453
|
};
|
|
2378
2454
|
// src/components/threads/ThreadDialog/Button/index.tsx
|
|
2379
2455
|
import { IconButton } from "@radix-ui/themes";
|
|
2380
2456
|
import { ChatBubbleIcon } from "@radix-ui/react-icons";
|
|
2381
|
-
import { jsx as
|
|
2457
|
+
import { jsx as jsx48 } from "react/jsx-runtime";
|
|
2382
2458
|
var Button3 = function() {
|
|
2383
|
-
return /* @__PURE__ */
|
|
2459
|
+
return /* @__PURE__ */ jsx48(IconButton, {
|
|
2384
2460
|
size: "4",
|
|
2385
2461
|
radius: "full",
|
|
2386
|
-
children: /* @__PURE__ */
|
|
2462
|
+
children: /* @__PURE__ */ jsx48(ChatBubbleIcon, {})
|
|
2387
2463
|
});
|
|
2388
2464
|
};
|
|
2389
2465
|
// src/components/threads/ThreadDialog/Content/index.tsx
|
|
2390
|
-
import { Card, Inset } from "@radix-ui/themes";
|
|
2391
|
-
import {
|
|
2392
|
-
var
|
|
2466
|
+
import { Card, Inset, Flex as Flex19 } from "@radix-ui/themes";
|
|
2467
|
+
import { jsx as jsx49, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
2468
|
+
var Root6 = function(param) {
|
|
2393
2469
|
var children = param.children;
|
|
2394
2470
|
var isOpen = useThreadDialogContext().isOpen;
|
|
2395
2471
|
if (!isOpen) return null;
|
|
2396
|
-
return /* @__PURE__ */
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2472
|
+
return /* @__PURE__ */ jsx49(Card, {
|
|
2473
|
+
mb: "3",
|
|
2474
|
+
style: {
|
|
2475
|
+
display: "flex",
|
|
2476
|
+
flexGrow: 1,
|
|
2477
|
+
width: "100vw",
|
|
2478
|
+
maxWidth: "400px",
|
|
2479
|
+
maxHeight: "720px"
|
|
2480
|
+
},
|
|
2481
|
+
children: /* @__PURE__ */ jsx49(Inset, {
|
|
2482
|
+
clip: "padding-box",
|
|
2483
|
+
side: "all",
|
|
2484
|
+
pb: "current",
|
|
2485
|
+
style: {
|
|
2486
|
+
display: "flex",
|
|
2487
|
+
flexGrow: 1
|
|
2488
|
+
},
|
|
2489
|
+
children: children
|
|
2490
|
+
})
|
|
2491
|
+
});
|
|
2492
|
+
};
|
|
2493
|
+
var Content4 = function() {
|
|
2494
|
+
return /* @__PURE__ */ jsx49(Root6, {
|
|
2495
|
+
children: /* @__PURE__ */ jsxs14(Thread.Root, {
|
|
2496
|
+
children: [
|
|
2497
|
+
/* @__PURE__ */ jsx49(Thread.Messages, {
|
|
2414
2498
|
style: {
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2499
|
+
padding: "var(--space-5)"
|
|
2500
|
+
}
|
|
2501
|
+
}),
|
|
2502
|
+
/* @__PURE__ */ jsx49(Flex19, {
|
|
2503
|
+
direction: "column",
|
|
2504
|
+
pl: "5",
|
|
2505
|
+
pr: "5",
|
|
2506
|
+
pb: "3",
|
|
2507
|
+
flexShrink: "0",
|
|
2508
|
+
children: /* @__PURE__ */ jsx49(Thread.MessageForm, {})
|
|
2419
2509
|
})
|
|
2420
|
-
|
|
2421
|
-
|
|
2510
|
+
]
|
|
2511
|
+
})
|
|
2422
2512
|
});
|
|
2423
2513
|
};
|
|
2514
|
+
Content4.Root = Root6;
|
|
2424
2515
|
// src/components/threads/ThreadDialog/index.tsx
|
|
2425
|
-
import { jsx as
|
|
2516
|
+
import { jsx as jsx50, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
2426
2517
|
var ThreadDialog = function() {
|
|
2427
|
-
return /* @__PURE__ */
|
|
2518
|
+
return /* @__PURE__ */ jsxs15(Root5, {
|
|
2428
2519
|
children: [
|
|
2429
|
-
/* @__PURE__ */
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
/* @__PURE__ */ jsx45(Trigger, {
|
|
2433
|
-
children: /* @__PURE__ */ jsx45(Button3, {})
|
|
2520
|
+
/* @__PURE__ */ jsx50(Content4, {}),
|
|
2521
|
+
/* @__PURE__ */ jsx50(Trigger, {
|
|
2522
|
+
children: /* @__PURE__ */ jsx50(Button3, {})
|
|
2434
2523
|
})
|
|
2435
2524
|
]
|
|
2436
2525
|
});
|
|
2437
2526
|
};
|
|
2438
|
-
ThreadDialog.Root =
|
|
2527
|
+
ThreadDialog.Root = Root5;
|
|
2439
2528
|
ThreadDialog.Trigger = Trigger;
|
|
2440
2529
|
ThreadDialog.Button = Button3;
|
|
2441
2530
|
ThreadDialog.Content = Content4;
|
|
2442
2531
|
// src/components/threads/AudioThread/Root/index.tsx
|
|
2443
2532
|
import "regenerator-runtime/runtime";
|
|
2444
2533
|
import { useEffect as useEffect7, useRef as useRef6 } from "react";
|
|
2445
|
-
import { Flex as
|
|
2534
|
+
import { Flex as Flex20 } from "@radix-ui/themes";
|
|
2446
2535
|
import SpeechRecognition, { useSpeechRecognition } from "react-speech-recognition";
|
|
2447
2536
|
// src/contexts/threads/AudioThreadContext/index.ts
|
|
2448
|
-
import { createContext as
|
|
2449
|
-
var AudioThreadContext =
|
|
2537
|
+
import { createContext as createContext8 } from "react";
|
|
2538
|
+
var AudioThreadContext = createContext8({
|
|
2450
2539
|
status: "idle",
|
|
2451
2540
|
recorderProps: {
|
|
2452
2541
|
status: "idle",
|
|
@@ -2504,13 +2593,13 @@ var AudioThreadContext = createContext7({
|
|
|
2504
2593
|
// src/components/threads/AudioThread/Root/index.tsx
|
|
2505
2594
|
import { usePermission } from "react-use";
|
|
2506
2595
|
// src/hooks/audioThreads/useStatus/index.ts
|
|
2507
|
-
import { useMemo as
|
|
2596
|
+
import { useMemo as useMemo11 } from "react";
|
|
2508
2597
|
var useStatus = function(param) {
|
|
2509
|
-
var messageAudioProps = param.messageAudioProps, recorderProps = param.recorderProps,
|
|
2598
|
+
var messageAudioProps = param.messageAudioProps, recorderProps = param.recorderProps, createMessageProps = param.createMessageProps;
|
|
2510
2599
|
var isRunActiveProps = useIsRunActive();
|
|
2511
|
-
var status =
|
|
2600
|
+
var status = useMemo11(function() {
|
|
2512
2601
|
if (recorderProps.status === "recording") return "recording";
|
|
2513
|
-
if (
|
|
2602
|
+
if (createMessageProps.isPending) return "creatingMessage";
|
|
2514
2603
|
if (isRunActiveProps.isRunActive) return "runActive";
|
|
2515
2604
|
if (messageAudioProps.playing) return "playing";
|
|
2516
2605
|
if (messageAudioProps.paused) return "playerPaused";
|
|
@@ -2521,7 +2610,7 @@ var useStatus = function(param) {
|
|
|
2521
2610
|
}, [
|
|
2522
2611
|
messageAudioProps,
|
|
2523
2612
|
recorderProps,
|
|
2524
|
-
|
|
2613
|
+
createMessageProps,
|
|
2525
2614
|
isRunActiveProps
|
|
2526
2615
|
]);
|
|
2527
2616
|
return {
|
|
@@ -2531,7 +2620,7 @@ var useStatus = function(param) {
|
|
|
2531
2620
|
// src/hooks/audioThreads/useRecorder/index.ts
|
|
2532
2621
|
import dayjs from "dayjs";
|
|
2533
2622
|
import { useAudioCapture } from "use-audio-capture";
|
|
2534
|
-
import { useMemo as
|
|
2623
|
+
import { useMemo as useMemo12, useRef as useRef4, useState as useState2, useCallback as useCallback2, useEffect as useEffect5 } from "react";
|
|
2535
2624
|
import { useAudioPlayer } from "react-use-audio-player";
|
|
2536
2625
|
import { useInterval as useInterval2 } from "react-use";
|
|
2537
2626
|
var useRecorder = function(param) {
|
|
@@ -2624,7 +2713,7 @@ var useRecorder = function(param) {
|
|
|
2624
2713
|
isInited,
|
|
2625
2714
|
mediaStream
|
|
2626
2715
|
]);
|
|
2627
|
-
var visualizationAnalyser =
|
|
2716
|
+
var visualizationAnalyser = useMemo12(function() {
|
|
2628
2717
|
if (!audioEngine) return null;
|
|
2629
2718
|
var result = audioEngine.audioContext.createAnalyser();
|
|
2630
2719
|
audioEngine.source.connect(result);
|
|
@@ -2632,7 +2721,7 @@ var useRecorder = function(param) {
|
|
|
2632
2721
|
}, [
|
|
2633
2722
|
audioEngine
|
|
2634
2723
|
]);
|
|
2635
|
-
var silenceAnalyser =
|
|
2724
|
+
var silenceAnalyser = useMemo12(function() {
|
|
2636
2725
|
if (!audioEngine) return null;
|
|
2637
2726
|
var result = audioEngine.audioContext.createAnalyser();
|
|
2638
2727
|
result.minDecibels = -45;
|
|
@@ -2687,14 +2776,14 @@ var useRecorder = function(param) {
|
|
|
2687
2776
|
});
|
|
2688
2777
|
};
|
|
2689
2778
|
// src/hooks/audioThreads/useMessageAudio/index.ts
|
|
2690
|
-
import { useMemo as
|
|
2779
|
+
import { useMemo as useMemo13, useRef as useRef5, useState as useState3, useEffect as useEffect6 } from "react";
|
|
2691
2780
|
import { Howler } from "howler";
|
|
2692
2781
|
import { useAudioPlayer as useAudioPlayer2 } from "react-use-audio-player";
|
|
2693
2782
|
// src/hooks/audioThreads/useMessageAudio/lib/input.ts
|
|
2694
2783
|
import { isEmpty } from "radash";
|
|
2695
2784
|
var input = function(param) {
|
|
2696
|
-
var
|
|
2697
|
-
var textContents =
|
|
2785
|
+
var message = param.message;
|
|
2786
|
+
var textContents = message.content.filter(function(c) {
|
|
2698
2787
|
return c.type === "text";
|
|
2699
2788
|
});
|
|
2700
2789
|
var result = textContents.map(function(c) {
|
|
@@ -2716,19 +2805,19 @@ var useMessageAudio = function(param) {
|
|
|
2716
2805
|
var _useState3 = _sliced_to_array(useState3([]), 2), playedMessageIds = _useState3[0], setPlayedMessageIds = _useState3[1];
|
|
2717
2806
|
var audioPlayer = useAudioPlayer2();
|
|
2718
2807
|
var superinterfaceContext = useSuperinterfaceContext();
|
|
2719
|
-
var
|
|
2808
|
+
var latestMessageProps = useLatestMessage();
|
|
2720
2809
|
useEffect6(function() {
|
|
2721
2810
|
if (audioPlayer.playing) return;
|
|
2722
|
-
if (!
|
|
2723
|
-
if (
|
|
2724
|
-
if (playedMessageIds.includes(
|
|
2811
|
+
if (!latestMessageProps.latestMessage) return;
|
|
2812
|
+
if (latestMessageProps.latestMessage.role !== "assistant") return;
|
|
2813
|
+
if (playedMessageIds.includes(latestMessageProps.latestMessage.id)) return;
|
|
2725
2814
|
var input2 = input({
|
|
2726
|
-
|
|
2815
|
+
message: latestMessageProps.latestMessage
|
|
2727
2816
|
});
|
|
2728
2817
|
if (!input2) return;
|
|
2729
2818
|
setPlayedMessageIds(function(prev) {
|
|
2730
2819
|
return _to_consumable_array(prev).concat([
|
|
2731
|
-
|
|
2820
|
+
latestMessageProps.latestMessage.id
|
|
2732
2821
|
]);
|
|
2733
2822
|
});
|
|
2734
2823
|
audioPlayer.load("".concat(superinterfaceContext.baseUrl, "/tts?input=").concat(input2), {
|
|
@@ -2739,7 +2828,7 @@ var useMessageAudio = function(param) {
|
|
|
2739
2828
|
});
|
|
2740
2829
|
}, [
|
|
2741
2830
|
superinterfaceContext,
|
|
2742
|
-
|
|
2831
|
+
latestMessageProps,
|
|
2743
2832
|
audioPlayer,
|
|
2744
2833
|
playedMessageIds,
|
|
2745
2834
|
onEnd
|
|
@@ -2767,7 +2856,7 @@ var useMessageAudio = function(param) {
|
|
|
2767
2856
|
audioPlayer,
|
|
2768
2857
|
isInited
|
|
2769
2858
|
]);
|
|
2770
|
-
var visualizationAnalyser =
|
|
2859
|
+
var visualizationAnalyser = useMemo13(function() {
|
|
2771
2860
|
if (!audioEngine) return null;
|
|
2772
2861
|
var result = audioEngine.audioContext.createAnalyser();
|
|
2773
2862
|
audioEngine.source.connect(audioEngine.audioContext.destination);
|
|
@@ -2781,17 +2870,12 @@ var useMessageAudio = function(param) {
|
|
|
2781
2870
|
});
|
|
2782
2871
|
};
|
|
2783
2872
|
// src/components/threads/AudioThread/Root/index.tsx
|
|
2784
|
-
import { jsx as
|
|
2785
|
-
var
|
|
2873
|
+
import { jsx as jsx51 } from "react/jsx-runtime";
|
|
2874
|
+
var Root7 = function(param) {
|
|
2786
2875
|
var children = param.children;
|
|
2787
|
-
|
|
2788
|
-
var
|
|
2789
|
-
var _useSpeechRecognition = useSpeechRecognition(), transcript = _useSpeechRecognition.transcript,
|
|
2790
|
-
"transcript",
|
|
2791
|
-
"listening",
|
|
2792
|
-
"resetTranscript",
|
|
2793
|
-
"browserSupportsSpeechRecognition"
|
|
2794
|
-
]);
|
|
2876
|
+
useLifecycle();
|
|
2877
|
+
var createMessageProps = useCreateMessage();
|
|
2878
|
+
var _useSpeechRecognition = useSpeechRecognition(), transcript = _useSpeechRecognition.transcript, resetTranscript = _useSpeechRecognition.resetTranscript;
|
|
2795
2879
|
var transcriptRef = useRef6(transcript);
|
|
2796
2880
|
useEffect7(function() {
|
|
2797
2881
|
transcriptRef.current = transcript;
|
|
@@ -2813,20 +2897,21 @@ var Root2 = function(param) {
|
|
|
2813
2897
|
});
|
|
2814
2898
|
}),
|
|
2815
2899
|
onStop: function() {
|
|
2816
|
-
var _ref = _async_to_generator(function(_event,
|
|
2900
|
+
var _ref = _async_to_generator(function(_event, _chunks) {
|
|
2817
2901
|
return _ts_generator(this, function(_state) {
|
|
2818
2902
|
console.log({
|
|
2819
2903
|
transcript: transcriptRef.current
|
|
2820
2904
|
});
|
|
2821
2905
|
return [
|
|
2822
2906
|
2,
|
|
2823
|
-
|
|
2907
|
+
createMessageProps.createMessage({
|
|
2908
|
+
// @ts-ignore-next-line
|
|
2824
2909
|
content: transcriptRef.current
|
|
2825
2910
|
})
|
|
2826
2911
|
];
|
|
2827
2912
|
});
|
|
2828
2913
|
});
|
|
2829
|
-
return function(_event,
|
|
2914
|
+
return function(_event, _chunks) {
|
|
2830
2915
|
return _ref.apply(this, arguments);
|
|
2831
2916
|
};
|
|
2832
2917
|
}()
|
|
@@ -2843,47 +2928,47 @@ var Root2 = function(param) {
|
|
|
2843
2928
|
});
|
|
2844
2929
|
var status = useStatus({
|
|
2845
2930
|
recorderProps: recorderProps,
|
|
2846
|
-
|
|
2931
|
+
createMessageProps: createMessageProps,
|
|
2847
2932
|
messageAudioProps: messageAudioProps
|
|
2848
2933
|
}).status;
|
|
2849
|
-
return /* @__PURE__ */
|
|
2934
|
+
return /* @__PURE__ */ jsx51(AudioThreadContext.Provider, {
|
|
2850
2935
|
value: {
|
|
2851
2936
|
status: status,
|
|
2852
2937
|
recorderProps: recorderProps,
|
|
2853
2938
|
messageAudioProps: messageAudioProps
|
|
2854
2939
|
},
|
|
2855
|
-
children: /* @__PURE__ */
|
|
2940
|
+
children: /* @__PURE__ */ jsx51(Flex20, {
|
|
2856
2941
|
direction: "column",
|
|
2857
|
-
|
|
2942
|
+
flexGrow: "1",
|
|
2858
2943
|
p: "5",
|
|
2859
2944
|
children: children
|
|
2860
2945
|
})
|
|
2861
2946
|
});
|
|
2862
2947
|
};
|
|
2863
2948
|
// src/components/threads/AudioThread/Visualization/index.tsx
|
|
2864
|
-
import { Flex as
|
|
2949
|
+
import { Flex as Flex21 } from "@radix-ui/themes";
|
|
2865
2950
|
// src/hooks/threads/useAudioThreadContext/index.ts
|
|
2866
|
-
import { useContext as
|
|
2951
|
+
import { useContext as useContext10 } from "react";
|
|
2867
2952
|
var useAudioThreadContext = function() {
|
|
2868
|
-
return
|
|
2953
|
+
return useContext10(AudioThreadContext);
|
|
2869
2954
|
};
|
|
2870
2955
|
// src/components/threads/AudioThread/Visualization/index.tsx
|
|
2871
|
-
import { jsx as
|
|
2956
|
+
import { jsx as jsx52 } from "react/jsx-runtime";
|
|
2872
2957
|
var Visualization = function() {
|
|
2873
2958
|
var audioThreadContext = useAudioThreadContext();
|
|
2874
|
-
return /* @__PURE__ */
|
|
2959
|
+
return /* @__PURE__ */ jsx52(Flex21, {
|
|
2875
2960
|
direction: "column",
|
|
2876
2961
|
align: "center",
|
|
2877
2962
|
justify: "center",
|
|
2878
2963
|
mb: "3",
|
|
2879
|
-
|
|
2880
|
-
children: /* @__PURE__ */
|
|
2964
|
+
flexGrow: "1",
|
|
2965
|
+
children: /* @__PURE__ */ jsx52(Flex21, {
|
|
2881
2966
|
align: "center",
|
|
2882
2967
|
justify: "center",
|
|
2968
|
+
height: "200px",
|
|
2969
|
+
width: "200px",
|
|
2883
2970
|
style: {
|
|
2884
2971
|
backgroundColor: "var(--".concat(audioThreadContext.status === "playing" ? "mint" : "gray", "-4)"),
|
|
2885
|
-
height: "200px",
|
|
2886
|
-
width: "200px",
|
|
2887
2972
|
borderRadius: "9999px"
|
|
2888
2973
|
}
|
|
2889
2974
|
})
|
|
@@ -2891,13 +2976,13 @@ var Visualization = function() {
|
|
|
2891
2976
|
};
|
|
2892
2977
|
// src/components/threads/AudioThread/Form/index.tsx
|
|
2893
2978
|
import { SpeakerModerateIcon } from "@radix-ui/react-icons";
|
|
2894
|
-
import { Flex as
|
|
2979
|
+
import { Flex as Flex24 } from "@radix-ui/themes";
|
|
2895
2980
|
// src/components/threads/AudioThread/Form/Visualizer/index.tsx
|
|
2896
2981
|
import _7 from "lodash";
|
|
2897
|
-
import { Flex as
|
|
2898
|
-
import { useState as useState4, useEffect as useEffect8, useCallback as
|
|
2982
|
+
import { Flex as Flex22, Grid } from "@radix-ui/themes";
|
|
2983
|
+
import { useState as useState4, useEffect as useEffect8, useCallback as useCallback3 } from "react";
|
|
2899
2984
|
import { cluster } from "radash";
|
|
2900
|
-
import { jsx as
|
|
2985
|
+
import { jsx as jsx53 } from "react/jsx-runtime";
|
|
2901
2986
|
var barCount = 4;
|
|
2902
2987
|
var Visualizer = function() {
|
|
2903
2988
|
var audioThreadContext = useAudioThreadContext();
|
|
@@ -2906,7 +2991,7 @@ var Visualizer = function() {
|
|
|
2906
2991
|
return new AudioContext().createAnalyser();
|
|
2907
2992
|
}), 1), emptyVisualizer = _useState4[0];
|
|
2908
2993
|
var _useState41 = _sliced_to_array(useState4([]), 2), barHeights = _useState41[0], setBarHeights = _useState41[1];
|
|
2909
|
-
var draw =
|
|
2994
|
+
var draw = useCallback3(function(param) {
|
|
2910
2995
|
var visualizationAnalyser2 = param.visualizationAnalyser;
|
|
2911
2996
|
var frequencyData = new Uint8Array(visualizationAnalyser2.frequencyBinCount / 15);
|
|
2912
2997
|
visualizationAnalyser2.getByteFrequencyData(frequencyData);
|
|
@@ -2929,7 +3014,7 @@ var Visualizer = function() {
|
|
|
2929
3014
|
visualizationAnalyser,
|
|
2930
3015
|
emptyVisualizer
|
|
2931
3016
|
]);
|
|
2932
|
-
return /* @__PURE__ */
|
|
3017
|
+
return /* @__PURE__ */ jsx53(Grid, {
|
|
2933
3018
|
columns: "".concat(barCount),
|
|
2934
3019
|
gap: "1",
|
|
2935
3020
|
width: "auto",
|
|
@@ -2938,21 +3023,19 @@ var Visualizer = function() {
|
|
|
2938
3023
|
gridTemplateColumns: "repeat(4, minmax(0, 1fr))"
|
|
2939
3024
|
},
|
|
2940
3025
|
children: barHeights.map(function(barHeight, index) {
|
|
2941
|
-
return /* @__PURE__ */
|
|
3026
|
+
return /* @__PURE__ */ jsx53(Flex22, {
|
|
2942
3027
|
direction: "column",
|
|
2943
3028
|
align: "center",
|
|
2944
3029
|
justify: "center",
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
3030
|
+
height: "20px",
|
|
3031
|
+
children: /* @__PURE__ */ jsx53(Flex22, {
|
|
3032
|
+
minHeight: "50%",
|
|
3033
|
+
maxHeight: "100%",
|
|
3034
|
+
height: "".concat(barHeight + 20, "%"),
|
|
3035
|
+
width: "12px",
|
|
2949
3036
|
style: {
|
|
2950
3037
|
backgroundColor: "var(--".concat(audioThreadContext.status === "recording" ? "mint" : "gray", "-11)"),
|
|
2951
|
-
borderRadius: "var(--radius-6)"
|
|
2952
|
-
height: "".concat(barHeight + 20, "%"),
|
|
2953
|
-
minHeight: "50%",
|
|
2954
|
-
maxHeight: "100%",
|
|
2955
|
-
width: "12px"
|
|
3038
|
+
borderRadius: "var(--radius-6)"
|
|
2956
3039
|
}
|
|
2957
3040
|
})
|
|
2958
3041
|
}, index);
|
|
@@ -2960,31 +3043,31 @@ var Visualizer = function() {
|
|
|
2960
3043
|
});
|
|
2961
3044
|
};
|
|
2962
3045
|
// src/components/threads/AudioThread/Form/ActionButton/index.tsx
|
|
2963
|
-
import { Flex as
|
|
3046
|
+
import { Flex as Flex23, IconButton as IconButton2, Tooltip } from "@radix-ui/themes";
|
|
2964
3047
|
import { PauseIcon, ArrowUpIcon as ArrowUpIcon2, ResumeIcon } from "@radix-ui/react-icons";
|
|
2965
|
-
import { jsx as
|
|
3048
|
+
import { jsx as jsx54, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
2966
3049
|
var ActionButton = function() {
|
|
2967
3050
|
var audioThreadContext = useAudioThreadContext();
|
|
2968
3051
|
if (audioThreadContext.status === "recording") {
|
|
2969
|
-
return /* @__PURE__ */
|
|
3052
|
+
return /* @__PURE__ */ jsxs16(Flex23, {
|
|
2970
3053
|
align: "center",
|
|
2971
3054
|
children: [
|
|
2972
|
-
/* @__PURE__ */
|
|
3055
|
+
/* @__PURE__ */ jsx54(Flex23, {
|
|
2973
3056
|
mr: "3",
|
|
2974
3057
|
ml: "-7",
|
|
2975
|
-
children: /* @__PURE__ */
|
|
3058
|
+
children: /* @__PURE__ */ jsx54(IconButton2, {
|
|
2976
3059
|
onClick: audioThreadContext.recorderProps.pause,
|
|
2977
3060
|
color: "gray",
|
|
2978
3061
|
radius: "full",
|
|
2979
3062
|
size: "1",
|
|
2980
|
-
children: /* @__PURE__ */
|
|
3063
|
+
children: /* @__PURE__ */ jsx54(PauseIcon, {})
|
|
2981
3064
|
})
|
|
2982
3065
|
}),
|
|
2983
|
-
/* @__PURE__ */
|
|
3066
|
+
/* @__PURE__ */ jsx54(Tooltip, {
|
|
2984
3067
|
open: true,
|
|
2985
3068
|
content: "Send your message",
|
|
2986
3069
|
side: "bottom",
|
|
2987
|
-
children: /* @__PURE__ */
|
|
3070
|
+
children: /* @__PURE__ */ jsx54(IconButton2, {
|
|
2988
3071
|
onClick: audioThreadContext.recorderProps.stop,
|
|
2989
3072
|
color: "gray",
|
|
2990
3073
|
highContrast: true,
|
|
@@ -2993,14 +3076,14 @@ var ActionButton = function() {
|
|
|
2993
3076
|
style: {
|
|
2994
3077
|
border: "2px solid var(--gray-8)"
|
|
2995
3078
|
},
|
|
2996
|
-
children: /* @__PURE__ */
|
|
3079
|
+
children: /* @__PURE__ */ jsx54(ArrowUpIcon2, {})
|
|
2997
3080
|
})
|
|
2998
3081
|
})
|
|
2999
3082
|
]
|
|
3000
3083
|
});
|
|
3001
3084
|
}
|
|
3002
3085
|
if (audioThreadContext.status === "recorderPaused") {
|
|
3003
|
-
return /* @__PURE__ */
|
|
3086
|
+
return /* @__PURE__ */ jsx54(IconButton2, {
|
|
3004
3087
|
onClick: audioThreadContext.recorderProps.resume,
|
|
3005
3088
|
color: "red",
|
|
3006
3089
|
radius: "full",
|
|
@@ -3008,11 +3091,11 @@ var ActionButton = function() {
|
|
|
3008
3091
|
style: {
|
|
3009
3092
|
border: "2px solid var(--gray-8)"
|
|
3010
3093
|
},
|
|
3011
|
-
children: /* @__PURE__ */
|
|
3094
|
+
children: /* @__PURE__ */ jsx54(ResumeIcon, {})
|
|
3012
3095
|
});
|
|
3013
3096
|
}
|
|
3014
3097
|
if (audioThreadContext.status === "idle") {
|
|
3015
|
-
return /* @__PURE__ */
|
|
3098
|
+
return /* @__PURE__ */ jsx54(IconButton2, {
|
|
3016
3099
|
onClick: function() {
|
|
3017
3100
|
return audioThreadContext.recorderProps.start();
|
|
3018
3101
|
},
|
|
@@ -3025,7 +3108,7 @@ var ActionButton = function() {
|
|
|
3025
3108
|
});
|
|
3026
3109
|
}
|
|
3027
3110
|
if (audioThreadContext.status === "playing") {
|
|
3028
|
-
return /* @__PURE__ */
|
|
3111
|
+
return /* @__PURE__ */ jsx54(IconButton2, {
|
|
3029
3112
|
onClick: function() {
|
|
3030
3113
|
return audioThreadContext.messageAudioProps.pause();
|
|
3031
3114
|
},
|
|
@@ -3035,11 +3118,11 @@ var ActionButton = function() {
|
|
|
3035
3118
|
style: {
|
|
3036
3119
|
border: "2px solid var(--gray-8)"
|
|
3037
3120
|
},
|
|
3038
|
-
children: /* @__PURE__ */
|
|
3121
|
+
children: /* @__PURE__ */ jsx54(PauseIcon, {})
|
|
3039
3122
|
});
|
|
3040
3123
|
}
|
|
3041
3124
|
if (audioThreadContext.status === "playerPaused") {
|
|
3042
|
-
return /* @__PURE__ */
|
|
3125
|
+
return /* @__PURE__ */ jsx54(IconButton2, {
|
|
3043
3126
|
onClick: function() {
|
|
3044
3127
|
return audioThreadContext.messageAudioProps.play();
|
|
3045
3128
|
},
|
|
@@ -3049,10 +3132,10 @@ var ActionButton = function() {
|
|
|
3049
3132
|
style: {
|
|
3050
3133
|
border: "2px solid var(--gray-8)"
|
|
3051
3134
|
},
|
|
3052
|
-
children: /* @__PURE__ */
|
|
3135
|
+
children: /* @__PURE__ */ jsx54(ResumeIcon, {})
|
|
3053
3136
|
});
|
|
3054
3137
|
}
|
|
3055
|
-
return /* @__PURE__ */
|
|
3138
|
+
return /* @__PURE__ */ jsx54(IconButton2, {
|
|
3056
3139
|
size: "4",
|
|
3057
3140
|
color: "red",
|
|
3058
3141
|
radius: "full",
|
|
@@ -3063,140 +3146,141 @@ var ActionButton = function() {
|
|
|
3063
3146
|
});
|
|
3064
3147
|
};
|
|
3065
3148
|
// src/components/threads/AudioThread/Form/index.tsx
|
|
3066
|
-
import { jsx as
|
|
3149
|
+
import { jsx as jsx55, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
3067
3150
|
var Form = function() {
|
|
3068
3151
|
var audioThreadContext = useAudioThreadContext();
|
|
3069
|
-
return /* @__PURE__ */
|
|
3152
|
+
return /* @__PURE__ */ jsxs17(Flex24, {
|
|
3070
3153
|
direction: "column",
|
|
3071
3154
|
align: "center",
|
|
3072
3155
|
children: [
|
|
3073
|
-
/* @__PURE__ */
|
|
3156
|
+
/* @__PURE__ */ jsxs17(Flex24, {
|
|
3074
3157
|
pb: "3",
|
|
3075
3158
|
align: "center",
|
|
3076
3159
|
children: [
|
|
3077
|
-
/* @__PURE__ */
|
|
3160
|
+
/* @__PURE__ */ jsx55(Flex24, {
|
|
3078
3161
|
ml: "-5",
|
|
3079
3162
|
mr: "2",
|
|
3080
3163
|
align: "center",
|
|
3081
|
-
children: /* @__PURE__ */
|
|
3164
|
+
children: /* @__PURE__ */ jsx55(SpeakerModerateIcon, {
|
|
3082
3165
|
style: {
|
|
3083
3166
|
color: "var(--".concat(audioThreadContext.status === "recording" ? "mint" : "gray", "-12)")
|
|
3084
3167
|
}
|
|
3085
3168
|
})
|
|
3086
3169
|
}),
|
|
3087
|
-
/* @__PURE__ */
|
|
3170
|
+
/* @__PURE__ */ jsx55(Flex24, {
|
|
3088
3171
|
px: "2",
|
|
3089
3172
|
py: "1",
|
|
3090
3173
|
style: {
|
|
3091
3174
|
backgroundColor: "var(--".concat(audioThreadContext.status === "recording" ? "mint" : "gray", "-4)"),
|
|
3092
3175
|
borderRadius: "var(--radius-6)"
|
|
3093
3176
|
},
|
|
3094
|
-
children: /* @__PURE__ */
|
|
3177
|
+
children: /* @__PURE__ */ jsx55(Visualizer, {})
|
|
3095
3178
|
})
|
|
3096
3179
|
]
|
|
3097
3180
|
}),
|
|
3098
|
-
/* @__PURE__ */
|
|
3181
|
+
/* @__PURE__ */ jsx55(ActionButton, {})
|
|
3099
3182
|
]
|
|
3100
3183
|
});
|
|
3101
3184
|
};
|
|
3102
3185
|
// src/components/threads/AudioThread/index.tsx
|
|
3103
|
-
import { jsx as
|
|
3186
|
+
import { jsx as jsx56, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
3104
3187
|
var AudioThread = function(props) {
|
|
3105
|
-
return /* @__PURE__ */
|
|
3188
|
+
return /* @__PURE__ */ jsxs18(Root7, _object_spread_props(_object_spread({}, props), {
|
|
3106
3189
|
children: [
|
|
3107
|
-
/* @__PURE__ */
|
|
3108
|
-
/* @__PURE__ */
|
|
3190
|
+
/* @__PURE__ */ jsx56(Visualization, {}),
|
|
3191
|
+
/* @__PURE__ */ jsx56(Form, {})
|
|
3109
3192
|
]
|
|
3110
3193
|
}));
|
|
3111
3194
|
};
|
|
3112
|
-
AudioThread.Root =
|
|
3195
|
+
AudioThread.Root = Root7;
|
|
3113
3196
|
AudioThread.Visualization = Visualization;
|
|
3114
3197
|
AudioThread.Form = Form;
|
|
3115
3198
|
// src/components/threads/AudioThreadDialog/index.tsx
|
|
3116
|
-
import { jsx as
|
|
3199
|
+
import { jsx as jsx57, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
3117
3200
|
var AudioThreadDialog = function() {
|
|
3118
|
-
return /* @__PURE__ */
|
|
3201
|
+
return /* @__PURE__ */ jsxs19(Root5, {
|
|
3119
3202
|
children: [
|
|
3120
|
-
/* @__PURE__ */
|
|
3121
|
-
children: /* @__PURE__ */
|
|
3203
|
+
/* @__PURE__ */ jsx57(Content4.Root, {
|
|
3204
|
+
children: /* @__PURE__ */ jsx57(AudioThread, {})
|
|
3122
3205
|
}),
|
|
3123
|
-
/* @__PURE__ */
|
|
3124
|
-
children: /* @__PURE__ */
|
|
3206
|
+
/* @__PURE__ */ jsx57(Trigger, {
|
|
3207
|
+
children: /* @__PURE__ */ jsx57(Button3, {})
|
|
3125
3208
|
})
|
|
3126
3209
|
]
|
|
3127
3210
|
});
|
|
3128
3211
|
};
|
|
3129
|
-
AudioThreadDialog.Root =
|
|
3212
|
+
AudioThreadDialog.Root = Root5;
|
|
3130
3213
|
AudioThreadDialog.Trigger = Trigger;
|
|
3131
3214
|
AudioThreadDialog.Button = Button3;
|
|
3132
3215
|
AudioThreadDialog.Content = Content4;
|
|
3133
3216
|
// src/components/suggestions/Suggestions/index.tsx
|
|
3134
|
-
import { useMemo as
|
|
3135
|
-
import { Flex as
|
|
3217
|
+
import { useMemo as useMemo14 } from "react";
|
|
3218
|
+
import { Flex as Flex25 } from "@radix-ui/themes";
|
|
3136
3219
|
// src/components/suggestions/Suggestion/index.tsx
|
|
3137
3220
|
import { ArrowUpIcon as ArrowUpIcon3 } from "@radix-ui/react-icons";
|
|
3138
3221
|
import { Text as Text6, Button as Button4 } from "@radix-ui/themes";
|
|
3139
|
-
import { jsx as
|
|
3222
|
+
import { jsx as jsx58, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
3140
3223
|
var Suggestion = function(param) {
|
|
3141
3224
|
var suggestion = param.suggestion;
|
|
3142
|
-
var
|
|
3225
|
+
var createMessage = useCreateMessage().createMessage;
|
|
3143
3226
|
var _useIsRunActive = useIsRunActive(), isRunActive2 = _useIsRunActive.isRunActive;
|
|
3144
|
-
return /* @__PURE__ */
|
|
3227
|
+
return /* @__PURE__ */ jsxs20(Button4, {
|
|
3145
3228
|
variant: "soft",
|
|
3146
3229
|
style: {
|
|
3147
3230
|
justifyContent: "space-between"
|
|
3148
3231
|
},
|
|
3149
3232
|
onClick: function() {
|
|
3150
|
-
|
|
3233
|
+
createMessage({
|
|
3234
|
+
// @ts-ignore-next-line
|
|
3151
3235
|
content: suggestion
|
|
3152
3236
|
});
|
|
3153
3237
|
},
|
|
3154
3238
|
disabled: isRunActive2,
|
|
3155
3239
|
children: [
|
|
3156
|
-
/* @__PURE__ */
|
|
3240
|
+
/* @__PURE__ */ jsx58(Text6, {
|
|
3157
3241
|
size: "1",
|
|
3158
3242
|
weight: "regular",
|
|
3159
3243
|
children: suggestion
|
|
3160
3244
|
}),
|
|
3161
|
-
/* @__PURE__ */
|
|
3245
|
+
/* @__PURE__ */ jsx58(ArrowUpIcon3, {})
|
|
3162
3246
|
]
|
|
3163
3247
|
});
|
|
3164
3248
|
};
|
|
3165
3249
|
// src/components/suggestions/Suggestions/index.tsx
|
|
3166
|
-
import { jsx as
|
|
3250
|
+
import { jsx as jsx59 } from "react/jsx-runtime";
|
|
3167
3251
|
var Suggestions = function(param) {
|
|
3168
3252
|
var _param_emptyStateSuggestions = param.emptyStateSuggestions, emptyStateSuggestions = _param_emptyStateSuggestions === void 0 ? [] : _param_emptyStateSuggestions, _param_suggestions = param.suggestions, suggestions = _param_suggestions === void 0 ? [] : _param_suggestions;
|
|
3169
|
-
var
|
|
3253
|
+
var latestMessageProps = useLatestMessage();
|
|
3170
3254
|
var isRunActiveProps = useIsRunActive();
|
|
3171
|
-
var isDisabled =
|
|
3255
|
+
var isDisabled = useMemo14(function() {
|
|
3172
3256
|
var // @ts-ignore-next-line
|
|
3173
|
-
|
|
3174
|
-
return ((
|
|
3257
|
+
_latestMessageProps_latestMessage_metadata, _latestMessageProps_latestMessage;
|
|
3258
|
+
return ((_latestMessageProps_latestMessage = latestMessageProps.latestMessage) === null || _latestMessageProps_latestMessage === void 0 ? void 0 : (_latestMessageProps_latestMessage_metadata = _latestMessageProps_latestMessage.metadata) === null || _latestMessageProps_latestMessage_metadata === void 0 ? void 0 : _latestMessageProps_latestMessage_metadata.isBlocking) || isRunActiveProps.isRunActive;
|
|
3175
3259
|
}, [
|
|
3176
|
-
|
|
3260
|
+
latestMessageProps,
|
|
3177
3261
|
isRunActiveProps
|
|
3178
3262
|
]);
|
|
3179
|
-
if (
|
|
3263
|
+
if (latestMessageProps.isLoading) return null;
|
|
3180
3264
|
if (isDisabled) return null;
|
|
3181
|
-
if (!
|
|
3182
|
-
return /* @__PURE__ */
|
|
3265
|
+
if (!latestMessageProps.latestMessage && emptyStateSuggestions.length > 0) {
|
|
3266
|
+
return /* @__PURE__ */ jsx59(Flex25, {
|
|
3183
3267
|
gap: "2",
|
|
3184
3268
|
py: "2",
|
|
3185
3269
|
wrap: "wrap",
|
|
3186
3270
|
children: emptyStateSuggestions.map(function(suggestion) {
|
|
3187
|
-
return /* @__PURE__ */
|
|
3271
|
+
return /* @__PURE__ */ jsx59(Suggestion, {
|
|
3188
3272
|
suggestion: suggestion
|
|
3189
3273
|
}, suggestion);
|
|
3190
3274
|
})
|
|
3191
3275
|
});
|
|
3192
3276
|
}
|
|
3193
|
-
if (
|
|
3194
|
-
return /* @__PURE__ */
|
|
3277
|
+
if (latestMessageProps.latestMessage.role === "assistant") {
|
|
3278
|
+
return /* @__PURE__ */ jsx59(Flex25, {
|
|
3195
3279
|
gap: "2",
|
|
3196
3280
|
py: "2",
|
|
3197
3281
|
wrap: "wrap",
|
|
3198
3282
|
children: suggestions.map(function(suggestion) {
|
|
3199
|
-
return /* @__PURE__ */
|
|
3283
|
+
return /* @__PURE__ */ jsx59(Suggestion, {
|
|
3200
3284
|
suggestion: suggestion
|
|
3201
3285
|
}, suggestion);
|
|
3202
3286
|
})
|
|
@@ -3205,9 +3289,9 @@ var Suggestions = function(param) {
|
|
|
3205
3289
|
return null;
|
|
3206
3290
|
};
|
|
3207
3291
|
// src/hooks/markdown/useMarkdownContext/index.ts
|
|
3208
|
-
import { useContext as
|
|
3292
|
+
import { useContext as useContext11 } from "react";
|
|
3209
3293
|
var useMarkdownContext = function() {
|
|
3210
|
-
return
|
|
3294
|
+
return useContext11(MarkdownContext);
|
|
3211
3295
|
};
|
|
3212
|
-
export { AssistantAvatarContext, AssistantNameContext, AudioThread, AudioThreadDialog, FunctionBase, FunctionComponentsContext, MarkdownContext, Suggestion, Suggestions, SuperinterfaceProvider, Thread, ThreadDialog,
|
|
3296
|
+
export { AssistantAvatarContext, AssistantNameContext, AudioThread, AudioThreadDialog, FunctionBase, FunctionComponentsContext, MarkdownContext, Suggestion, Suggestions, SuperinterfaceProvider, Thread, ThreadDialog, ThreadDialogContext, useCreateMessage, useCreateRun, useIsRunActive, useLatestMessage, useLatestRun, useLifecycle, useMarkdownContext, useMessages, useRuns, useSuperinterfaceContext, useSuperinterfaceContext as useThreadContext };
|
|
3213
3297
|
//# sourceMappingURL=index.js.map
|