@cognigy/rest-api-client
Version:
Cognigy REST-Client
92 lines • 3.12 kB
JavaScript
;
/* Custom modules */
Object.defineProperty(exports, "__esModule", { value: true });
exports.AI_AGENT_HANDOVER = void 0;
/* Interfaces */
const createNodeDescriptor_1 = require("../../../createNodeDescriptor");
exports.AI_AGENT_HANDOVER = (0, createNodeDescriptor_1.createNodeDescriptor)({
type: "aiAgentHandover",
defaultLabel: "AI Agent Handover",
summary: "UI__NODE_EDITOR__SERVICE__AI_AGENT_HANDOVER__SUMMARY",
appearance: {
showIcon: false,
color: "#7F199B",
},
behavior: {
stopping: true
},
fields: [
{
key: "flowNode",
type: "flowNode",
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_HANDOVER__FIELDS__FLOW_NODE__LABEL",
params: {
required: true
}
},
{
key: "parseIntents",
type: "toggle",
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_HANDOVER__FIELDS__PARSE_INTENTS__LABEL",
description: "UI__NODE_EDITOR__SERVICE__AI_AGENT_HANDOVER__FIELDS__PARSE_INTENTS__DESCRIPTION",
defaultValue: false,
},
{
key: "parseKeyphrases",
type: "toggle",
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_HANDOVER__FIELDS__PARSE_KEYPHRASES__LABEL",
description: "UI__NODE_EDITOR__SERVICE__AI_AGENT_HANDOVER__FIELDS__PARSE_KEYPHRASES__DESCRIPTION",
defaultValue: false,
},
],
sections: [
{
key: "advanced",
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_HANDOVER__SECTIONS__ADVANCED__LABEL",
defaultCollapsed: true,
fields: [
"parseIntents",
"parseKeyphrases",
]
}
],
form: [
{ type: "field", key: "flowNode" },
{ type: "section", key: "advanced" }
],
preview: {
key: "flowNode",
type: "resource",
},
tags: ["ai", "aiAgent"],
function: async ({ cognigy, config, nodeId: thisNodeId }) => {
var _a, _b;
const { flowNode: { flow: flowId, node: nodeId }, parseIntents, parseKeyphrases } = config;
const { api } = cognigy;
if (!flowId) {
throw new Error("flowId is required");
}
if (!nodeId) {
throw new Error("nodeId is required");
}
if (!((_a = api.checkThink) === null || _a === void 0 ? void 0 : _a.call(api, thisNodeId))) {
api.resetNextNodes();
(_b = api.setThinkMarker) === null || _b === void 0 ? void 0 : _b.call(api, config.flowNode.flow);
// If Execution is to continue, execute Flow
await api.executeFlow({
flowNode: {
flow: flowId,
node: nodeId,
isGoto: true,
},
absorbContext: true,
parseIntents,
parseKeyphrases
});
}
else {
throw new Error("Infinite Loop Detected");
}
},
});
//# sourceMappingURL=aiAgentHandover.js.map