@axiom-lattice/react-sdk 2.1.11 → 2.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +291 -26
- package/dist/index.d.ts +291 -26
- package/dist/index.js +1268 -319
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1279 -316
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -59,7 +59,6 @@ function useChat(threadId, options = {}) {
|
|
|
59
59
|
messages: options.initialMessages || [],
|
|
60
60
|
isLoading: false,
|
|
61
61
|
error: null,
|
|
62
|
-
streamingMessage: null,
|
|
63
62
|
interrupts: void 0,
|
|
64
63
|
...options.enableReturnStateWhenStreamCompleted ? { agentState: null } : {}
|
|
65
64
|
});
|
|
@@ -367,7 +366,9 @@ import {
|
|
|
367
366
|
useEffect as useEffect3,
|
|
368
367
|
useRef as useRef2
|
|
369
368
|
} from "react";
|
|
370
|
-
import {
|
|
369
|
+
import {
|
|
370
|
+
createSimpleMessageMerger as createSimpleMessageMerger2
|
|
371
|
+
} from "@axiom-lattice/client-sdk";
|
|
371
372
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
372
373
|
var AgentThreadContext = createContext2(
|
|
373
374
|
null
|
|
@@ -390,10 +391,17 @@ function AgentThreadProvider({
|
|
|
390
391
|
messages: options.initialMessages || [],
|
|
391
392
|
isLoading: false,
|
|
392
393
|
error: null,
|
|
393
|
-
streamingMessage: null,
|
|
394
394
|
interrupts: void 0,
|
|
395
395
|
agentState: null
|
|
396
396
|
});
|
|
397
|
+
useEffect3(() => {
|
|
398
|
+
setState((prev) => ({
|
|
399
|
+
...prev,
|
|
400
|
+
assistantId: clientAssistantId,
|
|
401
|
+
tenantId,
|
|
402
|
+
threadId
|
|
403
|
+
}));
|
|
404
|
+
}, [clientAssistantId, tenantId, threadId]);
|
|
397
405
|
const stopStreamingRef = useRef2(null);
|
|
398
406
|
const chunkMessageMerger = useRef2(createSimpleMessageMerger2());
|
|
399
407
|
const lastAgentStateCreatedAtRef = useRef2(null);
|
|
@@ -460,8 +468,7 @@ function AgentThreadProvider({
|
|
|
460
468
|
...prev,
|
|
461
469
|
todos: todos || prev.todos,
|
|
462
470
|
messages: updatedMessages,
|
|
463
|
-
isLoading: true
|
|
464
|
-
streamingMessage: null
|
|
471
|
+
isLoading: true
|
|
465
472
|
}));
|
|
466
473
|
},
|
|
467
474
|
[]
|
|
@@ -480,8 +487,7 @@ function AgentThreadProvider({
|
|
|
480
487
|
setState((prev) => ({
|
|
481
488
|
...prev,
|
|
482
489
|
isLoading: true,
|
|
483
|
-
error: null
|
|
484
|
-
streamingMessage: null
|
|
490
|
+
error: null
|
|
485
491
|
}));
|
|
486
492
|
const userMessage = {
|
|
487
493
|
id: Date.now().toString(),
|
|
@@ -524,8 +530,7 @@ function AgentThreadProvider({
|
|
|
524
530
|
setState((prev) => ({
|
|
525
531
|
...prev,
|
|
526
532
|
isLoading: false,
|
|
527
|
-
error
|
|
528
|
-
streamingMessage: null
|
|
533
|
+
error
|
|
529
534
|
}));
|
|
530
535
|
stopStreamingRef.current = null;
|
|
531
536
|
}
|
|
@@ -575,111 +580,148 @@ function AgentThreadProvider({
|
|
|
575
580
|
setState((prev) => ({
|
|
576
581
|
...prev,
|
|
577
582
|
messages: currentMessages,
|
|
578
|
-
isLoading: false
|
|
579
|
-
streamingMessage: null
|
|
583
|
+
isLoading: false
|
|
580
584
|
}));
|
|
581
585
|
}
|
|
582
586
|
}, []);
|
|
583
|
-
const
|
|
584
|
-
|
|
587
|
+
const resumeStream = useCallback2(
|
|
588
|
+
(messageId) => {
|
|
585
589
|
if (!threadId) {
|
|
586
|
-
|
|
590
|
+
throw new Error("Thread ID is required to resume stream");
|
|
591
|
+
}
|
|
592
|
+
let targetMessageId;
|
|
593
|
+
if (messageId) {
|
|
594
|
+
targetMessageId = messageId;
|
|
595
|
+
} else {
|
|
596
|
+
const messages = chunkMessageMerger.current.getMessages();
|
|
597
|
+
const lastMessage = messages[messages.length - 1];
|
|
598
|
+
if (!lastMessage) {
|
|
599
|
+
throw new Error(
|
|
600
|
+
"No message ID provided and no messages found in context"
|
|
601
|
+
);
|
|
602
|
+
}
|
|
603
|
+
targetMessageId = lastMessage.id;
|
|
587
604
|
}
|
|
588
605
|
if (stopStreamingRef.current) {
|
|
589
606
|
stopStreamingRef.current();
|
|
590
607
|
stopStreamingRef.current = null;
|
|
591
608
|
}
|
|
592
|
-
setState((prev) => ({
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
});
|
|
609
|
+
setState((prev) => ({
|
|
610
|
+
...prev,
|
|
611
|
+
isLoading: true,
|
|
612
|
+
error: null
|
|
613
|
+
}));
|
|
614
|
+
const resumeStreamOptions = {
|
|
615
|
+
threadId,
|
|
616
|
+
messageId: targetMessageId,
|
|
617
|
+
knownContent: "",
|
|
618
|
+
pollInterval: options.resumeStreamPollInterval || 100
|
|
619
|
+
};
|
|
620
|
+
const stopResumeStream = client.resumeStream(
|
|
621
|
+
resumeStreamOptions,
|
|
622
|
+
handleStreamEvent,
|
|
623
|
+
async () => {
|
|
624
|
+
setState((prev) => ({
|
|
625
|
+
...prev,
|
|
626
|
+
isLoading: false
|
|
627
|
+
}));
|
|
628
|
+
if (options.enableReturnStateWhenStreamCompleted) {
|
|
629
|
+
await fetchAndUpdateAgentState(threadId);
|
|
614
630
|
}
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
}));
|
|
626
|
-
if (options.enableResumeStream && fetchedMessages.length > 0) {
|
|
627
|
-
const lastMessage = fetchedMessages[fetchedMessages.length - 1];
|
|
628
|
-
chunkMessageMerger.current.removeMessageById(lastMessage.id);
|
|
629
|
-
const stopResumeStream = client.resumeStream(
|
|
630
|
-
{
|
|
631
|
-
threadId,
|
|
632
|
-
messageId: lastMessage.id,
|
|
633
|
-
knownContent: "",
|
|
634
|
-
pollInterval: options.resumeStreamPollInterval || 100
|
|
635
|
-
},
|
|
636
|
-
handleStreamEvent,
|
|
637
|
-
async () => {
|
|
638
|
-
setState((prev) => ({
|
|
639
|
-
...prev,
|
|
640
|
-
isLoading: false
|
|
641
|
-
}));
|
|
642
|
-
if (options.enableReturnStateWhenStreamCompleted) {
|
|
643
|
-
await fetchAndUpdateAgentState(threadId);
|
|
644
|
-
}
|
|
645
|
-
stopStreamingRef.current = null;
|
|
646
|
-
},
|
|
647
|
-
(error) => {
|
|
648
|
-
console.error("Resume stream error:", error);
|
|
649
|
-
setState((prev) => ({
|
|
650
|
-
...prev,
|
|
651
|
-
error
|
|
652
|
-
}));
|
|
653
|
-
stopStreamingRef.current = null;
|
|
654
|
-
}
|
|
655
|
-
);
|
|
656
|
-
stopStreamingRef.current = stopResumeStream;
|
|
631
|
+
stopStreamingRef.current = null;
|
|
632
|
+
},
|
|
633
|
+
(error) => {
|
|
634
|
+
console.error("Resume stream error:", error);
|
|
635
|
+
setState((prev) => ({
|
|
636
|
+
...prev,
|
|
637
|
+
isLoading: false,
|
|
638
|
+
error
|
|
639
|
+
}));
|
|
640
|
+
stopStreamingRef.current = null;
|
|
657
641
|
}
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
isLoading: false,
|
|
662
|
-
error: error instanceof Error ? error : new Error(String(error))
|
|
663
|
-
}));
|
|
664
|
-
}
|
|
642
|
+
);
|
|
643
|
+
stopStreamingRef.current = stopResumeStream;
|
|
644
|
+
return stopResumeStream;
|
|
665
645
|
},
|
|
666
646
|
[
|
|
667
647
|
client,
|
|
668
648
|
threadId,
|
|
669
|
-
options.enableResumeStream,
|
|
670
649
|
options.resumeStreamPollInterval,
|
|
650
|
+
options.enableReturnStateWhenStreamCompleted,
|
|
671
651
|
handleStreamEvent,
|
|
672
652
|
fetchAndUpdateAgentState
|
|
673
653
|
]
|
|
674
654
|
);
|
|
655
|
+
const loadMessages = useCallback2(async () => {
|
|
656
|
+
if (!threadId) {
|
|
657
|
+
return;
|
|
658
|
+
}
|
|
659
|
+
if (stopStreamingRef.current) {
|
|
660
|
+
stopStreamingRef.current();
|
|
661
|
+
stopStreamingRef.current = null;
|
|
662
|
+
}
|
|
663
|
+
setState((prev) => ({ ...prev, isLoading: true, error: null }));
|
|
664
|
+
try {
|
|
665
|
+
const agentState = await client.getAgentState(threadId);
|
|
666
|
+
const currentCreatedAt = agentState?.createdAt;
|
|
667
|
+
const needsUpdate = !lastAgentStateCreatedAtRef.current || currentCreatedAt !== lastAgentStateCreatedAtRef.current;
|
|
668
|
+
if (currentCreatedAt) {
|
|
669
|
+
lastAgentStateCreatedAtRef.current = currentCreatedAt;
|
|
670
|
+
}
|
|
671
|
+
let needUpdateFields = {};
|
|
672
|
+
let fetchedMessages = [];
|
|
673
|
+
needUpdateFields.agentState = agentState;
|
|
674
|
+
needUpdateFields.todos = agentState?.values?.todos;
|
|
675
|
+
const interrupts = agentState?.tasks?.flatMap(
|
|
676
|
+
(task) => {
|
|
677
|
+
return task.interrupts.map((interrupt) => {
|
|
678
|
+
return {
|
|
679
|
+
id: interrupt.id,
|
|
680
|
+
value: interrupt.value,
|
|
681
|
+
role: "ai",
|
|
682
|
+
type: "interrupt"
|
|
683
|
+
};
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
);
|
|
687
|
+
needUpdateFields.interrupts = interrupts;
|
|
688
|
+
fetchedMessages = await client.getMessages({ threadId });
|
|
689
|
+
needUpdateFields.messages = fetchedMessages;
|
|
690
|
+
chunkMessageMerger.current.reset();
|
|
691
|
+
chunkMessageMerger.current.initialMessages(fetchedMessages);
|
|
692
|
+
setState((prev) => ({
|
|
693
|
+
...prev,
|
|
694
|
+
...needUpdateFields,
|
|
695
|
+
isLoading: false
|
|
696
|
+
}));
|
|
697
|
+
if (options.enableResumeStream && fetchedMessages.length > 0) {
|
|
698
|
+
const lastMessage = fetchedMessages[fetchedMessages.length - 1];
|
|
699
|
+
chunkMessageMerger.current.removeMessageById(lastMessage.id);
|
|
700
|
+
resumeStream(lastMessage.id);
|
|
701
|
+
}
|
|
702
|
+
} catch (error) {
|
|
703
|
+
setState((prev) => ({
|
|
704
|
+
...prev,
|
|
705
|
+
isLoading: false,
|
|
706
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
707
|
+
}));
|
|
708
|
+
}
|
|
709
|
+
}, [
|
|
710
|
+
client,
|
|
711
|
+
threadId,
|
|
712
|
+
options.enableResumeStream,
|
|
713
|
+
options.resumeStreamPollInterval,
|
|
714
|
+
handleStreamEvent,
|
|
715
|
+
fetchAndUpdateAgentState,
|
|
716
|
+
resumeStream
|
|
717
|
+
]);
|
|
675
718
|
const clearMessages = useCallback2(() => {
|
|
676
719
|
chunkMessageMerger.current.reset();
|
|
677
720
|
lastAgentStateCreatedAtRef.current = null;
|
|
678
721
|
setState((prev) => ({
|
|
679
722
|
...prev,
|
|
680
723
|
messages: [],
|
|
681
|
-
interrupts: void 0
|
|
682
|
-
streamingMessage: null
|
|
724
|
+
interrupts: void 0
|
|
683
725
|
}));
|
|
684
726
|
}, []);
|
|
685
727
|
const clearError = useCallback2(() => {
|
|
@@ -706,6 +748,7 @@ function AgentThreadProvider({
|
|
|
706
748
|
state,
|
|
707
749
|
sendMessage,
|
|
708
750
|
stopStreaming,
|
|
751
|
+
resumeStream,
|
|
709
752
|
loadMessages,
|
|
710
753
|
clearMessages,
|
|
711
754
|
clearError
|
|
@@ -729,147 +772,20 @@ function useAgentChat(options) {
|
|
|
729
772
|
...context.state,
|
|
730
773
|
sendMessage: context.sendMessage,
|
|
731
774
|
stopStreaming: context.stopStreaming,
|
|
775
|
+
resumeStream: context.resumeStream,
|
|
732
776
|
loadMessages: context.loadMessages,
|
|
733
777
|
clearMessages: context.clearMessages,
|
|
734
778
|
clearError: context.clearError
|
|
735
779
|
};
|
|
736
780
|
}
|
|
737
781
|
|
|
738
|
-
// src/hooks/useThread.ts
|
|
739
|
-
import { useState as useState4, useCallback as useCallback3 } from "react";
|
|
740
|
-
function useThread() {
|
|
741
|
-
const client = useAxiomLattice();
|
|
742
|
-
const [state, setState] = useState4({
|
|
743
|
-
threads: [],
|
|
744
|
-
currentThread: null,
|
|
745
|
-
isLoading: false,
|
|
746
|
-
error: null
|
|
747
|
-
});
|
|
748
|
-
const createThread = useCallback3(
|
|
749
|
-
async (options = {}) => {
|
|
750
|
-
setState((prev) => ({ ...prev, isLoading: true, error: null }));
|
|
751
|
-
try {
|
|
752
|
-
const threadId = await client.createThread(options);
|
|
753
|
-
const thread = await client.getThread(threadId);
|
|
754
|
-
setState((prev) => ({
|
|
755
|
-
...prev,
|
|
756
|
-
threads: [...prev.threads, thread],
|
|
757
|
-
currentThread: thread,
|
|
758
|
-
isLoading: false
|
|
759
|
-
}));
|
|
760
|
-
return threadId;
|
|
761
|
-
} catch (error) {
|
|
762
|
-
setState((prev) => ({
|
|
763
|
-
...prev,
|
|
764
|
-
isLoading: false,
|
|
765
|
-
error: error instanceof Error ? error : new Error(String(error))
|
|
766
|
-
}));
|
|
767
|
-
throw error;
|
|
768
|
-
}
|
|
769
|
-
},
|
|
770
|
-
[client]
|
|
771
|
-
);
|
|
772
|
-
const getThread = useCallback3(
|
|
773
|
-
async (threadId) => {
|
|
774
|
-
setState((prev) => ({ ...prev, isLoading: true, error: null }));
|
|
775
|
-
try {
|
|
776
|
-
const thread = await client.getThread(threadId);
|
|
777
|
-
setState((prev) => ({
|
|
778
|
-
...prev,
|
|
779
|
-
isLoading: false
|
|
780
|
-
}));
|
|
781
|
-
return thread;
|
|
782
|
-
} catch (error) {
|
|
783
|
-
setState((prev) => ({
|
|
784
|
-
...prev,
|
|
785
|
-
isLoading: false,
|
|
786
|
-
error: error instanceof Error ? error : new Error(String(error))
|
|
787
|
-
}));
|
|
788
|
-
throw error;
|
|
789
|
-
}
|
|
790
|
-
},
|
|
791
|
-
[client]
|
|
792
|
-
);
|
|
793
|
-
const listThreads = useCallback3(
|
|
794
|
-
async (limit, offset) => {
|
|
795
|
-
setState((prev) => ({ ...prev, isLoading: true, error: null }));
|
|
796
|
-
try {
|
|
797
|
-
const threads = await client.listThreads({ limit, offset });
|
|
798
|
-
setState((prev) => ({
|
|
799
|
-
...prev,
|
|
800
|
-
threads,
|
|
801
|
-
isLoading: false
|
|
802
|
-
}));
|
|
803
|
-
} catch (error) {
|
|
804
|
-
setState((prev) => ({
|
|
805
|
-
...prev,
|
|
806
|
-
isLoading: false,
|
|
807
|
-
error: error instanceof Error ? error : new Error(String(error))
|
|
808
|
-
}));
|
|
809
|
-
}
|
|
810
|
-
},
|
|
811
|
-
[client]
|
|
812
|
-
);
|
|
813
|
-
const deleteThread = useCallback3(
|
|
814
|
-
async (threadId) => {
|
|
815
|
-
setState((prev) => ({ ...prev, isLoading: true, error: null }));
|
|
816
|
-
try {
|
|
817
|
-
await client.deleteThread(threadId);
|
|
818
|
-
setState((prev) => ({
|
|
819
|
-
...prev,
|
|
820
|
-
threads: prev.threads.filter((t) => t.id !== threadId),
|
|
821
|
-
currentThread: prev.currentThread?.id === threadId ? null : prev.currentThread,
|
|
822
|
-
isLoading: false
|
|
823
|
-
}));
|
|
824
|
-
} catch (error) {
|
|
825
|
-
setState((prev) => ({
|
|
826
|
-
...prev,
|
|
827
|
-
isLoading: false,
|
|
828
|
-
error: error instanceof Error ? error : new Error(String(error))
|
|
829
|
-
}));
|
|
830
|
-
throw error;
|
|
831
|
-
}
|
|
832
|
-
},
|
|
833
|
-
[client]
|
|
834
|
-
);
|
|
835
|
-
const selectThread = useCallback3(
|
|
836
|
-
async (threadId) => {
|
|
837
|
-
setState((prev) => ({ ...prev, isLoading: true, error: null }));
|
|
838
|
-
try {
|
|
839
|
-
const thread = await client.getThread(threadId);
|
|
840
|
-
setState((prev) => ({
|
|
841
|
-
...prev,
|
|
842
|
-
currentThread: thread,
|
|
843
|
-
isLoading: false
|
|
844
|
-
}));
|
|
845
|
-
} catch (error) {
|
|
846
|
-
setState((prev) => ({
|
|
847
|
-
...prev,
|
|
848
|
-
isLoading: false,
|
|
849
|
-
error: error instanceof Error ? error : new Error(String(error))
|
|
850
|
-
}));
|
|
851
|
-
throw error;
|
|
852
|
-
}
|
|
853
|
-
},
|
|
854
|
-
[client]
|
|
855
|
-
);
|
|
856
|
-
return {
|
|
857
|
-
...state,
|
|
858
|
-
createThread,
|
|
859
|
-
getThread,
|
|
860
|
-
listThreads,
|
|
861
|
-
deleteThread,
|
|
862
|
-
selectThread
|
|
863
|
-
};
|
|
864
|
-
}
|
|
865
|
-
|
|
866
782
|
// src/hooks/useAgentState.ts
|
|
867
|
-
import { useState as
|
|
783
|
+
import { useState as useState4, useCallback as useCallback3, useEffect as useEffect4, useRef as useRef3 } from "react";
|
|
868
784
|
function useAgentState(threadId, options = {}) {
|
|
869
785
|
const client = useAxiomLattice();
|
|
870
|
-
const [agentState, setAgentState] =
|
|
871
|
-
const [isLoading, setIsLoading] =
|
|
872
|
-
const [error, setError] =
|
|
786
|
+
const [agentState, setAgentState] = useState4(null);
|
|
787
|
+
const [isLoading, setIsLoading] = useState4(false);
|
|
788
|
+
const [error, setError] = useState4(null);
|
|
873
789
|
const pollingIntervalRef = useRef3(null);
|
|
874
790
|
const pollingTimeoutRef = useRef3(null);
|
|
875
791
|
const {
|
|
@@ -877,7 +793,7 @@ function useAgentState(threadId, options = {}) {
|
|
|
877
793
|
// 2 seconds by default
|
|
878
794
|
autoStart = true
|
|
879
795
|
} = options;
|
|
880
|
-
const fetchAgentState =
|
|
796
|
+
const fetchAgentState = useCallback3(async () => {
|
|
881
797
|
if (!threadId) {
|
|
882
798
|
return;
|
|
883
799
|
}
|
|
@@ -892,7 +808,7 @@ function useAgentState(threadId, options = {}) {
|
|
|
892
808
|
setIsLoading(false);
|
|
893
809
|
}
|
|
894
810
|
}, [client, threadId]);
|
|
895
|
-
const startPolling =
|
|
811
|
+
const startPolling = useCallback3(() => {
|
|
896
812
|
if (!threadId) {
|
|
897
813
|
return;
|
|
898
814
|
}
|
|
@@ -913,17 +829,17 @@ function useAgentState(threadId, options = {}) {
|
|
|
913
829
|
};
|
|
914
830
|
poll();
|
|
915
831
|
}, [threadId, pollingInterval, fetchAgentState]);
|
|
916
|
-
const stopPolling =
|
|
832
|
+
const stopPolling = useCallback3(() => {
|
|
917
833
|
pollingIntervalRef.current = null;
|
|
918
834
|
if (pollingTimeoutRef.current) {
|
|
919
835
|
clearTimeout(pollingTimeoutRef.current);
|
|
920
836
|
pollingTimeoutRef.current = null;
|
|
921
837
|
}
|
|
922
838
|
}, []);
|
|
923
|
-
const refresh =
|
|
839
|
+
const refresh = useCallback3(async () => {
|
|
924
840
|
await fetchAgentState();
|
|
925
841
|
}, [fetchAgentState]);
|
|
926
|
-
|
|
842
|
+
useEffect4(() => {
|
|
927
843
|
if (threadId && autoStart) {
|
|
928
844
|
startPolling();
|
|
929
845
|
} else {
|
|
@@ -944,13 +860,13 @@ function useAgentState(threadId, options = {}) {
|
|
|
944
860
|
}
|
|
945
861
|
|
|
946
862
|
// src/hooks/useAgentGraph.ts
|
|
947
|
-
import { useState as
|
|
863
|
+
import { useState as useState5, useCallback as useCallback4 } from "react";
|
|
948
864
|
function useAgentGraph() {
|
|
949
865
|
const client = useAxiomLattice();
|
|
950
|
-
const [graphImage, setGraphImage] =
|
|
951
|
-
const [isLoading, setIsLoading] =
|
|
952
|
-
const [error, setError] =
|
|
953
|
-
const fetchGraph =
|
|
866
|
+
const [graphImage, setGraphImage] = useState5(null);
|
|
867
|
+
const [isLoading, setIsLoading] = useState5(false);
|
|
868
|
+
const [error, setError] = useState5(null);
|
|
869
|
+
const fetchGraph = useCallback4(async () => {
|
|
954
870
|
setIsLoading(true);
|
|
955
871
|
setError(null);
|
|
956
872
|
try {
|
|
@@ -974,7 +890,7 @@ function useAgentGraph() {
|
|
|
974
890
|
export * from "@axiom-lattice/protocols";
|
|
975
891
|
|
|
976
892
|
// src/components/Chat/ChatUIContext.tsx
|
|
977
|
-
import { createContext as createContext3, useCallback as
|
|
893
|
+
import { createContext as createContext3, useCallback as useCallback5, useContext as useContext3, useState as useState6 } from "react";
|
|
978
894
|
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
979
895
|
var ChatUIContext = createContext3({
|
|
980
896
|
sideAppVisible: false,
|
|
@@ -989,22 +905,26 @@ var ChatUIContext = createContext3({
|
|
|
989
905
|
openSideApp: () => {
|
|
990
906
|
},
|
|
991
907
|
closeSideApp: () => {
|
|
908
|
+
},
|
|
909
|
+
menuCollapsed: false,
|
|
910
|
+
setMenuCollapsed: () => {
|
|
992
911
|
}
|
|
993
912
|
});
|
|
994
913
|
var ChatUIContextProvider = ({
|
|
995
914
|
children
|
|
996
915
|
}) => {
|
|
997
|
-
const [sideAppVisible, setSideAppVisible] =
|
|
998
|
-
const [sideAppSize, setSideAppSize] =
|
|
999
|
-
const [sideAppSelectedCard, setSideAppSelectedCard] =
|
|
1000
|
-
const
|
|
916
|
+
const [sideAppVisible, setSideAppVisible] = useState6(false);
|
|
917
|
+
const [sideAppSize, setSideAppSize] = useState6("large");
|
|
918
|
+
const [sideAppSelectedCard, setSideAppSelectedCard] = useState6(null);
|
|
919
|
+
const [menuCollapsed, setMenuCollapsed] = useState6(false);
|
|
920
|
+
const openSideApp = useCallback5(
|
|
1001
921
|
(card) => {
|
|
1002
922
|
setSideAppSelectedCard(card);
|
|
1003
923
|
setSideAppVisible(true);
|
|
1004
924
|
},
|
|
1005
925
|
[setSideAppSelectedCard, setSideAppVisible]
|
|
1006
926
|
);
|
|
1007
|
-
const closeSideApp =
|
|
927
|
+
const closeSideApp = useCallback5(() => {
|
|
1008
928
|
setSideAppSelectedCard(null);
|
|
1009
929
|
setSideAppVisible(false);
|
|
1010
930
|
}, [setSideAppSelectedCard, setSideAppVisible]);
|
|
@@ -1019,7 +939,9 @@ var ChatUIContextProvider = ({
|
|
|
1019
939
|
sideAppSelectedCard,
|
|
1020
940
|
setSideAppSelectedCard,
|
|
1021
941
|
openSideApp,
|
|
1022
|
-
closeSideApp
|
|
942
|
+
closeSideApp,
|
|
943
|
+
menuCollapsed,
|
|
944
|
+
setMenuCollapsed
|
|
1023
945
|
},
|
|
1024
946
|
children
|
|
1025
947
|
}
|
|
@@ -1044,7 +966,6 @@ var useStyle = createStyles(({ token, css }) => {
|
|
|
1044
966
|
position: relative;
|
|
1045
967
|
overflow: hidden;
|
|
1046
968
|
padding: 16px;
|
|
1047
|
-
padding-top: 2px;
|
|
1048
969
|
gap: 16px;
|
|
1049
970
|
|
|
1050
971
|
.ant-prompts {
|
|
@@ -1053,7 +974,7 @@ var useStyle = createStyles(({ token, css }) => {
|
|
|
1053
974
|
`,
|
|
1054
975
|
menu: css`
|
|
1055
976
|
background: ${token.colorBgContainer}90;
|
|
1056
|
-
width:
|
|
977
|
+
width: 240px;
|
|
1057
978
|
display: flex;
|
|
1058
979
|
flex-direction: column;
|
|
1059
980
|
flex-shrink: 0;
|
|
@@ -1171,6 +1092,17 @@ var useStyle = createStyles(({ token, css }) => {
|
|
|
1171
1092
|
min-width: 200px;
|
|
1172
1093
|
max-width: 466px;
|
|
1173
1094
|
}
|
|
1095
|
+
.ant-bubble-content-updating {
|
|
1096
|
+
background-image: linear-gradient(
|
|
1097
|
+
90deg,
|
|
1098
|
+
#ff6b23 0%,
|
|
1099
|
+
#af3cb8 31%,
|
|
1100
|
+
#53b6ff 89%
|
|
1101
|
+
);
|
|
1102
|
+
background-size: 100% 2px;
|
|
1103
|
+
background-repeat: no-repeat;
|
|
1104
|
+
background-position: bottom;
|
|
1105
|
+
}
|
|
1174
1106
|
`,
|
|
1175
1107
|
detailPanel: css`
|
|
1176
1108
|
display: flex;
|
|
@@ -1305,10 +1237,25 @@ var useStyle = createStyles(({ token, css }) => {
|
|
|
1305
1237
|
|
|
1306
1238
|
// src/components/Chat/ColumnLayout.tsx
|
|
1307
1239
|
import { Fragment, jsx as jsx4, jsxs } from "react/jsx-runtime";
|
|
1308
|
-
var ColumnLayout = ({
|
|
1240
|
+
var ColumnLayout = ({
|
|
1241
|
+
left,
|
|
1242
|
+
right,
|
|
1243
|
+
logo,
|
|
1244
|
+
menu
|
|
1245
|
+
}) => {
|
|
1309
1246
|
const { styles } = useStyle();
|
|
1310
|
-
const { sideAppVisible, sideAppSize, sideAppSelectedCard } = useChatUIContext();
|
|
1247
|
+
const { sideAppVisible, sideAppSize, sideAppSelectedCard, menuCollapsed } = useChatUIContext();
|
|
1311
1248
|
return /* @__PURE__ */ jsxs("div", { className: `fina_chat ${styles.layout}`, children: [
|
|
1249
|
+
menu && /* @__PURE__ */ jsxs(
|
|
1250
|
+
"div",
|
|
1251
|
+
{
|
|
1252
|
+
className: `${styles.menu} ${"open"} ${menuCollapsed ? "collapsed" : ""}`,
|
|
1253
|
+
children: [
|
|
1254
|
+
logo,
|
|
1255
|
+
menu
|
|
1256
|
+
]
|
|
1257
|
+
}
|
|
1258
|
+
),
|
|
1312
1259
|
/* @__PURE__ */ jsx4("div", { className: `${styles.mainContent} ${sideAppVisible ? "open" : ""}`, children: /* @__PURE__ */ jsx4("div", { className: `${styles.chat}`, children: left }) }),
|
|
1313
1260
|
/* @__PURE__ */ jsxs(
|
|
1314
1261
|
"div",
|
|
@@ -1333,20 +1280,20 @@ import {
|
|
|
1333
1280
|
|
|
1334
1281
|
// src/components/GenUI/elements/confirm_feedback.tsx
|
|
1335
1282
|
import { Button, Space, Typography } from "antd";
|
|
1336
|
-
import { useState as
|
|
1283
|
+
import { useState as useState8 } from "react";
|
|
1337
1284
|
|
|
1338
1285
|
// src/components/GenUI/MDResponse.tsx
|
|
1339
1286
|
import ReactMarkdown from "react-markdown";
|
|
1340
1287
|
import { Prism } from "react-syntax-highlighter";
|
|
1341
1288
|
import { dark } from "react-syntax-highlighter/dist/cjs/styles/prism";
|
|
1342
1289
|
import remarkGfm from "remark-gfm";
|
|
1343
|
-
import { useMemo as useMemo2, useRef as useRef5, useState as
|
|
1290
|
+
import { useMemo as useMemo2, useRef as useRef5, useState as useState7 } from "react";
|
|
1344
1291
|
import { createStyles as createStyles2 } from "antd-style";
|
|
1345
1292
|
import rehypeRaw from "rehype-raw";
|
|
1346
1293
|
|
|
1347
1294
|
// src/components/GenUI/MDMermaid.tsx
|
|
1348
1295
|
import mermaid from "mermaid";
|
|
1349
|
-
import { useEffect as
|
|
1296
|
+
import { useEffect as useEffect5, useRef as useRef4 } from "react";
|
|
1350
1297
|
import { v4 } from "uuid";
|
|
1351
1298
|
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
1352
1299
|
var MDMermaid = ({ children = [] }) => {
|
|
@@ -1354,7 +1301,7 @@ var MDMermaid = ({ children = [] }) => {
|
|
|
1354
1301
|
const code = String(children);
|
|
1355
1302
|
const target = useRef4(null);
|
|
1356
1303
|
const targetInternal = useRef4(null);
|
|
1357
|
-
|
|
1304
|
+
useEffect5(() => {
|
|
1358
1305
|
if (target.current && code) {
|
|
1359
1306
|
mermaid.initialize({
|
|
1360
1307
|
startOnLoad: true,
|
|
@@ -1584,8 +1531,8 @@ var MDViewFormItem = ({ value }) => {
|
|
|
1584
1531
|
};
|
|
1585
1532
|
var IFrameCard = ({ src }) => {
|
|
1586
1533
|
const containerRef = useRef5(null);
|
|
1587
|
-
const [width, setWidth] =
|
|
1588
|
-
const [height, setHeight] =
|
|
1534
|
+
const [width, setWidth] = useState7("640px");
|
|
1535
|
+
const [height, setHeight] = useState7("320px");
|
|
1589
1536
|
const valid_images = [
|
|
1590
1537
|
"jpg",
|
|
1591
1538
|
"jpeg",
|
|
@@ -1617,7 +1564,7 @@ var ConfirmFeedback = ({
|
|
|
1617
1564
|
}) => {
|
|
1618
1565
|
const { message: message4, type, config, feedback, options } = data ?? {};
|
|
1619
1566
|
const { sendMessage } = useAgentChat();
|
|
1620
|
-
const [clicked, setClicked] =
|
|
1567
|
+
const [clicked, setClicked] = useState8(false);
|
|
1621
1568
|
return /* @__PURE__ */ jsxs2(Space, { direction: "vertical", style: { width: "100%" }, children: [
|
|
1622
1569
|
/* @__PURE__ */ jsx7(MDResponse, { content: message4 }),
|
|
1623
1570
|
options ? /* @__PURE__ */ jsx7(Space, { style: { justifyContent: "flex-end", width: "100%" }, children: options?.map((option) => /* @__PURE__ */ jsx7(
|
|
@@ -1696,13 +1643,13 @@ var ConfirmFeedback = ({
|
|
|
1696
1643
|
|
|
1697
1644
|
// src/components/GenUI/elements/generic_data_table.tsx
|
|
1698
1645
|
import { Table, Typography as Typography2, Button as Button2, Flex, Space as Space2 } from "antd";
|
|
1699
|
-
import { useState as
|
|
1646
|
+
import { useState as useState9 } from "react";
|
|
1700
1647
|
import { DownloadOutlined, ExpandAltOutlined } from "@ant-design/icons";
|
|
1701
1648
|
import { jsx as jsx8, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1702
1649
|
var { Text: Text2 } = Typography2;
|
|
1703
1650
|
var GenericDataTable = ({ data, interactive = true, default_open_in_side_app = true }) => {
|
|
1704
1651
|
const { dataSource, message: message4 } = data ?? {};
|
|
1705
|
-
const [expandedRowKeys, setExpandedRowKeys] =
|
|
1652
|
+
const [expandedRowKeys, setExpandedRowKeys] = useState9([]);
|
|
1706
1653
|
const { openSideApp } = useChatUIContext();
|
|
1707
1654
|
const processedData = dataSource?.map((item, index) => ({
|
|
1708
1655
|
...item,
|
|
@@ -2319,7 +2266,7 @@ var WriteTodos = ({
|
|
|
2319
2266
|
};
|
|
2320
2267
|
|
|
2321
2268
|
// src/components/GenUI/FileExplorer.tsx
|
|
2322
|
-
import { useState as
|
|
2269
|
+
import { useState as useState10, useEffect as useEffect6, useMemo as useMemo3 } from "react";
|
|
2323
2270
|
import { Splitter, Tree, Empty, Button as Button3, Tooltip, message } from "antd";
|
|
2324
2271
|
import {
|
|
2325
2272
|
FolderOutlined,
|
|
@@ -2565,17 +2512,17 @@ var FileExplorer = ({
|
|
|
2565
2512
|
}) => {
|
|
2566
2513
|
const { files } = data ?? {};
|
|
2567
2514
|
const { styles, cx } = useStyles2();
|
|
2568
|
-
const [fileList, setFileList] =
|
|
2569
|
-
const [selectedKey, setSelectedKey] =
|
|
2570
|
-
const [expandedKeys, setExpandedKeys] =
|
|
2571
|
-
const [copied, setCopied] =
|
|
2572
|
-
|
|
2515
|
+
const [fileList, setFileList] = useState10([]);
|
|
2516
|
+
const [selectedKey, setSelectedKey] = useState10("");
|
|
2517
|
+
const [expandedKeys, setExpandedKeys] = useState10([]);
|
|
2518
|
+
const [copied, setCopied] = useState10(false);
|
|
2519
|
+
useEffect6(() => {
|
|
2573
2520
|
if (copied) {
|
|
2574
2521
|
const timer = setTimeout(() => setCopied(false), 2e3);
|
|
2575
2522
|
return () => clearTimeout(timer);
|
|
2576
2523
|
}
|
|
2577
2524
|
}, [copied]);
|
|
2578
|
-
|
|
2525
|
+
useEffect6(() => {
|
|
2579
2526
|
let list = [];
|
|
2580
2527
|
if (Array.isArray(files)) {
|
|
2581
2528
|
list = files;
|
|
@@ -2595,7 +2542,7 @@ var FileExplorer = ({
|
|
|
2595
2542
|
() => buildTreeData(fileList, expandedKeys),
|
|
2596
2543
|
[fileList, expandedKeys]
|
|
2597
2544
|
);
|
|
2598
|
-
|
|
2545
|
+
useEffect6(() => {
|
|
2599
2546
|
if (treeData.length > 0 && expandedKeys.length === 0) {
|
|
2600
2547
|
const getAllKeys = (nodes) => {
|
|
2601
2548
|
let keys = [];
|
|
@@ -2733,7 +2680,7 @@ import {
|
|
|
2733
2680
|
Button as Button4
|
|
2734
2681
|
} from "antd";
|
|
2735
2682
|
import dayjs from "dayjs";
|
|
2736
|
-
import { useState as
|
|
2683
|
+
import { useState as useState11 } from "react";
|
|
2737
2684
|
import { jsx as jsx16, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
2738
2685
|
var AttachmentsCard = ({
|
|
2739
2686
|
data,
|
|
@@ -2743,7 +2690,7 @@ var AttachmentsCard = ({
|
|
|
2743
2690
|
showDownloadButton = false
|
|
2744
2691
|
}) => {
|
|
2745
2692
|
const { Text: Text11 } = Typography7;
|
|
2746
|
-
const [showAll, setShowAll] =
|
|
2693
|
+
const [showAll, setShowAll] = useState11(false);
|
|
2747
2694
|
const { openSideApp } = useChatUIContext();
|
|
2748
2695
|
const getStyles = () => {
|
|
2749
2696
|
switch (size) {
|
|
@@ -2924,14 +2871,14 @@ var AttachmentsCard = ({
|
|
|
2924
2871
|
|
|
2925
2872
|
// src/components/GenUI/elements/attachments_viewer_side_app.tsx
|
|
2926
2873
|
import { Button as Button5, Empty as Empty2, Skeleton } from "antd";
|
|
2927
|
-
import { useState as
|
|
2874
|
+
import { useState as useState12 } from "react";
|
|
2928
2875
|
import { Fragment as Fragment2, jsx as jsx17, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
2929
2876
|
function AttachmentsViewerSideApp({
|
|
2930
2877
|
data,
|
|
2931
2878
|
component_key
|
|
2932
2879
|
}) {
|
|
2933
|
-
const [fileUri, setFileUri] =
|
|
2934
|
-
const [loading, setLoading] =
|
|
2880
|
+
const [fileUri, setFileUri] = useState12();
|
|
2881
|
+
const [loading, setLoading] = useState12(true);
|
|
2935
2882
|
const { file_id } = data ?? {};
|
|
2936
2883
|
if (loading) {
|
|
2937
2884
|
return /* @__PURE__ */ jsx17(Skeleton, { active: true });
|
|
@@ -2994,7 +2941,7 @@ function AttachmentsViewerSideApp({
|
|
|
2994
2941
|
import { Button as Button6, Space as Space8, Typography as Typography8 } from "antd";
|
|
2995
2942
|
|
|
2996
2943
|
// src/components/GenUI/elements/ContentPreviewCollapse.tsx
|
|
2997
|
-
import { useRef as useRef6, useState as
|
|
2944
|
+
import { useRef as useRef6, useState as useState13, useEffect as useEffect8, useCallback as useCallback6 } from "react";
|
|
2998
2945
|
import { Collapse as Collapse4 } from "antd";
|
|
2999
2946
|
import { createStyles as createStyles6 } from "antd-style";
|
|
3000
2947
|
import { DownOutlined as DownOutlined2, UpOutlined } from "@ant-design/icons";
|
|
@@ -3064,18 +3011,18 @@ var ContentPreviewCollapse = ({
|
|
|
3064
3011
|
showAllText = "Show all content",
|
|
3065
3012
|
showLessText = "Show less"
|
|
3066
3013
|
}) => {
|
|
3067
|
-
const [showFullContent, setShowFullContent] =
|
|
3068
|
-
const [isOverflowing, setIsOverflowing] =
|
|
3014
|
+
const [showFullContent, setShowFullContent] = useState13(false);
|
|
3015
|
+
const [isOverflowing, setIsOverflowing] = useState13(false);
|
|
3069
3016
|
const contentRef = useRef6(null);
|
|
3070
3017
|
const showShadow = isOverflowing && !showFullContent;
|
|
3071
3018
|
const { styles, cx } = useStyle4({ showShadow });
|
|
3072
|
-
const checkOverflow =
|
|
3019
|
+
const checkOverflow = useCallback6(() => {
|
|
3073
3020
|
if (contentRef.current) {
|
|
3074
3021
|
const scrollHeight = contentRef.current.scrollHeight;
|
|
3075
3022
|
setIsOverflowing(scrollHeight > collapsedMaxHeight);
|
|
3076
3023
|
}
|
|
3077
3024
|
}, [collapsedMaxHeight]);
|
|
3078
|
-
|
|
3025
|
+
useEffect8(() => {
|
|
3079
3026
|
const element = contentRef.current;
|
|
3080
3027
|
if (!element) return;
|
|
3081
3028
|
checkOverflow();
|
|
@@ -3267,8 +3214,7 @@ import { jsx as jsx22, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
|
3267
3214
|
var { Text: Text8 } = Typography10;
|
|
3268
3215
|
var useStyle5 = createStyles7(({ token, css }) => ({
|
|
3269
3216
|
card: css`
|
|
3270
|
-
|
|
3271
|
-
background: ${token.colorBgContainer};
|
|
3217
|
+
background: rgba(0, 0, 0, 0.02);
|
|
3272
3218
|
border: 1px solid ${token.colorBorderSecondary};
|
|
3273
3219
|
border-radius: 16px;
|
|
3274
3220
|
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
@@ -3278,17 +3224,17 @@ var useStyle5 = createStyles7(({ token, css }) => ({
|
|
|
3278
3224
|
&:hover {
|
|
3279
3225
|
border-color: ${token.colorPrimary};
|
|
3280
3226
|
box-shadow: 0 8px 24px rgba(24, 144, 255, 0.12);
|
|
3281
|
-
transform: translateX(4px);
|
|
3227
|
+
// transform: translateX(4px);
|
|
3282
3228
|
}
|
|
3283
3229
|
&::before {
|
|
3284
3230
|
content: "";
|
|
3285
3231
|
position: absolute;
|
|
3286
3232
|
top: 0;
|
|
3287
3233
|
left: 0;
|
|
3288
|
-
|
|
3289
|
-
|
|
3234
|
+
right: 0;
|
|
3235
|
+
height: 4px;
|
|
3290
3236
|
background: linear-gradient(
|
|
3291
|
-
|
|
3237
|
+
90deg,
|
|
3292
3238
|
${token.colorPrimary} 0%,
|
|
3293
3239
|
${token.colorPrimaryHover} 100%
|
|
3294
3240
|
);
|
|
@@ -3390,21 +3336,42 @@ var useStyle5 = createStyles7(({ token, css }) => ({
|
|
|
3390
3336
|
color: ${token.colorTextTertiary};
|
|
3391
3337
|
font-size: 14px;
|
|
3392
3338
|
transition: all 0.2s ease;
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3339
|
+
`,
|
|
3340
|
+
responseSection: css`
|
|
3341
|
+
margin-top: 16px;
|
|
3342
|
+
margin-bottom: 16px;
|
|
3343
|
+
padding-top: 16px;
|
|
3344
|
+
border-top: 1px solid ${token.colorBorderSecondary};
|
|
3345
|
+
`,
|
|
3346
|
+
responseHeader: css`
|
|
3347
|
+
font-size: 13px;
|
|
3348
|
+
font-weight: 600;
|
|
3349
|
+
color: ${token.colorTextSecondary};
|
|
3350
|
+
margin-bottom: 12px;
|
|
3351
|
+
text-transform: uppercase;
|
|
3352
|
+
letter-spacing: 0.5px;
|
|
3353
|
+
`,
|
|
3354
|
+
responseContent: css`
|
|
3355
|
+
padding: 12px;
|
|
3356
|
+
background: ${token.colorFillAlter};
|
|
3357
|
+
border-radius: 8px;
|
|
3358
|
+
border: 1px solid ${token.colorBorderSecondary};
|
|
3359
|
+
`
|
|
3360
|
+
}));
|
|
3361
|
+
var TaskCard = ({
|
|
3362
|
+
data,
|
|
3363
|
+
component_key,
|
|
3364
|
+
interactive = true
|
|
3365
|
+
}) => {
|
|
3366
|
+
const { styles } = useStyle5();
|
|
3367
|
+
const toolCallData = data;
|
|
3368
|
+
const { openSideApp } = useChatUIContext();
|
|
3403
3369
|
if (!toolCallData) {
|
|
3404
3370
|
return null;
|
|
3405
3371
|
}
|
|
3406
3372
|
const { description, subagent_type, assignee } = toolCallData?.args || {};
|
|
3407
3373
|
const status = toolCallData.status || "pending";
|
|
3374
|
+
const response = toolCallData.response || null;
|
|
3408
3375
|
const { threadId } = useAgentChat();
|
|
3409
3376
|
const subagent_thread_id = (threadId || "") + "____" + subagent_type + "_" + toolCallData.id;
|
|
3410
3377
|
const getStatusConfig = (status2) => {
|
|
@@ -3434,6 +3401,7 @@ var TaskCard = ({
|
|
|
3434
3401
|
}
|
|
3435
3402
|
};
|
|
3436
3403
|
const statusConfig = getStatusConfig(status);
|
|
3404
|
+
const showResponse = status === "success" && response;
|
|
3437
3405
|
const handleCardClick = () => {
|
|
3438
3406
|
openSideApp({
|
|
3439
3407
|
component_key: "task",
|
|
@@ -3494,7 +3462,18 @@ var TaskCard = ({
|
|
|
3494
3462
|
)
|
|
3495
3463
|
] }),
|
|
3496
3464
|
interactive && /* @__PURE__ */ jsx22(RightOutlined2, { className: styles.actionIcon })
|
|
3497
|
-
] })
|
|
3465
|
+
] }),
|
|
3466
|
+
showResponse && /* @__PURE__ */ jsxs14(
|
|
3467
|
+
"div",
|
|
3468
|
+
{
|
|
3469
|
+
className: styles.responseSection,
|
|
3470
|
+
onClick: (e) => e.stopPropagation(),
|
|
3471
|
+
children: [
|
|
3472
|
+
/* @__PURE__ */ jsx22(Text8, { className: styles.responseHeader, children: "Response" }),
|
|
3473
|
+
/* @__PURE__ */ jsx22("div", { className: styles.responseContent, children: /* @__PURE__ */ jsx22(MDResponse, { content: response }) })
|
|
3474
|
+
]
|
|
3475
|
+
}
|
|
3476
|
+
)
|
|
3498
3477
|
] })
|
|
3499
3478
|
}
|
|
3500
3479
|
);
|
|
@@ -3521,11 +3500,11 @@ import { Space as Space10 } from "antd";
|
|
|
3521
3500
|
import ErrorBoundary from "antd/es/alert/ErrorBoundary";
|
|
3522
3501
|
import {
|
|
3523
3502
|
memo,
|
|
3524
|
-
useCallback as
|
|
3525
|
-
useEffect as
|
|
3503
|
+
useCallback as useCallback7,
|
|
3504
|
+
useEffect as useEffect9,
|
|
3526
3505
|
useMemo as useMemo4,
|
|
3527
3506
|
useRef as useRef7,
|
|
3528
|
-
useState as
|
|
3507
|
+
useState as useState14
|
|
3529
3508
|
} from "react";
|
|
3530
3509
|
import { jsx as jsx23 } from "react/jsx-runtime";
|
|
3531
3510
|
var LazyBubble = ({
|
|
@@ -3534,9 +3513,9 @@ var LazyBubble = ({
|
|
|
3534
3513
|
autoLoadRightPanel
|
|
3535
3514
|
}) => {
|
|
3536
3515
|
const ref = useRef7(null);
|
|
3537
|
-
const [isVisible, setIsVisible] =
|
|
3538
|
-
const [wasEverVisible, setWasEverVisible] =
|
|
3539
|
-
|
|
3516
|
+
const [isVisible, setIsVisible] = useState14(false);
|
|
3517
|
+
const [wasEverVisible, setWasEverVisible] = useState14(false);
|
|
3518
|
+
useEffect9(() => {
|
|
3540
3519
|
const observer = new IntersectionObserver(
|
|
3541
3520
|
([entry]) => {
|
|
3542
3521
|
const visible = entry.isIntersecting;
|
|
@@ -3556,7 +3535,7 @@ var LazyBubble = ({
|
|
|
3556
3535
|
}
|
|
3557
3536
|
};
|
|
3558
3537
|
}, [wasEverVisible]);
|
|
3559
|
-
|
|
3538
|
+
useEffect9(() => {
|
|
3560
3539
|
autoLoadRightPanel?.();
|
|
3561
3540
|
}, []);
|
|
3562
3541
|
const getPlaceholder = () => {
|
|
@@ -3589,12 +3568,12 @@ var MessageList = ({
|
|
|
3589
3568
|
const { styles } = useStyle();
|
|
3590
3569
|
const { openSideApp } = useChatUIContext();
|
|
3591
3570
|
const messageLengthRef = useRef7(messages?.length ?? 0);
|
|
3592
|
-
|
|
3571
|
+
useEffect9(() => {
|
|
3593
3572
|
if (messages?.length) {
|
|
3594
3573
|
messageLengthRef.current = messages?.length;
|
|
3595
3574
|
}
|
|
3596
3575
|
}, [messages?.length]);
|
|
3597
|
-
const renderContent =
|
|
3576
|
+
const renderContent = useCallback7((message4) => {
|
|
3598
3577
|
const { content } = message4;
|
|
3599
3578
|
try {
|
|
3600
3579
|
const json = JSON.parse(content);
|
|
@@ -3695,7 +3674,7 @@ import {
|
|
|
3695
3674
|
Button as Button10,
|
|
3696
3675
|
message as message3
|
|
3697
3676
|
} from "antd";
|
|
3698
|
-
import React6, { useEffect as
|
|
3677
|
+
import React6, { useEffect as useEffect10, useRef as useRef8, useState as useState15 } from "react";
|
|
3699
3678
|
|
|
3700
3679
|
// src/components/GenUI/HITLContainer.tsx
|
|
3701
3680
|
import {
|
|
@@ -3875,8 +3854,8 @@ var AgentHeader = (props) => {
|
|
|
3875
3854
|
style: { padding: 8 },
|
|
3876
3855
|
variant: "borderless",
|
|
3877
3856
|
description,
|
|
3878
|
-
icon: /* @__PURE__ */ jsx27(Avatar2, { src: avatar
|
|
3879
|
-
title: name
|
|
3857
|
+
icon: avatar ? /* @__PURE__ */ jsx27(Avatar2, { src: avatar, size: 48 }) : /* @__PURE__ */ jsx27(Avatar2, { size: 48, children: name?.charAt(0).toUpperCase() }),
|
|
3858
|
+
title: name ? name : void 0,
|
|
3880
3859
|
extra: /* @__PURE__ */ jsxs16(Space12, { children: [
|
|
3881
3860
|
extra,
|
|
3882
3861
|
/* @__PURE__ */ jsx27(TodoProgress, {}),
|
|
@@ -3913,10 +3892,10 @@ var Chating = ({
|
|
|
3913
3892
|
showHITL = true,
|
|
3914
3893
|
showRefreshButton = false
|
|
3915
3894
|
}) => {
|
|
3916
|
-
const [content, setContent] =
|
|
3917
|
-
const [attachedFiles, setAttachedFiles] =
|
|
3895
|
+
const [content, setContent] = useState15("");
|
|
3896
|
+
const [attachedFiles, setAttachedFiles] = useState15([]);
|
|
3918
3897
|
const { styles } = useStyle();
|
|
3919
|
-
const [headerOpen, setHeaderOpen] =
|
|
3898
|
+
const [headerOpen, setHeaderOpen] = useState15(false);
|
|
3920
3899
|
const attachmentsRef = useRef8(null);
|
|
3921
3900
|
const senderRef = React6.useRef(null);
|
|
3922
3901
|
const {
|
|
@@ -3930,7 +3909,7 @@ var Chating = ({
|
|
|
3930
3909
|
tenantId,
|
|
3931
3910
|
clearError
|
|
3932
3911
|
} = useAgentChat();
|
|
3933
|
-
|
|
3912
|
+
useEffect10(() => {
|
|
3934
3913
|
regsiterElement("action_show_attachments_uploader", {
|
|
3935
3914
|
card_view: () => null,
|
|
3936
3915
|
action: (data) => {
|
|
@@ -4221,7 +4200,7 @@ var regsiterElement = (language, ElementMeta) => {
|
|
|
4221
4200
|
// src/components/Chat/SideAppViewBrowser.tsx
|
|
4222
4201
|
import { Button as Button11, Tabs } from "antd";
|
|
4223
4202
|
import { createStyles as createStyles9 } from "antd-style";
|
|
4224
|
-
import { useEffect as
|
|
4203
|
+
import { useEffect as useEffect11, useState as useState16 } from "react";
|
|
4225
4204
|
import { jsx as jsx30, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
4226
4205
|
var useStyle7 = createStyles9(({ token, css }) => {
|
|
4227
4206
|
return {
|
|
@@ -4256,10 +4235,10 @@ var SideAppViewBrowser = () => {
|
|
|
4256
4235
|
openSideApp,
|
|
4257
4236
|
closeSideApp
|
|
4258
4237
|
} = useChatUIContext();
|
|
4259
|
-
const [activeKey, setActiveKey] =
|
|
4238
|
+
const [activeKey, setActiveKey] = useState16(
|
|
4260
4239
|
JSON.stringify(sideAppSelectedCard)
|
|
4261
4240
|
);
|
|
4262
|
-
const [items, setItems] =
|
|
4241
|
+
const [items, setItems] = useState16([]);
|
|
4263
4242
|
const add = (key, label, children) => {
|
|
4264
4243
|
const newActiveKey = key;
|
|
4265
4244
|
const newPanes = [...items];
|
|
@@ -4295,7 +4274,7 @@ var SideAppViewBrowser = () => {
|
|
|
4295
4274
|
remove(targetKey);
|
|
4296
4275
|
}
|
|
4297
4276
|
};
|
|
4298
|
-
|
|
4277
|
+
useEffect11(() => {
|
|
4299
4278
|
const SideAppView = getElement(sideAppSelectedCard?.component_key).side_app_view || EmptySideAppView;
|
|
4300
4279
|
const key = JSON.stringify(sideAppSelectedCard);
|
|
4301
4280
|
if (items.find((item) => item.key === key)) {
|
|
@@ -4400,7 +4379,7 @@ var SideAppViewBrowser = () => {
|
|
|
4400
4379
|
// src/components/Chat/LatticeChat.tsx
|
|
4401
4380
|
import { jsx as jsx31 } from "react/jsx-runtime";
|
|
4402
4381
|
var LatticeChat = (props) => {
|
|
4403
|
-
const { assistant_id, thread_id, ...chatingProps } = props;
|
|
4382
|
+
const { assistant_id, thread_id = "", menu, ...chatingProps } = props;
|
|
4404
4383
|
return /* @__PURE__ */ jsx31(
|
|
4405
4384
|
AgentThreadProvider,
|
|
4406
4385
|
{
|
|
@@ -4414,7 +4393,8 @@ var LatticeChat = (props) => {
|
|
|
4414
4393
|
children: /* @__PURE__ */ jsx31(ChatUIContextProvider, { children: /* @__PURE__ */ jsx31(
|
|
4415
4394
|
ColumnLayout,
|
|
4416
4395
|
{
|
|
4417
|
-
|
|
4396
|
+
menu,
|
|
4397
|
+
left: thread_id ? /* @__PURE__ */ jsx31(Chating, { ...chatingProps }) : /* @__PURE__ */ jsx31("div", { children: "\u9700\u8981\u5148\u521B\u5EFA\u4F1A\u8BDD" }),
|
|
4418
4398
|
right: /* @__PURE__ */ jsx31(SideAppViewBrowser, {})
|
|
4419
4399
|
}
|
|
4420
4400
|
) })
|
|
@@ -4422,26 +4402,1007 @@ var LatticeChat = (props) => {
|
|
|
4422
4402
|
);
|
|
4423
4403
|
};
|
|
4424
4404
|
|
|
4425
|
-
// src/components/Chat/
|
|
4405
|
+
// src/components/Chat/ConversationContext.tsx
|
|
4426
4406
|
import {
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4407
|
+
createContext as createContext6,
|
|
4408
|
+
useCallback as useCallback10,
|
|
4409
|
+
useContext as useContext6,
|
|
4410
|
+
useEffect as useEffect13,
|
|
4411
|
+
useMemo as useMemo7,
|
|
4412
|
+
useRef as useRef10,
|
|
4413
|
+
useState as useState19
|
|
4414
|
+
} from "react";
|
|
4415
|
+
|
|
4416
|
+
// src/components/Chat/AssistantContext.tsx
|
|
4417
|
+
import {
|
|
4418
|
+
createContext as createContext5,
|
|
4419
|
+
useCallback as useCallback9,
|
|
4420
|
+
useContext as useContext5,
|
|
4421
|
+
useEffect as useEffect12,
|
|
4422
|
+
useMemo as useMemo6,
|
|
4423
|
+
useRef as useRef9,
|
|
4424
|
+
useState as useState18
|
|
4425
|
+
} from "react";
|
|
4426
|
+
import {
|
|
4427
|
+
Client as Client2
|
|
4428
|
+
} from "@axiom-lattice/client-sdk";
|
|
4429
|
+
|
|
4430
|
+
// src/components/Chat/LatticeChatShellContext.tsx
|
|
4431
|
+
import {
|
|
4432
|
+
createContext as createContext4,
|
|
4433
|
+
useCallback as useCallback8,
|
|
4434
|
+
useContext as useContext4,
|
|
4435
|
+
useState as useState17
|
|
4436
|
+
} from "react";
|
|
4437
|
+
import { jsx as jsx32 } from "react/jsx-runtime";
|
|
4438
|
+
var DEFAULT_CONFIG = {
|
|
4439
|
+
baseURL: "http://localhost:4001",
|
|
4440
|
+
apiKey: "",
|
|
4441
|
+
transport: "sse",
|
|
4442
|
+
timeout: 3e5,
|
|
4443
|
+
headers: {}
|
|
4444
|
+
};
|
|
4445
|
+
var LatticeChatShellContext = createContext4({
|
|
4446
|
+
config: DEFAULT_CONFIG,
|
|
4447
|
+
updateConfig: () => {
|
|
4448
|
+
},
|
|
4449
|
+
updateConfigValue: () => {
|
|
4450
|
+
},
|
|
4451
|
+
resetConfig: () => {
|
|
4452
|
+
}
|
|
4453
|
+
});
|
|
4454
|
+
var LatticeChatShellContextProvider = ({
|
|
4455
|
+
children,
|
|
4456
|
+
initialConfig = {},
|
|
4457
|
+
persistToLocalStorage = false,
|
|
4458
|
+
localStorageKey = "lattice_chat_shell_config"
|
|
4459
|
+
}) => {
|
|
4460
|
+
const loadInitialConfig = useCallback8(() => {
|
|
4461
|
+
if (persistToLocalStorage && typeof window !== "undefined") {
|
|
4462
|
+
try {
|
|
4463
|
+
const stored = localStorage.getItem(localStorageKey);
|
|
4464
|
+
if (stored) {
|
|
4465
|
+
const parsed = JSON.parse(stored);
|
|
4466
|
+
return { ...DEFAULT_CONFIG, ...parsed, ...initialConfig };
|
|
4467
|
+
}
|
|
4468
|
+
} catch (error) {
|
|
4469
|
+
console.warn("Failed to load config from localStorage:", error);
|
|
4470
|
+
}
|
|
4471
|
+
}
|
|
4472
|
+
return { ...DEFAULT_CONFIG, ...initialConfig };
|
|
4473
|
+
}, [persistToLocalStorage, localStorageKey, initialConfig]);
|
|
4474
|
+
const [config, setConfig] = useState17(loadInitialConfig);
|
|
4475
|
+
const saveToLocalStorage = useCallback8(
|
|
4476
|
+
(newConfig) => {
|
|
4477
|
+
if (persistToLocalStorage && typeof window !== "undefined") {
|
|
4478
|
+
try {
|
|
4479
|
+
localStorage.setItem(localStorageKey, JSON.stringify(newConfig));
|
|
4480
|
+
} catch (error) {
|
|
4481
|
+
console.warn("Failed to save config to localStorage:", error);
|
|
4482
|
+
}
|
|
4483
|
+
}
|
|
4484
|
+
},
|
|
4485
|
+
[persistToLocalStorage, localStorageKey]
|
|
4486
|
+
);
|
|
4487
|
+
const updateConfig = useCallback8(
|
|
4488
|
+
(updates) => {
|
|
4489
|
+
setConfig((prev) => {
|
|
4490
|
+
const newConfig = { ...prev, ...updates };
|
|
4491
|
+
saveToLocalStorage(newConfig);
|
|
4492
|
+
return newConfig;
|
|
4493
|
+
});
|
|
4494
|
+
},
|
|
4495
|
+
[saveToLocalStorage]
|
|
4496
|
+
);
|
|
4497
|
+
const updateConfigValue = useCallback8(
|
|
4498
|
+
(key, value) => {
|
|
4499
|
+
setConfig((prev) => {
|
|
4500
|
+
const newConfig = { ...prev, [key]: value };
|
|
4501
|
+
saveToLocalStorage(newConfig);
|
|
4502
|
+
return newConfig;
|
|
4503
|
+
});
|
|
4504
|
+
},
|
|
4505
|
+
[saveToLocalStorage]
|
|
4506
|
+
);
|
|
4507
|
+
const resetConfig = useCallback8(() => {
|
|
4508
|
+
const defaultConfig = { ...DEFAULT_CONFIG, ...initialConfig };
|
|
4509
|
+
setConfig(defaultConfig);
|
|
4510
|
+
saveToLocalStorage(defaultConfig);
|
|
4511
|
+
}, [initialConfig, saveToLocalStorage]);
|
|
4512
|
+
return /* @__PURE__ */ jsx32(
|
|
4513
|
+
LatticeChatShellContext.Provider,
|
|
4514
|
+
{
|
|
4515
|
+
value: {
|
|
4516
|
+
config,
|
|
4517
|
+
updateConfig,
|
|
4518
|
+
updateConfigValue,
|
|
4519
|
+
resetConfig
|
|
4520
|
+
},
|
|
4521
|
+
children
|
|
4522
|
+
}
|
|
4523
|
+
);
|
|
4524
|
+
};
|
|
4525
|
+
var useLatticeChatShellContext = () => {
|
|
4526
|
+
const context = useContext4(LatticeChatShellContext);
|
|
4527
|
+
if (!context) {
|
|
4528
|
+
throw new Error(
|
|
4529
|
+
"useLatticeChatShellContext must be used within a LatticeChatShellContextProvider"
|
|
4530
|
+
);
|
|
4531
|
+
}
|
|
4532
|
+
return context;
|
|
4533
|
+
};
|
|
4534
|
+
|
|
4535
|
+
// src/components/Chat/AssistantContext.tsx
|
|
4536
|
+
import { jsx as jsx33 } from "react/jsx-runtime";
|
|
4537
|
+
var AssistantContext = createContext5({
|
|
4538
|
+
assistants: [],
|
|
4539
|
+
currentAssistant: null,
|
|
4540
|
+
isLoading: false,
|
|
4541
|
+
error: null,
|
|
4542
|
+
listAssistants: async () => {
|
|
4543
|
+
},
|
|
4544
|
+
getAssistant: async () => {
|
|
4545
|
+
throw new Error("Not implemented");
|
|
4546
|
+
},
|
|
4547
|
+
createAssistant: async () => {
|
|
4548
|
+
throw new Error("Not implemented");
|
|
4549
|
+
},
|
|
4550
|
+
updateAssistant: async () => {
|
|
4551
|
+
throw new Error("Not implemented");
|
|
4552
|
+
},
|
|
4553
|
+
deleteAssistant: async () => {
|
|
4554
|
+
},
|
|
4555
|
+
selectAssistant: async () => {
|
|
4556
|
+
},
|
|
4557
|
+
clearCurrentAssistant: () => {
|
|
4558
|
+
},
|
|
4559
|
+
refresh: async () => {
|
|
4560
|
+
}
|
|
4561
|
+
});
|
|
4562
|
+
var AssistantContextProvider = ({
|
|
4563
|
+
children,
|
|
4564
|
+
autoLoad = true,
|
|
4565
|
+
initialAssistantId = null
|
|
4566
|
+
}) => {
|
|
4567
|
+
const {
|
|
4568
|
+
config: { baseURL, apiKey = "", transport = "sse" }
|
|
4569
|
+
} = useLatticeChatShellContext();
|
|
4570
|
+
const client = useMemo6(
|
|
4571
|
+
() => new Client2({
|
|
4572
|
+
baseURL,
|
|
4573
|
+
apiKey,
|
|
4574
|
+
assistantId: "",
|
|
4575
|
+
transport
|
|
4576
|
+
}),
|
|
4577
|
+
[baseURL, apiKey, transport]
|
|
4578
|
+
);
|
|
4579
|
+
const [state, setState] = useState18({
|
|
4580
|
+
assistants: [],
|
|
4581
|
+
currentAssistant: null,
|
|
4582
|
+
isLoading: false,
|
|
4583
|
+
error: null
|
|
4584
|
+
});
|
|
4585
|
+
const assistantsRef = useRef9([]);
|
|
4586
|
+
useEffect12(() => {
|
|
4587
|
+
assistantsRef.current = state.assistants;
|
|
4588
|
+
}, [state.assistants]);
|
|
4589
|
+
const listAssistants = useCallback9(async () => {
|
|
4590
|
+
setState((prev) => ({ ...prev, isLoading: true, error: null }));
|
|
4591
|
+
try {
|
|
4592
|
+
const assistants = await client.assistants.list();
|
|
4593
|
+
setState((prev) => ({
|
|
4594
|
+
...prev,
|
|
4595
|
+
assistants,
|
|
4596
|
+
isLoading: false
|
|
4597
|
+
}));
|
|
4598
|
+
} catch (error) {
|
|
4599
|
+
setState((prev) => ({
|
|
4600
|
+
...prev,
|
|
4601
|
+
isLoading: false,
|
|
4602
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
4603
|
+
}));
|
|
4604
|
+
}
|
|
4605
|
+
}, [client]);
|
|
4606
|
+
const getAssistant = useCallback9(
|
|
4607
|
+
async (id) => {
|
|
4608
|
+
setState((prev) => ({ ...prev, isLoading: true, error: null }));
|
|
4609
|
+
try {
|
|
4610
|
+
const assistant = await client.assistants.get(id);
|
|
4611
|
+
setState((prev) => ({
|
|
4612
|
+
...prev,
|
|
4613
|
+
// Update assistant in list if it exists
|
|
4614
|
+
assistants: prev.assistants.map((a) => a.id === id ? assistant : a),
|
|
4615
|
+
isLoading: false
|
|
4616
|
+
}));
|
|
4617
|
+
return assistant;
|
|
4618
|
+
} catch (error) {
|
|
4619
|
+
setState((prev) => ({
|
|
4620
|
+
...prev,
|
|
4621
|
+
isLoading: false,
|
|
4622
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
4623
|
+
}));
|
|
4624
|
+
throw error;
|
|
4625
|
+
}
|
|
4626
|
+
},
|
|
4627
|
+
[client]
|
|
4628
|
+
);
|
|
4629
|
+
const createAssistant = useCallback9(
|
|
4630
|
+
async (options) => {
|
|
4631
|
+
setState((prev) => ({ ...prev, isLoading: true, error: null }));
|
|
4632
|
+
try {
|
|
4633
|
+
const newAssistant = await client.assistants.create(options);
|
|
4634
|
+
setState((prev) => ({
|
|
4635
|
+
...prev,
|
|
4636
|
+
assistants: [...prev.assistants, newAssistant],
|
|
4637
|
+
isLoading: false
|
|
4638
|
+
}));
|
|
4639
|
+
return newAssistant;
|
|
4640
|
+
} catch (error) {
|
|
4641
|
+
setState((prev) => ({
|
|
4642
|
+
...prev,
|
|
4643
|
+
isLoading: false,
|
|
4644
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
4645
|
+
}));
|
|
4646
|
+
throw error;
|
|
4647
|
+
}
|
|
4648
|
+
},
|
|
4649
|
+
[client]
|
|
4650
|
+
);
|
|
4651
|
+
const updateAssistant = useCallback9(
|
|
4652
|
+
async (id, options) => {
|
|
4653
|
+
setState((prev) => ({ ...prev, isLoading: true, error: null }));
|
|
4654
|
+
try {
|
|
4655
|
+
const updatedAssistant = await client.assistants.update(id, options);
|
|
4656
|
+
setState((prev) => ({
|
|
4657
|
+
...prev,
|
|
4658
|
+
assistants: prev.assistants.map(
|
|
4659
|
+
(a) => a.id === id ? updatedAssistant : a
|
|
4660
|
+
),
|
|
4661
|
+
currentAssistant: prev.currentAssistant?.id === id ? updatedAssistant : prev.currentAssistant,
|
|
4662
|
+
isLoading: false
|
|
4663
|
+
}));
|
|
4664
|
+
return updatedAssistant;
|
|
4665
|
+
} catch (error) {
|
|
4666
|
+
setState((prev) => ({
|
|
4667
|
+
...prev,
|
|
4668
|
+
isLoading: false,
|
|
4669
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
4670
|
+
}));
|
|
4671
|
+
throw error;
|
|
4672
|
+
}
|
|
4673
|
+
},
|
|
4674
|
+
[client]
|
|
4675
|
+
);
|
|
4676
|
+
const deleteAssistant = useCallback9(
|
|
4677
|
+
async (id) => {
|
|
4678
|
+
setState((prev) => ({ ...prev, isLoading: true, error: null }));
|
|
4679
|
+
try {
|
|
4680
|
+
await client.assistants.delete(id);
|
|
4681
|
+
setState((prev) => ({
|
|
4682
|
+
...prev,
|
|
4683
|
+
assistants: prev.assistants.filter((a) => a.id !== id),
|
|
4684
|
+
currentAssistant: prev.currentAssistant?.id === id ? null : prev.currentAssistant,
|
|
4685
|
+
isLoading: false
|
|
4686
|
+
}));
|
|
4687
|
+
} catch (error) {
|
|
4688
|
+
setState((prev) => ({
|
|
4689
|
+
...prev,
|
|
4690
|
+
isLoading: false,
|
|
4691
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
4692
|
+
}));
|
|
4693
|
+
throw error;
|
|
4694
|
+
}
|
|
4695
|
+
},
|
|
4696
|
+
[client]
|
|
4697
|
+
);
|
|
4698
|
+
const selectAssistant = useCallback9(
|
|
4699
|
+
async (id) => {
|
|
4700
|
+
setState((prev) => ({ ...prev, isLoading: true, error: null }));
|
|
4701
|
+
try {
|
|
4702
|
+
const assistant = assistantsRef.current.find((a) => a.id === id);
|
|
4703
|
+
if (!assistant) {
|
|
4704
|
+
const fetchedAssistant = await client.assistants.get(id);
|
|
4705
|
+
setState((prev) => ({
|
|
4706
|
+
...prev,
|
|
4707
|
+
assistants: [...prev.assistants, fetchedAssistant],
|
|
4708
|
+
currentAssistant: fetchedAssistant,
|
|
4709
|
+
isLoading: false
|
|
4710
|
+
}));
|
|
4711
|
+
} else {
|
|
4712
|
+
setState((prev) => ({
|
|
4713
|
+
...prev,
|
|
4714
|
+
currentAssistant: assistant,
|
|
4715
|
+
isLoading: false
|
|
4716
|
+
}));
|
|
4717
|
+
}
|
|
4718
|
+
} catch (error) {
|
|
4719
|
+
setState((prev) => ({
|
|
4720
|
+
...prev,
|
|
4721
|
+
isLoading: false,
|
|
4722
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
4723
|
+
}));
|
|
4724
|
+
throw error;
|
|
4725
|
+
}
|
|
4726
|
+
},
|
|
4727
|
+
[client]
|
|
4728
|
+
);
|
|
4729
|
+
const clearCurrentAssistant = useCallback9(() => {
|
|
4730
|
+
setState((prev) => ({
|
|
4731
|
+
...prev,
|
|
4732
|
+
currentAssistant: null
|
|
4733
|
+
}));
|
|
4734
|
+
}, []);
|
|
4735
|
+
const refresh = useCallback9(async () => {
|
|
4736
|
+
await listAssistants();
|
|
4737
|
+
}, [listAssistants]);
|
|
4738
|
+
useEffect12(() => {
|
|
4739
|
+
if (autoLoad) {
|
|
4740
|
+
listAssistants();
|
|
4741
|
+
}
|
|
4742
|
+
}, [autoLoad, listAssistants]);
|
|
4743
|
+
useEffect12(() => {
|
|
4744
|
+
if (state.assistants.length > 0 && !state.currentAssistant) {
|
|
4745
|
+
if (initialAssistantId) {
|
|
4746
|
+
const assistant = state.assistants.find(
|
|
4747
|
+
(a) => a.id === initialAssistantId
|
|
4748
|
+
);
|
|
4749
|
+
if (assistant) {
|
|
4750
|
+
setState((prev) => ({
|
|
4751
|
+
...prev,
|
|
4752
|
+
currentAssistant: assistant
|
|
4753
|
+
}));
|
|
4754
|
+
}
|
|
4755
|
+
} else {
|
|
4756
|
+
setState((prev) => ({
|
|
4757
|
+
...prev,
|
|
4758
|
+
currentAssistant: prev.assistants[0]
|
|
4759
|
+
}));
|
|
4760
|
+
}
|
|
4761
|
+
}
|
|
4762
|
+
}, [initialAssistantId, state.assistants, state.currentAssistant]);
|
|
4763
|
+
return /* @__PURE__ */ jsx33(
|
|
4764
|
+
AssistantContext.Provider,
|
|
4765
|
+
{
|
|
4766
|
+
value: {
|
|
4767
|
+
...state,
|
|
4768
|
+
listAssistants,
|
|
4769
|
+
getAssistant,
|
|
4770
|
+
createAssistant,
|
|
4771
|
+
updateAssistant,
|
|
4772
|
+
deleteAssistant,
|
|
4773
|
+
selectAssistant,
|
|
4774
|
+
clearCurrentAssistant,
|
|
4775
|
+
refresh
|
|
4776
|
+
},
|
|
4777
|
+
children
|
|
4778
|
+
}
|
|
4779
|
+
);
|
|
4780
|
+
};
|
|
4781
|
+
var useAssistantContext = () => {
|
|
4782
|
+
const context = useContext5(AssistantContext);
|
|
4783
|
+
if (!context) {
|
|
4784
|
+
throw new Error(
|
|
4785
|
+
"useAssistantContext must be used within an AssistantContextProvider"
|
|
4786
|
+
);
|
|
4787
|
+
}
|
|
4788
|
+
return context;
|
|
4789
|
+
};
|
|
4790
|
+
|
|
4791
|
+
// src/components/Chat/ConversationContext.tsx
|
|
4792
|
+
import { Client as Client3 } from "@axiom-lattice/client-sdk";
|
|
4793
|
+
import { jsx as jsx34 } from "react/jsx-runtime";
|
|
4794
|
+
var ConversationContext = createContext6({
|
|
4795
|
+
assistantId: null,
|
|
4796
|
+
thread: null,
|
|
4797
|
+
threadId: null,
|
|
4798
|
+
threads: [],
|
|
4799
|
+
isLoading: false,
|
|
4800
|
+
error: null,
|
|
4801
|
+
setThread: () => {
|
|
4802
|
+
},
|
|
4803
|
+
selectThread: () => {
|
|
4804
|
+
},
|
|
4805
|
+
createThread: async () => {
|
|
4806
|
+
throw new Error("Not implemented");
|
|
4807
|
+
},
|
|
4808
|
+
listThreads: async () => [],
|
|
4809
|
+
updateThread: async () => {
|
|
4810
|
+
},
|
|
4811
|
+
getThreadById: () => null,
|
|
4812
|
+
deleteThread: async () => {
|
|
4813
|
+
},
|
|
4814
|
+
clearThread: () => {
|
|
4815
|
+
},
|
|
4816
|
+
refresh: async () => {
|
|
4817
|
+
}
|
|
4818
|
+
});
|
|
4819
|
+
function convertThreadToConversationThread(thread, label) {
|
|
4820
|
+
return {
|
|
4821
|
+
id: thread.id,
|
|
4822
|
+
label: label || thread.metadata?.label || new Date(thread.createdAt).toLocaleString()
|
|
4823
|
+
};
|
|
4824
|
+
}
|
|
4825
|
+
function getThreadMetadata(label) {
|
|
4826
|
+
return label ? { label } : {};
|
|
4827
|
+
}
|
|
4828
|
+
var ConversationContextProvider = ({
|
|
4829
|
+
children
|
|
4830
|
+
}) => {
|
|
4831
|
+
const { currentAssistant } = useAssistantContext();
|
|
4832
|
+
const assistantId = currentAssistant?.id || null;
|
|
4833
|
+
const {
|
|
4834
|
+
config: { baseURL, apiKey = "", transport = "sse" }
|
|
4835
|
+
} = useLatticeChatShellContext();
|
|
4836
|
+
const client = useMemo7(
|
|
4837
|
+
() => new Client3({
|
|
4838
|
+
baseURL,
|
|
4839
|
+
apiKey,
|
|
4840
|
+
assistantId: assistantId || "",
|
|
4841
|
+
transport
|
|
4842
|
+
}),
|
|
4843
|
+
[baseURL, apiKey, assistantId, transport]
|
|
4844
|
+
);
|
|
4845
|
+
const [threads, setThreads] = useState19([]);
|
|
4846
|
+
const [threadId, setThreadId] = useState19(null);
|
|
4847
|
+
const [isLoading, setIsLoading] = useState19(false);
|
|
4848
|
+
const [error, setError] = useState19(null);
|
|
4849
|
+
const loadedAssistantIdRef = useRef10(null);
|
|
4850
|
+
const prevAssistantIdRef = useRef10(null);
|
|
4851
|
+
const isLoadingRef = useRef10(false);
|
|
4852
|
+
const clientRef = useRef10(client);
|
|
4853
|
+
useEffect13(() => {
|
|
4854
|
+
clientRef.current = client;
|
|
4855
|
+
}, [client]);
|
|
4856
|
+
const loadThreads = useCallback10(async () => {
|
|
4857
|
+
const currentClient = clientRef.current;
|
|
4858
|
+
if (!assistantId || !currentClient.assistantId) {
|
|
4859
|
+
setThreads([]);
|
|
4860
|
+
loadedAssistantIdRef.current = null;
|
|
4861
|
+
return;
|
|
4862
|
+
}
|
|
4863
|
+
if (isLoadingRef.current && loadedAssistantIdRef.current === assistantId) {
|
|
4864
|
+
return;
|
|
4865
|
+
}
|
|
4866
|
+
isLoadingRef.current = true;
|
|
4867
|
+
setIsLoading(true);
|
|
4868
|
+
setError(null);
|
|
4869
|
+
try {
|
|
4870
|
+
const apiThreads = await currentClient.threads.list();
|
|
4871
|
+
const conversationThreads = apiThreads.map(
|
|
4872
|
+
(t) => convertThreadToConversationThread(t)
|
|
4873
|
+
);
|
|
4874
|
+
if (conversationThreads.length === 0) {
|
|
4875
|
+
try {
|
|
4876
|
+
const apiThread = await currentClient.threads.create({
|
|
4877
|
+
metadata: getThreadMetadata()
|
|
4878
|
+
});
|
|
4879
|
+
const newThread = convertThreadToConversationThread(apiThread);
|
|
4880
|
+
setThreads([newThread]);
|
|
4881
|
+
setThreadId(newThread.id);
|
|
4882
|
+
} catch (createErr) {
|
|
4883
|
+
const createError = createErr instanceof Error ? createErr : new Error(String(createErr));
|
|
4884
|
+
setError(createError);
|
|
4885
|
+
console.error("Failed to create initial thread:", createError);
|
|
4886
|
+
setThreads([]);
|
|
4887
|
+
}
|
|
4888
|
+
} else {
|
|
4889
|
+
setThreads(conversationThreads);
|
|
4890
|
+
setThreadId((currentThreadId) => {
|
|
4891
|
+
if (!currentThreadId) {
|
|
4892
|
+
const latestThread = conversationThreads[conversationThreads.length - 1];
|
|
4893
|
+
return latestThread.id;
|
|
4894
|
+
}
|
|
4895
|
+
const threadExists = conversationThreads.some(
|
|
4896
|
+
(t) => t.id === currentThreadId
|
|
4897
|
+
);
|
|
4898
|
+
if (!threadExists) {
|
|
4899
|
+
const latestThread = conversationThreads[conversationThreads.length - 1];
|
|
4900
|
+
return latestThread.id;
|
|
4901
|
+
}
|
|
4902
|
+
return currentThreadId;
|
|
4903
|
+
});
|
|
4904
|
+
}
|
|
4905
|
+
loadedAssistantIdRef.current = assistantId;
|
|
4906
|
+
} catch (err) {
|
|
4907
|
+
const error2 = err instanceof Error ? err : new Error(String(err));
|
|
4908
|
+
setError(error2);
|
|
4909
|
+
console.error("Failed to load threads:", error2);
|
|
4910
|
+
} finally {
|
|
4911
|
+
setIsLoading(false);
|
|
4912
|
+
isLoadingRef.current = false;
|
|
4913
|
+
}
|
|
4914
|
+
}, [assistantId]);
|
|
4915
|
+
useEffect13(() => {
|
|
4916
|
+
const currentClient = clientRef.current;
|
|
4917
|
+
const prevAssistantId = prevAssistantIdRef.current;
|
|
4918
|
+
const assistantChanged = prevAssistantId !== assistantId;
|
|
4919
|
+
if (assistantId && currentClient.assistantId === assistantId) {
|
|
4920
|
+
if (assistantChanged) {
|
|
4921
|
+
setThreadId(null);
|
|
4922
|
+
prevAssistantIdRef.current = assistantId;
|
|
4923
|
+
}
|
|
4924
|
+
if (loadedAssistantIdRef.current !== assistantId) {
|
|
4925
|
+
loadThreads();
|
|
4926
|
+
}
|
|
4927
|
+
} else {
|
|
4928
|
+
setThreadId(null);
|
|
4929
|
+
setThreads([]);
|
|
4930
|
+
loadedAssistantIdRef.current = null;
|
|
4931
|
+
prevAssistantIdRef.current = null;
|
|
4932
|
+
}
|
|
4933
|
+
}, [assistantId, loadThreads]);
|
|
4934
|
+
const thread = useMemo7(() => {
|
|
4935
|
+
if (!assistantId || !threadId) {
|
|
4936
|
+
return null;
|
|
4937
|
+
}
|
|
4938
|
+
return threads.find((t) => t.id === threadId) || null;
|
|
4939
|
+
}, [assistantId, threadId, threads]);
|
|
4940
|
+
const setThread = useCallback10((newThread) => {
|
|
4941
|
+
if (newThread) {
|
|
4942
|
+
setThreadId(newThread.id);
|
|
4943
|
+
} else {
|
|
4944
|
+
setThreadId(null);
|
|
4945
|
+
}
|
|
4946
|
+
}, []);
|
|
4947
|
+
const selectThread = useCallback10(
|
|
4948
|
+
(targetThreadId) => {
|
|
4949
|
+
const foundThread = threads.find((t) => t.id === targetThreadId);
|
|
4950
|
+
if (foundThread) {
|
|
4951
|
+
setThreadId(targetThreadId);
|
|
4952
|
+
}
|
|
4953
|
+
},
|
|
4954
|
+
[threads]
|
|
4955
|
+
);
|
|
4956
|
+
const createThread = useCallback10(
|
|
4957
|
+
async (label) => {
|
|
4958
|
+
if (!assistantId || !client.assistantId) {
|
|
4959
|
+
throw new Error("No assistant selected");
|
|
4960
|
+
}
|
|
4961
|
+
setIsLoading(true);
|
|
4962
|
+
setError(null);
|
|
4963
|
+
try {
|
|
4964
|
+
const apiThread = await client.threads.create({
|
|
4965
|
+
metadata: getThreadMetadata(label)
|
|
4966
|
+
});
|
|
4967
|
+
const newThread = convertThreadToConversationThread(apiThread, label);
|
|
4968
|
+
await loadThreads();
|
|
4969
|
+
setThreadId(newThread.id);
|
|
4970
|
+
return newThread;
|
|
4971
|
+
} catch (err) {
|
|
4972
|
+
const error2 = err instanceof Error ? err : new Error(String(err));
|
|
4973
|
+
setError(error2);
|
|
4974
|
+
throw error2;
|
|
4975
|
+
} finally {
|
|
4976
|
+
setIsLoading(false);
|
|
4977
|
+
}
|
|
4978
|
+
},
|
|
4979
|
+
[assistantId, client, loadThreads]
|
|
4980
|
+
);
|
|
4981
|
+
const listThreads = useCallback10(async () => {
|
|
4982
|
+
if (!assistantId || !client.assistantId) {
|
|
4983
|
+
return [];
|
|
4984
|
+
}
|
|
4985
|
+
setIsLoading(true);
|
|
4986
|
+
setError(null);
|
|
4987
|
+
try {
|
|
4988
|
+
const apiThreads = await client.threads.list();
|
|
4989
|
+
const conversationThreads = apiThreads.map(
|
|
4990
|
+
(t) => convertThreadToConversationThread(t)
|
|
4991
|
+
);
|
|
4992
|
+
setThreads(conversationThreads);
|
|
4993
|
+
return conversationThreads;
|
|
4994
|
+
} catch (err) {
|
|
4995
|
+
const error2 = err instanceof Error ? err : new Error(String(err));
|
|
4996
|
+
setError(error2);
|
|
4997
|
+
return threads;
|
|
4998
|
+
} finally {
|
|
4999
|
+
setIsLoading(false);
|
|
5000
|
+
}
|
|
5001
|
+
}, [assistantId, client, threads]);
|
|
5002
|
+
const updateThread = useCallback10(
|
|
5003
|
+
async (newThread) => {
|
|
5004
|
+
if (!assistantId || !client.assistantId) {
|
|
5005
|
+
throw new Error("No assistant selected");
|
|
5006
|
+
}
|
|
5007
|
+
setIsLoading(true);
|
|
5008
|
+
setError(null);
|
|
5009
|
+
try {
|
|
5010
|
+
await client.threads.update(newThread.id, {
|
|
5011
|
+
metadata: getThreadMetadata(newThread.label)
|
|
5012
|
+
});
|
|
5013
|
+
await loadThreads();
|
|
5014
|
+
} catch (err) {
|
|
5015
|
+
const error2 = err instanceof Error ? err : new Error(String(err));
|
|
5016
|
+
setError(error2);
|
|
5017
|
+
throw error2;
|
|
5018
|
+
} finally {
|
|
5019
|
+
setIsLoading(false);
|
|
5020
|
+
}
|
|
5021
|
+
},
|
|
5022
|
+
[assistantId, client, loadThreads]
|
|
5023
|
+
);
|
|
5024
|
+
const getThreadById = useCallback10(
|
|
5025
|
+
(targetThreadId) => {
|
|
5026
|
+
return threads.find((t) => t.id === targetThreadId) || null;
|
|
5027
|
+
},
|
|
5028
|
+
[threads]
|
|
5029
|
+
);
|
|
5030
|
+
const deleteThread = useCallback10(
|
|
5031
|
+
async (targetThreadId) => {
|
|
5032
|
+
if (!assistantId || !client.assistantId) {
|
|
5033
|
+
throw new Error("No assistant selected");
|
|
5034
|
+
}
|
|
5035
|
+
setIsLoading(true);
|
|
5036
|
+
setError(null);
|
|
5037
|
+
try {
|
|
5038
|
+
await client.threads.delete(targetThreadId);
|
|
5039
|
+
await loadThreads();
|
|
5040
|
+
if (targetThreadId === threadId) {
|
|
5041
|
+
setThreadId(null);
|
|
5042
|
+
}
|
|
5043
|
+
} catch (err) {
|
|
5044
|
+
const error2 = err instanceof Error ? err : new Error(String(err));
|
|
5045
|
+
setError(error2);
|
|
5046
|
+
throw error2;
|
|
5047
|
+
} finally {
|
|
5048
|
+
setIsLoading(false);
|
|
5049
|
+
}
|
|
5050
|
+
},
|
|
5051
|
+
[threadId, assistantId, client, loadThreads]
|
|
5052
|
+
);
|
|
5053
|
+
const clearThread = useCallback10(() => {
|
|
5054
|
+
setThreadId(null);
|
|
5055
|
+
}, []);
|
|
5056
|
+
return /* @__PURE__ */ jsx34(
|
|
5057
|
+
ConversationContext.Provider,
|
|
5058
|
+
{
|
|
5059
|
+
value: {
|
|
5060
|
+
assistantId,
|
|
5061
|
+
thread,
|
|
5062
|
+
threadId,
|
|
5063
|
+
threads,
|
|
5064
|
+
isLoading,
|
|
5065
|
+
error,
|
|
5066
|
+
setThread,
|
|
5067
|
+
selectThread,
|
|
5068
|
+
createThread,
|
|
5069
|
+
listThreads,
|
|
5070
|
+
updateThread,
|
|
5071
|
+
getThreadById,
|
|
5072
|
+
deleteThread,
|
|
5073
|
+
clearThread,
|
|
5074
|
+
refresh: loadThreads
|
|
5075
|
+
},
|
|
5076
|
+
children
|
|
5077
|
+
}
|
|
5078
|
+
);
|
|
5079
|
+
};
|
|
5080
|
+
var useConversationContext = () => {
|
|
5081
|
+
const context = useContext6(ConversationContext);
|
|
5082
|
+
if (!context) {
|
|
5083
|
+
throw new Error(
|
|
5084
|
+
"useConversationContext must be used within a ConversationContextProvider"
|
|
5085
|
+
);
|
|
5086
|
+
}
|
|
5087
|
+
return context;
|
|
5088
|
+
};
|
|
5089
|
+
|
|
5090
|
+
// src/components/Chat/AgentConversations.tsx
|
|
4432
5091
|
import { Conversations } from "@ant-design/x";
|
|
4433
5092
|
import { theme } from "antd";
|
|
4434
|
-
import {
|
|
4435
|
-
import { jsx as
|
|
5093
|
+
import { useMemo as useMemo8 } from "react";
|
|
5094
|
+
import { jsx as jsx35 } from "react/jsx-runtime";
|
|
5095
|
+
var AgentConversations = () => {
|
|
5096
|
+
const { token } = theme.useToken();
|
|
5097
|
+
const { currentAssistant } = useAssistantContext();
|
|
5098
|
+
const {
|
|
5099
|
+
assistantId,
|
|
5100
|
+
thread,
|
|
5101
|
+
selectThread,
|
|
5102
|
+
createThread,
|
|
5103
|
+
listThreads,
|
|
5104
|
+
threads
|
|
5105
|
+
} = useConversationContext();
|
|
5106
|
+
const style = {
|
|
5107
|
+
width: "100%",
|
|
5108
|
+
background: "transparent",
|
|
5109
|
+
borderRadius: token.borderRadius
|
|
5110
|
+
};
|
|
5111
|
+
const threadItems = useMemo8(() => {
|
|
5112
|
+
return threads || [];
|
|
5113
|
+
}, [threads]);
|
|
5114
|
+
const items = threadItems.map((thread2) => ({
|
|
5115
|
+
key: thread2.id,
|
|
5116
|
+
label: thread2.label
|
|
5117
|
+
}));
|
|
5118
|
+
const newChatClick = async () => {
|
|
5119
|
+
if (!assistantId) {
|
|
5120
|
+
return;
|
|
5121
|
+
}
|
|
5122
|
+
await createThread();
|
|
5123
|
+
};
|
|
5124
|
+
return /* @__PURE__ */ jsx35(
|
|
5125
|
+
Conversations,
|
|
5126
|
+
{
|
|
5127
|
+
creation: {
|
|
5128
|
+
onClick: newChatClick
|
|
5129
|
+
},
|
|
5130
|
+
items,
|
|
5131
|
+
activeKey: thread?.id,
|
|
5132
|
+
style,
|
|
5133
|
+
groupable: true,
|
|
5134
|
+
onActiveChange: (key) => {
|
|
5135
|
+
selectThread(key);
|
|
5136
|
+
}
|
|
5137
|
+
}
|
|
5138
|
+
);
|
|
5139
|
+
};
|
|
5140
|
+
|
|
5141
|
+
// src/components/Chat/ChatSidebar.tsx
|
|
5142
|
+
import { Divider as Divider2 } from "antd";
|
|
5143
|
+
import {
|
|
5144
|
+
MenuFoldOutlined,
|
|
5145
|
+
MenuUnfoldOutlined,
|
|
5146
|
+
SettingOutlined
|
|
5147
|
+
} from "@ant-design/icons";
|
|
5148
|
+
|
|
5149
|
+
// src/components/Chat/AssistantList.tsx
|
|
5150
|
+
import { Conversations as Conversations2 } from "@ant-design/x";
|
|
5151
|
+
import { Avatar as Avatar3, theme as theme2 } from "antd";
|
|
5152
|
+
import { jsx as jsx36 } from "react/jsx-runtime";
|
|
5153
|
+
var AssistantList = () => {
|
|
5154
|
+
const { token } = theme2.useToken();
|
|
5155
|
+
const { assistants, selectAssistant, currentAssistant } = useAssistantContext();
|
|
5156
|
+
const style = {
|
|
5157
|
+
width: "100%",
|
|
5158
|
+
background: "transparent",
|
|
5159
|
+
borderRadius: token.borderRadius
|
|
5160
|
+
};
|
|
5161
|
+
const items = assistants.map((assistant) => ({
|
|
5162
|
+
key: assistant.id,
|
|
5163
|
+
label: assistant.name,
|
|
5164
|
+
icon: /* @__PURE__ */ jsx36(
|
|
5165
|
+
Avatar3,
|
|
5166
|
+
{
|
|
5167
|
+
size: "small",
|
|
5168
|
+
style: {
|
|
5169
|
+
backgroundColor: token.colorFillSecondary,
|
|
5170
|
+
color: token.colorText
|
|
5171
|
+
},
|
|
5172
|
+
children: assistant.name.charAt(0).toUpperCase()
|
|
5173
|
+
}
|
|
5174
|
+
)
|
|
5175
|
+
}));
|
|
5176
|
+
return /* @__PURE__ */ jsx36(
|
|
5177
|
+
Conversations2,
|
|
5178
|
+
{
|
|
5179
|
+
items,
|
|
5180
|
+
activeKey: currentAssistant?.id,
|
|
5181
|
+
style,
|
|
5182
|
+
onActiveChange: (key) => {
|
|
5183
|
+
selectAssistant(key);
|
|
5184
|
+
}
|
|
5185
|
+
}
|
|
5186
|
+
);
|
|
5187
|
+
};
|
|
5188
|
+
|
|
5189
|
+
// src/components/Chat/ChatSidebar.tsx
|
|
5190
|
+
import { createStyles as createStyles10 } from "antd-style";
|
|
5191
|
+
import { jsx as jsx37, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
5192
|
+
var useStyles3 = createStyles10(({ token, css }) => ({
|
|
5193
|
+
sidebar: css`
|
|
5194
|
+
display: flex;
|
|
5195
|
+
flex-direction: column;
|
|
5196
|
+
height: 100%;
|
|
5197
|
+
width: 100%;
|
|
5198
|
+
position: relative;
|
|
5199
|
+
background: transparent;
|
|
5200
|
+
border-radius: ${token.borderRadiusLG}px;
|
|
5201
|
+
overflow: hidden;
|
|
5202
|
+
`,
|
|
5203
|
+
content: css`
|
|
5204
|
+
flex: 1;
|
|
5205
|
+
overflow-y: auto;
|
|
5206
|
+
overflow-x: hidden;
|
|
5207
|
+
padding: ${token.paddingMD}px ${token.paddingSM}px;
|
|
5208
|
+
padding-bottom: ${token.paddingLG}px;
|
|
5209
|
+
|
|
5210
|
+
/* Custom scrollbar styling */
|
|
5211
|
+
&::-webkit-scrollbar {
|
|
5212
|
+
width: 6px;
|
|
5213
|
+
}
|
|
5214
|
+
|
|
5215
|
+
&::-webkit-scrollbar-track {
|
|
5216
|
+
background: transparent;
|
|
5217
|
+
}
|
|
5218
|
+
|
|
5219
|
+
&::-webkit-scrollbar-thumb {
|
|
5220
|
+
background: ${token.colorBorder};
|
|
5221
|
+
border-radius: 3px;
|
|
5222
|
+
|
|
5223
|
+
&:hover {
|
|
5224
|
+
background: ${token.colorBorderSecondary};
|
|
5225
|
+
}
|
|
5226
|
+
}
|
|
5227
|
+
`,
|
|
5228
|
+
section: css`
|
|
5229
|
+
margin-bottom: ${token.marginLG}px;
|
|
5230
|
+
|
|
5231
|
+
&:last-child {
|
|
5232
|
+
margin-bottom: 0;
|
|
5233
|
+
}
|
|
5234
|
+
`,
|
|
5235
|
+
sectionTitle: css`
|
|
5236
|
+
font-size: ${token.fontSizeSM}px;
|
|
5237
|
+
font-weight: 600;
|
|
5238
|
+
color: ${token.colorTextSecondary};
|
|
5239
|
+
text-transform: uppercase;
|
|
5240
|
+
letter-spacing: 0.5px;
|
|
5241
|
+
padding: 0 ${token.paddingXS}px;
|
|
5242
|
+
margin-bottom: ${token.marginSM}px;
|
|
5243
|
+
`,
|
|
5244
|
+
footer: css`
|
|
5245
|
+
display: flex;
|
|
5246
|
+
justify-content: center;
|
|
5247
|
+
align-items: center;
|
|
5248
|
+
padding: ${token.paddingSM}px;
|
|
5249
|
+
background: transparent;
|
|
5250
|
+
border-top: 1px solid ${token.colorBorderSecondary};
|
|
5251
|
+
gap: ${token.marginXS}px;
|
|
5252
|
+
flex-shrink: 0;
|
|
5253
|
+
position: relative;
|
|
5254
|
+
|
|
5255
|
+
&::before {
|
|
5256
|
+
content: "";
|
|
5257
|
+
position: absolute;
|
|
5258
|
+
top: 0;
|
|
5259
|
+
left: 0;
|
|
5260
|
+
right: 0;
|
|
5261
|
+
height: 1px;
|
|
5262
|
+
background: linear-gradient(
|
|
5263
|
+
90deg,
|
|
5264
|
+
transparent,
|
|
5265
|
+
${token.colorBorder},
|
|
5266
|
+
transparent
|
|
5267
|
+
);
|
|
5268
|
+
}
|
|
5269
|
+
`,
|
|
5270
|
+
actionButton: css`
|
|
5271
|
+
display: flex;
|
|
5272
|
+
align-items: center;
|
|
5273
|
+
justify-content: center;
|
|
5274
|
+
width: 36px;
|
|
5275
|
+
height: 36px;
|
|
5276
|
+
border-radius: ${token.borderRadius}px;
|
|
5277
|
+
border: none;
|
|
5278
|
+
background: ${token.colorBgContainer};
|
|
5279
|
+
color: ${token.colorTextSecondary};
|
|
5280
|
+
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
|
5281
|
+
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
|
|
5282
|
+
|
|
5283
|
+
&:hover {
|
|
5284
|
+
background: ${token.colorPrimaryBg};
|
|
5285
|
+
color: ${token.colorPrimary};
|
|
5286
|
+
transform: translateY(-1px);
|
|
5287
|
+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
|
|
5288
|
+
}
|
|
5289
|
+
|
|
5290
|
+
&:active {
|
|
5291
|
+
transform: translateY(0);
|
|
5292
|
+
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
|
|
5293
|
+
}
|
|
5294
|
+
|
|
5295
|
+
.anticon {
|
|
5296
|
+
font-size: 16px;
|
|
5297
|
+
}
|
|
5298
|
+
`,
|
|
5299
|
+
divider: css`
|
|
5300
|
+
margin: ${token.marginMD}px 0;
|
|
5301
|
+
border-color: ${token.colorBorderSecondary};
|
|
5302
|
+
`
|
|
5303
|
+
}));
|
|
5304
|
+
var ChatSidebar = ({
|
|
5305
|
+
onSettingsClick,
|
|
5306
|
+
defaultCollapsed = false
|
|
5307
|
+
}) => {
|
|
5308
|
+
const { styles } = useStyles3();
|
|
5309
|
+
const { setMenuCollapsed, menuCollapsed } = useChatUIContext();
|
|
5310
|
+
const handleToggleCollapse = () => {
|
|
5311
|
+
setMenuCollapsed(!menuCollapsed);
|
|
5312
|
+
};
|
|
5313
|
+
const handleSettingsClick = () => {
|
|
5314
|
+
onSettingsClick?.();
|
|
5315
|
+
};
|
|
5316
|
+
return /* @__PURE__ */ jsxs19("div", { className: styles.sidebar, children: [
|
|
5317
|
+
!menuCollapsed && /* @__PURE__ */ jsxs19("div", { className: styles.content, children: [
|
|
5318
|
+
/* @__PURE__ */ jsxs19("div", { className: styles.section, children: [
|
|
5319
|
+
/* @__PURE__ */ jsx37("div", { className: styles.sectionTitle, children: "Assistants" }),
|
|
5320
|
+
/* @__PURE__ */ jsx37(AssistantList, {})
|
|
5321
|
+
] }),
|
|
5322
|
+
/* @__PURE__ */ jsx37(Divider2, { className: styles.divider }),
|
|
5323
|
+
/* @__PURE__ */ jsxs19("div", { className: styles.section, children: [
|
|
5324
|
+
/* @__PURE__ */ jsx37("div", { className: styles.sectionTitle, children: "Threads" }),
|
|
5325
|
+
/* @__PURE__ */ jsx37(AgentConversations, {})
|
|
5326
|
+
] })
|
|
5327
|
+
] }),
|
|
5328
|
+
/* @__PURE__ */ jsxs19("div", { className: styles.footer, children: [
|
|
5329
|
+
/* @__PURE__ */ jsx37(
|
|
5330
|
+
"button",
|
|
5331
|
+
{
|
|
5332
|
+
className: styles.actionButton,
|
|
5333
|
+
onClick: handleToggleCollapse,
|
|
5334
|
+
title: menuCollapsed ? "Expand sidebar" : "Collapse sidebar",
|
|
5335
|
+
"aria-label": menuCollapsed ? "Expand sidebar" : "Collapse sidebar",
|
|
5336
|
+
children: menuCollapsed ? /* @__PURE__ */ jsx37(MenuUnfoldOutlined, {}) : /* @__PURE__ */ jsx37(MenuFoldOutlined, {})
|
|
5337
|
+
}
|
|
5338
|
+
),
|
|
5339
|
+
!menuCollapsed && /* @__PURE__ */ jsx37(
|
|
5340
|
+
"button",
|
|
5341
|
+
{
|
|
5342
|
+
className: styles.actionButton,
|
|
5343
|
+
onClick: handleSettingsClick,
|
|
5344
|
+
title: "Settings",
|
|
5345
|
+
"aria-label": "Settings",
|
|
5346
|
+
children: /* @__PURE__ */ jsx37(SettingOutlined, {})
|
|
5347
|
+
}
|
|
5348
|
+
)
|
|
5349
|
+
] })
|
|
5350
|
+
] });
|
|
5351
|
+
};
|
|
5352
|
+
|
|
5353
|
+
// src/components/Chat/LatticeChatView.tsx
|
|
5354
|
+
import { jsx as jsx38 } from "react/jsx-runtime";
|
|
5355
|
+
var LatticeChatView = (props) => {
|
|
5356
|
+
const { assistantId, thread } = useConversationContext();
|
|
5357
|
+
const { currentAssistant } = useAssistantContext();
|
|
5358
|
+
const {
|
|
5359
|
+
config: { baseURL }
|
|
5360
|
+
} = useLatticeChatShellContext();
|
|
5361
|
+
return assistantId && thread ? /* @__PURE__ */ jsx38(
|
|
5362
|
+
AxiomLatticeProvider,
|
|
5363
|
+
{
|
|
5364
|
+
config: {
|
|
5365
|
+
baseURL,
|
|
5366
|
+
apiKey: "",
|
|
5367
|
+
assistantId,
|
|
5368
|
+
transport: "sse"
|
|
5369
|
+
},
|
|
5370
|
+
children: /* @__PURE__ */ jsx38(
|
|
5371
|
+
LatticeChat,
|
|
5372
|
+
{
|
|
5373
|
+
thread_id: thread?.id,
|
|
5374
|
+
assistant_id: assistantId,
|
|
5375
|
+
name: currentAssistant?.name,
|
|
5376
|
+
description: currentAssistant?.description,
|
|
5377
|
+
menu: /* @__PURE__ */ jsx38(ChatSidebar, {})
|
|
5378
|
+
}
|
|
5379
|
+
)
|
|
5380
|
+
}
|
|
5381
|
+
) : null;
|
|
5382
|
+
};
|
|
5383
|
+
|
|
5384
|
+
// src/components/Chat/LatticeChatShell.tsx
|
|
5385
|
+
import { jsx as jsx39 } from "react/jsx-runtime";
|
|
5386
|
+
var LatticeChatShell = (props) => {
|
|
5387
|
+
return /* @__PURE__ */ jsx39(LatticeChatShellContextProvider, { ...props, children: /* @__PURE__ */ jsx39(AssistantContextProvider, { autoLoad: true, children: /* @__PURE__ */ jsx39(ConversationContextProvider, { children: /* @__PURE__ */ jsx39(LatticeChatView, {}) }) }) });
|
|
5388
|
+
};
|
|
4436
5389
|
export {
|
|
5390
|
+
AgentConversations,
|
|
4437
5391
|
AgentThreadProvider,
|
|
5392
|
+
AssistantContext,
|
|
5393
|
+
AssistantContextProvider,
|
|
4438
5394
|
AxiomLatticeProvider,
|
|
4439
5395
|
ChatUIContext,
|
|
4440
5396
|
ChatUIContextProvider,
|
|
4441
5397
|
Chating,
|
|
4442
5398
|
ColumnLayout,
|
|
5399
|
+
ConversationContext,
|
|
5400
|
+
ConversationContextProvider,
|
|
4443
5401
|
FileExplorer,
|
|
4444
5402
|
LatticeChat,
|
|
5403
|
+
LatticeChatShell,
|
|
5404
|
+
LatticeChatShellContext,
|
|
5405
|
+
LatticeChatShellContextProvider,
|
|
4445
5406
|
MDMermaid,
|
|
4446
5407
|
MDResponse,
|
|
4447
5408
|
MDViewFormItem,
|
|
@@ -4452,9 +5413,11 @@ export {
|
|
|
4452
5413
|
useAgentGraph,
|
|
4453
5414
|
useAgentState,
|
|
4454
5415
|
useAgentThreadContext,
|
|
5416
|
+
useAssistantContext,
|
|
4455
5417
|
useAxiomLattice,
|
|
4456
5418
|
useChat,
|
|
4457
5419
|
useChatUIContext,
|
|
4458
|
-
|
|
5420
|
+
useConversationContext,
|
|
5421
|
+
useLatticeChatShellContext
|
|
4459
5422
|
};
|
|
4460
5423
|
//# sourceMappingURL=index.mjs.map
|