@copilotkit/runtime-client-gql 1.10.0 → 1.10.1-next.0

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.
Files changed (48) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/{chunk-YNQMTL2P.mjs → chunk-7OSRQ2O3.mjs} +9 -3
  3. package/dist/chunk-7OSRQ2O3.mjs.map +1 -0
  4. package/dist/{chunk-PAQ6AHHC.mjs → chunk-AES3X7TL.mjs} +2 -2
  5. package/dist/{chunk-PAQ6AHHC.mjs.map → chunk-AES3X7TL.mjs.map} +1 -1
  6. package/dist/{chunk-MTD2RJDJ.mjs → chunk-IGXWE4TX.mjs} +32 -29
  7. package/dist/chunk-IGXWE4TX.mjs.map +1 -0
  8. package/dist/client/CopilotRuntimeClient.js +1 -1
  9. package/dist/client/CopilotRuntimeClient.js.map +1 -1
  10. package/dist/client/CopilotRuntimeClient.mjs +1 -1
  11. package/dist/client/index.js +1 -1
  12. package/dist/client/index.js.map +1 -1
  13. package/dist/client/index.mjs +1 -1
  14. package/dist/index.d.ts +1 -1
  15. package/dist/index.js +41 -31
  16. package/dist/index.js.map +1 -1
  17. package/dist/index.mjs +5 -3
  18. package/dist/message-conversion/agui-to-gql.js +8 -2
  19. package/dist/message-conversion/agui-to-gql.js.map +1 -1
  20. package/dist/message-conversion/agui-to-gql.mjs +2 -2
  21. package/dist/message-conversion/agui-to-gql.test.js +380 -2
  22. package/dist/message-conversion/agui-to-gql.test.js.map +1 -1
  23. package/dist/message-conversion/agui-to-gql.test.mjs +374 -2
  24. package/dist/message-conversion/agui-to-gql.test.mjs.map +1 -1
  25. package/dist/message-conversion/gql-to-agui.d.ts +3 -2
  26. package/dist/message-conversion/gql-to-agui.js +32 -28
  27. package/dist/message-conversion/gql-to-agui.js.map +1 -1
  28. package/dist/message-conversion/gql-to-agui.mjs +4 -2
  29. package/dist/message-conversion/gql-to-agui.test.js +496 -28
  30. package/dist/message-conversion/gql-to-agui.test.js.map +1 -1
  31. package/dist/message-conversion/gql-to-agui.test.mjs +469 -2
  32. package/dist/message-conversion/gql-to-agui.test.mjs.map +1 -1
  33. package/dist/message-conversion/index.d.ts +1 -1
  34. package/dist/message-conversion/index.js +40 -30
  35. package/dist/message-conversion/index.js.map +1 -1
  36. package/dist/message-conversion/index.mjs +5 -3
  37. package/dist/message-conversion/roundtrip-conversion.test.js +132 -30
  38. package/dist/message-conversion/roundtrip-conversion.test.js.map +1 -1
  39. package/dist/message-conversion/roundtrip-conversion.test.mjs +97 -3
  40. package/dist/message-conversion/roundtrip-conversion.test.mjs.map +1 -1
  41. package/package.json +3 -3
  42. package/src/message-conversion/agui-to-gql.test.ts +426 -0
  43. package/src/message-conversion/agui-to-gql.ts +11 -2
  44. package/src/message-conversion/gql-to-agui.test.ts +524 -0
  45. package/src/message-conversion/gql-to-agui.ts +45 -36
  46. package/src/message-conversion/roundtrip-conversion.test.ts +122 -0
  47. package/dist/chunk-MTD2RJDJ.mjs.map +0 -1
  48. package/dist/chunk-YNQMTL2P.mjs.map +0 -1
