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