@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.
Files changed (48) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/{chunk-PAQ6AHHC.mjs → chunk-5V6B3OXS.mjs} +2 -2
  3. package/dist/{chunk-PAQ6AHHC.mjs.map → chunk-5V6B3OXS.mjs.map} +1 -1
  4. package/dist/{chunk-YNQMTL2P.mjs → chunk-SCACOKQX.mjs} +38 -8
  5. package/dist/chunk-SCACOKQX.mjs.map +1 -0
  6. package/dist/{chunk-MTD2RJDJ.mjs → chunk-ZYA32QXZ.mjs} +44 -29
  7. package/dist/chunk-ZYA32QXZ.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 +82 -36
  16. package/dist/index.js.map +1 -1
  17. package/dist/index.mjs +5 -3
  18. package/dist/message-conversion/agui-to-gql.js +37 -7
  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 +529 -7
  22. package/dist/message-conversion/agui-to-gql.test.js.map +1 -1
  23. package/dist/message-conversion/agui-to-gql.test.mjs +494 -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 +44 -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 +622 -28
  30. package/dist/message-conversion/gql-to-agui.test.js.map +1 -1
  31. package/dist/message-conversion/gql-to-agui.test.mjs +583 -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 +81 -35
  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 +250 -35
  38. package/dist/message-conversion/roundtrip-conversion.test.js.map +1 -1
  39. package/dist/message-conversion/roundtrip-conversion.test.mjs +174 -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 +566 -0
  43. package/src/message-conversion/agui-to-gql.ts +56 -9
  44. package/src/message-conversion/gql-to-agui.test.ts +663 -0
  45. package/src/message-conversion/gql-to-agui.ts +62 -35
  46. package/src/message-conversion/roundtrip-conversion.test.ts +228 -0
  47. package/dist/chunk-MTD2RJDJ.mjs.map +0 -1
  48. package/dist/chunk-YNQMTL2P.mjs.map +0 -1
@@ -6,7 +6,9 @@ import {
6
6
  gqlTextMessageToAGUIMessage,
7
7
  gqlResultMessageToAGUIMessage,
8
8
  gqlImageMessageToAGUIMessage,
9
+ gqlActionExecutionMessageToAGUIMessage,
9
10
  } from "./gql-to-agui";
11
+ import { AIMessage } from "@copilotkit/shared";
10
12
 
11
13
  describe("message-conversion", () => {
12
14
  describe("gqlTextMessageToAGUIMessage", () => {
@@ -841,4 +843,665 @@ describe("message-conversion", () => {
841
843
  });
842
844
  });
843
845
  });
