@cognigy/rest-api-client 2025.23.0 → 2025.25.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/shared/charts/descriptors/index.js +6 -1
- package/build/shared/charts/descriptors/nlu/matchPattern.js +1 -0
- package/build/shared/charts/descriptors/placeholder.js +3 -0
- package/build/shared/charts/descriptors/service/agentTools/handoverToAiAgentTool.js +192 -0
- package/build/shared/charts/descriptors/service/agentTools/knowledgeTool.js +1 -1
- package/build/shared/charts/descriptors/service/agentTools/sendEmailTool.js +243 -0
- package/build/shared/charts/descriptors/service/aiAgent/aiAgentJob.js +1 -1
- package/build/shared/charts/descriptors/service/aiAgent/helpers/createToolDefinitions.js +37 -3
- 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/handoverConnections.js +9 -1
- package/build/shared/charts/descriptors/service/index.js +6 -1
- package/build/shared/charts/descriptors/service/llmPrompt/LLMPromptV2.js +1 -1
- package/build/shared/charts/descriptors/voice/mappers/setSessionConfig.mapper.js +12 -16
- package/build/shared/constants.js +2 -1
- package/build/shared/interfaces/IOrganisation.js +1 -0
- package/build/shared/interfaces/IProfile.js +1 -0
- package/build/shared/interfaces/cxone/knowledgehub/CXoneKnowledgehubAPI.js +3 -0
- package/build/shared/interfaces/resources/IAuditEvent.js +1 -0
- package/build/shared/interfaces/resources/TRestChannelType.js +2 -2
- 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/shared/charts/descriptors/index.js +5 -1
- package/dist/esm/shared/charts/descriptors/nlu/matchPattern.js +1 -0
- package/dist/esm/shared/charts/descriptors/placeholder.js +3 -0
- package/dist/esm/shared/charts/descriptors/service/agentTools/handoverToAiAgentTool.js +190 -0
- package/dist/esm/shared/charts/descriptors/service/agentTools/knowledgeTool.js +1 -1
- package/dist/esm/shared/charts/descriptors/service/agentTools/sendEmailTool.js +241 -0
- package/dist/esm/shared/charts/descriptors/service/aiAgent/aiAgentJob.js +1 -1
- package/dist/esm/shared/charts/descriptors/service/aiAgent/helpers/createToolDefinitions.js +35 -2
- 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/handoverConnections.js +8 -0
- package/dist/esm/shared/charts/descriptors/service/index.js +3 -1
- package/dist/esm/shared/charts/descriptors/service/llmPrompt/LLMPromptV2.js +1 -1
- package/dist/esm/shared/charts/descriptors/voice/mappers/setSessionConfig.mapper.js +12 -16
- package/dist/esm/shared/constants.js +1 -0
- package/dist/esm/shared/interfaces/IOrganisation.js +1 -0
- package/dist/esm/shared/interfaces/IProfile.js +1 -0
- package/dist/esm/shared/interfaces/cxone/knowledgehub/CXoneKnowledgehubAPI.js +2 -0
- package/dist/esm/shared/interfaces/resources/IAuditEvent.js +1 -0
- package/dist/esm/shared/interfaces/resources/TRestChannelType.js +2 -2
- 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 +204 -22
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
# 2025.25.0
|
|
2
|
+
Released: December 09th, 2025
|
|
3
|
+
|
|
4
|
+
Released state of package up to date with Cognigy.AI v2025.25.0
|
|
5
|
+
|
|
6
|
+
# 2025.24.0
|
|
7
|
+
Released: November 25th, 2025
|
|
8
|
+
|
|
9
|
+
Released state of package up to date with Cognigy.AI v2025.24.0
|
|
10
|
+
|
|
1
11
|
# 2025.23.0
|
|
2
12
|
Released: November 11th, 2025
|
|
3
13
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.cognigyDocumentParserProviderModule = exports.cognigyTranslationProviderModule = exports.cognigySpeechProviderModule = exports.cognigyGenerativeAIProviderModule = exports.cognigyInternalStorageProviderModule = exports.cognigyVoiceGateway2Module = exports.cognigyMicrosoftModule = exports.cognigyVoiceGatewayModule = exports.cognigySMTPModule = exports.cognigySQLModule = exports.cognigyMongoDBModule = exports.cognigyBasicModule = void 0;
|
|
3
|
+
exports.niceCXoneKnowledgehubProviderModule = exports.cognigyDocumentParserProviderModule = exports.cognigyTranslationProviderModule = exports.cognigySpeechProviderModule = exports.cognigyGenerativeAIProviderModule = exports.cognigyInternalStorageProviderModule = exports.cognigyVoiceGateway2Module = exports.cognigyMicrosoftModule = exports.cognigyVoiceGatewayModule = exports.cognigySMTPModule = exports.cognigySQLModule = exports.cognigyMongoDBModule = exports.cognigyBasicModule = void 0;
|
|
4
4
|
/* Custom modules */
|
|
5
5
|
const createNodeDescriptor_1 = require("../createNodeDescriptor");
|
|
6
6
|
/* Nodes */
|
|
@@ -150,6 +150,8 @@ if (process.env.DISABLE_FEATURE_TRANSCRIPT_MANAGER !== "true") {
|
|
|
150
150
|
nodes.push(service_1.AI_AGENT_JOB_CALL_MCP_TOOL);
|
|
151
151
|
nodes.push(service_1.AI_AGENT_TOOL_ANSWER);
|
|
152
152
|
nodes.push(service_1.KNOWLEDGE_TOOL);
|
|
153
|
+
nodes.push(service_1.HANDOVER_TO_AI_AGENT_TOOL);
|
|
154
|
+
nodes.push(service_1.SEND_EMAIL_TOOL);
|
|
153
155
|
nodes.push(service_1.AI_AGENT_HANDOVER);
|
|
154
156
|
nodes.push(service_1.LOAD_AI_AGENT);
|
|
155
157
|
}
|
|
@@ -175,6 +177,7 @@ exports.cognigyBasicModule = (0, createNodeDescriptor_1.createExtension)({
|
|
|
175
177
|
service_1.GENESYS_CLOUD_CONNECTION_OM,
|
|
176
178
|
service_1.NICECXONEAAH_AUTHENTICATION_CONNECTION,
|
|
177
179
|
service_1.AIOPS_CENTER_WEBHOOKS_CONNECTION,
|
|
180
|
+
service_1.STORM_CONNECTION,
|
|
178
181
|
],
|
|
179
182
|
});
|
|
180
183
|
var mongoDB_1 = require("./connectionNodes/mongoDB");
|
|
@@ -199,4 +202,6 @@ var translationProviders_1 = require("./connectionNodes/translationProviders");
|
|
|
199
202
|
Object.defineProperty(exports, "cognigyTranslationProviderModule", { enumerable: true, get: function () { return translationProviders_1.cognigyTranslationProviderModule; } });
|
|
200
203
|
var documentParserProviders_1 = require("./connectionNodes/documentParserProviders");
|
|
201
204
|
Object.defineProperty(exports, "cognigyDocumentParserProviderModule", { enumerable: true, get: function () { return documentParserProviders_1.cognigyDocumentParserProviderModule; } });
|
|
205
|
+
var CXoneKnowledgehubProviderModule_1 = require("./service/cxone/knowledgehub/CXoneKnowledgehubProviderModule");
|
|
206
|
+
Object.defineProperty(exports, "niceCXoneKnowledgehubProviderModule", { enumerable: true, get: function () { return CXoneKnowledgehubProviderModule_1.niceCXoneKnowledgehubProviderModule; } });
|
|
202
207
|
//# sourceMappingURL=index.js.map
|
|
@@ -63,6 +63,7 @@ exports.MATCH_PATTERN = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
63
63
|
description: "UI__NODE_EDITOR__NLU__MATCH_PATTERN__FIELDS__USE_FULL_SYSTEM_SLOT_TEXT_DESCRIPTION",
|
|
64
64
|
type: "toggle",
|
|
65
65
|
defaultValue: true,
|
|
66
|
+
fallbackValue: false
|
|
66
67
|
}
|
|
67
68
|
],
|
|
68
69
|
sections: [
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HANDOVER_TO_AI_AGENT_TOOL = void 0;
|
|
4
|
+
/* Custom modules */
|
|
5
|
+
const createNodeDescriptor_1 = require("../../../createNodeDescriptor");
|
|
6
|
+
const transcripts_1 = require("../../../../interfaces/transcripts/transcripts");
|
|
7
|
+
exports.HANDOVER_TO_AI_AGENT_TOOL = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
8
|
+
type: "handoverToAiAgentTool",
|
|
9
|
+
defaultLabel: "Handover to AI Agent 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: "handover_to_ai_agent",
|
|
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
|
+
params: {
|
|
51
|
+
required: true,
|
|
52
|
+
rows: 5,
|
|
53
|
+
multiline: true,
|
|
54
|
+
placeholder: "UI__NODE_EDITOR__SERVICE__HANDOVER_TO_AI_AGENT_TOOL__FIELDS__DESCRIPTION__PLACEHOLDER"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
key: "parameters",
|
|
59
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__PARAMETERS__LABEL",
|
|
60
|
+
description: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__PARAMETERS__DESCRIPTION",
|
|
61
|
+
type: "toolParameters",
|
|
62
|
+
defaultValue: `{
|
|
63
|
+
"type": "object",
|
|
64
|
+
"properties": {
|
|
65
|
+
"handover_reason": {
|
|
66
|
+
"type": "string",
|
|
67
|
+
"description": "The reason for handing over to the AI Agent, including context from the conversation."
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"required": ["handover_reason"],
|
|
71
|
+
"additionalProperties": false
|
|
72
|
+
}`,
|
|
73
|
+
params: {
|
|
74
|
+
required: false,
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
key: "flowNode",
|
|
79
|
+
type: "flowNode",
|
|
80
|
+
label: "UI__NODE_EDITOR__SERVICE__HANDOVER_TO_AI_AGENT_TOOL__FIELDS__FLOW_NODE__LABEL",
|
|
81
|
+
params: {
|
|
82
|
+
required: true,
|
|
83
|
+
nodeTypeFilter: ["aiAgentJob"]
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
key: "debugMessage",
|
|
88
|
+
type: "toggle",
|
|
89
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__DEBUG_MESSAGE__LABEL",
|
|
90
|
+
description: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__DEBUG_MESSAGE__DESCRIPTION",
|
|
91
|
+
defaultValue: true,
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
key: "condition",
|
|
95
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__CONDITION__LABEL",
|
|
96
|
+
description: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__CONDITION__DESCRIPTION",
|
|
97
|
+
type: "cognigyText",
|
|
98
|
+
defaultValue: "",
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
sections: [
|
|
102
|
+
{
|
|
103
|
+
key: "debugging",
|
|
104
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_JOB__SECTIONS__DEBUG_SETTINGS__LABEL",
|
|
105
|
+
defaultCollapsed: true,
|
|
106
|
+
fields: [
|
|
107
|
+
"debugMessage",
|
|
108
|
+
],
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
key: "advanced",
|
|
112
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_JOB__SECTIONS__ADVANCED__LABEL",
|
|
113
|
+
defaultCollapsed: true,
|
|
114
|
+
fields: [
|
|
115
|
+
"condition",
|
|
116
|
+
],
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
form: [
|
|
120
|
+
{ type: "field", key: "toolId" },
|
|
121
|
+
{ type: "field", key: "description" },
|
|
122
|
+
{ type: "field", key: "flowNode" },
|
|
123
|
+
{ type: "section", key: "debugging" },
|
|
124
|
+
{ type: "section", key: "advanced" },
|
|
125
|
+
],
|
|
126
|
+
appearance: {
|
|
127
|
+
color: "white",
|
|
128
|
+
textColor: "#252525",
|
|
129
|
+
variant: "mini",
|
|
130
|
+
},
|
|
131
|
+
function: async ({ cognigy, config, nodeId: thisNodeId }) => {
|
|
132
|
+
var _a, _b, _c, _d, _e, _f;
|
|
133
|
+
const { api } = cognigy;
|
|
134
|
+
const { debugMessage, flowNode } = config;
|
|
135
|
+
const sessionState = await api.loadSessionState();
|
|
136
|
+
const toolCall = (_a = sessionState.lastToolCall) === null || _a === void 0 ? void 0 : _a.toolCall;
|
|
137
|
+
if (!(toolCall === null || toolCall === void 0 ? void 0 : toolCall.id)) {
|
|
138
|
+
(_b = api.logDebugError) === null || _b === void 0 ? void 0 : _b.call(api, "UI__DEBUG_MODE__AI_AGENT_ANSWER__ERROR__MESSAGE");
|
|
139
|
+
}
|
|
140
|
+
if (!(flowNode === null || flowNode === void 0 ? void 0 : flowNode.flow) || !(flowNode === null || flowNode === void 0 ? void 0 : flowNode.node)) {
|
|
141
|
+
throw new Error("Flow Node is required for Handover to AI Agent Tool");
|
|
142
|
+
}
|
|
143
|
+
if (toolCall) {
|
|
144
|
+
if (!((_c = api.checkThink) === null || _c === void 0 ? void 0 : _c.call(api, thisNodeId))) {
|
|
145
|
+
const handoverReason = ((_e = (_d = toolCall === null || toolCall === void 0 ? void 0 : toolCall.function) === null || _d === void 0 ? void 0 : _d.arguments) === null || _e === void 0 ? void 0 : _e.handover_reason) || "Handover requested";
|
|
146
|
+
// Optional Debug Message
|
|
147
|
+
if (debugMessage) {
|
|
148
|
+
(_f = api.logDebugMessage) === null || _f === void 0 ? void 0 : _f.call(api, JSON.stringify({ handover_reason: handoverReason, target_flow: flowNode.flow, target_node: flowNode.node }, null, 2));
|
|
149
|
+
}
|
|
150
|
+
// Add Tool Call Message to Transcript
|
|
151
|
+
const toolCallTranscriptStep = {
|
|
152
|
+
role: transcripts_1.TranscriptRole.ASSISTANT,
|
|
153
|
+
type: transcripts_1.TranscriptEntryType.TOOL_CALL,
|
|
154
|
+
source: "system",
|
|
155
|
+
payload: {
|
|
156
|
+
name: toolCall.function.name,
|
|
157
|
+
id: toolCall.id,
|
|
158
|
+
input: toolCall.function.arguments,
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
await api.addTranscriptStep(toolCallTranscriptStep);
|
|
162
|
+
// Add Tool Answer Message to Transcript
|
|
163
|
+
const toolAnswer = {
|
|
164
|
+
role: transcripts_1.TranscriptRole.TOOL,
|
|
165
|
+
type: transcripts_1.TranscriptEntryType.TOOL_ANSWER,
|
|
166
|
+
source: "system",
|
|
167
|
+
payload: {
|
|
168
|
+
toolCallId: toolCall.id,
|
|
169
|
+
name: toolCall.function.name,
|
|
170
|
+
content: `Handover to AI Agent initiated. Reason: ${handoverReason}`,
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
await api.addTranscriptStep(toolAnswer);
|
|
174
|
+
api.resetNextNodes();
|
|
175
|
+
api.updateSessionStateValues({
|
|
176
|
+
lastToolCall: undefined
|
|
177
|
+
});
|
|
178
|
+
await api.executeFlow({
|
|
179
|
+
flowNode: {
|
|
180
|
+
flow: flowNode.flow,
|
|
181
|
+
node: flowNode.node,
|
|
182
|
+
},
|
|
183
|
+
absorbContext: true,
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
throw new Error("Infinite Loop Detected");
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
//# sourceMappingURL=handoverToAiAgentTool.js.map
|
|
@@ -74,7 +74,7 @@ exports.KNOWLEDGE_TOOL = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
74
74
|
"generated_buffer_phrase": {
|
|
75
75
|
"type": "string",
|
|
76
76
|
"description": "A generated delay or stalling phrase. Consider the context. Adapt to your speech style and language."
|
|
77
|
-
}
|
|
77
|
+
}
|
|
78
78
|
},
|
|
79
79
|
"required": ["generated_prompt", "generated_buffer_phrase"],
|
|
80
80
|
"additionalProperties": false
|
|
@@ -0,0 +1,243 @@
|
|
|
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: "parameters",
|
|
71
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__PARAMETERS__LABEL",
|
|
72
|
+
type: "toolParameters",
|
|
73
|
+
defaultValue: `{
|
|
74
|
+
"type": "object",
|
|
75
|
+
"properties": {
|
|
76
|
+
"subject": {
|
|
77
|
+
"type": "string",
|
|
78
|
+
"description": "The subject of the email."
|
|
79
|
+
},
|
|
80
|
+
"message": {
|
|
81
|
+
"type": "string",
|
|
82
|
+
"description": "The body of the email."
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"required": ["subject", "message"],
|
|
86
|
+
"additionalProperties": false
|
|
87
|
+
}`,
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
key: "debugMessage",
|
|
91
|
+
type: "toggle",
|
|
92
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__DEBUG_MESSAGE__LABEL",
|
|
93
|
+
description: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__DEBUG_MESSAGE__DESCRIPTION",
|
|
94
|
+
defaultValue: true,
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
key: "condition",
|
|
98
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__CONDITION__LABEL",
|
|
99
|
+
description: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__CONDITION__DESCRIPTION",
|
|
100
|
+
type: "cognigyText",
|
|
101
|
+
defaultValue: "",
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
sections: [
|
|
105
|
+
{
|
|
106
|
+
key: "debugging",
|
|
107
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_JOB__SECTIONS__DEBUG_SETTINGS__LABEL",
|
|
108
|
+
defaultCollapsed: true,
|
|
109
|
+
fields: [
|
|
110
|
+
"debugMessage",
|
|
111
|
+
],
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
key: "advanced",
|
|
115
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_JOB__SECTIONS__ADVANCED__LABEL",
|
|
116
|
+
defaultCollapsed: true,
|
|
117
|
+
fields: [
|
|
118
|
+
"condition"
|
|
119
|
+
]
|
|
120
|
+
},
|
|
121
|
+
],
|
|
122
|
+
form: [
|
|
123
|
+
{ type: "field", key: "toolId" },
|
|
124
|
+
{ type: "field", key: "description" },
|
|
125
|
+
{ type: "field", key: "recipient" },
|
|
126
|
+
{ type: "section", key: "debugging" },
|
|
127
|
+
{ type: "section", key: "advanced" },
|
|
128
|
+
],
|
|
129
|
+
appearance: {
|
|
130
|
+
color: "white",
|
|
131
|
+
textColor: "#252525",
|
|
132
|
+
variant: "mini",
|
|
133
|
+
},
|
|
134
|
+
function: async ({ cognigy, config, nodeId, nodeType, organisationId, projectId, childConfigs }) => {
|
|
135
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
136
|
+
const { api, context, input } = cognigy;
|
|
137
|
+
const { debugMessage, recipient, } = config;
|
|
138
|
+
const sessionState = await api.loadSessionState();
|
|
139
|
+
const toolCall = (_a = sessionState.lastToolCall) === null || _a === void 0 ? void 0 : _a.toolCall;
|
|
140
|
+
const aiAgentJobNode = (_b = sessionState.lastToolCall) === null || _b === void 0 ? void 0 : _b.aiAgentJobNode;
|
|
141
|
+
if (!(toolCall === null || toolCall === void 0 ? void 0 : toolCall.id)) {
|
|
142
|
+
(_c = api.logDebugError) === null || _c === void 0 ? void 0 : _c.call(api, "UI__DEBUG_MODE__AI_AGENT_ANSWER__ERROR__MESSAGE");
|
|
143
|
+
}
|
|
144
|
+
if (toolCall && aiAgentJobNode) {
|
|
145
|
+
if (!((_d = api.checkThink) === null || _d === void 0 ? void 0 : _d.call(api, nodeId))) {
|
|
146
|
+
const { subject, message } = toolCall.function.arguments;
|
|
147
|
+
let result;
|
|
148
|
+
try {
|
|
149
|
+
result = await ((_e = api === null || api === void 0 ? void 0 : api.emailNotification) === null || _e === void 0 ? void 0 : _e.call(api, {
|
|
150
|
+
cognigy,
|
|
151
|
+
config: {
|
|
152
|
+
recipient,
|
|
153
|
+
subject,
|
|
154
|
+
message,
|
|
155
|
+
cc: "",
|
|
156
|
+
bcc: "",
|
|
157
|
+
priority: "normal",
|
|
158
|
+
async: false,
|
|
159
|
+
storeLocation: "none",
|
|
160
|
+
inputKey: "",
|
|
161
|
+
contextKey: "",
|
|
162
|
+
stopOnError: false,
|
|
163
|
+
},
|
|
164
|
+
nodeId,
|
|
165
|
+
nodeType,
|
|
166
|
+
organisationId,
|
|
167
|
+
projectId,
|
|
168
|
+
childConfigs,
|
|
169
|
+
}));
|
|
170
|
+
}
|
|
171
|
+
catch (error) {
|
|
172
|
+
// Log error message to debug mode
|
|
173
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
174
|
+
(_f = api.logDebugError) === null || _f === void 0 ? void 0 : _f.call(api, errorMessage, "UI__DEBUG_MODE__AI_AGENT__SEND_EMAIL_TOOL__ERROR");
|
|
175
|
+
// Pass error message to LLM as result
|
|
176
|
+
result = errorMessage;
|
|
177
|
+
}
|
|
178
|
+
// Optional Debug Message of Email sending and response
|
|
179
|
+
if (debugMessage) {
|
|
180
|
+
const messageLines = [];
|
|
181
|
+
if (recipient) {
|
|
182
|
+
messageLines.push(`\n<b>UI__DEBUG_MODE__AI_AGENT__SEND_EMAIL_TOOL__RECIPIENT</b> ${recipient}`);
|
|
183
|
+
}
|
|
184
|
+
if (subject) {
|
|
185
|
+
messageLines.push(`\n<b>UI__DEBUG_MODE__AI_AGENT__SEND_EMAIL_TOOL__SUBJECT</b> ${subject}`);
|
|
186
|
+
}
|
|
187
|
+
if (message) {
|
|
188
|
+
messageLines.push(`\n<b>UI__DEBUG_MODE__AI_AGENT__SEND_EMAIL_TOOL__MESSAGE</b> ${message}`);
|
|
189
|
+
}
|
|
190
|
+
if (result) {
|
|
191
|
+
const resultString = typeof result === 'string' ? result : JSON.stringify(result, null, 2);
|
|
192
|
+
messageLines.push(`\n<b>UI__DEBUG_MODE__AI_AGENT__SEND_EMAIL_TOOL__RESULT</b>\n${resultString}`);
|
|
193
|
+
}
|
|
194
|
+
(_g = api.logDebugMessage) === null || _g === void 0 ? void 0 : _g.call(api, messageLines.join("\n"), "UI__DEBUG_MODE__AI_AGENT__SEND_EMAIL_TOOL__HEADER");
|
|
195
|
+
}
|
|
196
|
+
const { flow, node } = aiAgentJobNode;
|
|
197
|
+
if (flow && node) {
|
|
198
|
+
// Add Tool Call Message to Transcript
|
|
199
|
+
const toolCallTranscriptStep = {
|
|
200
|
+
role: transcripts_1.TranscriptRole.ASSISTANT,
|
|
201
|
+
type: transcripts_1.TranscriptEntryType.TOOL_CALL,
|
|
202
|
+
source: "system",
|
|
203
|
+
payload: {
|
|
204
|
+
name: toolCall.function.name,
|
|
205
|
+
id: toolCall.id,
|
|
206
|
+
input: toolCall.function.arguments,
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
await api.addTranscriptStep(toolCallTranscriptStep);
|
|
210
|
+
// Add Tool Answer Message to Transcript
|
|
211
|
+
const resultString = typeof result === 'string' ? result : JSON.stringify(result);
|
|
212
|
+
const toolAnswer = {
|
|
213
|
+
role: transcripts_1.TranscriptRole.TOOL,
|
|
214
|
+
type: transcripts_1.TranscriptEntryType.TOOL_ANSWER,
|
|
215
|
+
source: "system",
|
|
216
|
+
payload: {
|
|
217
|
+
toolCallId: toolCall.id,
|
|
218
|
+
name: toolCall.function.name,
|
|
219
|
+
content: `Send email result:\n${resultString}`,
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
await api.addTranscriptStep(toolAnswer);
|
|
223
|
+
api.resetNextNodes();
|
|
224
|
+
// remove the call from the session state, because the call has been answered
|
|
225
|
+
api.updateSessionStateValues({
|
|
226
|
+
lastToolCall: undefined
|
|
227
|
+
});
|
|
228
|
+
await api.executeFlow({
|
|
229
|
+
flowNode: {
|
|
230
|
+
flow,
|
|
231
|
+
node,
|
|
232
|
+
},
|
|
233
|
+
absorbContext: true,
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
throw new Error("Infinite Loop Detected");
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
//# sourceMappingURL=sendEmailTool.js.map
|
|
@@ -24,7 +24,7 @@ const generateSearchPrompt_1 = require("./helpers/generateSearchPrompt");
|
|
|
24
24
|
const getUserMemory_1 = require("./helpers/getUserMemory");
|
|
25
25
|
const createToolDefinitions_1 = require("./helpers/createToolDefinitions");
|
|
26
26
|
const transcripts_1 = require("../../../../interfaces/transcripts/transcripts");
|
|
27
|
-
exports.AI_AGENT_TOOLS_WHITELIST = ["aiAgentJobDefault", "aiAgentJobTool", "aiAgentJobMCPTool", "knowledgeTool"];
|
|
27
|
+
exports.AI_AGENT_TOOLS_WHITELIST = ["aiAgentJobDefault", "aiAgentJobTool", "aiAgentJobMCPTool", "knowledgeTool", "handoverToAiAgentTool", "sendEmailTool"];
|
|
28
28
|
exports.AI_AGENT_JOB = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
29
29
|
type: "aiAgentJob",
|
|
30
30
|
defaultLabel: "AI Agent",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createToolDefinitions = void 0;
|
|
3
|
+
exports.safeParseJson = exports.createToolDefinitions = void 0;
|
|
4
4
|
const createSystemMessage_1 = require("./createSystemMessage");
|
|
5
5
|
/**
|
|
6
6
|
* Creates the tool definitions for the AI Agent Job and LLM Prompt v2 Nodes
|
|
@@ -162,8 +162,11 @@ const createToolDefinitions = async (childConfigs, api, useStrict) => {
|
|
|
162
162
|
if (useStrict) {
|
|
163
163
|
tool.function.strict = true;
|
|
164
164
|
}
|
|
165
|
-
if (child.config.useParameters) {
|
|
166
|
-
|
|
165
|
+
if (child.config.parameters && child.config.useParameters !== false) {
|
|
166
|
+
const parameters = safeParseJson(child.config.parameters);
|
|
167
|
+
if (parameters !== null) {
|
|
168
|
+
tool.function.parameters = parameters;
|
|
169
|
+
}
|
|
167
170
|
}
|
|
168
171
|
tools.push(tool);
|
|
169
172
|
}
|
|
@@ -177,4 +180,35 @@ const createToolDefinitions = async (childConfigs, api, useStrict) => {
|
|
|
177
180
|
};
|
|
178
181
|
};
|
|
179
182
|
exports.createToolDefinitions = createToolDefinitions;
|
|
183
|
+
/**
|
|
184
|
+
* Safely parses JSON with backwards compatibility for trailing commas.
|
|
185
|
+
*
|
|
186
|
+
* The trailing comma cleanup is required for backwards compatibility with the
|
|
187
|
+
* knowledge tool, which had invalid JSON (with trailing commas) in the initial
|
|
188
|
+
* release. Although the JSON wasn't actually used at that time due to parameters not being used,
|
|
189
|
+
* we need to handle it gracefully to support any stored configurations.
|
|
190
|
+
*
|
|
191
|
+
* @param raw - The value to parse. If already parsed (not a string), returns it as-is if truthy.
|
|
192
|
+
* @returns The parsed JSON object, the input value if already parsed, or null if parsing fails or input is falsy.
|
|
193
|
+
*/
|
|
194
|
+
function safeParseJson(raw) {
|
|
195
|
+
// If not a string, return as-is if truthy, otherwise null
|
|
196
|
+
if (typeof raw !== "string") {
|
|
197
|
+
return raw || null;
|
|
198
|
+
}
|
|
199
|
+
try {
|
|
200
|
+
return JSON.parse(raw);
|
|
201
|
+
}
|
|
202
|
+
catch (_a) {
|
|
203
|
+
// Fallback: remove trailing commas before } or ]
|
|
204
|
+
const cleaned = raw.replace(/,\s*([}\]])/g, "$1");
|
|
205
|
+
try {
|
|
206
|
+
return JSON.parse(cleaned);
|
|
207
|
+
}
|
|
208
|
+
catch (_b) {
|
|
209
|
+
return null; // safe fallback instead of throwing
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
exports.safeParseJson = safeParseJson;
|
|
180
214
|
//# sourceMappingURL=createToolDefinitions.js.map
|