@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
@@ -19013,8 +19013,14 @@ function aguiToGQL(messages, actions, coAgentStateRenders) {
19013
19013
  const actionExecMsg = aguiToolCallToGQLActionExecution(toolCall, message.id);
19014
19014
  if ("generativeUI" in message && message.generativeUI && actions) {
19015
19015
  const actionName = toolCall.function.name;
19016
- if (actions[actionName]) {
19017
- actions[actionName].render = message.generativeUI;
19016
+ const specificAction = Object.values(actions).find(
19017
+ (action) => action.name === actionName
19018
+ );
19019
+ const wildcardAction = Object.values(actions).find((action) => action.name === "*");
19020
+ if (specificAction) {
19021
+ specificAction.render = message.generativeUI;
19022
+ } else if (wildcardAction) {
19023
+ wildcardAction.render = message.generativeUI;
19018
19024
  }
19019
19025
  }
19020
19026
  gqlMessages.push(actionExecMsg);
@@ -19663,6 +19669,378 @@ describe("agui-to-gql", () => {
19663
19669
  globalExpect(result.role).toBe(Role.User);
19664
19670
  });
19665
19671
  });
19672
+ describe("Wild Card Actions", () => {
19673
+ test3("should preserve render function for specific action", () => {
19674
+ const mockRender = () => "Specific Action Render";
19675
+ const aguiMessage = {
19676
+ id: "assistant-1",
19677
+ role: "assistant",
19678
+ content: "I'll execute a function",
19679
+ toolCalls: [
19680
+ {
19681
+ id: "tool-call-1",
19682
+ type: "function",
19683
+ function: {
19684
+ name: "specificAction",
19685
+ arguments: JSON.stringify({ param: "value" })
19686
+ }
19687
+ }
19688
+ ],
19689
+ generativeUI: mockRender
19690
+ };
19691
+ const actions = {
19692
+ specificAction: { name: "specificAction" }
19693
+ };
19694
+ const result = aguiToGQL(aguiMessage, actions);
19695
+ globalExpect(result).toHaveLength(2);
19696
+ globalExpect(result[0]).toBeInstanceOf(TextMessage);
19697
+ globalExpect(result[1]).toBeInstanceOf(ActionExecutionMessage);
19698
+ globalExpect(actions.specificAction.render).toBe(mockRender);
19699
+ });
19700
+ test3("should preserve render function for wild card action", () => {
19701
+ const mockRender = () => "Wild Card Action Render";
19702
+ const aguiMessage = {
19703
+ id: "assistant-2",
19704
+ role: "assistant",
19705
+ content: "I'll execute an unknown function",
19706
+ toolCalls: [
19707
+ {
19708
+ id: "tool-call-2",
19709
+ type: "function",
19710
+ function: {
19711
+ name: "unknownAction",
19712
+ arguments: JSON.stringify({ param: "value" })
19713
+ }
19714
+ }
19715
+ ],
19716
+ generativeUI: mockRender
19717
+ };
19718
+ const actions = {
19719
+ "*": { name: "*" }
19720
+ };
19721
+ const result = aguiToGQL(aguiMessage, actions);
19722
+ globalExpect(result).toHaveLength(2);
19723
+ globalExpect(result[0]).toBeInstanceOf(TextMessage);
19724
+ globalExpect(result[1]).toBeInstanceOf(ActionExecutionMessage);
19725
+ globalExpect(actions["*"].render).toBe(mockRender);
19726
+ });
19727
+ test3("should prioritize specific action over wild card action", () => {
19728
+ const mockRender = () => "Prioritized Render";
19729
+ const aguiMessage = {
19730
+ id: "assistant-3",
19731
+ role: "assistant",
19732
+ content: "I'll execute a function",
19733
+ toolCalls: [
19734
+ {
19735
+ id: "tool-call-3",
19736
+ type: "function",
19737
+ function: {
19738
+ name: "specificAction",
19739
+ arguments: JSON.stringify({ param: "value" })
19740
+ }
19741
+ }
19742
+ ],
19743
+ generativeUI: mockRender
19744
+ };
19745
+ const actions = {
19746
+ specificAction: { name: "specificAction" },
19747
+ "*": { name: "*" }
19748
+ };
19749
+ const result = aguiToGQL(aguiMessage, actions);
19750
+ globalExpect(result).toHaveLength(2);
19751
+ globalExpect(result[0]).toBeInstanceOf(TextMessage);
19752
+ globalExpect(result[1]).toBeInstanceOf(ActionExecutionMessage);
19753
+ globalExpect(actions.specificAction.render).toBe(mockRender);
19754
+ globalExpect(actions["*"].render).toBeUndefined();
19755
+ });
19756
+ test3("should not preserve render function when no matching action", () => {
19757
+ const mockRender = () => "Unmatched Render";
19758
+ const aguiMessage = {
19759
+ id: "assistant-4",
19760
+ role: "assistant",
19761
+ content: "I'll execute an unmatched function",
19762
+ toolCalls: [
19763
+ {
19764
+ id: "tool-call-4",
19765
+ type: "function",
19766
+ function: {
19767
+ name: "unmatchedAction",
19768
+ arguments: JSON.stringify({ param: "value" })
19769
+ }
19770
+ }
19771
+ ],
19772
+ generativeUI: mockRender
19773
+ };
19774
+ const actions = {
19775
+ otherAction: { name: "otherAction" }
19776
+ };
19777
+ const result = aguiToGQL(aguiMessage, actions);
19778
+ globalExpect(result).toHaveLength(2);
19779
+ globalExpect(result[0]).toBeInstanceOf(TextMessage);
19780
+ globalExpect(result[1]).toBeInstanceOf(ActionExecutionMessage);
19781
+ globalExpect(actions.otherAction.render).toBeUndefined();
19782
+ });
19783
+ test3("should handle multiple tool calls with wild card action", () => {
19784
+ const mockRender = () => "Wild Card Render";
19785
+ const aguiMessage = {
19786
+ id: "assistant-5",
19787
+ role: "assistant",
19788
+ content: "I'll execute multiple functions",
19789
+ toolCalls: [
19790
+ {
19791
+ id: "tool-call-5",
19792
+ type: "function",
19793
+ function: {
19794
+ name: "firstFunction",
19795
+ arguments: JSON.stringify({ param: "value1" })
19796
+ }
19797
+ },
19798
+ {
19799
+ id: "tool-call-6",
19800
+ type: "function",
19801
+ function: {
19802
+ name: "secondFunction",
19803
+ arguments: JSON.stringify({ param: "value2" })
19804
+ }
19805
+ }
19806
+ ],
19807
+ generativeUI: mockRender
19808
+ };
19809
+ const actions = {
19810
+ "*": { name: "*" }
19811
+ };
19812
+ const result = aguiToGQL(aguiMessage, actions);
19813
+ globalExpect(result).toHaveLength(3);
19814
+ globalExpect(result[0]).toBeInstanceOf(TextMessage);
19815
+ globalExpect(result[1]).toBeInstanceOf(ActionExecutionMessage);
19816
+ globalExpect(result[2]).toBeInstanceOf(ActionExecutionMessage);
19817
+ globalExpect(actions["*"].render).toBe(mockRender);
19818
+ });
19819
+ test3("should handle mixed specific and wild card actions", () => {
19820
+ const mockRender = () => "Mixed Render";
19821
+ const aguiMessage = {
19822
+ id: "assistant-6",
19823
+ role: "assistant",
19824
+ content: "I'll execute mixed functions",
19825
+ toolCalls: [
19826
+ {
19827
+ id: "tool-call-7",
19828
+ type: "function",
19829
+ function: {
19830
+ name: "specificAction",
19831
+ arguments: JSON.stringify({ param: "value1" })
19832
+ }
19833
+ },
19834
+ {
19835
+ id: "tool-call-8",
19836
+ type: "function",
19837
+ function: {
19838
+ name: "unknownAction",
19839
+ arguments: JSON.stringify({ param: "value2" })
19840
+ }
19841
+ }
19842
+ ],
19843
+ generativeUI: mockRender
19844
+ };
19845
+ const actions = {
19846
+ specificAction: { name: "specificAction" },
19847
+ "*": { name: "*" }
19848
+ };
19849
+ const result = aguiToGQL(aguiMessage, actions);
19850
+ globalExpect(result).toHaveLength(3);
19851
+ globalExpect(result[0]).toBeInstanceOf(TextMessage);
19852
+ globalExpect(result[1]).toBeInstanceOf(ActionExecutionMessage);
19853
+ globalExpect(result[2]).toBeInstanceOf(ActionExecutionMessage);
19854
+ globalExpect(actions.specificAction.render).toBe(mockRender);
19855
+ globalExpect(actions["*"].render).toBe(mockRender);
19856
+ });
19857
+ test3("should handle no actions provided", () => {
19858
+ const mockRender = () => "No Actions Render";
19859
+ const aguiMessage = {
19860
+ id: "assistant-7",
19861
+ role: "assistant",
19862
+ content: "I'll execute a function",
19863
+ toolCalls: [
19864
+ {
19865
+ id: "tool-call-9",
19866
+ type: "function",
19867
+ function: {
19868
+ name: "anyAction",
19869
+ arguments: JSON.stringify({ param: "value" })
19870
+ }
19871
+ }
19872
+ ],
19873
+ generativeUI: mockRender
19874
+ };
19875
+ const result = aguiToGQL(aguiMessage);
19876
+ globalExpect(result).toHaveLength(2);
19877
+ globalExpect(result[0]).toBeInstanceOf(TextMessage);
19878
+ globalExpect(result[1]).toBeInstanceOf(ActionExecutionMessage);
19879
+ });
19880
+ test3("should handle empty actions object", () => {
19881
+ const mockRender = () => "Empty Actions Render";
19882
+ const aguiMessage = {
19883
+ id: "assistant-8",
19884
+ role: "assistant",
19885
+ content: "I'll execute a function",
19886
+ toolCalls: [
19887
+ {
19888
+ id: "tool-call-10",
19889
+ type: "function",
19890
+ function: {
19891
+ name: "anyAction",
19892
+ arguments: JSON.stringify({ param: "value" })
19893
+ }
19894
+ }
19895
+ ],
19896
+ generativeUI: mockRender
19897
+ };
19898
+ const actions = {};
19899
+ const result = aguiToGQL(aguiMessage, actions);
19900
+ globalExpect(result).toHaveLength(2);
19901
+ globalExpect(result[0]).toBeInstanceOf(TextMessage);
19902
+ globalExpect(result[1]).toBeInstanceOf(ActionExecutionMessage);
19903
+ });
19904
+ test3("should handle actions with null render functions", () => {
19905
+ const mockRender = () => "Null Render Test";
19906
+ const aguiMessage = {
19907
+ id: "assistant-9",
19908
+ role: "assistant",
19909
+ content: "I'll execute a function",
19910
+ toolCalls: [
19911
+ {
19912
+ id: "tool-call-11",
19913
+ type: "function",
19914
+ function: {
19915
+ name: "specificAction",
19916
+ arguments: JSON.stringify({ param: "value" })
19917
+ }
19918
+ }
19919
+ ],
19920
+ generativeUI: mockRender
19921
+ };
19922
+ const actions = {
19923
+ specificAction: { name: "specificAction", render: null },
19924
+ "*": { name: "*", render: null }
19925
+ };
19926
+ const result = aguiToGQL(aguiMessage, actions);
19927
+ globalExpect(result).toHaveLength(2);
19928
+ globalExpect(result[0]).toBeInstanceOf(TextMessage);
19929
+ globalExpect(result[1]).toBeInstanceOf(ActionExecutionMessage);
19930
+ globalExpect(actions.specificAction.render).toBe(mockRender);
19931
+ });
19932
+ test3("should handle actions with undefined render functions", () => {
19933
+ const mockRender = () => "Undefined Render Test";
19934
+ const aguiMessage = {
19935
+ id: "assistant-10",
19936
+ role: "assistant",
19937
+ content: "I'll execute a function",
19938
+ toolCalls: [
19939
+ {
19940
+ id: "tool-call-12",
19941
+ type: "function",
19942
+ function: {
19943
+ name: "wildcardAction",
19944
+ arguments: JSON.stringify({ param: "value" })
19945
+ }
19946
+ }
19947
+ ],
19948
+ generativeUI: mockRender
19949
+ };
19950
+ const actions = {
19951
+ "*": { name: "*", render: void 0 }
19952
+ };
19953
+ const result = aguiToGQL(aguiMessage, actions);
19954
+ globalExpect(result).toHaveLength(2);
19955
+ globalExpect(result[0]).toBeInstanceOf(TextMessage);
19956
+ globalExpect(result[1]).toBeInstanceOf(ActionExecutionMessage);
19957
+ globalExpect(actions["*"].render).toBe(mockRender);
19958
+ });
19959
+ test3("should handle tool calls with malformed arguments", () => {
19960
+ const mockRender = () => "Malformed Args Test";
19961
+ const aguiMessage = {
19962
+ id: "assistant-11",
19963
+ role: "assistant",
19964
+ content: "I'll execute a function",
19965
+ toolCalls: [
19966
+ {
19967
+ id: "tool-call-13",
19968
+ type: "function",
19969
+ function: {
19970
+ name: "wildcardAction",
19971
+ arguments: "invalid json {"
19972
+ // Malformed JSON
19973
+ }
19974
+ }
19975
+ ],
19976
+ generativeUI: mockRender
19977
+ };
19978
+ const actions = {
19979
+ "*": { name: "*" }
19980
+ };
19981
+ const result = aguiToGQL(aguiMessage, actions);
19982
+ globalExpect(result).toHaveLength(2);
19983
+ globalExpect(result[0]).toBeInstanceOf(TextMessage);
19984
+ globalExpect(result[1]).toBeInstanceOf(ActionExecutionMessage);
19985
+ globalExpect(actions["*"].render).toBe(mockRender);
19986
+ });
19987
+ test3("should handle tool calls with empty arguments string", () => {
19988
+ const mockRender = () => "Empty Args Test";
19989
+ const aguiMessage = {
19990
+ id: "assistant-12",
19991
+ role: "assistant",
19992
+ content: "I'll execute a function",
19993
+ toolCalls: [
19994
+ {
19995
+ id: "tool-call-14",
19996
+ type: "function",
19997
+ function: {
19998
+ name: "wildcardAction",
19999
+ arguments: ""
20000
+ }
20001
+ }
20002
+ ],
20003
+ generativeUI: mockRender
20004
+ };
20005
+ const actions = {
20006
+ "*": { name: "*" }
20007
+ };
20008
+ const result = aguiToGQL(aguiMessage, actions);
20009
+ globalExpect(result).toHaveLength(2);
20010
+ globalExpect(result[0]).toBeInstanceOf(TextMessage);
20011
+ globalExpect(result[1]).toBeInstanceOf(ActionExecutionMessage);
20012
+ globalExpect(actions["*"].render).toBe(mockRender);
20013
+ });
20014
+ test3("should handle multiple wild card actions in same object", () => {
20015
+ const mockRender = () => "Multiple Wildcards Test";
20016
+ const aguiMessage = {
20017
+ id: "assistant-13",
20018
+ role: "assistant",
20019
+ content: "I'll execute a function",
20020
+ toolCalls: [
20021
+ {
20022
+ id: "tool-call-15",
20023
+ type: "function",
20024
+ function: {
20025
+ name: "unknownAction",
20026
+ arguments: JSON.stringify({ param: "value" })
20027
+ }
20028
+ }
20029
+ ],
20030
+ generativeUI: mockRender
20031
+ };
20032
+ const actions = {
20033
+ wildcard1: { name: "*" },
20034
+ wildcard2: { name: "*" }
20035
+ };
20036
+ const result = aguiToGQL(aguiMessage, actions);
20037
+ globalExpect(result).toHaveLength(2);
20038
+ globalExpect(result[0]).toBeInstanceOf(TextMessage);
20039
+ globalExpect(result[1]).toBeInstanceOf(ActionExecutionMessage);
20040
+ globalExpect(actions.wildcard1.render).toBe(mockRender);
20041
+ globalExpect(actions.wildcard2.render).toBeUndefined();
20042
+ });
20043
+ });
19666
20044
  });
19667
20045
  /*! Bundled license information:
19668
20046