@cognigy/rest-api-client 2025.24.0 → 2026.1.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 (123) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/build/apigroups/ResourcesAPIGroup_2_0.js +14 -0
  3. package/build/apigroups/SimulationAPIGroup_2_0.js +15 -1
  4. package/build/authentication/AuthenticationAPI.js +1 -0
  5. package/build/shared/charts/createNodeDescriptor.js +1 -0
  6. package/build/shared/charts/descriptors/analytics/overwriteAnalytics.js +14 -0
  7. package/build/shared/charts/descriptors/analytics/updateProfile.js +5 -0
  8. package/build/shared/charts/descriptors/connectionNodes/smtp/emailNotification.js +7 -0
  9. package/build/shared/charts/descriptors/connectionNodes/smtp/sendEmail.js +9 -0
  10. package/build/shared/charts/descriptors/index.js +7 -1
  11. package/build/shared/charts/descriptors/message/question/question.js +5 -0
  12. package/build/shared/charts/descriptors/message/say.js +3 -0
  13. package/build/shared/charts/descriptors/placeholder.js +3 -0
  14. package/build/shared/charts/descriptors/service/agentTools/executeWorkflowTool.js +239 -0
  15. package/build/shared/charts/descriptors/service/agentTools/handoverToAiAgentTool.js +192 -0
  16. package/build/shared/charts/descriptors/service/agentTools/handoverToHumanAgentTool.js +783 -0
  17. package/build/shared/charts/descriptors/service/agentTools/sendEmailTool.js +272 -0
  18. package/build/shared/charts/descriptors/service/aiAgent/aiAgentJob.js +23 -20
  19. package/build/shared/charts/descriptors/service/aiAgent/aiAgentJobCallMCPTool.js +4 -2
  20. package/build/shared/charts/descriptors/service/aiAgent/helpers/createToolDefinitions.js +3 -1
  21. package/build/shared/charts/descriptors/service/aiAgent/helpers/parseMcpHeaders.js +26 -0
  22. package/build/shared/charts/descriptors/service/cxone/knowledgehub/CXoneKnowledgehub.js +198 -0
  23. package/build/shared/charts/descriptors/service/cxone/knowledgehub/CXoneKnowledgehubConnection.js +16 -0
  24. package/build/shared/charts/descriptors/service/cxone/knowledgehub/CXoneKnowledgehubForm.js +300 -0
  25. package/build/shared/charts/descriptors/service/cxone/knowledgehub/CXoneKnowledgehubProviderModule.js +16 -0
  26. package/build/shared/charts/descriptors/service/handoverV2.js +1 -1
  27. package/build/shared/charts/descriptors/service/httpRequest.js +3 -0
  28. package/build/shared/charts/descriptors/service/index.js +9 -1
  29. package/build/shared/charts/descriptors/service/llmPrompt/LLMPromptV2.js +11 -4
  30. package/build/shared/charts/descriptors/voice/mappers/setSessionConfig.mapper.js +29 -27
  31. package/build/shared/charts/descriptors/voice/mappers/transfer.mapper.js +5 -5
  32. package/build/shared/charts/descriptors/voice/nodes/sessionSpeechParameters.js +2 -2
  33. package/build/shared/charts/descriptors/voicegateway2/nodes/setSessionConfig.js +13 -4
  34. package/build/shared/charts/descriptors/voicegateway2/nodes/transfer.js +4 -4
  35. package/build/shared/constants.js +2 -1
  36. package/build/shared/interfaces/IOrganisation.js +1 -0
  37. package/build/shared/interfaces/amqpInterface.js +1 -0
  38. package/build/shared/interfaces/cxone/knowledgehub/CXoneKnowledgehubAPI.js +3 -0
  39. package/build/shared/interfaces/messageAPI/endpoints.js +1 -1
  40. package/build/shared/interfaces/resources/IAuditEvent.js +1 -0
  41. package/build/shared/interfaces/resources/IChart.js +10 -1
  42. package/build/shared/interfaces/resources/IChartNode.js +32 -4
  43. package/build/shared/interfaces/resources/IEndpoint.js +1 -0
  44. package/build/shared/interfaces/resources/INodeDescriptorSet.js +8 -0
  45. package/build/shared/interfaces/resources/TResourceType.js +1 -0
  46. package/build/shared/interfaces/resources/chart/IChartExecutableNode.js +10 -1
  47. package/build/shared/interfaces/resources/knowledgeStore/IKnowledgeConnector.js +49 -0
  48. package/build/shared/interfaces/resources/knowledgeStore/IKnowledgeSource.js +1 -1
  49. package/build/shared/interfaces/restAPI/administration/user/v2.0/IExchangeCXoneTokenRest_2_0.js +3 -0
  50. package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/connector/ICreateKnowledgeConnectorRest_2_0.js +3 -0
  51. package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/connector/IDeleteKnowledgeConnectorRest_2_0.js +3 -0
  52. package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/connector/IIndexKnowledgeConnectorsRest_2_0.js +3 -0
  53. package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/connector/IKnowledgeConnector_2_0.js +3 -0
  54. package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/connector/IReadKnowledgeConnectorRest_2_0.js +3 -0
  55. package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/connector/IUpdateKnowledgeConnectorRest_2_0.js +3 -0
  56. package/build/shared/interfaces/restAPI/simulation/scheduler/ICreateSchedulerRest_2_0.js +3 -0
  57. package/build/shared/interfaces/restAPI/simulation/scheduler/IGetSchedulerRest_2_0.js +3 -0
  58. package/build/shared/interfaces/restAPI/simulation/scheduler/ISchedulerRest_2_0.js +12 -0
  59. package/build/shared/interfaces/restAPI/simulation/scheduler/IUpdateSchedulerRest_2_0.js +3 -0
  60. package/build/shared/interfaces/restAPI/simulation/simulationRun/ISimulationRunRest_2_0.js +15 -1
  61. package/build/shared/interfaces/restAPI/simulation/simulationRunBatch/ISimulationRunBatchRest_2_0.js +6 -1
  62. package/dist/esm/apigroups/ResourcesAPIGroup_2_0.js +14 -0
  63. package/dist/esm/apigroups/SimulationAPIGroup_2_0.js +15 -1
  64. package/dist/esm/authentication/AuthenticationAPI.js +1 -0
  65. package/dist/esm/shared/charts/createNodeDescriptor.js +1 -0
  66. package/dist/esm/shared/charts/descriptors/analytics/overwriteAnalytics.js +14 -0
  67. package/dist/esm/shared/charts/descriptors/analytics/updateProfile.js +5 -0
  68. package/dist/esm/shared/charts/descriptors/connectionNodes/smtp/emailNotification.js +7 -0
  69. package/dist/esm/shared/charts/descriptors/connectionNodes/smtp/sendEmail.js +9 -0
  70. package/dist/esm/shared/charts/descriptors/index.js +6 -1
  71. package/dist/esm/shared/charts/descriptors/message/question/question.js +5 -0
  72. package/dist/esm/shared/charts/descriptors/message/say.js +3 -0
  73. package/dist/esm/shared/charts/descriptors/placeholder.js +3 -0
  74. package/dist/esm/shared/charts/descriptors/service/agentTools/executeWorkflowTool.js +237 -0
  75. package/dist/esm/shared/charts/descriptors/service/agentTools/handoverToAiAgentTool.js +190 -0
  76. package/dist/esm/shared/charts/descriptors/service/agentTools/handoverToHumanAgentTool.js +770 -0
  77. package/dist/esm/shared/charts/descriptors/service/agentTools/sendEmailTool.js +270 -0
  78. package/dist/esm/shared/charts/descriptors/service/aiAgent/aiAgentJob.js +23 -20
  79. package/dist/esm/shared/charts/descriptors/service/aiAgent/aiAgentJobCallMCPTool.js +4 -2
  80. package/dist/esm/shared/charts/descriptors/service/aiAgent/helpers/createToolDefinitions.js +3 -1
  81. package/dist/esm/shared/charts/descriptors/service/aiAgent/helpers/parseMcpHeaders.js +25 -0
  82. package/dist/esm/shared/charts/descriptors/service/cxone/knowledgehub/CXoneKnowledgehub.js +196 -0
  83. package/dist/esm/shared/charts/descriptors/service/cxone/knowledgehub/CXoneKnowledgehubConnection.js +13 -0
  84. package/dist/esm/shared/charts/descriptors/service/cxone/knowledgehub/CXoneKnowledgehubForm.js +297 -0
  85. package/dist/esm/shared/charts/descriptors/service/cxone/knowledgehub/CXoneKnowledgehubProviderModule.js +13 -0
  86. package/dist/esm/shared/charts/descriptors/service/handoverV2.js +1 -1
  87. package/dist/esm/shared/charts/descriptors/service/httpRequest.js +3 -0
  88. package/dist/esm/shared/charts/descriptors/service/index.js +4 -0
  89. package/dist/esm/shared/charts/descriptors/service/llmPrompt/LLMPromptV2.js +11 -4
  90. package/dist/esm/shared/charts/descriptors/voice/mappers/setSessionConfig.mapper.js +29 -27
  91. package/dist/esm/shared/charts/descriptors/voice/mappers/transfer.mapper.js +5 -5
  92. package/dist/esm/shared/charts/descriptors/voice/nodes/sessionSpeechParameters.js +2 -2
  93. package/dist/esm/shared/charts/descriptors/voicegateway2/nodes/setSessionConfig.js +13 -4
  94. package/dist/esm/shared/charts/descriptors/voicegateway2/nodes/transfer.js +4 -4
  95. package/dist/esm/shared/constants.js +1 -0
  96. package/dist/esm/shared/interfaces/IOrganisation.js +1 -0
  97. package/dist/esm/shared/interfaces/amqpInterface.js +1 -0
  98. package/dist/esm/shared/interfaces/cxone/knowledgehub/CXoneKnowledgehubAPI.js +2 -0
  99. package/dist/esm/shared/interfaces/messageAPI/endpoints.js +1 -1
  100. package/dist/esm/shared/interfaces/resources/IAuditEvent.js +1 -0
  101. package/dist/esm/shared/interfaces/resources/IChart.js +10 -1
  102. package/dist/esm/shared/interfaces/resources/IChartNode.js +32 -4
  103. package/dist/esm/shared/interfaces/resources/IEndpoint.js +1 -0
  104. package/dist/esm/shared/interfaces/resources/INodeDescriptorSet.js +8 -0
  105. package/dist/esm/shared/interfaces/resources/TResourceType.js +1 -0
  106. package/dist/esm/shared/interfaces/resources/chart/IChartExecutableNode.js +10 -1
  107. package/dist/esm/shared/interfaces/resources/knowledgeStore/IKnowledgeConnector.js +46 -0
  108. package/dist/esm/shared/interfaces/resources/knowledgeStore/IKnowledgeSource.js +1 -1
  109. package/dist/esm/shared/interfaces/restAPI/administration/user/v2.0/IExchangeCXoneTokenRest_2_0.js +2 -0
  110. package/dist/esm/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/connector/ICreateKnowledgeConnectorRest_2_0.js +2 -0
  111. package/dist/esm/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/connector/IDeleteKnowledgeConnectorRest_2_0.js +2 -0
  112. package/dist/esm/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/connector/IIndexKnowledgeConnectorsRest_2_0.js +2 -0
  113. package/dist/esm/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/connector/IKnowledgeConnector_2_0.js +2 -0
  114. package/dist/esm/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/connector/IReadKnowledgeConnectorRest_2_0.js +2 -0
  115. package/dist/esm/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/connector/IUpdateKnowledgeConnectorRest_2_0.js +2 -0
  116. package/dist/esm/shared/interfaces/restAPI/simulation/scheduler/ICreateSchedulerRest_2_0.js +2 -0
  117. package/dist/esm/shared/interfaces/restAPI/simulation/scheduler/IGetSchedulerRest_2_0.js +2 -0
  118. package/dist/esm/shared/interfaces/restAPI/simulation/scheduler/ISchedulerRest_2_0.js +9 -0
  119. package/dist/esm/shared/interfaces/restAPI/simulation/scheduler/IUpdateSchedulerRest_2_0.js +2 -0
  120. package/dist/esm/shared/interfaces/restAPI/simulation/simulationRun/ISimulationRunRest_2_0.js +14 -0
  121. package/dist/esm/shared/interfaces/restAPI/simulation/simulationRunBatch/ISimulationRunBatchRest_2_0.js +5 -0
  122. package/package.json +1 -1
  123. package/types/index.d.ts +727 -29
