@copilotkit/runtime-client-gql 1.10.0 → 1.10.1-next.1
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/CHANGELOG.md +20 -0
- package/dist/{chunk-PAQ6AHHC.mjs → chunk-5V6B3OXS.mjs} +2 -2
- package/dist/{chunk-PAQ6AHHC.mjs.map → chunk-5V6B3OXS.mjs.map} +1 -1
- package/dist/{chunk-YNQMTL2P.mjs → chunk-SCACOKQX.mjs} +38 -8
- package/dist/chunk-SCACOKQX.mjs.map +1 -0
- package/dist/{chunk-MTD2RJDJ.mjs → chunk-ZYA32QXZ.mjs} +44 -29
- package/dist/chunk-ZYA32QXZ.mjs.map +1 -0
- package/dist/client/CopilotRuntimeClient.js +1 -1
- package/dist/client/CopilotRuntimeClient.js.map +1 -1
- package/dist/client/CopilotRuntimeClient.mjs +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/index.mjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +82 -36
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -3
- package/dist/message-conversion/agui-to-gql.js +37 -7
- package/dist/message-conversion/agui-to-gql.js.map +1 -1
- package/dist/message-conversion/agui-to-gql.mjs +2 -2
- package/dist/message-conversion/agui-to-gql.test.js +529 -7
- package/dist/message-conversion/agui-to-gql.test.js.map +1 -1
- package/dist/message-conversion/agui-to-gql.test.mjs +494 -2
- package/dist/message-conversion/agui-to-gql.test.mjs.map +1 -1
- package/dist/message-conversion/gql-to-agui.d.ts +3 -2
- package/dist/message-conversion/gql-to-agui.js +44 -28
- package/dist/message-conversion/gql-to-agui.js.map +1 -1
- package/dist/message-conversion/gql-to-agui.mjs +4 -2
- package/dist/message-conversion/gql-to-agui.test.js +622 -28
- package/dist/message-conversion/gql-to-agui.test.js.map +1 -1
- package/dist/message-conversion/gql-to-agui.test.mjs +583 -2
- package/dist/message-conversion/gql-to-agui.test.mjs.map +1 -1
- package/dist/message-conversion/index.d.ts +1 -1
- package/dist/message-conversion/index.js +81 -35
- package/dist/message-conversion/index.js.map +1 -1
- package/dist/message-conversion/index.mjs +5 -3
- package/dist/message-conversion/roundtrip-conversion.test.js +250 -35
- package/dist/message-conversion/roundtrip-conversion.test.js.map +1 -1
- package/dist/message-conversion/roundtrip-conversion.test.mjs +174 -3
- package/dist/message-conversion/roundtrip-conversion.test.mjs.map +1 -1
- package/package.json +3 -3
- package/src/message-conversion/agui-to-gql.test.ts +566 -0
- package/src/message-conversion/agui-to-gql.ts +56 -9
- package/src/message-conversion/gql-to-agui.test.ts +663 -0
- package/src/message-conversion/gql-to-agui.ts +62 -35
- package/src/message-conversion/roundtrip-conversion.test.ts +228 -0
- package/dist/chunk-MTD2RJDJ.mjs.map +0 -1
- package/dist/chunk-YNQMTL2P.mjs.map +0 -1
|
@@ -5,14 +5,14 @@ import {
|
|
|
5
5
|
aguiToGQL,
|
|
6
6
|
aguiToolCallToGQLActionExecution,
|
|
7
7
|
aguiToolMessageToGQLResultMessage
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-SCACOKQX.mjs";
|
|
9
9
|
import {
|
|
10
10
|
describe,
|
|
11
11
|
globalExpect,
|
|
12
12
|
test
|
|
13
13
|
} from "../chunk-2R7M2FWR.mjs";
|
|
14
14
|
import "../chunk-7ECCT6PK.mjs";
|
|
15
|
-
import "../chunk-
|
|
15
|
+
import "../chunk-5V6B3OXS.mjs";
|
|
16
16
|
import "../chunk-X2UAP3QY.mjs";
|
|
17
17
|
import "../chunk-HEODM5TW.mjs";
|
|
18
18
|
import "../chunk-4KTMZMM2.mjs";
|
|
@@ -561,5 +561,497 @@ describe("agui-to-gql", () => {
|
|
|
561
561
|
globalExpect(result.role).toBe(Role.User);
|
|
562
562
|
});
|
|
563
563
|
});
|
|
564
|
+
describe("Wild Card Actions", () => {
|
|
565
|
+
test("should preserve render function for specific action", () => {
|
|
566
|
+
const mockRender = () => "Specific Action Render";
|
|
567
|
+
const aguiMessage = {
|
|
568
|
+
id: "assistant-1",
|
|
569
|
+
role: "assistant",
|
|
570
|
+
content: "I'll execute a function",
|
|
571
|
+
toolCalls: [
|
|
572
|
+
{
|
|
573
|
+
id: "tool-call-1",
|
|
574
|
+
type: "function",
|
|
575
|
+
function: {
|
|
576
|
+
name: "specificAction",
|
|
577
|
+
arguments: JSON.stringify({ param: "value" })
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
],
|
|
581
|
+
generativeUI: mockRender
|
|
582
|
+
};
|
|
583
|
+
const actions = {
|
|
584
|
+
specificAction: { name: "specificAction" }
|
|
585
|
+
};
|
|
586
|
+
const result = aguiToGQL(aguiMessage, actions);
|
|
587
|
+
globalExpect(result).toHaveLength(2);
|
|
588
|
+
globalExpect(result[0]).toBeInstanceOf(TextMessage);
|
|
589
|
+
globalExpect(result[1]).toBeInstanceOf(ActionExecutionMessage);
|
|
590
|
+
globalExpect(actions.specificAction.render).toBe(mockRender);
|
|
591
|
+
});
|
|
592
|
+
test("should preserve render function for wild card action", () => {
|
|
593
|
+
const mockRender = () => "Wild Card Action Render";
|
|
594
|
+
const aguiMessage = {
|
|
595
|
+
id: "assistant-2",
|
|
596
|
+
role: "assistant",
|
|
597
|
+
content: "I'll execute an unknown function",
|
|
598
|
+
toolCalls: [
|
|
599
|
+
{
|
|
600
|
+
id: "tool-call-2",
|
|
601
|
+
type: "function",
|
|
602
|
+
function: {
|
|
603
|
+
name: "unknownAction",
|
|
604
|
+
arguments: JSON.stringify({ param: "value" })
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
],
|
|
608
|
+
generativeUI: mockRender
|
|
609
|
+
};
|
|
610
|
+
const actions = {
|
|
611
|
+
"*": { name: "*" }
|
|
612
|
+
};
|
|
613
|
+
const result = aguiToGQL(aguiMessage, actions);
|
|
614
|
+
globalExpect(result).toHaveLength(2);
|
|
615
|
+
globalExpect(result[0]).toBeInstanceOf(TextMessage);
|
|
616
|
+
globalExpect(result[1]).toBeInstanceOf(ActionExecutionMessage);
|
|
617
|
+
globalExpect(actions["*"].render).toBe(mockRender);
|
|
618
|
+
});
|
|
619
|
+
test("should prioritize specific action over wild card action", () => {
|
|
620
|
+
const mockRender = () => "Prioritized Render";
|
|
621
|
+
const aguiMessage = {
|
|
622
|
+
id: "assistant-3",
|
|
623
|
+
role: "assistant",
|
|
624
|
+
content: "I'll execute a function",
|
|
625
|
+
toolCalls: [
|
|
626
|
+
{
|
|
627
|
+
id: "tool-call-3",
|
|
628
|
+
type: "function",
|
|
629
|
+
function: {
|
|
630
|
+
name: "specificAction",
|
|
631
|
+
arguments: JSON.stringify({ param: "value" })
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
],
|
|
635
|
+
generativeUI: mockRender
|
|
636
|
+
};
|
|
637
|
+
const actions = {
|
|
638
|
+
specificAction: { name: "specificAction" },
|
|
639
|
+
"*": { name: "*" }
|
|
640
|
+
};
|
|
641
|
+
const result = aguiToGQL(aguiMessage, actions);
|
|
642
|
+
globalExpect(result).toHaveLength(2);
|
|
643
|
+
globalExpect(result[0]).toBeInstanceOf(TextMessage);
|
|
644
|
+
globalExpect(result[1]).toBeInstanceOf(ActionExecutionMessage);
|
|
645
|
+
globalExpect(actions.specificAction.render).toBe(mockRender);
|
|
646
|
+
globalExpect(actions["*"].render).toBeUndefined();
|
|
647
|
+
});
|
|
648
|
+
test("should not preserve render function when no matching action", () => {
|
|
649
|
+
const mockRender = () => "Unmatched Render";
|
|
650
|
+
const aguiMessage = {
|
|
651
|
+
id: "assistant-4",
|
|
652
|
+
role: "assistant",
|
|
653
|
+
content: "I'll execute an unmatched function",
|
|
654
|
+
toolCalls: [
|
|
655
|
+
{
|
|
656
|
+
id: "tool-call-4",
|
|
657
|
+
type: "function",
|
|
658
|
+
function: {
|
|
659
|
+
name: "unmatchedAction",
|
|
660
|
+
arguments: JSON.stringify({ param: "value" })
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
],
|
|
664
|
+
generativeUI: mockRender
|
|
665
|
+
};
|
|
666
|
+
const actions = {
|
|
667
|
+
otherAction: { name: "otherAction" }
|
|
668
|
+
};
|
|
669
|
+
const result = aguiToGQL(aguiMessage, actions);
|
|
670
|
+
globalExpect(result).toHaveLength(2);
|
|
671
|
+
globalExpect(result[0]).toBeInstanceOf(TextMessage);
|
|
672
|
+
globalExpect(result[1]).toBeInstanceOf(ActionExecutionMessage);
|
|
673
|
+
globalExpect(actions.otherAction.render).toBeUndefined();
|
|
674
|
+
});
|
|
675
|
+
test("should handle multiple tool calls with wild card action", () => {
|
|
676
|
+
const mockRender = () => "Wild Card Render";
|
|
677
|
+
const aguiMessage = {
|
|
678
|
+
id: "assistant-5",
|
|
679
|
+
role: "assistant",
|
|
680
|
+
content: "I'll execute multiple functions",
|
|
681
|
+
toolCalls: [
|
|
682
|
+
{
|
|
683
|
+
id: "tool-call-5",
|
|
684
|
+
type: "function",
|
|
685
|
+
function: {
|
|
686
|
+
name: "firstFunction",
|
|
687
|
+
arguments: JSON.stringify({ param: "value1" })
|
|
688
|
+
}
|
|
689
|
+
},
|
|
690
|
+
{
|
|
691
|
+
id: "tool-call-6",
|
|
692
|
+
type: "function",
|
|
693
|
+
function: {
|
|
694
|
+
name: "secondFunction",
|
|
695
|
+
arguments: JSON.stringify({ param: "value2" })
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
],
|
|
699
|
+
generativeUI: mockRender
|
|
700
|
+
};
|
|
701
|
+
const actions = {
|
|
702
|
+
"*": { name: "*" }
|
|
703
|
+
};
|
|
704
|
+
const result = aguiToGQL(aguiMessage, actions);
|
|
705
|
+
globalExpect(result).toHaveLength(3);
|
|
706
|
+
globalExpect(result[0]).toBeInstanceOf(TextMessage);
|
|
707
|
+
globalExpect(result[1]).toBeInstanceOf(ActionExecutionMessage);
|
|
708
|
+
globalExpect(result[2]).toBeInstanceOf(ActionExecutionMessage);
|
|
709
|
+
globalExpect(actions["*"].render).toBe(mockRender);
|
|
710
|
+
});
|
|
711
|
+
test("should handle mixed specific and wild card actions", () => {
|
|
712
|
+
const mockRender = () => "Mixed Render";
|
|
713
|
+
const aguiMessage = {
|
|
714
|
+
id: "assistant-6",
|
|
715
|
+
role: "assistant",
|
|
716
|
+
content: "I'll execute mixed functions",
|
|
717
|
+
toolCalls: [
|
|
718
|
+
{
|
|
719
|
+
id: "tool-call-7",
|
|
720
|
+
type: "function",
|
|
721
|
+
function: {
|
|
722
|
+
name: "specificAction",
|
|
723
|
+
arguments: JSON.stringify({ param: "value1" })
|
|
724
|
+
}
|
|
725
|
+
},
|
|
726
|
+
{
|
|
727
|
+
id: "tool-call-8",
|
|
728
|
+
type: "function",
|
|
729
|
+
function: {
|
|
730
|
+
name: "unknownAction",
|
|
731
|
+
arguments: JSON.stringify({ param: "value2" })
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
],
|
|
735
|
+
generativeUI: mockRender
|
|
736
|
+
};
|
|
737
|
+
const actions = {
|
|
738
|
+
specificAction: { name: "specificAction" },
|
|
739
|
+
"*": { name: "*" }
|
|
740
|
+
};
|
|
741
|
+
const result = aguiToGQL(aguiMessage, actions);
|
|
742
|
+
globalExpect(result).toHaveLength(3);
|
|
743
|
+
globalExpect(result[0]).toBeInstanceOf(TextMessage);
|
|
744
|
+
globalExpect(result[1]).toBeInstanceOf(ActionExecutionMessage);
|
|
745
|
+
globalExpect(result[2]).toBeInstanceOf(ActionExecutionMessage);
|
|
746
|
+
globalExpect(actions.specificAction.render).toBe(mockRender);
|
|
747
|
+
globalExpect(actions["*"].render).toBe(mockRender);
|
|
748
|
+
});
|
|
749
|
+
test("should handle no actions provided", () => {
|
|
750
|
+
const mockRender = () => "No Actions Render";
|
|
751
|
+
const aguiMessage = {
|
|
752
|
+
id: "assistant-7",
|
|
753
|
+
role: "assistant",
|
|
754
|
+
content: "I'll execute a function",
|
|
755
|
+
toolCalls: [
|
|
756
|
+
{
|
|
757
|
+
id: "tool-call-9",
|
|
758
|
+
type: "function",
|
|
759
|
+
function: {
|
|
760
|
+
name: "anyAction",
|
|
761
|
+
arguments: JSON.stringify({ param: "value" })
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
],
|
|
765
|
+
generativeUI: mockRender
|
|
766
|
+
};
|
|
767
|
+
const result = aguiToGQL(aguiMessage);
|
|
768
|
+
globalExpect(result).toHaveLength(2);
|
|
769
|
+
globalExpect(result[0]).toBeInstanceOf(TextMessage);
|
|
770
|
+
globalExpect(result[1]).toBeInstanceOf(ActionExecutionMessage);
|
|
771
|
+
});
|
|
772
|
+
test("should handle empty actions object", () => {
|
|
773
|
+
const mockRender = () => "Empty Actions Render";
|
|
774
|
+
const aguiMessage = {
|
|
775
|
+
id: "assistant-8",
|
|
776
|
+
role: "assistant",
|
|
777
|
+
content: "I'll execute a function",
|
|
778
|
+
toolCalls: [
|
|
779
|
+
{
|
|
780
|
+
id: "tool-call-10",
|
|
781
|
+
type: "function",
|
|
782
|
+
function: {
|
|
783
|
+
name: "anyAction",
|
|
784
|
+
arguments: JSON.stringify({ param: "value" })
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
],
|
|
788
|
+
generativeUI: mockRender
|
|
789
|
+
};
|
|
790
|
+
const actions = {};
|
|
791
|
+
const result = aguiToGQL(aguiMessage, actions);
|
|
792
|
+
globalExpect(result).toHaveLength(2);
|
|
793
|
+
globalExpect(result[0]).toBeInstanceOf(TextMessage);
|
|
794
|
+
globalExpect(result[1]).toBeInstanceOf(ActionExecutionMessage);
|
|
795
|
+
});
|
|
796
|
+
test("should handle actions with null render functions", () => {
|
|
797
|
+
const mockRender = () => "Null Render Test";
|
|
798
|
+
const aguiMessage = {
|
|
799
|
+
id: "assistant-9",
|
|
800
|
+
role: "assistant",
|
|
801
|
+
content: "I'll execute a function",
|
|
802
|
+
toolCalls: [
|
|
803
|
+
{
|
|
804
|
+
id: "tool-call-11",
|
|
805
|
+
type: "function",
|
|
806
|
+
function: {
|
|
807
|
+
name: "specificAction",
|
|
808
|
+
arguments: JSON.stringify({ param: "value" })
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
],
|
|
812
|
+
generativeUI: mockRender
|
|
813
|
+
};
|
|
814
|
+
const actions = {
|
|
815
|
+
specificAction: { name: "specificAction", render: null },
|
|
816
|
+
"*": { name: "*", render: null }
|
|
817
|
+
};
|
|
818
|
+
const result = aguiToGQL(aguiMessage, actions);
|
|
819
|
+
globalExpect(result).toHaveLength(2);
|
|
820
|
+
globalExpect(result[0]).toBeInstanceOf(TextMessage);
|
|
821
|
+
globalExpect(result[1]).toBeInstanceOf(ActionExecutionMessage);
|
|
822
|
+
globalExpect(actions.specificAction.render).toBe(mockRender);
|
|
823
|
+
});
|
|
824
|
+
test("should handle actions with undefined render functions", () => {
|
|
825
|
+
const mockRender = () => "Undefined Render Test";
|
|
826
|
+
const aguiMessage = {
|
|
827
|
+
id: "assistant-10",
|
|
828
|
+
role: "assistant",
|
|
829
|
+
content: "I'll execute a function",
|
|
830
|
+
toolCalls: [
|
|
831
|
+
{
|
|
832
|
+
id: "tool-call-12",
|
|
833
|
+
type: "function",
|
|
834
|
+
function: {
|
|
835
|
+
name: "wildcardAction",
|
|
836
|
+
arguments: JSON.stringify({ param: "value" })
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
],
|
|
840
|
+
generativeUI: mockRender
|
|
841
|
+
};
|
|
842
|
+
const actions = {
|
|
843
|
+
"*": { name: "*", render: void 0 }
|
|
844
|
+
};
|
|
845
|
+
const result = aguiToGQL(aguiMessage, actions);
|
|
846
|
+
globalExpect(result).toHaveLength(2);
|
|
847
|
+
globalExpect(result[0]).toBeInstanceOf(TextMessage);
|
|
848
|
+
globalExpect(result[1]).toBeInstanceOf(ActionExecutionMessage);
|
|
849
|
+
globalExpect(actions["*"].render).toBe(mockRender);
|
|
850
|
+
});
|
|
851
|
+
test("should handle tool calls with malformed arguments", () => {
|
|
852
|
+
const mockRender = () => "Malformed Args Test";
|
|
853
|
+
const aguiMessage = {
|
|
854
|
+
id: "assistant-11",
|
|
855
|
+
role: "assistant",
|
|
856
|
+
content: "I'll execute a function",
|
|
857
|
+
toolCalls: [
|
|
858
|
+
{
|
|
859
|
+
id: "tool-call-13",
|
|
860
|
+
type: "function",
|
|
861
|
+
function: {
|
|
862
|
+
name: "wildcardAction",
|
|
863
|
+
arguments: "invalid json {"
|
|
864
|
+
// Malformed JSON
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
],
|
|
868
|
+
generativeUI: mockRender
|
|
869
|
+
};
|
|
870
|
+
const actions = {
|
|
871
|
+
"*": { name: "*" }
|
|
872
|
+
};
|
|
873
|
+
const result = aguiToGQL(aguiMessage, actions);
|
|
874
|
+
globalExpect(result).toHaveLength(2);
|
|
875
|
+
globalExpect(result[0]).toBeInstanceOf(TextMessage);
|
|
876
|
+
globalExpect(result[1]).toBeInstanceOf(ActionExecutionMessage);
|
|
877
|
+
globalExpect(actions["*"].render).toBe(mockRender);
|
|
878
|
+
});
|
|
879
|
+
test("should handle tool calls with empty arguments string", () => {
|
|
880
|
+
const mockRender = () => "Empty Args Test";
|
|
881
|
+
const aguiMessage = {
|
|
882
|
+
id: "assistant-12",
|
|
883
|
+
role: "assistant",
|
|
884
|
+
content: "I'll execute a function",
|
|
885
|
+
toolCalls: [
|
|
886
|
+
{
|
|
887
|
+
id: "tool-call-14",
|
|
888
|
+
type: "function",
|
|
889
|
+
function: {
|
|
890
|
+
name: "wildcardAction",
|
|
891
|
+
arguments: ""
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
],
|
|
895
|
+
generativeUI: mockRender
|
|
896
|
+
};
|
|
897
|
+
const actions = {
|
|
898
|
+
"*": { name: "*" }
|
|
899
|
+
};
|
|
900
|
+
const result = aguiToGQL(aguiMessage, actions);
|
|
901
|
+
globalExpect(result).toHaveLength(2);
|
|
902
|
+
globalExpect(result[0]).toBeInstanceOf(TextMessage);
|
|
903
|
+
globalExpect(result[1]).toBeInstanceOf(ActionExecutionMessage);
|
|
904
|
+
globalExpect(actions["*"].render).toBe(mockRender);
|
|
905
|
+
});
|
|
906
|
+
test("should handle multiple wild card actions in same object", () => {
|
|
907
|
+
const mockRender = () => "Multiple Wildcards Test";
|
|
908
|
+
const aguiMessage = {
|
|
909
|
+
id: "assistant-13",
|
|
910
|
+
role: "assistant",
|
|
911
|
+
content: "I'll execute a function",
|
|
912
|
+
toolCalls: [
|
|
913
|
+
{
|
|
914
|
+
id: "tool-call-15",
|
|
915
|
+
type: "function",
|
|
916
|
+
function: {
|
|
917
|
+
name: "unknownAction",
|
|
918
|
+
arguments: JSON.stringify({ param: "value" })
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
],
|
|
922
|
+
generativeUI: mockRender
|
|
923
|
+
};
|
|
924
|
+
const actions = {
|
|
925
|
+
wildcard1: { name: "*" },
|
|
926
|
+
wildcard2: { name: "*" }
|
|
927
|
+
};
|
|
928
|
+
const result = aguiToGQL(aguiMessage, actions);
|
|
929
|
+
globalExpect(result).toHaveLength(2);
|
|
930
|
+
globalExpect(result[0]).toBeInstanceOf(TextMessage);
|
|
931
|
+
globalExpect(result[1]).toBeInstanceOf(ActionExecutionMessage);
|
|
932
|
+
globalExpect(actions.wildcard1.render).toBe(mockRender);
|
|
933
|
+
globalExpect(actions.wildcard2.render).toBeUndefined();
|
|
934
|
+
});
|
|
935
|
+
test("should handle tool calls with object arguments (backward compatibility)", () => {
|
|
936
|
+
const mockRender = () => "Object Args Test";
|
|
937
|
+
const aguiMessage = {
|
|
938
|
+
id: "assistant-14",
|
|
939
|
+
role: "assistant",
|
|
940
|
+
content: "I'll execute a function",
|
|
941
|
+
toolCalls: [
|
|
942
|
+
{
|
|
943
|
+
id: "tool-call-16",
|
|
944
|
+
type: "function",
|
|
945
|
+
function: {
|
|
946
|
+
name: "objectArgsAction",
|
|
947
|
+
arguments: { param: "value" }
|
|
948
|
+
// Object instead of string
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
],
|
|
952
|
+
generativeUI: mockRender
|
|
953
|
+
};
|
|
954
|
+
const actions = {
|
|
955
|
+
"*": { name: "*" }
|
|
956
|
+
};
|
|
957
|
+
const result = aguiToGQL(aguiMessage, actions);
|
|
958
|
+
globalExpect(result).toHaveLength(2);
|
|
959
|
+
globalExpect(result[0]).toBeInstanceOf(TextMessage);
|
|
960
|
+
globalExpect(result[1]).toBeInstanceOf(ActionExecutionMessage);
|
|
961
|
+
globalExpect(result[1].arguments).toEqual({ param: "value" });
|
|
962
|
+
globalExpect(actions["*"].render).toBe(mockRender);
|
|
963
|
+
});
|
|
964
|
+
test("should handle tool calls with null/undefined arguments", () => {
|
|
965
|
+
const mockRender = () => "Null Args Test";
|
|
966
|
+
const aguiMessage = {
|
|
967
|
+
id: "assistant-15",
|
|
968
|
+
role: "assistant",
|
|
969
|
+
content: "I'll execute a function",
|
|
970
|
+
toolCalls: [
|
|
971
|
+
{
|
|
972
|
+
id: "tool-call-17",
|
|
973
|
+
type: "function",
|
|
974
|
+
function: {
|
|
975
|
+
name: "nullArgsAction",
|
|
976
|
+
arguments: null
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
],
|
|
980
|
+
generativeUI: mockRender
|
|
981
|
+
};
|
|
982
|
+
const actions = {
|
|
983
|
+
"*": { name: "*" }
|
|
984
|
+
};
|
|
985
|
+
const result = aguiToGQL(aguiMessage, actions);
|
|
986
|
+
globalExpect(result).toHaveLength(2);
|
|
987
|
+
globalExpect(result[0]).toBeInstanceOf(TextMessage);
|
|
988
|
+
globalExpect(result[1]).toBeInstanceOf(ActionExecutionMessage);
|
|
989
|
+
globalExpect(result[1].arguments).toEqual({});
|
|
990
|
+
globalExpect(actions["*"].render).toBe(mockRender);
|
|
991
|
+
});
|
|
992
|
+
test("should handle tool result messages with object content", () => {
|
|
993
|
+
const aguiMessage = {
|
|
994
|
+
id: "tool-result-1",
|
|
995
|
+
role: "tool",
|
|
996
|
+
content: { status: "success", data: { value: 42 } },
|
|
997
|
+
toolCallId: "tool-call-1",
|
|
998
|
+
toolName: "testAction"
|
|
999
|
+
};
|
|
1000
|
+
const toolCallNames = { "tool-call-1": "testAction" };
|
|
1001
|
+
const result = aguiToGQL(aguiMessage);
|
|
1002
|
+
globalExpect(result).toHaveLength(1);
|
|
1003
|
+
globalExpect(result[0]).toBeInstanceOf(ResultMessage);
|
|
1004
|
+
globalExpect(result[0].result).toBe('{"status":"success","data":{"value":42}}');
|
|
1005
|
+
globalExpect(result[0].actionExecutionId).toBe("tool-call-1");
|
|
1006
|
+
globalExpect(result[0].actionName).toBe("testAction");
|
|
1007
|
+
});
|
|
1008
|
+
test("should handle tool result messages with non-string content types", () => {
|
|
1009
|
+
const aguiMessage = {
|
|
1010
|
+
id: "tool-result-2",
|
|
1011
|
+
role: "tool",
|
|
1012
|
+
content: 42,
|
|
1013
|
+
toolCallId: "tool-call-2",
|
|
1014
|
+
toolName: "numberAction"
|
|
1015
|
+
};
|
|
1016
|
+
const result = aguiToGQL(aguiMessage);
|
|
1017
|
+
globalExpect(result).toHaveLength(1);
|
|
1018
|
+
globalExpect(result[0]).toBeInstanceOf(ResultMessage);
|
|
1019
|
+
globalExpect(result[0].result).toBe("42");
|
|
1020
|
+
globalExpect(result[0].actionExecutionId).toBe("tool-call-2");
|
|
1021
|
+
globalExpect(result[0].actionName).toBe("numberAction");
|
|
1022
|
+
});
|
|
1023
|
+
test("should handle tool result messages with circular reference content", () => {
|
|
1024
|
+
const circularObj = { status: "success" };
|
|
1025
|
+
circularObj.self = circularObj;
|
|
1026
|
+
const aguiMessage = {
|
|
1027
|
+
id: "tool-result-3",
|
|
1028
|
+
role: "tool",
|
|
1029
|
+
content: circularObj,
|
|
1030
|
+
toolCallId: "tool-call-3",
|
|
1031
|
+
toolName: "circularAction"
|
|
1032
|
+
};
|
|
1033
|
+
const result = aguiToGQL(aguiMessage);
|
|
1034
|
+
globalExpect(result).toHaveLength(1);
|
|
1035
|
+
globalExpect(result[0]).toBeInstanceOf(ResultMessage);
|
|
1036
|
+
globalExpect(result[0].result).toBe("[object Object]");
|
|
1037
|
+
globalExpect(result[0].actionExecutionId).toBe("tool-call-3");
|
|
1038
|
+
globalExpect(result[0].actionName).toBe("circularAction");
|
|
1039
|
+
});
|
|
1040
|
+
test("should handle tool result messages with boolean content", () => {
|
|
1041
|
+
const aguiMessage = {
|
|
1042
|
+
id: "tool-result-4",
|
|
1043
|
+
role: "tool",
|
|
1044
|
+
content: true,
|
|
1045
|
+
toolCallId: "tool-call-4",
|
|
1046
|
+
toolName: "booleanAction"
|
|
1047
|
+
};
|
|
1048
|
+
const result = aguiToGQL(aguiMessage);
|
|
1049
|
+
globalExpect(result).toHaveLength(1);
|
|
1050
|
+
globalExpect(result[0]).toBeInstanceOf(ResultMessage);
|
|
1051
|
+
globalExpect(result[0].result).toBe("true");
|
|
1052
|
+
globalExpect(result[0].actionExecutionId).toBe("tool-call-4");
|
|
1053
|
+
globalExpect(result[0].actionName).toBe("booleanAction");
|
|
1054
|
+
});
|
|
1055
|
+
});
|
|
564
1056
|
});
|
|
565
1057
|
//# sourceMappingURL=agui-to-gql.test.mjs.map
|