@@ -1,9 +1,10 @@
1
1
  import {
2
+ gqlActionExecutionMessageToAGUIMessage,
2
3
  gqlImageMessageToAGUIMessage,
3
4
  gqlResultMessageToAGUIMessage,
4
5
  gqlTextMessageToAGUIMessage,
5
6
  gqlToAGUI
6
- } from "../chunk-MTD2RJDJ.mjs";
7
+ } from "../chunk-IGXWE4TX.mjs";
7
8
  import {
8
9
  describe,
9
10
  globalExpect,
@@ -11,7 +12,7 @@ import {
11
12
  vi
12
13
  } from "../chunk-2R7M2FWR.mjs";
13
14
  import "../chunk-7ECCT6PK.mjs";
14
- import "../chunk-PAQ6AHHC.mjs";
15
+ import "../chunk-AES3X7TL.mjs";
15
16
  import "../chunk-X2UAP3QY.mjs";
16
17
  import "../chunk-HEODM5TW.mjs";
17
18
  import "../chunk-4KTMZMM2.mjs";
@@ -733,5 +734,471 @@ describe("message-conversion", () => {
733
734
  });
734
735
  });
735
736
  });
737
+ describe("Wild Card Actions", () => {
738
+ test("should handle action execution with specific action", () => {
739
+ const actions = {
740
+ testAction: {
741
+ name: "testAction",
742
+ render: vi.fn((props) => `Rendered: ${props.args.test}`)
743
+ }
744
+ };
745
+ const actionExecMsg = new ActionExecutionMessage({
746
+ id: "action-1",
747
+ name: "testAction",
748
+ arguments: { test: "value" },
749
+ parentMessageId: "parent-1"
750
+ });
751
+ const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg, actions);
752
+ globalExpect(result).toMatchObject({
753
+ id: "action-1",
754
+ role: "assistant",
755
+ content: "",
756
+ toolCalls: [
757
+ {
758
+ id: "action-1",
759
+ function: {
760
+ name: "testAction",
761
+ arguments: '{"test":"value"}'
762
+ },
763
+ type: "function"
764
+ }
765
+ ],
766
+ generativeUI: globalExpect.any(Function),
767
+ name: "testAction"
768
+ });
769
+ });
770
+ test("should handle action execution with wild card action", () => {
771
+ const actions = {
772
+ "*": {
773
+ name: "*",
774
+ render: vi.fn((props) => `Wildcard rendered: ${props.args.test}`)
775
+ }
776
+ };
777
+ const actionExecMsg = new ActionExecutionMessage({
778
+ id: "action-2",
779
+ name: "unknownAction",
780
+ arguments: { test: "wildcard-value" },
781
+ parentMessageId: "parent-2"
782
+ });
783
+ const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg, actions);
784
+ globalExpect(result).toMatchObject({
785
+ id: "action-2",
786
+ role: "assistant",
787
+ content: "",
788
+ toolCalls: [
789
+ {
790
+ id: "action-2",
791
+ function: {
792
+ name: "unknownAction",
793
+ arguments: '{"test":"wildcard-value"}'
794
+ },
795
+ type: "function"
796
+ }
797
+ ],
798
+ generativeUI: globalExpect.any(Function),
799
+ name: "unknownAction"
800
+ });
801
+ });
802
+ test("should prioritize specific action over wild card action", () => {
803
+ const actions = {
804
+ specificAction: {
805
+ name: "specificAction",
806
+ render: vi.fn((props) => "Specific action rendered")
807
+ },
808
+ "*": {
809
+ name: "*",
810
+ render: vi.fn((props) => "Wildcard action rendered")
811
+ }
812
+ };
813
+ const actionExecMsg = new ActionExecutionMessage({
814
+ id: "action-3",
815
+ name: "specificAction",
816
+ arguments: { test: "value" },
817
+ parentMessageId: "parent-3"
818
+ });
819
+ const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg, actions);
820
+ globalExpect(result).toMatchObject({
821
+ id: "action-3",
822
+ role: "assistant",
823
+ content: "",
824
+ toolCalls: [
825
+ {
826
+ id: "action-3",
827
+ function: {
828
+ name: "specificAction",
829
+ arguments: '{"test":"value"}'
830
+ },
831
+ type: "function"
832
+ }
833
+ ],
834
+ generativeUI: globalExpect.any(Function),
835
+ name: "specificAction"
836
+ });
837
+ });
838
+ test("should handle action execution without any matching actions", () => {
839
+ const actions = {
840
+ otherAction: {
841
+ name: "otherAction",
842
+ render: vi.fn()
843
+ }
844
+ };
845
+ const actionExecMsg = new ActionExecutionMessage({
846
+ id: "action-4",
847
+ name: "unmatchedAction",
848
+ arguments: { test: "value" },
849
+ parentMessageId: "parent-4"
850
+ });
851
+ const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg, actions);
852
+ globalExpect(result).toMatchObject({
853
+ id: "action-4",
854
+ role: "assistant",
855
+ toolCalls: [
856
+ {
857
+ id: "action-4",
858
+ function: {
859
+ name: "unmatchedAction",
860
+ arguments: '{"test":"value"}'
861
+ },
862
+ type: "function"
863
+ }
864
+ ],
865
+ name: "unmatchedAction"
866
+ });
867
+ globalExpect(result).not.toHaveProperty("generativeUI");
868
+ });
869
+ test("should handle action execution with no actions provided", () => {
870
+ const actionExecMsg = new ActionExecutionMessage({
871
+ id: "action-5",
872
+ name: "anyAction",
873
+ arguments: { test: "value" },
874
+ parentMessageId: "parent-5"
875
+ });
876
+ const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg);
877
+ globalExpect(result).toMatchObject({
878
+ id: "action-5",
879
+ role: "assistant",
880
+ toolCalls: [
881
+ {
882
+ id: "action-5",
883
+ function: {
884
+ name: "anyAction",
885
+ arguments: '{"test":"value"}'
886
+ },
887
+ type: "function"
888
+ }
889
+ ],
890
+ name: "anyAction"
891
+ });
892
+ globalExpect(result).not.toHaveProperty("generativeUI");
893
+ });
894
+ test("should handle action execution with completed result", () => {
895
+ const actions = {
896
+ "*": {
897
+ name: "*",
898
+ render: vi.fn((props) => `Result: ${props.result}`)
899
+ }
900
+ };
901
+ const actionExecMsg = new ActionExecutionMessage({
902
+ id: "action-6",
903
+ name: "testAction",
904
+ arguments: { test: "value" },
905
+ parentMessageId: "parent-6"
906
+ });
907
+ const actionResults = /* @__PURE__ */ new Map([["action-6", "completed result"]]);
908
+ const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg, actions, actionResults);
909
+ globalExpect(result).toMatchObject({
910
+ id: "action-6",
911
+ role: "assistant",
912
+ content: "",
913
+ toolCalls: [
914
+ {
915
+ id: "action-6",
916
+ function: {
917
+ name: "testAction",
918
+ arguments: '{"test":"value"}'
919
+ },
920
+ type: "function"
921
+ }
922
+ ],
923
+ generativeUI: globalExpect.any(Function),
924
+ name: "testAction"
925
+ });
926
+ });
927
+ test("should handle action execution with executing status", () => {
928
+ const actions = {
929
+ "*": {
930
+ name: "*",
931
+ render: vi.fn((props) => `Status: ${props.status}`)
932
+ }
933
+ };
934
+ const actionExecMsg = new ActionExecutionMessage({
935
+ id: "action-7",
936
+ name: "testAction",
937
+ arguments: { test: "value" },
938
+ parentMessageId: "parent-7",
939
+ status: { code: "Success" /* Success */ }
940
+ });
941
+ const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg, actions);
942
+ globalExpect(result).toMatchObject({
943
+ id: "action-7",
944
+ role: "assistant",
945
+ content: "",
946
+ toolCalls: [
947
+ {
948
+ id: "action-7",
949
+ function: {
950
+ name: "testAction",
951
+ arguments: '{"test":"value"}'
952
+ },
953
+ type: "function"
954
+ }
955
+ ],
956
+ generativeUI: globalExpect.any(Function),
957
+ name: "testAction"
958
+ });
959
+ });
960
+ test("should handle action execution with pending status", () => {
961
+ const actions = {
962
+ "*": {
963
+ name: "*",
964
+ render: vi.fn((props) => `Status: ${props.status}`)
965
+ }
966
+ };
967
+ const actionExecMsg = new ActionExecutionMessage({
968
+ id: "action-8",
969
+ name: "testAction",
970
+ arguments: { test: "value" },
971
+ parentMessageId: "parent-8",
972
+ status: { code: "Pending" /* Pending */ }
973
+ });
974
+ const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg, actions);
975
+ globalExpect(result).toMatchObject({
976
+ id: "action-8",
977
+ role: "assistant",
978
+ content: "",
979
+ toolCalls: [
980
+ {
981
+ id: "action-8",
982
+ function: {
983
+ name: "testAction",
984
+ arguments: '{"test":"value"}'
985
+ },
986
+ type: "function"
987
+ }
988
+ ],
989
+ generativeUI: globalExpect.any(Function),
990
+ name: "testAction"
991
+ });
992
+ });
993
+ test("should handle action execution with failed status", () => {
994
+ const actions = {
995
+ "*": {
996
+ name: "*",
997
+ render: vi.fn((props) => `Status: ${props.status}`)
998
+ }
999
+ };
1000
+ const actionExecMsg = new ActionExecutionMessage({
1001
+ id: "action-9",
1002
+ name: "testAction",
1003
+ arguments: { test: "value" },
1004
+ parentMessageId: "parent-9",
1005
+ status: { code: "Failed" /* Failed */ }
1006
+ });
1007
+ const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg, actions);
1008
+ globalExpect(result).toMatchObject({
1009
+ id: "action-9",
1010
+ role: "assistant",
1011
+ content: "",
1012
+ toolCalls: [
1013
+ {
1014
+ id: "action-9",
1015
+ function: {
1016
+ name: "testAction",
1017
+ arguments: '{"test":"value"}'
1018
+ },
1019
+ type: "function"
1020
+ }
1021
+ ],
1022
+ generativeUI: globalExpect.any(Function),
1023
+ name: "testAction"
1024
+ });
1025
+ });
1026
+ test("should handle action execution with undefined status", () => {
1027
+ const actions = {
1028
+ "*": {
1029
+ name: "*",
1030
+ render: vi.fn((props) => `Status: ${props.status}`)
1031
+ }
1032
+ };
1033
+ const actionExecMsg = new ActionExecutionMessage({
1034
+ id: "action-10",
1035
+ name: "testAction",
1036
+ arguments: { test: "value" },
1037
+ parentMessageId: "parent-10"
1038
+ // No status field
1039
+ });
1040
+ const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg, actions);
1041
+ globalExpect(result).toMatchObject({
1042
+ id: "action-10",
1043
+ role: "assistant",
1044
+ content: "",
1045
+ toolCalls: [
1046
+ {
1047
+ id: "action-10",
1048
+ function: {
1049
+ name: "testAction",
1050
+ arguments: '{"test":"value"}'
1051
+ },
1052
+ type: "function"
1053
+ }
1054
+ ],
1055
+ generativeUI: globalExpect.any(Function),
1056
+ name: "testAction"
1057
+ });
1058
+ });
1059
+ test("should handle action execution with empty arguments", () => {
1060
+ const actions = {
1061
+ "*": {
1062
+ name: "*",
1063
+ render: vi.fn((props) => `Args: ${JSON.stringify(props.args)}`)
1064
+ }
1065
+ };
1066
+ const actionExecMsg = new ActionExecutionMessage({
1067
+ id: "action-11",
1068
+ name: "testAction",
1069
+ arguments: {},
1070
+ parentMessageId: "parent-11"
1071
+ });
1072
+ const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg, actions);
1073
+ globalExpect(result).toMatchObject({
1074
+ id: "action-11",
1075
+ role: "assistant",
1076
+ content: "",
1077
+ toolCalls: [
1078
+ {
1079
+ id: "action-11",
1080
+ function: {
1081
+ name: "testAction",
1082
+ arguments: "{}"
1083
+ },
1084
+ type: "function"
1085
+ }
1086
+ ],
1087
+ generativeUI: globalExpect.any(Function),
1088
+ name: "testAction"
1089
+ });
1090
+ });
1091
+ test("should handle action execution with null arguments", () => {
1092
+ const actions = {
1093
+ "*": {
1094
+ name: "*",
1095
+ render: vi.fn((props) => `Args: ${JSON.stringify(props.args)}`)
1096
+ }
1097
+ };
1098
+ const actionExecMsg = new ActionExecutionMessage({
1099
+ id: "action-12",
1100
+ name: "testAction",
1101
+ arguments: null,
1102
+ parentMessageId: "parent-12"
1103
+ });
1104
+ const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg, actions);
1105
+ globalExpect(result).toMatchObject({
1106
+ id: "action-12",
1107
+ role: "assistant",
1108
+ content: "",
1109
+ toolCalls: [
1110
+ {
1111
+ id: "action-12",
1112
+ function: {
1113
+ name: "testAction",
1114
+ arguments: "null"
1115
+ },
1116
+ type: "function"
1117
+ }
1118
+ ],
1119
+ generativeUI: globalExpect.any(Function),
1120
+ name: "testAction"
1121
+ });
1122
+ });
1123
+ test("should handle action execution with complex nested arguments", () => {
1124
+ const actions = {
1125
+ "*": {
1126
+ name: "*",
1127
+ render: vi.fn((props) => `Complex: ${JSON.stringify(props.args)}`)
1128
+ }
1129
+ };
1130
+ const complexArgs = {
1131
+ nested: {
1132
+ array: [1, 2, 3],
1133
+ object: { key: "value" },
1134
+ nullValue: null,
1135
+ undefinedValue: void 0
1136
+ },
1137
+ string: "test",
1138
+ number: 42,
1139
+ boolean: true
1140
+ };
1141
+ const actionExecMsg = new ActionExecutionMessage({
1142
+ id: "action-13",
1143
+ name: "testAction",
1144
+ arguments: complexArgs,
1145
+ parentMessageId: "parent-13"
1146
+ });
1147
+ const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg, actions);
1148
+ globalExpect(result).toMatchObject({
1149
+ id: "action-13",
1150
+ role: "assistant",
1151
+ content: "",
1152
+ toolCalls: [
1153
+ {
1154
+ id: "action-13",
1155
+ function: {
1156
+ name: "testAction",
1157
+ arguments: JSON.stringify(complexArgs)
1158
+ },
1159
+ type: "function"
1160
+ }
1161
+ ],
1162
+ generativeUI: globalExpect.any(Function),
1163
+ name: "testAction"
1164
+ });
1165
+ });
1166
+ test("should handle multiple wild card actions (should use first one)", () => {
1167
+ const actions = {
1168
+ wildcard1: {
1169
+ name: "*",
1170
+ render: vi.fn((props) => "First wildcard")
1171
+ },
1172
+ wildcard2: {
1173
+ name: "*",
1174
+ render: vi.fn((props) => "Second wildcard")
1175
+ }
1176
+ };
1177
+ const actionExecMsg = new ActionExecutionMessage({
1178
+ id: "action-14",
1179
+ name: "unknownAction",
1180
+ arguments: { test: "value" },
1181
+ parentMessageId: "parent-14"
1182
+ });
1183
+ const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg, actions);
1184
+ globalExpect(result).toMatchObject({
1185
+ id: "action-14",
1186
+ role: "assistant",
1187
+ content: "",
1188
+ toolCalls: [
1189
+ {
1190
+ id: "action-14",
1191
+ function: {
1192
+ name: "unknownAction",
1193
+ arguments: '{"test":"value"}'
1194
+ },
1195
+ type: "function"
1196
+ }
1197
+ ],
1198
+ generativeUI: globalExpect.any(Function),
1199
+ name: "unknownAction"
1200
+ });
1201
+ });
1202
+ });
736
1203
  });
737
1204
  //# sourceMappingURL=gql-to-agui.test.mjs.map