@@ -0,0 +1,272 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SEND_EMAIL_TOOL = void 0;
4
+ /* Custom modules */
5
+ const createNodeDescriptor_1 = require("../../../createNodeDescriptor");
6
+ const transcripts_1 = require("../../../../interfaces/transcripts/transcripts");
7
+ exports.SEND_EMAIL_TOOL = (0, createNodeDescriptor_1.createNodeDescriptor)({
8
+ type: "sendEmailTool",
9
+ defaultLabel: "Send Email Tool",
10
+ parentType: ["aiAgentJob", "llmPromptV2"],
11
+ constraints: {
12
+ editable: true,
13
+ deletable: true,
14
+ collapsable: true,
15
+ creatable: true,
16
+ movable: true,
17
+ placement: {
18
+ predecessor: {
19
+ whitelist: []
20
+ }
21
+ },
22
+ childFlowCreatable: false
23
+ },
24
+ behavior: {
25
+ stopping: true
26
+ },
27
+ preview: {
28
+ type: "text",
29
+ key: "toolId"
30
+ },
31
+ fields: [
32
+ {
33
+ key: "toolId",
34
+ label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__TOOL_ID__LABEL",
35
+ description: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__TOOL_ID__DESCRIPTION",
36
+ type: "cognigyLLMText",
37
+ defaultValue: "send_email",
38
+ params: {
39
+ required: true,
40
+ rows: 1,
41
+ multiline: false,
42
+ maxLength: 64,
43
+ }
44
+ },
45
+ {
46
+ key: "description",
47
+ label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__DESCRIPTION__LABEL",
48
+ description: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__DESCRIPTION__DESCRIPTION",
49
+ type: "cognigyLLMText",
50
+ defaultValue: "Create and send a new email message.",
51
+ params: {
52
+ required: true,
53
+ rows: 5,
54
+ multiline: true
55
+ }
56
+ },
57
+ {
58
+ key: "recipient",
59
+ label: "UI__NODE_EDITOR__SMTP__EMAIL_NOTIFICATION__RECIPIENT__LABEL",
60
+ description: "UI__NODE_EDITOR__SMTP__EMAIL_NOTIFICATION__RECIPIENT__DESCRIPTION",
61
+ type: "cognigyText",
62
+ params: {
63
+ required: true,
64
+ rows: 1,
65
+ multiline: false,
66
+ maxLength: 255,
67
+ },
68
+ },
69
+ {
70
+ key: "cc",
71
+ type: "cognigyText",
72
+ label: "UI__NODE_EDITOR__SMTP__EMAIL_NOTIFICATION__CC__LABEL",
73
+ description: "UI__NODE_EDITOR__SMTP__EMAIL_NOTIFICATION__CC__DESCRIPTION",
74
+ },
75
+ {
76
+ key: "bcc",
77
+ type: "cognigyText",
78
+ label: "UI__NODE_EDITOR__SMTP__EMAIL_NOTIFICATION__BCC__LABEL",
79
+ description: "UI__NODE_EDITOR__SMTP__EMAIL_NOTIFICATION__BCC__DESCRIPTION",
80
+ },
81
+ {
82
+ key: "priority",
83
+ type: "select",
84
+ label: "UI__NODE_EDITOR__SMTP__EMAIL_NOTIFICATION__PRIORITY__LABEL",
85
+ defaultValue: "normal",
86
+ params: {
87
+ options: [
88
+ { label: "UI__NODE_EDITOR__SMTP__EMAIL_NOTIFICATION__PRIORITY__HIGH__LABEL", value: "high" },
89
+ { label: "UI__NODE_EDITOR__SMTP__EMAIL_NOTIFICATION__PRIORITY__NORMAL__LABEL", value: "normal" },
90
+ { label: "UI__NODE_EDITOR__SMTP__EMAIL_NOTIFICATION__PRIORITY__LOW__LABEL", value: "low" }
91
+ ]
92
+ }
93
+ },
94
+ {
95
+ key: "parameters",
96
+ label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__PARAMETERS__LABEL",
97
+ type: "toolParameters",
98
+ defaultValue: `{
99
+ "type": "object",
100
+ "properties": {
101
+ "subject": {
102
+ "type": "string",
103
+ "description": "The subject of the email."
104
+ },
105
+ "message": {
106
+ "type": "string",
107
+ "description": "The body of the email."
108
+ }
109
+ },
110
+ "required": ["subject", "message"],
111
+ "additionalProperties": false
112
+ }`,
113
+ },
114
+ {
115
+ key: "debugMessage",
116
+ type: "toggle",
117
+ label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__DEBUG_MESSAGE__LABEL",
118
+ description: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__DEBUG_MESSAGE__DESCRIPTION",
119
+ defaultValue: true,
120
+ },
121
+ {
122
+ key: "condition",
123
+ label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__CONDITION__LABEL",
124
+ description: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__CONDITION__DESCRIPTION",
125
+ type: "cognigyText",
126
+ defaultValue: "",
127
+ },
128
+ ],
129
+ sections: [
130
+ {
131
+ key: "debugging",
132
+ label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_JOB__SECTIONS__DEBUG_SETTINGS__LABEL",
133
+ defaultCollapsed: true,
134
+ fields: [
135
+ "debugMessage",
136
+ ],
137
+ },
138
+ {
139
+ key: "advanced",
140
+ label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_JOB__SECTIONS__ADVANCED__LABEL",
141
+ defaultCollapsed: true,
142
+ fields: [
143
+ "cc",
144
+ "bcc",
145
+ "priority",
146
+ "condition"
147
+ ]
148
+ },
149
+ ],
150
+ form: [
151
+ { type: "field", key: "toolId" },
152
+ { type: "field", key: "description" },
153
+ { type: "field", key: "recipient" },
154
+ { type: "section", key: "debugging" },
155
+ { type: "section", key: "advanced" },
156
+ ],
157
+ appearance: {
158
+ color: "white",
159
+ textColor: "#252525",
160
+ variant: "mini",
161
+ },
162
+ function: async ({ cognigy, config, nodeId, nodeType, organisationId, projectId, childConfigs }) => {
163
+ var _a, _b, _c, _d, _e, _f, _g;
164
+ const { api, context, input } = cognigy;
165
+ const { debugMessage, recipient, cc, bcc, priority, } = config;
166
+ const sessionState = await api.loadSessionState();
167
+ const toolCall = (_a = sessionState.lastToolCall) === null || _a === void 0 ? void 0 : _a.toolCall;
168
+ const aiAgentJobNode = (_b = sessionState.lastToolCall) === null || _b === void 0 ? void 0 : _b.aiAgentJobNode;
169
+ if (!(toolCall === null || toolCall === void 0 ? void 0 : toolCall.id)) {
170
+ (_c = api.logDebugError) === null || _c === void 0 ? void 0 : _c.call(api, "UI__DEBUG_MODE__AI_AGENT_ANSWER__ERROR__MESSAGE");
171
+ }
172
+ if (toolCall && aiAgentJobNode) {
173
+ if (!((_d = api.checkThink) === null || _d === void 0 ? void 0 : _d.call(api, nodeId))) {
174
+ const { subject, message } = toolCall.function.arguments;
175
+ let result;
176
+ try {
177
+ result = await ((_e = api === null || api === void 0 ? void 0 : api.emailNotification) === null || _e === void 0 ? void 0 : _e.call(api, {
178
+ cognigy,
179
+ config: {
180
+ recipient,
181
+ subject,
182
+ message,
183
+ cc: cc || "",
184
+ bcc: bcc || "",
185
+ priority: priority || "normal",
186
+ async: false,
187
+ storeLocation: "none",
188
+ inputKey: "",
189
+ contextKey: "",
190
+ stopOnError: false,
191
+ senderName: "",
192
+ },
193
+ nodeId,
194
+ nodeType,
195
+ organisationId,
196
+ projectId,
197
+ childConfigs,
198
+ }));
199
+ }
200
+ catch (error) {
201
+ // Log error message to debug mode
202
+ const errorMessage = error instanceof Error ? error.message : String(error);
203
+ (_f = api.logDebugError) === null || _f === void 0 ? void 0 : _f.call(api, errorMessage, "UI__DEBUG_MODE__AI_AGENT__SEND_EMAIL_TOOL__ERROR");
204
+ // Pass error message to LLM as result
205
+ result = errorMessage;
206
+ }
207
+ // Optional Debug Message of Email sending and response
208
+ if (debugMessage) {
209
+ const messageLines = [];
210
+ if (recipient) {
211
+ messageLines.push(`\n<b>UI__DEBUG_MODE__AI_AGENT__SEND_EMAIL_TOOL__RECIPIENT</b> ${recipient}`);
212
+ }
213
+ if (subject) {
214
+ messageLines.push(`\n<b>UI__DEBUG_MODE__AI_AGENT__SEND_EMAIL_TOOL__SUBJECT</b> ${subject}`);
215
+ }
216
+ if (message) {
217
+ messageLines.push(`\n<b>UI__DEBUG_MODE__AI_AGENT__SEND_EMAIL_TOOL__MESSAGE</b> ${message}`);
218
+ }
219
+ if (result) {
220
+ const resultString = typeof result === 'string' ? result : JSON.stringify(result, null, 2);
221
+ messageLines.push(`\n<b>UI__DEBUG_MODE__AI_AGENT__SEND_EMAIL_TOOL__RESULT</b>\n${resultString}`);
222
+ }
223
+ (_g = api.logDebugMessage) === null || _g === void 0 ? void 0 : _g.call(api, messageLines.join("\n"), "UI__DEBUG_MODE__AI_AGENT__SEND_EMAIL_TOOL__HEADER");
224
+ }
225
+ const { flow, node } = aiAgentJobNode;
226
+ if (flow && node) {
227
+ // Add Tool Call Message to Transcript
228
+ const toolCallTranscriptStep = {
229
+ role: transcripts_1.TranscriptRole.ASSISTANT,
230
+ type: transcripts_1.TranscriptEntryType.TOOL_CALL,
231
+ source: "system",
232
+ payload: {
233
+ name: toolCall.function.name,
234
+ id: toolCall.id,
235
+ input: toolCall.function.arguments,
236
+ }
237
+ };
238
+ await api.addTranscriptStep(toolCallTranscriptStep);
239
+ // Add Tool Answer Message to Transcript
240
+ const resultString = typeof result === 'string' ? result : JSON.stringify(result);
241
+ const toolAnswer = {
242
+ role: transcripts_1.TranscriptRole.TOOL,
243
+ type: transcripts_1.TranscriptEntryType.TOOL_ANSWER,
244
+ source: "system",
245
+ payload: {
246
+ toolCallId: toolCall.id,
247
+ name: toolCall.function.name,
248
+ content: `Send email result:\n${resultString}`,
249
+ }
250
+ };
251
+ await api.addTranscriptStep(toolAnswer);
252
+ api.resetNextNodes();
253
+ // remove the call from the session state, because the call has been answered
254
+ api.updateSessionStateValues({
255
+ lastToolCall: undefined
256
+ });
257
+ await api.executeFlow({
258
+ flowNode: {
259
+ flow,
260
+ node,
261
+ },
262
+ absorbContext: true,
263
+ });
264
+ }
265
+ }
266
+ else {
267
+ throw new Error("Infinite Loop Detected");
268
+ }
269
+ }
270
+ }
271
+ });
272
+ //# sourceMappingURL=sendEmailTool.js.map
@@ -23,8 +23,9 @@ const createSystemMessage_1 = require("./helpers/createSystemMessage");
23
23
  const generateSearchPrompt_1 = require("./helpers/generateSearchPrompt");
