@superinterface/react 2.0.1 → 2.0.3
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 +1850 -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 +1792 -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,1561 @@ 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
|
|
1935
1968
|
});
|
|
1936
|
-
// src/hooks/
|
|
1969
|
+
// src/hooks/messages/useMessageFormContext/index.ts
|
|
1970
|
+
var useMessageFormContext = function() {
|
|
1971
|
+
return useContext7(MessageFormContext);
|
|
1972
|
+
};
|
|
1973
|
+
// src/components/threads/Thread/MessageForm/Submit/index.tsx
|
|
1974
|
+
import { jsx as jsx38 } from "react/jsx-runtime";
|
|
1975
|
+
var Submit = function() {
|
|
1976
|
+
var _useMessageFormContext = useMessageFormContext(), isDisabled = _useMessageFormContext.isDisabled, isLoading = _useMessageFormContext.isLoading;
|
|
1977
|
+
return /* @__PURE__ */ jsx38(Button2, {
|
|
1978
|
+
type: "submit",
|
|
1979
|
+
radius: "large",
|
|
1980
|
+
disabled: isDisabled,
|
|
1981
|
+
children: isLoading ? /* @__PURE__ */ jsx38(Spinner, {}) : /* @__PURE__ */ jsx38(ArrowUpIcon, {})
|
|
1982
|
+
});
|
|
1983
|
+
};
|
|
1984
|
+
// src/components/threads/Thread/MessageForm/Root/index.tsx
|
|
1985
|
+
import { useMemo as useMemo9 } from "react";
|
|
1986
|
+
import { useForm, FormProvider } from "react-hook-form";
|
|
1987
|
+
// src/hooks/messages/useCreateMessage/index.ts
|
|
1937
1988
|
import { partob as partob3 } from "radash";
|
|
1938
1989
|
import { useMutation as useMutation3, useQueryClient as useQueryClient9 } from "@tanstack/react-query";
|
|
1939
|
-
// src/hooks/
|
|
1990
|
+
// src/hooks/messages/useCreateMessage/lib/mutationOptions/onMutate/index.ts
|
|
1940
1991
|
import { omit } from "radash";
|
|
1941
|
-
// src/hooks/
|
|
1992
|
+
// src/hooks/messages/useCreateMessage/lib/mutationOptions/onMutate/data.ts
|
|
1942
1993
|
var data2 = function(param) {
|
|
1943
|
-
var
|
|
1994
|
+
var newMessage = param.newMessage;
|
|
1944
1995
|
return function(prevData) {
|
|
1945
1996
|
var message = {
|
|
1946
1997
|
id: optimisticId(),
|
|
@@ -1952,7 +2003,7 @@ var data2 = function(param) {
|
|
|
1952
2003
|
type: "text",
|
|
1953
2004
|
text: {
|
|
1954
2005
|
annotations: [],
|
|
1955
|
-
value:
|
|
2006
|
+
value: newMessage.content
|
|
1956
2007
|
}
|
|
1957
2008
|
}
|
|
1958
2009
|
],
|
|
@@ -1989,18 +2040,18 @@ var data2 = function(param) {
|
|
|
1989
2040
|
});
|
|
1990
2041
|
};
|
|
1991
2042
|
};
|
|
1992
|
-
// src/hooks/
|
|
2043
|
+
// src/hooks/messages/useCreateMessage/lib/mutationOptions/onMutate/index.ts
|
|
1993
2044
|
var onMutate2 = function(param) {
|
|
1994
2045
|
var queryClient = param.queryClient;
|
|
1995
2046
|
return function() {
|
|
1996
|
-
var _ref = _async_to_generator(function(
|
|
1997
|
-
var queryKey,
|
|
2047
|
+
var _ref = _async_to_generator(function(newMessage) {
|
|
2048
|
+
var queryKey, prevMessages;
|
|
1998
2049
|
return _ts_generator(this, function(_state) {
|
|
1999
2050
|
switch(_state.label){
|
|
2000
2051
|
case 0:
|
|
2001
2052
|
queryKey = [
|
|
2002
|
-
"
|
|
2003
|
-
omit(
|
|
2053
|
+
"messages",
|
|
2054
|
+
omit(newMessage, [
|
|
2004
2055
|
"content"
|
|
2005
2056
|
])
|
|
2006
2057
|
];
|
|
@@ -2012,26 +2063,26 @@ var onMutate2 = function(param) {
|
|
|
2012
2063
|
];
|
|
2013
2064
|
case 1:
|
|
2014
2065
|
_state.sent();
|
|
2015
|
-
|
|
2066
|
+
prevMessages = queryClient.getQueryData(queryKey);
|
|
2016
2067
|
queryClient.setQueryData(queryKey, data2({
|
|
2017
|
-
|
|
2068
|
+
newMessage: newMessage
|
|
2018
2069
|
}));
|
|
2019
2070
|
return [
|
|
2020
2071
|
2,
|
|
2021
2072
|
{
|
|
2022
|
-
|
|
2023
|
-
|
|
2073
|
+
prevMessages: prevMessages,
|
|
2074
|
+
newMessage: newMessage
|
|
2024
2075
|
}
|
|
2025
2076
|
];
|
|
2026
2077
|
}
|
|
2027
2078
|
});
|
|
2028
2079
|
});
|
|
2029
|
-
return function(
|
|
2080
|
+
return function(newMessage) {
|
|
2030
2081
|
return _ref.apply(this, arguments);
|
|
2031
2082
|
};
|
|
2032
2083
|
}();
|
|
2033
2084
|
};
|
|
2034
|
-
// src/hooks/
|
|
2085
|
+
// src/hooks/messages/useCreateMessage/lib/mutationOptions/onSettled.ts
|
|
2035
2086
|
import { omit as omit2 } from "radash";
|
|
2036
2087
|
var onSettled3 = function(param) {
|
|
2037
2088
|
var queryClient = param.queryClient;
|
|
@@ -2044,7 +2095,7 @@ var onSettled3 = function(param) {
|
|
|
2044
2095
|
4,
|
|
2045
2096
|
queryClient.invalidateQueries({
|
|
2046
2097
|
queryKey: [
|
|
2047
|
-
"
|
|
2098
|
+
"messages",
|
|
2048
2099
|
omit2(variables, [
|
|
2049
2100
|
"content"
|
|
2050
2101
|
])
|
|
@@ -2077,8 +2128,8 @@ var onSettled3 = function(param) {
|
|
|
2077
2128
|
};
|
|
2078
2129
|
}();
|
|
2079
2130
|
};
|
|
2080
|
-
// src/hooks/
|
|
2081
|
-
var
|
|
2131
|
+
// src/hooks/messages/useCreateMessage/index.ts
|
|
2132
|
+
var useCreateMessage = function() {
|
|
2082
2133
|
var queryClient = useQueryClient9();
|
|
2083
2134
|
var superinterfaceContext = useSuperinterfaceContext();
|
|
2084
2135
|
var threadContext = useSuperinterfaceContext();
|
|
@@ -2091,69 +2142,32 @@ var useCreateThreadMessage = function() {
|
|
|
2091
2142
|
})
|
|
2092
2143
|
}, mutationOptions({
|
|
2093
2144
|
mutationKeyBase: [
|
|
2094
|
-
"
|
|
2145
|
+
"createMessage"
|
|
2095
2146
|
],
|
|
2096
|
-
path: "/
|
|
2147
|
+
path: "/messages",
|
|
2097
2148
|
queryClient: queryClient,
|
|
2098
2149
|
threadContext: threadContext,
|
|
2099
2150
|
superinterfaceContext: superinterfaceContext
|
|
2100
2151
|
})));
|
|
2101
2152
|
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, {})
|
|
2153
|
+
createMessage: partob3(props.mutateAsync, threadContext.variables)
|
|
2141
2154
|
});
|
|
2142
2155
|
};
|
|
2143
|
-
// src/components/
|
|
2156
|
+
// src/components/threads/Thread/MessageForm/Root/lib/formOptions.ts
|
|
2144
2157
|
import { z } from "zod";
|
|
2145
2158
|
import { zodResolver } from "@hookform/resolvers/zod";
|
|
2146
2159
|
var schema = z.object({
|
|
2147
2160
|
content: z.string().min(1)
|
|
2148
2161
|
});
|
|
2149
|
-
var
|
|
2162
|
+
var formOptions = {
|
|
2150
2163
|
resolver: zodResolver(schema)
|
|
2151
2164
|
};
|
|
2152
|
-
// src/components/
|
|
2153
|
-
import { jsx as
|
|
2154
|
-
var
|
|
2155
|
-
var
|
|
2156
|
-
var
|
|
2165
|
+
// src/components/threads/Thread/MessageForm/Root/index.tsx
|
|
2166
|
+
import { jsx as jsx39 } from "react/jsx-runtime";
|
|
2167
|
+
var Root2 = function(param) {
|
|
2168
|
+
var children = param.children;
|
|
2169
|
+
var formProps = useForm(formOptions);
|
|
2170
|
+
var handleSubmit = formProps.handleSubmit, isSubmitting = formProps.formState.isSubmitting, reset = formProps.reset;
|
|
2157
2171
|
var _useIsRunActive = useIsRunActive(), isRunActive2 = _useIsRunActive.isRunActive;
|
|
2158
2172
|
var isLoading = useMemo9(function() {
|
|
2159
2173
|
return isRunActive2 || isSubmitting;
|
|
@@ -2161,7 +2175,7 @@ var ThreadMessageForm = function() {
|
|
|
2161
2175
|
isRunActive2,
|
|
2162
2176
|
isSubmitting
|
|
2163
2177
|
]);
|
|
2164
|
-
var
|
|
2178
|
+
var createMessage = useCreateMessage().createMessage;
|
|
2165
2179
|
var onSubmit = function() {
|
|
2166
2180
|
var _ref = _async_to_generator(function(data3) {
|
|
2167
2181
|
return _ts_generator(this, function(_state) {
|
|
@@ -2170,7 +2184,7 @@ var ThreadMessageForm = function() {
|
|
|
2170
2184
|
reset();
|
|
2171
2185
|
return [
|
|
2172
2186
|
4,
|
|
2173
|
-
|
|
2187
|
+
createMessage({
|
|
2174
2188
|
content: data3.content
|
|
2175
2189
|
})
|
|
2176
2190
|
];
|
|
@@ -2186,16 +2200,91 @@ var ThreadMessageForm = function() {
|
|
|
2186
2200
|
return _ref.apply(this, arguments);
|
|
2187
2201
|
};
|
|
2188
2202
|
}();
|
|
2189
|
-
var
|
|
2203
|
+
var latestMessage = useLatestMessage().latestMessage;
|
|
2190
2204
|
var isDisabled = useMemo9(function() {
|
|
2191
2205
|
var // @ts-ignore-next-line
|
|
2192
|
-
|
|
2193
|
-
return
|
|
2206
|
+
_latestMessage_metadata;
|
|
2207
|
+
return latestMessage === null || latestMessage === void 0 ? void 0 : (_latestMessage_metadata = latestMessage.metadata) === null || _latestMessage_metadata === void 0 ? void 0 : _latestMessage_metadata.isBlocking;
|
|
2194
2208
|
}, [
|
|
2195
|
-
|
|
2209
|
+
latestMessage,
|
|
2196
2210
|
isLoading
|
|
2197
2211
|
]);
|
|
2198
|
-
|
|
2212
|
+
return /* @__PURE__ */ jsx39(MessageFormContext.Provider, {
|
|
2213
|
+
value: {
|
|
2214
|
+
isDisabled: isDisabled,
|
|
2215
|
+
isLoading: isLoading
|
|
2216
|
+
},
|
|
2217
|
+
children: /* @__PURE__ */ jsx39(FormProvider, _object_spread_props(_object_spread({}, formProps), {
|
|
2218
|
+
children: /* @__PURE__ */ jsx39("form", {
|
|
2219
|
+
onSubmit: handleSubmit(onSubmit),
|
|
2220
|
+
children: children
|
|
2221
|
+
})
|
|
2222
|
+
}))
|
|
2223
|
+
});
|
|
2224
|
+
};
|
|
2225
|
+
// src/components/threads/Thread/MessageForm/Field/index.tsx
|
|
2226
|
+
import { usePrevious } from "react-use";
|
|
2227
|
+
import { useContext as useContext8, useMemo as useMemo10, useRef as useRef3, useEffect as useEffect4 } from "react";
|
|
2228
|
+
// src/components/textareas/TextareaBase/index.tsx
|
|
2229
|
+
import { forwardRef as forwardRef3 } from "react";
|
|
2230
|
+
import TextareaAutosize from "react-textarea-autosize";
|
|
2231
|
+
import { jsx as jsx40 } from "react/jsx-runtime";
|
|
2232
|
+
var UPSCALE_RATIO = 16 / 14;
|
|
2233
|
+
var TextareaBase = forwardRef3(function TextareaBase2(props, ref) {
|
|
2234
|
+
return /* @__PURE__ */ jsx40(TextareaAutosize, _object_spread({
|
|
2235
|
+
ref: ref,
|
|
2236
|
+
className: "textarea-base",
|
|
2237
|
+
style: {
|
|
2238
|
+
resize: "none",
|
|
2239
|
+
fontSize: "".concat(14 * UPSCALE_RATIO, "px"),
|
|
2240
|
+
lineHeight: "".concat(24 * UPSCALE_RATIO, "px"),
|
|
2241
|
+
transform: "scale(".concat(1 / UPSCALE_RATIO, ")"),
|
|
2242
|
+
margin: "0 ".concat((-100 * UPSCALE_RATIO + 100) / 2, "%"),
|
|
2243
|
+
width: "".concat(100 * UPSCALE_RATIO, "%"),
|
|
2244
|
+
maxWidth: "".concat(100 * UPSCALE_RATIO, "%"),
|
|
2245
|
+
flexGrow: 1,
|
|
2246
|
+
display: "flex"
|
|
2247
|
+
}
|
|
2248
|
+
}, props));
|
|
2249
|
+
});
|
|
2250
|
+
// src/components/threads/Thread/MessageForm/Field/index.tsx
|
|
2251
|
+
import { useFormContext } from "react-hook-form";
|
|
2252
|
+
import { Container as Container2, Flex as Flex14 } from "@radix-ui/themes";
|
|
2253
|
+
import { jsx as jsx41 } from "react/jsx-runtime";
|
|
2254
|
+
var Root3 = function(param) {
|
|
2255
|
+
var children = param.children;
|
|
2256
|
+
var _useFormContext = useFormContext(), errors = _useFormContext.formState.errors;
|
|
2257
|
+
return /* @__PURE__ */ jsx41(Container2, {
|
|
2258
|
+
size: "2",
|
|
2259
|
+
flexGrow: "0",
|
|
2260
|
+
children: /* @__PURE__ */ jsx41(Flex14, {
|
|
2261
|
+
direction: "column",
|
|
2262
|
+
flexShrink: "0",
|
|
2263
|
+
children: /* @__PURE__ */ jsx41(Flex14, {
|
|
2264
|
+
direction: "column",
|
|
2265
|
+
flexShrink: "0",
|
|
2266
|
+
children: /* @__PURE__ */ jsx41(Flex14, {
|
|
2267
|
+
style: _object_spread({
|
|
2268
|
+
borderRadius: "var(--radius-2)",
|
|
2269
|
+
borderWidth: "1px",
|
|
2270
|
+
borderStyle: "solid",
|
|
2271
|
+
borderColor: errors.content ? "var(--red-9)" : "var(--gray-5)"
|
|
2272
|
+
}, errors.content ? {
|
|
2273
|
+
backgroundColor: "var(--red-2)"
|
|
2274
|
+
} : {}),
|
|
2275
|
+
p: "2",
|
|
2276
|
+
pl: "4",
|
|
2277
|
+
children: children
|
|
2278
|
+
})
|
|
2279
|
+
})
|
|
2280
|
+
})
|
|
2281
|
+
});
|
|
2282
|
+
};
|
|
2283
|
+
var Control = function() {
|
|
2284
|
+
var assistantNameContext = useContext8(AssistantNameContext);
|
|
2285
|
+
var register = useFormContext().register;
|
|
2286
|
+
var _useMessageFormContext = useMessageFormContext(), isDisabled = _useMessageFormContext.isDisabled, isLoading = _useMessageFormContext.isLoading;
|
|
2287
|
+
var isSubmitDisabled = useMemo10(function() {
|
|
2199
2288
|
return isDisabled || isLoading;
|
|
2200
2289
|
}, [
|
|
2201
2290
|
isDisabled,
|
|
@@ -2214,123 +2303,108 @@ var ThreadMessageForm = function() {
|
|
|
2214
2303
|
isDisabledPrevious,
|
|
2215
2304
|
textareaProps
|
|
2216
2305
|
]);
|
|
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
|
-
});
|
|
2306
|
+
return /* @__PURE__ */ jsx41(TextareaBase, _object_spread_props(_object_spread({
|
|
2307
|
+
minRows: 1,
|
|
2308
|
+
placeholder: "Message ".concat(assistantNameContext, "..."),
|
|
2309
|
+
disabled: isDisabled,
|
|
2310
|
+
onKeyDown: function(e) {
|
|
2311
|
+
if (e.key === "Enter" && !e.shiftKey) {
|
|
2312
|
+
var _e_currentTarget_form;
|
|
2313
|
+
e.preventDefault();
|
|
2314
|
+
if (isSubmitDisabled) return;
|
|
2315
|
+
(_e_currentTarget_form = e.currentTarget.form) === null || _e_currentTarget_form === void 0 ? void 0 : _e_currentTarget_form.requestSubmit();
|
|
2316
|
+
}
|
|
2317
|
+
}
|
|
2318
|
+
}, textareaProps), {
|
|
2319
|
+
ref: function(e) {
|
|
2320
|
+
textareaProps.ref(e);
|
|
2321
|
+
textareaRef.current = e;
|
|
2322
|
+
}
|
|
2323
|
+
}));
|
|
2287
2324
|
};
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2325
|
+
var Field = {
|
|
2326
|
+
Root: Root3,
|
|
2327
|
+
Control: Control
|
|
2328
|
+
};
|
|
2329
|
+
// src/components/threads/Thread/MessageForm/index.tsx
|
|
2330
|
+
import { jsx as jsx42, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
2331
|
+
var MessageForm = function() {
|
|
2332
|
+
return /* @__PURE__ */ jsx42(Root2, {
|
|
2333
|
+
children: /* @__PURE__ */ jsxs12(Field.Root, {
|
|
2295
2334
|
children: [
|
|
2296
|
-
/* @__PURE__ */
|
|
2335
|
+
/* @__PURE__ */ jsx42(Text5, {
|
|
2336
|
+
size: "2",
|
|
2297
2337
|
style: {
|
|
2298
|
-
|
|
2299
|
-
}
|
|
2338
|
+
flexGrow: 1
|
|
2339
|
+
},
|
|
2340
|
+
children: /* @__PURE__ */ jsx42(Flex15, {
|
|
2341
|
+
flexGrow: "1",
|
|
2342
|
+
direction: "column",
|
|
2343
|
+
children: /* @__PURE__ */ jsx42(Field.Control, {})
|
|
2344
|
+
})
|
|
2300
2345
|
}),
|
|
2301
|
-
/* @__PURE__ */
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
paddingBottom: "var(--space-5)"
|
|
2306
|
-
}
|
|
2346
|
+
/* @__PURE__ */ jsx42(Flex15, {
|
|
2347
|
+
flexShrink: "0",
|
|
2348
|
+
align: "end",
|
|
2349
|
+
children: /* @__PURE__ */ jsx42(Submit, {})
|
|
2307
2350
|
})
|
|
2308
2351
|
]
|
|
2309
2352
|
})
|
|
2353
|
+
});
|
|
2354
|
+
};
|
|
2355
|
+
MessageForm.Root = Root2;
|
|
2356
|
+
MessageForm.Field = Field;
|
|
2357
|
+
MessageForm.Submit = Submit;
|
|
2358
|
+
// src/components/threads/Thread/Root/index.tsx
|
|
2359
|
+
import { Flex as Flex16 } from "@radix-ui/themes";
|
|
2360
|
+
import { jsx as jsx43 } from "react/jsx-runtime";
|
|
2361
|
+
var Root4 = function(_param) {
|
|
2362
|
+
var children = _param.children, rest = _object_without_properties(_param, [
|
|
2363
|
+
"children"
|
|
2364
|
+
]);
|
|
2365
|
+
return /* @__PURE__ */ jsx43(SuperinterfaceProvider, _object_spread_props(_object_spread({}, rest), {
|
|
2366
|
+
children: /* @__PURE__ */ jsx43(Flex16, {
|
|
2367
|
+
direction: "column",
|
|
2368
|
+
flexGrow: "1",
|
|
2369
|
+
children: children
|
|
2370
|
+
})
|
|
2371
|
+
}));
|
|
2372
|
+
};
|
|
2373
|
+
// src/components/threads/Thread/index.tsx
|
|
2374
|
+
import { jsx as jsx44, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
2375
|
+
var Thread = function(props) {
|
|
2376
|
+
return /* @__PURE__ */ jsxs13(Root4, _object_spread_props(_object_spread({}, props), {
|
|
2377
|
+
children: [
|
|
2378
|
+
/* @__PURE__ */ jsx44(Messages, {}),
|
|
2379
|
+
/* @__PURE__ */ jsx44(MessageForm, {})
|
|
2380
|
+
]
|
|
2310
2381
|
}));
|
|
2311
2382
|
};
|
|
2383
|
+
Thread.Root = Root4;
|
|
2384
|
+
Thread.Messages = Messages;
|
|
2385
|
+
Thread.MessageForm = MessageForm;
|
|
2312
2386
|
// src/components/threads/ThreadDialog/Root/index.tsx
|
|
2313
|
-
import { Flex as
|
|
2387
|
+
import { Flex as Flex17 } from "@radix-ui/themes";
|
|
2314
2388
|
// src/components/threads/ThreadDialog/Provider/index.tsx
|
|
2315
2389
|
import { useState } from "react";
|
|
2316
2390
|
// src/contexts/threads/ThreadDialogContext/index.ts
|
|
2317
|
-
import { createContext as
|
|
2318
|
-
var ThreadDialogContext =
|
|
2391
|
+
import { createContext as createContext7 } from "react";
|
|
2392
|
+
var ThreadDialogContext = createContext7({
|
|
2319
2393
|
isOpen: false,
|
|
2320
2394
|
setIsOpen: function() {}
|
|
2321
2395
|
});
|
|
2322
2396
|
// src/hooks/threads/useThreadDialogContext/index.ts
|
|
2323
|
-
import { useContext as
|
|
2397
|
+
import { useContext as useContext9 } from "react";
|
|
2324
2398
|
var useThreadDialogContext = function() {
|
|
2325
|
-
return
|
|
2399
|
+
return useContext9(ThreadDialogContext);
|
|
2326
2400
|
};
|
|
2327
2401
|
// src/components/threads/ThreadDialog/Provider/index.tsx
|
|
2328
|
-
import { jsx as
|
|
2402
|
+
import { jsx as jsx45 } from "react/jsx-runtime";
|
|
2329
2403
|
var Provider = function(param) {
|
|
2330
2404
|
var children = param.children;
|
|
2331
2405
|
var threadDialogContext = useThreadDialogContext();
|
|
2332
2406
|
var _useState = _sliced_to_array(useState(threadDialogContext.isOpen), 2), isOpen = _useState[0], setIsOpen = _useState[1];
|
|
2333
|
-
return /* @__PURE__ */
|
|
2407
|
+
return /* @__PURE__ */ jsx45(ThreadDialogContext.Provider, {
|
|
2334
2408
|
value: {
|
|
2335
2409
|
isOpen: isOpen,
|
|
2336
2410
|
setIsOpen: setIsOpen
|
|
@@ -2339,11 +2413,11 @@ var Provider = function(param) {
|
|
|
2339
2413
|
});
|
|
2340
2414
|
};
|
|
2341
2415
|
// src/components/threads/ThreadDialog/Root/index.tsx
|
|
2342
|
-
import { jsx as
|
|
2343
|
-
var
|
|
2416
|
+
import { jsx as jsx46 } from "react/jsx-runtime";
|
|
2417
|
+
var Root5 = function(param) {
|
|
2344
2418
|
var children = param.children, _param_style = param.style, style = _param_style === void 0 ? {} : _param_style;
|
|
2345
|
-
return /* @__PURE__ */
|
|
2346
|
-
children: /* @__PURE__ */
|
|
2419
|
+
return /* @__PURE__ */ jsx46(Provider, {
|
|
2420
|
+
children: /* @__PURE__ */ jsx46(Flex17, {
|
|
2347
2421
|
direction: "column",
|
|
2348
2422
|
justify: "end",
|
|
2349
2423
|
align: "end",
|
|
@@ -2359,94 +2433,107 @@ var Root = function(param) {
|
|
|
2359
2433
|
});
|
|
2360
2434
|
};
|
|
2361
2435
|
// src/components/threads/ThreadDialog/Trigger/index.tsx
|
|
2362
|
-
import { Flex as
|
|
2363
|
-
import { jsx as
|
|
2436
|
+
import { Flex as Flex18 } from "@radix-ui/themes";
|
|
2437
|
+
import { jsx as jsx47 } from "react/jsx-runtime";
|
|
2364
2438
|
var Trigger = function(param) {
|
|
2365
2439
|
var children = param.children;
|
|
2366
2440
|
var setIsOpen = useThreadDialogContext().setIsOpen;
|
|
2367
|
-
return /* @__PURE__ */
|
|
2441
|
+
return /* @__PURE__ */ jsx47(Flex18, {
|
|
2368
2442
|
onClick: function() {
|
|
2369
2443
|
return setIsOpen(function(prev) {
|
|
2370
2444
|
return !prev;
|
|
2371
2445
|
});
|
|
2372
2446
|
},
|
|
2373
2447
|
direction: "column",
|
|
2374
|
-
|
|
2448
|
+
flexShrink: "0",
|
|
2375
2449
|
children: children
|
|
2376
2450
|
});
|
|
2377
2451
|
};
|
|
2378
2452
|
// src/components/threads/ThreadDialog/Button/index.tsx
|
|
2379
2453
|
import { IconButton } from "@radix-ui/themes";
|
|
2380
2454
|
import { ChatBubbleIcon } from "@radix-ui/react-icons";
|
|
2381
|
-
import { jsx as
|
|
2455
|
+
import { jsx as jsx48 } from "react/jsx-runtime";
|
|
2382
2456
|
var Button3 = function() {
|
|
2383
|
-
return /* @__PURE__ */
|
|
2457
|
+
return /* @__PURE__ */ jsx48(IconButton, {
|
|
2384
2458
|
size: "4",
|
|
2385
2459
|
radius: "full",
|
|
2386
|
-
children: /* @__PURE__ */
|
|
2460
|
+
children: /* @__PURE__ */ jsx48(ChatBubbleIcon, {})
|
|
2387
2461
|
});
|
|
2388
2462
|
};
|
|
2389
2463
|
// src/components/threads/ThreadDialog/Content/index.tsx
|
|
2390
|
-
import { Card, Inset } from "@radix-ui/themes";
|
|
2391
|
-
import {
|
|
2392
|
-
var
|
|
2464
|
+
import { Card, Inset, Flex as Flex19 } from "@radix-ui/themes";
|
|
2465
|
+
import { jsx as jsx49, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
2466
|
+
var Root6 = function(param) {
|
|
2393
2467
|
var children = param.children;
|
|
2394
2468
|
var isOpen = useThreadDialogContext().isOpen;
|
|
2395
2469
|
if (!isOpen) return null;
|
|
2396
|
-
return /* @__PURE__ */
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2470
|
+
return /* @__PURE__ */ jsx49(Card, {
|
|
2471
|
+
mb: "3",
|
|
2472
|
+
style: {
|
|
2473
|
+
display: "flex",
|
|
2474
|
+
flexGrow: 1,
|
|
2475
|
+
width: "100vw",
|
|
2476
|
+
maxWidth: "400px",
|
|
2477
|
+
maxHeight: "720px"
|
|
2478
|
+
},
|
|
2479
|
+
children: /* @__PURE__ */ jsx49(Inset, {
|
|
2480
|
+
clip: "padding-box",
|
|
2481
|
+
side: "all",
|
|
2482
|
+
pb: "current",
|
|
2483
|
+
style: {
|
|
2484
|
+
display: "flex",
|
|
2485
|
+
flexGrow: 1
|
|
2486
|
+
},
|
|
2487
|
+
children: children
|
|
2488
|
+
})
|
|
2489
|
+
});
|
|
2490
|
+
};
|
|
2491
|
+
var Content4 = function() {
|
|
2492
|
+
return /* @__PURE__ */ jsx49(Root6, {
|
|
2493
|
+
children: /* @__PURE__ */ jsxs14(Thread.Root, {
|
|
2494
|
+
children: [
|
|
2495
|
+
/* @__PURE__ */ jsx49(Thread.Messages, {
|
|
2414
2496
|
style: {
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2497
|
+
padding: "var(--space-5)"
|
|
2498
|
+
}
|
|
2499
|
+
}),
|
|
2500
|
+
/* @__PURE__ */ jsx49(Flex19, {
|
|
2501
|
+
direction: "column",
|
|
2502
|
+
pl: "5",
|
|
2503
|
+
pr: "5",
|
|
2504
|
+
pb: "3",
|
|
2505
|
+
flexShrink: "0",
|
|
2506
|
+
children: /* @__PURE__ */ jsx49(Thread.MessageForm, {})
|
|
2419
2507
|
})
|
|
2420
|
-
|
|
2421
|
-
|
|
2508
|
+
]
|
|
2509
|
+
})
|
|
2422
2510
|
});
|
|
2423
2511
|
};
|
|
2512
|
+
Content4.Root = Root6;
|
|
2424
2513
|
// src/components/threads/ThreadDialog/index.tsx
|
|
2425
|
-
import { jsx as
|
|
2514
|
+
import { jsx as jsx50, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
2426
2515
|
var ThreadDialog = function() {
|
|
2427
|
-
return /* @__PURE__ */
|
|
2516
|
+
return /* @__PURE__ */ jsxs15(Root5, {
|
|
2428
2517
|
children: [
|
|
2429
|
-
/* @__PURE__ */
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
/* @__PURE__ */ jsx45(Trigger, {
|
|
2433
|
-
children: /* @__PURE__ */ jsx45(Button3, {})
|
|
2518
|
+
/* @__PURE__ */ jsx50(Content4, {}),
|
|
2519
|
+
/* @__PURE__ */ jsx50(Trigger, {
|
|
2520
|
+
children: /* @__PURE__ */ jsx50(Button3, {})
|
|
2434
2521
|
})
|
|
2435
2522
|
]
|
|
2436
2523
|
});
|
|
2437
2524
|
};
|
|
2438
|
-
ThreadDialog.Root =
|
|
2525
|
+
ThreadDialog.Root = Root5;
|
|
2439
2526
|
ThreadDialog.Trigger = Trigger;
|
|
2440
2527
|
ThreadDialog.Button = Button3;
|
|
2441
2528
|
ThreadDialog.Content = Content4;
|
|
2442
2529
|
// src/components/threads/AudioThread/Root/index.tsx
|
|
2443
2530
|
import "regenerator-runtime/runtime";
|
|
2444
2531
|
import { useEffect as useEffect7, useRef as useRef6 } from "react";
|
|
2445
|
-
import { Flex as
|
|
2532
|
+
import { Flex as Flex20 } from "@radix-ui/themes";
|
|
2446
2533
|
import SpeechRecognition, { useSpeechRecognition } from "react-speech-recognition";
|
|
2447
2534
|
// src/contexts/threads/AudioThreadContext/index.ts
|
|
2448
|
-
import { createContext as
|
|
2449
|
-
var AudioThreadContext =
|
|
2535
|
+
import { createContext as createContext8 } from "react";
|
|
2536
|
+
var AudioThreadContext = createContext8({
|
|
2450
2537
|
status: "idle",
|
|
2451
2538
|
recorderProps: {
|
|
2452
2539
|
status: "idle",
|
|
@@ -2504,13 +2591,13 @@ var AudioThreadContext = createContext7({
|
|
|
2504
2591
|
// src/components/threads/AudioThread/Root/index.tsx
|
|
2505
2592
|
import { usePermission } from "react-use";
|
|
2506
2593
|
// src/hooks/audioThreads/useStatus/index.ts
|
|
2507
|
-
import { useMemo as
|
|
2594
|
+
import { useMemo as useMemo11 } from "react";
|
|
2508
2595
|
var useStatus = function(param) {
|
|
2509
|
-
var messageAudioProps = param.messageAudioProps, recorderProps = param.recorderProps,
|
|
2596
|
+
var messageAudioProps = param.messageAudioProps, recorderProps = param.recorderProps, createMessageProps = param.createMessageProps;
|
|
2510
2597
|
var isRunActiveProps = useIsRunActive();
|
|
2511
|
-
var status =
|
|
2598
|
+
var status = useMemo11(function() {
|
|
2512
2599
|
if (recorderProps.status === "recording") return "recording";
|
|
2513
|
-
if (
|
|
2600
|
+
if (createMessageProps.isPending) return "creatingMessage";
|
|
2514
2601
|
if (isRunActiveProps.isRunActive) return "runActive";
|
|
2515
2602
|
if (messageAudioProps.playing) return "playing";
|
|
2516
2603
|
if (messageAudioProps.paused) return "playerPaused";
|
|
@@ -2521,7 +2608,7 @@ var useStatus = function(param) {
|
|
|
2521
2608
|
}, [
|
|
2522
2609
|
messageAudioProps,
|
|
2523
2610
|
recorderProps,
|
|
2524
|
-
|
|
2611
|
+
createMessageProps,
|
|
2525
2612
|
isRunActiveProps
|
|
2526
2613
|
]);
|
|
2527
2614
|
return {
|
|
@@ -2531,7 +2618,7 @@ var useStatus = function(param) {
|
|
|
2531
2618
|
// src/hooks/audioThreads/useRecorder/index.ts
|
|
2532
2619
|
import dayjs from "dayjs";
|
|
2533
2620
|
import { useAudioCapture } from "use-audio-capture";
|
|
2534
|
-
import { useMemo as
|
|
2621
|
+
import { useMemo as useMemo12, useRef as useRef4, useState as useState2, useCallback as useCallback2, useEffect as useEffect5 } from "react";
|
|
2535
2622
|
import { useAudioPlayer } from "react-use-audio-player";
|
|
2536
2623
|
import { useInterval as useInterval2 } from "react-use";
|
|
2537
2624
|
var useRecorder = function(param) {
|
|
@@ -2624,7 +2711,7 @@ var useRecorder = function(param) {
|
|
|
2624
2711
|
isInited,
|
|
2625
2712
|
mediaStream
|
|
2626
2713
|
]);
|
|
2627
|
-
var visualizationAnalyser =
|
|
2714
|
+
var visualizationAnalyser = useMemo12(function() {
|
|
2628
2715
|
if (!audioEngine) return null;
|
|
2629
2716
|
var result = audioEngine.audioContext.createAnalyser();
|
|
2630
2717
|
audioEngine.source.connect(result);
|
|
@@ -2632,7 +2719,7 @@ var useRecorder = function(param) {
|
|
|
2632
2719
|
}, [
|
|
2633
2720
|
audioEngine
|
|
2634
2721
|
]);
|
|
2635
|
-
var silenceAnalyser =
|
|
2722
|
+
var silenceAnalyser = useMemo12(function() {
|
|
2636
2723
|
if (!audioEngine) return null;
|
|
2637
2724
|
var result = audioEngine.audioContext.createAnalyser();
|
|
2638
2725
|
result.minDecibels = -45;
|
|
@@ -2687,14 +2774,14 @@ var useRecorder = function(param) {
|
|
|
2687
2774
|
});
|
|
2688
2775
|
};
|
|
2689
2776
|
// src/hooks/audioThreads/useMessageAudio/index.ts
|
|
2690
|
-
import { useMemo as
|
|
2777
|
+
import { useMemo as useMemo13, useRef as useRef5, useState as useState3, useEffect as useEffect6 } from "react";
|
|
2691
2778
|
import { Howler } from "howler";
|
|
2692
2779
|
import { useAudioPlayer as useAudioPlayer2 } from "react-use-audio-player";
|
|
2693
2780
|
// src/hooks/audioThreads/useMessageAudio/lib/input.ts
|
|
2694
2781
|
import { isEmpty } from "radash";
|
|
2695
2782
|
var input = function(param) {
|
|
2696
|
-
var
|
|
2697
|
-
var textContents =
|
|
2783
|
+
var message = param.message;
|
|
2784
|
+
var textContents = message.content.filter(function(c) {
|
|
2698
2785
|
return c.type === "text";
|
|
2699
2786
|
});
|
|
2700
2787
|
var result = textContents.map(function(c) {
|
|
@@ -2716,19 +2803,19 @@ var useMessageAudio = function(param) {
|
|
|
2716
2803
|
var _useState3 = _sliced_to_array(useState3([]), 2), playedMessageIds = _useState3[0], setPlayedMessageIds = _useState3[1];
|
|
2717
2804
|
var audioPlayer = useAudioPlayer2();
|
|
2718
2805
|
var superinterfaceContext = useSuperinterfaceContext();
|
|
2719
|
-
var
|
|
2806
|
+
var latestMessageProps = useLatestMessage();
|
|
2720
2807
|
useEffect6(function() {
|
|
2721
2808
|
if (audioPlayer.playing) return;
|
|
2722
|
-
if (!
|
|
2723
|
-
if (
|
|
2724
|
-
if (playedMessageIds.includes(
|
|
2809
|
+
if (!latestMessageProps.latestMessage) return;
|
|
2810
|
+
if (latestMessageProps.latestMessage.role !== "assistant") return;
|
|
2811
|
+
if (playedMessageIds.includes(latestMessageProps.latestMessage.id)) return;
|
|
2725
2812
|
var input2 = input({
|
|
2726
|
-
|
|
2813
|
+
message: latestMessageProps.latestMessage
|
|
2727
2814
|
});
|
|
2728
2815
|
if (!input2) return;
|
|
2729
2816
|
setPlayedMessageIds(function(prev) {
|
|
2730
2817
|
return _to_consumable_array(prev).concat([
|
|
2731
|
-
|
|
2818
|
+
latestMessageProps.latestMessage.id
|
|
2732
2819
|
]);
|
|
2733
2820
|
});
|
|
2734
2821
|
audioPlayer.load("".concat(superinterfaceContext.baseUrl, "/tts?input=").concat(input2), {
|
|
@@ -2739,7 +2826,7 @@ var useMessageAudio = function(param) {
|
|
|
2739
2826
|
});
|
|
2740
2827
|
}, [
|
|
2741
2828
|
superinterfaceContext,
|
|
2742
|
-
|
|
2829
|
+
latestMessageProps,
|
|
2743
2830
|
audioPlayer,
|
|
2744
2831
|
playedMessageIds,
|
|
2745
2832
|
onEnd
|
|
@@ -2767,7 +2854,7 @@ var useMessageAudio = function(param) {
|
|
|
2767
2854
|
audioPlayer,
|
|
2768
2855
|
isInited
|
|
2769
2856
|
]);
|
|
2770
|
-
var visualizationAnalyser =
|
|
2857
|
+
var visualizationAnalyser = useMemo13(function() {
|
|
2771
2858
|
if (!audioEngine) return null;
|
|
2772
2859
|
var result = audioEngine.audioContext.createAnalyser();
|
|
2773
2860
|
audioEngine.source.connect(audioEngine.audioContext.destination);
|
|
@@ -2781,17 +2868,12 @@ var useMessageAudio = function(param) {
|
|
|
2781
2868
|
});
|
|
2782
2869
|
};
|
|
2783
2870
|
// src/components/threads/AudioThread/Root/index.tsx
|
|
2784
|
-
import { jsx as
|
|
2785
|
-
var
|
|
2871
|
+
import { jsx as jsx51 } from "react/jsx-runtime";
|
|
2872
|
+
var Root7 = function(param) {
|
|
2786
2873
|
var children = param.children;
|
|
2787
|
-
|
|
2788
|
-
var
|
|
2789
|
-
var _useSpeechRecognition = useSpeechRecognition(), transcript = _useSpeechRecognition.transcript,
|
|
2790
|
-
"transcript",
|
|
2791
|
-
"listening",
|
|
2792
|
-
"resetTranscript",
|
|
2793
|
-
"browserSupportsSpeechRecognition"
|
|
2794
|
-
]);
|
|
2874
|
+
useLifecycle();
|
|
2875
|
+
var createMessageProps = useCreateMessage();
|
|
2876
|
+
var _useSpeechRecognition = useSpeechRecognition(), transcript = _useSpeechRecognition.transcript, resetTranscript = _useSpeechRecognition.resetTranscript;
|
|
2795
2877
|
var transcriptRef = useRef6(transcript);
|
|
2796
2878
|
useEffect7(function() {
|
|
2797
2879
|
transcriptRef.current = transcript;
|
|
@@ -2813,20 +2895,21 @@ var Root2 = function(param) {
|
|
|
2813
2895
|
});
|
|
2814
2896
|
}),
|
|
2815
2897
|
onStop: function() {
|
|
2816
|
-
var _ref = _async_to_generator(function(_event,
|
|
2898
|
+
var _ref = _async_to_generator(function(_event, _chunks) {
|
|
2817
2899
|
return _ts_generator(this, function(_state) {
|
|
2818
2900
|
console.log({
|
|
2819
2901
|
transcript: transcriptRef.current
|
|
2820
2902
|
});
|
|
2821
2903
|
return [
|
|
2822
2904
|
2,
|
|
2823
|
-
|
|
2905
|
+
createMessageProps.createMessage({
|
|
2906
|
+
// @ts-ignore-next-line
|
|
2824
2907
|
content: transcriptRef.current
|
|
2825
2908
|
})
|
|
2826
2909
|
];
|
|
2827
2910
|
});
|
|
2828
2911
|
});
|
|
2829
|
-
return function(_event,
|
|
2912
|
+
return function(_event, _chunks) {
|
|
2830
2913
|
return _ref.apply(this, arguments);
|
|
2831
2914
|
};
|
|
2832
2915
|
}()
|
|
@@ -2843,47 +2926,47 @@ var Root2 = function(param) {
|
|
|
2843
2926
|
});
|
|
2844
2927
|
var status = useStatus({
|
|
2845
2928
|
recorderProps: recorderProps,
|
|
2846
|
-
|
|
2929
|
+
createMessageProps: createMessageProps,
|
|
2847
2930
|
messageAudioProps: messageAudioProps
|
|
2848
2931
|
}).status;
|
|
2849
|
-
return /* @__PURE__ */
|
|
2932
|
+
return /* @__PURE__ */ jsx51(AudioThreadContext.Provider, {
|
|
2850
2933
|
value: {
|
|
2851
2934
|
status: status,
|
|
2852
2935
|
recorderProps: recorderProps,
|
|
2853
2936
|
messageAudioProps: messageAudioProps
|
|
2854
2937
|
},
|
|
2855
|
-
children: /* @__PURE__ */
|
|
2938
|
+
children: /* @__PURE__ */ jsx51(Flex20, {
|
|
2856
2939
|
direction: "column",
|
|
2857
|
-
|
|
2940
|
+
flexGrow: "1",
|
|
2858
2941
|
p: "5",
|
|
2859
2942
|
children: children
|
|
2860
2943
|
})
|
|
2861
2944
|
});
|
|
2862
2945
|
};
|
|
2863
2946
|
// src/components/threads/AudioThread/Visualization/index.tsx
|
|
2864
|
-
import { Flex as
|
|
2947
|
+
import { Flex as Flex21 } from "@radix-ui/themes";
|
|
2865
2948
|
// src/hooks/threads/useAudioThreadContext/index.ts
|
|
2866
|
-
import { useContext as
|
|
2949
|
+
import { useContext as useContext10 } from "react";
|
|
2867
2950
|
var useAudioThreadContext = function() {
|
|
2868
|
-
return
|
|
2951
|
+
return useContext10(AudioThreadContext);
|
|
2869
2952
|
};
|
|
2870
2953
|
// src/components/threads/AudioThread/Visualization/index.tsx
|
|
2871
|
-
import { jsx as
|
|
2954
|
+
import { jsx as jsx52 } from "react/jsx-runtime";
|
|
2872
2955
|
var Visualization = function() {
|
|
2873
2956
|
var audioThreadContext = useAudioThreadContext();
|
|
2874
|
-
return /* @__PURE__ */
|
|
2957
|
+
return /* @__PURE__ */ jsx52(Flex21, {
|
|
2875
2958
|
direction: "column",
|
|
2876
2959
|
align: "center",
|
|
2877
2960
|
justify: "center",
|
|
2878
2961
|
mb: "3",
|
|
2879
|
-
|
|
2880
|
-
children: /* @__PURE__ */
|
|
2962
|
+
flexGrow: "1",
|
|
2963
|
+
children: /* @__PURE__ */ jsx52(Flex21, {
|
|
2881
2964
|
align: "center",
|
|
2882
2965
|
justify: "center",
|
|
2966
|
+
height: "200px",
|
|
2967
|
+
width: "200px",
|
|
2883
2968
|
style: {
|
|
2884
2969
|
backgroundColor: "var(--".concat(audioThreadContext.status === "playing" ? "mint" : "gray", "-4)"),
|
|
2885
|
-
height: "200px",
|
|
2886
|
-
width: "200px",
|
|
2887
2970
|
borderRadius: "9999px"
|
|
2888
2971
|
}
|
|
2889
2972
|
})
|
|
@@ -2891,13 +2974,13 @@ var Visualization = function() {
|
|
|
2891
2974
|
};
|
|
2892
2975
|
// src/components/threads/AudioThread/Form/index.tsx
|
|
2893
2976
|
import { SpeakerModerateIcon } from "@radix-ui/react-icons";
|
|
2894
|
-
import { Flex as
|
|
2977
|
+
import { Flex as Flex24 } from "@radix-ui/themes";
|
|
2895
2978
|
// src/components/threads/AudioThread/Form/Visualizer/index.tsx
|
|
2896
2979
|
import _7 from "lodash";
|
|
2897
|
-
import { Flex as
|
|
2898
|
-
import { useState as useState4, useEffect as useEffect8, useCallback as
|
|
2980
|
+
import { Flex as Flex22, Grid } from "@radix-ui/themes";
|
|
2981
|
+
import { useState as useState4, useEffect as useEffect8, useCallback as useCallback3 } from "react";
|
|
2899
2982
|
import { cluster } from "radash";
|
|
2900
|
-
import { jsx as
|
|
2983
|
+
import { jsx as jsx53 } from "react/jsx-runtime";
|
|
2901
2984
|
var barCount = 4;
|
|
2902
2985
|
var Visualizer = function() {
|
|
2903
2986
|
var audioThreadContext = useAudioThreadContext();
|
|
@@ -2906,7 +2989,7 @@ var Visualizer = function() {
|
|
|
2906
2989
|
return new AudioContext().createAnalyser();
|
|
2907
2990
|
}), 1), emptyVisualizer = _useState4[0];
|
|
2908
2991
|
var _useState41 = _sliced_to_array(useState4([]), 2), barHeights = _useState41[0], setBarHeights = _useState41[1];
|
|
2909
|
-
var draw =
|
|
2992
|
+
var draw = useCallback3(function(param) {
|
|
2910
2993
|
var visualizationAnalyser2 = param.visualizationAnalyser;
|
|
2911
2994
|
var frequencyData = new Uint8Array(visualizationAnalyser2.frequencyBinCount / 15);
|
|
2912
2995
|
visualizationAnalyser2.getByteFrequencyData(frequencyData);
|
|
@@ -2929,7 +3012,7 @@ var Visualizer = function() {
|
|
|
2929
3012
|
visualizationAnalyser,
|
|
2930
3013
|
emptyVisualizer
|
|
2931
3014
|
]);
|
|
2932
|
-
return /* @__PURE__ */
|
|
3015
|
+
return /* @__PURE__ */ jsx53(Grid, {
|
|
2933
3016
|
columns: "".concat(barCount),
|
|
2934
3017
|
gap: "1",
|
|
2935
3018
|
width: "auto",
|
|
@@ -2938,21 +3021,19 @@ var Visualizer = function() {
|
|
|
2938
3021
|
gridTemplateColumns: "repeat(4, minmax(0, 1fr))"
|
|
2939
3022
|
},
|
|
2940
3023
|
children: barHeights.map(function(barHeight, index) {
|
|
2941
|
-
return /* @__PURE__ */
|
|
3024
|
+
return /* @__PURE__ */ jsx53(Flex22, {
|
|
2942
3025
|
direction: "column",
|
|
2943
3026
|
align: "center",
|
|
2944
3027
|
justify: "center",
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
3028
|
+
height: "20px",
|
|
3029
|
+
children: /* @__PURE__ */ jsx53(Flex22, {
|
|
3030
|
+
minHeight: "50%",
|
|
3031
|
+
maxHeight: "100%",
|
|
3032
|
+
height: "".concat(barHeight + 20, "%"),
|
|
3033
|
+
width: "12px",
|
|
2949
3034
|
style: {
|
|
2950
3035
|
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"
|
|
3036
|
+
borderRadius: "var(--radius-6)"
|
|
2956
3037
|
}
|
|
2957
3038
|
})
|
|
2958
3039
|
}, index);
|
|
@@ -2960,31 +3041,31 @@ var Visualizer = function() {
|
|
|
2960
3041
|
});
|
|
2961
3042
|
};
|
|
2962
3043
|
// src/components/threads/AudioThread/Form/ActionButton/index.tsx
|
|
2963
|
-
import { Flex as
|
|
3044
|
+
import { Flex as Flex23, IconButton as IconButton2, Tooltip } from "@radix-ui/themes";
|
|
2964
3045
|
import { PauseIcon, ArrowUpIcon as ArrowUpIcon2, ResumeIcon } from "@radix-ui/react-icons";
|
|
2965
|
-
import { jsx as
|
|
3046
|
+
import { jsx as jsx54, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
2966
3047
|
var ActionButton = function() {
|
|
2967
3048
|
var audioThreadContext = useAudioThreadContext();
|
|
2968
3049
|
if (audioThreadContext.status === "recording") {
|
|
2969
|
-
return /* @__PURE__ */
|
|
3050
|
+
return /* @__PURE__ */ jsxs16(Flex23, {
|
|
2970
3051
|
align: "center",
|
|
2971
3052
|
children: [
|
|
2972
|
-
/* @__PURE__ */
|
|
3053
|
+
/* @__PURE__ */ jsx54(Flex23, {
|
|
2973
3054
|
mr: "3",
|
|
2974
3055
|
ml: "-7",
|
|
2975
|
-
children: /* @__PURE__ */
|
|
3056
|
+
children: /* @__PURE__ */ jsx54(IconButton2, {
|
|
2976
3057
|
onClick: audioThreadContext.recorderProps.pause,
|
|
2977
3058
|
color: "gray",
|
|
2978
3059
|
radius: "full",
|
|
2979
3060
|
size: "1",
|
|
2980
|
-
children: /* @__PURE__ */
|
|
3061
|
+
children: /* @__PURE__ */ jsx54(PauseIcon, {})
|
|
2981
3062
|
})
|
|
2982
3063
|
}),
|
|
2983
|
-
/* @__PURE__ */
|
|
3064
|
+
/* @__PURE__ */ jsx54(Tooltip, {
|
|
2984
3065
|
open: true,
|
|
2985
3066
|
content: "Send your message",
|
|
2986
3067
|
side: "bottom",
|
|
2987
|
-
children: /* @__PURE__ */
|
|
3068
|
+
children: /* @__PURE__ */ jsx54(IconButton2, {
|
|
2988
3069
|
onClick: audioThreadContext.recorderProps.stop,
|
|
2989
3070
|
color: "gray",
|
|
2990
3071
|
highContrast: true,
|
|
@@ -2993,14 +3074,14 @@ var ActionButton = function() {
|
|
|
2993
3074
|
style: {
|
|
2994
3075
|
border: "2px solid var(--gray-8)"
|
|
2995
3076
|
},
|
|
2996
|
-
children: /* @__PURE__ */
|
|
3077
|
+
children: /* @__PURE__ */ jsx54(ArrowUpIcon2, {})
|
|
2997
3078
|
})
|
|
2998
3079
|
})
|
|
2999
3080
|
]
|
|
3000
3081
|
});
|
|
3001
3082
|
}
|
|
3002
3083
|
if (audioThreadContext.status === "recorderPaused") {
|
|
3003
|
-
return /* @__PURE__ */
|
|
3084
|
+
return /* @__PURE__ */ jsx54(IconButton2, {
|
|
3004
3085
|
onClick: audioThreadContext.recorderProps.resume,
|
|
3005
3086
|
color: "red",
|
|
3006
3087
|
radius: "full",
|
|
@@ -3008,11 +3089,11 @@ var ActionButton = function() {
|
|
|
3008
3089
|
style: {
|
|
3009
3090
|
border: "2px solid var(--gray-8)"
|
|
3010
3091
|
},
|
|
3011
|
-
children: /* @__PURE__ */
|
|
3092
|
+
children: /* @__PURE__ */ jsx54(ResumeIcon, {})
|
|
3012
3093
|
});
|
|
3013
3094
|
}
|
|
3014
3095
|
if (audioThreadContext.status === "idle") {
|
|
3015
|
-
return /* @__PURE__ */
|
|
3096
|
+
return /* @__PURE__ */ jsx54(IconButton2, {
|
|
3016
3097
|
onClick: function() {
|
|
3017
3098
|
return audioThreadContext.recorderProps.start();
|
|
3018
3099
|
},
|
|
@@ -3025,7 +3106,7 @@ var ActionButton = function() {
|
|
|
3025
3106
|
});
|
|
3026
3107
|
}
|
|
3027
3108
|
if (audioThreadContext.status === "playing") {
|
|
3028
|
-
return /* @__PURE__ */
|
|
3109
|
+
return /* @__PURE__ */ jsx54(IconButton2, {
|
|
3029
3110
|
onClick: function() {
|
|
3030
3111
|
return audioThreadContext.messageAudioProps.pause();
|
|
3031
3112
|
},
|
|
@@ -3035,11 +3116,11 @@ var ActionButton = function() {
|
|
|
3035
3116
|
style: {
|
|
3036
3117
|
border: "2px solid var(--gray-8)"
|
|
3037
3118
|
},
|
|
3038
|
-
children: /* @__PURE__ */
|
|
3119
|
+
children: /* @__PURE__ */ jsx54(PauseIcon, {})
|
|
3039
3120
|
});
|
|
3040
3121
|
}
|
|
3041
3122
|
if (audioThreadContext.status === "playerPaused") {
|
|
3042
|
-
return /* @__PURE__ */
|
|
3123
|
+
return /* @__PURE__ */ jsx54(IconButton2, {
|
|
3043
3124
|
onClick: function() {
|
|
3044
3125
|
return audioThreadContext.messageAudioProps.play();
|
|
3045
3126
|
},
|
|
@@ -3049,10 +3130,10 @@ var ActionButton = function() {
|
|
|
3049
3130
|
style: {
|
|
3050
3131
|
border: "2px solid var(--gray-8)"
|
|
3051
3132
|
},
|
|
3052
|
-
children: /* @__PURE__ */
|
|
3133
|
+
children: /* @__PURE__ */ jsx54(ResumeIcon, {})
|
|
3053
3134
|
});
|
|
3054
3135
|
}
|
|
3055
|
-
return /* @__PURE__ */
|
|
3136
|
+
return /* @__PURE__ */ jsx54(IconButton2, {
|
|
3056
3137
|
size: "4",
|
|
3057
3138
|
color: "red",
|
|
3058
3139
|
radius: "full",
|
|
@@ -3063,140 +3144,141 @@ var ActionButton = function() {
|
|
|
3063
3144
|
});
|
|
3064
3145
|
};
|
|
3065
3146
|
// src/components/threads/AudioThread/Form/index.tsx
|
|
3066
|
-
import { jsx as
|
|
3147
|
+
import { jsx as jsx55, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
3067
3148
|
var Form = function() {
|
|
3068
3149
|
var audioThreadContext = useAudioThreadContext();
|
|
3069
|
-
return /* @__PURE__ */
|
|
3150
|
+
return /* @__PURE__ */ jsxs17(Flex24, {
|
|
3070
3151
|
direction: "column",
|
|
3071
3152
|
align: "center",
|
|
3072
3153
|
children: [
|
|
3073
|
-
/* @__PURE__ */
|
|
3154
|
+
/* @__PURE__ */ jsxs17(Flex24, {
|
|
3074
3155
|
pb: "3",
|
|
3075
3156
|
align: "center",
|
|
3076
3157
|
children: [
|
|
3077
|
-
/* @__PURE__ */
|
|
3158
|
+
/* @__PURE__ */ jsx55(Flex24, {
|
|
3078
3159
|
ml: "-5",
|
|
3079
3160
|
mr: "2",
|
|
3080
3161
|
align: "center",
|
|
3081
|
-
children: /* @__PURE__ */
|
|
3162
|
+
children: /* @__PURE__ */ jsx55(SpeakerModerateIcon, {
|
|
3082
3163
|
style: {
|
|
3083
3164
|
color: "var(--".concat(audioThreadContext.status === "recording" ? "mint" : "gray", "-12)")
|
|
3084
3165
|
}
|
|
3085
3166
|
})
|
|
3086
3167
|
}),
|
|
3087
|
-
/* @__PURE__ */
|
|
3168
|
+
/* @__PURE__ */ jsx55(Flex24, {
|
|
3088
3169
|
px: "2",
|
|
3089
3170
|
py: "1",
|
|
3090
3171
|
style: {
|
|
3091
3172
|
backgroundColor: "var(--".concat(audioThreadContext.status === "recording" ? "mint" : "gray", "-4)"),
|
|
3092
3173
|
borderRadius: "var(--radius-6)"
|
|
3093
3174
|
},
|
|
3094
|
-
children: /* @__PURE__ */
|
|
3175
|
+
children: /* @__PURE__ */ jsx55(Visualizer, {})
|
|
3095
3176
|
})
|
|
3096
3177
|
]
|
|
3097
3178
|
}),
|
|
3098
|
-
/* @__PURE__ */
|
|
3179
|
+
/* @__PURE__ */ jsx55(ActionButton, {})
|
|
3099
3180
|
]
|
|
3100
3181
|
});
|
|
3101
3182
|
};
|
|
3102
3183
|
// src/components/threads/AudioThread/index.tsx
|
|
3103
|
-
import { jsx as
|
|
3184
|
+
import { jsx as jsx56, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
3104
3185
|
var AudioThread = function(props) {
|
|
3105
|
-
return /* @__PURE__ */
|
|
3186
|
+
return /* @__PURE__ */ jsxs18(Root7, _object_spread_props(_object_spread({}, props), {
|
|
3106
3187
|
children: [
|
|
3107
|
-
/* @__PURE__ */
|
|
3108
|
-
/* @__PURE__ */
|
|
3188
|
+
/* @__PURE__ */ jsx56(Visualization, {}),
|
|
3189
|
+
/* @__PURE__ */ jsx56(Form, {})
|
|
3109
3190
|
]
|
|
3110
3191
|
}));
|
|
3111
3192
|
};
|
|
3112
|
-
AudioThread.Root =
|
|
3193
|
+
AudioThread.Root = Root7;
|
|
3113
3194
|
AudioThread.Visualization = Visualization;
|
|
3114
3195
|
AudioThread.Form = Form;
|
|
3115
3196
|
// src/components/threads/AudioThreadDialog/index.tsx
|
|
3116
|
-
import { jsx as
|
|
3197
|
+
import { jsx as jsx57, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
3117
3198
|
var AudioThreadDialog = function() {
|
|
3118
|
-
return /* @__PURE__ */
|
|
3199
|
+
return /* @__PURE__ */ jsxs19(Root5, {
|
|
3119
3200
|
children: [
|
|
3120
|
-
/* @__PURE__ */
|
|
3121
|
-
children: /* @__PURE__ */
|
|
3201
|
+
/* @__PURE__ */ jsx57(Content4.Root, {
|
|
3202
|
+
children: /* @__PURE__ */ jsx57(AudioThread, {})
|
|
3122
3203
|
}),
|
|
3123
|
-
/* @__PURE__ */
|
|
3124
|
-
children: /* @__PURE__ */
|
|
3204
|
+
/* @__PURE__ */ jsx57(Trigger, {
|
|
3205
|
+
children: /* @__PURE__ */ jsx57(Button3, {})
|
|
3125
3206
|
})
|
|
3126
3207
|
]
|
|
3127
3208
|
});
|
|
3128
3209
|
};
|
|
3129
|
-
AudioThreadDialog.Root =
|
|
3210
|
+
AudioThreadDialog.Root = Root5;
|
|
3130
3211
|
AudioThreadDialog.Trigger = Trigger;
|
|
3131
3212
|
AudioThreadDialog.Button = Button3;
|
|
3132
3213
|
AudioThreadDialog.Content = Content4;
|
|
3133
3214
|
// src/components/suggestions/Suggestions/index.tsx
|
|
3134
|
-
import { useMemo as
|
|
3135
|
-
import { Flex as
|
|
3215
|
+
import { useMemo as useMemo14 } from "react";
|
|
3216
|
+
import { Flex as Flex25 } from "@radix-ui/themes";
|
|
3136
3217
|
// src/components/suggestions/Suggestion/index.tsx
|
|
3137
3218
|
import { ArrowUpIcon as ArrowUpIcon3 } from "@radix-ui/react-icons";
|
|
3138
3219
|
import { Text as Text6, Button as Button4 } from "@radix-ui/themes";
|
|
3139
|
-
import { jsx as
|
|
3220
|
+
import { jsx as jsx58, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
3140
3221
|
var Suggestion = function(param) {
|
|
3141
3222
|
var suggestion = param.suggestion;
|
|
3142
|
-
var
|
|
3223
|
+
var createMessage = useCreateMessage().createMessage;
|
|
3143
3224
|
var _useIsRunActive = useIsRunActive(), isRunActive2 = _useIsRunActive.isRunActive;
|
|
3144
|
-
return /* @__PURE__ */
|
|
3225
|
+
return /* @__PURE__ */ jsxs20(Button4, {
|
|
3145
3226
|
variant: "soft",
|
|
3146
3227
|
style: {
|
|
3147
3228
|
justifyContent: "space-between"
|
|
3148
3229
|
},
|
|
3149
3230
|
onClick: function() {
|
|
3150
|
-
|
|
3231
|
+
createMessage({
|
|
3232
|
+
// @ts-ignore-next-line
|
|
3151
3233
|
content: suggestion
|
|
3152
3234
|
});
|
|
3153
3235
|
},
|
|
3154
3236
|
disabled: isRunActive2,
|
|
3155
3237
|
children: [
|
|
3156
|
-
/* @__PURE__ */
|
|
3238
|
+
/* @__PURE__ */ jsx58(Text6, {
|
|
3157
3239
|
size: "1",
|
|
3158
3240
|
weight: "regular",
|
|
3159
3241
|
children: suggestion
|
|
3160
3242
|
}),
|
|
3161
|
-
/* @__PURE__ */
|
|
3243
|
+
/* @__PURE__ */ jsx58(ArrowUpIcon3, {})
|
|
3162
3244
|
]
|
|
3163
3245
|
});
|
|
3164
3246
|
};
|
|
3165
3247
|
// src/components/suggestions/Suggestions/index.tsx
|
|
3166
|
-
import { jsx as
|
|
3248
|
+
import { jsx as jsx59 } from "react/jsx-runtime";
|
|
3167
3249
|
var Suggestions = function(param) {
|
|
3168
3250
|
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
|
|
3251
|
+
var latestMessageProps = useLatestMessage();
|
|
3170
3252
|
var isRunActiveProps = useIsRunActive();
|
|
3171
|
-
var isDisabled =
|
|
3253
|
+
var isDisabled = useMemo14(function() {
|
|
3172
3254
|
var // @ts-ignore-next-line
|
|
3173
|
-
|
|
3174
|
-
return ((
|
|
3255
|
+
_latestMessageProps_latestMessage_metadata, _latestMessageProps_latestMessage;
|
|
3256
|
+
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
3257
|
}, [
|
|
3176
|
-
|
|
3258
|
+
latestMessageProps,
|
|
3177
3259
|
isRunActiveProps
|
|
3178
3260
|
]);
|
|
3179
|
-
if (
|
|
3261
|
+
if (latestMessageProps.isLoading) return null;
|
|
3180
3262
|
if (isDisabled) return null;
|
|
3181
|
-
if (!
|
|
3182
|
-
return /* @__PURE__ */
|
|
3263
|
+
if (!latestMessageProps.latestMessage && emptyStateSuggestions.length > 0) {
|
|
3264
|
+
return /* @__PURE__ */ jsx59(Flex25, {
|
|
3183
3265
|
gap: "2",
|
|
3184
3266
|
py: "2",
|
|
3185
3267
|
wrap: "wrap",
|
|
3186
3268
|
children: emptyStateSuggestions.map(function(suggestion) {
|
|
3187
|
-
return /* @__PURE__ */
|
|
3269
|
+
return /* @__PURE__ */ jsx59(Suggestion, {
|
|
3188
3270
|
suggestion: suggestion
|
|
3189
3271
|
}, suggestion);
|
|
3190
3272
|
})
|
|
3191
3273
|
});
|
|
3192
3274
|
}
|
|
3193
|
-
if (
|
|
3194
|
-
return /* @__PURE__ */
|
|
3275
|
+
if (latestMessageProps.latestMessage.role === "assistant") {
|
|
3276
|
+
return /* @__PURE__ */ jsx59(Flex25, {
|
|
3195
3277
|
gap: "2",
|
|
3196
3278
|
py: "2",
|
|
3197
3279
|
wrap: "wrap",
|
|
3198
3280
|
children: suggestions.map(function(suggestion) {
|
|
3199
|
-
return /* @__PURE__ */
|
|
3281
|
+
return /* @__PURE__ */ jsx59(Suggestion, {
|
|
3200
3282
|
suggestion: suggestion
|
|
3201
3283
|
}, suggestion);
|
|
3202
3284
|
})
|
|
@@ -3205,9 +3287,9 @@ var Suggestions = function(param) {
|
|
|
3205
3287
|
return null;
|
|
3206
3288
|
};
|
|
3207
3289
|
// src/hooks/markdown/useMarkdownContext/index.ts
|
|
3208
|
-
import { useContext as
|
|
3290
|
+
import { useContext as useContext11 } from "react";
|
|
3209
3291
|
var useMarkdownContext = function() {
|
|
3210
|
-
return
|
|
3292
|
+
return useContext11(MarkdownContext);
|
|
3211
3293
|
};
|
|
3212
|
-
export { AssistantAvatarContext, AssistantNameContext, AudioThread, AudioThreadDialog, FunctionBase, FunctionComponentsContext, MarkdownContext, Suggestion, Suggestions, SuperinterfaceProvider, Thread, ThreadDialog,
|
|
3294
|
+
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
3295
|
//# sourceMappingURL=index.js.map
|