@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.
- package/CHANGELOG.md +10 -0
- package/dist/{chunk-YNQMTL2P.mjs → chunk-7OSRQ2O3.mjs} +9 -3
- package/dist/chunk-7OSRQ2O3.mjs.map +1 -0
- package/dist/{chunk-PAQ6AHHC.mjs → chunk-AES3X7TL.mjs} +2 -2
- package/dist/{chunk-PAQ6AHHC.mjs.map → chunk-AES3X7TL.mjs.map} +1 -1
- package/dist/{chunk-MTD2RJDJ.mjs → chunk-IGXWE4TX.mjs} +32 -29
- package/dist/chunk-IGXWE4TX.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 +41 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -3
- package/dist/message-conversion/agui-to-gql.js +8 -2
- 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 +380 -2
- package/dist/message-conversion/agui-to-gql.test.js.map +1 -1
- package/dist/message-conversion/agui-to-gql.test.mjs +374 -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 +32 -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 +496 -28
- package/dist/message-conversion/gql-to-agui.test.js.map +1 -1
- package/dist/message-conversion/gql-to-agui.test.mjs +469 -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 +40 -30
- 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 +132 -30
- package/dist/message-conversion/roundtrip-conversion.test.js.map +1 -1
- package/dist/message-conversion/roundtrip-conversion.test.mjs +97 -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 +426 -0
- package/src/message-conversion/agui-to-gql.ts +11 -2
- package/src/message-conversion/gql-to-agui.test.ts +524 -0
- package/src/message-conversion/gql-to-agui.ts +45 -36
- package/src/message-conversion/roundtrip-conversion.test.ts +122 -0
- package/dist/chunk-MTD2RJDJ.mjs.map +0 -1
- package/dist/chunk-YNQMTL2P.mjs.map +0 -1
|
@@ -18989,45 +18989,47 @@ function gqlToAGUI(messages, actions, coAgentStateRenders) {
|
|
|
18989
18989
|
return aguiMessages;
|
|
18990
18990
|
}
|
|
18991
18991
|
function gqlActionExecutionMessageToAGUIMessage(message, actions, actionResults) {
|
|
18992
|
-
|
|
18993
|
-
|
|
18994
|
-
|
|
18995
|
-
if (!originalRender)
|
|
18996
|
-
return void 0;
|
|
18997
|
-
return (props) => {
|
|
18998
|
-
var _a3;
|
|
18999
|
-
const actionResult = actionResults == null ? void 0 : actionResults.get(message.id);
|
|
19000
|
-
let status = "inProgress";
|
|
19001
|
-
if (actionResult !== void 0) {
|
|
19002
|
-
status = "complete";
|
|
19003
|
-
} else if (((_a3 = message.status) == null ? void 0 : _a3.code) !== "Pending" /* Pending */) {
|
|
19004
|
-
status = "executing";
|
|
19005
|
-
}
|
|
19006
|
-
const renderProps = {
|
|
19007
|
-
status: (props == null ? void 0 : props.status) || status,
|
|
19008
|
-
args: message.arguments || {},
|
|
19009
|
-
result: (props == null ? void 0 : props.result) || actionResult || void 0,
|
|
19010
|
-
respond: (props == null ? void 0 : props.respond) || (() => {
|
|
19011
|
-
}),
|
|
19012
|
-
messageId: message.id,
|
|
19013
|
-
...props
|
|
19014
|
-
};
|
|
19015
|
-
return originalRender(renderProps);
|
|
19016
|
-
};
|
|
19017
|
-
};
|
|
18992
|
+
const hasSpecificAction = actions && Object.values(actions).some((action2) => action2.name === message.name);
|
|
18993
|
+
const hasWildcardAction = actions && Object.values(actions).some((action2) => action2.name === "*");
|
|
18994
|
+
if (!actions || !hasSpecificAction && !hasWildcardAction) {
|
|
19018
18995
|
return {
|
|
19019
18996
|
id: message.id,
|
|
19020
18997
|
role: "assistant",
|
|
19021
|
-
content: "",
|
|
19022
18998
|
toolCalls: [actionExecutionMessageToAGUIMessage(message)],
|
|
19023
|
-
generativeUI: createRenderWrapper(action.render),
|
|
19024
18999
|
name: message.name
|
|
19025
19000
|
};
|
|
19026
19001
|
}
|
|
19002
|
+
const action = Object.values(actions).find((action2) => action2.name === message.name) || Object.values(actions).find((action2) => action2.name === "*");
|
|
19003
|
+
const createRenderWrapper = (originalRender) => {
|
|
19004
|
+
if (!originalRender)
|
|
19005
|
+
return void 0;
|
|
19006
|
+
return (props) => {
|
|
19007
|
+
var _a3;
|
|
19008
|
+
const actionResult = actionResults == null ? void 0 : actionResults.get(message.id);
|
|
19009
|
+
let status = "inProgress";
|
|
19010
|
+
if (actionResult !== void 0) {
|
|
19011
|
+
status = "complete";
|
|
19012
|
+
} else if (((_a3 = message.status) == null ? void 0 : _a3.code) !== "Pending" /* Pending */) {
|
|
19013
|
+
status = "executing";
|
|
19014
|
+
}
|
|
19015
|
+
const renderProps = {
|
|
19016
|
+
status: (props == null ? void 0 : props.status) || status,
|
|
19017
|
+
args: message.arguments || {},
|
|
19018
|
+
result: (props == null ? void 0 : props.result) || actionResult || void 0,
|
|
19019
|
+
respond: (props == null ? void 0 : props.respond) || (() => {
|
|
19020
|
+
}),
|
|
19021
|
+
messageId: message.id,
|
|
19022
|
+
...props
|
|
19023
|
+
};
|
|
19024
|
+
return originalRender(renderProps);
|
|
19025
|
+
};
|
|
19026
|
+
};
|
|
19027
19027
|
return {
|
|
19028
19028
|
id: message.id,
|
|
19029
19029
|
role: "assistant",
|
|
19030
|
+
content: "",
|
|
19030
19031
|
toolCalls: [actionExecutionMessageToAGUIMessage(message)],
|
|
19032
|
+
generativeUI: createRenderWrapper(action.render),
|
|
19031
19033
|
name: message.name
|
|
19032
19034
|
};
|
|
19033
19035
|
}
|
|
@@ -19839,6 +19841,472 @@ describe("message-conversion", () => {
|
|
|
19839
19841
|
});
|
|
19840
19842
|
});
|
|
19841
19843
|
});
|
|
19844
|
+
describe("Wild Card Actions", () => {
|
|
19845
|
+
test3("should handle action execution with specific action", () => {
|
|
19846
|
+
const actions = {
|
|
19847
|
+
testAction: {
|
|
19848
|
+
name: "testAction",
|
|
19849
|
+
render: vi.fn((props) => `Rendered: ${props.args.test}`)
|
|
19850
|
+
}
|
|
19851
|
+
};
|
|
19852
|
+
const actionExecMsg = new ActionExecutionMessage({
|
|
19853
|
+
id: "action-1",
|
|
19854
|
+
name: "testAction",
|
|
19855
|
+
arguments: { test: "value" },
|
|
19856
|
+
parentMessageId: "parent-1"
|
|
19857
|
+
});
|
|
19858
|
+
const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg, actions);
|
|
19859
|
+
globalExpect(result).toMatchObject({
|
|
19860
|
+
id: "action-1",
|
|
19861
|
+
role: "assistant",
|
|
19862
|
+
content: "",
|
|
19863
|
+
toolCalls: [
|
|
19864
|
+
{
|
|
19865
|
+
id: "action-1",
|
|
19866
|
+
function: {
|
|
19867
|
+
name: "testAction",
|
|
19868
|
+
arguments: '{"test":"value"}'
|
|
19869
|
+
},
|
|
19870
|
+
type: "function"
|
|
19871
|
+
}
|
|
19872
|
+
],
|
|
19873
|
+
generativeUI: globalExpect.any(Function),
|
|
19874
|
+
name: "testAction"
|
|
19875
|
+
});
|
|
19876
|
+
});
|
|
19877
|
+
test3("should handle action execution with wild card action", () => {
|
|
19878
|
+
const actions = {
|
|
19879
|
+
"*": {
|
|
19880
|
+
name: "*",
|
|
19881
|
+
render: vi.fn((props) => `Wildcard rendered: ${props.args.test}`)
|
|
19882
|
+
}
|
|
19883
|
+
};
|
|
19884
|
+
const actionExecMsg = new ActionExecutionMessage({
|
|
19885
|
+
id: "action-2",
|
|
19886
|
+
name: "unknownAction",
|
|
19887
|
+
arguments: { test: "wildcard-value" },
|
|
19888
|
+
parentMessageId: "parent-2"
|
|
19889
|
+
});
|
|
19890
|
+
const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg, actions);
|
|
19891
|
+
globalExpect(result).toMatchObject({
|
|
19892
|
+
id: "action-2",
|
|
19893
|
+
role: "assistant",
|
|
19894
|
+
content: "",
|
|
19895
|
+
toolCalls: [
|
|
19896
|
+
{
|
|
19897
|
+
id: "action-2",
|
|
19898
|
+
function: {
|
|
19899
|
+
name: "unknownAction",
|
|
19900
|
+
arguments: '{"test":"wildcard-value"}'
|
|
19901
|
+
},
|
|
19902
|
+
type: "function"
|
|
19903
|
+
}
|
|
19904
|
+
],
|
|
19905
|
+
generativeUI: globalExpect.any(Function),
|
|
19906
|
+
name: "unknownAction"
|
|
19907
|
+
});
|
|
19908
|
+
});
|
|
19909
|
+
test3("should prioritize specific action over wild card action", () => {
|
|
19910
|
+
const actions = {
|
|
19911
|
+
specificAction: {
|
|
19912
|
+
name: "specificAction",
|
|
19913
|
+
render: vi.fn((props) => "Specific action rendered")
|
|
19914
|
+
},
|
|
19915
|
+
"*": {
|
|
19916
|
+
name: "*",
|
|
19917
|
+
render: vi.fn((props) => "Wildcard action rendered")
|
|
19918
|
+
}
|
|
19919
|
+
};
|
|
19920
|
+
const actionExecMsg = new ActionExecutionMessage({
|
|
19921
|
+
id: "action-3",
|
|
19922
|
+
name: "specificAction",
|
|
19923
|
+
arguments: { test: "value" },
|
|
19924
|
+
parentMessageId: "parent-3"
|
|
19925
|
+
});
|
|
19926
|
+
const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg, actions);
|
|
19927
|
+
globalExpect(result).toMatchObject({
|
|
19928
|
+
id: "action-3",
|
|
19929
|
+
role: "assistant",
|
|
19930
|
+
content: "",
|
|
19931
|
+
toolCalls: [
|
|
19932
|
+
{
|
|
19933
|
+
id: "action-3",
|
|
19934
|
+
function: {
|
|
19935
|
+
name: "specificAction",
|
|
19936
|
+
arguments: '{"test":"value"}'
|
|
19937
|
+
},
|
|
19938
|
+
type: "function"
|
|
19939
|
+
}
|
|
19940
|
+
],
|
|
19941
|
+
generativeUI: globalExpect.any(Function),
|
|
19942
|
+
name: "specificAction"
|
|
19943
|
+
});
|
|
19944
|
+
});
|
|
19945
|
+
test3("should handle action execution without any matching actions", () => {
|
|
19946
|
+
const actions = {
|
|
19947
|
+
otherAction: {
|
|
19948
|
+
name: "otherAction",
|
|
19949
|
+
render: vi.fn()
|
|
19950
|
+
}
|
|
19951
|
+
};
|
|
19952
|
+
const actionExecMsg = new ActionExecutionMessage({
|
|
19953
|
+
id: "action-4",
|
|
19954
|
+
name: "unmatchedAction",
|
|
19955
|
+
arguments: { test: "value" },
|
|
19956
|
+
parentMessageId: "parent-4"
|
|
19957
|
+
});
|
|
19958
|
+
const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg, actions);
|
|
19959
|
+
globalExpect(result).toMatchObject({
|
|
19960
|
+
id: "action-4",
|
|
19961
|
+
role: "assistant",
|
|
19962
|
+
toolCalls: [
|
|
19963
|
+
{
|
|
19964
|
+
id: "action-4",
|
|
19965
|
+
function: {
|
|
19966
|
+
name: "unmatchedAction",
|
|
19967
|
+
arguments: '{"test":"value"}'
|
|
19968
|
+
},
|
|
19969
|
+
type: "function"
|
|
19970
|
+
}
|
|
19971
|
+
],
|
|
19972
|
+
name: "unmatchedAction"
|
|
19973
|
+
});
|
|
19974
|
+
globalExpect(result).not.toHaveProperty("generativeUI");
|
|
19975
|
+
});
|
|
19976
|
+
test3("should handle action execution with no actions provided", () => {
|
|
19977
|
+
const actionExecMsg = new ActionExecutionMessage({
|
|
19978
|
+
id: "action-5",
|
|
19979
|
+
name: "anyAction",
|
|
19980
|
+
arguments: { test: "value" },
|
|
19981
|
+
parentMessageId: "parent-5"
|
|
19982
|
+
});
|
|
19983
|
+
const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg);
|
|
19984
|
+
globalExpect(result).toMatchObject({
|
|
19985
|
+
id: "action-5",
|
|
19986
|
+
role: "assistant",
|
|
19987
|
+
toolCalls: [
|
|
19988
|
+
{
|
|
19989
|
+
id: "action-5",
|
|
19990
|
+
function: {
|
|
19991
|
+
name: "anyAction",
|
|
19992
|
+
arguments: '{"test":"value"}'
|
|
19993
|
+
},
|
|
19994
|
+
type: "function"
|
|
19995
|
+
}
|
|
19996
|
+
],
|
|
19997
|
+
name: "anyAction"
|
|
19998
|
+
});
|
|
19999
|
+
globalExpect(result).not.toHaveProperty("generativeUI");
|
|
20000
|
+
});
|
|
20001
|
+
test3("should handle action execution with completed result", () => {
|
|
20002
|
+
const actions = {
|
|
20003
|
+
"*": {
|
|
20004
|
+
name: "*",
|
|
20005
|
+
render: vi.fn((props) => `Result: ${props.result}`)
|
|
20006
|
+
}
|
|
20007
|
+
};
|
|
20008
|
+
const actionExecMsg = new ActionExecutionMessage({
|
|
20009
|
+
id: "action-6",
|
|
20010
|
+
name: "testAction",
|
|
20011
|
+
arguments: { test: "value" },
|
|
20012
|
+
parentMessageId: "parent-6"
|
|
20013
|
+
});
|
|
20014
|
+
const actionResults = /* @__PURE__ */ new Map([["action-6", "completed result"]]);
|
|
20015
|
+
const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg, actions, actionResults);
|
|
20016
|
+
globalExpect(result).toMatchObject({
|
|
20017
|
+
id: "action-6",
|
|
20018
|
+
role: "assistant",
|
|
20019
|
+
content: "",
|
|
20020
|
+
toolCalls: [
|
|
20021
|
+
{
|
|
20022
|
+
id: "action-6",
|
|
20023
|
+
function: {
|
|
20024
|
+
name: "testAction",
|
|
20025
|
+
arguments: '{"test":"value"}'
|
|
20026
|
+
},
|
|
20027
|
+
type: "function"
|
|
20028
|
+
}
|
|
20029
|
+
],
|
|
20030
|
+
generativeUI: globalExpect.any(Function),
|
|
20031
|
+
name: "testAction"
|
|
20032
|
+
});
|
|
20033
|
+
});
|
|
20034
|
+
test3("should handle action execution with executing status", () => {
|
|
20035
|
+
const actions = {
|
|
20036
|
+
"*": {
|
|
20037
|
+
name: "*",
|
|
20038
|
+
render: vi.fn((props) => `Status: ${props.status}`)
|
|
20039
|
+
}
|
|
20040
|
+
};
|
|
20041
|
+
const actionExecMsg = new ActionExecutionMessage({
|
|
20042
|
+
id: "action-7",
|
|
20043
|
+
name: "testAction",
|
|
20044
|
+
arguments: { test: "value" },
|
|
20045
|
+
parentMessageId: "parent-7",
|
|
20046
|
+
status: { code: "Success" /* Success */ }
|
|
20047
|
+
});
|
|
20048
|
+
const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg, actions);
|
|
20049
|
+
globalExpect(result).toMatchObject({
|
|
20050
|
+
id: "action-7",
|
|
20051
|
+
role: "assistant",
|
|
20052
|
+
content: "",
|
|
20053
|
+
toolCalls: [
|
|
20054
|
+
{
|
|
20055
|
+
id: "action-7",
|
|
20056
|
+
function: {
|
|
20057
|
+
name: "testAction",
|
|
20058
|
+
arguments: '{"test":"value"}'
|
|
20059
|
+
},
|
|
20060
|
+
type: "function"
|
|
20061
|
+
}
|
|
20062
|
+
],
|
|
20063
|
+
generativeUI: globalExpect.any(Function),
|
|
20064
|
+
name: "testAction"
|
|
20065
|
+
});
|
|
20066
|
+
});
|
|
20067
|
+
test3("should handle action execution with pending status", () => {
|
|
20068
|
+
const actions = {
|
|
20069
|
+
"*": {
|
|
20070
|
+
name: "*",
|
|
20071
|
+
render: vi.fn((props) => `Status: ${props.status}`)
|
|
20072
|
+
}
|
|
20073
|
+
};
|
|
20074
|
+
const actionExecMsg = new ActionExecutionMessage({
|
|
20075
|
+
id: "action-8",
|
|
20076
|
+
name: "testAction",
|
|
20077
|
+
arguments: { test: "value" },
|
|
20078
|
+
parentMessageId: "parent-8",
|
|
20079
|
+
status: { code: "Pending" /* Pending */ }
|
|
20080
|
+
});
|
|
20081
|
+
const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg, actions);
|
|
20082
|
+
globalExpect(result).toMatchObject({
|
|
20083
|
+
id: "action-8",
|
|
20084
|
+
role: "assistant",
|
|
20085
|
+
content: "",
|
|
20086
|
+
toolCalls: [
|
|
20087
|
+
{
|
|
20088
|
+
id: "action-8",
|
|
20089
|
+
function: {
|
|
20090
|
+
name: "testAction",
|
|
20091
|
+
arguments: '{"test":"value"}'
|
|
20092
|
+
},
|
|
20093
|
+
type: "function"
|
|
20094
|
+
}
|
|
20095
|
+
],
|
|
20096
|
+
generativeUI: globalExpect.any(Function),
|
|
20097
|
+
name: "testAction"
|
|
20098
|
+
});
|
|
20099
|
+
});
|
|
20100
|
+
test3("should handle action execution with failed status", () => {
|
|
20101
|
+
const actions = {
|
|
20102
|
+
"*": {
|
|
20103
|
+
name: "*",
|
|
20104
|
+
render: vi.fn((props) => `Status: ${props.status}`)
|
|
20105
|
+
}
|
|
20106
|
+
};
|
|
20107
|
+
const actionExecMsg = new ActionExecutionMessage({
|
|
20108
|
+
id: "action-9",
|
|
20109
|
+
name: "testAction",
|
|
20110
|
+
arguments: { test: "value" },
|
|
20111
|
+
parentMessageId: "parent-9",
|
|
20112
|
+
status: { code: "Failed" /* Failed */ }
|
|
20113
|
+
});
|
|
20114
|
+
const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg, actions);
|
|
20115
|
+
globalExpect(result).toMatchObject({
|
|
20116
|
+
id: "action-9",
|
|
20117
|
+
role: "assistant",
|
|
20118
|
+
content: "",
|
|
20119
|
+
toolCalls: [
|
|
20120
|
+
{
|
|
20121
|
+
id: "action-9",
|
|
20122
|
+
function: {
|
|
20123
|
+
name: "testAction",
|
|
20124
|
+
arguments: '{"test":"value"}'
|
|
20125
|
+
},
|
|
20126
|
+
type: "function"
|
|
20127
|
+
}
|
|
20128
|
+
],
|
|
20129
|
+
generativeUI: globalExpect.any(Function),
|
|
20130
|
+
name: "testAction"
|
|
20131
|
+
});
|
|
20132
|
+
});
|
|
20133
|
+
test3("should handle action execution with undefined status", () => {
|
|
20134
|
+
const actions = {
|
|
20135
|
+
"*": {
|
|
20136
|
+
name: "*",
|
|
20137
|
+
render: vi.fn((props) => `Status: ${props.status}`)
|
|
20138
|
+
}
|
|
20139
|
+
};
|
|
20140
|
+
const actionExecMsg = new ActionExecutionMessage({
|
|
20141
|
+
id: "action-10",
|
|
20142
|
+
name: "testAction",
|
|
20143
|
+
arguments: { test: "value" },
|
|
20144
|
+
parentMessageId: "parent-10"
|
|
20145
|
+
// No status field
|
|
20146
|
+
});
|
|
20147
|
+
const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg, actions);
|
|
20148
|
+
globalExpect(result).toMatchObject({
|
|
20149
|
+
id: "action-10",
|
|
20150
|
+
role: "assistant",
|
|
20151
|
+
content: "",
|
|
20152
|
+
toolCalls: [
|
|
20153
|
+
{
|
|
20154
|
+
id: "action-10",
|
|
20155
|
+
function: {
|
|
20156
|
+
name: "testAction",
|
|
20157
|
+
arguments: '{"test":"value"}'
|
|
20158
|
+
},
|
|
20159
|
+
type: "function"
|
|
20160
|
+
}
|
|
20161
|
+
],
|
|
20162
|
+
generativeUI: globalExpect.any(Function),
|
|
20163
|
+
name: "testAction"
|
|
20164
|
+
});
|
|
20165
|
+
});
|
|
20166
|
+
test3("should handle action execution with empty arguments", () => {
|
|
20167
|
+
const actions = {
|
|
20168
|
+
"*": {
|
|
20169
|
+
name: "*",
|
|
20170
|
+
render: vi.fn((props) => `Args: ${JSON.stringify(props.args)}`)
|
|
20171
|
+
}
|
|
20172
|
+
};
|
|
20173
|
+
const actionExecMsg = new ActionExecutionMessage({
|
|
20174
|
+
id: "action-11",
|
|
20175
|
+
name: "testAction",
|
|
20176
|
+
arguments: {},
|
|
20177
|
+
parentMessageId: "parent-11"
|
|
20178
|
+
});
|
|
20179
|
+
const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg, actions);
|
|
20180
|
+
globalExpect(result).toMatchObject({
|
|
20181
|
+
id: "action-11",
|
|
20182
|
+
role: "assistant",
|
|
20183
|
+
content: "",
|
|
20184
|
+
toolCalls: [
|
|
20185
|
+
{
|
|
20186
|
+
id: "action-11",
|
|
20187
|
+
function: {
|
|
20188
|
+
name: "testAction",
|
|
20189
|
+
arguments: "{}"
|
|
20190
|
+
},
|
|
20191
|
+
type: "function"
|
|
20192
|
+
}
|
|
20193
|
+
],
|
|
20194
|
+
generativeUI: globalExpect.any(Function),
|
|
20195
|
+
name: "testAction"
|
|
20196
|
+
});
|
|
20197
|
+
});
|
|
20198
|
+
test3("should handle action execution with null arguments", () => {
|
|
20199
|
+
const actions = {
|
|
20200
|
+
"*": {
|
|
20201
|
+
name: "*",
|
|
20202
|
+
render: vi.fn((props) => `Args: ${JSON.stringify(props.args)}`)
|
|
20203
|
+
}
|
|
20204
|
+
};
|
|
20205
|
+
const actionExecMsg = new ActionExecutionMessage({
|
|
20206
|
+
id: "action-12",
|
|
20207
|
+
name: "testAction",
|
|
20208
|
+
arguments: null,
|
|
20209
|
+
parentMessageId: "parent-12"
|
|
20210
|
+
});
|
|
20211
|
+
const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg, actions);
|
|
20212
|
+
globalExpect(result).toMatchObject({
|
|
20213
|
+
id: "action-12",
|
|
20214
|
+
role: "assistant",
|
|
20215
|
+
content: "",
|
|
20216
|
+
toolCalls: [
|
|
20217
|
+
{
|
|
20218
|
+
id: "action-12",
|
|
20219
|
+
function: {
|
|
20220
|
+
name: "testAction",
|
|
20221
|
+
arguments: "null"
|
|
20222
|
+
},
|
|
20223
|
+
type: "function"
|
|
20224
|
+
}
|
|
20225
|
+
],
|
|
20226
|
+
generativeUI: globalExpect.any(Function),
|
|
20227
|
+
name: "testAction"
|
|
20228
|
+
});
|
|
20229
|
+
});
|
|
20230
|
+
test3("should handle action execution with complex nested arguments", () => {
|
|
20231
|
+
const actions = {
|
|
20232
|
+
"*": {
|
|
20233
|
+
name: "*",
|
|
20234
|
+
render: vi.fn((props) => `Complex: ${JSON.stringify(props.args)}`)
|
|
20235
|
+
}
|
|
20236
|
+
};
|
|
20237
|
+
const complexArgs = {
|
|
20238
|
+
nested: {
|
|
20239
|
+
array: [1, 2, 3],
|
|
20240
|
+
object: { key: "value" },
|
|
20241
|
+
nullValue: null,
|
|
20242
|
+
undefinedValue: void 0
|
|
20243
|
+
},
|
|
20244
|
+
string: "test",
|
|
20245
|
+
number: 42,
|
|
20246
|
+
boolean: true
|
|
20247
|
+
};
|
|
20248
|
+
const actionExecMsg = new ActionExecutionMessage({
|
|
20249
|
+
id: "action-13",
|
|
20250
|
+
name: "testAction",
|
|
20251
|
+
arguments: complexArgs,
|
|
20252
|
+
parentMessageId: "parent-13"
|
|
20253
|
+
});
|
|
20254
|
+
const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg, actions);
|
|
20255
|
+
globalExpect(result).toMatchObject({
|
|
20256
|
+
id: "action-13",
|
|
20257
|
+
role: "assistant",
|
|
20258
|
+
content: "",
|
|
20259
|
+
toolCalls: [
|
|
20260
|
+
{
|
|
20261
|
+
id: "action-13",
|
|
20262
|
+
function: {
|
|
20263
|
+
name: "testAction",
|
|
20264
|
+
arguments: JSON.stringify(complexArgs)
|
|
20265
|
+
},
|
|
20266
|
+
type: "function"
|
|
20267
|
+
}
|
|
20268
|
+
],
|
|
20269
|
+
generativeUI: globalExpect.any(Function),
|
|
20270
|
+
name: "testAction"
|
|
20271
|
+
});
|
|
20272
|
+
});
|
|
20273
|
+
test3("should handle multiple wild card actions (should use first one)", () => {
|
|
20274
|
+
const actions = {
|
|
20275
|
+
wildcard1: {
|
|
20276
|
+
name: "*",
|
|
20277
|
+
render: vi.fn((props) => "First wildcard")
|
|
20278
|
+
},
|
|
20279
|
+
wildcard2: {
|
|
20280
|
+
name: "*",
|
|
20281
|
+
render: vi.fn((props) => "Second wildcard")
|
|
20282
|
+
}
|
|
20283
|
+
};
|
|
20284
|
+
const actionExecMsg = new ActionExecutionMessage({
|
|
20285
|
+
id: "action-14",
|
|
20286
|
+
name: "unknownAction",
|
|
20287
|
+
arguments: { test: "value" },
|
|
20288
|
+
parentMessageId: "parent-14"
|
|
20289
|
+
});
|
|
20290
|
+
const result = gqlActionExecutionMessageToAGUIMessage(actionExecMsg, actions);
|
|
20291
|
+
globalExpect(result).toMatchObject({
|
|
20292
|
+
id: "action-14",
|
|
20293
|
+
role: "assistant",
|
|
20294
|
+
content: "",
|
|
20295
|
+
toolCalls: [
|
|
20296
|
+
{
|
|
20297
|
+
id: "action-14",
|
|
20298
|
+
function: {
|
|
20299
|
+
name: "unknownAction",
|
|
20300
|
+
arguments: '{"test":"value"}'
|
|
20301
|
+
},
|
|
20302
|
+
type: "function"
|
|
20303
|
+
}
|
|
20304
|
+
],
|
|
20305
|
+
generativeUI: globalExpect.any(Function),
|
|
20306
|
+
name: "unknownAction"
|
|
20307
|
+
});
|
|
20308
|
+
});
|
|
20309
|
+
});
|
|
19842
20310
|
});
|
|
19843
20311
|
/*! Bundled license information:
|
|
19844
20312
|
|