@atomoz/workflows-nodes 0.1.10 → 0.1.12

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.
Files changed (200) hide show
  1. package/package.json +51 -50
  2. package/src/index.d.ts +2 -0
  3. package/src/index.d.ts.map +1 -0
  4. package/src/index.js +1 -0
  5. package/src/nodes/consts/index.d.ts +3 -0
  6. package/src/nodes/consts/index.d.ts.map +1 -0
  7. package/src/nodes/consts/index.js +2 -0
  8. package/src/nodes/consts/node-colors.d.ts +7 -0
  9. package/src/nodes/consts/node-colors.d.ts.map +1 -0
  10. package/src/nodes/consts/node-colors.js +6 -0
  11. package/src/nodes/consts/node-functions.d.ts +19 -0
  12. package/src/nodes/consts/node-functions.d.ts.map +1 -0
  13. package/src/nodes/consts/node-functions.js +27 -0
  14. package/src/nodes/consts/nodes.d.ts +3 -0
  15. package/src/nodes/consts/nodes.d.ts.map +1 -0
  16. package/src/nodes/consts/nodes.js +28 -0
  17. package/src/nodes/consts/schemas.d.ts +30 -0
  18. package/src/nodes/consts/schemas.d.ts.map +1 -0
  19. package/src/nodes/consts/schemas.js +7 -0
  20. package/src/nodes/ia/agent/data.d.ts +11 -0
  21. package/src/nodes/ia/agent/data.d.ts.map +1 -0
  22. package/src/nodes/ia/agent/data.js +111 -0
  23. package/src/nodes/ia/agent/function.d.ts +2 -0
  24. package/src/nodes/ia/agent/function.d.ts.map +1 -0
  25. package/src/nodes/ia/agent/function.js +90 -0
  26. package/src/nodes/ia/agent/index.d.ts +3 -0
  27. package/src/nodes/ia/agent/index.d.ts.map +1 -0
  28. package/src/nodes/ia/agent/index.js +2 -0
  29. package/src/nodes/ia/index.d.ts +5 -0
  30. package/src/nodes/ia/index.d.ts.map +1 -0
  31. package/src/nodes/ia/index.js +4 -0
  32. package/src/nodes/ia/message/index.d.ts +2 -0
  33. package/src/nodes/ia/message/index.d.ts.map +1 -0
  34. package/src/nodes/ia/message/index.js +1 -0
  35. package/src/nodes/ia/message/message.d.ts +10 -0
  36. package/src/nodes/ia/message/message.d.ts.map +1 -0
  37. package/src/nodes/ia/message/message.js +118 -0
  38. package/src/nodes/ia/supervisor/data.d.ts +10 -0
  39. package/src/nodes/ia/supervisor/data.d.ts.map +1 -0
  40. package/src/nodes/ia/supervisor/data.js +84 -0
  41. package/src/nodes/ia/supervisor/function.d.ts +2 -0
  42. package/src/nodes/ia/supervisor/function.d.ts.map +1 -0
  43. package/src/nodes/ia/supervisor/function.js +227 -0
  44. package/src/nodes/ia/supervisor/index.d.ts +3 -0
  45. package/src/nodes/ia/supervisor/index.d.ts.map +1 -0
  46. package/src/nodes/ia/supervisor/index.js +2 -0
  47. package/src/nodes/ia/tool/data.d.ts +16 -0
  48. package/src/nodes/ia/tool/data.d.ts.map +1 -0
  49. package/src/nodes/ia/tool/data.js +70 -0
  50. package/src/nodes/ia/tool/function.d.ts +4 -0
  51. package/src/nodes/ia/tool/function.d.ts.map +1 -0
  52. package/src/nodes/ia/tool/function.js +36 -0
  53. package/src/nodes/ia/tool/index.d.ts +3 -0
  54. package/src/nodes/ia/tool/index.d.ts.map +1 -0
  55. package/src/nodes/ia/tool/index.js +2 -0
  56. package/src/nodes/index.d.ts +9 -0
  57. package/src/nodes/index.d.ts.map +1 -0
  58. package/src/nodes/index.js +8 -0
  59. package/src/nodes/inputs/chat/chat.d.ts +4 -0
  60. package/src/nodes/inputs/chat/chat.d.ts.map +1 -0
  61. package/src/nodes/inputs/chat/chat.js +51 -0
  62. package/src/nodes/inputs/http/delete/data.d.ts +3 -0
  63. package/src/nodes/inputs/http/delete/data.d.ts.map +1 -0
  64. package/src/nodes/inputs/http/delete/data.js +57 -0
  65. package/src/nodes/inputs/http/delete/function.d.ts +2 -0
  66. package/src/nodes/inputs/http/delete/function.d.ts.map +1 -0
  67. package/src/nodes/inputs/http/delete/function.js +28 -0
  68. package/src/nodes/inputs/http/delete/index.d.ts +4 -0
  69. package/src/nodes/inputs/http/delete/index.d.ts.map +1 -0
  70. package/src/nodes/inputs/http/delete/index.js +3 -0
  71. package/src/nodes/inputs/http/delete/schema.d.ts +16 -0
  72. package/src/nodes/inputs/http/delete/schema.d.ts.map +1 -0
  73. package/src/nodes/inputs/http/delete/schema.js +7 -0
  74. package/src/nodes/inputs/http/get/data.d.ts +3 -0
  75. package/src/nodes/inputs/http/get/data.d.ts.map +1 -0
  76. package/src/nodes/inputs/http/get/data.js +58 -0
  77. package/src/nodes/inputs/http/get/function.d.ts +2 -0
  78. package/src/nodes/inputs/http/get/function.d.ts.map +1 -0
  79. package/src/nodes/inputs/http/get/function.js +25 -0
  80. package/src/nodes/inputs/http/get/index.d.ts +4 -0
  81. package/src/nodes/inputs/http/get/index.d.ts.map +1 -0
  82. package/src/nodes/inputs/http/get/index.js +3 -0
  83. package/src/nodes/inputs/http/get/schema.d.ts +16 -0
  84. package/src/nodes/inputs/http/get/schema.d.ts.map +1 -0
  85. package/src/nodes/inputs/http/get/schema.js +7 -0
  86. package/src/nodes/inputs/http/index.d.ts +8 -0
  87. package/src/nodes/inputs/http/index.d.ts.map +1 -0
  88. package/src/nodes/inputs/http/index.js +10 -0
  89. package/src/nodes/inputs/http/patch/data.d.ts +3 -0
  90. package/src/nodes/inputs/http/patch/data.d.ts.map +1 -0
  91. package/src/nodes/inputs/http/patch/data.js +70 -0
  92. package/src/nodes/inputs/http/patch/function.d.ts +2 -0
  93. package/src/nodes/inputs/http/patch/function.d.ts.map +1 -0
  94. package/src/nodes/inputs/http/patch/function.js +36 -0
  95. package/src/nodes/inputs/http/patch/index.d.ts +4 -0
  96. package/src/nodes/inputs/http/patch/index.d.ts.map +1 -0
  97. package/src/nodes/inputs/http/patch/index.js +3 -0
  98. package/src/nodes/inputs/http/patch/schema.d.ts +21 -0
  99. package/src/nodes/inputs/http/patch/schema.d.ts.map +1 -0
  100. package/src/nodes/inputs/http/patch/schema.js +8 -0
  101. package/src/nodes/inputs/http/post/data.d.ts +3 -0
  102. package/src/nodes/inputs/http/post/data.d.ts.map +1 -0
  103. package/src/nodes/inputs/http/post/data.js +70 -0
  104. package/src/nodes/inputs/http/post/function.d.ts +2 -0
  105. package/src/nodes/inputs/http/post/function.d.ts.map +1 -0
  106. package/src/nodes/inputs/http/post/function.js +36 -0
  107. package/src/nodes/inputs/http/post/index.d.ts +4 -0
  108. package/src/nodes/inputs/http/post/index.d.ts.map +1 -0
  109. package/src/nodes/inputs/http/post/index.js +3 -0
  110. package/src/nodes/inputs/http/post/schema.d.ts +21 -0
  111. package/src/nodes/inputs/http/post/schema.d.ts.map +1 -0
  112. package/src/nodes/inputs/http/post/schema.js +8 -0
  113. package/src/nodes/inputs/http/put/data.d.ts +3 -0
  114. package/src/nodes/inputs/http/put/data.d.ts.map +1 -0
  115. package/src/nodes/inputs/http/put/data.js +70 -0
  116. package/src/nodes/inputs/http/put/function.d.ts +2 -0
  117. package/src/nodes/inputs/http/put/function.d.ts.map +1 -0
  118. package/src/nodes/inputs/http/put/function.js +36 -0
  119. package/src/nodes/inputs/http/put/index.d.ts +4 -0
  120. package/src/nodes/inputs/http/put/index.d.ts.map +1 -0
  121. package/src/nodes/inputs/http/put/index.js +3 -0
  122. package/src/nodes/inputs/http/put/schema.d.ts +21 -0
  123. package/src/nodes/inputs/http/put/schema.d.ts.map +1 -0
  124. package/src/nodes/inputs/http/put/schema.js +8 -0
  125. package/src/nodes/inputs/http/schemas.d.ts +18 -0
  126. package/src/nodes/inputs/http/schemas.d.ts.map +1 -0
  127. package/src/nodes/inputs/http/schemas.js +17 -0
  128. package/src/nodes/inputs/http/utils.d.ts +21 -0
  129. package/src/nodes/inputs/http/utils.d.ts.map +1 -0
  130. package/src/nodes/inputs/http/utils.js +63 -0
  131. package/src/nodes/inputs/index.d.ts +5 -0
  132. package/src/nodes/inputs/index.d.ts.map +1 -0
  133. package/src/nodes/inputs/index.js +4 -0
  134. package/src/nodes/inputs/manual/trigger.d.ts +4 -0
  135. package/src/nodes/inputs/manual/trigger.d.ts.map +1 -0
  136. package/src/nodes/inputs/manual/trigger.js +39 -0
  137. package/src/nodes/output-node/index.d.ts +4 -0
  138. package/src/nodes/output-node/index.d.ts.map +1 -0
  139. package/src/nodes/output-node/index.js +123 -0
  140. package/src/nodes/outputs/chat/output.d.ts +4 -0
  141. package/src/nodes/outputs/chat/output.d.ts.map +1 -0
  142. package/src/nodes/outputs/chat/output.js +48 -0
  143. package/src/nodes/outputs/http-output.d.ts +4 -0
  144. package/src/nodes/outputs/http-output.d.ts.map +1 -0
  145. package/src/nodes/outputs/http-output.js +76 -0
  146. package/src/nodes/processors/concat.d.ts +9 -0
  147. package/src/nodes/processors/concat.d.ts.map +1 -0
  148. package/src/nodes/processors/concat.js +68 -0
  149. package/src/nodes/processors/custom-code.d.ts +4 -0
  150. package/src/nodes/processors/custom-code.d.ts.map +1 -0
  151. package/src/nodes/processors/custom-code.js +54 -0
  152. package/src/nodes/processors/index.d.ts +2 -0
  153. package/src/nodes/processors/index.d.ts.map +1 -0
  154. package/src/nodes/processors/index.js +1 -0
  155. package/src/nodes/processors/transform.d.ts +3 -0
  156. package/src/nodes/processors/transform.d.ts.map +1 -0
  157. package/src/nodes/processors/transform.js +48 -0
  158. package/src/nodes/social/index.d.ts +2 -0
  159. package/src/nodes/social/index.d.ts.map +1 -0
  160. package/src/nodes/social/index.js +1 -0
  161. package/src/nodes/social/whatsapp/index.d.ts +4 -0
  162. package/src/nodes/social/whatsapp/index.d.ts.map +1 -0
  163. package/src/nodes/social/whatsapp/index.js +3 -0
  164. package/src/nodes/social/whatsapp/message-trigger/data.d.ts +3 -0
  165. package/src/nodes/social/whatsapp/message-trigger/data.d.ts.map +1 -0
  166. package/src/nodes/social/whatsapp/message-trigger/data.js +55 -0
  167. package/src/nodes/social/whatsapp/message-trigger/index.d.ts +2 -0
  168. package/src/nodes/social/whatsapp/message-trigger/index.d.ts.map +1 -0
  169. package/src/nodes/social/whatsapp/message-trigger/index.js +1 -0
  170. package/src/nodes/social/whatsapp/send-message/data.d.ts +8 -0
  171. package/src/nodes/social/whatsapp/send-message/data.d.ts.map +1 -0
  172. package/src/nodes/social/whatsapp/send-message/data.js +46 -0
  173. package/src/nodes/social/whatsapp/send-message/functions.d.ts +3 -0
  174. package/src/nodes/social/whatsapp/send-message/functions.d.ts.map +1 -0
  175. package/src/nodes/social/whatsapp/send-message/functions.js +32 -0
  176. package/src/nodes/social/whatsapp/send-message/index.d.ts +3 -0
  177. package/src/nodes/social/whatsapp/send-message/index.d.ts.map +1 -0
  178. package/src/nodes/social/whatsapp/send-message/index.js +2 -0
  179. package/src/nodes/social/whatsapp/send-template/data.d.ts +8 -0
  180. package/src/nodes/social/whatsapp/send-template/data.d.ts.map +1 -0
  181. package/src/nodes/social/whatsapp/send-template/data.js +42 -0
  182. package/src/nodes/social/whatsapp/send-template/functions.d.ts +5 -0
  183. package/src/nodes/social/whatsapp/send-template/functions.d.ts.map +1 -0
  184. package/src/nodes/social/whatsapp/send-template/functions.js +60 -0
  185. package/src/nodes/social/whatsapp/send-template/index.d.ts +3 -0
  186. package/src/nodes/social/whatsapp/send-template/index.d.ts.map +1 -0
  187. package/src/nodes/social/whatsapp/send-template/index.js +2 -0
  188. package/src/nodes/types/base-node.d.ts +17 -0
  189. package/src/nodes/types/base-node.d.ts.map +1 -0
  190. package/src/nodes/types/base-node.js +1 -0
  191. package/src/nodes/types/base-node.types.d.ts +144 -0
  192. package/src/nodes/types/base-node.types.d.ts.map +1 -0
  193. package/src/nodes/types/base-node.types.js +1 -0
  194. package/src/utils/llm-factory.d.ts +16 -0
  195. package/src/utils/llm-factory.d.ts.map +1 -0
  196. package/src/utils/llm-factory.js +110 -0
  197. package/dist/index.cjs +0 -2154
  198. package/dist/index.d.cts +0 -429
  199. package/dist/index.d.ts +0 -429
  200. package/dist/index.js +0 -2063
