@cognigy/rest-api-client 2025.18.1 → 2025.20.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/InsightsAPIGroup_2_0.js +10 -10
- package/build/apigroups/MetricsAPIGroup_2_0.js +4 -0
- package/build/authentication/OAuth2/OAuth2Authentication.js +2 -0
- package/build/connector/AxiosAdapter.js +4 -1
- package/build/shared/charts/descriptors/nlu/fuzzySearch.js +6 -6
- package/build/shared/charts/descriptors/service/aiAgent/aiAgentJob.js +81 -21
- package/build/shared/charts/descriptors/service/aiAgent/aiAgentJobCallMCPTool.js +7 -5
- package/build/shared/charts/descriptors/service/aiAgent/aiAgentJobMCPTool.js +8 -1
- package/build/shared/charts/descriptors/service/aiAgent/helpers/createToolDefinitions.js +2 -0
- package/build/shared/charts/descriptors/service/llmPrompt/LLMPromptV2.js +78 -18
- package/build/shared/charts/descriptors/service/llmPrompt/llmPromptMCPTool.js +8 -1
- package/build/shared/charts/descriptors/voice/mappers/transfer.mapper.js +20 -6
- package/build/shared/charts/descriptors/voicegateway2/nodes/transfer.js +39 -3
- package/build/shared/interfaces/IOrganisation.js +1 -0
- package/build/shared/interfaces/handover.js +3 -1
- package/build/shared/interfaces/messageAPI/endpoints.js +2 -0
- package/build/shared/interfaces/resources/IAuditEvent.js +2 -1
- package/build/shared/interfaces/resources/knowledgeStore/IKnowledgeSource.js +1 -1
- package/build/shared/interfaces/restAPI/metrics/logs/v2.0/ITailLogEntriesRest_2_0.js +3 -0
- package/dist/esm/apigroups/InsightsAPIGroup_2_0.js +10 -10
- package/dist/esm/apigroups/MetricsAPIGroup_2_0.js +4 -0
- package/dist/esm/authentication/OAuth2/OAuth2Authentication.js +2 -0
- package/dist/esm/connector/AxiosAdapter.js +4 -1
- package/dist/esm/shared/charts/descriptors/nlu/fuzzySearch.js +6 -6
- package/dist/esm/shared/charts/descriptors/service/aiAgent/aiAgentJob.js +81 -21
- package/dist/esm/shared/charts/descriptors/service/aiAgent/aiAgentJobCallMCPTool.js +7 -5
- package/dist/esm/shared/charts/descriptors/service/aiAgent/aiAgentJobMCPTool.js +8 -1
- package/dist/esm/shared/charts/descriptors/service/aiAgent/helpers/createToolDefinitions.js +2 -0
- package/dist/esm/shared/charts/descriptors/service/llmPrompt/LLMPromptV2.js +85 -25
- package/dist/esm/shared/charts/descriptors/service/llmPrompt/llmPromptMCPTool.js +8 -1
- package/dist/esm/shared/charts/descriptors/voice/mappers/transfer.mapper.js +20 -6
- package/dist/esm/shared/charts/descriptors/voicegateway2/nodes/transfer.js +39 -3
- package/dist/esm/shared/interfaces/IOrganisation.js +1 -0
- package/dist/esm/shared/interfaces/handover.js +3 -1
- package/dist/esm/shared/interfaces/messageAPI/endpoints.js +2 -0
- package/dist/esm/shared/interfaces/resources/IAuditEvent.js +2 -1
- package/dist/esm/shared/interfaces/resources/knowledgeStore/IKnowledgeSource.js +1 -1
- package/dist/esm/shared/interfaces/restAPI/metrics/logs/v2.0/ITailLogEntriesRest_2_0.js +2 -0
- package/package.json +1 -1
- package/types/index.d.ts +873 -816
- package/build/test.js +0 -39
- package/dist/esm/shared/interfaces/restAPI/management/authentication/ICreateJWTToken.js +0 -1
- package/dist/esm/test.js +0 -39
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
# 2025.20.0
|
|
2
|
+
Released: October 02nd, 2025
|
|
3
|
+
|
|
4
|
+
Released state of package up to date with Cognigy.AI v2025.20.0
|
|
5
|
+
|
|
6
|
+
# 2025.19.0
|
|
7
|
+
Released: September 16th, 2025
|
|
8
|
+
|
|
9
|
+
Released state of package up to date with Cognigy.AI v2025.19.0
|
|
10
|
+
|
|
1
11
|
# 2025.18.1
|
|
2
12
|
Released: September 04th, 2025
|
|
3
13
|
|
|
@@ -17,12 +17,12 @@ const rest_1 = require("../shared/helper/rest");
|
|
|
17
17
|
function InsightsAPIGroup_2_0(instance) {
|
|
18
18
|
const self = instance;
|
|
19
19
|
return {
|
|
20
|
-
indexSteps: (args, options) => (0, GenericAPIFn_1.GenericAPIFn)(`/
|
|
21
|
-
generateReport: (args, options) => (0, GenericAPIFn_1.GenericAPIFn)("/
|
|
22
|
-
loadReportByQueryHash: ({ queryHash }, options) => (0, GenericAPIFn_1.GenericAPIFn)(`/
|
|
20
|
+
indexSteps: (args, options) => (0, GenericAPIFn_1.GenericAPIFn)(`/v1.0/insights/steps?${(0, rest_1.stringifyQuery)(args)}`, "GET", self)(undefined, options),
|
|
21
|
+
generateReport: (args, options) => (0, GenericAPIFn_1.GenericAPIFn)("/v1.0/insights/reports/generate", "POST", self)(args, options),
|
|
22
|
+
loadReportByQueryHash: ({ queryHash }, options) => (0, GenericAPIFn_1.GenericAPIFn)(`/v1.0/insights/reports/${queryHash}`, "GET", self)(undefined, options),
|
|
23
23
|
generateMessagesReport: (_a, options) => {
|
|
24
24
|
var { search, skip, limit, next, previous, sort, messageType } = _a, args = __rest(_a, ["search", "skip", "limit", "next", "previous", "sort", "messageType"]);
|
|
25
|
-
return (0, GenericAPIFn_1.GenericAPIFn)(`/
|
|
25
|
+
return (0, GenericAPIFn_1.GenericAPIFn)(`/v1.0/insights/messages/report/generate?${(0, rest_1.stringifyQuery)({
|
|
26
26
|
search,
|
|
27
27
|
skip,
|
|
28
28
|
limit,
|
|
@@ -32,12 +32,12 @@ function InsightsAPIGroup_2_0(instance) {
|
|
|
32
32
|
messageType
|
|
33
33
|
})}`, "POST", self)(args, options);
|
|
34
34
|
},
|
|
35
|
-
loadMessagesReportByQueryHash: ({ queryHash }, options) => (0, GenericAPIFn_1.GenericAPIFn)(`/
|
|
36
|
-
generateStepReport: (args, options) => (0, GenericAPIFn_1.GenericAPIFn)("/
|
|
37
|
-
loadStepReportByQueryHash: ({ queryHash }, options) => (0, GenericAPIFn_1.GenericAPIFn)(`/
|
|
35
|
+
loadMessagesReportByQueryHash: ({ queryHash }, options) => (0, GenericAPIFn_1.GenericAPIFn)(`/v1.0/insights/messages/report/${queryHash}`, "GET", self)(undefined, options),
|
|
36
|
+
generateStepReport: (args, options) => (0, GenericAPIFn_1.GenericAPIFn)("/v1.0/insights/steps/report/generate", "POST", self)(args, options),
|
|
37
|
+
loadStepReportByQueryHash: ({ queryHash }, options) => (0, GenericAPIFn_1.GenericAPIFn)(`/v1.0/insights/steps/report/${queryHash}`, "GET", self)(undefined, options),
|
|
38
38
|
generateTranscriptsReport: (_a, options) => {
|
|
39
39
|
var { search, skip, limit, next, previous, sort } = _a, args = __rest(_a, ["search", "skip", "limit", "next", "previous", "sort"]);
|
|
40
|
-
return (0, GenericAPIFn_1.GenericAPIFn)(`/
|
|
40
|
+
return (0, GenericAPIFn_1.GenericAPIFn)(`/v1.0/insights/transcripts/report/generate?${(0, rest_1.stringifyQuery)({
|
|
41
41
|
search,
|
|
42
42
|
skip,
|
|
43
43
|
limit,
|
|
@@ -46,12 +46,12 @@ function InsightsAPIGroup_2_0(instance) {
|
|
|
46
46
|
sort
|
|
47
47
|
})}`, "POST", self)(args, options);
|
|
48
48
|
},
|
|
49
|
-
loadTranscriptsReportByQueryHash: ({ queryHash }, options) => (0, GenericAPIFn_1.GenericAPIFn)(`/
|
|
49
|
+
loadTranscriptsReportByQueryHash: ({ queryHash }, options) => (0, GenericAPIFn_1.GenericAPIFn)(`/v1.0/insights/transcripts/report/${queryHash}`, "GET", self)(undefined, options),
|
|
50
50
|
deleteAnalyticsRecords: (_a, options) => {
|
|
51
51
|
var { projectId } = _a, restArgs = __rest(_a, ["projectId"]);
|
|
52
52
|
return (0, GenericAPIFn_1.GenericAPIFn)(`/v2.0/analytics/${projectId}`, "DELETE", self)(restArgs, options);
|
|
53
53
|
},
|
|
54
|
-
insightsJWT: (options) => (0, GenericAPIFn_1.GenericAPIFn)("/
|
|
54
|
+
insightsJWT: (options) => (0, GenericAPIFn_1.GenericAPIFn)("/insights/auth", "POST", self)(undefined, options)
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
57
|
exports.InsightsAPIGroup_2_0 = InsightsAPIGroup_2_0;
|
|
@@ -25,6 +25,10 @@ function MetricsAPIGroup_2_0(instance) {
|
|
|
25
25
|
var { projectId } = _a, args = __rest(_a, ["projectId"]);
|
|
26
26
|
return (0, GenericAPIFn_1.GenericAPIFn)(`/new/v2.0/projects/${projectId}/logs?${(0, query_1.stringifyQuery)(args)}`, "GET", self)(undefined, options);
|
|
27
27
|
},
|
|
28
|
+
tailLogEntries: (_a, options) => {
|
|
29
|
+
var { projectId } = _a, args = __rest(_a, ["projectId"]);
|
|
30
|
+
return (0, GenericAPIFn_1.GenericAPIFn)(`/new/v2.0/projects/${projectId}/logs/tail?${(0, query_1.stringifyQuery)(args)}`, "GET", self)(undefined, options);
|
|
31
|
+
},
|
|
28
32
|
readLogEntry: ({ projectId, logEntryId }, options) => (0, GenericAPIFn_1.GenericAPIFn)(`/new/v2.0/projects/${projectId}/logs/${logEntryId}}`, "GET", self)(undefined, options),
|
|
29
33
|
indexProfiles: (args, options) => (0, GenericAPIFn_1.GenericAPIFn)(`/new/v2.0/profiles?${(0, query_1.stringifyQuery)(args)}`, "GET", self)(undefined, options),
|
|
30
34
|
createProfile: (args, options) => (0, GenericAPIFn_1.GenericAPIFn)("/new/v2.0/profiles", "POST", self)(args, options),
|
|
@@ -105,6 +105,8 @@ exports.OAuth2Authentication = function (credentials, self) {
|
|
|
105
105
|
break;
|
|
106
106
|
case "refreshToken":
|
|
107
107
|
{
|
|
108
|
+
// The refresh token from the parameters is to support older token granted via Password Grant flow
|
|
109
|
+
// TODO - remove this in future once PKCE fully takes over
|
|
108
110
|
const { refreshToken } = parameters;
|
|
109
111
|
const credentials = self.credentials;
|
|
110
112
|
const result = await refreshTokenGrant({
|
|
@@ -117,7 +117,7 @@ class AxiosAdapter {
|
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
if (isAxiosResponse(axiosResponse)) {
|
|
120
|
-
|
|
120
|
+
let errorClass = errors_1.ErrorCollection[(_b = axiosResponse.data) === null || _b === void 0 ? void 0 : _b.code] ||
|
|
121
121
|
errors_1.ErrorCollection[axiosResponse.status] ||
|
|
122
122
|
errors_1.ErrorCollection[errors_1.ErrorCode.INTERNAL_SERVER_ERROR];
|
|
123
123
|
if ((axiosResponse.status === HttpStatusCode_1.HttpStatusCode.UNAUTHORIZED ||
|
|
@@ -126,6 +126,9 @@ class AxiosAdapter {
|
|
|
126
126
|
typeof this.config.onUnauthorized === "function") {
|
|
127
127
|
this.config.onUnauthorized();
|
|
128
128
|
}
|
|
129
|
+
if (axiosResponse.status === HttpStatusCode_1.HttpStatusCode.CONFLICT) {
|
|
130
|
+
errorClass = errors_1.ErrorCollection[errors_1.ErrorCode.CONFLICT_ERROR];
|
|
131
|
+
}
|
|
129
132
|
if (IOAuth2ErrorResponse_1.OAuth2Errors.includes((_d = axiosResponse.data) === null || _d === void 0 ? void 0 : _d.error)) {
|
|
130
133
|
throw new errorClass(axiosResponse.data.detail, { traceId: axiosResponse.data.traceId }, undefined, axiosResponse.data);
|
|
131
134
|
}
|
|
@@ -33,12 +33,12 @@ exports.FUZZY_SEARCH = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
33
33
|
params: {
|
|
34
34
|
required: true
|
|
35
35
|
},
|
|
36
|
-
defaultValue: `
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
defaultValue: `{
|
|
37
|
+
"$cs":{
|
|
38
|
+
"script":"context.names",
|
|
39
|
+
"type":"array"
|
|
40
|
+
}
|
|
41
|
+
}`
|
|
42
42
|
},
|
|
43
43
|
{
|
|
44
44
|
key: "isCaseSensitive",
|
|
@@ -428,6 +428,57 @@ exports.AI_AGENT_JOB = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
428
428
|
description: "UI__NODE_EDITOR__SERVICE__AI_AGENT_JOB__FIELDS__INCLUDE_ALL_OUTPUT_TYPES__DESCRIPTION",
|
|
429
429
|
defaultValue: true,
|
|
430
430
|
},
|
|
431
|
+
{
|
|
432
|
+
key: "advancedLogging",
|
|
433
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_JOB__FIELDS__ADVANCED_LOGGING__LABEL",
|
|
434
|
+
type: "toggle",
|
|
435
|
+
description: "UI__NODE_EDITOR__SERVICE__AI_AGENT_JOB__FIELDS__ADVANCED_LOGGING__DESCRIPTION",
|
|
436
|
+
defaultValue: false,
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
key: "loggingWebhookUrl",
|
|
440
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_JOB__FIELDS__LOGGING_WEBHOOK_URL__LABEL",
|
|
441
|
+
type: "cognigyText",
|
|
442
|
+
description: "UI__NODE_EDITOR__SERVICE__AI_AGENT_JOB__FIELDS__LOGGING_WEBHOOK_URL__DESCRIPTION",
|
|
443
|
+
defaultValue: "",
|
|
444
|
+
condition: {
|
|
445
|
+
key: "advancedLogging",
|
|
446
|
+
value: true
|
|
447
|
+
}
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
key: "loggingCustomData",
|
|
451
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_JOB__FIELDS__CUSTOM_LOGGING_DATA__LABEL",
|
|
452
|
+
type: "cognigyText",
|
|
453
|
+
description: "UI__NODE_EDITOR__SERVICE__AI_AGENT_JOB__FIELDS__CUSTOM_LOGGING_DATA__DESCRIPTION",
|
|
454
|
+
defaultValue: "",
|
|
455
|
+
condition: {
|
|
456
|
+
key: "advancedLogging",
|
|
457
|
+
value: true
|
|
458
|
+
}
|
|
459
|
+
},
|
|
460
|
+
{
|
|
461
|
+
key: "loggingHeaders",
|
|
462
|
+
type: "keyValuePairs",
|
|
463
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_JOB__FIELDS__LOGGING_HEADERS__LABEL",
|
|
464
|
+
description: "UI__NODE_EDITOR__SERVICE__AI_AGENT_JOB__FIELDS__LOGGING_HEADERS__DESCRIPTION",
|
|
465
|
+
defaultValue: "{}",
|
|
466
|
+
condition: {
|
|
467
|
+
key: "advancedLogging",
|
|
468
|
+
value: true
|
|
469
|
+
}
|
|
470
|
+
},
|
|
471
|
+
{
|
|
472
|
+
key: "conditionForLogging",
|
|
473
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_JOB__FIELDS__CONDITION_FOR_LOGGING__LABEL",
|
|
474
|
+
type: "cognigyText",
|
|
475
|
+
description: "UI__NODE_EDITOR__SERVICE__AI_AGENT_JOB__FIELDS__CONDITION_FOR_LOGGING__DESCRIPTION",
|
|
476
|
+
defaultValue: "",
|
|
477
|
+
condition: {
|
|
478
|
+
key: "advancedLogging",
|
|
479
|
+
value: true
|
|
480
|
+
}
|
|
481
|
+
},
|
|
431
482
|
{
|
|
432
483
|
key: "logErrorToSystem",
|
|
433
484
|
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_JOB__FIELDS__LOG_TO_SYSTEM__LABEL",
|
|
@@ -823,7 +874,7 @@ exports.AI_AGENT_JOB = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
823
874
|
"timeoutInMs",
|
|
824
875
|
"maxTokens",
|
|
825
876
|
"temperature",
|
|
826
|
-
"useTextAlternativeForLLM"
|
|
877
|
+
"useTextAlternativeForLLM"
|
|
827
878
|
],
|
|
828
879
|
},
|
|
829
880
|
{
|
|
@@ -848,7 +899,12 @@ exports.AI_AGENT_JOB = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
848
899
|
"debugLogTokenCount",
|
|
849
900
|
"debugLogSystemPrompt",
|
|
850
901
|
"debugLogToolDefinitions",
|
|
851
|
-
"debugLogLLMLatency"
|
|
902
|
+
"debugLogLLMLatency",
|
|
903
|
+
"advancedLogging",
|
|
904
|
+
"loggingWebhookUrl",
|
|
905
|
+
"loggingCustomData",
|
|
906
|
+
"conditionForLogging",
|
|
907
|
+
"loggingHeaders",
|
|
852
908
|
],
|
|
853
909
|
}
|
|
854
910
|
],
|
|
@@ -869,9 +925,9 @@ exports.AI_AGENT_JOB = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
869
925
|
],
|
|
870
926
|
tags: ["ai", "aiAgent"],
|
|
871
927
|
function: async ({ cognigy, config, childConfigs, nodeId }) => {
|
|
872
|
-
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;
|
|
928
|
+
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;
|
|
873
929
|
const { api, context, input, profile, flowReferenceId } = cognigy;
|
|
874
|
-
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, logErrorToSystem, storeErrorInInput, errorHandling, errorHandlingGotoTarget, errorMessage, debugConfig, debugLogTokenCount, debugLogSystemPrompt, debugLogToolDefinitions, debugResult, debugLogLLMLatency, storeLocation, contextKey, inputKey, streamStoreCopyInInput, streamStopTokens, processImages, transcriptImageHandling, sessionParams } = config;
|
|
930
|
+
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;
|
|
875
931
|
try {
|
|
876
932
|
if (!aiAgent) {
|
|
877
933
|
throw new Error("Could not resolve AI Agent reference in AI Agent Node");
|
|
@@ -919,7 +975,7 @@ exports.AI_AGENT_JOB = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
919
975
|
throw new Error(`[VG2] Error on AI Agent Job node. Error message: ${error.message}`);
|
|
920
976
|
}
|
|
921
977
|
}
|
|
922
|
-
const
|
|
978
|
+
const _25 = profile, { profileId, accepted_gdpr, prevent_data_collection, privacy_policy } = _25, cleanedProfile = __rest(_25, ["profileId", "accepted_gdpr", "prevent_data_collection", "privacy_policy"]);
|
|
923
979
|
const userMemory = (0, getUserMemory_1.getUserMemory)(memoryType, selectedProfileFields, aiAgent, cleanedProfile);
|
|
924
980
|
/**
|
|
925
981
|
* ----- Knowledge Search Section -----
|
|
@@ -1164,7 +1220,8 @@ exports.AI_AGENT_JOB = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
1164
1220
|
}
|
|
1165
1221
|
const isStreamingChannel = input.channel === "webchat3" || input.channel === "adminconsole";
|
|
1166
1222
|
const _messageId = (0, uuid_1.v4)();
|
|
1167
|
-
const
|
|
1223
|
+
const enableAdvancedLogging = advancedLogging && loggingWebhookUrl && (conditionForLogging === "" || !!conditionForLogging);
|
|
1224
|
+
const llmPromptOptions = Object.assign(Object.assign(Object.assign({ prompt: "", chat: systemMessage,
|
|
1168
1225
|
// Temp fix to override the transcript if needed
|
|
1169
1226
|
transcript: ((_0 = context === null || context === void 0 ? void 0 : context._cognigy) === null || _0 === void 0 ? void 0 : _0.transcript) ? [...context._cognigy.transcript] : transcript, detailedResults: true, timeoutInMs: timeoutInMs !== null && timeoutInMs !== void 0 ? timeoutInMs : 8000, maxTokens: maxTokens !== null && maxTokens !== void 0 ? maxTokens : 4000, temperature: temperature !== null && temperature !== void 0 ? temperature : 0.7, topP: 1, frequencyPenalty: 0, presencePenalty: 0, responseFormat: "text", stream: storeLocation === "stream", streamOnDataHandler: (text) => {
|
|
1170
1227
|
var _a;
|
|
@@ -1182,7 +1239,9 @@ exports.AI_AGENT_JOB = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
1182
1239
|
}
|
|
1183
1240
|
});
|
|
1184
1241
|
}
|
|
1185
|
-
}, streamStopTokens: streamStopTokens || [".", "!", "?", "\\n"], preventNewLineRemoval: isStreamingChannel ? true : false }, (tools.length > 0 && { tools })), (tools.length > 0 && { toolChoice: toolChoice }))
|
|
1242
|
+
}, streamStopTokens: streamStopTokens || [".", "!", "?", "\\n"], preventNewLineRemoval: isStreamingChannel ? true : false }, (tools.length > 0 && { tools })), (tools.length > 0 && { toolChoice: toolChoice })), (enableAdvancedLogging && {
|
|
1243
|
+
logging: Object.assign(Object.assign({ webhookUrl: loggingWebhookUrl }, (loggingCustomData && { customData: loggingCustomData })), (loggingHeaders && { headers: loggingHeaders }))
|
|
1244
|
+
}));
|
|
1186
1245
|
// llmProviderReferenceId `default` value is not a responseFormat, rather it is LLM Model default selection.
|
|
1187
1246
|
if (llmProviderReferenceId && llmProviderReferenceId !== "default") {
|
|
1188
1247
|
llmPromptOptions["llmProviderReferenceId"] = llmProviderReferenceId;
|
|
@@ -1257,20 +1316,21 @@ exports.AI_AGENT_JOB = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
1257
1316
|
node: nodeId,
|
|
1258
1317
|
} }, (isMcpToolCall && {
|
|
1259
1318
|
mcpServerUrl: (_8 = toolChild === null || toolChild === void 0 ? void 0 : toolChild.config) === null || _8 === void 0 ? void 0 : _8.mcpServerUrl,
|
|
1260
|
-
|
|
1319
|
+
mcpHeaders: (_9 = toolChild === null || toolChild === void 0 ? void 0 : toolChild.config) === null || _9 === void 0 ? void 0 : _9.mcpHeaders,
|
|
1320
|
+
timeout: (_10 = toolChild === null || toolChild === void 0 ? void 0 : toolChild.config) === null || _10 === void 0 ? void 0 : _10.timeout,
|
|
1261
1321
|
mcpToolNode: toolChild === null || toolChild === void 0 ? void 0 : toolChild.id,
|
|
1262
1322
|
})), { toolCall: mainToolCall }),
|
|
1263
1323
|
});
|
|
1264
1324
|
// if there are any parameters/arguments, add them to the input slots
|
|
1265
1325
|
if (mainToolCall.function.arguments) {
|
|
1266
|
-
input.aiAgent = Object.assign(Object.assign({}, input.aiAgent), { toolArgs: Object.assign(Object.assign({}, (
|
|
1326
|
+
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) });
|
|
1267
1327
|
}
|
|
1268
1328
|
// Debug Message for Tool Calls, configured in the Tool Node
|
|
1269
|
-
if ((
|
|
1329
|
+
if ((_13 = toolChild === null || toolChild === void 0 ? void 0 : toolChild.config) === null || _13 === void 0 ? void 0 : _13.debugMessage) {
|
|
1270
1330
|
const toolId = isMcpToolCall ? mainToolCall.function.name : await api.parseCognigyScriptText(toolChild.config.toolId);
|
|
1271
1331
|
const messageLines = [`<b>UI__DEBUG_MODE__AI_AGENT_JOB__TOOL_CALL__DEBUG_MESSAGE__HEADER:</b> ${toolId}`];
|
|
1272
1332
|
// Arguments / Parameters Slots
|
|
1273
|
-
const slots = ((
|
|
1333
|
+
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);
|
|
1274
1334
|
const hasSlots = slots && slots.length > 0;
|
|
1275
1335
|
messageLines.push(`<b>UI__DEBUG_MODE__AI_AGENT_JOB__TOOL_CALL__DEBUG_MESSAGE__SLOTS</b>${hasSlots ? "" : " -"}`);
|
|
1276
1336
|
if (hasSlots) {
|
|
@@ -1285,7 +1345,7 @@ exports.AI_AGENT_JOB = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
1285
1345
|
messageLines.push(`- ${slot}: ${slotValueAsString}`);
|
|
1286
1346
|
});
|
|
1287
1347
|
}
|
|
1288
|
-
(
|
|
1348
|
+
(_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");
|
|
1289
1349
|
}
|
|
1290
1350
|
if (toolChild) {
|
|
1291
1351
|
api.setNextNode(toolChild.id);
|
|
@@ -1310,11 +1370,11 @@ exports.AI_AGENT_JOB = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
1310
1370
|
}
|
|
1311
1371
|
// Optionally output the result immediately
|
|
1312
1372
|
if (llmResult.result && outputImmediately && !llmPromptOptions.stream) {
|
|
1313
|
-
await ((
|
|
1373
|
+
await ((_16 = api.output) === null || _16 === void 0 ? void 0 : _16.call(api, llmResult.result, {}));
|
|
1314
1374
|
}
|
|
1315
1375
|
else if (llmResult.finishReason && llmPromptOptions.stream) {
|
|
1316
1376
|
// send the finishReason as last output for a stream
|
|
1317
|
-
(
|
|
1377
|
+
(_17 = api.output) === null || _17 === void 0 ? void 0 : _17.call(api, "", {
|
|
1318
1378
|
_cognigy: {
|
|
1319
1379
|
_preventTranscript: true,
|
|
1320
1380
|
_messageId,
|
|
@@ -1337,7 +1397,7 @@ exports.AI_AGENT_JOB = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
1337
1397
|
}
|
|
1338
1398
|
// Add response to Cognigy Input/Context for further usage
|
|
1339
1399
|
if (storeLocation === "context") {
|
|
1340
|
-
(
|
|
1400
|
+
(_18 = api.addToContext) === null || _18 === void 0 ? void 0 : _18.call(api, contextKey, llmResult, "simple");
|
|
1341
1401
|
}
|
|
1342
1402
|
else if (storeLocation === "input") {
|
|
1343
1403
|
api.addToInput(inputKey, llmResult);
|
|
@@ -1350,14 +1410,14 @@ exports.AI_AGENT_JOB = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
1350
1410
|
const errorDetails = {
|
|
1351
1411
|
name: (error === null || error === void 0 ? void 0 : error.name) || "Error",
|
|
1352
1412
|
code: (error === null || error === void 0 ? void 0 : error.code) || (error === null || error === void 0 ? void 0 : error.httpStatusCode),
|
|
1353
|
-
message: (error === null || error === void 0 ? void 0 : error.message) || ((
|
|
1413
|
+
message: (error === null || error === void 0 ? void 0 : error.message) || ((_19 = error.originalErrorDetails) === null || _19 === void 0 ? void 0 : _19.message),
|
|
1354
1414
|
};
|
|
1355
|
-
(
|
|
1415
|
+
(_20 = api.emitEvent) === null || _20 === void 0 ? void 0 : _20.call(api, "nodeError", { nodeId, flowId: flowReferenceId, errorMessage: error });
|
|
1356
1416
|
if (logErrorToSystem) {
|
|
1357
|
-
(
|
|
1417
|
+
(_21 = api.log) === null || _21 === void 0 ? void 0 : _21.call(api, "error", JSON.stringify(errorDetails));
|
|
1358
1418
|
}
|
|
1359
1419
|
if (errorHandling !== "stop") {
|
|
1360
|
-
(
|
|
1420
|
+
(_22 = api.logDebugError) === null || _22 === void 0 ? void 0 : _22.call(api, errorDetails.message + (errorDetails.code ? ` (error code: ${errorDetails.code})` : ""), errorDetails.name);
|
|
1361
1421
|
}
|
|
1362
1422
|
if (storeErrorInInput) {
|
|
1363
1423
|
input.aiAgent = input.aiAgent || {};
|
|
@@ -1366,7 +1426,7 @@ exports.AI_AGENT_JOB = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
1366
1426
|
if (errorHandling === "continue") {
|
|
1367
1427
|
// output the timeout message
|
|
1368
1428
|
if (errorMessage) {
|
|
1369
|
-
await ((
|
|
1429
|
+
await ((_23 = api.output) === null || _23 === void 0 ? void 0 : _23.call(api, errorMessage, null));
|
|
1370
1430
|
}
|
|
1371
1431
|
// Set default node as next node
|
|
1372
1432
|
const defaultChild = childConfigs.find(child => child.type === "aiAgentJobDefault");
|
|
@@ -1378,7 +1438,7 @@ exports.AI_AGENT_JOB = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
1378
1438
|
if (!errorHandlingGotoTarget) {
|
|
1379
1439
|
throw new Error("GoTo Target is required");
|
|
1380
1440
|
}
|
|
1381
|
-
if (!((
|
|
1441
|
+
if (!((_24 = api.checkThink) === null || _24 === void 0 ? void 0 : _24.call(api, nodeId))) {
|
|
1382
1442
|
api.resetNextNodes();
|
|
1383
1443
|
await api.executeFlow({
|
|
1384
1444
|
flowNode: {
|
|
@@ -94,7 +94,7 @@ exports.AI_AGENT_JOB_CALL_MCP_TOOL = (0, createNodeDescriptor_1.createNodeDescri
|
|
|
94
94
|
},
|
|
95
95
|
tags: ["ai", "aiAgent"],
|
|
96
96
|
function: async ({ cognigy, config }) => {
|
|
97
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
97
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
98
98
|
const { api } = cognigy;
|
|
99
99
|
const { storeLocation, contextKey, inputKey, resolveImmediately, debugToolResult } = config;
|
|
100
100
|
const sessionState = await api.loadSessionState();
|
|
@@ -102,8 +102,9 @@ exports.AI_AGENT_JOB_CALL_MCP_TOOL = (0, createNodeDescriptor_1.createNodeDescri
|
|
|
102
102
|
const aiAgentJobNode = (_b = sessionState.lastToolCall) === null || _b === void 0 ? void 0 : _b.aiAgentJobNode;
|
|
103
103
|
const mcpServerUrl = (_c = sessionState.lastToolCall) === null || _c === void 0 ? void 0 : _c.mcpServerUrl;
|
|
104
104
|
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;
|
|
105
106
|
if (!(toolCall === null || toolCall === void 0 ? void 0 : toolCall.id)) {
|
|
106
|
-
(
|
|
107
|
+
(_f = api.logDebugError) === null || _f === void 0 ? void 0 : _f.call(api, "UI__DEBUG_MODE__AI_AGENT_ANSWER__ERROR__MESSAGE");
|
|
107
108
|
}
|
|
108
109
|
if (toolCall && aiAgentJobNode && mcpServerUrl && timeout) {
|
|
109
110
|
let toolResult = null;
|
|
@@ -114,10 +115,11 @@ exports.AI_AGENT_JOB_CALL_MCP_TOOL = (0, createNodeDescriptor_1.createNodeDescri
|
|
|
114
115
|
toolName: toolCall.function.name,
|
|
115
116
|
toolArgs: toolCall.function.arguments,
|
|
116
117
|
timeout,
|
|
118
|
+
mcpHeaders: mcpHeaders !== null && mcpHeaders !== void 0 ? mcpHeaders : {},
|
|
117
119
|
});
|
|
118
120
|
fullResult = JSON.stringify(toolResult, null, 2);
|
|
119
121
|
if (debugToolResult) {
|
|
120
|
-
(
|
|
122
|
+
(_g = api.logDebugMessage) === null || _g === void 0 ? void 0 : _g.call(api, `Tool <b>${(_h = toolCall === null || toolCall === void 0 ? void 0 : toolCall.function) === null || _h === void 0 ? void 0 : _h.name}</b> called successfully.<br><br><b>Result:</b><br>${fullResult}`);
|
|
121
123
|
}
|
|
122
124
|
}
|
|
123
125
|
catch (error) {
|
|
@@ -127,11 +129,11 @@ exports.AI_AGENT_JOB_CALL_MCP_TOOL = (0, createNodeDescriptor_1.createNodeDescri
|
|
|
127
129
|
message: error.message,
|
|
128
130
|
}
|
|
129
131
|
: error;
|
|
130
|
-
(
|
|
132
|
+
(_j = api.logDebugError) === null || _j === void 0 ? void 0 : _j.call(api, `Failed to execute MCP Tool ${(_k = toolCall === null || toolCall === void 0 ? void 0 : toolCall.function) === null || _k === void 0 ? void 0 : _k.name}:<br>${JSON.stringify(errorDetails, null, 2)}`);
|
|
131
133
|
}
|
|
132
134
|
// Add result to Cognigy Input/Context for further usage
|
|
133
135
|
if (storeLocation === "context") {
|
|
134
|
-
(
|
|
136
|
+
(_l = api.addToContext) === null || _l === void 0 ? void 0 : _l.call(api, contextKey, toolResult, "simple");
|
|
135
137
|
}
|
|
136
138
|
else if (storeLocation === "input") {
|
|
137
139
|
api.addToInput(inputKey, toolResult);
|
|
@@ -163,6 +163,13 @@ exports.AI_AGENT_JOB_MCP_TOOL = (0, createNodeDescriptor_1.createNodeDescriptor)
|
|
|
163
163
|
value: "blacklist",
|
|
164
164
|
},
|
|
165
165
|
},
|
|
166
|
+
{
|
|
167
|
+
key: "mcpHeaders",
|
|
168
|
+
type: "keyValuePairs",
|
|
169
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_MCP_TOOL__FIELDS__HEADERS__LABEL",
|
|
170
|
+
description: "UI__NODE_EDITOR__SERVICE__AI_AGENT_MCP_TOOL__FIELDS__HEADERS__DESCRIPTION",
|
|
171
|
+
defaultValue: "{}",
|
|
172
|
+
},
|
|
166
173
|
],
|
|
167
174
|
sections: [
|
|
168
175
|
{
|
|
@@ -175,7 +182,7 @@ exports.AI_AGENT_JOB_MCP_TOOL = (0, createNodeDescriptor_1.createNodeDescriptor)
|
|
|
175
182
|
key: "advanced",
|
|
176
183
|
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_JOB__SECTIONS__ADVANCED__LABEL",
|
|
177
184
|
defaultCollapsed: true,
|
|
178
|
-
fields: ["cacheTools", "condition", "toolFilter", "whitelist", "blacklist"],
|
|
185
|
+
fields: ["cacheTools", "condition", "toolFilter", "whitelist", "blacklist", "mcpHeaders"],
|
|
179
186
|
},
|
|
180
187
|
],
|
|
181
188
|
form: [
|
|
@@ -74,12 +74,14 @@ const createToolDefinitions = async (childConfigs, api, useStrict) => {
|
|
|
74
74
|
const cacheTools = child.config.cacheTools;
|
|
75
75
|
const sendDebug = child.config.debugMessageFetchedTools;
|
|
76
76
|
const toolFilter = child.config.toolFilter;
|
|
77
|
+
const mcpHeaders = child.config.mcpHeaders;
|
|
77
78
|
let mcpTools = null;
|
|
78
79
|
try {
|
|
79
80
|
mcpTools = await api.fetchMcpTools({
|
|
80
81
|
mcpServerUrl,
|
|
81
82
|
timeout,
|
|
82
83
|
cacheTools,
|
|
84
|
+
mcpHeaders,
|
|
83
85
|
});
|
|
84
86
|
}
|
|
85
87
|
catch (error) {
|