846
+
847
+ describe("Wild Card Actions", () => {
848
+ test("should handle action execution with specific action", () => {
849
+ const actions = {
850
+ testAction: {
851
+ name: "testAction",
852
+ render: vi.fn((props) => `Rendered: ${props.args.test}`),
853
+ },
854
+ };
855
+
856
+ const actionExecMsg = new gql.ActionExecutionMessage({
857
+ id: "action-1",
858
+ name: "testAction",
859
+ arguments: { test: "value" },
860
+ parentMessageId: "parent-1",
861
+ });
862
+
863
+ const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg, actions);
864
+
865
+ expect(result).toMatchObject({
866
+ id: "action-1",
867
+ role: "assistant",
868
+ content: "",
869
+ toolCalls: [
870
+ {
871
+ id: "action-1",
872
+ function: {
873
+ name: "testAction",
874
+ arguments: '{"test":"value"}',
875
+ },
876
+ type: "function",
877
+ },
878
+ ],
879
+ generativeUI: expect.any(Function),
880
+ name: "testAction",
881
+ });
882
+ });
883
+
884
+ test("should handle action execution with wild card action", () => {
885
+ const actions = {
886
+ "*": {
887
+ name: "*",
888
+ render: vi.fn((props) => `Wildcard rendered: ${props.args.test}`),
889
+ },
890
+ };
891
+
892
+ const actionExecMsg = new gql.ActionExecutionMessage({
893
+ id: "action-2",
894
+ name: "unknownAction",
895
+ arguments: { test: "wildcard-value" },
896
+ parentMessageId: "parent-2",
897
+ });
898
+
899
+ const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg, actions);
900
+
901
+ expect(result).toMatchObject({
902
+ id: "action-2",
903
+ role: "assistant",
904
+ content: "",
905
+ toolCalls: [
906
+ {
907
+ id: "action-2",
908
+ function: {
909
+ name: "unknownAction",
910
+ arguments: '{"test":"wildcard-value"}',
911
+ },
912
+ type: "function",
913
+ },
914
+ ],
915
+ generativeUI: expect.any(Function),
916
+ name: "unknownAction",
917
+ });
918
+ });
919
+
920
+ test("should prioritize specific action over wild card action", () => {
921
+ const actions = {
922
+ specificAction: {
923
+ name: "specificAction",
924
+ render: vi.fn((props) => "Specific action rendered"),
925
+ },
926
+ "*": {
927
+ name: "*",
928
+ render: vi.fn((props) => "Wildcard action rendered"),
929
+ },
930
+ };
931
+
932
+ const actionExecMsg = new gql.ActionExecutionMessage({
933
+ id: "action-3",
934
+ name: "specificAction",
935
+ arguments: { test: "value" },
936
+ parentMessageId: "parent-3",
937
+ });
938
+
939
+ const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg, actions);
940
+
941
+ expect(result).toMatchObject({
942
+ id: "action-3",
943
+ role: "assistant",
944
+ content: "",
945
+ toolCalls: [
946
+ {
947
+ id: "action-3",
948
+ function: {
949
+ name: "specificAction",
950
+ arguments: '{"test":"value"}',
951
+ },
952
+ type: "function",
953
+ },
954
+ ],
955
+ generativeUI: expect.any(Function),
956
+ name: "specificAction",
957
+ });
958
+ });
959
+
960
+ test("should handle action execution without any matching actions", () => {
961
+ const actions = {
962
+ otherAction: {
963
+ name: "otherAction",
964
+ render: vi.fn(),
965
+ },
966
+ };
967
+
968
+ const actionExecMsg = new gql.ActionExecutionMessage({
969
+ id: "action-4",
970
+ name: "unmatchedAction",
971
+ arguments: { test: "value" },
972
+ parentMessageId: "parent-4",
973
+ });
974
+
975
+ const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg, actions);
976
+
977
+ expect(result).toMatchObject({
978
+ id: "action-4",
979
+ role: "assistant",
980
+ toolCalls: [
981
+ {
982
+ id: "action-4",
983
+ function: {
984
+ name: "unmatchedAction",
985
+ arguments: '{"test":"value"}',
986
+ },
987
+ type: "function",
988
+ },
989
+ ],
990
+ name: "unmatchedAction",
991
+ });
992
+ expect(result).not.toHaveProperty("generativeUI");
993
+ });
994
+
995
+ test("should handle action execution with no actions provided", () => {
996
+ const actionExecMsg = new gql.ActionExecutionMessage({
997
+ id: "action-5",
998
+ name: "anyAction",
999
+ arguments: { test: "value" },
1000
+ parentMessageId: "parent-5",
1001
+ });
1002
+
1003
+ const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg);
1004
+
1005
+ expect(result).toMatchObject({
1006
+ id: "action-5",
1007
+ role: "assistant",
1008
+ toolCalls: [
1009
+ {
1010
+ id: "action-5",
1011
+ function: {
1012
+ name: "anyAction",
1013
+ arguments: '{"test":"value"}',
1014
+ },
1015
+ type: "function",
1016
+ },
1017
+ ],
1018
+ name: "anyAction",
1019
+ });
1020
+ expect(result).not.toHaveProperty("generativeUI");
1021
+ });
1022
+
1023
+ test("should handle action execution with completed result", () => {
1024
+ const actions = {
1025
+ "*": {
1026
+ name: "*",
1027
+ render: vi.fn((props) => `Result: ${props.result}`),
1028
+ },
1029
+ };
1030
+
1031
+ const actionExecMsg = new gql.ActionExecutionMessage({
1032
+ id: "action-6",
1033
+ name: "testAction",
1034
+ arguments: { test: "value" },
1035
+ parentMessageId: "parent-6",
1036
+ });
1037
+
1038
+ const actionResults = new Map([["action-6", "completed result"]]);
1039
+
1040
+ const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg, actions, actionResults);
1041
+
1042
+ expect(result).toMatchObject({
1043
+ id: "action-6",
1044
+ role: "assistant",
1045
+ content: "",
1046
+ toolCalls: [
1047
+ {
1048
+ id: "action-6",
1049
+ function: {
1050
+ name: "testAction",
1051
+ arguments: '{"test":"value"}',
1052
+ },
1053
+ type: "function",
1054
+ },
1055
+ ],
1056
+ generativeUI: expect.any(Function),
1057
+ name: "testAction",
1058
+ });
1059
+ });
1060
+
1061
+ test("should handle action execution with executing status", () => {
1062
+ const actions = {
1063
+ "*": {
1064
+ name: "*",
1065
+ render: vi.fn((props) => `Status: ${props.status}`),
1066
+ },
1067
+ };
1068
+
1069
+ const actionExecMsg = new gql.ActionExecutionMessage({
1070
+ id: "action-7",
1071
+ name: "testAction",
1072
+ arguments: { test: "value" },
1073
+ parentMessageId: "parent-7",
1074
+ status: { code: MessageStatusCode.Success },
1075
+ });
1076
+
1077
+ const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg, actions);
1078
+
1079
+ expect(result).toMatchObject({
1080
+ id: "action-7",
1081
+ role: "assistant",
1082
+ content: "",
1083
+ toolCalls: [
1084
+ {
1085
+ id: "action-7",
1086
+ function: {
1087
+ name: "testAction",
1088
+ arguments: '{"test":"value"}',
1089
+ },
1090
+ type: "function",
1091
+ },
1092
+ ],
1093
+ generativeUI: expect.any(Function),
1094
+ name: "testAction",
1095
+ });
1096
+ });
1097
+
1098
+ test("should handle action execution with pending status", () => {
1099
+ const actions = {
1100
+ "*": {
1101
+ name: "*",
1102
+ render: vi.fn((props) => `Status: ${props.status}`),
1103
+ },
1104
+ };
1105
+
1106
+ const actionExecMsg = new gql.ActionExecutionMessage({
1107
+ id: "action-8",
1108
+ name: "testAction",
1109
+ arguments: { test: "value" },
1110
+ parentMessageId: "parent-8",
1111
+ status: { code: MessageStatusCode.Pending },
1112
+ });
1113
+
1114
+ const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg, actions);
1115
+
1116
+ expect(result).toMatchObject({
1117
+ id: "action-8",
1118
+ role: "assistant",
1119
+ content: "",
1120
+ toolCalls: [
1121
+ {
1122
+ id: "action-8",
1123
+ function: {
1124
+ name: "testAction",
1125
+ arguments: '{"test":"value"}',
1126
+ },
1127
+ type: "function",
1128
+ },
1129
+ ],
1130
+ generativeUI: expect.any(Function),
1131
+ name: "testAction",
1132
+ });
1133
+ });
1134
+
1135
+ test("should handle action execution with failed status", () => {
1136
+ const actions = {
1137
+ "*": {
1138
+ name: "*",
1139
+ render: vi.fn((props) => `Status: ${props.status}`),
1140
+ },
1141
+ };
1142
+
1143
+ const actionExecMsg = new gql.ActionExecutionMessage({
1144
+ id: "action-9",
1145
+ name: "testAction",
1146
+ arguments: { test: "value" },
1147
+ parentMessageId: "parent-9",
1148
+ status: { code: MessageStatusCode.Failed },
1149
+ });
1150
+
1151
+ const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg, actions);
1152
+
1153
+ expect(result).toMatchObject({
1154
+ id: "action-9",
1155
+ role: "assistant",
1156
+ content: "",
1157
+ toolCalls: [
1158
+ {
1159
+ id: "action-9",
1160
+ function: {
1161
+ name: "testAction",
1162
+ arguments: '{"test":"value"}',
1163
+ },
1164
+ type: "function",
1165
+ },
1166
+ ],
1167
+ generativeUI: expect.any(Function),
1168
+ name: "testAction",
1169
+ });
1170
+ });
1171
+
1172
+ test("should handle action execution with undefined status", () => {
1173
+ const actions = {
1174
+ "*": {
1175
+ name: "*",
1176
+ render: vi.fn((props) => `Status: ${props.status}`),
1177
+ },
1178
+ };
1179
+
1180
+ const actionExecMsg = new gql.ActionExecutionMessage({
1181
+ id: "action-10",
1182
+ name: "testAction",
1183
+ arguments: { test: "value" },
1184
+ parentMessageId: "parent-10",
1185
+ // No status field
1186
+ });
1187
+
1188
+ const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg, actions);
1189
+
1190
+ expect(result).toMatchObject({
1191
+ id: "action-10",
1192
+ role: "assistant",
1193
+ content: "",
1194
+ toolCalls: [
1195
+ {
1196
+ id: "action-10",
1197
+ function: {
1198
+ name: "testAction",
1199
+ arguments: '{"test":"value"}',
1200
+ },
1201
+ type: "function",
1202
+ },
1203
+ ],
1204
+ generativeUI: expect.any(Function),
1205
+ name: "testAction",
1206
+ });
1207
+ });
1208
+
1209
+ test("should handle action execution with empty arguments", () => {
1210
+ const actions = {
1211
+ "*": {
1212
+ name: "*",
1213
+ render: vi.fn((props) => `Args: ${JSON.stringify(props.args)}`),
1214
+ },
1215
+ };
1216
+
1217
+ const actionExecMsg = new gql.ActionExecutionMessage({
1218
+ id: "action-11",
1219
+ name: "testAction",
1220
+ arguments: {},
1221
+ parentMessageId: "parent-11",
1222
+ });
1223
+
1224
+ const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg, actions);
1225
+
1226
+ expect(result).toMatchObject({
1227
+ id: "action-11",
1228
+ role: "assistant",
1229
+ content: "",
1230
+ toolCalls: [
1231
+ {
1232
+ id: "action-11",
1233
+ function: {
1234
+ name: "testAction",
1235
+ arguments: "{}",
1236
+ },
1237
+ type: "function",
1238
+ },
1239
+ ],
1240
+ generativeUI: expect.any(Function),
1241
+ name: "testAction",
1242
+ });
1243
+ });
1244
+
1245
+ test("should handle action execution with null arguments", () => {
1246
+ const actions = {
1247
+ "*": {
1248
+ name: "*",
1249
+ render: vi.fn((props) => `Args: ${JSON.stringify(props.args)}`),
1250
+ },
1251
+ };
1252
+
1253
+ const actionExecMsg = new gql.ActionExecutionMessage({
1254
+ id: "action-12",
1255
+ name: "testAction",
1256
+ arguments: null as any,
1257
+ parentMessageId: "parent-12",
1258
+ });
1259
+
1260
+ const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg, actions);
1261
+
1262
+ expect(result).toMatchObject({
1263
+ id: "action-12",
1264
+ role: "assistant",
1265
+ content: "",
1266
+ toolCalls: [
1267
+ {
1268
+ id: "action-12",
1269
+ function: {
1270
+ name: "testAction",
1271
+ arguments: "null",
1272
+ },
1273
+ type: "function",
1274
+ },
1275
+ ],
1276
+ generativeUI: expect.any(Function),
1277
+ name: "testAction",
1278
+ });
1279
+ });
1280
+
1281
+ test("should handle action execution with complex nested arguments", () => {
1282
+ const actions = {
1283
+ "*": {
1284
+ name: "*",
1285
+ render: vi.fn((props) => `Complex: ${JSON.stringify(props.args)}`),
1286
+ },
1287
+ };
1288
+
1289
+ const complexArgs = {
1290
+ nested: {
1291
+ array: [1, 2, 3],
1292
+ object: { key: "value" },
1293
+ nullValue: null,
1294
+ undefinedValue: undefined,
1295
+ },
1296
+ string: "test",
1297
+ number: 42,
1298
+ boolean: true,
1299
+ };
1300
+
1301
+ const actionExecMsg = new gql.ActionExecutionMessage({
1302
+ id: "action-13",
1303
+ name: "testAction",
1304
+ arguments: complexArgs,
1305
+ parentMessageId: "parent-13",
1306
+ });
1307
+
1308
+ const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg, actions);
1309
+
1310
+ expect(result).toMatchObject({
1311
+ id: "action-13",
1312
+ role: "assistant",
1313
+ content: "",
1314
+ toolCalls: [
1315
+ {
1316
+ id: "action-13",
1317
+ function: {
1318
+ name: "testAction",
1319
+ arguments: JSON.stringify(complexArgs),
1320
+ },
1321
+ type: "function",
1322
+ },
1323
+ ],
1324
+ generativeUI: expect.any(Function),
1325
+ name: "testAction",
1326
+ });
1327
+ });
1328
+
1329
+ test("should handle multiple wild card actions (should use first one)", () => {
1330
+ const actions = {
1331
+ wildcard1: {
1332
+ name: "*",
1333
+ render: vi.fn((props) => "First wildcard"),
1334
+ },
1335
+ wildcard2: {
1336
+ name: "*",
1337
+ render: vi.fn((props) => "Second wildcard"),
1338
+ },
1339
+ };
1340
+
1341
+ const actionExecMsg = new gql.ActionExecutionMessage({
1342
+ id: "action-14",
1343
+ name: "unknownAction",
1344
+ arguments: { test: "value" },
1345
+ parentMessageId: "parent-14",
1346
+ });
1347
+
1348
+ const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg, actions);
1349
+
1350
+ expect(result).toMatchObject({
1351
+ id: "action-14",
1352
+ role: "assistant",
1353
+ content: "",
1354
+ toolCalls: [
1355
+ {
1356
+ id: "action-14",
1357
+ function: {
1358
+ name: "unknownAction",
1359
+ arguments: '{"test":"value"}',
1360
+ },
1361
+ type: "function",
1362
+ },
1363
+ ],
1364
+ generativeUI: expect.any(Function),
1365
+ name: "unknownAction",
1366
+ });
1367
+ });
1368
+
1369
+ test("should parse string results in generativeUI props", () => {
1370
+ const actions = {
1371
+ "*": {
1372
+ name: "*",
1373
+ render: vi.fn((props) => `Result: ${JSON.stringify(props.result)}`),
1374
+ },
1375
+ };
1376
+
1377
+ const actionExecMsg = new gql.ActionExecutionMessage({
1378
+ id: "action-string-result",
1379
+ name: "stringResultAction",
1380
+ arguments: { test: "value" },
1381
+ parentMessageId: "parent-string",
1382
+ });
1383
+
1384
+ const actionResults = new Map<string, string>();
1385
+ actionResults.set("action-string-result", '{"parsed": true, "value": 42}');
1386
+
1387
+ const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg, actions, actionResults);
1388
+
1389
+ expect((result as AIMessage).generativeUI).toBeDefined();
1390
+ // Call the render function to test the result parsing
1391
+ const renderResult = (result as AIMessage).generativeUI!({
1392
+ result: '{"from": "props", "data": "test"}',
1393
+ });
1394
+
1395
+ // Verify the render function was called and the result was parsed
1396
+ expect(actions["*"].render).toHaveBeenCalledWith(
1397
+ expect.objectContaining({
1398
+ result: { from: "props", data: "test" }, // Should be parsed from string
1399
+ args: { test: "value" },
1400
+ status: "complete",
1401
+ messageId: "action-string-result",
1402
+ }),
1403
+ );
1404
+ });
1405
+
1406
+ test("should handle malformed JSON strings gracefully in results", () => {
1407
+ const actions = {
1408
+ "*": {
1409
+ name: "*",
1410
+ render: vi.fn((props) => `Result: ${JSON.stringify(props.result)}`),
1411
+ },
1412
+ };
1413
+
1414
+ const actionExecMsg = new gql.ActionExecutionMessage({
1415
+ id: "action-malformed",
1416
+ name: "malformedAction",
1417
+ arguments: { test: "value" },
1418
+ parentMessageId: "parent-malformed",
1419
+ });
1420
+
1421
+ const actionResults = new Map<string, string>();
1422
+ actionResults.set("action-malformed", "invalid json {");
1423
+
1424
+ const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg, actions, actionResults);
1425
+
1426
+ expect((result as AIMessage).generativeUI).toBeDefined();
1427
+ // Call the render function to test malformed JSON handling
1428
+ const renderResult = (result as AIMessage).generativeUI!({
1429
+ result: "invalid json {",
1430
+ });
1431
+
1432
+ // Verify the render function was called with the original string (unparsed)
1433
+ expect(actions["*"].render).toHaveBeenCalledWith(
1434
+ expect.objectContaining({
1435
+ result: "invalid json {", // Should remain as string due to parse error
1436
+ args: { test: "value" },
1437
+ status: "complete",
1438
+ messageId: "action-malformed",
1439
+ }),
1440
+ );
1441
+ });
1442
+
1443
+ test("should handle non-string results without parsing", () => {
1444
+ const actions = {
1445
+ "*": {
1446
+ name: "*",
1447
+ render: vi.fn((props) => `Result: ${JSON.stringify(props.result)}`),
1448
+ },
1449
+ };
1450
+
1451
+ const actionExecMsg = new gql.ActionExecutionMessage({
1452
+ id: "action-object-result",
1453
+ name: "objectResultAction",
1454
+ arguments: { test: "value" },
1455
+ parentMessageId: "parent-object",
1456
+ });
1457
+
1458
+ const actionResults = new Map<string, string>();
1459
+ actionResults.set("action-object-result", '{"already": "parsed"}');
1460
+
1461
+ const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg, actions, actionResults);
1462
+
1463
+ expect((result as AIMessage).generativeUI).toBeDefined();
1464
+ // Call the render function with an object result
1465
+ const renderResult = (result as AIMessage).generativeUI!({
1466
+ result: { from: "props", data: "object" },
1467
+ });
1468
+
1469
+ // Verify the render function was called with the object as-is
1470
+ expect(actions["*"].render).toHaveBeenCalledWith(
1471
+ expect.objectContaining({
1472
+ result: { from: "props", data: "object" }, // Should remain as object
1473
+ args: { test: "value" },
1474
+ status: "complete",
1475
+ messageId: "action-object-result",
1476
+ }),
1477
+ );
1478
+ });
1479
+
1480
+ test("should handle action execution arguments correctly with simplified conversion", () => {
1481
+ const actionExecMsg = new gql.ActionExecutionMessage({
1482
+ id: "action-simplified",
1483
+ name: "simplifiedAction",
1484
+ arguments: { complex: { nested: "value" }, array: [1, 2, 3] },
1485
+ parentMessageId: "parent-simplified",
1486
+ });
1487
+
1488
+ const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg);
1489
+
1490
+ expect(result).toMatchObject({
1491
+ id: "action-simplified",
1492
+ role: "assistant",
1493
+ toolCalls: [
1494
+ {
1495
+ id: "action-simplified",
1496
+ function: {
1497
+ name: "simplifiedAction",
1498
+ arguments: '{"complex":{"nested":"value"},"array":[1,2,3]}',
1499
+ },
1500
+ type: "function",
1501
+ },
1502
+ ],
1503
+ name: "simplifiedAction",
1504
+ });
1505
+ });
1506
+ });
844
1507
  });