package/dist/index.js DELETED
@@ -1,2063 +0,0 @@
1
- // src/nodes/inputs/http/get/data.ts
2
- var HttpGetInputNode = {
3
- label: "Http GET Input",
4
- type: "HttpGetInput",
5
- category: "input",
6
- icon: "\u{1F310}",
7
- description: "Node que representa uma rota GET HTTP e recebe query/path parameters",
8
- group: "HTTP",
9
- tags: {
10
- execution: "sync",
11
- group: "HTTP"
12
- },
13
- fields: [
14
- {
15
- id: "route",
16
- label: "Route",
17
- type: "route",
18
- required: true,
19
- placeholder: "/produtos/{id}"
20
- },
21
- {
22
- id: "queryParams",
23
- label: "Query Params",
24
- type: "keyValue",
25
- required: false,
26
- handle: {
27
- type: "output",
28
- label: "Query Params",
29
- name: "queryParams",
30
- fieldType: "keyValue"
31
- }
32
- },
33
- {
34
- id: "headers",
35
- label: "Headers",
36
- type: "keyValue",
37
- required: false,
38
- handle: {
39
- type: "output",
40
- label: "Headers",
41
- name: "headers",
42
- fieldType: "keyValue"
43
- }
44
- },
45
- {
46
- id: "ip",
47
- label: "Request IP",
48
- type: "string",
49
- required: false,
50
- typeable: false,
51
- handle: {
52
- type: "output",
53
- label: "IP",
54
- name: "ip",
55
- fieldType: "string"
56
- }
57
- }
58
- ]
59
- };
60
-
61
- // src/nodes/inputs/http/get/function.ts
62
- var HttpGetInputNodeFunction = async (params) => {
63
- const { request, fieldValues } = params;
64
- const { queryParams: configQueryParams, headers: configHeaders } = fieldValues || {};
65
- const actualData = {
66
- queryParams: request?.query || {},
67
- headers: request?.headers || {},
68
- ip: request?.ip || "127.0.0.1"
69
- };
70
- if (configQueryParams) {
71
- const requiredParams = configQueryParams.filter((p) => p.required);
72
- const missingParams = requiredParams.filter((p) => !actualData.queryParams[p.key]);
73
- if (missingParams.length > 0) {
74
- throw new Error(`Par\xE2metros obrigat\xF3rios ausentes: ${missingParams.map((p) => p.key).join(", ")}`);
75
- }
76
- }
77
- if (configHeaders) {
78
- const requiredHeaders = configHeaders.filter((h) => h.required);
79
- const missingHeaders = requiredHeaders.filter((h) => !actualData.headers[h.key.toLowerCase()]);
80
- if (missingHeaders.length > 0) {
81
- throw new Error(`Headers obrigat\xF3rios ausentes: ${missingHeaders.map((h) => h.key).join(", ")}`);
82
- }
83
- }
84
- return actualData;
85
- };
86
-
87
- // src/nodes/inputs/http/get/schema.ts
88
- import { z as z2 } from "zod";
89
-
90
- // src/nodes/inputs/http/schemas.ts
91
- import { z } from "zod";
92
- var QueryParamSchema = z.object({
93
- key: z.string(),
94
- value: z.string().optional(),
95
- required: z.boolean().optional()
96
- });
97
- var HeaderSchema = z.object({
98
- key: z.string(),
99
- value: z.string().optional(),
100
- required: z.boolean().optional()
101
- });
102
- var BodyFieldSchema = z.object({
103
- key: z.string(),
104
- value: z.any().optional(),
105
- required: z.boolean().optional()
106
- });
107
- var RouteSchema = z.string().describe("HTTP route path");
108
-
109
- // src/nodes/inputs/http/get/schema.ts
110
- var HttpGetInputNodeSchema = z2.object({
111
- route: RouteSchema,
112
- queryParams: z2.array(QueryParamSchema).optional().describe("Query parameters configuration"),
113
- headers: z2.array(HeaderSchema).optional().describe("Headers configuration")
114
- });
115
-
116
- // src/nodes/inputs/http/post/data.ts
117
- var HttpPostInputNode = {
118
- label: "Http POST Input",
119
- type: "HttpPostInput",
120
- category: "input",
121
- icon: "\u{1F4E4}",
122
- description: "Node que representa uma rota POST HTTP e recebe dados no body",
123
- tags: {
124
- execution: "sync",
125
- group: "HTTP"
126
- },
127
- fields: [
128
- {
129
- id: "route",
130
- label: "Route",
131
- type: "route",
132
- required: true,
133
- placeholder: "/produtos/{id}"
134
- },
135
- {
136
- id: "queryParams",
137
- label: "Query Params",
138
- type: "keyValue",
139
- required: false,
140
- handle: {
141
- type: "output",
142
- label: "Query Params",
143
- name: "queryParams",
144
- fieldType: "keyValue"
145
- }
146
- },
147
- {
148
- id: "headers",
149
- label: "Headers",
150
- type: "keyValue",
151
- required: false,
152
- handle: {
153
- type: "output",
154
- label: "Headers",
155
- name: "headers",
156
- fieldType: "keyValue"
157
- }
158
- },
159
- {
160
- id: "body",
161
- label: "Body",
162
- type: "object",
163
- required: false,
164
- handle: {
165
- type: "output",
166
- label: "Body",
167
- name: "body",
168
- fieldType: "object",
169
- required: false
170
- }
171
- },
172
- {
173
- id: "ip",
174
- label: "Request IP",
175
- type: "string",
176
- required: false,
177
- typeable: false,
178
- handle: {
179
- type: "output",
180
- label: "IP",
181
- name: "ip",
182
- fieldType: "string"
183
- }
184
- }
185
- ]
186
- };
187
-
188
- // src/nodes/inputs/http/post/function.ts
189
- var HttpPostInputNodeFunction = (params) => {
190
- const { request, fieldValues } = params;
191
- const { queryParams: configQueryParams, headers: configHeaders, body: configBody } = fieldValues || {};
192
- if (request.method !== "POST") {
193
- throw new Error("M\xE9todo HTTP inv\xE1lido");
194
- }
195
- const actualData = {
196
- queryParams: request?.query || {},
197
- headers: request?.headers || {},
198
- body: request?.body || {},
199
- ip: request?.ip || "127.0.0.1"
200
- };
201
- if (configQueryParams) {
202
- const requiredParams = configQueryParams.filter((p) => p.required);
203
- const missingParams = requiredParams.filter((p) => !actualData.queryParams[p.key]);
204
- if (missingParams.length > 0) {
205
- throw new Error(`Par\xE2metros obrigat\xF3rios ausentes: ${missingParams.map((p) => p.key).join(", ")}`);
206
- }
207
- }
208
- if (configHeaders) {
209
- const requiredHeaders = configHeaders.filter((h) => h.required);
210
- const missingHeaders = requiredHeaders.filter((h) => !actualData.headers[h.key.toLowerCase()]);
211
- if (missingHeaders.length > 0) {
212
- throw new Error(`Headers obrigat\xF3rios ausentes: ${missingHeaders.map((h) => h.key).join(", ")}`);
213
- }
214
- }
215
- if (configBody) {
216
- const requiredBodyFields = configBody.filter((f) => f.required);
217
- const missingBodyFields = requiredBodyFields.filter((f) => !actualData.body[f.key]);
218
- if (missingBodyFields.length > 0) {
219
- throw new Error(`Campos obrigat\xF3rios do body ausentes: ${missingBodyFields.map((f) => f.key).join(", ")}`);
220
- }
221
- }
222
- return actualData;
223
- };
224
-
225
- // src/nodes/inputs/http/post/schema.ts
226
- import { z as z3 } from "zod";
227
- var HttpPostInputNodeSchema = z3.object({
228
- route: RouteSchema,
229
- queryParams: z3.array(QueryParamSchema).optional().describe("Query parameters configuration"),
230
- headers: z3.array(HeaderSchema).optional().describe("Headers configuration"),
231
- body: z3.array(BodyFieldSchema).optional().describe("Body fields configuration")
232
- });
233
-
234
- // src/nodes/inputs/chat/chat.ts
235
- var ChatInputNodeFunction = (params) => {
236
- const { request, fieldValues } = params;
237
- const { message: configMessage, chatId: configChatId } = fieldValues || {};
238
- const actualData = {
239
- message: request?.message ?? configMessage ?? "",
240
- chatId: request?.chatId ?? configChatId ?? null
241
- };
242
- if (!actualData.message || typeof actualData.message !== "string") {
243
- throw new Error("Message is required for ChatInputNode");
244
- }
245
- return actualData;
246
- };
247
- var ChatInputNode = {
248
- label: "Chat Input",
249
- type: "ChatInput",
250
- category: "input",
251
- icon: "\u{1F4AC}",
252
- description: "Entrada de mensagem de chat para iniciar conversas com IA",
253
- tags: {
254
- execution: "sync",
255
- group: "IA"
256
- },
257
- fields: [
258
- {
259
- id: "message",
260
- label: "Message",
261
- type: "string",
262
- required: true,
263
- typeable: false,
264
- handle: {
265
- type: "output",
266
- label: "Message",
267
- name: "message",
268
- fieldType: "string"
269
- }
270
- },
271
- {
272
- id: "chatId",
273
- label: "Chat ID",
274
- type: "string",
275
- required: true,
276
- typeable: false,
277
- handle: {
278
- type: "output",
279
- label: "Chat ID",
280
- name: "chatId",
281
- fieldType: "string"
282
- }
283
- }
284
- ]
285
- };
286
-
287
- // src/nodes/inputs/manual/trigger.ts
288
- var ManualTriggerNodeFunction = (params) => {
289
- const { fieldValues } = params || {};
290
- return fieldValues || {};
291
- };
292
- var ManualTriggerNode = {
293
- label: "Manual Trigger",
294
- type: "ManualTrigger",
295
- category: "input",
296
- icon: "\u{1F590}\uFE0F",
297
- description: "Dispara fluxo manualmente e envia campos din\xE2micos",
298
- tags: {
299
- execution: "sync",
300
- group: "Custom"
301
- },
302
- fields: [
303
- {
304
- id: "stringExample",
305
- label: "String Example",
306
- type: "string",
307
- handle: { type: "output", label: "String", name: "stringExample", fieldType: "string" },
308
- placeholder: "Ex.: valor literal"
309
- },
310
- {
311
- id: "numberExample",
312
- label: "Number Example",
313
- type: "number",
314
- handle: { type: "output", label: "Number", name: "numberExample", fieldType: "number" },
315
- placeholder: "Ex.: 123"
316
- },
317
- {
318
- id: "keyValue1",
319
- label: "Key/Value 1",
320
- type: "keyValue",
321
- handle: { type: "output", label: "Key/Value", name: "keyValue1", fieldType: "keyValue" }
322
- }
323
- ]
324
- };
325
-
326
- // src/nodes/processors/concat.ts
327
- import { z as z4 } from "zod";
328
- var ConcatNodeFunction = (inputs) => {
329
- const input1 = inputs.input1 || "";
330
- const input2 = inputs.input2 || "";
331
- const result = `${input1}${input2}`;
332
- return {
333
- output: result,
334
- function: ConcatNodeFunction,
335
- type: "ConcatNode"
336
- };
337
- };
338
- var ConcatNodeSchema = z4.object({
339
- input1: z4.string(),
340
- input2: z4.string()
341
- });
342
- var ConcatNode = {
343
- label: "Concat Data",
344
- type: "ConcatNode",
345
- category: "step",
346
- icon: "\u{1F504}",
347
- description: "Node para concatenar dados de entrada",
348
- toolable: true,
349
- fields: [
350
- {
351
- id: "input1",
352
- label: "Input 1",
353
- type: "string",
354
- required: true,
355
- typeable: false,
356
- handle: {
357
- type: "input",
358
- label: "Input 1",
359
- name: "input1",
360
- fieldType: "string",
361
- required: true
362
- }
363
- },
364
- {
365
- id: "input2",
366
- label: "Input 2",
367
- type: "string",
368
- required: true,
369
- typeable: false,
370
- handle: {
371
- type: "input",
372
- label: "Input 2",
373
- name: "input2",
374
- fieldType: "string",
375
- required: true
376
- }
377
- },
378
- {
379
- id: "output",
380
- label: "Output",
381
- type: "string",
382
- required: true,
383
- typeable: false,
384
- handle: {
385
- type: "output",
386
- label: "Output",
387
- name: "output",
388
- fieldType: "string",
389
- required: true
390
- }
391
- }
392
- ]
393
- };
394
-
395
- // src/nodes/output-node/index.ts
396
- var HttpOutputNodeFunction = (params) => {
397
- const { fieldValues, results } = params;
398
- let responseData = fieldValues?.data || {};
399
- if (typeof responseData === "object" && responseData !== null) {
400
- const processedData = {};
401
- for (const [key, value] of Object.entries(responseData)) {
402
- if (typeof value === "string" && value.includes("{{")) {
403
- processedData[key] = processPlaceholders(value, results);
404
- } else {
405
- processedData[key] = value;
406
- }
407
- }
408
- responseData = processedData;
409
- } else if (typeof responseData === "string") {
410
- responseData = { value: responseData };
411
- }
412
- const status = fieldValues?.status || 200;
413
- const headers = fieldValues?.headers || {};
414
- if (status && (status < 100 || status > 599)) {
415
- throw new Error(`Status HTTP inv\xE1lido: ${status}`);
416
- }
417
- return {
418
- status,
419
- headers,
420
- data: responseData,
421
- isHttpResponse: true
422
- };
423
- };
424
- function processPlaceholders(value, results) {
425
- return value.replace(/\{\{(.*?)\}\}/g, (match, placeholder) => {
426
- const parts = placeholder.split("-");
427
- const friendlyId = parts[0];
428
- const fieldName = parts[1];
429
- const keyName = parts.length > 2 ? parts[2] : void 0;
430
- const sourceResult = results[friendlyId];
431
- if (sourceResult) {
432
- if (keyName) {
433
- return sourceResult[fieldName]?.[keyName] || keyName;
434
- } else {
435
- return sourceResult[fieldName] || "";
436
- }
437
- }
438
- return match;
439
- });
440
- }
441
- var OutputNode = {
442
- label: "Http Output Node",
443
- type: "HttpOutput",
444
- category: "output",
445
- icon: "\u{1F4E4}",
446
- description: "Node de sa\xEDda do workflow que aceita qualquer entrada e retorna ela diretamente",
447
- group: "HTTP",
448
- tags: {
449
- execution: "sync",
450
- group: "HTTP"
451
- },
452
- fields: [
453
- {
454
- id: "status",
455
- label: "Status Code",
456
- type: "select",
457
- required: true,
458
- defaultValue: 200,
459
- options: [
460
- { label: "200 - OK", value: 200 },
461
- { label: "201 - Created", value: 201 },
462
- { label: "204 - No Content", value: 204 },
463
- { label: "400 - Bad Request", value: 400 },
464
- { label: "401 - Unauthorized", value: 401 },
465
- { label: "403 - Forbidden", value: 403 },
466
- { label: "404 - Not Found", value: 404 },
467
- { label: "422 - Unprocessable Entity", value: 422 },
468
- { label: "500 - Internal Server Error", value: 500 }
469
- ],
470
- handle: {
471
- type: "output",
472
- label: "Status",
473
- name: "status",
474
- fieldType: "number",
475
- required: true
476
- }
477
- },
478
- {
479
- id: "headers",
480
- label: "Response Headers",
481
- type: "keyValue",
482
- required: false,
483
- defaultValue: {},
484
- handle: {
485
- type: "output",
486
- label: "Headers",
487
- name: "headers",
488
- fieldType: "object",
489
- required: false
490
- }
491
- },
492
- {
493
- id: "data",
494
- label: "Response Data",
495
- type: "json",
496
- required: true,
497
- handle: {
498
- type: "input",
499
- label: "Data",
500
- name: "data",
501
- fieldType: "json",
502
- required: true
503
- }
504
- }
505
- ]
506
- };
507
-
508
- // src/nodes/outputs/chat/output.ts
509
- var ChatOutputNodeFunction = async (params) => {
510
- const { inputs, fieldValues, stream, emitter } = params || {};
511
- const content = inputs?.data ?? fieldValues?.data ?? "";
512
- if (stream && emitter) {
513
- try {
514
- emitter.emitDone({ content });
515
- } catch (_e) {
516
- try {
517
- emitter.emitDone({ content });
518
- } catch (err) {
519
- console.debug("ChatOutput emitDone error", err);
520
- }
521
- }
522
- }
523
- return {
524
- output: content,
525
- type: "ChatOutput"
526
- };
527
- };
528
- var ChatOutputNode = {
529
- label: "Chat Output",
530
- type: "ChatOutput",
531
- category: "output",
532
- icon: "\u{1F4E4}",
533
- description: "Output de chat que envia a resposta para o cliente via WebSocket",
534
- tags: {
535
- execution: "async",
536
- group: "IA"
537
- },
538
- fields: [
539
- {
540
- id: "data",
541
- label: "Data",
542
- type: "string",
543
- required: true,
544
- typeable: false,
545
- handle: {
546
- type: "input",
547
- label: "Data",
548
- name: "data",
549
- fieldType: "string"
550
- }
551
- }
552
- ]
553
- };
554
-
555
- // src/nodes/ia/agent/data.ts
556
- import { z as z5 } from "zod";
557
- var IaAgentNodeSchema = z5.object({
558
- name: z5.string().describe("Unique name for the agent"),
559
- systemMessage: z5.string().optional().describe("System context for the agent"),
560
- message: z5.string().optional().describe("Input message for the agent"),
561
- model: z5.any().describe("LLM model for the agent"),
562
- tools: z5.any().optional().describe("Tools available to the agent")
563
- });
564
- var IaAgentNode = {
565
- label: "IA Agent",
566
- type: "IaAgentNode",
567
- category: "step",
568
- description: "Creates a configurable AI agent for supervision",
569
- icon: "\u{1F916}",
570
- toolable: true,
571
- group: "IA",
572
- tags: {
573
- execution: "async",
574
- group: "IA"
575
- },
576
- fields: [
577
- {
578
- id: "name",
579
- label: "Agent Name",
580
- type: "string",
581
- required: true,
582
- placeholder: "e.g., researcher_agent"
583
- },
584
- {
585
- id: "systemMessage",
586
- label: "System Message",
587
- type: "textarea",
588
- required: true,
589
- placeholder: "You are a web researcher...",
590
- handle: {
591
- type: "input",
592
- label: "System Message",
593
- name: "systemMessage",
594
- fieldType: "string"
595
- }
596
- },
597
- {
598
- id: "message",
599
- label: "Message",
600
- type: "string",
601
- required: false,
602
- typeable: false,
603
- handle: {
604
- type: "input",
605
- label: "Message",
606
- name: "message",
607
- fieldType: "string"
608
- }
609
- },
610
- {
611
- id: "model",
612
- label: "Model",
613
- type: "model",
614
- typeable: false,
615
- required: true,
616
- handle: {
617
- type: "input",
618
- label: "Model",
619
- name: "model",
620
- fieldType: "model",
621
- acceptTypes: ["model"],
622
- maxConnections: 1
623
- }
624
- },
625
- {
626
- id: "tools",
627
- label: "Tools",
628
- type: "tool",
629
- required: false,
630
- typeable: false,
631
- handle: {
632
- type: "input",
633
- label: "Tools",
634
- name: "tools",
635
- fieldType: "tool",
636
- acceptTypes: ["tool"]
637
- }
638
- },
639
- {
640
- id: "agent",
641
- label: "Agent",
642
- type: "agent",
643
- required: true,
644
- typeable: false,
645
- handle: {
646
- type: "output",
647
- label: "Agent",
648
- name: "agent",
649
- fieldType: "agent"
650
- }
651
- },
652
- {
653
- id: "response",
654
- label: "Response",
655
- type: "string",
656
- required: true,
657
- typeable: false,
658
- handle: {
659
- type: "output",
660
- label: "response",
661
- name: "response",
662
- fieldType: "string"
663
- }
664
- }
665
- ]
666
- };
667
-
668
- // src/nodes/ia/agent/function.ts
669
- import { createReactAgent } from "@langchain/langgraph/prebuilt";
670
- import { SystemMessage } from "@langchain/core/messages";
671
-
672
- // src/utils/llm-factory.ts
673
- import { GraphQLClient, gql } from "graphql-request";
674
- import { ChatGoogle } from "@langchain/google-gauth";
675
- import { ChatOpenAI } from "@langchain/openai";
676
- var GRAPHQL_ENDPOINT = process.env["GRAPHQL_URL"] || "http://localhost:3001/graphql";
677
- var GET_INTEGRATIONS_QUERY = gql`
678
- query GetIntegrations($where: IntegrationWhereInput) {
679
- getIntegrations(where: $where) {
680
- status
681
- message
682
- data {
683
- id
684
- status
685
- data
686
- }
687
- }
688
- }
689
- `;
690
- async function createLLMFromModel(modelConfig, authToken, streaming = false) {
691
- if (modelConfig?.invoke || modelConfig?.call) {
692
- return modelConfig;
693
- }
694
- if (!modelConfig?.model || !modelConfig?.integrationId) {
695
- throw new Error('Model config deve conter "model" e "integrationId"');
696
- }
697
- const { model, integrationId } = modelConfig;
698
- const client = new GraphQLClient(GRAPHQL_ENDPOINT, {
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);
731
- switch (provider) {
732
- case "gemini":
733
- return new ChatGoogle({
734
- model: "gemini-flash-latest",
735
- apiKey,
736
- streaming
737
- });
738
- case "openai":
739
- return new ChatOpenAI({
740
- model,
741
- openAIApiKey: apiKey,
742
- streaming
743
- });
744
- case "openrouter":
745
- return new ChatOpenAI({
746
- model,
747
- openAIApiKey: apiKey,
748
- configuration: {
749
- baseURL: "https://openrouter.ai/api/v1"
750
- },
751
- streaming
752
- });
753
- default:
754
- throw new Error(
755
- `Provider "${provider}" n\xE3o suportado. Providers dispon\xEDveis: gemini, openai, openrouter`
756
- );
757
- }
758
- }
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
-
770
- // src/nodes/ia/agent/function.ts
771
- var IaAgentNodeFunction = async (inputs) => {
772
- const { model, tools, systemMessage, name, message } = inputs.fieldValues;
773
- const authToken = inputs.authToken;
774
- if (!name) {
775
- throw new Error("Agent 'name' is required. Please provide a unique name for the agent in the node properties.");
776
- }
777
- if (!model) {
778
- throw new Error("Model is required for IaAgentNode");
779
- }
780
- let toolsArray = [];
781
- if (Array.isArray(tools)) {
782
- toolsArray = tools;
783
- } else if (tools) {
784
- toolsArray = [tools];
785
- }
786
- const finalSystemMessageContent = `${systemMessage || ""}
787
-
788
- IMPORTANT: You must base your response on the last message in the conversation history.`;
789
- const finalSystemMessage = new SystemMessage(finalSystemMessageContent);
790
- let llmInstance;
791
- if (model?.integrationId) {
792
- if (!authToken) {
793
- throw new Error("Auth token is required to instantiate LLM from integration");
794
- }
795
- const streaming = Boolean(inputs?.stream);
796
- llmInstance = await createLLMFromModel(model, authToken, streaming);
797
- } else if (typeof model?.bindTools === "function") {
798
- llmInstance = model;
799
- } else {
800
- throw new Error("Invalid model: must have integrationId or be a valid LLM instance with bindTools method");
801
- }
802
- const agent = createReactAgent({
803
- llm: llmInstance,
804
- tools: toolsArray,
805
- messageModifier: finalSystemMessage
806
- });
807
- agent.name = name;
808
- let output = "";
809
- if (message) {
810
- try {
811
- const { HumanMessage: HumanMessage2 } = await import("@langchain/core/messages");
812
- const result = await agent.invoke({
813
- messages: [new HumanMessage2(message)]
814
- });
815
- if (result?.messages && result.messages.length > 0) {
816
- const lastMessage = result.messages[result.messages.length - 1];
817
- const content = lastMessage?.content;
818
- if (typeof content === "string") {
819
- output = content;
820
- } else if (Array.isArray(content)) {
821
- output = content.map((part) => {
822
- if (typeof part === "string") return part;
823
- if (part?.type === "text") return part.text;
824
- return "";
825
- }).filter(Boolean).join("\n");
826
- } else {
827
- output = "";
828
- }
829
- }
830
- } catch (error) {
831
- console.error("Error processing message in agent:", error);
832
- output = `Error: ${error instanceof Error ? error.message : "Unknown error"}`;
833
- }
834
- }
835
- return {
836
- agent,
837
- output: output || ""
838
- };
839
- };
840
-
841
- // src/nodes/ia/supervisor/data.ts
842
- import { z as z6 } from "zod";
843
- var AiSupervisorNodeSchema = z6.object({
844
- model: z6.any().describe("LLM model for the supervisor"),
845
- agents: z6.any().optional().describe("Agent(s) to supervise"),
846
- message: z6.string().describe("Task or message for the supervisor to handle"),
847
- systemMessage: z6.string().optional().describe("Custom system message for the supervisor")
848
- });
849
- var AiSupervisorNode = {
850
- label: "AI Supervisor",
851
- type: "AiSupervisorNode",
852
- category: "step",
853
- description: "Coordinates multiple agents to perform tasks manually",
854
- icon: "\u{1F440}",
855
- toolable: false,
856
- group: "IA",
857
- tags: {
858
- execution: "async",
859
- group: "IA"
860
- },
861
- fields: [
862
- {
863
- id: "message",
864
- label: "Message",
865
- type: "string",
866
- required: true,
867
- handle: { type: "input", label: "Message", name: "message", fieldType: "string" }
868
- },
869
- {
870
- id: "systemMessage",
871
- label: "System Message",
872
- type: "textarea",
873
- required: false,
874
- placeholder: "You are a supervisor... (use {members} to list agents)",
875
- handle: {
876
- type: "input",
877
- label: "System Message",
878
- name: "systemMessage",
879
- fieldType: "string"
880
- }
881
- },
882
- {
883
- id: "model",
884
- label: "Model",
885
- type: "model",
886
- typeable: false,
887
- required: true,
888
- handle: {
889
- type: "input",
890
- label: "Model",
891
- name: "model",
892
- fieldType: "model",
893
- acceptTypes: ["model"],
894
- maxConnections: 1
895
- }
896
- },
897
- {
898
- id: "agents",
899
- label: "Agents",
900
- type: "agent",
901
- required: true,
902
- typeable: false,
903
- handle: {
904
- type: "input",
905
- label: "Agents",
906
- name: "agents",
907
- fieldType: "agent",
908
- acceptTypes: ["agent"]
909
- }
910
- },
911
- {
912
- id: "response",
913
- label: "Response",
914
- type: "string",
915
- required: true,
916
- typeable: false,
917
- handle: {
918
- type: "output",
919
- label: "response",
920
- name: "response",
921
- fieldType: "string"
922
- }
923
- }
924
- ]
925
- };
926
-
927
- // src/nodes/ia/supervisor/function.ts
928
- import { createSupervisor } from "@langchain/langgraph-supervisor";
929
- import { HumanMessage } from "@langchain/core/messages";
930
- import { InMemoryStore, MemorySaver } from "@langchain/langgraph";
931
- var checkpointer = new MemorySaver();
932
- var store = new InMemoryStore();
933
- var extractSupervisorAgents = (agents) => {
934
- if (Array.isArray(agents)) {
935
- return agents.map((a) => a.agent).filter(Boolean);
936
- }
937
- if (agents?.agent) {
938
- return [agents.agent];
939
- }
940
- return [agents];
941
- };
942
- var extractFinalResponse = (messages) => {
943
- if (!messages || messages.length === 0) return "No response generated.";
944
- const isTransferOrToolMsg = (m) => {
945
- const content = m?.content;
946
- const name = m?.name;
947
- const hasToolCallId = typeof m?.tool_call_id === "string" || typeof m?.additional_kwargs?.tool_call_id === "string";
948
- const hasToolCalls = Array.isArray(m?.additional_kwargs?.tool_calls) && m.additional_kwargs.tool_calls.length > 0;
949
- const contentStr = typeof content === "string" ? content : "";
950
- const nameStr = typeof name === "string" ? name : "";
951
- if (hasToolCallId || hasToolCalls) return true;
952
- if (/^Successfully transferred/i.test(contentStr)) return true;
953
- if (/^Transferring back to supervisor/i.test(contentStr)) return true;
954
- if (/^transfer_/i.test(nameStr)) return true;
955
- return false;
956
- };
957
- for (let i = messages.length - 1; i >= 0; i--) {
958
- const msg = messages[i];
959
- if (isTransferOrToolMsg(msg)) continue;
960
- const content = msg?.content;
961
- if (typeof content === "string" && content.trim()) return content;
962
- if (Array.isArray(content)) {
963
- const textContent = content.map((part) => part.type === "text" ? part.text : "").filter(Boolean).join("\n");
964
- if (textContent.trim()) return textContent;
965
- }
966
- }
967
- const lastMessage = messages[messages.length - 1];
968
- if (!lastMessage?.content) return "No response generated.";
969
- if (typeof lastMessage.content === "string") return lastMessage.content;
970
- if (Array.isArray(lastMessage.content)) {
971
- const textContent = lastMessage.content.map((part) => part.type === "text" ? part.text : "").filter(Boolean).join("\n");
972
- return textContent || JSON.stringify(lastMessage.content);
973
- }
974
- return "No response generated.";
975
- };
976
- var AiSupervisorNodeFunction = async (fieldValues) => {
977
- const outer = fieldValues ?? {};
978
- const inner = outer && typeof outer === "object" && outer.fieldValues && typeof outer.fieldValues === "object" ? outer.fieldValues : {};
979
- const model = inner.model ?? outer.model;
980
- const agents = inner.agents ?? outer.agents;
981
- const message = inner.message ?? outer.message;
982
- const systemMessage = inner.systemMessage ?? outer.systemMessage;
983
- const stream = (typeof outer.stream === "boolean" ? outer.stream : inner.stream) ?? false;
984
- const emitter = outer.emitter ?? inner.emitter;
985
- const authToken = outer.authToken ?? inner.authToken;
986
- if (!model) throw new Error("Model is required for AiSupervisorNode");
987
- if (!agents) throw new Error("Agents are required for AiSupervisorNode.");
988
- try {
989
- const supervisorAgents = extractSupervisorAgents(agents);
990
- if (supervisorAgents.length === 0) throw new Error("No valid agents were extracted from the 'agents' input.");
991
- if (supervisorAgents.some((agent) => !agent.name)) throw new Error("All agents must have a name.");
992
- let llmInstance;
993
- if (model?.model && model?.integrationId) {
994
- if (!authToken) {
995
- throw new Error("Auth token is required to instantiate LLM from integration 3");
996
- }
997
- llmInstance = await createLLMFromModel(model, authToken, stream);
998
- } else {
999
- llmInstance = model;
1000
- }
1001
- const finalSystemPrompt = systemMessage || "You are a supervisor...";
1002
- const workflow = createSupervisor({
1003
- llm: llmInstance,
1004
- agents: supervisorAgents,
1005
- prompt: finalSystemPrompt
1006
- });
1007
- const app = workflow.compile({
1008
- checkpointer,
1009
- store
1010
- });
1011
- if (stream && emitter) {
1012
- try {
1013
- const streamIterator = await app.stream(
1014
- { messages: [new HumanMessage({ content: message })] },
1015
- { recursionLimit: 150, configurable: { thread_id: "conversation" } }
1016
- );
1017
- let finalMessages = [];
1018
- const previousStepMessages = /* @__PURE__ */ new Map();
1019
- const sentMessages = /* @__PURE__ */ new Set();
1020
- let stepCount = 0;
1021
- for await (const step of streamIterator) {
1022
- stepCount++;
1023
- if (step && typeof step === "object") {
1024
- for (const [agentKey, agentData] of Object.entries(step)) {
1025
- if (agentData && typeof agentData === "object" && "messages" in agentData) {
1026
- const currentMessages = agentData.messages;
1027
- if (Array.isArray(currentMessages) && currentMessages.length > 0) {
1028
- finalMessages = currentMessages;
1029
- const previousCount = previousStepMessages.get(agentKey) || 0;
1030
- const currentCount = currentMessages.length;
1031
- if (currentCount > previousCount) {
1032
- const newMessages = currentMessages.slice(previousCount);
1033
- const structuredMessages = newMessages.map((msg) => {
1034
- const msgContent = msg?.content || "";
1035
- const msgName = msg?.name || "";
1036
- const toolCallId = msg?.tool_call_id;
1037
- const isTool = !!(toolCallId || msgName.includes("transfer_") || msgContent.includes("Successfully transferred"));
1038
- const isAgent = !isTool && agentKey !== "supervisor";
1039
- let name = "";
1040
- if (isTool) {
1041
- if (msgName.includes("transfer_")) {
1042
- name = msgName;
1043
- } else {
1044
- name = "transfer_tool";
1045
- }
1046
- } else if (isAgent) {
1047
- name = msgName || agentKey;
1048
- } else {
1049
- name = agentKey === "supervisor" ? "supervisor" : agentKey;
1050
- }
1051
- return {
1052
- isTool,
1053
- isAgent,
1054
- name,
1055
- message: msgContent.trim()
1056
- };
1057
- }).filter((item) => item.message);
1058
- if (structuredMessages.length > 0) {
1059
- structuredMessages.forEach((structuredMsg) => {
1060
- const messageHash = `${structuredMsg.name}-${structuredMsg.message.slice(0, 100)}`;
1061
- if (!sentMessages.has(messageHash)) {
1062
- sentMessages.add(messageHash);
1063
- if (emitter?.emitDelta) {
1064
- emitter.emitDelta({
1065
- content: structuredMsg.message,
1066
- actor: structuredMsg.name,
1067
- isAgent: structuredMsg.isAgent,
1068
- isTool: structuredMsg.isTool
1069
- });
1070
- }
1071
- }
1072
- });
1073
- }
1074
- previousStepMessages.set(agentKey, currentCount);
1075
- }
1076
- }
1077
- }
1078
- }
1079
- }
1080
- }
1081
- const finalResponse = extractFinalResponse(finalMessages);
1082
- return {
1083
- output: finalResponse,
1084
- function: AiSupervisorNodeFunction,
1085
- type: "AiSupervisorNode"
1086
- };
1087
- } catch (err) {
1088
- console.error("\u274C Streaming error:", err);
1089
- throw err;
1090
- }
1091
- } else {
1092
- const result = await app.invoke(
1093
- { messages: [new HumanMessage({ content: message })] },
1094
- { recursionLimit: 150, configurable: { thread_id: "conversation" } }
1095
- );
1096
- const finalResponse = extractFinalResponse(result?.messages);
1097
- return {
1098
- output: finalResponse,
1099
- function: AiSupervisorNodeFunction,
1100
- type: "AiSupervisorNode"
1101
- };
1102
- }
1103
- } catch (error) {
1104
- console.error("\u274C AiSupervisorNode - Error:", error);
1105
- return {
1106
- output: `Error: ${error instanceof Error ? error.message : String(error)}`,
1107
- function: AiSupervisorNodeFunction,
1108
- type: "AiSupervisorNode"
1109
- };
1110
- }
1111
- };
1112
-
1113
- // src/nodes/ia/tool/data.ts
1114
- import { z as z7 } from "zod";
1115
- var CustomToolSchema = z7.object({
1116
- input: z7.string().optional().describe("Input for the tool")
1117
- });
1118
- var AiToolNodeSchema = z7.object({
1119
- name: z7.string().describe("Name of the tool"),
1120
- description: z7.string().describe("Description of what the tool does"),
1121
- // z.function() não suporta .describe(), então usamos z.any() para aceitar qualquer função.
1122
- nodeFunction: z7.any().describe("The function to execute"),
1123
- nodeType: z7.string().describe("The type of the node the tool represents"),
1124
- originalNodeData: z7.any().optional().describe("Original data of the node"),
1125
- workflowService: z7.any().optional().describe("Service for workflow operations"),
1126
- currentResults: z7.any().optional().describe("Current results in the workflow")
1127
- });
1128
- var AiToolNode = {
1129
- label: "AI Tool",
1130
- type: "AiToolNode",
1131
- category: "step",
1132
- description: "Wraps another node to be used as a tool by an AI agent",
1133
- icon: "\u{1F6E0}\uFE0F",
1134
- group: "IA",
1135
- tags: {
1136
- execution: "async",
1137
- group: "IA"
1138
- },
1139
- fields: [
1140
- {
1141
- id: "name",
1142
- label: "Name",
1143
- type: "string",
1144
- required: true
1145
- },
1146
- {
1147
- id: "description",
1148
- label: "Description",
1149
- type: "string",
1150
- required: true
1151
- },
1152
- {
1153
- id: "function",
1154
- label: "Function",
1155
- type: "any",
1156
- // Alterado para 'any' para corresponder ao schema z.any()
1157
- required: true,
1158
- typeable: false,
1159
- handle: {
1160
- type: "input",
1161
- label: "Input",
1162
- name: "input",
1163
- fieldType: "string",
1164
- required: true
1165
- }
1166
- },
1167
- {
1168
- id: "tool",
1169
- label: "Tool",
1170
- type: "tool",
1171
- required: true,
1172
- typeable: false,
1173
- handle: {
1174
- type: "output",
1175
- label: "Tool",
1176
- name: "tool",
1177
- fieldType: "tool",
1178
- required: true,
1179
- acceptTypes: ["tool"]
1180
- }
1181
- }
1182
- ]
1183
- };
1184
-
1185
- // src/nodes/ia/tool/function.ts
1186
- import { tool } from "@langchain/core/tools";
1187
-
1188
- // src/nodes/consts/schemas.ts
1189
- var schemas = {
1190
- IaAgentNode: IaAgentNodeSchema,
1191
- AiSupervisorNode: AiSupervisorNodeSchema,
1192
- AiToolNode: AiToolNodeSchema,
1193
- IaMessageNode: IaMessageNodeSchema
1194
- };
1195
-
1196
- // src/nodes/ia/tool/function.ts
1197
- var AiToolNodeFunction = async (fieldValues) => {
1198
- const { name, description, nodeFunction, nodeType, originalNodeData, workflowService, currentResults } = fieldValues;
1199
- const schema = schemas[nodeType] || CustomToolSchema;
1200
- const dynamicTool = tool(
1201
- async (args) => {
1202
- if (nodeFunction && typeof nodeFunction === "function") {
1203
- try {
1204
- let resolvedInputs = originalNodeData?.inputs || {};
1205
- if (workflowService && currentResults && originalNodeData?.inputs) {
1206
- resolvedInputs = await workflowService.resolveInputs(originalNodeData.inputs, currentResults);
1207
- }
1208
- const combinedInputs = {
1209
- ...resolvedInputs,
1210
- ...args,
1211
- originalNodeData
1212
- };
1213
- const result = await nodeFunction({ fieldValues: combinedInputs });
1214
- return result?.output || result;
1215
- } catch (error) {
1216
- return `Error: ${error instanceof Error ? error.message : String(error)}`;
1217
- }
1218
- }
1219
- return "Tool function not provided";
1220
- },
1221
- {
1222
- name: name || "Dynamic Tool",
1223
- description: description || "Tool created from workflow",
1224
- schema
1225
- }
1226
- );
1227
- return {
1228
- tool: dynamicTool
1229
- };
1230
- };
1231
-
1232
- // src/nodes/ia/message/message.ts
1233
- import { z as z8 } from "zod";
1234
- var IaMessageNodeSchema = z8.object({
1235
- model: z8.any().describe("LLM model to use"),
1236
- systemMessage: z8.string().optional().describe("System message for context"),
1237
- message: z8.string().describe("User message to send to the LLM")
1238
- });
1239
- var IaMessageNodeFunction = async (inputs) => {
1240
- const fieldValues = inputs.fieldValues || inputs;
1241
- const { model, systemMessage, message } = fieldValues;
1242
- const authToken = inputs.authToken;
1243
- if (!model) {
1244
- throw new Error("Model is required");
1245
- }
1246
- if (!message) {
1247
- throw new Error("Message is required");
1248
- }
1249
- let llmInstance;
1250
- if (model?.model && model?.integrationId) {
1251
- if (!authToken) {
1252
- throw new Error("Auth token is required to instantiate LLM from integration2 ");
1253
- }
1254
- const streaming = Boolean(inputs?.stream);
1255
- llmInstance = await createLLMFromModel(model, authToken, streaming);
1256
- } else {
1257
- llmInstance = model;
1258
- }
1259
- const messages = [];
1260
- if (systemMessage) {
1261
- messages.push(["system", systemMessage]);
1262
- }
1263
- messages.push(["human", message]);
1264
- try {
1265
- const response = await llmInstance.invoke(messages);
1266
- return {
1267
- output: response.content,
1268
- response: response.content,
1269
- fullResponse: response
1270
- };
1271
- } catch (error) {
1272
- const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
1273
- throw new Error(`Error invoking Model: ${errorMessage}`);
1274
- }
1275
- };
1276
- var IaMessageNode = {
1277
- label: "AI Message",
1278
- type: "IaMessageNode",
1279
- category: "step",
1280
- description: "Send message to AI model and return response",
1281
- icon: "\u{1F4AC}",
1282
- group: "IA",
1283
- tags: {
1284
- execution: "async",
1285
- group: "IA"
1286
- },
1287
- fields: [
1288
- {
1289
- id: "model",
1290
- label: "Model",
1291
- type: "model",
1292
- required: true,
1293
- typeable: false,
1294
- handle: {
1295
- type: "input",
1296
- label: "Model",
1297
- name: "model",
1298
- fieldType: "model",
1299
- acceptTypes: ["model"],
1300
- maxConnections: 1,
1301
- required: true
1302
- }
1303
- },
1304
- {
1305
- id: "systemMessage",
1306
- label: "System Message",
1307
- type: "string",
1308
- required: false,
1309
- placeholder: "You are a helpful assistant...",
1310
- handle: {
1311
- type: "input",
1312
- label: "System Message",
1313
- name: "systemMessage",
1314
- fieldType: "string"
1315
- }
1316
- },
1317
- {
1318
- id: "message",
1319
- label: "Message",
1320
- type: "string",
1321
- required: true,
1322
- placeholder: "Type your message...",
1323
- handle: {
1324
- type: "input",
1325
- label: "Message",
1326
- name: "message",
1327
- fieldType: "string"
1328
- }
1329
- },
1330
- {
1331
- id: "response",
1332
- label: "Response",
1333
- type: "string",
1334
- required: true,
1335
- typeable: false,
1336
- handle: {
1337
- type: "output",
1338
- label: "response",
1339
- name: "response",
1340
- fieldType: "string"
1341
- }
1342
- }
1343
- ]
1344
- };
1345
-
1346
- // src/nodes/social/whatsapp/send-template/data.ts
1347
- import { z as z9 } from "zod";
1348
- var WhatsappSendTemplateNodeSchema = z9.object({
1349
- phoneNumber: z9.string().describe("Phone number to send the message to"),
1350
- message: z9.string().describe("Message to send")
1351
- });
1352
- var WhatsappSendTemplateNode = {
1353
- label: "Whatsapp Send Template",
1354
- type: "WhatsappSendTemplateNode",
1355
- category: "step",
1356
- description: "Send a template message to a WhatsApp number",
1357
- icon: "\u{1F4F1}",
1358
- toolable: true,
1359
- group: "Social",
1360
- tags: {
1361
- execution: "async",
1362
- group: "Social"
1363
- },
1364
- fields: [
1365
- {
1366
- id: "phoneNumber",
1367
- label: "Phone Number",
1368
- type: "string",
1369
- required: true,
1370
- placeholder: "e.g., +5511999999999",
1371
- handle: {
1372
- type: "input",
1373
- label: "Phone Number",
1374
- name: "phoneNumber",
1375
- fieldType: "string"
1376
- }
1377
- },
1378
- {
1379
- id: "template",
1380
- label: "Template",
1381
- type: "select",
1382
- required: true,
1383
- optionsSource: {
1384
- provider: "whatsapp.messageTemplates"
1385
- }
1386
- }
1387
- ]
1388
- };
1389
-
1390
- // src/nodes/social/whatsapp/send-message/data.ts
1391
- import { z as z10 } from "zod";
1392
- var WhatsappSendMessageNodeSchema = z10.object({
1393
- phoneNumber: z10.string().describe("Phone number to send the message to"),
1394
- message: z10.string().describe("Message content to send")
1395
- });
1396
- var WhatsappSendMessageNode = {
1397
- label: "Whatsapp Send Message",
1398
- type: "WhatsappSendMessageNode",
1399
- category: "step",
1400
- description: "Send an open text message to a WhatsApp number",
1401
- icon: "\u{1F4AC}",
1402
- toolable: true,
1403
- group: "Social",
1404
- tags: {
1405
- execution: "async",
1406
- group: "Social"
1407
- },
1408
- fields: [
1409
- {
1410
- id: "phoneNumber",
1411
- label: "Phone Number",
1412
- type: "string",
1413
- required: true,
1414
- placeholder: "e.g., +5511999999999",
1415
- handle: {
1416
- type: "input",
1417
- label: "Phone Number",
1418
- name: "phoneNumber",
1419
- fieldType: "string"
1420
- }
1421
- },
1422
- {
1423
- id: "message",
1424
- label: "Message",
1425
- type: "textarea",
1426
- required: true,
1427
- placeholder: "Type your message here...",
1428
- handle: {
1429
- type: "input",
1430
- label: "Message",
1431
- name: "message",
1432
- fieldType: "string"
1433
- }
1434
- }
1435
- ]
1436
- };
1437
-
1438
- // src/nodes/social/whatsapp/message-trigger/data.ts
1439
- var WhatsappMessageTriggerNode = {
1440
- label: "Whatsapp Message Trigger",
1441
- type: "WhatsappMessageTriggerNode",
1442
- category: "input",
1443
- description: "Trigger when a message is received from a WhatsApp number",
1444
- icon: "\u{1F4F1}",
1445
- toolable: false,
1446
- group: "Social",
1447
- tags: {
1448
- execution: "async",
1449
- group: "Social"
1450
- },
1451
- fields: [
1452
- {
1453
- id: "phoneNumber",
1454
- label: "Phone Number",
1455
- type: "string",
1456
- required: true,
1457
- typeable: false,
1458
- handle: {
1459
- type: "output",
1460
- label: "Phone Number",
1461
- name: "phoneNumber",
1462
- fieldType: "string"
1463
- }
1464
- },
1465
- {
1466
- id: "userName",
1467
- label: "User Name",
1468
- type: "string",
1469
- required: true,
1470
- typeable: false,
1471
- handle: {
1472
- type: "output",
1473
- label: "User Name",
1474
- name: "userName",
1475
- fieldType: "string"
1476
- }
1477
- },
1478
- {
1479
- id: "message",
1480
- label: "Message",
1481
- type: "string",
1482
- required: true,
1483
- typeable: false,
1484
- handle: {
1485
- type: "output",
1486
- label: "Message",
1487
- name: "message",
1488
- fieldType: "string"
1489
- }
1490
- }
1491
- ]
1492
- };
1493
-
1494
- // src/nodes/consts/nodes.ts
1495
- var nodes = [
1496
- ChatInputNode,
1497
- ManualTriggerNode,
1498
- HttpGetInputNode,
1499
- // HttpPostInputNode,
1500
- // TransformNode,
1501
- ConcatNode,
1502
- OutputNode,
1503
- ChatOutputNode,
1504
- IaMessageNode,
1505
- IaAgentNode,
1506
- AiToolNode,
1507
- AiSupervisorNode,
1508
- WhatsappSendTemplateNode,
1509
- WhatsappSendMessageNode,
1510
- WhatsappMessageTriggerNode
1511
- ];
1512
- var nodes_default = nodes;
1513
-
1514
- // src/nodes/social/whatsapp/send-template/functions.ts
1515
- var BUSINESS_ACCOUNT_ID = "1079341674316936";
1516
- var NUMBER_ID = "700207253183039";
1517
- var TOKEN = "EAAUuy5eznhEBPQUOoF07SUTSVjgNIX9eZCWSKPYQhzHiXeEp4Qj3g47bZAPcZAgs8P2B5cZBH9YJjzq0HKNXfA14kaK5Cp2DZCmxzV60MgWlsY1yKavb2qXAQcydoHTTLKcWO53w6ZB7JNzZBeIpZBTb9cB0teRzfX3kjrZBc7utyKq2ZCZCCOQ74pZA28gnmQYzp24oZBQpf7BmuNHgndFVlTba5drxgcpERyNl1dUIDhky7NIruggZDZD";
1518
- var WhatsappStartChatFunction = async (fieldValues) => {
1519
- const { phoneNumber, template } = fieldValues;
1520
- const response = await fetch(`https://graph.facebook.com/v23.0/${NUMBER_ID}/messages`, {
1521
- method: "POST",
1522
- headers: {
1523
- "Authorization": `Bearer ${TOKEN}`,
1524
- "Content-Type": "application/json"
1525
- },
1526
- body: JSON.stringify({
1527
- messaging_product: "whatsapp",
1528
- to: phoneNumber,
1529
- type: "template",
1530
- template: {
1531
- name: template,
1532
- language: {
1533
- code: "pt_BR"
1534
- }
1535
- }
1536
- })
1537
- });
1538
- const data = await response.json();
1539
- if (!response.ok) {
1540
- throw new Error(`Failed to start chat: ${response.statusText}`);
1541
- }
1542
- return data;
1543
- };
1544
- var getMessageTemplates = async () => {
1545
- const response = await fetch(`https://graph.facebook.com/v23.0/${BUSINESS_ACCOUNT_ID}/message_templates`, {
1546
- method: "GET",
1547
- headers: {
1548
- "Authorization": `Bearer ${TOKEN}`
1549
- }
1550
- });
1551
- const data = await response.json();
1552
- return data;
1553
- };
1554
- var createMessageTemplate = async (payload) => {
1555
- const response = await fetch(`https://graph.facebook.com/v23.0/${BUSINESS_ACCOUNT_ID}/message_templates`, {
1556
- method: "POST",
1557
- headers: {
1558
- "Authorization": `Bearer ${TOKEN}`,
1559
- "Content-Type": "application/json"
1560
- },
1561
- body: JSON.stringify(payload)
1562
- });
1563
- const data = await response.json();
1564
- if (!response.ok) {
1565
- const errObj = data.error;
1566
- const msg = errObj?.message || response.statusText;
1567
- const enriched = new Error(`Failed to create template: ${msg}`);
1568
- enriched.details = data;
1569
- enriched.status = response.status;
1570
- throw enriched;
1571
- }
1572
- return data;
1573
- };
1574
-
1575
- // src/nodes/social/whatsapp/send-message/functions.ts
1576
- var NUMBER_ID2 = "700207253183039";
1577
- var TOKEN2 = "EAAUuy5eznhEBPWw62uE6cs4oZAW6WvpsiF9RBjTGDjg8H74GouBMl1MBifCuA572AVMp53T83pBuSaMJUcWMDIGxvXbxaU6RFTyXOuKkhUPkF3Boc7QbmRuUWSFuyvkjZCyA7ngAg2NXV8nYzzZCleSuFQD487NN2mat7sHPx2pMHuN95IcaevyKLnuz5Om2Bp36JihQweodc517aH2Krv70jqNKKzBjoGVziWNnOhULQZDZD";
1578
- var WhatsappSendMessageFunction = async (fieldValues) => {
1579
- const { phoneNumber, message } = fieldValues;
1580
- const response = await fetch(`https://graph.facebook.com/v23.0/${NUMBER_ID2}/messages`, {
1581
- method: "POST",
1582
- headers: {
1583
- "Authorization": `Bearer ${TOKEN2}`,
1584
- "Content-Type": "application/json"
1585
- },
1586
- body: JSON.stringify({
1587
- messaging_product: "whatsapp",
1588
- to: phoneNumber,
1589
- type: "text",
1590
- text: {
1591
- preview_url: false,
1592
- body: message
1593
- }
1594
- })
1595
- });
1596
- const data = await response.json();
1597
- if (!response.ok) {
1598
- const errObj = data.error;
1599
- const msg = errObj?.message || response.statusText;
1600
- const enriched = new Error(`Failed to send message: ${msg}`);
1601
- enriched.details = data;
1602
- enriched.status = response.status;
1603
- throw enriched;
1604
- }
1605
- return data;
1606
- };
1607
-
1608
- // src/nodes/consts/node-functions.ts
1609
- var nodeFunctions = {
1610
- ChatInput: ChatInputNodeFunction,
1611
- ChatOutput: ChatOutputNodeFunction,
1612
- HttpGetInput: HttpGetInputNodeFunction,
1613
- HttpPostInput: HttpPostInputNodeFunction,
1614
- ManualTrigger: ManualTriggerNodeFunction,
1615
- HttpOutput: HttpOutputNodeFunction,
1616
- ConcatNode: ConcatNodeFunction,
1617
- IaMessageNode: IaMessageNodeFunction,
1618
- IaAgentNode: IaAgentNodeFunction,
1619
- AiToolNode: AiToolNodeFunction,
1620
- AiSupervisorNode: AiSupervisorNodeFunction,
1621
- WhatsappNode: WhatsappStartChatFunction,
1622
- WhatsappSendMessageNode: WhatsappSendMessageFunction
1623
- };
1624
- var node_functions_default = nodeFunctions;
1625
-
1626
- // src/nodes/inputs/http/put/data.ts
1627
- var HttpPutInputNode = {
1628
- label: "Http PUT Input",
1629
- type: "HttpPutInput",
1630
- category: "input",
1631
- icon: "\u{1F4DD}",
1632
- description: "Node que representa uma rota PUT HTTP para atualiza\xE7\xE3o completa de recursos",
1633
- tags: {
1634
- execution: "sync",
1635
- group: "HTTP"
1636
- },
1637
- fields: [
1638
- {
1639
- id: "route",
1640
- label: "Route",
1641
- type: "route",
1642
- required: true,
1643
- placeholder: "/produtos/{id}"
1644
- },
1645
- {
1646
- id: "queryParams",
1647
- label: "Query Params",
1648
- type: "keyValue",
1649
- required: false,
1650
- handle: {
1651
- type: "output",
1652
- label: "Query Params",
1653
- name: "queryParams",
1654
- fieldType: "keyValue"
1655
- }
1656
- },
1657
- {
1658
- id: "headers",
1659
- label: "Headers",
1660
- type: "keyValue",
1661
- required: false,
1662
- handle: {
1663
- type: "output",
1664
- label: "Headers",
1665
- name: "headers",
1666
- fieldType: "keyValue"
1667
- }
1668
- },
1669
- {
1670
- id: "body",
1671
- label: "Body",
1672
- type: "object",
1673
- required: false,
1674
- handle: {
1675
- type: "output",
1676
- label: "Body",
1677
- name: "body",
1678
- fieldType: "object",
1679
- required: false
1680
- }
1681
- },
1682
- {
1683
- id: "ip",
1684
- label: "Request IP",
1685
- type: "string",
1686
- required: false,
1687
- typeable: false,
1688
- handle: {
1689
- type: "output",
1690
- label: "IP",
1691
- name: "ip",
1692
- fieldType: "string"
1693
- }
1694
- }
1695
- ]
1696
- };
1697
-
1698
- // src/nodes/inputs/http/put/function.ts
1699
- var HttpPutInputNodeFunction = (params) => {
1700
- const { request, fieldValues } = params;
1701
- const { queryParams: configQueryParams, headers: configHeaders, body: configBody } = fieldValues || {};
1702
- if (request.method !== "PUT") {
1703
- throw new Error("M\xE9todo HTTP inv\xE1lido");
1704
- }
1705
- const actualData = {
1706
- queryParams: request?.query || {},
1707
- headers: request?.headers || {},
1708
- body: request?.body || {},
1709
- ip: request?.ip || "127.0.0.1"
1710
- };
1711
- if (configQueryParams) {
1712
- const requiredParams = configQueryParams.filter((p) => p.required);
1713
- const missingParams = requiredParams.filter((p) => !actualData.queryParams[p.key]);
1714
- if (missingParams.length > 0) {
1715
- throw new Error(`Par\xE2metros obrigat\xF3rios ausentes: ${missingParams.map((p) => p.key).join(", ")}`);
1716
- }
1717
- }
1718
- if (configHeaders) {
1719
- const requiredHeaders = configHeaders.filter((h) => h.required);
1720
- const missingHeaders = requiredHeaders.filter((h) => !actualData.headers[h.key.toLowerCase()]);
1721
- if (missingHeaders.length > 0) {
1722
- throw new Error(`Headers obrigat\xF3rios ausentes: ${missingHeaders.map((h) => h.key).join(", ")}`);
1723
- }
1724
- }
1725
- if (configBody) {
1726
- const requiredBodyFields = configBody.filter((f) => f.required);
1727
- const missingBodyFields = requiredBodyFields.filter((f) => !actualData.body[f.key]);
1728
- if (missingBodyFields.length > 0) {
1729
- throw new Error(`Campos obrigat\xF3rios do body ausentes: ${missingBodyFields.map((f) => f.key).join(", ")}`);
1730
- }
1731
- }
1732
- return actualData;
1733
- };
1734
-
1735
- // src/nodes/inputs/http/put/schema.ts
1736
- import { z as z11 } from "zod";
1737
- var HttpPutInputNodeSchema = z11.object({
1738
- route: RouteSchema,
1739
- queryParams: z11.array(QueryParamSchema).optional().describe("Query parameters configuration"),
1740
- headers: z11.array(HeaderSchema).optional().describe("Headers configuration"),
1741
- body: z11.array(BodyFieldSchema).optional().describe("Body fields configuration")
1742
- });
1743
-
1744
- // src/nodes/inputs/http/delete/data.ts
1745
- var HttpDeleteInputNode = {
1746
- label: "Http DELETE Input",
1747
- type: "HttpDeleteInput",
1748
- category: "input",
1749
- icon: "\u{1F5D1}\uFE0F",
1750
- description: "Node que representa uma rota DELETE HTTP para remo\xE7\xE3o de recursos",
1751
- tags: {
1752
- execution: "sync",
1753
- group: "HTTP"
1754
- },
1755
- fields: [
1756
- {
1757
- id: "route",
1758
- label: "Route",
1759
- type: "route",
1760
- required: true,
1761
- placeholder: "/produtos/{id}"
1762
- },
1763
- {
1764
- id: "queryParams",
1765
- label: "Query Params",
1766
- type: "keyValue",
1767
- required: false,
1768
- handle: {
1769
- type: "output",
1770
- label: "Query Params",
1771
- name: "queryParams",
1772
- fieldType: "keyValue"
1773
- }
1774
- },
1775
- {
1776
- id: "headers",
1777
- label: "Headers",
1778
- type: "keyValue",
1779
- required: false,
1780
- handle: {
1781
- type: "output",
1782
- label: "Headers",
1783
- name: "headers",
1784
- fieldType: "keyValue"
1785
- }
1786
- },
1787
- {
1788
- id: "ip",
1789
- label: "Request IP",
1790
- type: "string",
1791
- required: false,
1792
- typeable: false,
1793
- handle: {
1794
- type: "output",
1795
- label: "IP",
1796
- name: "ip",
1797
- fieldType: "string"
1798
- }
1799
- }
1800
- ]
1801
- };
1802
-
1803
- // src/nodes/inputs/http/delete/function.ts
1804
- var HttpDeleteInputNodeFunction = async (params) => {
1805
- const { request, fieldValues } = params;
1806
- const { queryParams: configQueryParams, headers: configHeaders } = fieldValues || {};
1807
- if (request.method !== "DELETE") {
1808
- throw new Error("M\xE9todo HTTP inv\xE1lido");
1809
- }
1810
- const actualData = {
1811
- queryParams: request?.query || {},
1812
- headers: request?.headers || {},
1813
- ip: request?.ip || "127.0.0.1"
1814
- };
1815
- if (configQueryParams) {
1816
- const requiredParams = configQueryParams.filter((p) => p.required);
1817
- const missingParams = requiredParams.filter((p) => !actualData.queryParams[p.key]);
1818
- if (missingParams.length > 0) {
1819
- throw new Error(`Par\xE2metros obrigat\xF3rios ausentes: ${missingParams.map((p) => p.key).join(", ")}`);
1820
- }
1821
- }
1822
- if (configHeaders) {
1823
- const requiredHeaders = configHeaders.filter((h) => h.required);
1824
- const missingHeaders = requiredHeaders.filter((h) => !actualData.headers[h.key.toLowerCase()]);
1825
- if (missingHeaders.length > 0) {
1826
- throw new Error(`Headers obrigat\xF3rios ausentes: ${missingHeaders.map((h) => h.key).join(", ")}`);
1827
- }
1828
- }
1829
- return actualData;
1830
- };
1831
-
1832
- // src/nodes/inputs/http/delete/schema.ts
1833
- import { z as z12 } from "zod";
1834
- var HttpDeleteInputNodeSchema = z12.object({
1835
- route: RouteSchema,
1836
- queryParams: z12.array(QueryParamSchema).optional().describe("Query parameters configuration"),
1837
- headers: z12.array(HeaderSchema).optional().describe("Headers configuration")
1838
- });
1839
-
1840
- // src/nodes/inputs/http/patch/data.ts
1841
- var HttpPatchInputNode = {
1842
- label: "Http PATCH Input",
1843
- type: "HttpPatchInput",
1844
- category: "input",
1845
- icon: "\u{1F527}",
1846
- description: "Node que representa uma rota PATCH HTTP para atualiza\xE7\xE3o parcial de recursos",
1847
- tags: {
1848
- execution: "sync",
1849
- group: "HTTP"
1850
- },
1851
- fields: [
1852
- {
1853
- id: "route",
1854
- label: "Route",
1855
- type: "route",
1856
- required: true,
1857
- placeholder: "/produtos/{id}"
1858
- },
1859
- {
1860
- id: "queryParams",
1861
- label: "Query Params",
1862
- type: "keyValue",
1863
- required: false,
1864
- handle: {
1865
- type: "output",
1866
- label: "Query Params",
1867
- name: "queryParams",
1868
- fieldType: "keyValue"
1869
- }
1870
- },
1871
- {
1872
- id: "headers",
1873
- label: "Headers",
1874
- type: "keyValue",
1875
- required: false,
1876
- handle: {
1877
- type: "output",
1878
- label: "Headers",
1879
- name: "headers",
1880
- fieldType: "keyValue"
1881
- }
1882
- },
1883
- {
1884
- id: "body",
1885
- label: "Body",
1886
- type: "object",
1887
- required: false,
1888
- handle: {
1889
- type: "output",
1890
- label: "Body",
1891
- name: "body",
1892
- fieldType: "object",
1893
- required: false
1894
- }
1895
- },
1896
- {
1897
- id: "ip",
1898
- label: "Request IP",
1899
- type: "string",
1900
- required: false,
1901
- typeable: false,
1902
- handle: {
1903
- type: "output",
1904
- label: "IP",
1905
- name: "ip",
1906
- fieldType: "string"
1907
- }
1908
- }
1909
- ]
1910
- };
1911
-
1912
- // src/nodes/inputs/http/patch/function.ts
1913
- var HttpPatchInputNodeFunction = (params) => {
1914
- const { request, fieldValues } = params;
1915
- const { queryParams: configQueryParams, headers: configHeaders, body: configBody } = fieldValues || {};
1916
- if (request.method !== "PATCH") {
1917
- throw new Error("M\xE9todo HTTP inv\xE1lido");
1918
- }
1919
- const actualData = {
1920
- queryParams: request?.query || {},
1921
- headers: request?.headers || {},
1922
- body: request?.body || {},
1923
- ip: request?.ip || "127.0.0.1"
1924
- };
1925
- if (configQueryParams) {
1926
- const requiredParams = configQueryParams.filter((p) => p.required);
1927
- const missingParams = requiredParams.filter((p) => !actualData.queryParams[p.key]);
1928
- if (missingParams.length > 0) {
1929
- throw new Error(`Par\xE2metros obrigat\xF3rios ausentes: ${missingParams.map((p) => p.key).join(", ")}`);
1930
- }
1931
- }
1932
- if (configHeaders) {
1933
- const requiredHeaders = configHeaders.filter((h) => h.required);
1934
- const missingHeaders = requiredHeaders.filter((h) => !actualData.headers[h.key.toLowerCase()]);
1935
- if (missingHeaders.length > 0) {
1936
- throw new Error(`Headers obrigat\xF3rios ausentes: ${missingHeaders.map((h) => h.key).join(", ")}`);
1937
- }
1938
- }
1939
- if (configBody) {
1940
- const requiredBodyFields = configBody.filter((f) => f.required);
1941
- const missingBodyFields = requiredBodyFields.filter((f) => !actualData.body[f.key]);
1942
- if (missingBodyFields.length > 0) {
1943
- throw new Error(`Campos obrigat\xF3rios do body ausentes: ${missingBodyFields.map((f) => f.key).join(", ")}`);
1944
- }
1945
- }
1946
- return actualData;
1947
- };
1948
-
1949
- // src/nodes/inputs/http/patch/schema.ts
1950
- import { z as z13 } from "zod";
1951
- var HttpPatchInputNodeSchema = z13.object({
1952
- route: RouteSchema,
1953
- queryParams: z13.array(QueryParamSchema).optional().describe("Query parameters configuration"),
1954
- headers: z13.array(HeaderSchema).optional().describe("Headers configuration"),
1955
- body: z13.array(BodyFieldSchema).optional().describe("Body fields configuration")
1956
- });
1957
-
1958
- // src/nodes/inputs/http/utils.ts
1959
- var HTTP_NODE_TYPES = {
1960
- GET: "HttpGetInput",
1961
- POST: "HttpPostInput",
1962
- PUT: "HttpPutInput",
1963
- DELETE: "HttpDeleteInput",
1964
- PATCH: "HttpPatchInput"
1965
- };
1966
- var HTTP_METHODS = ["GET", "POST", "PUT", "DELETE", "PATCH"];
1967
- var getHttpNodesTypes = () => {
1968
- return [
1969
- HttpGetInputNode,
1970
- HttpPostInputNode,
1971
- HttpPutInputNode,
1972
- HttpDeleteInputNode,
1973
- HttpPatchInputNode
1974
- ].map((node) => node.type);
1975
- };
1976
- var getHttpNodeTypesArray = () => {
1977
- return Object.values(HTTP_NODE_TYPES);
1978
- };
1979
- var isHttpInputNode = (nodeType) => {
1980
- return getHttpNodeTypesArray().some((httpType) => nodeType.includes(httpType));
1981
- };
1982
- var isHttpMethodNode = (nodeType, method) => {
1983
- return nodeType.includes(HTTP_NODE_TYPES[method]);
1984
- };
1985
- var extractHttpMethodFromNodeType = (nodeType) => {
1986
- for (const [method, nodeTypeValue] of Object.entries(HTTP_NODE_TYPES)) {
1987
- if (nodeType.includes(nodeTypeValue)) {
1988
- return method;
1989
- }
1990
- }
1991
- return "GET";
1992
- };
1993
- var getHttpMethodFromNodeType = extractHttpMethodFromNodeType;
1994
- var isAnyHttpInputNode = (nodeType) => {
1995
- return nodeType.includes("Http") && nodeType.includes("Input");
1996
- };
1997
- var getHttpNodeTypeStrings = () => {
1998
- return Object.values(HTTP_NODE_TYPES);
1999
- };
2000
- var isHttpInputFriendlyId = (friendlyId) => {
2001
- return friendlyId.includes("Http") && friendlyId.includes("Input");
2002
- };
2003
- var getHttpMethodFromFriendlyId = (friendlyId) => {
2004
- return extractHttpMethodFromNodeType(friendlyId);
2005
- };
2006
- export {
2007
- AiSupervisorNode,
2008
- AiSupervisorNodeFunction,
2009
- AiSupervisorNodeSchema,
2010
- AiToolNode,
2011
- AiToolNodeFunction,
2012
- AiToolNodeSchema,
2013
- BodyFieldSchema,
2014
- CustomToolSchema,
2015
- HTTP_METHODS,
2016
- HTTP_NODE_TYPES,
2017
- HeaderSchema,
2018
- HttpDeleteInputNode,
2019
- HttpDeleteInputNodeFunction,
2020
- HttpDeleteInputNodeSchema,
2021
- HttpGetInputNode,
2022
- HttpGetInputNodeFunction,
2023
- HttpGetInputNodeSchema,
2024
- HttpPatchInputNode,
2025
- HttpPatchInputNodeFunction,
2026
- HttpPatchInputNodeSchema,
2027
- HttpPostInputNode,
2028
- HttpPostInputNodeFunction,
2029
- HttpPostInputNodeSchema,
2030
- HttpPutInputNode,
2031
- HttpPutInputNodeFunction,
2032
- HttpPutInputNodeSchema,
2033
- IaAgentNode,
2034
- IaAgentNodeFunction,
2035
- IaAgentNodeSchema,
2036
- IaMessageNode,
2037
- IaMessageNodeFunction,
2038
- IaMessageNodeSchema,
2039
- QueryParamSchema,
2040
- RouteSchema,
2041
- WhatsappMessageTriggerNode,
2042
- WhatsappSendMessageFunction,
2043
- WhatsappSendMessageNode,
2044
- WhatsappSendMessageNodeSchema,
2045
- WhatsappSendTemplateNode,
2046
- WhatsappSendTemplateNodeSchema,
2047
- WhatsappStartChatFunction,
2048
- createMessageTemplate,
2049
- extractHttpMethodFromNodeType,
2050
- getHttpMethodFromFriendlyId,
2051
- getHttpMethodFromNodeType,
2052
- getHttpNodeTypeStrings,
2053
- getHttpNodeTypesArray,
2054
- getHttpNodesTypes,
2055
- getMessageTemplates,
2056
- isAnyHttpInputNode,
2057
- isHttpInputFriendlyId,
2058
- isHttpInputNode,
2059
- isHttpMethodNode,
2060
- node_functions_default as nodeFunctions,
2061
- nodes_default as nodes,
2062
- schemas
2063
- };