@atomoz/workflows-nodes 0.1.28 → 0.1.29
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/dist/index.cjs +347 -6
- package/dist/index.d.cts +31 -2
- package/dist/index.d.ts +31 -2
- package/dist/index.js +341 -6
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -67,8 +67,13 @@ __export(index_exports, {
|
|
|
67
67
|
IaMessageNode: () => IaMessageNode,
|
|
68
68
|
IaMessageNodeFunction: () => IaMessageNodeFunction,
|
|
69
69
|
IaMessageNodeSchema: () => IaMessageNodeSchema,
|
|
70
|
+
IsHumanActiveData: () => IsHumanActiveData,
|
|
70
71
|
QueryParamSchema: () => QueryParamSchema,
|
|
71
72
|
RouteSchema: () => RouteSchema,
|
|
73
|
+
SwitchNode: () => SwitchNode,
|
|
74
|
+
SwitchNodeFunction: () => SwitchNodeFunction,
|
|
75
|
+
VarNode: () => VarNode,
|
|
76
|
+
VarNodeFunction: () => VarNodeFunction,
|
|
72
77
|
WhatsappMessageTriggerNode: () => WhatsappMessageTriggerNode,
|
|
73
78
|
WhatsappSendMessageFunction: () => WhatsappSendMessageFunction,
|
|
74
79
|
WhatsappSendMessageNode: () => WhatsappSendMessageNode,
|
|
@@ -88,6 +93,7 @@ __export(index_exports, {
|
|
|
88
93
|
isHttpInputFriendlyId: () => isHttpInputFriendlyId,
|
|
89
94
|
isHttpInputNode: () => isHttpInputNode,
|
|
90
95
|
isHttpMethodNode: () => isHttpMethodNode,
|
|
96
|
+
isHumanActiveFunc: () => isHumanActiveFunc,
|
|
91
97
|
nodeFunctions: () => node_functions_default,
|
|
92
98
|
nodes: () => nodes_default,
|
|
93
99
|
schemas: () => schemas
|
|
@@ -339,7 +345,11 @@ var ChatInputNodeFunction = (params) => {
|
|
|
339
345
|
const { message: configMessage, chatId: configChatId } = fieldValues || {};
|
|
340
346
|
const actualData = {
|
|
341
347
|
message: request?.message ?? configMessage ?? "",
|
|
342
|
-
chatId: request?.chatId ?? configChatId ?? null
|
|
348
|
+
chatId: request?.chatId ?? configChatId ?? null,
|
|
349
|
+
roomId: request?.sessionId ?? request?.chatId ?? configChatId ?? null,
|
|
350
|
+
// Room = Session/Chat
|
|
351
|
+
source: "chat"
|
|
352
|
+
// Hardcoded source for web chat
|
|
343
353
|
};
|
|
344
354
|
if (!actualData.message || typeof actualData.message !== "string") {
|
|
345
355
|
throw new Error("Message is required for ChatInputNode");
|
|
@@ -382,6 +392,33 @@ var ChatInputNode = {
|
|
|
382
392
|
name: "chatId",
|
|
383
393
|
fieldType: "string"
|
|
384
394
|
}
|
|
395
|
+
},
|
|
396
|
+
{
|
|
397
|
+
id: "roomId",
|
|
398
|
+
label: "Room ID",
|
|
399
|
+
type: "string",
|
|
400
|
+
required: false,
|
|
401
|
+
typeable: false,
|
|
402
|
+
handle: {
|
|
403
|
+
type: "output",
|
|
404
|
+
label: "Room ID",
|
|
405
|
+
name: "roomId",
|
|
406
|
+
fieldType: "string"
|
|
407
|
+
}
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
id: "source",
|
|
411
|
+
label: "Source",
|
|
412
|
+
type: "string",
|
|
413
|
+
required: false,
|
|
414
|
+
typeable: false,
|
|
415
|
+
defaultValue: "chat",
|
|
416
|
+
handle: {
|
|
417
|
+
type: "output",
|
|
418
|
+
label: "Source",
|
|
419
|
+
name: "source",
|
|
420
|
+
fieldType: "string"
|
|
421
|
+
}
|
|
385
422
|
}
|
|
386
423
|
]
|
|
387
424
|
};
|
|
@@ -1104,7 +1141,7 @@ async function createLLMFromModel(modelConfig, authToken, streaming = false) {
|
|
|
1104
1141
|
case "gemini":
|
|
1105
1142
|
return new import_google_gauth.ChatGoogle({
|
|
1106
1143
|
model: "gemini-flash-latest",
|
|
1107
|
-
apiKey: "
|
|
1144
|
+
apiKey: "AIzaSyBLeXr43XWg1lOQfsUTZQ85IX-IYYpZIW0",
|
|
1108
1145
|
streaming
|
|
1109
1146
|
});
|
|
1110
1147
|
case "openai":
|
|
@@ -2057,7 +2094,8 @@ var import_tools = require("@langchain/core/tools");
|
|
|
2057
2094
|
// src/nodes/memory/postgres/data.ts
|
|
2058
2095
|
var import_zod8 = require("zod");
|
|
2059
2096
|
var PostgresMemoryNodeSchema = import_zod8.z.object({
|
|
2060
|
-
connectionString: import_zod8.z.string().describe("PostgreSQL connection string")
|
|
2097
|
+
connectionString: import_zod8.z.string().describe("PostgreSQL connection string"),
|
|
2098
|
+
threadId: import_zod8.z.string().optional().describe("Thread ID for conversation isolation")
|
|
2061
2099
|
});
|
|
2062
2100
|
var PostgresMemoryNode = {
|
|
2063
2101
|
label: "Postgres Memory",
|
|
@@ -2079,6 +2117,20 @@ var PostgresMemoryNode = {
|
|
|
2079
2117
|
defaultValue: "postgresql://yugabyte:yugabyte@localhost:5433/workflows",
|
|
2080
2118
|
placeholder: "postgresql://user:pass@host:5432/database"
|
|
2081
2119
|
},
|
|
2120
|
+
{
|
|
2121
|
+
id: "threadId",
|
|
2122
|
+
label: "Thread ID",
|
|
2123
|
+
type: "string",
|
|
2124
|
+
required: false,
|
|
2125
|
+
typeable: true,
|
|
2126
|
+
placeholder: "Thread/Session ID for conversation isolation",
|
|
2127
|
+
handle: {
|
|
2128
|
+
type: "input",
|
|
2129
|
+
label: "Thread ID",
|
|
2130
|
+
name: "threadId",
|
|
2131
|
+
fieldType: "string"
|
|
2132
|
+
}
|
|
2133
|
+
},
|
|
2082
2134
|
{
|
|
2083
2135
|
id: "checkpointer",
|
|
2084
2136
|
label: "Checkpointer",
|
|
@@ -2101,12 +2153,15 @@ var PostgresMemoryNodeFunction = async (inputs) => {
|
|
|
2101
2153
|
const { $field: _$field, $req: _$req, $inputs: _$inputs, $vars: _$vars } = inputs;
|
|
2102
2154
|
const fieldValues = inputs.fieldValues || {};
|
|
2103
2155
|
const connectionString = fieldValues.connectionString || inputs.connectionString || "postgresql://yugabyte:yugabyte@localhost:5433/workflows";
|
|
2156
|
+
const threadId = inputs.threadId ?? fieldValues.threadId;
|
|
2104
2157
|
try {
|
|
2105
2158
|
const checkpointer = import_langgraph_checkpoint_postgres.PostgresSaver.fromConnString(connectionString);
|
|
2106
2159
|
await checkpointer.setup();
|
|
2107
|
-
console.log(
|
|
2160
|
+
console.log(`\u2705 PostgresMemory: Checkpointer initialized${threadId ? ` with threadId: ${threadId}` : ""}`);
|
|
2108
2161
|
return {
|
|
2109
2162
|
checkpointer,
|
|
2163
|
+
threadId,
|
|
2164
|
+
// Pass threadId to agent for conversation isolation
|
|
2110
2165
|
type: "PostgresMemoryNode",
|
|
2111
2166
|
connectionString: connectionString.replace(/:[^:@]+@/, ":***@")
|
|
2112
2167
|
// Hide password in output
|
|
@@ -2510,6 +2565,20 @@ var WhatsappMessageTriggerNode = {
|
|
|
2510
2565
|
name: "message",
|
|
2511
2566
|
fieldType: "string"
|
|
2512
2567
|
}
|
|
2568
|
+
},
|
|
2569
|
+
{
|
|
2570
|
+
id: "source",
|
|
2571
|
+
label: "Source",
|
|
2572
|
+
type: "string",
|
|
2573
|
+
required: false,
|
|
2574
|
+
typeable: false,
|
|
2575
|
+
defaultValue: "whatsapp",
|
|
2576
|
+
handle: {
|
|
2577
|
+
type: "output",
|
|
2578
|
+
label: "Source",
|
|
2579
|
+
name: "source",
|
|
2580
|
+
fieldType: "string"
|
|
2581
|
+
}
|
|
2513
2582
|
}
|
|
2514
2583
|
]
|
|
2515
2584
|
};
|
|
@@ -3659,6 +3728,266 @@ var ChatLogNodeFunction = async (inputs) => {
|
|
|
3659
3728
|
}
|
|
3660
3729
|
};
|
|
3661
3730
|
|
|
3731
|
+
// src/nodes/chat/isHumanActive/data.ts
|
|
3732
|
+
var IsHumanActiveData = {
|
|
3733
|
+
label: "Is Human Active?",
|
|
3734
|
+
type: "isHumanActive",
|
|
3735
|
+
category: "chat",
|
|
3736
|
+
description: "Checks if a human agent is currently handling the conversation (handoff mode).",
|
|
3737
|
+
icon: "\u{1F464}",
|
|
3738
|
+
group: "Chat",
|
|
3739
|
+
tags: {
|
|
3740
|
+
execution: "async",
|
|
3741
|
+
group: "Chat"
|
|
3742
|
+
},
|
|
3743
|
+
fields: [
|
|
3744
|
+
{
|
|
3745
|
+
id: "threadId",
|
|
3746
|
+
label: "Thread ID",
|
|
3747
|
+
type: "string",
|
|
3748
|
+
required: false,
|
|
3749
|
+
typeable: true,
|
|
3750
|
+
placeholder: "Session/Thread ID (optional, uses context if empty)",
|
|
3751
|
+
handle: {
|
|
3752
|
+
type: "input",
|
|
3753
|
+
label: "Thread ID",
|
|
3754
|
+
name: "threadId",
|
|
3755
|
+
fieldType: "string"
|
|
3756
|
+
}
|
|
3757
|
+
},
|
|
3758
|
+
{
|
|
3759
|
+
id: "active",
|
|
3760
|
+
label: "Active",
|
|
3761
|
+
type: "boolean",
|
|
3762
|
+
required: true,
|
|
3763
|
+
typeable: false,
|
|
3764
|
+
handle: {
|
|
3765
|
+
type: "output",
|
|
3766
|
+
label: "Active",
|
|
3767
|
+
name: "active",
|
|
3768
|
+
fieldType: "continue"
|
|
3769
|
+
}
|
|
3770
|
+
},
|
|
3771
|
+
{
|
|
3772
|
+
id: "inactive",
|
|
3773
|
+
label: "Inactive",
|
|
3774
|
+
type: "boolean",
|
|
3775
|
+
required: true,
|
|
3776
|
+
typeable: false,
|
|
3777
|
+
handle: {
|
|
3778
|
+
type: "output",
|
|
3779
|
+
label: "Inactive",
|
|
3780
|
+
name: "inactive",
|
|
3781
|
+
fieldType: "continue"
|
|
3782
|
+
}
|
|
3783
|
+
}
|
|
3784
|
+
]
|
|
3785
|
+
};
|
|
3786
|
+
|
|
3787
|
+
// src/nodes/chat/isHumanActive/function.ts
|
|
3788
|
+
var isHumanActiveFunc = async (inputs) => {
|
|
3789
|
+
const fieldValues = inputs.fieldValues || {};
|
|
3790
|
+
const context = inputs.context || {};
|
|
3791
|
+
const sessionId = inputs.threadId || fieldValues.threadId || context?.sessionId || context?.chatId;
|
|
3792
|
+
if (!sessionId) {
|
|
3793
|
+
console.warn("[IsHumanActive] No sessionId found in input or context.");
|
|
3794
|
+
return {
|
|
3795
|
+
active: false,
|
|
3796
|
+
inactive: true
|
|
3797
|
+
};
|
|
3798
|
+
}
|
|
3799
|
+
const db = context?.db;
|
|
3800
|
+
if (!db) {
|
|
3801
|
+
console.warn("[IsHumanActive] No database connection in context.");
|
|
3802
|
+
return { active: false, inactive: true };
|
|
3803
|
+
}
|
|
3804
|
+
try {
|
|
3805
|
+
const result = await db.query(`
|
|
3806
|
+
SELECT human_active_until
|
|
3807
|
+
FROM chat_sessions
|
|
3808
|
+
WHERE session_id = $1
|
|
3809
|
+
LIMIT 1
|
|
3810
|
+
`, [sessionId]);
|
|
3811
|
+
const session = result.rows?.[0];
|
|
3812
|
+
if (!session) {
|
|
3813
|
+
console.warn(`[IsHumanActive] Session not found: ${sessionId}`);
|
|
3814
|
+
return { active: false, inactive: true };
|
|
3815
|
+
}
|
|
3816
|
+
const now = /* @__PURE__ */ new Date();
|
|
3817
|
+
const isActive = session.human_active_until && new Date(session.human_active_until) > now;
|
|
3818
|
+
console.log(`[IsHumanActive] Session: ${sessionId}, Until: ${session.human_active_until}, Active: ${isActive}`);
|
|
3819
|
+
return {
|
|
3820
|
+
active: !!isActive,
|
|
3821
|
+
inactive: !isActive
|
|
3822
|
+
};
|
|
3823
|
+
} catch (error) {
|
|
3824
|
+
console.error("[IsHumanActive] Error querying session:", error);
|
|
3825
|
+
return { active: false, inactive: true };
|
|
3826
|
+
}
|
|
3827
|
+
};
|
|
3828
|
+
|
|
3829
|
+
// src/nodes/logic/varNode/data.ts
|
|
3830
|
+
var VarNode = {
|
|
3831
|
+
label: "Variable",
|
|
3832
|
+
type: "VarNode",
|
|
3833
|
+
category: "logic",
|
|
3834
|
+
description: "Stores a value from multiple inputs. Strategy: keep first or last value received.",
|
|
3835
|
+
icon: "\u{1F4E6}",
|
|
3836
|
+
group: "Control",
|
|
3837
|
+
tags: {
|
|
3838
|
+
execution: "sync",
|
|
3839
|
+
group: "Control"
|
|
3840
|
+
},
|
|
3841
|
+
fields: [
|
|
3842
|
+
{
|
|
3843
|
+
id: "strategy",
|
|
3844
|
+
label: "Strategy",
|
|
3845
|
+
type: "select",
|
|
3846
|
+
required: true,
|
|
3847
|
+
defaultValue: "first",
|
|
3848
|
+
options: [
|
|
3849
|
+
{ label: "First Value", value: "first" },
|
|
3850
|
+
{ label: "Last Value", value: "last" }
|
|
3851
|
+
]
|
|
3852
|
+
},
|
|
3853
|
+
{
|
|
3854
|
+
id: "value",
|
|
3855
|
+
label: "Value",
|
|
3856
|
+
type: "any",
|
|
3857
|
+
required: false,
|
|
3858
|
+
typeable: true,
|
|
3859
|
+
handle: {
|
|
3860
|
+
type: "input",
|
|
3861
|
+
label: "Value",
|
|
3862
|
+
name: "value",
|
|
3863
|
+
fieldType: "any",
|
|
3864
|
+
maxConnections: 10
|
|
3865
|
+
// Allow multiple connections
|
|
3866
|
+
}
|
|
3867
|
+
},
|
|
3868
|
+
{
|
|
3869
|
+
id: "output",
|
|
3870
|
+
label: "Output",
|
|
3871
|
+
type: "any",
|
|
3872
|
+
required: true,
|
|
3873
|
+
typeable: false,
|
|
3874
|
+
handle: {
|
|
3875
|
+
type: "output",
|
|
3876
|
+
label: "Value",
|
|
3877
|
+
name: "output",
|
|
3878
|
+
fieldType: "any"
|
|
3879
|
+
}
|
|
3880
|
+
},
|
|
3881
|
+
// Continue handle (hidden by default)
|
|
3882
|
+
{
|
|
3883
|
+
id: "continue",
|
|
3884
|
+
label: "Continue",
|
|
3885
|
+
type: "continue",
|
|
3886
|
+
typeable: false,
|
|
3887
|
+
active: false,
|
|
3888
|
+
// Hidden by default
|
|
3889
|
+
handle: {
|
|
3890
|
+
type: "output",
|
|
3891
|
+
label: "Continue",
|
|
3892
|
+
name: "continue",
|
|
3893
|
+
fieldType: "continue"
|
|
3894
|
+
}
|
|
3895
|
+
}
|
|
3896
|
+
]
|
|
3897
|
+
};
|
|
3898
|
+
|
|
3899
|
+
// src/nodes/logic/varNode/function.ts
|
|
3900
|
+
var VarNodeFunction = async (inputs) => {
|
|
3901
|
+
const fieldValues = inputs.fieldValues || {};
|
|
3902
|
+
const strategy = fieldValues.strategy || "first";
|
|
3903
|
+
let values = inputs.value ?? fieldValues.value;
|
|
3904
|
+
if (!Array.isArray(values)) {
|
|
3905
|
+
values = values !== void 0 ? [values] : [];
|
|
3906
|
+
}
|
|
3907
|
+
const validValues = values.filter((v) => v !== void 0 && v !== null);
|
|
3908
|
+
if (validValues.length === 0) {
|
|
3909
|
+
return { output: void 0, continue: true };
|
|
3910
|
+
}
|
|
3911
|
+
const result = strategy === "first" ? validValues[0] : validValues[validValues.length - 1];
|
|
3912
|
+
return {
|
|
3913
|
+
output: result,
|
|
3914
|
+
continue: true
|
|
3915
|
+
};
|
|
3916
|
+
};
|
|
3917
|
+
|
|
3918
|
+
// src/nodes/logic/switchNode/data.ts
|
|
3919
|
+
var SwitchNode = {
|
|
3920
|
+
label: "Switch",
|
|
3921
|
+
type: "SwitchNode",
|
|
3922
|
+
category: "logic",
|
|
3923
|
+
description: "Routes execution based on input value. Each case triggers its corresponding path.",
|
|
3924
|
+
icon: "\u{1F500}",
|
|
3925
|
+
group: "Control",
|
|
3926
|
+
tags: {
|
|
3927
|
+
execution: "sync",
|
|
3928
|
+
group: "Control"
|
|
3929
|
+
},
|
|
3930
|
+
fields: [
|
|
3931
|
+
{
|
|
3932
|
+
id: "value",
|
|
3933
|
+
label: "Value",
|
|
3934
|
+
type: "string",
|
|
3935
|
+
required: true,
|
|
3936
|
+
typeable: true,
|
|
3937
|
+
placeholder: "Value to match",
|
|
3938
|
+
handle: {
|
|
3939
|
+
type: "input",
|
|
3940
|
+
label: "Value",
|
|
3941
|
+
name: "value",
|
|
3942
|
+
fieldType: "string"
|
|
3943
|
+
}
|
|
3944
|
+
},
|
|
3945
|
+
{
|
|
3946
|
+
id: "cases",
|
|
3947
|
+
label: "Cases",
|
|
3948
|
+
type: "keyValue",
|
|
3949
|
+
required: true,
|
|
3950
|
+
defaultValue: [
|
|
3951
|
+
{ key: "whatsapp", value: "WhatsApp" },
|
|
3952
|
+
{ key: "chat", value: "Web Chat" }
|
|
3953
|
+
],
|
|
3954
|
+
placeholder: "Add cases (key = match value, value = label)"
|
|
3955
|
+
},
|
|
3956
|
+
{
|
|
3957
|
+
id: "includeDefault",
|
|
3958
|
+
label: "Include Default Path",
|
|
3959
|
+
type: "boolean",
|
|
3960
|
+
required: false,
|
|
3961
|
+
defaultValue: true
|
|
3962
|
+
}
|
|
3963
|
+
// Note: Dynamic outputs are generated based on 'cases' at runtime
|
|
3964
|
+
// Each case.key becomes an output handle of type 'continue'
|
|
3965
|
+
// Plus optional 'default' output if includeDefault is true
|
|
3966
|
+
]
|
|
3967
|
+
};
|
|
3968
|
+
|
|
3969
|
+
// src/nodes/logic/switchNode/function.ts
|
|
3970
|
+
var SwitchNodeFunction = async (inputs) => {
|
|
3971
|
+
const fieldValues = inputs.fieldValues || {};
|
|
3972
|
+
const inputValue = inputs.value ?? fieldValues.value;
|
|
3973
|
+
const cases = fieldValues.cases || [];
|
|
3974
|
+
const includeDefault = fieldValues.includeDefault ?? true;
|
|
3975
|
+
const outputs = {};
|
|
3976
|
+
for (const c of cases) {
|
|
3977
|
+
outputs[c.key] = false;
|
|
3978
|
+
}
|
|
3979
|
+
if (includeDefault) {
|
|
3980
|
+
outputs["default"] = false;
|
|
3981
|
+
}
|
|
3982
|
+
const matchedCase = cases.find((c) => c.key === inputValue);
|
|
3983
|
+
if (matchedCase) {
|
|
3984
|
+
outputs[matchedCase.key] = true;
|
|
3985
|
+
} else if (includeDefault) {
|
|
3986
|
+
outputs["default"] = true;
|
|
3987
|
+
}
|
|
3988
|
+
return outputs;
|
|
3989
|
+
};
|
|
3990
|
+
|
|
3662
3991
|
// src/nodes/consts/nodes.ts
|
|
3663
3992
|
var nodes = [
|
|
3664
3993
|
ChatInputNode,
|
|
@@ -3687,7 +4016,10 @@ var nodes = [
|
|
|
3687
4016
|
FunctionGuardrailNode,
|
|
3688
4017
|
ModelGuardrailNode,
|
|
3689
4018
|
GetOrCreateThreadNode,
|
|
3690
|
-
ChatLogNode
|
|
4019
|
+
ChatLogNode,
|
|
4020
|
+
IsHumanActiveData,
|
|
4021
|
+
VarNode,
|
|
4022
|
+
SwitchNode
|
|
3691
4023
|
];
|
|
3692
4024
|
var nodes_default = nodes;
|
|
3693
4025
|
|
|
@@ -3811,7 +4143,10 @@ var nodeFunctions = {
|
|
|
3811
4143
|
FunctionGuardrailNode: FunctionGuardrailNodeFunction,
|
|
3812
4144
|
ModelGuardrailNode: ModelGuardrailNodeFunction,
|
|
3813
4145
|
GetOrCreateThreadNode: GetOrCreateThreadNodeFunction,
|
|
3814
|
-
ChatLogNode: ChatLogNodeFunction
|
|
4146
|
+
ChatLogNode: ChatLogNodeFunction,
|
|
4147
|
+
isHumanActive: isHumanActiveFunc,
|
|
4148
|
+
VarNode: VarNodeFunction,
|
|
4149
|
+
SwitchNode: SwitchNodeFunction
|
|
3815
4150
|
};
|
|
3816
4151
|
var node_functions_default = nodeFunctions;
|
|
3817
4152
|
|
|
@@ -4235,8 +4570,13 @@ var getHttpMethodFromFriendlyId = (friendlyId) => {
|
|
|
4235
4570
|
IaMessageNode,
|
|
4236
4571
|
IaMessageNodeFunction,
|
|
4237
4572
|
IaMessageNodeSchema,
|
|
4573
|
+
IsHumanActiveData,
|
|
4238
4574
|
QueryParamSchema,
|
|
4239
4575
|
RouteSchema,
|
|
4576
|
+
SwitchNode,
|
|
4577
|
+
SwitchNodeFunction,
|
|
4578
|
+
VarNode,
|
|
4579
|
+
VarNodeFunction,
|
|
4240
4580
|
WhatsappMessageTriggerNode,
|
|
4241
4581
|
WhatsappSendMessageFunction,
|
|
4242
4582
|
WhatsappSendMessageNode,
|
|
@@ -4256,6 +4596,7 @@ var getHttpMethodFromFriendlyId = (friendlyId) => {
|
|
|
4256
4596
|
isHttpInputFriendlyId,
|
|
4257
4597
|
isHttpInputNode,
|
|
4258
4598
|
isHttpMethodNode,
|
|
4599
|
+
isHumanActiveFunc,
|
|
4259
4600
|
nodeFunctions,
|
|
4260
4601
|
nodes,
|
|
4261
4602
|
schemas
|
package/dist/index.d.cts
CHANGED
|
@@ -18,7 +18,7 @@ interface NodeField {
|
|
|
18
18
|
label: string;
|
|
19
19
|
toolField?: boolean;
|
|
20
20
|
typeable?: boolean;
|
|
21
|
-
type: 'text' | 'textarea' | 'number' | 'boolean' | 'select' | 'json' | 'string' | 'object' | 'HttpOutput' | 'route' | 'code' | 'keyValue' | 'any' | 'llm' | 'function' | 'agent' | 'tool' | 'model' | 'supervisor' | 'memory' | 'guardrail';
|
|
21
|
+
type: 'text' | 'textarea' | 'number' | 'boolean' | 'select' | 'json' | 'string' | 'object' | 'HttpOutput' | 'route' | 'code' | 'keyValue' | 'any' | 'llm' | 'function' | 'agent' | 'tool' | 'model' | 'supervisor' | 'memory' | 'guardrail' | 'continue';
|
|
22
22
|
required?: boolean;
|
|
23
23
|
placeholder?: string;
|
|
24
24
|
defaultValue?: any;
|
|
@@ -193,6 +193,9 @@ declare const nodeFunctions: {
|
|
|
193
193
|
ModelGuardrailNode: (inputs: any) => Promise<any>;
|
|
194
194
|
GetOrCreateThreadNode: (inputs: any) => Promise<any>;
|
|
195
195
|
ChatLogNode: (inputs: any) => Promise<any>;
|
|
196
|
+
isHumanActive: (inputs: any) => Promise<any>;
|
|
197
|
+
VarNode: (inputs: any) => Promise<any>;
|
|
198
|
+
SwitchNode: (inputs: any) => Promise<any>;
|
|
196
199
|
};
|
|
197
200
|
|
|
198
201
|
declare const IaAgentNodeSchema: z.ZodObject<{
|
|
@@ -420,6 +423,7 @@ declare const schemas: {
|
|
|
420
423
|
}, zod_v4_core.$strip>;
|
|
421
424
|
PostgresMemoryNode: zod.ZodObject<{
|
|
422
425
|
connectionString: zod.ZodString;
|
|
426
|
+
threadId: zod.ZodOptional<zod.ZodString>;
|
|
423
427
|
}, zod_v4_core.$strip>;
|
|
424
428
|
RedisMemoryNode: zod.ZodObject<{
|
|
425
429
|
redisUrl: zod.ZodString;
|
|
@@ -482,4 +486,29 @@ declare const ChatLogNode: NodeData;
|
|
|
482
486
|
*/
|
|
483
487
|
declare const ChatLogNodeFunction: (inputs: any) => Promise<any>;
|
|
484
488
|
|
|
485
|
-
|
|
489
|
+
declare const IsHumanActiveData: NodeData;
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* IsHumanActive Node Function
|
|
493
|
+
*
|
|
494
|
+
* Checks if a human agent is currently active in the conversation.
|
|
495
|
+
* Returns { active: true, inactive: false } or vice versa.
|
|
496
|
+
*
|
|
497
|
+
* Note: This node requires database access via context to check session state.
|
|
498
|
+
*/
|
|
499
|
+
declare const isHumanActiveFunc: (inputs: any) => Promise<any>;
|
|
500
|
+
|
|
501
|
+
declare const VarNode: NodeData;
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* VarNode Function
|
|
505
|
+
*
|
|
506
|
+
* Stores a value from multiple inputs using first/last strategy.
|
|
507
|
+
*/
|
|
508
|
+
declare const VarNodeFunction: (inputs: any) => Promise<any>;
|
|
509
|
+
|
|
510
|
+
declare const SwitchNode: NodeData;
|
|
511
|
+
|
|
512
|
+
declare const SwitchNodeFunction: (inputs: any) => Promise<any>;
|
|
513
|
+
|
|
514
|
+
export { AiSupervisorNode, AiSupervisorNodeFunction, AiSupervisorNodeSchema, AiToolNode, AiToolNodeFunction, AiToolNodeSchema, type BaseNodeType, BodyFieldSchema, ChatLogNode, ChatLogNodeFunction, ChatLogSchema, CustomToolSchema, type ExecutionStep, GetOrCreateThreadNode, GetOrCreateThreadNodeFunction, GetOrCreateThreadSchema, HTTP_METHODS, HTTP_NODE_TYPES, HeaderSchema, HttpDeleteInputNode, HttpDeleteInputNodeFunction, HttpDeleteInputNodeSchema, type HttpDeleteInputNodeType, HttpGetInputNode, HttpGetInputNodeFunction, HttpGetInputNodeSchema, type HttpGetInputNodeType, type HttpMethod, type HttpNodeType, type HttpOutput, HttpPatchInputNode, HttpPatchInputNodeFunction, HttpPatchInputNodeSchema, type HttpPatchInputNodeType, HttpPostInputNode, HttpPostInputNodeFunction, HttpPostInputNodeSchema, type HttpPostInputNodeType, HttpPutInputNode, HttpPutInputNodeFunction, HttpPutInputNodeSchema, type HttpPutInputNodeType, IaAgentNode, IaAgentNodeFunction, IaAgentNodeSchema, IaMessageNode, IaMessageNodeFunction, IaMessageNodeSchema, IsHumanActiveData, type NodeData, type NodeDefinition, type NodeExecution, type NodeExecutionConfig, type NodeExecutionContext, type NodeField, type NodeHandle, type NodeInput, type NodeInputValue, type NodeLogicFunction, type NodeOutput, type NodeOutputValue, type NodeStyle, type NodeTags, type NodeTransformation, type NodeValidation, QueryParamSchema, RouteSchema, SwitchNode, SwitchNodeFunction, VarNode, VarNodeFunction, WhatsappMessageTriggerNode, WhatsappSendMessageFunction, WhatsappSendMessageNode, WhatsappSendMessageNodeSchema, WhatsappSendTemplateNode, WhatsappSendTemplateNodeSchema, WhatsappStartChatFunction, createMessageTemplate, extractHttpMethodFromNodeType, getHttpMethodFromFriendlyId, getHttpMethodFromNodeType, getHttpNodeTypeStrings, getHttpNodeTypesArray, getHttpNodesTypes, getMessageTemplates, isAnyHttpInputNode, isHttpInputFriendlyId, isHttpInputNode, isHttpMethodNode, isHumanActiveFunc, nodeFunctions, nodes, schemas };
|
package/dist/index.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ interface NodeField {
|
|
|
18
18
|
label: string;
|
|
19
19
|
toolField?: boolean;
|
|
20
20
|
typeable?: boolean;
|
|
21
|
-
type: 'text' | 'textarea' | 'number' | 'boolean' | 'select' | 'json' | 'string' | 'object' | 'HttpOutput' | 'route' | 'code' | 'keyValue' | 'any' | 'llm' | 'function' | 'agent' | 'tool' | 'model' | 'supervisor' | 'memory' | 'guardrail';
|
|
21
|
+
type: 'text' | 'textarea' | 'number' | 'boolean' | 'select' | 'json' | 'string' | 'object' | 'HttpOutput' | 'route' | 'code' | 'keyValue' | 'any' | 'llm' | 'function' | 'agent' | 'tool' | 'model' | 'supervisor' | 'memory' | 'guardrail' | 'continue';
|
|
22
22
|
required?: boolean;
|
|
23
23
|
placeholder?: string;
|
|
24
24
|
defaultValue?: any;
|
|
@@ -193,6 +193,9 @@ declare const nodeFunctions: {
|
|
|
193
193
|
ModelGuardrailNode: (inputs: any) => Promise<any>;
|
|
194
194
|
GetOrCreateThreadNode: (inputs: any) => Promise<any>;
|
|
195
195
|
ChatLogNode: (inputs: any) => Promise<any>;
|
|
196
|
+
isHumanActive: (inputs: any) => Promise<any>;
|
|
197
|
+
VarNode: (inputs: any) => Promise<any>;
|
|
198
|
+
SwitchNode: (inputs: any) => Promise<any>;
|
|
196
199
|
};
|
|
197
200
|
|
|
198
201
|
declare const IaAgentNodeSchema: z.ZodObject<{
|
|
@@ -420,6 +423,7 @@ declare const schemas: {
|
|
|
420
423
|
}, zod_v4_core.$strip>;
|
|
421
424
|
PostgresMemoryNode: zod.ZodObject<{
|
|
422
425
|
connectionString: zod.ZodString;
|
|
426
|
+
threadId: zod.ZodOptional<zod.ZodString>;
|
|
423
427
|
}, zod_v4_core.$strip>;
|
|
424
428
|
RedisMemoryNode: zod.ZodObject<{
|
|
425
429
|
redisUrl: zod.ZodString;
|
|
@@ -482,4 +486,29 @@ declare const ChatLogNode: NodeData;
|
|
|
482
486
|
*/
|
|
483
487
|
declare const ChatLogNodeFunction: (inputs: any) => Promise<any>;
|
|
484
488
|
|
|
485
|
-
|
|
489
|
+
declare const IsHumanActiveData: NodeData;
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* IsHumanActive Node Function
|
|
493
|
+
*
|
|
494
|
+
* Checks if a human agent is currently active in the conversation.
|
|
495
|
+
* Returns { active: true, inactive: false } or vice versa.
|
|
496
|
+
*
|
|
497
|
+
* Note: This node requires database access via context to check session state.
|
|
498
|
+
*/
|
|
499
|
+
declare const isHumanActiveFunc: (inputs: any) => Promise<any>;
|
|
500
|
+
|
|
501
|
+
declare const VarNode: NodeData;
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* VarNode Function
|
|
505
|
+
*
|
|
506
|
+
* Stores a value from multiple inputs using first/last strategy.
|
|
507
|
+
*/
|
|
508
|
+
declare const VarNodeFunction: (inputs: any) => Promise<any>;
|
|
509
|
+
|
|
510
|
+
declare const SwitchNode: NodeData;
|
|
511
|
+
|
|
512
|
+
declare const SwitchNodeFunction: (inputs: any) => Promise<any>;
|
|
513
|
+
|
|
514
|
+
export { AiSupervisorNode, AiSupervisorNodeFunction, AiSupervisorNodeSchema, AiToolNode, AiToolNodeFunction, AiToolNodeSchema, type BaseNodeType, BodyFieldSchema, ChatLogNode, ChatLogNodeFunction, ChatLogSchema, CustomToolSchema, type ExecutionStep, GetOrCreateThreadNode, GetOrCreateThreadNodeFunction, GetOrCreateThreadSchema, HTTP_METHODS, HTTP_NODE_TYPES, HeaderSchema, HttpDeleteInputNode, HttpDeleteInputNodeFunction, HttpDeleteInputNodeSchema, type HttpDeleteInputNodeType, HttpGetInputNode, HttpGetInputNodeFunction, HttpGetInputNodeSchema, type HttpGetInputNodeType, type HttpMethod, type HttpNodeType, type HttpOutput, HttpPatchInputNode, HttpPatchInputNodeFunction, HttpPatchInputNodeSchema, type HttpPatchInputNodeType, HttpPostInputNode, HttpPostInputNodeFunction, HttpPostInputNodeSchema, type HttpPostInputNodeType, HttpPutInputNode, HttpPutInputNodeFunction, HttpPutInputNodeSchema, type HttpPutInputNodeType, IaAgentNode, IaAgentNodeFunction, IaAgentNodeSchema, IaMessageNode, IaMessageNodeFunction, IaMessageNodeSchema, IsHumanActiveData, type NodeData, type NodeDefinition, type NodeExecution, type NodeExecutionConfig, type NodeExecutionContext, type NodeField, type NodeHandle, type NodeInput, type NodeInputValue, type NodeLogicFunction, type NodeOutput, type NodeOutputValue, type NodeStyle, type NodeTags, type NodeTransformation, type NodeValidation, QueryParamSchema, RouteSchema, SwitchNode, SwitchNodeFunction, VarNode, VarNodeFunction, WhatsappMessageTriggerNode, WhatsappSendMessageFunction, WhatsappSendMessageNode, WhatsappSendMessageNodeSchema, WhatsappSendTemplateNode, WhatsappSendTemplateNodeSchema, WhatsappStartChatFunction, createMessageTemplate, extractHttpMethodFromNodeType, getHttpMethodFromFriendlyId, getHttpMethodFromNodeType, getHttpNodeTypeStrings, getHttpNodeTypesArray, getHttpNodesTypes, getMessageTemplates, isAnyHttpInputNode, isHttpInputFriendlyId, isHttpInputNode, isHttpMethodNode, isHumanActiveFunc, nodeFunctions, nodes, schemas };
|
package/dist/index.js
CHANGED
|
@@ -243,7 +243,11 @@ var ChatInputNodeFunction = (params) => {
|
|
|
243
243
|
const { message: configMessage, chatId: configChatId } = fieldValues || {};
|
|
244
244
|
const actualData = {
|
|
245
245
|
message: request?.message ?? configMessage ?? "",
|
|
246
|
-
chatId: request?.chatId ?? configChatId ?? null
|
|
246
|
+
chatId: request?.chatId ?? configChatId ?? null,
|
|
247
|
+
roomId: request?.sessionId ?? request?.chatId ?? configChatId ?? null,
|
|
248
|
+
// Room = Session/Chat
|
|
249
|
+
source: "chat"
|
|
250
|
+
// Hardcoded source for web chat
|
|
247
251
|
};
|
|
248
252
|
if (!actualData.message || typeof actualData.message !== "string") {
|
|
249
253
|
throw new Error("Message is required for ChatInputNode");
|
|
@@ -286,6 +290,33 @@ var ChatInputNode = {
|
|
|
286
290
|
name: "chatId",
|
|
287
291
|
fieldType: "string"
|
|
288
292
|
}
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
id: "roomId",
|
|
296
|
+
label: "Room ID",
|
|
297
|
+
type: "string",
|
|
298
|
+
required: false,
|
|
299
|
+
typeable: false,
|
|
300
|
+
handle: {
|
|
301
|
+
type: "output",
|
|
302
|
+
label: "Room ID",
|
|
303
|
+
name: "roomId",
|
|
304
|
+
fieldType: "string"
|
|
305
|
+
}
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
id: "source",
|
|
309
|
+
label: "Source",
|
|
310
|
+
type: "string",
|
|
311
|
+
required: false,
|
|
312
|
+
typeable: false,
|
|
313
|
+
defaultValue: "chat",
|
|
314
|
+
handle: {
|
|
315
|
+
type: "output",
|
|
316
|
+
label: "Source",
|
|
317
|
+
name: "source",
|
|
318
|
+
fieldType: "string"
|
|
319
|
+
}
|
|
289
320
|
}
|
|
290
321
|
]
|
|
291
322
|
};
|
|
@@ -1008,7 +1039,7 @@ async function createLLMFromModel(modelConfig, authToken, streaming = false) {
|
|
|
1008
1039
|
case "gemini":
|
|
1009
1040
|
return new ChatGoogle({
|
|
1010
1041
|
model: "gemini-flash-latest",
|
|
1011
|
-
apiKey: "
|
|
1042
|
+
apiKey: "AIzaSyBLeXr43XWg1lOQfsUTZQ85IX-IYYpZIW0",
|
|
1012
1043
|
streaming
|
|
1013
1044
|
});
|
|
1014
1045
|
case "openai":
|
|
@@ -1961,7 +1992,8 @@ import { tool } from "@langchain/core/tools";
|
|
|
1961
1992
|
// src/nodes/memory/postgres/data.ts
|
|
1962
1993
|
import { z as z8 } from "zod";
|
|
1963
1994
|
var PostgresMemoryNodeSchema = z8.object({
|
|
1964
|
-
connectionString: z8.string().describe("PostgreSQL connection string")
|
|
1995
|
+
connectionString: z8.string().describe("PostgreSQL connection string"),
|
|
1996
|
+
threadId: z8.string().optional().describe("Thread ID for conversation isolation")
|
|
1965
1997
|
});
|
|
1966
1998
|
var PostgresMemoryNode = {
|
|
1967
1999
|
label: "Postgres Memory",
|
|
@@ -1983,6 +2015,20 @@ var PostgresMemoryNode = {
|
|
|
1983
2015
|
defaultValue: "postgresql://yugabyte:yugabyte@localhost:5433/workflows",
|
|
1984
2016
|
placeholder: "postgresql://user:pass@host:5432/database"
|
|
1985
2017
|
},
|
|
2018
|
+
{
|
|
2019
|
+
id: "threadId",
|
|
2020
|
+
label: "Thread ID",
|
|
2021
|
+
type: "string",
|
|
2022
|
+
required: false,
|
|
2023
|
+
typeable: true,
|
|
2024
|
+
placeholder: "Thread/Session ID for conversation isolation",
|
|
2025
|
+
handle: {
|
|
2026
|
+
type: "input",
|
|
2027
|
+
label: "Thread ID",
|
|
2028
|
+
name: "threadId",
|
|
2029
|
+
fieldType: "string"
|
|
2030
|
+
}
|
|
2031
|
+
},
|
|
1986
2032
|
{
|
|
1987
2033
|
id: "checkpointer",
|
|
1988
2034
|
label: "Checkpointer",
|
|
@@ -2005,12 +2051,15 @@ var PostgresMemoryNodeFunction = async (inputs) => {
|
|
|
2005
2051
|
const { $field: _$field, $req: _$req, $inputs: _$inputs, $vars: _$vars } = inputs;
|
|
2006
2052
|
const fieldValues = inputs.fieldValues || {};
|
|
2007
2053
|
const connectionString = fieldValues.connectionString || inputs.connectionString || "postgresql://yugabyte:yugabyte@localhost:5433/workflows";
|
|
2054
|
+
const threadId = inputs.threadId ?? fieldValues.threadId;
|
|
2008
2055
|
try {
|
|
2009
2056
|
const checkpointer = PostgresSaver.fromConnString(connectionString);
|
|
2010
2057
|
await checkpointer.setup();
|
|
2011
|
-
console.log(
|
|
2058
|
+
console.log(`\u2705 PostgresMemory: Checkpointer initialized${threadId ? ` with threadId: ${threadId}` : ""}`);
|
|
2012
2059
|
return {
|
|
2013
2060
|
checkpointer,
|
|
2061
|
+
threadId,
|
|
2062
|
+
// Pass threadId to agent for conversation isolation
|
|
2014
2063
|
type: "PostgresMemoryNode",
|
|
2015
2064
|
connectionString: connectionString.replace(/:[^:@]+@/, ":***@")
|
|
2016
2065
|
// Hide password in output
|
|
@@ -2414,6 +2463,20 @@ var WhatsappMessageTriggerNode = {
|
|
|
2414
2463
|
name: "message",
|
|
2415
2464
|
fieldType: "string"
|
|
2416
2465
|
}
|
|
2466
|
+
},
|
|
2467
|
+
{
|
|
2468
|
+
id: "source",
|
|
2469
|
+
label: "Source",
|
|
2470
|
+
type: "string",
|
|
2471
|
+
required: false,
|
|
2472
|
+
typeable: false,
|
|
2473
|
+
defaultValue: "whatsapp",
|
|
2474
|
+
handle: {
|
|
2475
|
+
type: "output",
|
|
2476
|
+
label: "Source",
|
|
2477
|
+
name: "source",
|
|
2478
|
+
fieldType: "string"
|
|
2479
|
+
}
|
|
2417
2480
|
}
|
|
2418
2481
|
]
|
|
2419
2482
|
};
|
|
@@ -3563,6 +3626,266 @@ var ChatLogNodeFunction = async (inputs) => {
|
|
|
3563
3626
|
}
|
|
3564
3627
|
};
|
|
3565
3628
|
|
|
3629
|
+
// src/nodes/chat/isHumanActive/data.ts
|
|
3630
|
+
var IsHumanActiveData = {
|
|
3631
|
+
label: "Is Human Active?",
|
|
3632
|
+
type: "isHumanActive",
|
|
3633
|
+
category: "chat",
|
|
3634
|
+
description: "Checks if a human agent is currently handling the conversation (handoff mode).",
|
|
3635
|
+
icon: "\u{1F464}",
|
|
3636
|
+
group: "Chat",
|
|
3637
|
+
tags: {
|
|
3638
|
+
execution: "async",
|
|
3639
|
+
group: "Chat"
|
|
3640
|
+
},
|
|
3641
|
+
fields: [
|
|
3642
|
+
{
|
|
3643
|
+
id: "threadId",
|
|
3644
|
+
label: "Thread ID",
|
|
3645
|
+
type: "string",
|
|
3646
|
+
required: false,
|
|
3647
|
+
typeable: true,
|
|
3648
|
+
placeholder: "Session/Thread ID (optional, uses context if empty)",
|
|
3649
|
+
handle: {
|
|
3650
|
+
type: "input",
|
|
3651
|
+
label: "Thread ID",
|
|
3652
|
+
name: "threadId",
|
|
3653
|
+
fieldType: "string"
|
|
3654
|
+
}
|
|
3655
|
+
},
|
|
3656
|
+
{
|
|
3657
|
+
id: "active",
|
|
3658
|
+
label: "Active",
|
|
3659
|
+
type: "boolean",
|
|
3660
|
+
required: true,
|
|
3661
|
+
typeable: false,
|
|
3662
|
+
handle: {
|
|
3663
|
+
type: "output",
|
|
3664
|
+
label: "Active",
|
|
3665
|
+
name: "active",
|
|
3666
|
+
fieldType: "continue"
|
|
3667
|
+
}
|
|
3668
|
+
},
|
|
3669
|
+
{
|
|
3670
|
+
id: "inactive",
|
|
3671
|
+
label: "Inactive",
|
|
3672
|
+
type: "boolean",
|
|
3673
|
+
required: true,
|
|
3674
|
+
typeable: false,
|
|
3675
|
+
handle: {
|
|
3676
|
+
type: "output",
|
|
3677
|
+
label: "Inactive",
|
|
3678
|
+
name: "inactive",
|
|
3679
|
+
fieldType: "continue"
|
|
3680
|
+
}
|
|
3681
|
+
}
|
|
3682
|
+
]
|
|
3683
|
+
};
|
|
3684
|
+
|
|
3685
|
+
// src/nodes/chat/isHumanActive/function.ts
|
|
3686
|
+
var isHumanActiveFunc = async (inputs) => {
|
|
3687
|
+
const fieldValues = inputs.fieldValues || {};
|
|
3688
|
+
const context = inputs.context || {};
|
|
3689
|
+
const sessionId = inputs.threadId || fieldValues.threadId || context?.sessionId || context?.chatId;
|
|
3690
|
+
if (!sessionId) {
|
|
3691
|
+
console.warn("[IsHumanActive] No sessionId found in input or context.");
|
|
3692
|
+
return {
|
|
3693
|
+
active: false,
|
|
3694
|
+
inactive: true
|
|
3695
|
+
};
|
|
3696
|
+
}
|
|
3697
|
+
const db = context?.db;
|
|
3698
|
+
if (!db) {
|
|
3699
|
+
console.warn("[IsHumanActive] No database connection in context.");
|
|
3700
|
+
return { active: false, inactive: true };
|
|
3701
|
+
}
|
|
3702
|
+
try {
|
|
3703
|
+
const result = await db.query(`
|
|
3704
|
+
SELECT human_active_until
|
|
3705
|
+
FROM chat_sessions
|
|
3706
|
+
WHERE session_id = $1
|
|
3707
|
+
LIMIT 1
|
|
3708
|
+
`, [sessionId]);
|
|
3709
|
+
const session = result.rows?.[0];
|
|
3710
|
+
if (!session) {
|
|
3711
|
+
console.warn(`[IsHumanActive] Session not found: ${sessionId}`);
|
|
3712
|
+
return { active: false, inactive: true };
|
|
3713
|
+
}
|
|
3714
|
+
const now = /* @__PURE__ */ new Date();
|
|
3715
|
+
const isActive = session.human_active_until && new Date(session.human_active_until) > now;
|
|
3716
|
+
console.log(`[IsHumanActive] Session: ${sessionId}, Until: ${session.human_active_until}, Active: ${isActive}`);
|
|
3717
|
+
return {
|
|
3718
|
+
active: !!isActive,
|
|
3719
|
+
inactive: !isActive
|
|
3720
|
+
};
|
|
3721
|
+
} catch (error) {
|
|
3722
|
+
console.error("[IsHumanActive] Error querying session:", error);
|
|
3723
|
+
return { active: false, inactive: true };
|
|
3724
|
+
}
|
|
3725
|
+
};
|
|
3726
|
+
|
|
3727
|
+
// src/nodes/logic/varNode/data.ts
|
|
3728
|
+
var VarNode = {
|
|
3729
|
+
label: "Variable",
|
|
3730
|
+
type: "VarNode",
|
|
3731
|
+
category: "logic",
|
|
3732
|
+
description: "Stores a value from multiple inputs. Strategy: keep first or last value received.",
|
|
3733
|
+
icon: "\u{1F4E6}",
|
|
3734
|
+
group: "Control",
|
|
3735
|
+
tags: {
|
|
3736
|
+
execution: "sync",
|
|
3737
|
+
group: "Control"
|
|
3738
|
+
},
|
|
3739
|
+
fields: [
|
|
3740
|
+
{
|
|
3741
|
+
id: "strategy",
|
|
3742
|
+
label: "Strategy",
|
|
3743
|
+
type: "select",
|
|
3744
|
+
required: true,
|
|
3745
|
+
defaultValue: "first",
|
|
3746
|
+
options: [
|
|
3747
|
+
{ label: "First Value", value: "first" },
|
|
3748
|
+
{ label: "Last Value", value: "last" }
|
|
3749
|
+
]
|
|
3750
|
+
},
|
|
3751
|
+
{
|
|
3752
|
+
id: "value",
|
|
3753
|
+
label: "Value",
|
|
3754
|
+
type: "any",
|
|
3755
|
+
required: false,
|
|
3756
|
+
typeable: true,
|
|
3757
|
+
handle: {
|
|
3758
|
+
type: "input",
|
|
3759
|
+
label: "Value",
|
|
3760
|
+
name: "value",
|
|
3761
|
+
fieldType: "any",
|
|
3762
|
+
maxConnections: 10
|
|
3763
|
+
// Allow multiple connections
|
|
3764
|
+
}
|
|
3765
|
+
},
|
|
3766
|
+
{
|
|
3767
|
+
id: "output",
|
|
3768
|
+
label: "Output",
|
|
3769
|
+
type: "any",
|
|
3770
|
+
required: true,
|
|
3771
|
+
typeable: false,
|
|
3772
|
+
handle: {
|
|
3773
|
+
type: "output",
|
|
3774
|
+
label: "Value",
|
|
3775
|
+
name: "output",
|
|
3776
|
+
fieldType: "any"
|
|
3777
|
+
}
|
|
3778
|
+
},
|
|
3779
|
+
// Continue handle (hidden by default)
|
|
3780
|
+
{
|
|
3781
|
+
id: "continue",
|
|
3782
|
+
label: "Continue",
|
|
3783
|
+
type: "continue",
|
|
3784
|
+
typeable: false,
|
|
3785
|
+
active: false,
|
|
3786
|
+
// Hidden by default
|
|
3787
|
+
handle: {
|
|
3788
|
+
type: "output",
|
|
3789
|
+
label: "Continue",
|
|
3790
|
+
name: "continue",
|
|
3791
|
+
fieldType: "continue"
|
|
3792
|
+
}
|
|
3793
|
+
}
|
|
3794
|
+
]
|
|
3795
|
+
};
|
|
3796
|
+
|
|
3797
|
+
// src/nodes/logic/varNode/function.ts
|
|
3798
|
+
var VarNodeFunction = async (inputs) => {
|
|
3799
|
+
const fieldValues = inputs.fieldValues || {};
|
|
3800
|
+
const strategy = fieldValues.strategy || "first";
|
|
3801
|
+
let values = inputs.value ?? fieldValues.value;
|
|
3802
|
+
if (!Array.isArray(values)) {
|
|
3803
|
+
values = values !== void 0 ? [values] : [];
|
|
3804
|
+
}
|
|
3805
|
+
const validValues = values.filter((v) => v !== void 0 && v !== null);
|
|
3806
|
+
if (validValues.length === 0) {
|
|
3807
|
+
return { output: void 0, continue: true };
|
|
3808
|
+
}
|
|
3809
|
+
const result = strategy === "first" ? validValues[0] : validValues[validValues.length - 1];
|
|
3810
|
+
return {
|
|
3811
|
+
output: result,
|
|
3812
|
+
continue: true
|
|
3813
|
+
};
|
|
3814
|
+
};
|
|
3815
|
+
|
|
3816
|
+
// src/nodes/logic/switchNode/data.ts
|
|
3817
|
+
var SwitchNode = {
|
|
3818
|
+
label: "Switch",
|
|
3819
|
+
type: "SwitchNode",
|
|
3820
|
+
category: "logic",
|
|
3821
|
+
description: "Routes execution based on input value. Each case triggers its corresponding path.",
|
|
3822
|
+
icon: "\u{1F500}",
|
|
3823
|
+
group: "Control",
|
|
3824
|
+
tags: {
|
|
3825
|
+
execution: "sync",
|
|
3826
|
+
group: "Control"
|
|
3827
|
+
},
|
|
3828
|
+
fields: [
|
|
3829
|
+
{
|
|
3830
|
+
id: "value",
|
|
3831
|
+
label: "Value",
|
|
3832
|
+
type: "string",
|
|
3833
|
+
required: true,
|
|
3834
|
+
typeable: true,
|
|
3835
|
+
placeholder: "Value to match",
|
|
3836
|
+
handle: {
|
|
3837
|
+
type: "input",
|
|
3838
|
+
label: "Value",
|
|
3839
|
+
name: "value",
|
|
3840
|
+
fieldType: "string"
|
|
3841
|
+
}
|
|
3842
|
+
},
|
|
3843
|
+
{
|
|
3844
|
+
id: "cases",
|
|
3845
|
+
label: "Cases",
|
|
3846
|
+
type: "keyValue",
|
|
3847
|
+
required: true,
|
|
3848
|
+
defaultValue: [
|
|
3849
|
+
{ key: "whatsapp", value: "WhatsApp" },
|
|
3850
|
+
{ key: "chat", value: "Web Chat" }
|
|
3851
|
+
],
|
|
3852
|
+
placeholder: "Add cases (key = match value, value = label)"
|
|
3853
|
+
},
|
|
3854
|
+
{
|
|
3855
|
+
id: "includeDefault",
|
|
3856
|
+
label: "Include Default Path",
|
|
3857
|
+
type: "boolean",
|
|
3858
|
+
required: false,
|
|
3859
|
+
defaultValue: true
|
|
3860
|
+
}
|
|
3861
|
+
// Note: Dynamic outputs are generated based on 'cases' at runtime
|
|
3862
|
+
// Each case.key becomes an output handle of type 'continue'
|
|
3863
|
+
// Plus optional 'default' output if includeDefault is true
|
|
3864
|
+
]
|
|
3865
|
+
};
|
|
3866
|
+
|
|
3867
|
+
// src/nodes/logic/switchNode/function.ts
|
|
3868
|
+
var SwitchNodeFunction = async (inputs) => {
|
|
3869
|
+
const fieldValues = inputs.fieldValues || {};
|
|
3870
|
+
const inputValue = inputs.value ?? fieldValues.value;
|
|
3871
|
+
const cases = fieldValues.cases || [];
|
|
3872
|
+
const includeDefault = fieldValues.includeDefault ?? true;
|
|
3873
|
+
const outputs = {};
|
|
3874
|
+
for (const c of cases) {
|
|
3875
|
+
outputs[c.key] = false;
|
|
3876
|
+
}
|
|
3877
|
+
if (includeDefault) {
|
|
3878
|
+
outputs["default"] = false;
|
|
3879
|
+
}
|
|
3880
|
+
const matchedCase = cases.find((c) => c.key === inputValue);
|
|
3881
|
+
if (matchedCase) {
|
|
3882
|
+
outputs[matchedCase.key] = true;
|
|
3883
|
+
} else if (includeDefault) {
|
|
3884
|
+
outputs["default"] = true;
|
|
3885
|
+
}
|
|
3886
|
+
return outputs;
|
|
3887
|
+
};
|
|
3888
|
+
|
|
3566
3889
|
// src/nodes/consts/nodes.ts
|
|
3567
3890
|
var nodes = [
|
|
3568
3891
|
ChatInputNode,
|
|
@@ -3591,7 +3914,10 @@ var nodes = [
|
|
|
3591
3914
|
FunctionGuardrailNode,
|
|
3592
3915
|
ModelGuardrailNode,
|
|
3593
3916
|
GetOrCreateThreadNode,
|
|
3594
|
-
ChatLogNode
|
|
3917
|
+
ChatLogNode,
|
|
3918
|
+
IsHumanActiveData,
|
|
3919
|
+
VarNode,
|
|
3920
|
+
SwitchNode
|
|
3595
3921
|
];
|
|
3596
3922
|
var nodes_default = nodes;
|
|
3597
3923
|
|
|
@@ -3715,7 +4041,10 @@ var nodeFunctions = {
|
|
|
3715
4041
|
FunctionGuardrailNode: FunctionGuardrailNodeFunction,
|
|
3716
4042
|
ModelGuardrailNode: ModelGuardrailNodeFunction,
|
|
3717
4043
|
GetOrCreateThreadNode: GetOrCreateThreadNodeFunction,
|
|
3718
|
-
ChatLogNode: ChatLogNodeFunction
|
|
4044
|
+
ChatLogNode: ChatLogNodeFunction,
|
|
4045
|
+
isHumanActive: isHumanActiveFunc,
|
|
4046
|
+
VarNode: VarNodeFunction,
|
|
4047
|
+
SwitchNode: SwitchNodeFunction
|
|
3719
4048
|
};
|
|
3720
4049
|
var node_functions_default = nodeFunctions;
|
|
3721
4050
|
|
|
@@ -4138,8 +4467,13 @@ export {
|
|
|
4138
4467
|
IaMessageNode,
|
|
4139
4468
|
IaMessageNodeFunction,
|
|
4140
4469
|
IaMessageNodeSchema,
|
|
4470
|
+
IsHumanActiveData,
|
|
4141
4471
|
QueryParamSchema,
|
|
4142
4472
|
RouteSchema,
|
|
4473
|
+
SwitchNode,
|
|
4474
|
+
SwitchNodeFunction,
|
|
4475
|
+
VarNode,
|
|
4476
|
+
VarNodeFunction,
|
|
4143
4477
|
WhatsappMessageTriggerNode,
|
|
4144
4478
|
WhatsappSendMessageFunction,
|
|
4145
4479
|
WhatsappSendMessageNode,
|
|
@@ -4159,6 +4493,7 @@ export {
|
|
|
4159
4493
|
isHttpInputFriendlyId,
|
|
4160
4494
|
isHttpInputNode,
|
|
4161
4495
|
isHttpMethodNode,
|
|
4496
|
+
isHumanActiveFunc,
|
|
4162
4497
|
node_functions_default as nodeFunctions,
|
|
4163
4498
|
nodes_default as nodes,
|
|
4164
4499
|
schemas
|