@atomoz/workflows-nodes 0.1.16 → 0.1.18
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 +331 -86
- package/dist/index.js +332 -87
- package/package.json +8 -5
- package/dist/index.d.cts +0 -430
- package/dist/index.d.ts +0 -430
package/dist/index.js
CHANGED
|
@@ -60,7 +60,9 @@ var HttpGetInputNode = {
|
|
|
60
60
|
|
|
61
61
|
// src/nodes/inputs/http/get/function.ts
|
|
62
62
|
var HttpGetInputNodeFunction = async (params) => {
|
|
63
|
-
const {
|
|
63
|
+
const { $field: _$field, $req, $inputs: _$inputs, $vars: _$vars } = params;
|
|
64
|
+
const request = $req || params.request;
|
|
65
|
+
const fieldValues = params.fieldValues || {};
|
|
64
66
|
const { queryParams: configQueryParams, headers: configHeaders } = fieldValues || {};
|
|
65
67
|
const actualData = {
|
|
66
68
|
queryParams: request?.query || {},
|
|
@@ -187,7 +189,9 @@ var HttpPostInputNode = {
|
|
|
187
189
|
|
|
188
190
|
// src/nodes/inputs/http/post/function.ts
|
|
189
191
|
var HttpPostInputNodeFunction = (params) => {
|
|
190
|
-
const {
|
|
192
|
+
const { $field: _$field, $req, $inputs: _$inputs, $vars: _$vars } = params;
|
|
193
|
+
const request = $req || params.request;
|
|
194
|
+
const fieldValues = params.fieldValues || {};
|
|
191
195
|
const { queryParams: configQueryParams, headers: configHeaders, body: configBody } = fieldValues || {};
|
|
192
196
|
if (request.method !== "POST") {
|
|
193
197
|
throw new Error("M\xE9todo HTTP inv\xE1lido");
|
|
@@ -233,7 +237,9 @@ var HttpPostInputNodeSchema = z3.object({
|
|
|
233
237
|
|
|
234
238
|
// src/nodes/inputs/chat/chat.ts
|
|
235
239
|
var ChatInputNodeFunction = (params) => {
|
|
236
|
-
const {
|
|
240
|
+
const { $field: _$field, $req, $inputs: _$inputs, $vars: _$vars } = params;
|
|
241
|
+
const request = $req || params.request;
|
|
242
|
+
const fieldValues = params.fieldValues || {};
|
|
237
243
|
const { message: configMessage, chatId: configChatId } = fieldValues || {};
|
|
238
244
|
const actualData = {
|
|
239
245
|
message: request?.message ?? configMessage ?? "",
|
|
@@ -286,7 +292,8 @@ var ChatInputNode = {
|
|
|
286
292
|
|
|
287
293
|
// src/nodes/inputs/manual/trigger.ts
|
|
288
294
|
var ManualTriggerNodeFunction = (params) => {
|
|
289
|
-
const {
|
|
295
|
+
const { $field: _$field, $req: _$req, $inputs: _$inputs, $vars: _$vars } = params;
|
|
296
|
+
const fieldValues = params.fieldValues || {};
|
|
290
297
|
return fieldValues || {};
|
|
291
298
|
};
|
|
292
299
|
var ManualTriggerNode = {
|
|
@@ -323,11 +330,143 @@ var ManualTriggerNode = {
|
|
|
323
330
|
]
|
|
324
331
|
};
|
|
325
332
|
|
|
333
|
+
// src/nodes/inputs/cron/trigger.ts
|
|
334
|
+
var CronTriggerNodeFunction = (params) => {
|
|
335
|
+
const { $req } = params;
|
|
336
|
+
const triggerData = $req || {};
|
|
337
|
+
const fieldValues = params.fieldValues || {};
|
|
338
|
+
return {
|
|
339
|
+
triggeredAt: triggerData.triggeredAt || (/* @__PURE__ */ new Date()).toISOString(),
|
|
340
|
+
scheduleId: triggerData.scheduleId || null,
|
|
341
|
+
cronExpression: fieldValues.cronExpression || null,
|
|
342
|
+
timezone: fieldValues.timezone || "America/Sao_Paulo",
|
|
343
|
+
success: true
|
|
344
|
+
};
|
|
345
|
+
};
|
|
346
|
+
var CronTriggerNode = {
|
|
347
|
+
label: "Cron Trigger",
|
|
348
|
+
type: "CronTrigger",
|
|
349
|
+
category: "input",
|
|
350
|
+
icon: "\u23F0",
|
|
351
|
+
description: "Dispara fluxo automaticamente baseado em express\xE3o cron",
|
|
352
|
+
tags: {
|
|
353
|
+
execution: "async",
|
|
354
|
+
group: "Custom"
|
|
355
|
+
},
|
|
356
|
+
fields: [
|
|
357
|
+
{
|
|
358
|
+
id: "cronExpression",
|
|
359
|
+
label: "Express\xE3o Cron",
|
|
360
|
+
type: "string",
|
|
361
|
+
required: true,
|
|
362
|
+
placeholder: "0 9 * * * (todos os dias \xE0s 9h)"
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
id: "timezone",
|
|
366
|
+
label: "Timezone",
|
|
367
|
+
type: "select",
|
|
368
|
+
defaultValue: "America/Sao_Paulo",
|
|
369
|
+
options: [
|
|
370
|
+
{ label: "S\xE3o Paulo (GMT-3)", value: "America/Sao_Paulo" },
|
|
371
|
+
{ label: "UTC", value: "UTC" },
|
|
372
|
+
{ label: "New York (GMT-5)", value: "America/New_York" },
|
|
373
|
+
{ label: "Los Angeles (GMT-8)", value: "America/Los_Angeles" },
|
|
374
|
+
{ label: "London (GMT+0)", value: "Europe/London" }
|
|
375
|
+
]
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
id: "triggeredAt",
|
|
379
|
+
label: "Triggered At",
|
|
380
|
+
type: "string",
|
|
381
|
+
typeable: false,
|
|
382
|
+
handle: {
|
|
383
|
+
type: "output",
|
|
384
|
+
label: "Triggered At",
|
|
385
|
+
name: "triggeredAt",
|
|
386
|
+
fieldType: "string"
|
|
387
|
+
}
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
id: "scheduleId",
|
|
391
|
+
label: "Schedule ID",
|
|
392
|
+
type: "string",
|
|
393
|
+
typeable: false,
|
|
394
|
+
handle: {
|
|
395
|
+
type: "output",
|
|
396
|
+
label: "Schedule ID",
|
|
397
|
+
name: "scheduleId",
|
|
398
|
+
fieldType: "string"
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
]
|
|
402
|
+
};
|
|
403
|
+
|
|
404
|
+
// src/nodes/processors/delay/index.ts
|
|
405
|
+
var DelayNode = {
|
|
406
|
+
label: "Delay",
|
|
407
|
+
type: "DelayNode",
|
|
408
|
+
category: "step",
|
|
409
|
+
icon: "\u23F3",
|
|
410
|
+
description: "Pausa o workflow por um tempo determinado",
|
|
411
|
+
tags: {
|
|
412
|
+
execution: "async",
|
|
413
|
+
group: "Control"
|
|
414
|
+
},
|
|
415
|
+
fields: [
|
|
416
|
+
{
|
|
417
|
+
id: "input",
|
|
418
|
+
label: "Trigger",
|
|
419
|
+
type: "any",
|
|
420
|
+
required: false,
|
|
421
|
+
handle: {
|
|
422
|
+
type: "input",
|
|
423
|
+
label: "Start",
|
|
424
|
+
name: "trigger",
|
|
425
|
+
fieldType: "any"
|
|
426
|
+
}
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
id: "duration",
|
|
430
|
+
label: "Dura\xE7\xE3o",
|
|
431
|
+
type: "number",
|
|
432
|
+
required: true,
|
|
433
|
+
defaultValue: 1
|
|
434
|
+
},
|
|
435
|
+
{
|
|
436
|
+
id: "unit",
|
|
437
|
+
label: "Unidade",
|
|
438
|
+
type: "select",
|
|
439
|
+
defaultValue: "minutes",
|
|
440
|
+
required: true,
|
|
441
|
+
options: [
|
|
442
|
+
{ label: "Segundos", value: "seconds" },
|
|
443
|
+
{ label: "Minutos", value: "minutes" },
|
|
444
|
+
{ label: "Horas", value: "hours" },
|
|
445
|
+
{ label: "Dias", value: "days" }
|
|
446
|
+
]
|
|
447
|
+
},
|
|
448
|
+
{
|
|
449
|
+
id: "output",
|
|
450
|
+
label: "Continue",
|
|
451
|
+
type: "any",
|
|
452
|
+
required: false,
|
|
453
|
+
handle: {
|
|
454
|
+
type: "output",
|
|
455
|
+
label: "Continue",
|
|
456
|
+
name: "continue",
|
|
457
|
+
fieldType: "any"
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
]
|
|
461
|
+
};
|
|
462
|
+
|
|
326
463
|
// src/nodes/processors/concat.ts
|
|
327
464
|
import { z as z4 } from "zod";
|
|
328
|
-
var ConcatNodeFunction = (
|
|
329
|
-
const
|
|
330
|
-
const
|
|
465
|
+
var ConcatNodeFunction = (params) => {
|
|
466
|
+
const { $field: _$field, $req: _$req, $inputs: _$inputs, $vars: _$vars } = params;
|
|
467
|
+
const inputs_resolved = params.inputs || params || {};
|
|
468
|
+
const input1 = inputs_resolved.input1 || "";
|
|
469
|
+
const input2 = inputs_resolved.input2 || "";
|
|
331
470
|
const result = `${input1}${input2}`;
|
|
332
471
|
return {
|
|
333
472
|
output: result,
|
|
@@ -507,8 +646,12 @@ var OutputNode = {
|
|
|
507
646
|
|
|
508
647
|
// src/nodes/outputs/chat/output.ts
|
|
509
648
|
var ChatOutputNodeFunction = async (params) => {
|
|
510
|
-
const {
|
|
511
|
-
const
|
|
649
|
+
const { $field: _$field, $req: _$req, $inputs: _$inputs, $vars: _$vars } = params;
|
|
650
|
+
const inputs_resolved = params.inputs || {};
|
|
651
|
+
const fieldValues = params.fieldValues || {};
|
|
652
|
+
const stream = params.stream;
|
|
653
|
+
const emitter = params.emitter;
|
|
654
|
+
const content = inputs_resolved?.data ?? fieldValues?.data ?? "";
|
|
512
655
|
if (stream && emitter) {
|
|
513
656
|
try {
|
|
514
657
|
emitter.emitDone({ content });
|
|
@@ -670,7 +813,7 @@ import { createReactAgent } from "@langchain/langgraph/prebuilt";
|
|
|
670
813
|
import { SystemMessage } from "@langchain/core/messages";
|
|
671
814
|
|
|
672
815
|
// src/utils/llm-factory.ts
|
|
673
|
-
import {
|
|
816
|
+
import { gql } from "graphql-request";
|
|
674
817
|
import { ChatGoogle } from "@langchain/google-gauth";
|
|
675
818
|
import { ChatOpenAI } from "@langchain/openai";
|
|
676
819
|
var GRAPHQL_ENDPOINT = process.env["GRAPHQL_URL"] || "http://localhost:3001/graphql";
|
|
@@ -695,44 +838,12 @@ async function createLLMFromModel(modelConfig, authToken, streaming = false) {
|
|
|
695
838
|
throw new Error('Model config deve conter "model" e "integrationId"');
|
|
696
839
|
}
|
|
697
840
|
const { model, integrationId } = modelConfig;
|
|
698
|
-
const
|
|
699
|
-
headers: {
|
|
700
|
-
Authorization: `Bearer ${authToken}`,
|
|
701
|
-
"x-tenant-id": "65d62c52-0c09-473a-8895-359afbed3f5a"
|
|
702
|
-
}
|
|
703
|
-
});
|
|
704
|
-
let integrationData;
|
|
705
|
-
try {
|
|
706
|
-
const response = await client.request(
|
|
707
|
-
GET_INTEGRATIONS_QUERY,
|
|
708
|
-
{
|
|
709
|
-
where: {
|
|
710
|
-
id: {
|
|
711
|
-
eq: integrationId
|
|
712
|
-
}
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
);
|
|
716
|
-
if (!response.getIntegrations?.data?.[0]) {
|
|
717
|
-
throw new Error(`Integra\xE7\xE3o ${integrationId} n\xE3o encontrada`);
|
|
718
|
-
}
|
|
719
|
-
integrationData = response.getIntegrations.data[0];
|
|
720
|
-
} catch (error) {
|
|
721
|
-
console.error("Erro ao buscar integra\xE7\xE3o:", error);
|
|
722
|
-
throw new Error(
|
|
723
|
-
`Falha ao buscar integra\xE7\xE3o: ${error instanceof Error ? error.message : "Erro desconhecido"}`
|
|
724
|
-
);
|
|
725
|
-
}
|
|
726
|
-
const apiKey = integrationData.data?.["token"] || integrationData.data?.["token"];
|
|
727
|
-
if (!apiKey) {
|
|
728
|
-
throw new Error(`API Key n\xE3o encontrada na integra\xE7\xE3o ${integrationId}`);
|
|
729
|
-
}
|
|
730
|
-
const provider = integrationData.data?.provider?.toLowerCase() || inferProviderFromModel(model);
|
|
841
|
+
const provider = "gemini";
|
|
731
842
|
switch (provider) {
|
|
732
843
|
case "gemini":
|
|
733
844
|
return new ChatGoogle({
|
|
734
845
|
model: "gemini-flash-latest",
|
|
735
|
-
apiKey,
|
|
846
|
+
apiKey: "AIzaSyAWS9GhesWxG4uTdJRQbBziMB1diXtXtlI",
|
|
736
847
|
streaming
|
|
737
848
|
});
|
|
738
849
|
case "openai":
|
|
@@ -756,21 +867,14 @@ async function createLLMFromModel(modelConfig, authToken, streaming = false) {
|
|
|
756
867
|
);
|
|
757
868
|
}
|
|
758
869
|
}
|
|
759
|
-
function inferProviderFromModel(model) {
|
|
760
|
-
const modelLower = model.toLowerCase();
|
|
761
|
-
if (modelLower.includes("gemini") || modelLower.includes("palm")) {
|
|
762
|
-
return "gemini";
|
|
763
|
-
}
|
|
764
|
-
if (modelLower.includes("gpt") || modelLower.includes("o1") || modelLower.includes("o3")) {
|
|
765
|
-
return "openai";
|
|
766
|
-
}
|
|
767
|
-
return "openrouter";
|
|
768
|
-
}
|
|
769
870
|
|
|
770
871
|
// src/nodes/ia/agent/function.ts
|
|
771
872
|
var IaAgentNodeFunction = async (inputs) => {
|
|
772
|
-
const {
|
|
873
|
+
const { $field: _$field, $req: _$req, $inputs: _$inputs, $vars: _$vars } = inputs;
|
|
874
|
+
const { model, tools, systemMessage, name, message } = inputs.fieldValues || {};
|
|
773
875
|
const authToken = inputs.authToken;
|
|
876
|
+
const stream = Boolean(inputs?.stream);
|
|
877
|
+
const emitter = inputs?.emitter;
|
|
774
878
|
if (!name) {
|
|
775
879
|
throw new Error("Agent 'name' is required. Please provide a unique name for the agent in the node properties.");
|
|
776
880
|
}
|
|
@@ -792,8 +896,7 @@ IMPORTANT: You must base your response on the last message in the conversation h
|
|
|
792
896
|
if (!authToken) {
|
|
793
897
|
throw new Error("Auth token is required to instantiate LLM from integration");
|
|
794
898
|
}
|
|
795
|
-
|
|
796
|
-
llmInstance = await createLLMFromModel(model, authToken, streaming);
|
|
899
|
+
llmInstance = await createLLMFromModel(model, authToken, stream);
|
|
797
900
|
} else if (typeof model?.bindTools === "function") {
|
|
798
901
|
llmInstance = model;
|
|
799
902
|
} else {
|
|
@@ -809,22 +912,70 @@ IMPORTANT: You must base your response on the last message in the conversation h
|
|
|
809
912
|
if (message) {
|
|
810
913
|
try {
|
|
811
914
|
const { HumanMessage: HumanMessage2 } = await import("@langchain/core/messages");
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
const
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
915
|
+
if (stream && emitter) {
|
|
916
|
+
const streamIterator = await agent.stream({
|
|
917
|
+
messages: [new HumanMessage2(message)]
|
|
918
|
+
});
|
|
919
|
+
let lastMessages = [];
|
|
920
|
+
const sentContents = /* @__PURE__ */ new Set();
|
|
921
|
+
for await (const step of streamIterator) {
|
|
922
|
+
if (step && typeof step === "object") {
|
|
923
|
+
for (const [key, value] of Object.entries(step)) {
|
|
924
|
+
if (value && typeof value === "object" && "messages" in value) {
|
|
925
|
+
const messages = value.messages;
|
|
926
|
+
if (Array.isArray(messages)) {
|
|
927
|
+
lastMessages = messages;
|
|
928
|
+
for (const msg of messages) {
|
|
929
|
+
const content = msg?.content;
|
|
930
|
+
const contentStr = typeof content === "string" ? content : Array.isArray(content) ? content.map((p) => p.type === "text" ? p.text : "").filter(Boolean).join("") : "";
|
|
931
|
+
if (contentStr && !sentContents.has(contentStr)) {
|
|
932
|
+
sentContents.add(contentStr);
|
|
933
|
+
if (emitter?.emitDelta) {
|
|
934
|
+
emitter.emitDelta({
|
|
935
|
+
content: contentStr,
|
|
936
|
+
actor: name,
|
|
937
|
+
isAgent: true,
|
|
938
|
+
isTool: false
|
|
939
|
+
});
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
if (lastMessages.length > 0) {
|
|
949
|
+
const lastMessage = lastMessages[lastMessages.length - 1];
|
|
950
|
+
const content = lastMessage?.content;
|
|
951
|
+
if (typeof content === "string") {
|
|
952
|
+
output = content;
|
|
953
|
+
} else if (Array.isArray(content)) {
|
|
954
|
+
output = content.map((part) => {
|
|
955
|
+
if (typeof part === "string") return part;
|
|
956
|
+
if (part?.type === "text") return part.text;
|
|
957
|
+
return "";
|
|
958
|
+
}).filter(Boolean).join("\n");
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
} else {
|
|
962
|
+
const result = await agent.invoke({
|
|
963
|
+
messages: [new HumanMessage2(message)]
|
|
964
|
+
});
|
|
965
|
+
if (result?.messages && result.messages.length > 0) {
|
|
966
|
+
const lastMessage = result.messages[result.messages.length - 1];
|
|
967
|
+
const content = lastMessage?.content;
|
|
968
|
+
if (typeof content === "string") {
|
|
969
|
+
output = content;
|
|
970
|
+
} else if (Array.isArray(content)) {
|
|
971
|
+
output = content.map((part) => {
|
|
972
|
+
if (typeof part === "string") return part;
|
|
973
|
+
if (part?.type === "text") return part.text;
|
|
974
|
+
return "";
|
|
975
|
+
}).filter(Boolean).join("\n");
|
|
976
|
+
} else {
|
|
977
|
+
output = "";
|
|
978
|
+
}
|
|
828
979
|
}
|
|
829
980
|
}
|
|
830
981
|
} catch (error) {
|
|
@@ -973,8 +1124,9 @@ var extractFinalResponse = (messages) => {
|
|
|
973
1124
|
}
|
|
974
1125
|
return "No response generated.";
|
|
975
1126
|
};
|
|
976
|
-
var AiSupervisorNodeFunction = async (
|
|
977
|
-
const
|
|
1127
|
+
var AiSupervisorNodeFunction = async (params) => {
|
|
1128
|
+
const { $field: _$field, $req: _$req, $inputs: _$inputs, $vars: _$vars } = params;
|
|
1129
|
+
const outer = params ?? {};
|
|
978
1130
|
const inner = outer && typeof outer === "object" && outer.fieldValues && typeof outer.fieldValues === "object" ? outer.fieldValues : {};
|
|
979
1131
|
const model = inner.model ?? outer.model;
|
|
980
1132
|
const agents = inner.agents ?? outer.agents;
|
|
@@ -1194,7 +1346,9 @@ var schemas = {
|
|
|
1194
1346
|
};
|
|
1195
1347
|
|
|
1196
1348
|
// src/nodes/ia/tool/function.ts
|
|
1197
|
-
var AiToolNodeFunction = async (
|
|
1349
|
+
var AiToolNodeFunction = async (params) => {
|
|
1350
|
+
const { $field: _$field, $req: _$req, $inputs: _$inputs, $vars: _$vars } = params;
|
|
1351
|
+
const fieldValues = params.fieldValues || params;
|
|
1198
1352
|
const { name, description, nodeFunction, nodeType, originalNodeData, workflowService, currentResults } = fieldValues;
|
|
1199
1353
|
const schema = schemas[nodeType] || CustomToolSchema;
|
|
1200
1354
|
const dynamicTool = tool(
|
|
@@ -1237,9 +1391,12 @@ var IaMessageNodeSchema = z8.object({
|
|
|
1237
1391
|
message: z8.string().describe("User message to send to the LLM")
|
|
1238
1392
|
});
|
|
1239
1393
|
var IaMessageNodeFunction = async (inputs) => {
|
|
1394
|
+
const { $field: _$field, $req: _$req, $inputs: _$inputs_var, $vars: _$vars } = inputs;
|
|
1240
1395
|
const fieldValues = inputs.fieldValues || inputs;
|
|
1241
1396
|
const { model, systemMessage, message } = fieldValues;
|
|
1242
1397
|
const authToken = inputs.authToken;
|
|
1398
|
+
const stream = Boolean(inputs?.stream);
|
|
1399
|
+
const emitter = inputs?.emitter;
|
|
1243
1400
|
if (!model) {
|
|
1244
1401
|
throw new Error("Model is required");
|
|
1245
1402
|
}
|
|
@@ -1249,10 +1406,9 @@ var IaMessageNodeFunction = async (inputs) => {
|
|
|
1249
1406
|
let llmInstance;
|
|
1250
1407
|
if (model?.model && model?.integrationId) {
|
|
1251
1408
|
if (!authToken) {
|
|
1252
|
-
throw new Error("Auth token is required to instantiate LLM from
|
|
1409
|
+
throw new Error("Auth token is required to instantiate LLM from integration");
|
|
1253
1410
|
}
|
|
1254
|
-
|
|
1255
|
-
llmInstance = await createLLMFromModel(model, authToken, streaming);
|
|
1411
|
+
llmInstance = await createLLMFromModel(model, authToken, stream);
|
|
1256
1412
|
} else {
|
|
1257
1413
|
llmInstance = model;
|
|
1258
1414
|
}
|
|
@@ -1262,6 +1418,29 @@ var IaMessageNodeFunction = async (inputs) => {
|
|
|
1262
1418
|
}
|
|
1263
1419
|
messages.push(["human", message]);
|
|
1264
1420
|
try {
|
|
1421
|
+
if (stream && emitter) {
|
|
1422
|
+
let fullContent = "";
|
|
1423
|
+
const streamResponse = await llmInstance.stream(messages);
|
|
1424
|
+
for await (const chunk of streamResponse) {
|
|
1425
|
+
const chunkContent = typeof chunk.content === "string" ? chunk.content : chunk.content?.text || "";
|
|
1426
|
+
if (chunkContent) {
|
|
1427
|
+
fullContent += chunkContent;
|
|
1428
|
+
if (emitter?.emitDelta) {
|
|
1429
|
+
emitter.emitDelta({
|
|
1430
|
+
content: chunkContent,
|
|
1431
|
+
actor: "IaMessageNode",
|
|
1432
|
+
isAgent: false,
|
|
1433
|
+
isTool: false
|
|
1434
|
+
});
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
}
|
|
1438
|
+
return {
|
|
1439
|
+
output: fullContent,
|
|
1440
|
+
response: fullContent,
|
|
1441
|
+
fullResponse: { content: fullContent }
|
|
1442
|
+
};
|
|
1443
|
+
}
|
|
1265
1444
|
const response = await llmInstance.invoke(messages);
|
|
1266
1445
|
return {
|
|
1267
1446
|
output: response.content,
|
|
@@ -1493,19 +1672,75 @@ var WhatsappMessageTriggerNode = {
|
|
|
1493
1672
|
|
|
1494
1673
|
// src/nodes/processors/custom-code.ts
|
|
1495
1674
|
var NodeFunction = (params) => {
|
|
1496
|
-
|
|
1497
|
-
const
|
|
1498
|
-
|
|
1499
|
-
|
|
1675
|
+
let input = params?.inputValue ?? params?.input;
|
|
1676
|
+
const context = params && params.fieldValues ? params.fieldValues : params || {};
|
|
1677
|
+
let customCode = context?.customCode ?? params?.customCode;
|
|
1678
|
+
if (input === void 0 && Array.isArray(context?.fields)) {
|
|
1679
|
+
const firstInputField = context.fields.find((f) => f?.handle?.type === "input");
|
|
1680
|
+
if (firstInputField && firstInputField.id) {
|
|
1681
|
+
const key = String(firstInputField.id);
|
|
1682
|
+
if (params && Object.prototype.hasOwnProperty.call(params, key)) input = params[key];
|
|
1683
|
+
else if (context && Object.prototype.hasOwnProperty.call(context, key)) input = context[key];
|
|
1684
|
+
else if (firstInputField.value !== void 0) input = firstInputField.value;
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1687
|
+
const looksLikeCode = (code) => {
|
|
1688
|
+
if (typeof code !== "string") return false;
|
|
1689
|
+
const c = code.trim();
|
|
1690
|
+
if (c.length < 3) return false;
|
|
1691
|
+
return /(return\s+|=>|function\s*\(|;|\n|\{|\})/.test(c);
|
|
1692
|
+
};
|
|
1693
|
+
if (typeof customCode === "string" && !looksLikeCode(customCode)) {
|
|
1694
|
+
if (input === void 0) input = customCode;
|
|
1695
|
+
customCode = "";
|
|
1696
|
+
}
|
|
1697
|
+
if (!customCode || typeof customCode === "string" && customCode.trim() === "") {
|
|
1698
|
+
return input;
|
|
1500
1699
|
}
|
|
1501
1700
|
try {
|
|
1502
|
-
const
|
|
1503
|
-
const
|
|
1701
|
+
const $inputs = params?.results || {};
|
|
1702
|
+
const $vars = context && context.variables || params?.variables || void 0;
|
|
1703
|
+
const __placeholders = params?.__codePlaceholders ?? context?.__codePlaceholders;
|
|
1704
|
+
const customFunction = new Function("input", "context", "request", "params", "$inputs", "$vars", "__placeholders", customCode);
|
|
1705
|
+
const result = customFunction(input, context, params?.request, params, $inputs, $vars, __placeholders);
|
|
1504
1706
|
return result;
|
|
1505
1707
|
} catch (error) {
|
|
1506
1708
|
throw new Error(`Erro ao executar c\xF3digo customizado: ${error instanceof Error ? error.message : "Erro desconhecido"}`);
|
|
1507
1709
|
}
|
|
1508
1710
|
};
|
|
1711
|
+
var CustomNodeFunction = (params) => {
|
|
1712
|
+
const context = params && params.fieldValues ? params.fieldValues : params || {};
|
|
1713
|
+
const customCode = context?.customCode;
|
|
1714
|
+
if (!customCode || typeof customCode === "string" && customCode.trim() === "") {
|
|
1715
|
+
throw new Error("CustomNode sem c\xF3digo configurado");
|
|
1716
|
+
}
|
|
1717
|
+
const fields = Array.isArray(context?.fields) ? context.fields : [];
|
|
1718
|
+
const $field = {};
|
|
1719
|
+
fields.forEach((field) => {
|
|
1720
|
+
const fieldId = field?.id;
|
|
1721
|
+
if (!fieldId) return;
|
|
1722
|
+
let value;
|
|
1723
|
+
if (params && Object.prototype.hasOwnProperty.call(params, fieldId)) {
|
|
1724
|
+
value = params[fieldId];
|
|
1725
|
+
} else if (field.handle && field.handle.name && params && Object.prototype.hasOwnProperty.call(params, field.handle.name)) {
|
|
1726
|
+
value = params[field.handle.name];
|
|
1727
|
+
} else if (field.value !== void 0) {
|
|
1728
|
+
value = field.value;
|
|
1729
|
+
} else if (field.defaultValue !== void 0) {
|
|
1730
|
+
value = field.defaultValue;
|
|
1731
|
+
}
|
|
1732
|
+
$field[fieldId] = value;
|
|
1733
|
+
});
|
|
1734
|
+
try {
|
|
1735
|
+
const $inputs = params?.results || {};
|
|
1736
|
+
const $vars = context && context.variables || params?.variables || void 0;
|
|
1737
|
+
const customFunction = new Function("$field", "context", "request", "params", "$inputs", "$vars", customCode);
|
|
1738
|
+
const result = customFunction($field, context, params?.request, params, $inputs, $vars);
|
|
1739
|
+
return result;
|
|
1740
|
+
} catch (error) {
|
|
1741
|
+
throw new Error(`Erro ao executar CustomNode: ${error instanceof Error ? error.message : "Erro desconhecido"}`);
|
|
1742
|
+
}
|
|
1743
|
+
};
|
|
1509
1744
|
var CustomCodeNode = {
|
|
1510
1745
|
label: "Custom Code",
|
|
1511
1746
|
type: "CustomCodeNode",
|
|
@@ -1518,7 +1753,13 @@ var CustomCodeNode = {
|
|
|
1518
1753
|
label: "C\xF3digo Customizado",
|
|
1519
1754
|
type: "code",
|
|
1520
1755
|
required: false,
|
|
1521
|
-
placeholder: '// Seu c\xF3digo JavaScript aqui\n// Use "input" para acessar o valor de entrada\n// Use "context" para acessar os dados do n\xF3\nreturn input;'
|
|
1756
|
+
placeholder: '// Seu c\xF3digo JavaScript aqui\n// Use "input" para acessar o valor de entrada\n// Use "context" para acessar os dados do n\xF3\nreturn input;'
|
|
1757
|
+
},
|
|
1758
|
+
{
|
|
1759
|
+
id: "input",
|
|
1760
|
+
label: "Input",
|
|
1761
|
+
type: "any",
|
|
1762
|
+
required: false,
|
|
1522
1763
|
handle: {
|
|
1523
1764
|
type: "input",
|
|
1524
1765
|
label: "Input",
|
|
@@ -1547,6 +1788,8 @@ var CustomCodeNode = {
|
|
|
1547
1788
|
var nodes = [
|
|
1548
1789
|
ChatInputNode,
|
|
1549
1790
|
ManualTriggerNode,
|
|
1791
|
+
CronTriggerNode,
|
|
1792
|
+
DelayNode,
|
|
1550
1793
|
HttpGetInputNode,
|
|
1551
1794
|
// HttpPostInputNode,
|
|
1552
1795
|
// TransformNode,
|
|
@@ -1665,6 +1908,7 @@ var nodeFunctions = {
|
|
|
1665
1908
|
HttpGetInput: HttpGetInputNodeFunction,
|
|
1666
1909
|
HttpPostInput: HttpPostInputNodeFunction,
|
|
1667
1910
|
ManualTrigger: ManualTriggerNodeFunction,
|
|
1911
|
+
CronTrigger: CronTriggerNodeFunction,
|
|
1668
1912
|
HttpOutput: HttpOutputNodeFunction,
|
|
1669
1913
|
ConcatNode: ConcatNodeFunction,
|
|
1670
1914
|
IaMessageNode: IaMessageNodeFunction,
|
|
@@ -1673,7 +1917,8 @@ var nodeFunctions = {
|
|
|
1673
1917
|
AiSupervisorNode: AiSupervisorNodeFunction,
|
|
1674
1918
|
WhatsappNode: WhatsappStartChatFunction,
|
|
1675
1919
|
WhatsappSendMessageNode: WhatsappSendMessageFunction,
|
|
1676
|
-
CustomCodeNode: NodeFunction
|
|
1920
|
+
CustomCodeNode: NodeFunction,
|
|
1921
|
+
CustomNode: CustomNodeFunction
|
|
1677
1922
|
};
|
|
1678
1923
|
var node_functions_default = nodeFunctions;
|
|
1679
1924
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atomoz/workflows-nodes",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.18",
|
|
4
4
|
"description": "Atomoz Workflows - Node Library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -35,17 +35,20 @@
|
|
|
35
35
|
"build": "tsup index.ts --dts --format esm,cjs --target node18 --out-dir dist --clean --tsconfig tsconfig.build.json",
|
|
36
36
|
"dev": "tsup index.ts --dts --format esm,cjs --target node18 --out-dir dist --watch --tsconfig tsconfig.build.json"
|
|
37
37
|
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"zod": ">=3.0.0 || >=4.0.0"
|
|
40
|
+
},
|
|
38
41
|
"dependencies": {
|
|
39
42
|
"@langchain/core": "^0.3.66",
|
|
40
43
|
"@langchain/google-gauth": "^0.2.16",
|
|
41
44
|
"@langchain/langgraph": "^0.4.3",
|
|
42
45
|
"@langchain/langgraph-supervisor": "^0.0.17",
|
|
43
46
|
"@langchain/openai": "^0.6.3",
|
|
44
|
-
"graphql-request": "^7.2.0"
|
|
45
|
-
"zod": "^4.0.14"
|
|
47
|
+
"graphql-request": "^7.2.0"
|
|
46
48
|
},
|
|
47
49
|
"devDependencies": {
|
|
48
50
|
"tsup": "^8.2.4",
|
|
49
|
-
"typescript": "^5.6.3"
|
|
51
|
+
"typescript": "^5.6.3",
|
|
52
|
+
"zod": "^4.0.14"
|
|
50
53
|
}
|
|
51
|
-
}
|
|
54
|
+
}
|