24
24
  const getUserMemory_1 = require("./helpers/getUserMemory");
25
25
  const createToolDefinitions_1 = require("./helpers/createToolDefinitions");
26
+ const parseMcpHeaders_1 = require("./helpers/parseMcpHeaders");
26
27
  const transcripts_1 = require("../../../../interfaces/transcripts/transcripts");
27
- exports.AI_AGENT_TOOLS_WHITELIST = ["aiAgentJobDefault", "aiAgentJobTool", "aiAgentJobMCPTool", "knowledgeTool"];
28
+ exports.AI_AGENT_TOOLS_WHITELIST = ["aiAgentJobDefault", "aiAgentJobTool", "aiAgentJobMCPTool", "knowledgeTool", "handoverToAiAgentTool", "handoverToHumanAgentTool", "sendEmailTool", "executeWorkflowTool"];
28
29
  exports.AI_AGENT_JOB = (0, createNodeDescriptor_1.createNodeDescriptor)({
29
30
  type: "aiAgentJob",
30
31
  defaultLabel: "AI Agent",
@@ -926,7 +927,7 @@ exports.AI_AGENT_JOB = (0, createNodeDescriptor_1.createNodeDescriptor)({
926
927
  ],
927
928
  tags: ["ai", "aiAgent"],
928
929
  function: async ({ cognigy, config, childConfigs, nodeId }) => {
929
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24;
930
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25;
930
931
  const { api, context, input, profile, flowReferenceId } = cognigy;
931
932
  const { aiAgent, llmProviderReferenceId, name: jobName, description: jobDescription, instructions: jobInstructions, outputImmediately, toolChoice, useStrict, memoryType, selectedProfileFields, memoryContextInjection, knowledgeSearchBehavior, knowledgeSearchTags, knowledgeSearchTagsFilterOp, knowledgeSearchAiAgentKnowledge, knowledgeSearchJobKnowledge, knowledgeSearchJobStore, knowledgeSearchGenerateSearchPrompt, knowledgeSearchTopK, timeoutInMs, maxTokens, temperature, useTextAlternativeForLLM, advancedLogging, loggingWebhookUrl, loggingCustomData, conditionForLogging, logErrorToSystem, storeErrorInInput, errorHandling, errorHandlingGotoTarget, errorMessage, debugConfig, debugLogTokenCount, debugLogSystemPrompt, debugLogToolDefinitions, debugResult, debugLogLLMLatency, storeLocation, contextKey, inputKey, streamStoreCopyInInput, streamStopTokens, processImages, transcriptImageHandling, loggingHeaders, sessionParams } = config;
932
933
  try {
@@ -976,7 +977,7 @@ exports.AI_AGENT_JOB = (0, createNodeDescriptor_1.createNodeDescriptor)({
976
977
  throw new Error(`[VG2] Error on AI Agent Job node. Error message: ${error.message}`);
977
978
  }
978
979
  }
979
- const _25 = profile, { profileId, accepted_gdpr, prevent_data_collection, privacy_policy } = _25, cleanedProfile = __rest(_25, ["profileId", "accepted_gdpr", "prevent_data_collection", "privacy_policy"]);
980
+ const _26 = profile, { profileId, accepted_gdpr, prevent_data_collection, privacy_policy } = _26, cleanedProfile = __rest(_26, ["profileId", "accepted_gdpr", "prevent_data_collection", "privacy_policy"]);
980
981
  const userMemory = (0, getUserMemory_1.getUserMemory)(memoryType, selectedProfileFields, aiAgent, cleanedProfile);
981
982
  /**
982
983
  * ----- Knowledge Search Section -----
@@ -1303,13 +1304,15 @@ exports.AI_AGENT_JOB = (0, createNodeDescriptor_1.createNodeDescriptor)({
1303
1304
  break;
1304
1305
  }
1305
1306
  }
1307
+ let mcpHeaders = (_7 = toolChild === null || toolChild === void 0 ? void 0 : toolChild.config) === null || _7 === void 0 ? void 0 : _7.mcpHeaders;
1306
1308
  if (!toolChild && toolMap.has(mainToolCall.function.name)) {
1307
1309
  // If the tool call is from an MCP tool, set the next node to the corresponding child node
1308
1310
  toolChild = childConfigs.find(child => child.id === toolMap.get(mainToolCall.function.name));
1309
1311
  isMcpToolCall = true;
1312
+ mcpHeaders = await (0, parseMcpHeaders_1.parseMcpHeaders)((_8 = toolChild === null || toolChild === void 0 ? void 0 : toolChild.config) === null || _8 === void 0 ? void 0 : _8.mcpHeaders, api);
1310
1313
  }
1311
1314
  if (mainToolCall.function.name !== "retrieve_knowledge" && toolChild === undefined) {
1312
- (_7 = api.logDebugError) === null || _7 === void 0 ? void 0 : _7.call(api, `UI__DEBUG_MODE__AI_AGENT_JOB__TOOL_CALL__ERROR__BODY <b>${mainToolCall.function.name}</b>`, "UI__DEBUG_MODE__AI_AGENT_JOB__TOOL_CALL__ERROR__HEADER");
1315
+ (_9 = api.logDebugError) === null || _9 === void 0 ? void 0 : _9.call(api, `UI__DEBUG_MODE__AI_AGENT_JOB__TOOL_CALL__ERROR__BODY <b>${mainToolCall.function.name}</b>`, "UI__DEBUG_MODE__AI_AGENT_JOB__TOOL_CALL__ERROR__HEADER");
1313
1316
  }
1314
1317
  // Add last tool call to session state for loading it from Tool Answer Node
1315
1318
  api.updateSessionStateValues({
@@ -1317,22 +1320,22 @@ exports.AI_AGENT_JOB = (0, createNodeDescriptor_1.createNodeDescriptor)({
1317
1320
  flow: flowReferenceId,
1318
1321
  node: nodeId,
1319
1322
  } }, (isMcpToolCall && {
1320
- mcpServerUrl: (_8 = toolChild === null || toolChild === void 0 ? void 0 : toolChild.config) === null || _8 === void 0 ? void 0 : _8.mcpServerUrl,
1321
- mcpHeaders: (_9 = toolChild === null || toolChild === void 0 ? void 0 : toolChild.config) === null || _9 === void 0 ? void 0 : _9.mcpHeaders,
1322
- timeout: (_10 = toolChild === null || toolChild === void 0 ? void 0 : toolChild.config) === null || _10 === void 0 ? void 0 : _10.timeout,
1323
+ mcpServerUrl: (_10 = toolChild === null || toolChild === void 0 ? void 0 : toolChild.config) === null || _10 === void 0 ? void 0 : _10.mcpServerUrl,
1324
+ mcpHeaders,
1325
+ timeout: (_11 = toolChild === null || toolChild === void 0 ? void 0 : toolChild.config) === null || _11 === void 0 ? void 0 : _11.timeout,
1323
1326
  mcpToolNode: toolChild === null || toolChild === void 0 ? void 0 : toolChild.id,
1324
1327
  })), { toolCall: mainToolCall }),
1325
1328
  });
1326
1329
  // if there are any parameters/arguments, add them to the input slots
1327
1330
  if (mainToolCall.function.arguments) {
1328
- input.aiAgent = Object.assign(Object.assign({}, input.aiAgent), { toolArgs: Object.assign(Object.assign({}, (_12 = (_11 = input.aiAgent) === null || _11 === void 0 ? void 0 : _11.toolArgs) !== null && _12 !== void 0 ? _12 : {}), mainToolCall.function.arguments) });
1331
+ input.aiAgent = Object.assign(Object.assign({}, input.aiAgent), { toolArgs: Object.assign(Object.assign({}, (_13 = (_12 = input.aiAgent) === null || _12 === void 0 ? void 0 : _12.toolArgs) !== null && _13 !== void 0 ? _13 : {}), mainToolCall.function.arguments) });
1329
1332
  }
1330
1333
  // Debug Message for Tool Calls, configured in the Tool Node
1331
- if ((_13 = toolChild === null || toolChild === void 0 ? void 0 : toolChild.config) === null || _13 === void 0 ? void 0 : _13.debugMessage) {
1334
+ if ((_14 = toolChild === null || toolChild === void 0 ? void 0 : toolChild.config) === null || _14 === void 0 ? void 0 : _14.debugMessage) {
1332
1335
  const toolId = isMcpToolCall ? mainToolCall.function.name : await api.parseCognigyScriptText(toolChild.config.toolId);
1333
1336
  const messageLines = [`<b>UI__DEBUG_MODE__AI_AGENT_JOB__TOOL_CALL__DEBUG_MESSAGE__HEADER:</b> ${toolId}`];
1334
1337
  // Arguments / Parameters Slots
1335
- const slots = ((_14 = mainToolCall === null || mainToolCall === void 0 ? void 0 : mainToolCall.function) === null || _14 === void 0 ? void 0 : _14.arguments) && Object.keys(mainToolCall.function.arguments);
1338
+ const slots = ((_15 = mainToolCall === null || mainToolCall === void 0 ? void 0 : mainToolCall.function) === null || _15 === void 0 ? void 0 : _15.arguments) && Object.keys(mainToolCall.function.arguments);
1336
1339
  const hasSlots = slots && slots.length > 0;
1337
1340
  messageLines.push(`<b>UI__DEBUG_MODE__AI_AGENT_JOB__TOOL_CALL__DEBUG_MESSAGE__SLOTS</b>${hasSlots ? "" : " -"}`);
1338
1341
  if (hasSlots) {
@@ -1347,7 +1350,7 @@ exports.AI_AGENT_JOB = (0, createNodeDescriptor_1.createNodeDescriptor)({
1347
1350
  messageLines.push(`- ${slot}: ${slotValueAsString}`);
1348
1351
  });
1349
1352
  }
1350
- (_15 = api.logDebugMessage) === null || _15 === void 0 ? void 0 : _15.call(api, messageLines.join("\n"), "UI__DEBUG_MODE__AI_AGENT_JOB__TOOL_CALL__DEBUG_MESSAGE__HEADER");
1353
+ (_16 = api.logDebugMessage) === null || _16 === void 0 ? void 0 : _16.call(api, messageLines.join("\n"), "UI__DEBUG_MODE__AI_AGENT_JOB__TOOL_CALL__DEBUG_MESSAGE__HEADER");
1351
1354
  }
1352
1355
  if (toolChild) {
1353
1356
  api.setNextNode(toolChild.id);
@@ -1372,11 +1375,11 @@ exports.AI_AGENT_JOB = (0, createNodeDescriptor_1.createNodeDescriptor)({
1372
1375
  }
1373
1376
  // Optionally output the result immediately
1374
1377
  if (llmResult.result && outputImmediately && !llmPromptOptions.stream) {
1375
- await ((_16 = api.output) === null || _16 === void 0 ? void 0 : _16.call(api, llmResult.result, {}));
1378
+ await ((_17 = api.output) === null || _17 === void 0 ? void 0 : _17.call(api, llmResult.result, {}));
1376
1379
  }
1377
1380
  else if (llmResult.finishReason && llmPromptOptions.stream) {
1378
1381
  // send the finishReason as last output for a stream
1379
- (_17 = api.output) === null || _17 === void 0 ? void 0 : _17.call(api, "", {
1382
+ (_18 = api.output) === null || _18 === void 0 ? void 0 : _18.call(api, "", {
1380
1383
  _cognigy: {
1381
1384
  _preventTranscript: true,
1382
1385
  _messageId,
@@ -1399,7 +1402,7 @@ exports.AI_AGENT_JOB = (0, createNodeDescriptor_1.createNodeDescriptor)({
1399
1402
  }
1400
1403
  // Add response to Cognigy Input/Context for further usage
1401
1404
  if (storeLocation === "context") {
1402
- (_18 = api.addToContext) === null || _18 === void 0 ? void 0 : _18.call(api, contextKey, llmResult, "simple");
1405
+ (_19 = api.addToContext) === null || _19 === void 0 ? void 0 : _19.call(api, contextKey, llmResult, "simple");
1403
1406
  }
1404
1407
  else if (storeLocation === "input") {
1405
1408
  api.addToInput(inputKey, llmResult);
@@ -1412,14 +1415,14 @@ exports.AI_AGENT_JOB = (0, createNodeDescriptor_1.createNodeDescriptor)({
1412
1415
  const errorDetails = {
1413
1416
  name: (error === null || error === void 0 ? void 0 : error.name) || "Error",
1414
1417
  code: (error === null || error === void 0 ? void 0 : error.code) || (error === null || error === void 0 ? void 0 : error.httpStatusCode),
1415
- message: (error === null || error === void 0 ? void 0 : error.message) || ((_19 = error.originalErrorDetails) === null || _19 === void 0 ? void 0 : _19.message),
1418
+ message: (error === null || error === void 0 ? void 0 : error.message) || ((_20 = error.originalErrorDetails) === null || _20 === void 0 ? void 0 : _20.message),
1416
1419
  };
1417
- (_20 = api.emitEvent) === null || _20 === void 0 ? void 0 : _20.call(api, "nodeError", { nodeId, flowId: flowReferenceId, errorMessage: error });
1420
+ (_21 = api.emitEvent) === null || _21 === void 0 ? void 0 : _21.call(api, "nodeError", { nodeId, flowId: flowReferenceId, errorMessage: error });
1418
1421
  if (logErrorToSystem) {
1419
- (_21 = api.log) === null || _21 === void 0 ? void 0 : _21.call(api, "error", JSON.stringify(errorDetails));
1422
+ (_22 = api.log) === null || _22 === void 0 ? void 0 : _22.call(api, "error", JSON.stringify(errorDetails));
1420
1423
  }
1421
1424
  if (errorHandling !== "stop") {
1422
- (_22 = api.logDebugError) === null || _22 === void 0 ? void 0 : _22.call(api, errorDetails.message + (errorDetails.code ? ` (error code: ${errorDetails.code})` : ""), errorDetails.name);
1425
+ (_23 = api.logDebugError) === null || _23 === void 0 ? void 0 : _23.call(api, errorDetails.message + (errorDetails.code ? ` (error code: ${errorDetails.code})` : ""), errorDetails.name);
1423
1426
  }
1424
1427
  if (storeErrorInInput) {
1425
1428
  input.aiAgent = input.aiAgent || {};
@@ -1428,7 +1431,7 @@ exports.AI_AGENT_JOB = (0, createNodeDescriptor_1.createNodeDescriptor)({
1428
1431
  if (errorHandling === "continue") {
1429
1432
  // output the timeout message
1430
1433
  if (errorMessage) {
1431
- await ((_23 = api.output) === null || _23 === void 0 ? void 0 : _23.call(api, errorMessage, null));
1434
+ await ((_24 = api.output) === null || _24 === void 0 ? void 0 : _24.call(api, errorMessage, null));
1432
1435
  }
1433
1436
  // Set default node as next node
1434
1437
  const defaultChild = childConfigs.find(child => child.type === "aiAgentJobDefault");
@@ -1440,7 +1443,7 @@ exports.AI_AGENT_JOB = (0, createNodeDescriptor_1.createNodeDescriptor)({
1440
1443
  if (!errorHandlingGotoTarget) {
1441
1444
  throw new Error("GoTo Target is required");
1442
1445
  }
1443
- if (!((_24 = api.checkThink) === null || _24 === void 0 ? void 0 : _24.call(api, nodeId))) {
1446
+ if (!((_25 = api.checkThink) === null || _25 === void 0 ? void 0 : _25.call(api, nodeId))) {
1444
1447
  api.resetNextNodes();
1445
1448
  await api.executeFlow({
1446
1449
  flowNode: {
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AI_AGENT_JOB_CALL_MCP_TOOL = void 0;
4
4
  /* Custom modules */
5
5
  const createNodeDescriptor_1 = require("../../../createNodeDescriptor");
6
+ const parseMcpHeaders_1 = require("./helpers/parseMcpHeaders");
6
7
  const transcripts_1 = require("../../../../interfaces/transcripts/transcripts");
7
8
  exports.AI_AGENT_JOB_CALL_MCP_TOOL = (0, createNodeDescriptor_1.createNodeDescriptor)({
8
9
  type: "aiAgentJobCallMCPTool",
@@ -60,7 +61,7 @@ exports.AI_AGENT_JOB_CALL_MCP_TOOL = (0, createNodeDescriptor_1.createNodeDescri
60
61
  label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_CALL_MCP_TOOL__FIELDS__RESOLVE_IMMEDIATELY__LABEL",
61
62
  type: "toggle",
62
63
  description: "UI__NODE_EDITOR__SERVICE__AI_AGENT_CALL_MCP_TOOL__FIELDS__RESOLVE_IMMEDIATELY__DESCRIPTION",
63
- defaultValue: false,
64
+ defaultValue: true,
64
65
  },
65
66
  {
66
67
  key: "debugToolResult",
@@ -102,7 +103,8 @@ exports.AI_AGENT_JOB_CALL_MCP_TOOL = (0, createNodeDescriptor_1.createNodeDescri
102
103
  const aiAgentJobNode = (_b = sessionState.lastToolCall) === null || _b === void 0 ? void 0 : _b.aiAgentJobNode;
103
104
  const mcpServerUrl = (_c = sessionState.lastToolCall) === null || _c === void 0 ? void 0 : _c.mcpServerUrl;
104
105
  const timeout = (_d = sessionState.lastToolCall) === null || _d === void 0 ? void 0 : _d.timeout;
105
- const mcpHeaders = (_e = sessionState.lastToolCall) === null || _e === void 0 ? void 0 : _e.mcpHeaders;
106
+ // Use the helper function to parse MCP headers
107
+ const mcpHeaders = await (0, parseMcpHeaders_1.parseMcpHeaders)((_e = sessionState.lastToolCall) === null || _e === void 0 ? void 0 : _e.mcpHeaders, api);
106
108
  if (!(toolCall === null || toolCall === void 0 ? void 0 : toolCall.id)) {
107
109
  (_f = api.logDebugError) === null || _f === void 0 ? void 0 : _f.call(api, "UI__DEBUG_MODE__AI_AGENT_ANSWER__ERROR__MESSAGE");
108
110
  }
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.safeParseJson = exports.createToolDefinitions = void 0;
4
4
  const createSystemMessage_1 = require("./createSystemMessage");
5
+ const parseMcpHeaders_1 = require("./parseMcpHeaders");
5
6
  /**
6
7
  * Creates the tool definitions for the AI Agent Job and LLM Prompt v2 Nodes
7
8
  * @param childConfigs Child node configurations
@@ -45,7 +46,8 @@ const createToolDefinitions = async (childConfigs, api, useStrict) => {
45
46
  const cacheTools = child.config.cacheTools;
46
47
  const sendDebug = child.config.debugMessageFetchedTools;
47
48
  const toolFilter = child.config.toolFilter;
48
- const mcpHeaders = child.config.mcpHeaders;
49
+ // Parse mcpHeaders values if present and resolve any Cognigy script expressions
50
+ const mcpHeaders = await (0, parseMcpHeaders_1.parseMcpHeaders)(child.config.mcpHeaders, api);
49
51
  let mcpTools = null;
50
52
  let fetchedFromCache = null;
51
53
  try {
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseMcpHeaders = void 0;
4
+ /**
5
+ * Parses MCP headers by resolving any Cognigy script expressions in string values
6
+ * @param mcpHeaders - The headers object to parse
7
+ * @param api - The Cognigy API instance for parsing script text
8
+ * @returns The parsed headers object
9
+ */
10
+ async function parseMcpHeaders(mcpHeaders, api) {
11
+ if (!mcpHeaders || typeof mcpHeaders !== "object") {
12
+ return {};
13
+ }
14
+ const parsedMcpHeaders = {};
15
+ for (const [key, value] of Object.entries(mcpHeaders)) {
16
+ if (typeof value === "string") {
17
+ parsedMcpHeaders[key] = await api.parseCognigyScriptText(value);
18
+ }
19
+ else {
20
+ parsedMcpHeaders[key] = value;
21
+ }
22
+ }
23
+ return parsedMcpHeaders;
24
+ }
25
+ exports.parseMcpHeaders = parseMcpHeaders;
26
+ //# sourceMappingURL=parseMcpHeaders.js.map